]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.11.9-201311222137.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.11.9-201311222137.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 06379bd..abdd9a8 100644
285 --- a/Makefile
286 +++ b/Makefile
287 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
288
289 HOSTCC = gcc
290 HOSTCXX = g++
291 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
292 -HOSTCXXFLAGS = -O2
293 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
294 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
295 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
296
297 # Decide whether to build built-in, modular, or both.
298 # Normally, just do built-in.
299 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
300 # Rules shared between *config targets and build targets
301
302 # Basic helpers built in scripts/
303 -PHONY += scripts_basic
304 -scripts_basic:
305 +PHONY += scripts_basic gcc-plugins
306 +scripts_basic: gcc-plugins
307 $(Q)$(MAKE) $(build)=scripts/basic
308 $(Q)rm -f .tmp_quiet_recordmcount
309
310 @@ -576,6 +577,65 @@ else
311 KBUILD_CFLAGS += -O2
312 endif
313
314 +ifndef DISABLE_PAX_PLUGINS
315 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
316 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
317 +else
318 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
319 +endif
320 +ifneq ($(PLUGINCC),)
321 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
322 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
323 +endif
324 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
325 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
326 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
327 +endif
328 +ifdef CONFIG_KALLOCSTAT_PLUGIN
329 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
330 +endif
331 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
332 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
333 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
334 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
335 +endif
336 +ifdef CONFIG_CHECKER_PLUGIN
337 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
338 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
339 +endif
340 +endif
341 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
342 +ifdef CONFIG_PAX_SIZE_OVERFLOW
343 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
344 +endif
345 +ifdef CONFIG_PAX_LATENT_ENTROPY
346 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
347 +endif
348 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
349 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
350 +endif
351 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
352 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
353 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
354 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
355 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
356 +ifeq ($(KBUILD_EXTMOD),)
357 +gcc-plugins:
358 + $(Q)$(MAKE) $(build)=tools/gcc
359 +else
360 +gcc-plugins: ;
361 +endif
362 +else
363 +gcc-plugins:
364 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
365 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
366 +else
367 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
368 +endif
369 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
370 +endif
371 +endif
372 +
373 include $(srctree)/arch/$(SRCARCH)/Makefile
374
375 ifdef CONFIG_READABLE_ASM
376 @@ -733,7 +793,7 @@ export mod_sign_cmd
377
378
379 ifeq ($(KBUILD_EXTMOD),)
380 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
381 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
382
383 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
384 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
385 @@ -782,6 +842,8 @@ endif
386
387 # The actual objects are generated when descending,
388 # make sure no implicit rule kicks in
389 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
390 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
391 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
392
393 # Handle descending into subdirectories listed in $(vmlinux-dirs)
394 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
395 # Error messages still appears in the original language
396
397 PHONY += $(vmlinux-dirs)
398 -$(vmlinux-dirs): prepare scripts
399 +$(vmlinux-dirs): gcc-plugins prepare scripts
400 $(Q)$(MAKE) $(build)=$@
401
402 # Store (new) KERNELRELEASE string in include/config/kernel.release
403 @@ -835,6 +897,7 @@ prepare0: archprepare FORCE
404 $(Q)$(MAKE) $(build)=.
405
406 # All the preparing..
407 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
408 prepare: prepare0
409
410 # Generate some files
411 @@ -942,6 +1005,8 @@ all: modules
412 # using awk while concatenating to the final file.
413
414 PHONY += modules
415 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
416 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
417 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
418 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
419 @$(kecho) ' Building modules, stage 2.';
420 @@ -957,7 +1022,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
421
422 # Target to prepare building external modules
423 PHONY += modules_prepare
424 -modules_prepare: prepare scripts
425 +modules_prepare: gcc-plugins prepare scripts
426
427 # Target to install modules
428 PHONY += modules_install
429 @@ -1023,7 +1088,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
430 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
431 signing_key.priv signing_key.x509 x509.genkey \
432 extra_certificates signing_key.x509.keyid \
433 - signing_key.x509.signer
434 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
435
436 # clean - Delete most, but leave enough to build external modules
437 #
438 @@ -1063,6 +1128,7 @@ distclean: mrproper
439 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
440 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
441 -o -name '.*.rej' \
442 + -o -name '.*.rej' -o -name '*.so' \
443 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
444 -type f -print | xargs rm -f
445
446 @@ -1224,6 +1290,8 @@ PHONY += $(module-dirs) modules
447 $(module-dirs): crmodverdir $(objtree)/Module.symvers
448 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
449
450 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
451 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
452 modules: $(module-dirs)
453 @$(kecho) ' Building modules, stage 2.';
454 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
455 @@ -1363,17 +1431,21 @@ else
456 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
457 endif
458
459 -%.s: %.c prepare scripts FORCE
460 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 +%.s: %.c gcc-plugins prepare scripts FORCE
463 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
464 %.i: %.c prepare scripts FORCE
465 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
466 -%.o: %.c prepare scripts FORCE
467 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
468 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
469 +%.o: %.c gcc-plugins prepare scripts FORCE
470 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
471 %.lst: %.c prepare scripts FORCE
472 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
473 -%.s: %.S prepare scripts FORCE
474 +%.s: %.S gcc-plugins prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.S prepare scripts FORCE
477 +%.o: %.S gcc-plugins prepare scripts FORCE
478 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
479 %.symtypes: %.c prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 @@ -1383,11 +1455,15 @@ endif
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir)
485 -%/: prepare scripts FORCE
486 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
487 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
488 +%/: gcc-plugins prepare scripts FORCE
489 $(cmd_crmodverdir)
490 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
491 $(build)=$(build-dir)
492 -%.ko: prepare scripts FORCE
493 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
494 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
495 +%.ko: gcc-plugins prepare scripts FORCE
496 $(cmd_crmodverdir)
497 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
498 $(build)=$(build-dir) $(@:.ko=.o)
499 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
500 index 78b03ef..da28a51 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
504 #define atomic_dec(v) atomic_sub(1,(v))
505 #define atomic64_dec(v) atomic64_sub(1,(v))
506
507 +#define atomic64_read_unchecked(v) atomic64_read(v)
508 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
509 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
510 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
511 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
512 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
513 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
514 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
515 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
516 +
517 #define smp_mb__before_atomic_dec() smp_mb()
518 #define smp_mb__after_atomic_dec() smp_mb()
519 #define smp_mb__before_atomic_inc() smp_mb()
520 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
521 index ad368a9..fbe0f25 100644
522 --- a/arch/alpha/include/asm/cache.h
523 +++ b/arch/alpha/include/asm/cache.h
524 @@ -4,19 +4,19 @@
525 #ifndef __ARCH_ALPHA_CACHE_H
526 #define __ARCH_ALPHA_CACHE_H
527
528 +#include <linux/const.h>
529
530 /* Bytes per L1 (data) cache line. */
531 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
532 -# define L1_CACHE_BYTES 64
533 # define L1_CACHE_SHIFT 6
534 #else
535 /* Both EV4 and EV5 are write-through, read-allocate,
536 direct-mapped, physical.
537 */
538 -# define L1_CACHE_BYTES 32
539 # define L1_CACHE_SHIFT 5
540 #endif
541
542 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
543 #define SMP_CACHE_BYTES L1_CACHE_BYTES
544
545 #endif
546 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
547 index 968d999..d36b2df 100644
548 --- a/arch/alpha/include/asm/elf.h
549 +++ b/arch/alpha/include/asm/elf.h
550 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
551
552 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
553
554 +#ifdef CONFIG_PAX_ASLR
555 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
556 +
557 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
558 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
559 +#endif
560 +
561 /* $0 is set by ld.so to a pointer to a function which might be
562 registered using atexit. This provides a mean for the dynamic
563 linker to call DT_FINI functions for shared libraries that have
564 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
565 index bc2a0da..8ad11ee 100644
566 --- a/arch/alpha/include/asm/pgalloc.h
567 +++ b/arch/alpha/include/asm/pgalloc.h
568 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
569 pgd_set(pgd, pmd);
570 }
571
572 +static inline void
573 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
574 +{
575 + pgd_populate(mm, pgd, pmd);
576 +}
577 +
578 extern pgd_t *pgd_alloc(struct mm_struct *mm);
579
580 static inline void
581 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
582 index d8f9b7e..f6222fa 100644
583 --- a/arch/alpha/include/asm/pgtable.h
584 +++ b/arch/alpha/include/asm/pgtable.h
585 @@ -102,6 +102,17 @@ struct vm_area_struct;
586 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
587 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
588 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
589 +
590 +#ifdef CONFIG_PAX_PAGEEXEC
591 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
592 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
593 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
594 +#else
595 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
596 +# define PAGE_COPY_NOEXEC PAGE_COPY
597 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
598 +#endif
599 +
600 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
601
602 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
603 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
604 index 2fd00b7..cfd5069 100644
605 --- a/arch/alpha/kernel/module.c
606 +++ b/arch/alpha/kernel/module.c
607 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
608
609 /* The small sections were sorted to the end of the segment.
610 The following should definitely cover them. */
611 - gp = (u64)me->module_core + me->core_size - 0x8000;
612 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
613 got = sechdrs[me->arch.gotsecindex].sh_addr;
614
615 for (i = 0; i < n; i++) {
616 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
617 index 1402fcc..0b1abd2 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1298,10 +1298,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
621 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
622
623 static unsigned long
624 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
625 - unsigned long limit)
626 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
627 + unsigned long limit, unsigned long flags)
628 {
629 struct vm_unmapped_area_info info;
630 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
631
632 info.flags = 0;
633 info.length = len;
634 @@ -1309,6 +1310,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 info.high_limit = limit;
636 info.align_mask = 0;
637 info.align_offset = 0;
638 + info.threadstack_offset = offset;
639 return vm_unmapped_area(&info);
640 }
641
642 @@ -1341,20 +1343,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
643 merely specific addresses, but regions of memory -- perhaps
644 this feature should be incorporated into all ports? */
645
646 +#ifdef CONFIG_PAX_RANDMMAP
647 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
648 +#endif
649 +
650 if (addr) {
651 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
652 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
653 if (addr != (unsigned long) -ENOMEM)
654 return addr;
655 }
656
657 /* Next, try allocating at TASK_UNMAPPED_BASE. */
658 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
659 - len, limit);
660 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
661 +
662 if (addr != (unsigned long) -ENOMEM)
663 return addr;
664
665 /* Finally, try allocating in low memory. */
666 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
667 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
668
669 return addr;
670 }
671 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
672 index 0c4132d..88f0d53 100644
673 --- a/arch/alpha/mm/fault.c
674 +++ b/arch/alpha/mm/fault.c
675 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
676 __reload_thread(pcb);
677 }
678
679 +#ifdef CONFIG_PAX_PAGEEXEC
680 +/*
681 + * PaX: decide what to do with offenders (regs->pc = fault address)
682 + *
683 + * returns 1 when task should be killed
684 + * 2 when patched PLT trampoline was detected
685 + * 3 when unpatched PLT trampoline was detected
686 + */
687 +static int pax_handle_fetch_fault(struct pt_regs *regs)
688 +{
689 +
690 +#ifdef CONFIG_PAX_EMUPLT
691 + int err;
692 +
693 + do { /* PaX: patched PLT emulation #1 */
694 + unsigned int ldah, ldq, jmp;
695 +
696 + err = get_user(ldah, (unsigned int *)regs->pc);
697 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
698 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
699 +
700 + if (err)
701 + break;
702 +
703 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
704 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
705 + jmp == 0x6BFB0000U)
706 + {
707 + unsigned long r27, addr;
708 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
709 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
710 +
711 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
712 + err = get_user(r27, (unsigned long *)addr);
713 + if (err)
714 + break;
715 +
716 + regs->r27 = r27;
717 + regs->pc = r27;
718 + return 2;
719 + }
720 + } while (0);
721 +
722 + do { /* PaX: patched PLT emulation #2 */
723 + unsigned int ldah, lda, br;
724 +
725 + err = get_user(ldah, (unsigned int *)regs->pc);
726 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
727 + err |= get_user(br, (unsigned int *)(regs->pc+8));
728 +
729 + if (err)
730 + break;
731 +
732 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
733 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
734 + (br & 0xFFE00000U) == 0xC3E00000U)
735 + {
736 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
737 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
738 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
739 +
740 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
741 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + return 2;
743 + }
744 + } while (0);
745 +
746 + do { /* PaX: unpatched PLT emulation */
747 + unsigned int br;
748 +
749 + err = get_user(br, (unsigned int *)regs->pc);
750 +
751 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
752 + unsigned int br2, ldq, nop, jmp;
753 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
754 +
755 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
756 + err = get_user(br2, (unsigned int *)addr);
757 + err |= get_user(ldq, (unsigned int *)(addr+4));
758 + err |= get_user(nop, (unsigned int *)(addr+8));
759 + err |= get_user(jmp, (unsigned int *)(addr+12));
760 + err |= get_user(resolver, (unsigned long *)(addr+16));
761 +
762 + if (err)
763 + break;
764 +
765 + if (br2 == 0xC3600000U &&
766 + ldq == 0xA77B000CU &&
767 + nop == 0x47FF041FU &&
768 + jmp == 0x6B7B0000U)
769 + {
770 + regs->r28 = regs->pc+4;
771 + regs->r27 = addr+16;
772 + regs->pc = resolver;
773 + return 3;
774 + }
775 + }
776 + } while (0);
777 +#endif
778 +
779 + return 1;
780 +}
781 +
782 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
783 +{
784 + unsigned long i;
785 +
786 + printk(KERN_ERR "PAX: bytes at PC: ");
787 + for (i = 0; i < 5; i++) {
788 + unsigned int c;
789 + if (get_user(c, (unsigned int *)pc+i))
790 + printk(KERN_CONT "???????? ");
791 + else
792 + printk(KERN_CONT "%08x ", c);
793 + }
794 + printk("\n");
795 +}
796 +#endif
797
798 /*
799 * This routine handles page faults. It determines the address,
800 @@ -133,8 +251,29 @@ retry:
801 good_area:
802 si_code = SEGV_ACCERR;
803 if (cause < 0) {
804 - if (!(vma->vm_flags & VM_EXEC))
805 + if (!(vma->vm_flags & VM_EXEC)) {
806 +
807 +#ifdef CONFIG_PAX_PAGEEXEC
808 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
809 + goto bad_area;
810 +
811 + up_read(&mm->mmap_sem);
812 + switch (pax_handle_fetch_fault(regs)) {
813 +
814 +#ifdef CONFIG_PAX_EMUPLT
815 + case 2:
816 + case 3:
817 + return;
818 +#endif
819 +
820 + }
821 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
822 + do_group_exit(SIGKILL);
823 +#else
824 goto bad_area;
825 +#endif
826 +
827 + }
828 } else if (!cause) {
829 /* Allow reads even for write-only mappings */
830 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
831 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
832 index 43594d5..da71e62 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1791,7 +1791,7 @@ config ALIGNMENT_TRAP
836
837 config UACCESS_WITH_MEMCPY
838 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
839 - depends on MMU
840 + depends on MMU && !PAX_MEMORY_UDEREF
841 default y if CPU_FEROCEON
842 help
843 Implement faster copy_to_user and clear_user methods for CPU
844 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
845 index da1c77d..2ee6056 100644
846 --- a/arch/arm/include/asm/atomic.h
847 +++ b/arch/arm/include/asm/atomic.h
848 @@ -17,17 +17,35 @@
849 #include <asm/barrier.h>
850 #include <asm/cmpxchg.h>
851
852 +#ifdef CONFIG_GENERIC_ATOMIC64
853 +#include <asm-generic/atomic64.h>
854 +#endif
855 +
856 #define ATOMIC_INIT(i) { (i) }
857
858 #ifdef __KERNEL__
859
860 +#define _ASM_EXTABLE(from, to) \
861 +" .pushsection __ex_table,\"a\"\n"\
862 +" .align 3\n" \
863 +" .long " #from ", " #to"\n" \
864 +" .popsection"
865 +
866 /*
867 * On ARM, ordinary assignment (str instruction) doesn't clear the local
868 * strex/ldrex monitor on some implementations. The reason we can use it for
869 * atomic_set() is the clrex or dummy strex done on every exception return.
870 */
871 #define atomic_read(v) (*(volatile int *)&(v)->counter)
872 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
873 +{
874 + return v->counter;
875 +}
876 #define atomic_set(v,i) (((v)->counter) = (i))
877 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
878 +{
879 + v->counter = i;
880 +}
881
882 #if __LINUX_ARM_ARCH__ >= 6
883
884 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
885 int result;
886
887 __asm__ __volatile__("@ atomic_add\n"
888 +"1: ldrex %1, [%3]\n"
889 +" adds %0, %1, %4\n"
890 +
891 +#ifdef CONFIG_PAX_REFCOUNT
892 +" bvc 3f\n"
893 +"2: bkpt 0xf103\n"
894 +"3:\n"
895 +#endif
896 +
897 +" strex %1, %0, [%3]\n"
898 +" teq %1, #0\n"
899 +" bne 1b"
900 +
901 +#ifdef CONFIG_PAX_REFCOUNT
902 +"\n4:\n"
903 + _ASM_EXTABLE(2b, 4b)
904 +#endif
905 +
906 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
907 + : "r" (&v->counter), "Ir" (i)
908 + : "cc");
909 +}
910 +
911 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
912 +{
913 + unsigned long tmp;
914 + int result;
915 +
916 + __asm__ __volatile__("@ atomic_add_unchecked\n"
917 "1: ldrex %0, [%3]\n"
918 " add %0, %0, %4\n"
919 " strex %1, %0, [%3]\n"
920 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
921 smp_mb();
922
923 __asm__ __volatile__("@ atomic_add_return\n"
924 +"1: ldrex %1, [%3]\n"
925 +" adds %0, %1, %4\n"
926 +
927 +#ifdef CONFIG_PAX_REFCOUNT
928 +" bvc 3f\n"
929 +" mov %0, %1\n"
930 +"2: bkpt 0xf103\n"
931 +"3:\n"
932 +#endif
933 +
934 +" strex %1, %0, [%3]\n"
935 +" teq %1, #0\n"
936 +" bne 1b"
937 +
938 +#ifdef CONFIG_PAX_REFCOUNT
939 +"\n4:\n"
940 + _ASM_EXTABLE(2b, 4b)
941 +#endif
942 +
943 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
944 + : "r" (&v->counter), "Ir" (i)
945 + : "cc");
946 +
947 + smp_mb();
948 +
949 + return result;
950 +}
951 +
952 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
953 +{
954 + unsigned long tmp;
955 + int result;
956 +
957 + smp_mb();
958 +
959 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
960 "1: ldrex %0, [%3]\n"
961 " add %0, %0, %4\n"
962 " strex %1, %0, [%3]\n"
963 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
964 int result;
965
966 __asm__ __volatile__("@ atomic_sub\n"
967 +"1: ldrex %1, [%3]\n"
968 +" subs %0, %1, %4\n"
969 +
970 +#ifdef CONFIG_PAX_REFCOUNT
971 +" bvc 3f\n"
972 +"2: bkpt 0xf103\n"
973 +"3:\n"
974 +#endif
975 +
976 +" strex %1, %0, [%3]\n"
977 +" teq %1, #0\n"
978 +" bne 1b"
979 +
980 +#ifdef CONFIG_PAX_REFCOUNT
981 +"\n4:\n"
982 + _ASM_EXTABLE(2b, 4b)
983 +#endif
984 +
985 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
986 + : "r" (&v->counter), "Ir" (i)
987 + : "cc");
988 +}
989 +
990 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
991 +{
992 + unsigned long tmp;
993 + int result;
994 +
995 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
996 "1: ldrex %0, [%3]\n"
997 " sub %0, %0, %4\n"
998 " strex %1, %0, [%3]\n"
999 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1000 smp_mb();
1001
1002 __asm__ __volatile__("@ atomic_sub_return\n"
1003 -"1: ldrex %0, [%3]\n"
1004 -" sub %0, %0, %4\n"
1005 +"1: ldrex %1, [%3]\n"
1006 +" subs %0, %1, %4\n"
1007 +
1008 +#ifdef CONFIG_PAX_REFCOUNT
1009 +" bvc 3f\n"
1010 +" mov %0, %1\n"
1011 +"2: bkpt 0xf103\n"
1012 +"3:\n"
1013 +#endif
1014 +
1015 " strex %1, %0, [%3]\n"
1016 " teq %1, #0\n"
1017 " bne 1b"
1018 +
1019 +#ifdef CONFIG_PAX_REFCOUNT
1020 +"\n4:\n"
1021 + _ASM_EXTABLE(2b, 4b)
1022 +#endif
1023 +
1024 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1025 : "r" (&v->counter), "Ir" (i)
1026 : "cc");
1027 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1028 return oldval;
1029 }
1030
1031 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1032 +{
1033 + unsigned long oldval, res;
1034 +
1035 + smp_mb();
1036 +
1037 + do {
1038 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1039 + "ldrex %1, [%3]\n"
1040 + "mov %0, #0\n"
1041 + "teq %1, %4\n"
1042 + "strexeq %0, %5, [%3]\n"
1043 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1044 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1045 + : "cc");
1046 + } while (res);
1047 +
1048 + smp_mb();
1049 +
1050 + return oldval;
1051 +}
1052 +
1053 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1054 {
1055 unsigned long tmp, tmp2;
1056 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1057
1058 return val;
1059 }
1060 +
1061 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1062 +{
1063 + return atomic_add_return(i, v);
1064 +}
1065 +
1066 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1067 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1068 +{
1069 + (void) atomic_add_return(i, v);
1070 +}
1071
1072 static inline int atomic_sub_return(int i, atomic_t *v)
1073 {
1074 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1075 return val;
1076 }
1077 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1078 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1079 +{
1080 + (void) atomic_sub_return(i, v);
1081 +}
1082
1083 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1084 {
1085 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1086 return ret;
1087 }
1088
1089 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1090 +{
1091 + return atomic_cmpxchg(v, old, new);
1092 +}
1093 +
1094 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1095 {
1096 unsigned long flags;
1097 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1098 #endif /* __LINUX_ARM_ARCH__ */
1099
1100 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1101 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1102 +{
1103 + return xchg(&v->counter, new);
1104 +}
1105
1106 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1107 {
1108 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1109 }
1110
1111 #define atomic_inc(v) atomic_add(1, v)
1112 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1113 +{
1114 + atomic_add_unchecked(1, v);
1115 +}
1116 #define atomic_dec(v) atomic_sub(1, v)
1117 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1118 +{
1119 + atomic_sub_unchecked(1, v);
1120 +}
1121
1122 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1123 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1124 +{
1125 + return atomic_add_return_unchecked(1, v) == 0;
1126 +}
1127 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1128 #define atomic_inc_return(v) (atomic_add_return(1, v))
1129 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1130 +{
1131 + return atomic_add_return_unchecked(1, v);
1132 +}
1133 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1134 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1135
1136 @@ -241,6 +428,14 @@ typedef struct {
1137 u64 __aligned(8) counter;
1138 } atomic64_t;
1139
1140 +#ifdef CONFIG_PAX_REFCOUNT
1141 +typedef struct {
1142 + u64 __aligned(8) counter;
1143 +} atomic64_unchecked_t;
1144 +#else
1145 +typedef atomic64_t atomic64_unchecked_t;
1146 +#endif
1147 +
1148 #define ATOMIC64_INIT(i) { (i) }
1149
1150 #ifdef CONFIG_ARM_LPAE
1151 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1152 return result;
1153 }
1154
1155 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1156 +{
1157 + u64 result;
1158 +
1159 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1160 +" ldrd %0, %H0, [%1]"
1161 + : "=&r" (result)
1162 + : "r" (&v->counter), "Qo" (v->counter)
1163 + );
1164 +
1165 + return result;
1166 +}
1167 +
1168 static inline void atomic64_set(atomic64_t *v, u64 i)
1169 {
1170 __asm__ __volatile__("@ atomic64_set\n"
1171 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1172 : "r" (&v->counter), "r" (i)
1173 );
1174 }
1175 +
1176 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1177 +{
1178 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1179 +" strd %2, %H2, [%1]"
1180 + : "=Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + );
1183 +}
1184 #else
1185 static inline u64 atomic64_read(const atomic64_t *v)
1186 {
1187 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1188 return result;
1189 }
1190
1191 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1192 +{
1193 + u64 result;
1194 +
1195 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1196 +" ldrexd %0, %H0, [%1]"
1197 + : "=&r" (result)
1198 + : "r" (&v->counter), "Qo" (v->counter)
1199 + );
1200 +
1201 + return result;
1202 +}
1203 +
1204 static inline void atomic64_set(atomic64_t *v, u64 i)
1205 {
1206 u64 tmp;
1207 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1208 : "r" (&v->counter), "r" (i)
1209 : "cc");
1210 }
1211 +
1212 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1213 +{
1214 + u64 tmp;
1215 +
1216 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1217 +"1: ldrexd %0, %H0, [%2]\n"
1218 +" strexd %0, %3, %H3, [%2]\n"
1219 +" teq %0, #0\n"
1220 +" bne 1b"
1221 + : "=&r" (tmp), "=Qo" (v->counter)
1222 + : "r" (&v->counter), "r" (i)
1223 + : "cc");
1224 +}
1225 +
1226 #endif
1227
1228 static inline void atomic64_add(u64 i, atomic64_t *v)
1229 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1230 __asm__ __volatile__("@ atomic64_add\n"
1231 "1: ldrexd %0, %H0, [%3]\n"
1232 " adds %0, %0, %4\n"
1233 +" adcs %H0, %H0, %H4\n"
1234 +
1235 +#ifdef CONFIG_PAX_REFCOUNT
1236 +" bvc 3f\n"
1237 +"2: bkpt 0xf103\n"
1238 +"3:\n"
1239 +#endif
1240 +
1241 +" strexd %1, %0, %H0, [%3]\n"
1242 +" teq %1, #0\n"
1243 +" bne 1b"
1244 +
1245 +#ifdef CONFIG_PAX_REFCOUNT
1246 +"\n4:\n"
1247 + _ASM_EXTABLE(2b, 4b)
1248 +#endif
1249 +
1250 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1251 + : "r" (&v->counter), "r" (i)
1252 + : "cc");
1253 +}
1254 +
1255 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1256 +{
1257 + u64 result;
1258 + unsigned long tmp;
1259 +
1260 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1261 +"1: ldrexd %0, %H0, [%3]\n"
1262 +" adds %0, %0, %4\n"
1263 " adc %H0, %H0, %H4\n"
1264 " strexd %1, %0, %H0, [%3]\n"
1265 " teq %1, #0\n"
1266 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1267
1268 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1269 {
1270 - u64 result;
1271 - unsigned long tmp;
1272 + u64 result, tmp;
1273
1274 smp_mb();
1275
1276 __asm__ __volatile__("@ atomic64_add_return\n"
1277 +"1: ldrexd %1, %H1, [%3]\n"
1278 +" adds %0, %1, %4\n"
1279 +" adcs %H0, %H1, %H4\n"
1280 +
1281 +#ifdef CONFIG_PAX_REFCOUNT
1282 +" bvc 3f\n"
1283 +" mov %0, %1\n"
1284 +" mov %H0, %H1\n"
1285 +"2: bkpt 0xf103\n"
1286 +"3:\n"
1287 +#endif
1288 +
1289 +" strexd %1, %0, %H0, [%3]\n"
1290 +" teq %1, #0\n"
1291 +" bne 1b"
1292 +
1293 +#ifdef CONFIG_PAX_REFCOUNT
1294 +"\n4:\n"
1295 + _ASM_EXTABLE(2b, 4b)
1296 +#endif
1297 +
1298 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1299 + : "r" (&v->counter), "r" (i)
1300 + : "cc");
1301 +
1302 + smp_mb();
1303 +
1304 + return result;
1305 +}
1306 +
1307 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1308 +{
1309 + u64 result;
1310 + unsigned long tmp;
1311 +
1312 + smp_mb();
1313 +
1314 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1315 "1: ldrexd %0, %H0, [%3]\n"
1316 " adds %0, %0, %4\n"
1317 " adc %H0, %H0, %H4\n"
1318 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1319 __asm__ __volatile__("@ atomic64_sub\n"
1320 "1: ldrexd %0, %H0, [%3]\n"
1321 " subs %0, %0, %4\n"
1322 +" sbcs %H0, %H0, %H4\n"
1323 +
1324 +#ifdef CONFIG_PAX_REFCOUNT
1325 +" bvc 3f\n"
1326 +"2: bkpt 0xf103\n"
1327 +"3:\n"
1328 +#endif
1329 +
1330 +" strexd %1, %0, %H0, [%3]\n"
1331 +" teq %1, #0\n"
1332 +" bne 1b"
1333 +
1334 +#ifdef CONFIG_PAX_REFCOUNT
1335 +"\n4:\n"
1336 + _ASM_EXTABLE(2b, 4b)
1337 +#endif
1338 +
1339 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1340 + : "r" (&v->counter), "r" (i)
1341 + : "cc");
1342 +}
1343 +
1344 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1345 +{
1346 + u64 result;
1347 + unsigned long tmp;
1348 +
1349 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1350 +"1: ldrexd %0, %H0, [%3]\n"
1351 +" subs %0, %0, %4\n"
1352 " sbc %H0, %H0, %H4\n"
1353 " strexd %1, %0, %H0, [%3]\n"
1354 " teq %1, #0\n"
1355 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1356
1357 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1358 {
1359 - u64 result;
1360 - unsigned long tmp;
1361 + u64 result, tmp;
1362
1363 smp_mb();
1364
1365 __asm__ __volatile__("@ atomic64_sub_return\n"
1366 -"1: ldrexd %0, %H0, [%3]\n"
1367 -" subs %0, %0, %4\n"
1368 -" sbc %H0, %H0, %H4\n"
1369 +"1: ldrexd %1, %H1, [%3]\n"
1370 +" subs %0, %1, %4\n"
1371 +" sbcs %H0, %H1, %H4\n"
1372 +
1373 +#ifdef CONFIG_PAX_REFCOUNT
1374 +" bvc 3f\n"
1375 +" mov %0, %1\n"
1376 +" mov %H0, %H1\n"
1377 +"2: bkpt 0xf103\n"
1378 +"3:\n"
1379 +#endif
1380 +
1381 " strexd %1, %0, %H0, [%3]\n"
1382 " teq %1, #0\n"
1383 " bne 1b"
1384 +
1385 +#ifdef CONFIG_PAX_REFCOUNT
1386 +"\n4:\n"
1387 + _ASM_EXTABLE(2b, 4b)
1388 +#endif
1389 +
1390 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1391 : "r" (&v->counter), "r" (i)
1392 : "cc");
1393 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1394 return oldval;
1395 }
1396
1397 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1398 +{
1399 + u64 oldval;
1400 + unsigned long res;
1401 +
1402 + smp_mb();
1403 +
1404 + do {
1405 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1406 + "ldrexd %1, %H1, [%3]\n"
1407 + "mov %0, #0\n"
1408 + "teq %1, %4\n"
1409 + "teqeq %H1, %H4\n"
1410 + "strexdeq %0, %5, %H5, [%3]"
1411 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1412 + : "r" (&ptr->counter), "r" (old), "r" (new)
1413 + : "cc");
1414 + } while (res);
1415 +
1416 + smp_mb();
1417 +
1418 + return oldval;
1419 +}
1420 +
1421 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1422 {
1423 u64 result;
1424 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1425
1426 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1427 {
1428 - u64 result;
1429 - unsigned long tmp;
1430 + u64 result, tmp;
1431
1432 smp_mb();
1433
1434 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1435 -"1: ldrexd %0, %H0, [%3]\n"
1436 -" subs %0, %0, #1\n"
1437 -" sbc %H0, %H0, #0\n"
1438 +"1: ldrexd %1, %H1, [%3]\n"
1439 +" subs %0, %1, #1\n"
1440 +" sbcs %H0, %H1, #0\n"
1441 +
1442 +#ifdef CONFIG_PAX_REFCOUNT
1443 +" bvc 3f\n"
1444 +" mov %0, %1\n"
1445 +" mov %H0, %H1\n"
1446 +"2: bkpt 0xf103\n"
1447 +"3:\n"
1448 +#endif
1449 +
1450 " teq %H0, #0\n"
1451 -" bmi 2f\n"
1452 +" bmi 4f\n"
1453 " strexd %1, %0, %H0, [%3]\n"
1454 " teq %1, #0\n"
1455 " bne 1b\n"
1456 -"2:"
1457 +"4:\n"
1458 +
1459 +#ifdef CONFIG_PAX_REFCOUNT
1460 + _ASM_EXTABLE(2b, 4b)
1461 +#endif
1462 +
1463 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1464 : "r" (&v->counter)
1465 : "cc");
1466 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1467 " teq %0, %5\n"
1468 " teqeq %H0, %H5\n"
1469 " moveq %1, #0\n"
1470 -" beq 2f\n"
1471 +" beq 4f\n"
1472 " adds %0, %0, %6\n"
1473 -" adc %H0, %H0, %H6\n"
1474 +" adcs %H0, %H0, %H6\n"
1475 +
1476 +#ifdef CONFIG_PAX_REFCOUNT
1477 +" bvc 3f\n"
1478 +"2: bkpt 0xf103\n"
1479 +"3:\n"
1480 +#endif
1481 +
1482 " strexd %2, %0, %H0, [%4]\n"
1483 " teq %2, #0\n"
1484 " bne 1b\n"
1485 -"2:"
1486 +"4:\n"
1487 +
1488 +#ifdef CONFIG_PAX_REFCOUNT
1489 + _ASM_EXTABLE(2b, 4b)
1490 +#endif
1491 +
1492 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1493 : "r" (&v->counter), "r" (u), "r" (a)
1494 : "cc");
1495 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1496
1497 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1498 #define atomic64_inc(v) atomic64_add(1LL, (v))
1499 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1500 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1501 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1502 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1503 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1504 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1505 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1506 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1507 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1508 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1509 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1510 index 75fe66b..ba3dee4 100644
1511 --- a/arch/arm/include/asm/cache.h
1512 +++ b/arch/arm/include/asm/cache.h
1513 @@ -4,8 +4,10 @@
1514 #ifndef __ASMARM_CACHE_H
1515 #define __ASMARM_CACHE_H
1516
1517 +#include <linux/const.h>
1518 +
1519 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1520 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1521 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1522
1523 /*
1524 * Memory returned by kmalloc() may be used for DMA, so we must make
1525 @@ -24,5 +26,6 @@
1526 #endif
1527
1528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1529 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1530
1531 #endif
1532 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1533 index 17d0ae8..014e350 100644
1534 --- a/arch/arm/include/asm/cacheflush.h
1535 +++ b/arch/arm/include/asm/cacheflush.h
1536 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1537 void (*dma_unmap_area)(const void *, size_t, int);
1538
1539 void (*dma_flush_range)(const void *, const void *);
1540 -};
1541 +} __no_const;
1542
1543 /*
1544 * Select the calling method
1545 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1546 index 6dcc164..b14d917 100644
1547 --- a/arch/arm/include/asm/checksum.h
1548 +++ b/arch/arm/include/asm/checksum.h
1549 @@ -37,7 +37,19 @@ __wsum
1550 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1551
1552 __wsum
1553 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1554 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1555 +
1556 +static inline __wsum
1557 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1558 +{
1559 + __wsum ret;
1560 + pax_open_userland();
1561 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1562 + pax_close_userland();
1563 + return ret;
1564 +}
1565 +
1566 +
1567
1568 /*
1569 * Fold a partial checksum without adding pseudo headers
1570 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1571 index 4f009c1..466c59b 100644
1572 --- a/arch/arm/include/asm/cmpxchg.h
1573 +++ b/arch/arm/include/asm/cmpxchg.h
1574 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1575
1576 #define xchg(ptr,x) \
1577 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1578 +#define xchg_unchecked(ptr,x) \
1579 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1580
1581 #include <asm-generic/cmpxchg-local.h>
1582
1583 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1584 index 6ddbe44..b5e38b1 100644
1585 --- a/arch/arm/include/asm/domain.h
1586 +++ b/arch/arm/include/asm/domain.h
1587 @@ -48,18 +48,37 @@
1588 * Domain types
1589 */
1590 #define DOMAIN_NOACCESS 0
1591 -#define DOMAIN_CLIENT 1
1592 #ifdef CONFIG_CPU_USE_DOMAINS
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_KERNELCLIENT 1
1595 #define DOMAIN_MANAGER 3
1596 +#define DOMAIN_VECTORS DOMAIN_USER
1597 #else
1598 +
1599 +#ifdef CONFIG_PAX_KERNEXEC
1600 #define DOMAIN_MANAGER 1
1601 +#define DOMAIN_KERNEXEC 3
1602 +#else
1603 +#define DOMAIN_MANAGER 1
1604 +#endif
1605 +
1606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1607 +#define DOMAIN_USERCLIENT 0
1608 +#define DOMAIN_UDEREF 1
1609 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1610 +#else
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_VECTORS DOMAIN_USER
1613 +#endif
1614 +#define DOMAIN_KERNELCLIENT 1
1615 +
1616 #endif
1617
1618 #define domain_val(dom,type) ((type) << (2*(dom)))
1619
1620 #ifndef __ASSEMBLY__
1621
1622 -#ifdef CONFIG_CPU_USE_DOMAINS
1623 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1624 static inline void set_domain(unsigned val)
1625 {
1626 asm volatile(
1627 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1628 isb();
1629 }
1630
1631 -#define modify_domain(dom,type) \
1632 - do { \
1633 - struct thread_info *thread = current_thread_info(); \
1634 - unsigned int domain = thread->cpu_domain; \
1635 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1636 - thread->cpu_domain = domain | domain_val(dom, type); \
1637 - set_domain(thread->cpu_domain); \
1638 - } while (0)
1639 -
1640 +extern void modify_domain(unsigned int dom, unsigned int type);
1641 #else
1642 static inline void set_domain(unsigned val) { }
1643 static inline void modify_domain(unsigned dom, unsigned type) { }
1644 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1645 index 56211f2..17e8a25 100644
1646 --- a/arch/arm/include/asm/elf.h
1647 +++ b/arch/arm/include/asm/elf.h
1648 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1649 the loader. We need to make sure that it is out of the way of the program
1650 that it will "exec", and that there is sufficient room for the brk. */
1651
1652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1654 +
1655 +#ifdef CONFIG_PAX_ASLR
1656 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1657 +
1658 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1659 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1660 +#endif
1661
1662 /* When the program starts, a1 contains a pointer to a function to be
1663 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1664 @@ -126,10 +133,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1665 extern void elf_set_personality(const struct elf32_hdr *);
1666 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1667
1668 -struct mm_struct;
1669 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1670 -#define arch_randomize_brk arch_randomize_brk
1671 -
1672 #ifdef CONFIG_MMU
1673 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1674 struct linux_binprm;
1675 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1676 index de53547..52b9a28 100644
1677 --- a/arch/arm/include/asm/fncpy.h
1678 +++ b/arch/arm/include/asm/fncpy.h
1679 @@ -81,7 +81,9 @@
1680 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1681 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1682 \
1683 + pax_open_kernel(); \
1684 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1685 + pax_close_kernel(); \
1686 flush_icache_range((unsigned long)(dest_buf), \
1687 (unsigned long)(dest_buf) + (size)); \
1688 \
1689 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1690 index e42cf59..7b94b8f 100644
1691 --- a/arch/arm/include/asm/futex.h
1692 +++ b/arch/arm/include/asm/futex.h
1693 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1694 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1695 return -EFAULT;
1696
1697 + pax_open_userland();
1698 +
1699 smp_mb();
1700 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1701 "1: ldrex %1, [%4]\n"
1702 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1703 : "cc", "memory");
1704 smp_mb();
1705
1706 + pax_close_userland();
1707 +
1708 *uval = val;
1709 return ret;
1710 }
1711 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1718 "1: " TUSER(ldr) " %1, [%4]\n"
1719 " teq %1, %2\n"
1720 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1722 : "cc", "memory");
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1730 return -EFAULT;
1731
1732 pagefault_disable(); /* implies preempt_disable() */
1733 + pax_open_userland();
1734
1735 switch (op) {
1736 case FUTEX_OP_SET:
1737 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 ret = -ENOSYS;
1739 }
1740
1741 + pax_close_userland();
1742 pagefault_enable(); /* subsumes preempt_enable() */
1743
1744 if (!ret) {
1745 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1746 index 83eb2f7..ed77159 100644
1747 --- a/arch/arm/include/asm/kmap_types.h
1748 +++ b/arch/arm/include/asm/kmap_types.h
1749 @@ -4,6 +4,6 @@
1750 /*
1751 * This is the "bare minimum". AIO seems to require this.
1752 */
1753 -#define KM_TYPE_NR 16
1754 +#define KM_TYPE_NR 17
1755
1756 #endif
1757 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1758 index 9e614a1..3302cca 100644
1759 --- a/arch/arm/include/asm/mach/dma.h
1760 +++ b/arch/arm/include/asm/mach/dma.h
1761 @@ -22,7 +22,7 @@ struct dma_ops {
1762 int (*residue)(unsigned int, dma_t *); /* optional */
1763 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1764 const char *type;
1765 -};
1766 +} __do_const;
1767
1768 struct dma_struct {
1769 void *addr; /* single DMA address */
1770 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1771 index 2fe141f..192dc01 100644
1772 --- a/arch/arm/include/asm/mach/map.h
1773 +++ b/arch/arm/include/asm/mach/map.h
1774 @@ -27,13 +27,16 @@ struct map_desc {
1775 #define MT_MINICLEAN 6
1776 #define MT_LOW_VECTORS 7
1777 #define MT_HIGH_VECTORS 8
1778 -#define MT_MEMORY 9
1779 +#define MT_MEMORY_RWX 9
1780 #define MT_ROM 10
1781 -#define MT_MEMORY_NONCACHED 11
1782 +#define MT_MEMORY_NONCACHED_RX 11
1783 #define MT_MEMORY_DTCM 12
1784 #define MT_MEMORY_ITCM 13
1785 #define MT_MEMORY_SO 14
1786 #define MT_MEMORY_DMA_READY 15
1787 +#define MT_MEMORY_RW 16
1788 +#define MT_MEMORY_RX 17
1789 +#define MT_MEMORY_NONCACHED_RW 18
1790
1791 #ifdef CONFIG_MMU
1792 extern void iotable_init(struct map_desc *, int);
1793 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1794 index 12f71a1..04e063c 100644
1795 --- a/arch/arm/include/asm/outercache.h
1796 +++ b/arch/arm/include/asm/outercache.h
1797 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1798 #endif
1799 void (*set_debug)(unsigned long);
1800 void (*resume)(void);
1801 -};
1802 +} __no_const;
1803
1804 #ifdef CONFIG_OUTER_CACHE
1805
1806 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1807 index 4355f0e..c229913 100644
1808 --- a/arch/arm/include/asm/page.h
1809 +++ b/arch/arm/include/asm/page.h
1810 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1811 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1812 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1813 unsigned long vaddr, struct vm_area_struct *vma);
1814 -};
1815 +} __no_const;
1816
1817 #ifdef MULTI_USER
1818 extern struct cpu_user_fns cpu_user;
1819 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1820 index 943504f..c37a730 100644
1821 --- a/arch/arm/include/asm/pgalloc.h
1822 +++ b/arch/arm/include/asm/pgalloc.h
1823 @@ -17,6 +17,7 @@
1824 #include <asm/processor.h>
1825 #include <asm/cacheflush.h>
1826 #include <asm/tlbflush.h>
1827 +#include <asm/system_info.h>
1828
1829 #define check_pgt_cache() do { } while (0)
1830
1831 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1832 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1833 }
1834
1835 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1836 +{
1837 + pud_populate(mm, pud, pmd);
1838 +}
1839 +
1840 #else /* !CONFIG_ARM_LPAE */
1841
1842 /*
1843 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1845 #define pmd_free(mm, pmd) do { } while (0)
1846 #define pud_populate(mm,pmd,pte) BUG()
1847 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1848
1849 #endif /* CONFIG_ARM_LPAE */
1850
1851 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1852 __free_page(pte);
1853 }
1854
1855 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1856 +{
1857 +#ifdef CONFIG_ARM_LPAE
1858 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1859 +#else
1860 + if (addr & SECTION_SIZE)
1861 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1862 + else
1863 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1864 +#endif
1865 + flush_pmd_entry(pmdp);
1866 +}
1867 +
1868 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1869 pmdval_t prot)
1870 {
1871 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1872 static inline void
1873 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1874 {
1875 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1876 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1877 }
1878 #define pmd_pgtable(pmd) pmd_page(pmd)
1879
1880 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1881 index 5cfba15..f415e1a 100644
1882 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1883 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 @@ -20,12 +20,15 @@
1885 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1886 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1887 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1888 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1889 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1890 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1891 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1892 +
1893 /*
1894 * - section
1895 */
1896 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1897 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1898 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1899 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1900 @@ -37,6 +40,7 @@
1901 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1902 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1903 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1904 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1905
1906 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1907 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1908 @@ -66,6 +70,7 @@
1909 * - extended small page/tiny page
1910 */
1911 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1912 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1913 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1914 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1915 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1916 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1917 index f97ee02..cc9fe9e 100644
1918 --- a/arch/arm/include/asm/pgtable-2level.h
1919 +++ b/arch/arm/include/asm/pgtable-2level.h
1920 @@ -126,6 +126,9 @@
1921 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1922 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1923
1924 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1925 +#define L_PTE_PXN (_AT(pteval_t, 0))
1926 +
1927 /*
1928 * These are the memory types, defined to be compatible with
1929 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1930 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1931 index 626989f..9d67a33 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -75,6 +75,7 @@
1935 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1936 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1937 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1938 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1939 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1940
1941 /*
1942 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1943 index 5689c18..eea12f9 100644
1944 --- a/arch/arm/include/asm/pgtable-3level.h
1945 +++ b/arch/arm/include/asm/pgtable-3level.h
1946 @@ -82,6 +82,7 @@
1947 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1948 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1949 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1950 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1951 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1952 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1953 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1954 @@ -95,6 +96,7 @@
1955 /*
1956 * To be used in assembly code with the upper page attributes.
1957 */
1958 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1959 #define L_PTE_XN_HIGH (1 << (54 - 32))
1960 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1961
1962 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1963 index 04aeb02..73b70dd 100644
1964 --- a/arch/arm/include/asm/pgtable.h
1965 +++ b/arch/arm/include/asm/pgtable.h
1966 @@ -33,6 +33,9 @@
1967 #include <asm/pgtable-2level.h>
1968 #endif
1969
1970 +#define ktla_ktva(addr) (addr)
1971 +#define ktva_ktla(addr) (addr)
1972 +
1973 /*
1974 * Just any arbitrary offset to the start of the vmalloc VM area: the
1975 * current 8MB value just means that there will be a 8MB "hole" after the
1976 @@ -48,6 +51,9 @@
1977 #define LIBRARY_TEXT_START 0x0c000000
1978
1979 #ifndef __ASSEMBLY__
1980 +extern pteval_t __supported_pte_mask;
1981 +extern pmdval_t __supported_pmd_mask;
1982 +
1983 extern void __pte_error(const char *file, int line, pte_t);
1984 extern void __pmd_error(const char *file, int line, pmd_t);
1985 extern void __pgd_error(const char *file, int line, pgd_t);
1986 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1987 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1988 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1989
1990 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1991 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1992 +
1993 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1994 +#include <asm/domain.h>
1995 +#include <linux/thread_info.h>
1996 +#include <linux/preempt.h>
1997 +
1998 +static inline int test_domain(int domain, int domaintype)
1999 +{
2000 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2001 +}
2002 +#endif
2003 +
2004 +#ifdef CONFIG_PAX_KERNEXEC
2005 +static inline unsigned long pax_open_kernel(void) {
2006 +#ifdef CONFIG_ARM_LPAE
2007 + /* TODO */
2008 +#else
2009 + preempt_disable();
2010 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2011 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2012 +#endif
2013 + return 0;
2014 +}
2015 +
2016 +static inline unsigned long pax_close_kernel(void) {
2017 +#ifdef CONFIG_ARM_LPAE
2018 + /* TODO */
2019 +#else
2020 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2021 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2022 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2023 + preempt_enable_no_resched();
2024 +#endif
2025 + return 0;
2026 +}
2027 +#else
2028 +static inline unsigned long pax_open_kernel(void) { return 0; }
2029 +static inline unsigned long pax_close_kernel(void) { return 0; }
2030 +#endif
2031 +
2032 /*
2033 * This is the lowest virtual address we can permit any user space
2034 * mapping to be mapped at. This is particularly important for
2035 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2036 /*
2037 * The pgprot_* and protection_map entries will be fixed up in runtime
2038 * to include the cachable and bufferable bits based on memory policy,
2039 - * as well as any architecture dependent bits like global/ASID and SMP
2040 - * shared mapping bits.
2041 + * as well as any architecture dependent bits like global/ASID, PXN,
2042 + * and SMP shared mapping bits.
2043 */
2044 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2045
2046 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2047 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2048 {
2049 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2050 - L_PTE_NONE | L_PTE_VALID;
2051 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2052 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2053 return pte;
2054 }
2055 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2056 index 5324c11..bcae5f0 100644
2057 --- a/arch/arm/include/asm/proc-fns.h
2058 +++ b/arch/arm/include/asm/proc-fns.h
2059 @@ -75,7 +75,7 @@ extern struct processor {
2060 unsigned int suspend_size;
2061 void (*do_suspend)(void *);
2062 void (*do_resume)(void *);
2063 -} processor;
2064 +} __do_const processor;
2065
2066 #ifndef MULTI_CPU
2067 extern void cpu_proc_init(void);
2068 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2069 index c4ae171..ea0c0c2 100644
2070 --- a/arch/arm/include/asm/psci.h
2071 +++ b/arch/arm/include/asm/psci.h
2072 @@ -29,7 +29,7 @@ struct psci_operations {
2073 int (*cpu_off)(struct psci_power_state state);
2074 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2075 int (*migrate)(unsigned long cpuid);
2076 -};
2077 +} __no_const;
2078
2079 extern struct psci_operations psci_ops;
2080 extern struct smp_operations psci_smp_ops;
2081 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2082 index a8cae71c..65dd797 100644
2083 --- a/arch/arm/include/asm/smp.h
2084 +++ b/arch/arm/include/asm/smp.h
2085 @@ -110,7 +110,7 @@ struct smp_operations {
2086 int (*cpu_disable)(unsigned int cpu);
2087 #endif
2088 #endif
2089 -};
2090 +} __no_const;
2091
2092 /*
2093 * set platform specific SMP operations
2094 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2095 index 2b8114f..8fe9bcf 100644
2096 --- a/arch/arm/include/asm/thread_info.h
2097 +++ b/arch/arm/include/asm/thread_info.h
2098 @@ -77,9 +77,9 @@ struct thread_info {
2099 .flags = 0, \
2100 .preempt_count = INIT_PREEMPT_COUNT, \
2101 .addr_limit = KERNEL_DS, \
2102 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2103 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2104 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2105 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2106 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2107 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2108 .restart_block = { \
2109 .fn = do_no_restart_syscall, \
2110 }, \
2111 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2112 #define TIF_SYSCALL_AUDIT 9
2113 #define TIF_SYSCALL_TRACEPOINT 10
2114 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2115 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2116 +/* within 8 bits of TIF_SYSCALL_TRACE
2117 + * to meet flexible second operand requirements
2118 + */
2119 +#define TIF_GRSEC_SETXID 12
2120 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2121 #define TIF_USING_IWMMXT 17
2122 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2123 #define TIF_RESTORE_SIGMASK 20
2124 @@ -165,10 +169,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2125 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2126 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2127 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2128 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2129
2130 /* Checks for any syscall work in entry-common.S */
2131 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2132 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2133 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2134
2135 /*
2136 * Change these and you break ASM code in entry-common.S
2137 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2138 index 7e1f760..de33b13 100644
2139 --- a/arch/arm/include/asm/uaccess.h
2140 +++ b/arch/arm/include/asm/uaccess.h
2141 @@ -18,6 +18,7 @@
2142 #include <asm/domain.h>
2143 #include <asm/unified.h>
2144 #include <asm/compiler.h>
2145 +#include <asm/pgtable.h>
2146
2147 #define VERIFY_READ 0
2148 #define VERIFY_WRITE 1
2149 @@ -63,11 +64,38 @@ extern int __put_user_bad(void);
2150 static inline void set_fs(mm_segment_t fs)
2151 {
2152 current_thread_info()->addr_limit = fs;
2153 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2154 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2155 }
2156
2157 #define segment_eq(a,b) ((a) == (b))
2158
2159 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2160 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2161 +
2162 +static inline void pax_open_userland(void)
2163 +{
2164 +
2165 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2166 + if (segment_eq(get_fs(), USER_DS)) {
2167 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2168 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2169 + }
2170 +#endif
2171 +
2172 +}
2173 +
2174 +static inline void pax_close_userland(void)
2175 +{
2176 +
2177 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2178 + if (segment_eq(get_fs(), USER_DS)) {
2179 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2180 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2181 + }
2182 +#endif
2183 +
2184 +}
2185 +
2186 #define __addr_ok(addr) ({ \
2187 unsigned long flag; \
2188 __asm__("cmp %2, %0; movlo %0, #0" \
2189 @@ -143,8 +171,12 @@ extern int __get_user_4(void *);
2190
2191 #define get_user(x,p) \
2192 ({ \
2193 + int __e; \
2194 might_fault(); \
2195 - __get_user_check(x,p); \
2196 + pax_open_userland(); \
2197 + __e = __get_user_check(x,p); \
2198 + pax_close_userland(); \
2199 + __e; \
2200 })
2201
2202 extern int __put_user_1(void *, unsigned int);
2203 @@ -188,8 +220,12 @@ extern int __put_user_8(void *, unsigned long long);
2204
2205 #define put_user(x,p) \
2206 ({ \
2207 + int __e; \
2208 might_fault(); \
2209 - __put_user_check(x,p); \
2210 + pax_open_userland(); \
2211 + __e = __put_user_check(x,p); \
2212 + pax_close_userland(); \
2213 + __e; \
2214 })
2215
2216 #else /* CONFIG_MMU */
2217 @@ -230,13 +266,17 @@ static inline void set_fs(mm_segment_t fs)
2218 #define __get_user(x,ptr) \
2219 ({ \
2220 long __gu_err = 0; \
2221 + pax_open_userland(); \
2222 __get_user_err((x),(ptr),__gu_err); \
2223 + pax_close_userland(); \
2224 __gu_err; \
2225 })
2226
2227 #define __get_user_error(x,ptr,err) \
2228 ({ \
2229 + pax_open_userland(); \
2230 __get_user_err((x),(ptr),err); \
2231 + pax_close_userland(); \
2232 (void) 0; \
2233 })
2234
2235 @@ -312,13 +352,17 @@ do { \
2236 #define __put_user(x,ptr) \
2237 ({ \
2238 long __pu_err = 0; \
2239 + pax_open_userland(); \
2240 __put_user_err((x),(ptr),__pu_err); \
2241 + pax_close_userland(); \
2242 __pu_err; \
2243 })
2244
2245 #define __put_user_error(x,ptr,err) \
2246 ({ \
2247 + pax_open_userland(); \
2248 __put_user_err((x),(ptr),err); \
2249 + pax_close_userland(); \
2250 (void) 0; \
2251 })
2252
2253 @@ -418,11 +462,44 @@ do { \
2254
2255
2256 #ifdef CONFIG_MMU
2257 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2258 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2259 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2260 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2261 +
2262 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2263 +{
2264 + unsigned long ret;
2265 +
2266 + check_object_size(to, n, false);
2267 + pax_open_userland();
2268 + ret = ___copy_from_user(to, from, n);
2269 + pax_close_userland();
2270 + return ret;
2271 +}
2272 +
2273 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2274 +{
2275 + unsigned long ret;
2276 +
2277 + check_object_size(from, n, true);
2278 + pax_open_userland();
2279 + ret = ___copy_to_user(to, from, n);
2280 + pax_close_userland();
2281 + return ret;
2282 +}
2283 +
2284 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2285 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2286 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2287 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2288 +
2289 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2290 +{
2291 + unsigned long ret;
2292 + pax_open_userland();
2293 + ret = ___clear_user(addr, n);
2294 + pax_close_userland();
2295 + return ret;
2296 +}
2297 +
2298 #else
2299 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2300 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2301 @@ -431,6 +508,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2302
2303 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2304 {
2305 + if ((long)n < 0)
2306 + return n;
2307 +
2308 if (access_ok(VERIFY_READ, from, n))
2309 n = __copy_from_user(to, from, n);
2310 else /* security hole - plug it */
2311 @@ -440,6 +520,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2312
2313 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2314 {
2315 + if ((long)n < 0)
2316 + return n;
2317 +
2318 if (access_ok(VERIFY_WRITE, to, n))
2319 n = __copy_to_user(to, from, n);
2320 return n;
2321 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2322 index 5af0ed1..cea83883 100644
2323 --- a/arch/arm/include/uapi/asm/ptrace.h
2324 +++ b/arch/arm/include/uapi/asm/ptrace.h
2325 @@ -92,7 +92,7 @@
2326 * ARMv7 groups of PSR bits
2327 */
2328 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2329 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2330 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2331 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2332 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2333
2334 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2335 index 60d3b73..e5a0f22 100644
2336 --- a/arch/arm/kernel/armksyms.c
2337 +++ b/arch/arm/kernel/armksyms.c
2338 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2339
2340 /* networking */
2341 EXPORT_SYMBOL(csum_partial);
2342 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2343 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2344 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2345 EXPORT_SYMBOL(__csum_ipv6_magic);
2346
2347 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2348 #ifdef CONFIG_MMU
2349 EXPORT_SYMBOL(copy_page);
2350
2351 -EXPORT_SYMBOL(__copy_from_user);
2352 -EXPORT_SYMBOL(__copy_to_user);
2353 -EXPORT_SYMBOL(__clear_user);
2354 +EXPORT_SYMBOL(___copy_from_user);
2355 +EXPORT_SYMBOL(___copy_to_user);
2356 +EXPORT_SYMBOL(___clear_user);
2357
2358 EXPORT_SYMBOL(__get_user_1);
2359 EXPORT_SYMBOL(__get_user_2);
2360 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2361 index 9cbe70c..a7b5e34 100644
2362 --- a/arch/arm/kernel/entry-armv.S
2363 +++ b/arch/arm/kernel/entry-armv.S
2364 @@ -47,6 +47,87 @@
2365 9997:
2366 .endm
2367
2368 + .macro pax_enter_kernel
2369 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2370 + @ make aligned space for saved DACR
2371 + sub sp, sp, #8
2372 + @ save regs
2373 + stmdb sp!, {r1, r2}
2374 + @ read DACR from cpu_domain into r1
2375 + mov r2, sp
2376 + @ assume 8K pages, since we have to split the immediate in two
2377 + bic r2, r2, #(0x1fc0)
2378 + bic r2, r2, #(0x3f)
2379 + ldr r1, [r2, #TI_CPU_DOMAIN]
2380 + @ store old DACR on stack
2381 + str r1, [sp, #8]
2382 +#ifdef CONFIG_PAX_KERNEXEC
2383 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2384 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2385 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2386 +#endif
2387 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2388 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2389 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2390 +#endif
2391 + @ write r1 to current_thread_info()->cpu_domain
2392 + str r1, [r2, #TI_CPU_DOMAIN]
2393 + @ write r1 to DACR
2394 + mcr p15, 0, r1, c3, c0, 0
2395 + @ instruction sync
2396 + instr_sync
2397 + @ restore regs
2398 + ldmia sp!, {r1, r2}
2399 +#endif
2400 + .endm
2401 +
2402 + .macro pax_open_userland
2403 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2404 + @ save regs
2405 + stmdb sp!, {r0, r1}
2406 + @ read DACR from cpu_domain into r1
2407 + mov r0, sp
2408 + @ assume 8K pages, since we have to split the immediate in two
2409 + bic r0, r0, #(0x1fc0)
2410 + bic r0, r0, #(0x3f)
2411 + ldr r1, [r0, #TI_CPU_DOMAIN]
2412 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2413 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2414 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2415 + @ write r1 to current_thread_info()->cpu_domain
2416 + str r1, [r0, #TI_CPU_DOMAIN]
2417 + @ write r1 to DACR
2418 + mcr p15, 0, r1, c3, c0, 0
2419 + @ instruction sync
2420 + instr_sync
2421 + @ restore regs
2422 + ldmia sp!, {r0, r1}
2423 +#endif
2424 + .endm
2425 +
2426 + .macro pax_close_userland
2427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2428 + @ save regs
2429 + stmdb sp!, {r0, r1}
2430 + @ read DACR from cpu_domain into r1
2431 + mov r0, sp
2432 + @ assume 8K pages, since we have to split the immediate in two
2433 + bic r0, r0, #(0x1fc0)
2434 + bic r0, r0, #(0x3f)
2435 + ldr r1, [r0, #TI_CPU_DOMAIN]
2436 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2437 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2438 + @ write r1 to current_thread_info()->cpu_domain
2439 + str r1, [r0, #TI_CPU_DOMAIN]
2440 + @ write r1 to DACR
2441 + mcr p15, 0, r1, c3, c0, 0
2442 + @ instruction sync
2443 + instr_sync
2444 + @ restore regs
2445 + ldmia sp!, {r0, r1}
2446 +#endif
2447 + .endm
2448 +
2449 .macro pabt_helper
2450 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2451 #ifdef MULTI_PABORT
2452 @@ -89,11 +170,15 @@
2453 * Invalid mode handlers
2454 */
2455 .macro inv_entry, reason
2456 +
2457 + pax_enter_kernel
2458 +
2459 sub sp, sp, #S_FRAME_SIZE
2460 ARM( stmib sp, {r1 - lr} )
2461 THUMB( stmia sp, {r0 - r12} )
2462 THUMB( str sp, [sp, #S_SP] )
2463 THUMB( str lr, [sp, #S_LR] )
2464 +
2465 mov r1, #\reason
2466 .endm
2467
2468 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2469 .macro svc_entry, stack_hole=0
2470 UNWIND(.fnstart )
2471 UNWIND(.save {r0 - pc} )
2472 +
2473 + pax_enter_kernel
2474 +
2475 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2476 +
2477 #ifdef CONFIG_THUMB2_KERNEL
2478 SPFIX( str r0, [sp] ) @ temporarily saved
2479 SPFIX( mov r0, sp )
2480 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2481 ldmia r0, {r3 - r5}
2482 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2483 mov r6, #-1 @ "" "" "" ""
2484 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2485 + @ offset sp by 8 as done in pax_enter_kernel
2486 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2487 +#else
2488 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2489 +#endif
2490 SPFIX( addeq r2, r2, #4 )
2491 str r3, [sp, #-4]! @ save the "real" r0 copied
2492 @ from the exception stack
2493 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2494 .macro usr_entry
2495 UNWIND(.fnstart )
2496 UNWIND(.cantunwind ) @ don't unwind the user space
2497 +
2498 + pax_enter_kernel_user
2499 +
2500 sub sp, sp, #S_FRAME_SIZE
2501 ARM( stmib sp, {r1 - r12} )
2502 THUMB( stmia sp, {r0 - r12} )
2503 @@ -415,7 +512,9 @@ __und_usr:
2504 tst r3, #PSR_T_BIT @ Thumb mode?
2505 bne __und_usr_thumb
2506 sub r4, r2, #4 @ ARM instr at LR - 4
2507 + pax_open_userland
2508 1: ldrt r0, [r4]
2509 + pax_close_userland
2510 #ifdef CONFIG_CPU_ENDIAN_BE8
2511 rev r0, r0 @ little endian instruction
2512 #endif
2513 @@ -450,10 +549,14 @@ __und_usr_thumb:
2514 */
2515 .arch armv6t2
2516 #endif
2517 + pax_open_userland
2518 2: ldrht r5, [r4]
2519 + pax_close_userland
2520 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2521 blo __und_usr_fault_16 @ 16bit undefined instruction
2522 + pax_open_userland
2523 3: ldrht r0, [r2]
2524 + pax_close_userland
2525 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2526 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2527 orr r0, r0, r5, lsl #16
2528 @@ -482,7 +585,8 @@ ENDPROC(__und_usr)
2529 */
2530 .pushsection .fixup, "ax"
2531 .align 2
2532 -4: mov pc, r9
2533 +4: pax_close_userland
2534 + mov pc, r9
2535 .popsection
2536 .pushsection __ex_table,"a"
2537 .long 1b, 4b
2538 @@ -692,7 +796,7 @@ ENTRY(__switch_to)
2539 THUMB( str lr, [ip], #4 )
2540 ldr r4, [r2, #TI_TP_VALUE]
2541 ldr r5, [r2, #TI_TP_VALUE + 4]
2542 -#ifdef CONFIG_CPU_USE_DOMAINS
2543 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 ldr r6, [r2, #TI_CPU_DOMAIN]
2545 #endif
2546 switch_tls r1, r4, r5, r3, r7
2547 @@ -701,7 +805,7 @@ ENTRY(__switch_to)
2548 ldr r8, =__stack_chk_guard
2549 ldr r7, [r7, #TSK_STACK_CANARY]
2550 #endif
2551 -#ifdef CONFIG_CPU_USE_DOMAINS
2552 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2553 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2554 #endif
2555 mov r5, r0
2556 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2557 index 94104bf..e425391 100644
2558 --- a/arch/arm/kernel/entry-common.S
2559 +++ b/arch/arm/kernel/entry-common.S
2560 @@ -10,18 +10,46 @@
2561
2562 #include <asm/unistd.h>
2563 #include <asm/ftrace.h>
2564 +#include <asm/domain.h>
2565 #include <asm/unwind.h>
2566
2567 +#include "entry-header.S"
2568 +
2569 #ifdef CONFIG_NEED_RET_TO_USER
2570 #include <mach/entry-macro.S>
2571 #else
2572 .macro arch_ret_to_user, tmp1, tmp2
2573 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2574 + @ save regs
2575 + stmdb sp!, {r1, r2}
2576 + @ read DACR from cpu_domain into r1
2577 + mov r2, sp
2578 + @ assume 8K pages, since we have to split the immediate in two
2579 + bic r2, r2, #(0x1fc0)
2580 + bic r2, r2, #(0x3f)
2581 + ldr r1, [r2, #TI_CPU_DOMAIN]
2582 +#ifdef CONFIG_PAX_KERNEXEC
2583 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2584 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2585 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2586 +#endif
2587 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2588 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2589 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2590 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2591 +#endif
2592 + @ write r1 to current_thread_info()->cpu_domain
2593 + str r1, [r2, #TI_CPU_DOMAIN]
2594 + @ write r1 to DACR
2595 + mcr p15, 0, r1, c3, c0, 0
2596 + @ instruction sync
2597 + instr_sync
2598 + @ restore regs
2599 + ldmia sp!, {r1, r2}
2600 +#endif
2601 .endm
2602 #endif
2603
2604 -#include "entry-header.S"
2605 -
2606 -
2607 .align 5
2608 /*
2609 * This is the fast syscall return path. We do as little as
2610 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2611 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2612 #endif
2613
2614 + /*
2615 + * do this here to avoid a performance hit of wrapping the code above
2616 + * that directly dereferences userland to parse the SWI instruction
2617 + */
2618 + pax_enter_kernel_user
2619 +
2620 adr tbl, sys_call_table @ load syscall table pointer
2621
2622 #if defined(CONFIG_OABI_COMPAT)
2623 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2624 index de23a9b..94c37c4 100644
2625 --- a/arch/arm/kernel/entry-header.S
2626 +++ b/arch/arm/kernel/entry-header.S
2627 @@ -184,6 +184,60 @@
2628 msr cpsr_c, \rtemp @ switch back to the SVC mode
2629 .endm
2630
2631 + .macro pax_enter_kernel_user
2632 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2633 + @ save regs
2634 + stmdb sp!, {r0, r1}
2635 + @ read DACR from cpu_domain into r1
2636 + mov r0, sp
2637 + @ assume 8K pages, since we have to split the immediate in two
2638 + bic r0, r0, #(0x1fc0)
2639 + bic r0, r0, #(0x3f)
2640 + ldr r1, [r0, #TI_CPU_DOMAIN]
2641 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2642 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2643 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2644 +#endif
2645 +#ifdef CONFIG_PAX_KERNEXEC
2646 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2647 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2648 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2649 +#endif
2650 + @ write r1 to current_thread_info()->cpu_domain
2651 + str r1, [r0, #TI_CPU_DOMAIN]
2652 + @ write r1 to DACR
2653 + mcr p15, 0, r1, c3, c0, 0
2654 + @ instruction sync
2655 + instr_sync
2656 + @ restore regs
2657 + ldmia sp!, {r0, r1}
2658 +#endif
2659 + .endm
2660 +
2661 + .macro pax_exit_kernel
2662 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2663 + @ save regs
2664 + stmdb sp!, {r0, r1}
2665 + @ read old DACR from stack into r1
2666 + ldr r1, [sp, #(8 + S_SP)]
2667 + sub r1, r1, #8
2668 + ldr r1, [r1]
2669 +
2670 + @ write r1 to current_thread_info()->cpu_domain
2671 + mov r0, sp
2672 + @ assume 8K pages, since we have to split the immediate in two
2673 + bic r0, r0, #(0x1fc0)
2674 + bic r0, r0, #(0x3f)
2675 + str r1, [r0, #TI_CPU_DOMAIN]
2676 + @ write r1 to DACR
2677 + mcr p15, 0, r1, c3, c0, 0
2678 + @ instruction sync
2679 + instr_sync
2680 + @ restore regs
2681 + ldmia sp!, {r0, r1}
2682 +#endif
2683 + .endm
2684 +
2685 #ifndef CONFIG_THUMB2_KERNEL
2686 .macro svc_exit, rpsr, irq = 0
2687 .if \irq != 0
2688 @@ -203,6 +257,9 @@
2689 blne trace_hardirqs_off
2690 #endif
2691 .endif
2692 +
2693 + pax_exit_kernel
2694 +
2695 msr spsr_cxsf, \rpsr
2696 #if defined(CONFIG_CPU_V6)
2697 ldr r0, [sp]
2698 @@ -266,6 +323,9 @@
2699 blne trace_hardirqs_off
2700 #endif
2701 .endif
2702 +
2703 + pax_exit_kernel
2704 +
2705 ldr lr, [sp, #S_SP] @ top of the stack
2706 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2707 clrex @ clear the exclusive monitor
2708 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2709 index 918875d..cd5fa27 100644
2710 --- a/arch/arm/kernel/fiq.c
2711 +++ b/arch/arm/kernel/fiq.c
2712 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2713 void *base = vectors_page;
2714 unsigned offset = FIQ_OFFSET;
2715
2716 + pax_open_kernel();
2717 memcpy(base + offset, start, length);
2718 + pax_close_kernel();
2719 +
2720 if (!cache_is_vipt_nonaliasing())
2721 flush_icache_range((unsigned long)base + offset, offset +
2722 length);
2723 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2724 index 2c7cc1e..ab2e911 100644
2725 --- a/arch/arm/kernel/head.S
2726 +++ b/arch/arm/kernel/head.S
2727 @@ -52,7 +52,9 @@
2728 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2729
2730 .macro pgtbl, rd, phys
2731 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2732 + mov \rd, #TEXT_OFFSET
2733 + sub \rd, #PG_DIR_SIZE
2734 + add \rd, \rd, \phys
2735 .endm
2736
2737 /*
2738 @@ -432,7 +434,7 @@ __enable_mmu:
2739 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2740 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2741 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2742 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2743 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2744 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2745 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2746 #endif
2747 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2748 index 85c3fb6..054c2dc 100644
2749 --- a/arch/arm/kernel/module.c
2750 +++ b/arch/arm/kernel/module.c
2751 @@ -37,12 +37,39 @@
2752 #endif
2753
2754 #ifdef CONFIG_MMU
2755 -void *module_alloc(unsigned long size)
2756 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2757 {
2758 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2759 + return NULL;
2760 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2761 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2762 + GFP_KERNEL, prot, -1,
2763 __builtin_return_address(0));
2764 }
2765 +
2766 +void *module_alloc(unsigned long size)
2767 +{
2768 +
2769 +#ifdef CONFIG_PAX_KERNEXEC
2770 + return __module_alloc(size, PAGE_KERNEL);
2771 +#else
2772 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2773 +#endif
2774 +
2775 +}
2776 +
2777 +#ifdef CONFIG_PAX_KERNEXEC
2778 +void module_free_exec(struct module *mod, void *module_region)
2779 +{
2780 + module_free(mod, module_region);
2781 +}
2782 +EXPORT_SYMBOL(module_free_exec);
2783 +
2784 +void *module_alloc_exec(unsigned long size)
2785 +{
2786 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2787 +}
2788 +EXPORT_SYMBOL(module_alloc_exec);
2789 +#endif
2790 #endif
2791
2792 int
2793 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2794 index 07314af..c46655c 100644
2795 --- a/arch/arm/kernel/patch.c
2796 +++ b/arch/arm/kernel/patch.c
2797 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2798 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2799 int size;
2800
2801 + pax_open_kernel();
2802 if (thumb2 && __opcode_is_thumb16(insn)) {
2803 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2804 size = sizeof(u16);
2805 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2806 *(u32 *)addr = insn;
2807 size = sizeof(u32);
2808 }
2809 + pax_close_kernel();
2810
2811 flush_icache_range((uintptr_t)(addr),
2812 (uintptr_t)(addr) + size);
2813 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2814 index 94f6b05..efd7312 100644
2815 --- a/arch/arm/kernel/process.c
2816 +++ b/arch/arm/kernel/process.c
2817 @@ -217,6 +217,7 @@ void machine_power_off(void)
2818
2819 if (pm_power_off)
2820 pm_power_off();
2821 + BUG();
2822 }
2823
2824 /*
2825 @@ -230,7 +231,7 @@ void machine_power_off(void)
2826 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2827 * to use. Implementing such co-ordination would be essentially impossible.
2828 */
2829 -void machine_restart(char *cmd)
2830 +__noreturn void machine_restart(char *cmd)
2831 {
2832 local_irq_disable();
2833 smp_send_stop();
2834 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2835
2836 show_regs_print_info(KERN_DEFAULT);
2837
2838 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2839 - print_symbol("LR is at %s\n", regs->ARM_lr);
2840 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2841 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2842 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2843 "sp : %08lx ip : %08lx fp : %08lx\n",
2844 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2845 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2846 return 0;
2847 }
2848
2849 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2850 -{
2851 - unsigned long range_end = mm->brk + 0x02000000;
2852 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2853 -}
2854 -
2855 #ifdef CONFIG_MMU
2856 #ifdef CONFIG_KUSER_HELPERS
2857 /*
2858 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2859
2860 static int __init gate_vma_init(void)
2861 {
2862 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2863 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2864 return 0;
2865 }
2866 arch_initcall(gate_vma_init);
2867 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2868
2869 const char *arch_vma_name(struct vm_area_struct *vma)
2870 {
2871 - return is_gate_vma(vma) ? "[vectors]" :
2872 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2873 - "[sigpage]" : NULL;
2874 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2875 }
2876
2877 -static struct page *signal_page;
2878 -extern struct page *get_signal_page(void);
2879 -
2880 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2881 {
2882 struct mm_struct *mm = current->mm;
2883 - unsigned long addr;
2884 - int ret;
2885 -
2886 - if (!signal_page)
2887 - signal_page = get_signal_page();
2888 - if (!signal_page)
2889 - return -ENOMEM;
2890
2891 down_write(&mm->mmap_sem);
2892 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2893 - if (IS_ERR_VALUE(addr)) {
2894 - ret = addr;
2895 - goto up_fail;
2896 - }
2897 -
2898 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2899 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2900 - &signal_page);
2901 -
2902 - if (ret == 0)
2903 - mm->context.sigpage = addr;
2904 -
2905 - up_fail:
2906 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2907 up_write(&mm->mmap_sem);
2908 - return ret;
2909 + return 0;
2910 }
2911 #endif
2912 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2913 index 4693188..4596c5e 100644
2914 --- a/arch/arm/kernel/psci.c
2915 +++ b/arch/arm/kernel/psci.c
2916 @@ -24,7 +24,7 @@
2917 #include <asm/opcodes-virt.h>
2918 #include <asm/psci.h>
2919
2920 -struct psci_operations psci_ops;
2921 +struct psci_operations psci_ops __read_only;
2922
2923 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2924
2925 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2926 index 0dd3b79..e018f64 100644
2927 --- a/arch/arm/kernel/ptrace.c
2928 +++ b/arch/arm/kernel/ptrace.c
2929 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2930 return current_thread_info()->syscall;
2931 }
2932
2933 +#ifdef CONFIG_GRKERNSEC_SETXID
2934 +extern void gr_delayed_cred_worker(void);
2935 +#endif
2936 +
2937 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2938 {
2939 current_thread_info()->syscall = scno;
2940
2941 +#ifdef CONFIG_GRKERNSEC_SETXID
2942 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2943 + gr_delayed_cred_worker();
2944 +#endif
2945 +
2946 /* Do the secure computing check first; failures should be fast. */
2947 if (secure_computing(scno) == -1)
2948 return -1;
2949 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2950 index afc2489..6372bc8 100644
2951 --- a/arch/arm/kernel/setup.c
2952 +++ b/arch/arm/kernel/setup.c
2953 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2954 unsigned int elf_hwcap __read_mostly;
2955 EXPORT_SYMBOL(elf_hwcap);
2956
2957 +pteval_t __supported_pte_mask __read_only;
2958 +pmdval_t __supported_pmd_mask __read_only;
2959
2960 #ifdef MULTI_CPU
2961 -struct processor processor __read_mostly;
2962 +struct processor processor;
2963 #endif
2964 #ifdef MULTI_TLB
2965 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2966 +struct cpu_tlb_fns cpu_tlb __read_only;
2967 #endif
2968 #ifdef MULTI_USER
2969 -struct cpu_user_fns cpu_user __read_mostly;
2970 +struct cpu_user_fns cpu_user __read_only;
2971 #endif
2972 #ifdef MULTI_CACHE
2973 -struct cpu_cache_fns cpu_cache __read_mostly;
2974 +struct cpu_cache_fns cpu_cache __read_only;
2975 #endif
2976 #ifdef CONFIG_OUTER_CACHE
2977 -struct outer_cache_fns outer_cache __read_mostly;
2978 +struct outer_cache_fns outer_cache __read_only;
2979 EXPORT_SYMBOL(outer_cache);
2980 #endif
2981
2982 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
2983 asm("mrc p15, 0, %0, c0, c1, 4"
2984 : "=r" (mmfr0));
2985 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2986 - (mmfr0 & 0x000000f0) >= 0x00000030)
2987 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2988 cpu_arch = CPU_ARCH_ARMv7;
2989 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2990 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2991 + __supported_pte_mask |= L_PTE_PXN;
2992 + __supported_pmd_mask |= PMD_PXNTABLE;
2993 + }
2994 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2995 (mmfr0 & 0x000000f0) == 0x00000020)
2996 cpu_arch = CPU_ARCH_ARMv6;
2997 else
2998 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
2999 __cpu_architecture = __get_cpu_architecture();
3000
3001 #ifdef MULTI_CPU
3002 - processor = *list->proc;
3003 + memcpy((void *)&processor, list->proc, sizeof processor);
3004 #endif
3005 #ifdef MULTI_TLB
3006 cpu_tlb = *list->tlb;
3007 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3008 index ab33042..11248a8 100644
3009 --- a/arch/arm/kernel/signal.c
3010 +++ b/arch/arm/kernel/signal.c
3011 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3012 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3013 };
3014
3015 -static unsigned long signal_return_offset;
3016 -
3017 #ifdef CONFIG_CRUNCH
3018 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3019 {
3020 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3021 * except when the MPU has protected the vectors
3022 * page from PL0
3023 */
3024 - retcode = mm->context.sigpage + signal_return_offset +
3025 - (idx << 2) + thumb;
3026 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3027 } else
3028 #endif
3029 {
3030 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3031 } while (thread_flags & _TIF_WORK_MASK);
3032 return 0;
3033 }
3034 -
3035 -struct page *get_signal_page(void)
3036 -{
3037 - unsigned long ptr;
3038 - unsigned offset;
3039 - struct page *page;
3040 - void *addr;
3041 -
3042 - page = alloc_pages(GFP_KERNEL, 0);
3043 -
3044 - if (!page)
3045 - return NULL;
3046 -
3047 - addr = page_address(page);
3048 -
3049 - /* Give the signal return code some randomness */
3050 - offset = 0x200 + (get_random_int() & 0x7fc);
3051 - signal_return_offset = offset;
3052 -
3053 - /*
3054 - * Copy signal return handlers into the vector page, and
3055 - * set sigreturn to be a pointer to these.
3056 - */
3057 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3058 -
3059 - ptr = (unsigned long)addr + offset;
3060 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3061 -
3062 - return page;
3063 -}
3064 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3065 index 2dc1934..ecf0e21 100644
3066 --- a/arch/arm/kernel/smp.c
3067 +++ b/arch/arm/kernel/smp.c
3068 @@ -71,7 +71,7 @@ enum ipi_msg_type {
3069
3070 static DECLARE_COMPLETION(cpu_running);
3071
3072 -static struct smp_operations smp_ops;
3073 +static struct smp_operations smp_ops __read_only;
3074
3075 void __init smp_set_ops(struct smp_operations *ops)
3076 {
3077 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3078 index ab517fc..9adf2fa 100644
3079 --- a/arch/arm/kernel/traps.c
3080 +++ b/arch/arm/kernel/traps.c
3081 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3082 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3083 {
3084 #ifdef CONFIG_KALLSYMS
3085 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3086 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3087 #else
3088 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3089 #endif
3090 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3091 static int die_owner = -1;
3092 static unsigned int die_nest_count;
3093
3094 +extern void gr_handle_kernel_exploit(void);
3095 +
3096 static unsigned long oops_begin(void)
3097 {
3098 int cpu;
3099 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3100 panic("Fatal exception in interrupt");
3101 if (panic_on_oops)
3102 panic("Fatal exception");
3103 +
3104 + gr_handle_kernel_exploit();
3105 +
3106 if (signr)
3107 do_exit(signr);
3108 }
3109 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3110 * The user helper at 0xffff0fe0 must be used instead.
3111 * (see entry-armv.S for details)
3112 */
3113 + pax_open_kernel();
3114 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3115 + pax_close_kernel();
3116 }
3117 return 0;
3118
3119 @@ -849,7 +856,11 @@ void __init early_trap_init(void *vectors_base)
3120 kuser_init(vectors_base);
3121
3122 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3123 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3124 +
3125 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3126 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3127 +#endif
3128 +
3129 #else /* ifndef CONFIG_CPU_V7M */
3130 /*
3131 * on V7-M there is no need to copy the vector table to a dedicated
3132 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3133 index 7bcee5c..e2f3249 100644
3134 --- a/arch/arm/kernel/vmlinux.lds.S
3135 +++ b/arch/arm/kernel/vmlinux.lds.S
3136 @@ -8,7 +8,11 @@
3137 #include <asm/thread_info.h>
3138 #include <asm/memory.h>
3139 #include <asm/page.h>
3140 -
3141 +
3142 +#ifdef CONFIG_PAX_KERNEXEC
3143 +#include <asm/pgtable.h>
3144 +#endif
3145 +
3146 #define PROC_INFO \
3147 . = ALIGN(4); \
3148 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3149 @@ -34,7 +38,7 @@
3150 #endif
3151
3152 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3153 - defined(CONFIG_GENERIC_BUG)
3154 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3155 #define ARM_EXIT_KEEP(x) x
3156 #define ARM_EXIT_DISCARD(x)
3157 #else
3158 @@ -90,6 +94,11 @@ SECTIONS
3159 _text = .;
3160 HEAD_TEXT
3161 }
3162 +
3163 +#ifdef CONFIG_PAX_KERNEXEC
3164 + . = ALIGN(1<<SECTION_SHIFT);
3165 +#endif
3166 +
3167 .text : { /* Real text segment */
3168 _stext = .; /* Text and read-only data */
3169 __exception_text_start = .;
3170 @@ -112,6 +121,8 @@ SECTIONS
3171 ARM_CPU_KEEP(PROC_INFO)
3172 }
3173
3174 + _etext = .; /* End of text section */
3175 +
3176 RO_DATA(PAGE_SIZE)
3177
3178 . = ALIGN(4);
3179 @@ -142,7 +153,9 @@ SECTIONS
3180
3181 NOTES
3182
3183 - _etext = .; /* End of text and rodata section */
3184 +#ifdef CONFIG_PAX_KERNEXEC
3185 + . = ALIGN(1<<SECTION_SHIFT);
3186 +#endif
3187
3188 #ifndef CONFIG_XIP_KERNEL
3189 . = ALIGN(PAGE_SIZE);
3190 @@ -220,6 +233,11 @@ SECTIONS
3191 . = PAGE_OFFSET + TEXT_OFFSET;
3192 #else
3193 __init_end = .;
3194 +
3195 +#ifdef CONFIG_PAX_KERNEXEC
3196 + . = ALIGN(1<<SECTION_SHIFT);
3197 +#endif
3198 +
3199 . = ALIGN(THREAD_SIZE);
3200 __data_loc = .;
3201 #endif
3202 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3203 index 741f66a..8a5615c 100644
3204 --- a/arch/arm/kvm/arm.c
3205 +++ b/arch/arm/kvm/arm.c
3206 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3207 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3208
3209 /* The VMID used in the VTTBR */
3210 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3211 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3212 static u8 kvm_next_vmid;
3213 static DEFINE_SPINLOCK(kvm_vmid_lock);
3214
3215 @@ -392,7 +392,7 @@ void force_vm_exit(const cpumask_t *mask)
3216 */
3217 static bool need_new_vmid_gen(struct kvm *kvm)
3218 {
3219 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3220 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3221 }
3222
3223 /**
3224 @@ -425,7 +425,7 @@ static void update_vttbr(struct kvm *kvm)
3225
3226 /* First user of a new VMID generation? */
3227 if (unlikely(kvm_next_vmid == 0)) {
3228 - atomic64_inc(&kvm_vmid_gen);
3229 + atomic64_inc_unchecked(&kvm_vmid_gen);
3230 kvm_next_vmid = 1;
3231
3232 /*
3233 @@ -442,7 +442,7 @@ static void update_vttbr(struct kvm *kvm)
3234 kvm_call_hyp(__kvm_flush_vm_context);
3235 }
3236
3237 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3238 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3239 kvm->arch.vmid = kvm_next_vmid;
3240 kvm_next_vmid++;
3241
3242 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3243 index 14a0d98..7771a7d 100644
3244 --- a/arch/arm/lib/clear_user.S
3245 +++ b/arch/arm/lib/clear_user.S
3246 @@ -12,14 +12,14 @@
3247
3248 .text
3249
3250 -/* Prototype: int __clear_user(void *addr, size_t sz)
3251 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3252 * Purpose : clear some user memory
3253 * Params : addr - user memory address to clear
3254 * : sz - number of bytes to clear
3255 * Returns : number of bytes NOT cleared
3256 */
3257 ENTRY(__clear_user_std)
3258 -WEAK(__clear_user)
3259 +WEAK(___clear_user)
3260 stmfd sp!, {r1, lr}
3261 mov r2, #0
3262 cmp r1, #4
3263 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3264 USER( strnebt r2, [r0])
3265 mov r0, #0
3266 ldmfd sp!, {r1, pc}
3267 -ENDPROC(__clear_user)
3268 +ENDPROC(___clear_user)
3269 ENDPROC(__clear_user_std)
3270
3271 .pushsection .fixup,"ax"
3272 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3273 index 66a477a..bee61d3 100644
3274 --- a/arch/arm/lib/copy_from_user.S
3275 +++ b/arch/arm/lib/copy_from_user.S
3276 @@ -16,7 +16,7 @@
3277 /*
3278 * Prototype:
3279 *
3280 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3281 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3282 *
3283 * Purpose:
3284 *
3285 @@ -84,11 +84,11 @@
3286
3287 .text
3288
3289 -ENTRY(__copy_from_user)
3290 +ENTRY(___copy_from_user)
3291
3292 #include "copy_template.S"
3293
3294 -ENDPROC(__copy_from_user)
3295 +ENDPROC(___copy_from_user)
3296
3297 .pushsection .fixup,"ax"
3298 .align 0
3299 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3300 index 6ee2f67..d1cce76 100644
3301 --- a/arch/arm/lib/copy_page.S
3302 +++ b/arch/arm/lib/copy_page.S
3303 @@ -10,6 +10,7 @@
3304 * ASM optimised string functions
3305 */
3306 #include <linux/linkage.h>
3307 +#include <linux/const.h>
3308 #include <asm/assembler.h>
3309 #include <asm/asm-offsets.h>
3310 #include <asm/cache.h>
3311 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3312 index d066df6..df28194 100644
3313 --- a/arch/arm/lib/copy_to_user.S
3314 +++ b/arch/arm/lib/copy_to_user.S
3315 @@ -16,7 +16,7 @@
3316 /*
3317 * Prototype:
3318 *
3319 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3320 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3321 *
3322 * Purpose:
3323 *
3324 @@ -88,11 +88,11 @@
3325 .text
3326
3327 ENTRY(__copy_to_user_std)
3328 -WEAK(__copy_to_user)
3329 +WEAK(___copy_to_user)
3330
3331 #include "copy_template.S"
3332
3333 -ENDPROC(__copy_to_user)
3334 +ENDPROC(___copy_to_user)
3335 ENDPROC(__copy_to_user_std)
3336
3337 .pushsection .fixup,"ax"
3338 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3339 index 7d08b43..f7ca7ea 100644
3340 --- a/arch/arm/lib/csumpartialcopyuser.S
3341 +++ b/arch/arm/lib/csumpartialcopyuser.S
3342 @@ -57,8 +57,8 @@
3343 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3344 */
3345
3346 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3347 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3348 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3349 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3350
3351 #include "csumpartialcopygeneric.S"
3352
3353 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3354 index 5306de3..aed6d03 100644
3355 --- a/arch/arm/lib/delay.c
3356 +++ b/arch/arm/lib/delay.c
3357 @@ -28,7 +28,7 @@
3358 /*
3359 * Default to the loop-based delay implementation.
3360 */
3361 -struct arm_delay_ops arm_delay_ops = {
3362 +struct arm_delay_ops arm_delay_ops __read_only = {
3363 .delay = __loop_delay,
3364 .const_udelay = __loop_const_udelay,
3365 .udelay = __loop_udelay,
3366 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3367 index 025f742..a9e5b3b 100644
3368 --- a/arch/arm/lib/uaccess_with_memcpy.c
3369 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3370 @@ -104,7 +104,7 @@ out:
3371 }
3372
3373 unsigned long
3374 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3375 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3376 {
3377 /*
3378 * This test is stubbed out of the main function above to keep
3379 @@ -155,7 +155,7 @@ out:
3380 return n;
3381 }
3382
3383 -unsigned long __clear_user(void __user *addr, unsigned long n)
3384 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3385 {
3386 /* See rational for this in __copy_to_user() above. */
3387 if (n < 64)
3388 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3389 index e9238b5..6ed904a 100644
3390 --- a/arch/arm/mach-kirkwood/common.c
3391 +++ b/arch/arm/mach-kirkwood/common.c
3392 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3393 clk_gate_ops.disable(hw);
3394 }
3395
3396 -static struct clk_ops clk_gate_fn_ops;
3397 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3398 +{
3399 + return clk_gate_ops.is_enabled(hw);
3400 +}
3401 +
3402 +static struct clk_ops clk_gate_fn_ops = {
3403 + .enable = clk_gate_fn_enable,
3404 + .disable = clk_gate_fn_disable,
3405 + .is_enabled = clk_gate_fn_is_enabled,
3406 +};
3407
3408 static struct clk __init *clk_register_gate_fn(struct device *dev,
3409 const char *name,
3410 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3411 gate_fn->fn_en = fn_en;
3412 gate_fn->fn_dis = fn_dis;
3413
3414 - /* ops is the gate ops, but with our enable/disable functions */
3415 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3416 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3417 - clk_gate_fn_ops = clk_gate_ops;
3418 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3419 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3420 - }
3421 -
3422 clk = clk_register(dev, &gate_fn->gate.hw);
3423
3424 if (IS_ERR(clk))
3425 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3426 index 827d1500..2885dc6 100644
3427 --- a/arch/arm/mach-omap2/board-n8x0.c
3428 +++ b/arch/arm/mach-omap2/board-n8x0.c
3429 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3430 }
3431 #endif
3432
3433 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3434 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3435 .late_init = n8x0_menelaus_late_init,
3436 };
3437
3438 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3439 index f3fdd6a..3564800 100644
3440 --- a/arch/arm/mach-omap2/gpmc.c
3441 +++ b/arch/arm/mach-omap2/gpmc.c
3442 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3443 };
3444
3445 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3446 -static struct irq_chip gpmc_irq_chip;
3447 static unsigned gpmc_irq_start;
3448
3449 static struct resource gpmc_mem_root;
3450 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3451
3452 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3453
3454 +static struct irq_chip gpmc_irq_chip = {
3455 + .name = "gpmc",
3456 + .irq_startup = gpmc_irq_noop_ret,
3457 + .irq_enable = gpmc_irq_enable,
3458 + .irq_disable = gpmc_irq_disable,
3459 + .irq_shutdown = gpmc_irq_noop,
3460 + .irq_ack = gpmc_irq_noop,
3461 + .irq_mask = gpmc_irq_noop,
3462 + .irq_unmask = gpmc_irq_noop,
3463 +
3464 +};
3465 +
3466 static int gpmc_setup_irq(void)
3467 {
3468 int i;
3469 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3470 return gpmc_irq_start;
3471 }
3472
3473 - gpmc_irq_chip.name = "gpmc";
3474 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3475 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3476 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3477 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3478 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3479 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3480 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3481 -
3482 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3483 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3484
3485 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3486 index f991016..145ebeb 100644
3487 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3488 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3489 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3490 int (*finish_suspend)(unsigned long cpu_state);
3491 void (*resume)(void);
3492 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3493 -};
3494 +} __no_const;
3495
3496 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3497 static struct powerdomain *mpuss_pd;
3498 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3499 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3500 {}
3501
3502 -struct cpu_pm_ops omap_pm_ops = {
3503 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3504 .finish_suspend = default_finish_suspend,
3505 .resume = dummy_cpu_resume,
3506 .scu_prepare = dummy_scu_prepare,
3507 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3508 index 813c615..ce467c6 100644
3509 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3510 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3511 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3512 return NOTIFY_OK;
3513 }
3514
3515 -static struct notifier_block __refdata irq_hotplug_notifier = {
3516 +static struct notifier_block irq_hotplug_notifier = {
3517 .notifier_call = irq_cpu_hotplug_notify,
3518 };
3519
3520 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3521 index f99f68e..e573e20 100644
3522 --- a/arch/arm/mach-omap2/omap_device.c
3523 +++ b/arch/arm/mach-omap2/omap_device.c
3524 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3525 struct platform_device __init *omap_device_build(const char *pdev_name,
3526 int pdev_id,
3527 struct omap_hwmod *oh,
3528 - void *pdata, int pdata_len)
3529 + const void *pdata, int pdata_len)
3530 {
3531 struct omap_hwmod *ohs[] = { oh };
3532
3533 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3534 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3535 int pdev_id,
3536 struct omap_hwmod **ohs,
3537 - int oh_cnt, void *pdata,
3538 + int oh_cnt, const void *pdata,
3539 int pdata_len)
3540 {
3541 int ret = -ENOMEM;
3542 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3543 index 17ca1ae..beba869 100644
3544 --- a/arch/arm/mach-omap2/omap_device.h
3545 +++ b/arch/arm/mach-omap2/omap_device.h
3546 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3547 /* Core code interface */
3548
3549 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3550 - struct omap_hwmod *oh, void *pdata,
3551 + struct omap_hwmod *oh, const void *pdata,
3552 int pdata_len);
3553
3554 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3555 struct omap_hwmod **oh, int oh_cnt,
3556 - void *pdata, int pdata_len);
3557 + const void *pdata, int pdata_len);
3558
3559 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3560 struct omap_hwmod **ohs, int oh_cnt);
3561 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3562 index 7f4db12..0243012 100644
3563 --- a/arch/arm/mach-omap2/omap_hwmod.c
3564 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3565 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3566 int (*init_clkdm)(struct omap_hwmod *oh);
3567 void (*update_context_lost)(struct omap_hwmod *oh);
3568 int (*get_context_lost)(struct omap_hwmod *oh);
3569 -};
3570 +} __no_const;
3571
3572 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3573 -static struct omap_hwmod_soc_ops soc_ops;
3574 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3575
3576 /* omap_hwmod_list contains all registered struct omap_hwmods */
3577 static LIST_HEAD(omap_hwmod_list);
3578 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3579 index d15c7bb..b2d1f0c 100644
3580 --- a/arch/arm/mach-omap2/wd_timer.c
3581 +++ b/arch/arm/mach-omap2/wd_timer.c
3582 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3583 struct omap_hwmod *oh;
3584 char *oh_name = "wd_timer2";
3585 char *dev_name = "omap_wdt";
3586 - struct omap_wd_timer_platform_data pdata;
3587 + static struct omap_wd_timer_platform_data pdata = {
3588 + .read_reset_sources = prm_read_reset_sources
3589 + };
3590
3591 if (!cpu_class_is_omap2() || of_have_populated_dt())
3592 return 0;
3593 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3594 return -EINVAL;
3595 }
3596
3597 - pdata.read_reset_sources = prm_read_reset_sources;
3598 -
3599 pdev = omap_device_build(dev_name, id, oh, &pdata,
3600 sizeof(struct omap_wd_timer_platform_data));
3601 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3602 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3603 index 706aa42..f85e9131 100644
3604 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3605 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3606 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3607 bool entered_lp2 = false;
3608
3609 if (tegra_pending_sgi())
3610 - ACCESS_ONCE(abort_flag) = true;
3611 + ACCESS_ONCE_RW(abort_flag) = true;
3612
3613 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3614
3615 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3616 index cad3ca86..1d79e0f 100644
3617 --- a/arch/arm/mach-ux500/setup.h
3618 +++ b/arch/arm/mach-ux500/setup.h
3619 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3620 .type = MT_DEVICE, \
3621 }
3622
3623 -#define __MEM_DEV_DESC(x, sz) { \
3624 - .virtual = IO_ADDRESS(x), \
3625 - .pfn = __phys_to_pfn(x), \
3626 - .length = sz, \
3627 - .type = MT_MEMORY, \
3628 -}
3629 -
3630 extern struct smp_operations ux500_smp_ops;
3631 extern void ux500_cpu_die(unsigned int cpu);
3632
3633 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3634 index cd2c88e..4dd9b67 100644
3635 --- a/arch/arm/mm/Kconfig
3636 +++ b/arch/arm/mm/Kconfig
3637 @@ -446,7 +446,7 @@ config CPU_32v5
3638
3639 config CPU_32v6
3640 bool
3641 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3642 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3643 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3644
3645 config CPU_32v6K
3646 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3647
3648 config CPU_USE_DOMAINS
3649 bool
3650 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3651 help
3652 This option enables or disables the use of domain switching
3653 via the set_fs() function.
3654 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3655 config KUSER_HELPERS
3656 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3657 default y
3658 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3659 help
3660 Warning: disabling this option may break user programs.
3661
3662 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3663 See Documentation/arm/kernel_user_helpers.txt for details.
3664
3665 However, the fixed address nature of these helpers can be used
3666 - by ROP (return orientated programming) authors when creating
3667 + by ROP (Return Oriented Programming) authors when creating
3668 exploits.
3669
3670 If all of the binaries and libraries which run on your platform
3671 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3672 index 6f4585b..7b6f52b 100644
3673 --- a/arch/arm/mm/alignment.c
3674 +++ b/arch/arm/mm/alignment.c
3675 @@ -211,10 +211,12 @@ union offset_union {
3676 #define __get16_unaligned_check(ins,val,addr) \
3677 do { \
3678 unsigned int err = 0, v, a = addr; \
3679 + pax_open_userland(); \
3680 __get8_unaligned_check(ins,v,a,err); \
3681 val = v << ((BE) ? 8 : 0); \
3682 __get8_unaligned_check(ins,v,a,err); \
3683 val |= v << ((BE) ? 0 : 8); \
3684 + pax_close_userland(); \
3685 if (err) \
3686 goto fault; \
3687 } while (0)
3688 @@ -228,6 +230,7 @@ union offset_union {
3689 #define __get32_unaligned_check(ins,val,addr) \
3690 do { \
3691 unsigned int err = 0, v, a = addr; \
3692 + pax_open_userland(); \
3693 __get8_unaligned_check(ins,v,a,err); \
3694 val = v << ((BE) ? 24 : 0); \
3695 __get8_unaligned_check(ins,v,a,err); \
3696 @@ -236,6 +239,7 @@ union offset_union {
3697 val |= v << ((BE) ? 8 : 16); \
3698 __get8_unaligned_check(ins,v,a,err); \
3699 val |= v << ((BE) ? 0 : 24); \
3700 + pax_close_userland(); \
3701 if (err) \
3702 goto fault; \
3703 } while (0)
3704 @@ -249,6 +253,7 @@ union offset_union {
3705 #define __put16_unaligned_check(ins,val,addr) \
3706 do { \
3707 unsigned int err = 0, v = val, a = addr; \
3708 + pax_open_userland(); \
3709 __asm__( FIRST_BYTE_16 \
3710 ARM( "1: "ins" %1, [%2], #1\n" ) \
3711 THUMB( "1: "ins" %1, [%2]\n" ) \
3712 @@ -268,6 +273,7 @@ union offset_union {
3713 " .popsection\n" \
3714 : "=r" (err), "=&r" (v), "=&r" (a) \
3715 : "0" (err), "1" (v), "2" (a)); \
3716 + pax_close_userland(); \
3717 if (err) \
3718 goto fault; \
3719 } while (0)
3720 @@ -281,6 +287,7 @@ union offset_union {
3721 #define __put32_unaligned_check(ins,val,addr) \
3722 do { \
3723 unsigned int err = 0, v = val, a = addr; \
3724 + pax_open_userland(); \
3725 __asm__( FIRST_BYTE_32 \
3726 ARM( "1: "ins" %1, [%2], #1\n" ) \
3727 THUMB( "1: "ins" %1, [%2]\n" ) \
3728 @@ -310,6 +317,7 @@ union offset_union {
3729 " .popsection\n" \
3730 : "=r" (err), "=&r" (v), "=&r" (a) \
3731 : "0" (err), "1" (v), "2" (a)); \
3732 + pax_close_userland(); \
3733 if (err) \
3734 goto fault; \
3735 } while (0)
3736 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3737 index 4a05444..d21968c 100644
3738 --- a/arch/arm/mm/context.c
3739 +++ b/arch/arm/mm/context.c
3740 @@ -43,7 +43,7 @@
3741 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3742
3743 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3744 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3745 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3746 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3747
3748 static DEFINE_PER_CPU(atomic64_t, active_asids);
3749 @@ -183,7 +183,7 @@ static int is_reserved_asid(u64 asid)
3750 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3751 {
3752 u64 asid = atomic64_read(&mm->context.id);
3753 - u64 generation = atomic64_read(&asid_generation);
3754 + u64 generation = atomic64_read_unchecked(&asid_generation);
3755
3756 if (asid != 0 && is_reserved_asid(asid)) {
3757 /*
3758 @@ -201,7 +201,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3759 */
3760 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3761 if (asid == NUM_USER_ASIDS) {
3762 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3763 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3764 &asid_generation);
3765 flush_context(cpu);
3766 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3767 @@ -230,14 +230,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3768 cpu_set_reserved_ttbr0();
3769
3770 asid = atomic64_read(&mm->context.id);
3771 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3772 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3773 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3774 goto switch_mm_fastpath;
3775
3776 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3777 /* Check that our ASID belongs to the current generation. */
3778 asid = atomic64_read(&mm->context.id);
3779 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3780 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3781 asid = new_context(mm, cpu);
3782 atomic64_set(&mm->context.id, asid);
3783 }
3784 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3785 index c97f794..6461880 100644
3786 --- a/arch/arm/mm/fault.c
3787 +++ b/arch/arm/mm/fault.c
3788 @@ -25,6 +25,7 @@
3789 #include <asm/system_misc.h>
3790 #include <asm/system_info.h>
3791 #include <asm/tlbflush.h>
3792 +#include <asm/sections.h>
3793
3794 #include "fault.h"
3795
3796 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3797 if (fixup_exception(regs))
3798 return;
3799
3800 +#ifdef CONFIG_PAX_KERNEXEC
3801 + if ((fsr & FSR_WRITE) &&
3802 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3803 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3804 + {
3805 + if (current->signal->curr_ip)
3806 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3807 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3808 + else
3809 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3810 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3811 + }
3812 +#endif
3813 +
3814 /*
3815 * No handler, we'll have to terminate things with extreme prejudice.
3816 */
3817 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3818 }
3819 #endif
3820
3821 +#ifdef CONFIG_PAX_PAGEEXEC
3822 + if (fsr & FSR_LNX_PF) {
3823 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3824 + do_group_exit(SIGKILL);
3825 + }
3826 +#endif
3827 +
3828 tsk->thread.address = addr;
3829 tsk->thread.error_code = fsr;
3830 tsk->thread.trap_no = 14;
3831 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3832 }
3833 #endif /* CONFIG_MMU */
3834
3835 +#ifdef CONFIG_PAX_PAGEEXEC
3836 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3837 +{
3838 + long i;
3839 +
3840 + printk(KERN_ERR "PAX: bytes at PC: ");
3841 + for (i = 0; i < 20; i++) {
3842 + unsigned char c;
3843 + if (get_user(c, (__force unsigned char __user *)pc+i))
3844 + printk(KERN_CONT "?? ");
3845 + else
3846 + printk(KERN_CONT "%02x ", c);
3847 + }
3848 + printk("\n");
3849 +
3850 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3851 + for (i = -1; i < 20; i++) {
3852 + unsigned long c;
3853 + if (get_user(c, (__force unsigned long __user *)sp+i))
3854 + printk(KERN_CONT "???????? ");
3855 + else
3856 + printk(KERN_CONT "%08lx ", c);
3857 + }
3858 + printk("\n");
3859 +}
3860 +#endif
3861 +
3862 /*
3863 * First Level Translation Fault Handler
3864 *
3865 @@ -545,9 +594,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3866 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3867 struct siginfo info;
3868
3869 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3870 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3871 + if (current->signal->curr_ip)
3872 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3873 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3874 + else
3875 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3876 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3877 + goto die;
3878 + }
3879 +#endif
3880 +
3881 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3882 return;
3883
3884 +die:
3885 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3886 inf->name, fsr, addr);
3887
3888 @@ -571,15 +633,92 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3889 ifsr_info[nr].name = name;
3890 }
3891
3892 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3893 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3894 +
3895 asmlinkage void __exception
3896 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3897 {
3898 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3899 struct siginfo info;
3900 + unsigned long pc = instruction_pointer(regs);
3901 +
3902 + if (user_mode(regs)) {
3903 + unsigned long sigpage = current->mm->context.sigpage;
3904 +
3905 + if (sigpage <= pc && pc < sigpage + 7*4) {
3906 + if (pc < sigpage + 3*4)
3907 + sys_sigreturn(regs);
3908 + else
3909 + sys_rt_sigreturn(regs);
3910 + return;
3911 + }
3912 + if (pc == 0xffff0f60UL) {
3913 + /*
3914 + * PaX: __kuser_cmpxchg64 emulation
3915 + */
3916 + // TODO
3917 + //regs->ARM_pc = regs->ARM_lr;
3918 + //return;
3919 + }
3920 + if (pc == 0xffff0fa0UL) {
3921 + /*
3922 + * PaX: __kuser_memory_barrier emulation
3923 + */
3924 + // dmb(); implied by the exception
3925 + regs->ARM_pc = regs->ARM_lr;
3926 + return;
3927 + }
3928 + if (pc == 0xffff0fc0UL) {
3929 + /*
3930 + * PaX: __kuser_cmpxchg emulation
3931 + */
3932 + // TODO
3933 + //regs->ARM_pc = regs->ARM_lr;
3934 + //return;
3935 + }
3936 + if (pc == 0xffff0fe0UL) {
3937 + /*
3938 + * PaX: __kuser_get_tls emulation
3939 + */
3940 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3941 + regs->ARM_pc = regs->ARM_lr;
3942 + return;
3943 + }
3944 + }
3945 +
3946 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3947 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3948 + if (current->signal->curr_ip)
3949 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3950 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3951 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3952 + else
3953 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3954 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3955 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3956 + goto die;
3957 + }
3958 +#endif
3959 +
3960 +#ifdef CONFIG_PAX_REFCOUNT
3961 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3962 + unsigned int bkpt;
3963 +
3964 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3965 + current->thread.error_code = ifsr;
3966 + current->thread.trap_no = 0;
3967 + pax_report_refcount_overflow(regs);
3968 + fixup_exception(regs);
3969 + return;
3970 + }
3971 + }
3972 +#endif
3973
3974 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3975 return;
3976
3977 +die:
3978 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3979 inf->name, ifsr, addr);
3980
3981 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3982 index cf08bdf..772656c 100644
3983 --- a/arch/arm/mm/fault.h
3984 +++ b/arch/arm/mm/fault.h
3985 @@ -3,6 +3,7 @@
3986
3987 /*
3988 * Fault status register encodings. We steal bit 31 for our own purposes.
3989 + * Set when the FSR value is from an instruction fault.
3990 */
3991 #define FSR_LNX_PF (1 << 31)
3992 #define FSR_WRITE (1 << 11)
3993 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3994 }
3995 #endif
3996
3997 +/* valid for LPAE and !LPAE */
3998 +static inline int is_xn_fault(unsigned int fsr)
3999 +{
4000 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4001 +}
4002 +
4003 +static inline int is_domain_fault(unsigned int fsr)
4004 +{
4005 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4006 +}
4007 +
4008 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4009 unsigned long search_exception_table(unsigned long addr);
4010
4011 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4012 index 15225d8..25e2e3c 100644
4013 --- a/arch/arm/mm/init.c
4014 +++ b/arch/arm/mm/init.c
4015 @@ -30,6 +30,8 @@
4016 #include <asm/setup.h>
4017 #include <asm/tlb.h>
4018 #include <asm/fixmap.h>
4019 +#include <asm/system_info.h>
4020 +#include <asm/cp15.h>
4021
4022 #include <asm/mach/arch.h>
4023 #include <asm/mach/map.h>
4024 @@ -683,7 +685,46 @@ void free_initmem(void)
4025 {
4026 #ifdef CONFIG_HAVE_TCM
4027 extern char __tcm_start, __tcm_end;
4028 +#endif
4029
4030 +#ifdef CONFIG_PAX_KERNEXEC
4031 + unsigned long addr;
4032 + pgd_t *pgd;
4033 + pud_t *pud;
4034 + pmd_t *pmd;
4035 + int cpu_arch = cpu_architecture();
4036 + unsigned int cr = get_cr();
4037 +
4038 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4039 + /* make pages tables, etc before .text NX */
4040 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4041 + pgd = pgd_offset_k(addr);
4042 + pud = pud_offset(pgd, addr);
4043 + pmd = pmd_offset(pud, addr);
4044 + __section_update(pmd, addr, PMD_SECT_XN);
4045 + }
4046 + /* make init NX */
4047 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4048 + pgd = pgd_offset_k(addr);
4049 + pud = pud_offset(pgd, addr);
4050 + pmd = pmd_offset(pud, addr);
4051 + __section_update(pmd, addr, PMD_SECT_XN);
4052 + }
4053 + /* make kernel code/rodata RX */
4054 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4055 + pgd = pgd_offset_k(addr);
4056 + pud = pud_offset(pgd, addr);
4057 + pmd = pmd_offset(pud, addr);
4058 +#ifdef CONFIG_ARM_LPAE
4059 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4060 +#else
4061 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4062 +#endif
4063 + }
4064 + }
4065 +#endif
4066 +
4067 +#ifdef CONFIG_HAVE_TCM
4068 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4069 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4070 #endif
4071 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4072 index f123d6e..04bf569 100644
4073 --- a/arch/arm/mm/ioremap.c
4074 +++ b/arch/arm/mm/ioremap.c
4075 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4076 unsigned int mtype;
4077
4078 if (cached)
4079 - mtype = MT_MEMORY;
4080 + mtype = MT_MEMORY_RX;
4081 else
4082 - mtype = MT_MEMORY_NONCACHED;
4083 + mtype = MT_MEMORY_NONCACHED_RX;
4084
4085 return __arm_ioremap_caller(phys_addr, size, mtype,
4086 __builtin_return_address(0));
4087 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4088 index 0c63562..7128a90 100644
4089 --- a/arch/arm/mm/mmap.c
4090 +++ b/arch/arm/mm/mmap.c
4091 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4092 struct vm_area_struct *vma;
4093 int do_align = 0;
4094 int aliasing = cache_is_vipt_aliasing();
4095 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4096 struct vm_unmapped_area_info info;
4097
4098 /*
4099 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4100 if (len > TASK_SIZE)
4101 return -ENOMEM;
4102
4103 +#ifdef CONFIG_PAX_RANDMMAP
4104 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4105 +#endif
4106 +
4107 if (addr) {
4108 if (do_align)
4109 addr = COLOUR_ALIGN(addr, pgoff);
4110 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4111 addr = PAGE_ALIGN(addr);
4112
4113 vma = find_vma(mm, addr);
4114 - if (TASK_SIZE - len >= addr &&
4115 - (!vma || addr + len <= vma->vm_start))
4116 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4117 return addr;
4118 }
4119
4120 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4121 info.high_limit = TASK_SIZE;
4122 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4123 info.align_offset = pgoff << PAGE_SHIFT;
4124 + info.threadstack_offset = offset;
4125 return vm_unmapped_area(&info);
4126 }
4127
4128 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4129 unsigned long addr = addr0;
4130 int do_align = 0;
4131 int aliasing = cache_is_vipt_aliasing();
4132 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4133 struct vm_unmapped_area_info info;
4134
4135 /*
4136 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4137 return addr;
4138 }
4139
4140 +#ifdef CONFIG_PAX_RANDMMAP
4141 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4142 +#endif
4143 +
4144 /* requesting a specific address */
4145 if (addr) {
4146 if (do_align)
4147 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4148 else
4149 addr = PAGE_ALIGN(addr);
4150 vma = find_vma(mm, addr);
4151 - if (TASK_SIZE - len >= addr &&
4152 - (!vma || addr + len <= vma->vm_start))
4153 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4154 return addr;
4155 }
4156
4157 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4158 info.high_limit = mm->mmap_base;
4159 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4160 info.align_offset = pgoff << PAGE_SHIFT;
4161 + info.threadstack_offset = offset;
4162 addr = vm_unmapped_area(&info);
4163
4164 /*
4165 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4166 {
4167 unsigned long random_factor = 0UL;
4168
4169 +#ifdef CONFIG_PAX_RANDMMAP
4170 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4171 +#endif
4172 +
4173 /* 8 bits of randomness in 20 address space bits */
4174 if ((current->flags & PF_RANDOMIZE) &&
4175 !(current->personality & ADDR_NO_RANDOMIZE))
4176 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4177
4178 if (mmap_is_legacy()) {
4179 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4180 +
4181 +#ifdef CONFIG_PAX_RANDMMAP
4182 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4183 + mm->mmap_base += mm->delta_mmap;
4184 +#endif
4185 +
4186 mm->get_unmapped_area = arch_get_unmapped_area;
4187 } else {
4188 mm->mmap_base = mmap_base(random_factor);
4189 +
4190 +#ifdef CONFIG_PAX_RANDMMAP
4191 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4192 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4193 +#endif
4194 +
4195 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4196 }
4197 }
4198 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4199 index 53cdbd3..670f177 100644
4200 --- a/arch/arm/mm/mmu.c
4201 +++ b/arch/arm/mm/mmu.c
4202 @@ -36,6 +36,22 @@
4203 #include "mm.h"
4204 #include "tcm.h"
4205
4206 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4207 +void modify_domain(unsigned int dom, unsigned int type)
4208 +{
4209 + struct thread_info *thread = current_thread_info();
4210 + unsigned int domain = thread->cpu_domain;
4211 + /*
4212 + * DOMAIN_MANAGER might be defined to some other value,
4213 + * use the arch-defined constant
4214 + */
4215 + domain &= ~domain_val(dom, 3);
4216 + thread->cpu_domain = domain | domain_val(dom, type);
4217 + set_domain(thread->cpu_domain);
4218 +}
4219 +EXPORT_SYMBOL(modify_domain);
4220 +#endif
4221 +
4222 /*
4223 * empty_zero_page is a special page that is used for
4224 * zero-initialized data and COW.
4225 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4226
4227 #endif /* ifdef CONFIG_CPU_CP15 / else */
4228
4229 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4230 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4231 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4232
4233 -static struct mem_type mem_types[] = {
4234 +#ifdef CONFIG_PAX_KERNEXEC
4235 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4236 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4237 +#else
4238 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4239 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4240 +#endif
4241 +
4242 +static struct mem_type mem_types[] __read_only = {
4243 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4244 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4245 L_PTE_SHARED,
4246 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4247 [MT_UNCACHED] = {
4248 .prot_pte = PROT_PTE_DEVICE,
4249 .prot_l1 = PMD_TYPE_TABLE,
4250 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4251 + .prot_sect = PROT_SECT_DEVICE,
4252 .domain = DOMAIN_IO,
4253 },
4254 [MT_CACHECLEAN] = {
4255 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4256 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4257 .domain = DOMAIN_KERNEL,
4258 },
4259 #ifndef CONFIG_ARM_LPAE
4260 [MT_MINICLEAN] = {
4261 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4262 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4263 .domain = DOMAIN_KERNEL,
4264 },
4265 #endif
4266 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4267 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4268 L_PTE_RDONLY,
4269 .prot_l1 = PMD_TYPE_TABLE,
4270 - .domain = DOMAIN_USER,
4271 + .domain = DOMAIN_VECTORS,
4272 },
4273 [MT_HIGH_VECTORS] = {
4274 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4275 L_PTE_USER | L_PTE_RDONLY,
4276 .prot_l1 = PMD_TYPE_TABLE,
4277 - .domain = DOMAIN_USER,
4278 + .domain = DOMAIN_VECTORS,
4279 },
4280 - [MT_MEMORY] = {
4281 + [MT_MEMORY_RWX] = {
4282 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4283 .prot_l1 = PMD_TYPE_TABLE,
4284 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4285 .domain = DOMAIN_KERNEL,
4286 },
4287 + [MT_MEMORY_RW] = {
4288 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4289 + .prot_l1 = PMD_TYPE_TABLE,
4290 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4291 + .domain = DOMAIN_KERNEL,
4292 + },
4293 + [MT_MEMORY_RX] = {
4294 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4295 + .prot_l1 = PMD_TYPE_TABLE,
4296 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4297 + .domain = DOMAIN_KERNEL,
4298 + },
4299 [MT_ROM] = {
4300 - .prot_sect = PMD_TYPE_SECT,
4301 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4302 .domain = DOMAIN_KERNEL,
4303 },
4304 - [MT_MEMORY_NONCACHED] = {
4305 + [MT_MEMORY_NONCACHED_RW] = {
4306 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4307 L_PTE_MT_BUFFERABLE,
4308 .prot_l1 = PMD_TYPE_TABLE,
4309 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4310 .domain = DOMAIN_KERNEL,
4311 },
4312 + [MT_MEMORY_NONCACHED_RX] = {
4313 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4314 + L_PTE_MT_BUFFERABLE,
4315 + .prot_l1 = PMD_TYPE_TABLE,
4316 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4317 + .domain = DOMAIN_KERNEL,
4318 + },
4319 [MT_MEMORY_DTCM] = {
4320 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4321 - L_PTE_XN,
4322 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4323 .prot_l1 = PMD_TYPE_TABLE,
4324 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4325 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4326 .domain = DOMAIN_KERNEL,
4327 },
4328 [MT_MEMORY_ITCM] = {
4329 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4330 },
4331 [MT_MEMORY_SO] = {
4332 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4333 - L_PTE_MT_UNCACHED | L_PTE_XN,
4334 + L_PTE_MT_UNCACHED,
4335 .prot_l1 = PMD_TYPE_TABLE,
4336 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4337 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4338 + PMD_SECT_UNCACHED,
4339 .domain = DOMAIN_KERNEL,
4340 },
4341 [MT_MEMORY_DMA_READY] = {
4342 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4343 * to prevent speculative instruction fetches.
4344 */
4345 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4346 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4347 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4348 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4349 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4350 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4351 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4352 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4353 +
4354 + /* Mark other regions on ARMv6+ as execute-never */
4355 +
4356 +#ifdef CONFIG_PAX_KERNEXEC
4357 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4358 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4359 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4360 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4361 +#ifndef CONFIG_ARM_LPAE
4362 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4363 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4364 +#endif
4365 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4366 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4367 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4368 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4369 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4370 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4371 +#endif
4372 +
4373 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4374 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4375 }
4376 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4377 /*
4378 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4379 * from SVC mode and no access from userspace.
4380 */
4381 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4382 +#ifdef CONFIG_PAX_KERNEXEC
4383 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4384 +#endif
4385 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4386 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4387 #endif
4388 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4389 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4390 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4391 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4392 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4393 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4394 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4395 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4396 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4397 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4398 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4399 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4400 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4401 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4402 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4403 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4404 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4405 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4406 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4407 }
4408 }
4409
4410 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4411 if (cpu_arch >= CPU_ARCH_ARMv6) {
4412 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4413 /* Non-cacheable Normal is XCB = 001 */
4414 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4415 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4416 + PMD_SECT_BUFFERED;
4417 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4418 PMD_SECT_BUFFERED;
4419 } else {
4420 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4421 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4422 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4423 + PMD_SECT_TEX(1);
4424 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4425 PMD_SECT_TEX(1);
4426 }
4427 } else {
4428 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4429 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4430 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4431 }
4432
4433 #ifdef CONFIG_ARM_LPAE
4434 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4435 vecs_pgprot |= PTE_EXT_AF;
4436 #endif
4437
4438 + user_pgprot |= __supported_pte_mask;
4439 +
4440 for (i = 0; i < 16; i++) {
4441 pteval_t v = pgprot_val(protection_map[i]);
4442 protection_map[i] = __pgprot(v | user_pgprot);
4443 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4444
4445 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4446 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4447 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4448 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4449 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4450 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4451 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4452 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4453 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4454 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4455 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4456 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4457 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4458 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4459 mem_types[MT_ROM].prot_sect |= cp->pmd;
4460
4461 switch (cp->pmd) {
4462 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4463 * called function. This means you can't use any function or debugging
4464 * method which may touch any device, otherwise the kernel _will_ crash.
4465 */
4466 +
4467 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4468 +
4469 static void __init devicemaps_init(struct machine_desc *mdesc)
4470 {
4471 struct map_desc map;
4472 unsigned long addr;
4473 - void *vectors;
4474
4475 - /*
4476 - * Allocate the vector page early.
4477 - */
4478 - vectors = early_alloc(PAGE_SIZE * 2);
4479 -
4480 - early_trap_init(vectors);
4481 + early_trap_init(&vectors);
4482
4483 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4484 pmd_clear(pmd_off_k(addr));
4485 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4486 * location (0xffff0000). If we aren't using high-vectors, also
4487 * create a mapping at the low-vectors virtual address.
4488 */
4489 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4490 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4491 map.virtual = 0xffff0000;
4492 map.length = PAGE_SIZE;
4493 #ifdef CONFIG_KUSER_HELPERS
4494 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4495 map.pfn = __phys_to_pfn(start);
4496 map.virtual = __phys_to_virt(start);
4497 map.length = end - start;
4498 - map.type = MT_MEMORY;
4499
4500 +#ifdef CONFIG_PAX_KERNEXEC
4501 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4502 + struct map_desc kernel;
4503 + struct map_desc initmap;
4504 +
4505 + /* when freeing initmem we will make this RW */
4506 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4507 + initmap.virtual = (unsigned long)__init_begin;
4508 + initmap.length = _sdata - __init_begin;
4509 + initmap.type = MT_MEMORY_RWX;
4510 + create_mapping(&initmap);
4511 +
4512 + /* when freeing initmem we will make this RX */
4513 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4514 + kernel.virtual = (unsigned long)_stext;
4515 + kernel.length = __init_begin - _stext;
4516 + kernel.type = MT_MEMORY_RWX;
4517 + create_mapping(&kernel);
4518 +
4519 + if (map.virtual < (unsigned long)_stext) {
4520 + map.length = (unsigned long)_stext - map.virtual;
4521 + map.type = MT_MEMORY_RWX;
4522 + create_mapping(&map);
4523 + }
4524 +
4525 + map.pfn = __phys_to_pfn(__pa(_sdata));
4526 + map.virtual = (unsigned long)_sdata;
4527 + map.length = end - __pa(_sdata);
4528 + }
4529 +#endif
4530 +
4531 + map.type = MT_MEMORY_RW;
4532 create_mapping(&map);
4533 }
4534 }
4535 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4536 index a5bc92d..0bb4730 100644
4537 --- a/arch/arm/plat-omap/sram.c
4538 +++ b/arch/arm/plat-omap/sram.c
4539 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4540 * Looks like we need to preserve some bootloader code at the
4541 * beginning of SRAM for jumping to flash for reboot to work...
4542 */
4543 + pax_open_kernel();
4544 memset_io(omap_sram_base + omap_sram_skip, 0,
4545 omap_sram_size - omap_sram_skip);
4546 + pax_close_kernel();
4547 }
4548 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4549 index ce6d763..cfea917 100644
4550 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4551 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4552 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4553 int (*started)(unsigned ch);
4554 int (*flush)(unsigned ch);
4555 int (*stop)(unsigned ch);
4556 -};
4557 +} __no_const;
4558
4559 extern void *samsung_dmadev_get_ops(void);
4560 extern void *s3c_dma_get_ops(void);
4561 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4562 index c3a58a1..78fbf54 100644
4563 --- a/arch/avr32/include/asm/cache.h
4564 +++ b/arch/avr32/include/asm/cache.h
4565 @@ -1,8 +1,10 @@
4566 #ifndef __ASM_AVR32_CACHE_H
4567 #define __ASM_AVR32_CACHE_H
4568
4569 +#include <linux/const.h>
4570 +
4571 #define L1_CACHE_SHIFT 5
4572 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4573 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4574
4575 /*
4576 * Memory returned by kmalloc() may be used for DMA, so we must make
4577 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4578 index d232888..87c8df1 100644
4579 --- a/arch/avr32/include/asm/elf.h
4580 +++ b/arch/avr32/include/asm/elf.h
4581 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4582 the loader. We need to make sure that it is out of the way of the program
4583 that it will "exec", and that there is sufficient room for the brk. */
4584
4585 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4586 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4587
4588 +#ifdef CONFIG_PAX_ASLR
4589 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4590 +
4591 +#define PAX_DELTA_MMAP_LEN 15
4592 +#define PAX_DELTA_STACK_LEN 15
4593 +#endif
4594
4595 /* This yields a mask that user programs can use to figure out what
4596 instruction set this CPU supports. This could be done in user space,
4597 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4598 index 479330b..53717a8 100644
4599 --- a/arch/avr32/include/asm/kmap_types.h
4600 +++ b/arch/avr32/include/asm/kmap_types.h
4601 @@ -2,9 +2,9 @@
4602 #define __ASM_AVR32_KMAP_TYPES_H
4603
4604 #ifdef CONFIG_DEBUG_HIGHMEM
4605 -# define KM_TYPE_NR 29
4606 +# define KM_TYPE_NR 30
4607 #else
4608 -# define KM_TYPE_NR 14
4609 +# define KM_TYPE_NR 15
4610 #endif
4611
4612 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4613 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4614 index b2f2d2d..d1c85cb 100644
4615 --- a/arch/avr32/mm/fault.c
4616 +++ b/arch/avr32/mm/fault.c
4617 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4618
4619 int exception_trace = 1;
4620
4621 +#ifdef CONFIG_PAX_PAGEEXEC
4622 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4623 +{
4624 + unsigned long i;
4625 +
4626 + printk(KERN_ERR "PAX: bytes at PC: ");
4627 + for (i = 0; i < 20; i++) {
4628 + unsigned char c;
4629 + if (get_user(c, (unsigned char *)pc+i))
4630 + printk(KERN_CONT "???????? ");
4631 + else
4632 + printk(KERN_CONT "%02x ", c);
4633 + }
4634 + printk("\n");
4635 +}
4636 +#endif
4637 +
4638 /*
4639 * This routine handles page faults. It determines the address and the
4640 * problem, and then passes it off to one of the appropriate routines.
4641 @@ -174,6 +191,16 @@ bad_area:
4642 up_read(&mm->mmap_sem);
4643
4644 if (user_mode(regs)) {
4645 +
4646 +#ifdef CONFIG_PAX_PAGEEXEC
4647 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4648 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4649 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4650 + do_group_exit(SIGKILL);
4651 + }
4652 + }
4653 +#endif
4654 +
4655 if (exception_trace && printk_ratelimit())
4656 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4657 "sp %08lx ecr %lu\n",
4658 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4659 index 568885a..f8008df 100644
4660 --- a/arch/blackfin/include/asm/cache.h
4661 +++ b/arch/blackfin/include/asm/cache.h
4662 @@ -7,6 +7,7 @@
4663 #ifndef __ARCH_BLACKFIN_CACHE_H
4664 #define __ARCH_BLACKFIN_CACHE_H
4665
4666 +#include <linux/const.h>
4667 #include <linux/linkage.h> /* for asmlinkage */
4668
4669 /*
4670 @@ -14,7 +15,7 @@
4671 * Blackfin loads 32 bytes for cache
4672 */
4673 #define L1_CACHE_SHIFT 5
4674 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4675 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4676 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4677
4678 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4679 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4680 index aea2718..3639a60 100644
4681 --- a/arch/cris/include/arch-v10/arch/cache.h
4682 +++ b/arch/cris/include/arch-v10/arch/cache.h
4683 @@ -1,8 +1,9 @@
4684 #ifndef _ASM_ARCH_CACHE_H
4685 #define _ASM_ARCH_CACHE_H
4686
4687 +#include <linux/const.h>
4688 /* Etrax 100LX have 32-byte cache-lines. */
4689 -#define L1_CACHE_BYTES 32
4690 #define L1_CACHE_SHIFT 5
4691 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4692
4693 #endif /* _ASM_ARCH_CACHE_H */
4694 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4695 index 7caf25d..ee65ac5 100644
4696 --- a/arch/cris/include/arch-v32/arch/cache.h
4697 +++ b/arch/cris/include/arch-v32/arch/cache.h
4698 @@ -1,11 +1,12 @@
4699 #ifndef _ASM_CRIS_ARCH_CACHE_H
4700 #define _ASM_CRIS_ARCH_CACHE_H
4701
4702 +#include <linux/const.h>
4703 #include <arch/hwregs/dma.h>
4704
4705 /* A cache-line is 32 bytes. */
4706 -#define L1_CACHE_BYTES 32
4707 #define L1_CACHE_SHIFT 5
4708 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4709
4710 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4711
4712 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4713 index b86329d..6709906 100644
4714 --- a/arch/frv/include/asm/atomic.h
4715 +++ b/arch/frv/include/asm/atomic.h
4716 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4717 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4718 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4719
4720 +#define atomic64_read_unchecked(v) atomic64_read(v)
4721 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4722 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4723 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4724 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4725 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4726 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4727 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4728 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4729 +
4730 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4731 {
4732 int c, old;
4733 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4734 index 2797163..c2a401d 100644
4735 --- a/arch/frv/include/asm/cache.h
4736 +++ b/arch/frv/include/asm/cache.h
4737 @@ -12,10 +12,11 @@
4738 #ifndef __ASM_CACHE_H
4739 #define __ASM_CACHE_H
4740
4741 +#include <linux/const.h>
4742
4743 /* bytes per L1 cache line */
4744 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4745 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4746 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4747
4748 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4749 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4750 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4751 index 43901f2..0d8b865 100644
4752 --- a/arch/frv/include/asm/kmap_types.h
4753 +++ b/arch/frv/include/asm/kmap_types.h
4754 @@ -2,6 +2,6 @@
4755 #ifndef _ASM_KMAP_TYPES_H
4756 #define _ASM_KMAP_TYPES_H
4757
4758 -#define KM_TYPE_NR 17
4759 +#define KM_TYPE_NR 18
4760
4761 #endif
4762 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4763 index 836f147..4cf23f5 100644
4764 --- a/arch/frv/mm/elf-fdpic.c
4765 +++ b/arch/frv/mm/elf-fdpic.c
4766 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4767 {
4768 struct vm_area_struct *vma;
4769 struct vm_unmapped_area_info info;
4770 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4771
4772 if (len > TASK_SIZE)
4773 return -ENOMEM;
4774 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4775 if (addr) {
4776 addr = PAGE_ALIGN(addr);
4777 vma = find_vma(current->mm, addr);
4778 - if (TASK_SIZE - len >= addr &&
4779 - (!vma || addr + len <= vma->vm_start))
4780 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4781 goto success;
4782 }
4783
4784 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4785 info.high_limit = (current->mm->start_stack - 0x00200000);
4786 info.align_mask = 0;
4787 info.align_offset = 0;
4788 + info.threadstack_offset = offset;
4789 addr = vm_unmapped_area(&info);
4790 if (!(addr & ~PAGE_MASK))
4791 goto success;
4792 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4793 index f4ca594..adc72fd6 100644
4794 --- a/arch/hexagon/include/asm/cache.h
4795 +++ b/arch/hexagon/include/asm/cache.h
4796 @@ -21,9 +21,11 @@
4797 #ifndef __ASM_CACHE_H
4798 #define __ASM_CACHE_H
4799
4800 +#include <linux/const.h>
4801 +
4802 /* Bytes per L1 cache line */
4803 -#define L1_CACHE_SHIFT (5)
4804 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4805 +#define L1_CACHE_SHIFT 5
4806 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4807
4808 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4809 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4810 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4811 index 6e6fe18..a6ae668 100644
4812 --- a/arch/ia64/include/asm/atomic.h
4813 +++ b/arch/ia64/include/asm/atomic.h
4814 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4815 #define atomic64_inc(v) atomic64_add(1, (v))
4816 #define atomic64_dec(v) atomic64_sub(1, (v))
4817
4818 +#define atomic64_read_unchecked(v) atomic64_read(v)
4819 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4820 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4821 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4822 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4823 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4824 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4825 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4826 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4827 +
4828 /* Atomic operations are already serializing */
4829 #define smp_mb__before_atomic_dec() barrier()
4830 #define smp_mb__after_atomic_dec() barrier()
4831 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4832 index 988254a..e1ee885 100644
4833 --- a/arch/ia64/include/asm/cache.h
4834 +++ b/arch/ia64/include/asm/cache.h
4835 @@ -1,6 +1,7 @@
4836 #ifndef _ASM_IA64_CACHE_H
4837 #define _ASM_IA64_CACHE_H
4838
4839 +#include <linux/const.h>
4840
4841 /*
4842 * Copyright (C) 1998-2000 Hewlett-Packard Co
4843 @@ -9,7 +10,7 @@
4844
4845 /* Bytes per L1 (data) cache line. */
4846 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4847 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4848 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4849
4850 #ifdef CONFIG_SMP
4851 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4852 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4853 index 5a83c5c..4d7f553 100644
4854 --- a/arch/ia64/include/asm/elf.h
4855 +++ b/arch/ia64/include/asm/elf.h
4856 @@ -42,6 +42,13 @@
4857 */
4858 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4859
4860 +#ifdef CONFIG_PAX_ASLR
4861 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4862 +
4863 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4864 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4865 +#endif
4866 +
4867 #define PT_IA_64_UNWIND 0x70000001
4868
4869 /* IA-64 relocations: */
4870 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4871 index 96a8d92..617a1cf 100644
4872 --- a/arch/ia64/include/asm/pgalloc.h
4873 +++ b/arch/ia64/include/asm/pgalloc.h
4874 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4875 pgd_val(*pgd_entry) = __pa(pud);
4876 }
4877
4878 +static inline void
4879 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4880 +{
4881 + pgd_populate(mm, pgd_entry, pud);
4882 +}
4883 +
4884 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4885 {
4886 return quicklist_alloc(0, GFP_KERNEL, NULL);
4887 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4888 pud_val(*pud_entry) = __pa(pmd);
4889 }
4890
4891 +static inline void
4892 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4893 +{
4894 + pud_populate(mm, pud_entry, pmd);
4895 +}
4896 +
4897 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4898 {
4899 return quicklist_alloc(0, GFP_KERNEL, NULL);
4900 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4901 index 7935115..c0eca6a 100644
4902 --- a/arch/ia64/include/asm/pgtable.h
4903 +++ b/arch/ia64/include/asm/pgtable.h
4904 @@ -12,7 +12,7 @@
4905 * David Mosberger-Tang <davidm@hpl.hp.com>
4906 */
4907
4908 -
4909 +#include <linux/const.h>
4910 #include <asm/mman.h>
4911 #include <asm/page.h>
4912 #include <asm/processor.h>
4913 @@ -142,6 +142,17 @@
4914 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4915 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4916 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4917 +
4918 +#ifdef CONFIG_PAX_PAGEEXEC
4919 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4920 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4921 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4922 +#else
4923 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4924 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4925 +# define PAGE_COPY_NOEXEC PAGE_COPY
4926 +#endif
4927 +
4928 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4929 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4930 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4931 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4932 index 54ff557..70c88b7 100644
4933 --- a/arch/ia64/include/asm/spinlock.h
4934 +++ b/arch/ia64/include/asm/spinlock.h
4935 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4936 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4937
4938 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4939 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4940 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4941 }
4942
4943 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4944 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4945 index 449c8c0..18965fb 100644
4946 --- a/arch/ia64/include/asm/uaccess.h
4947 +++ b/arch/ia64/include/asm/uaccess.h
4948 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4949 static inline unsigned long
4950 __copy_to_user (void __user *to, const void *from, unsigned long count)
4951 {
4952 + if (count > INT_MAX)
4953 + return count;
4954 +
4955 + if (!__builtin_constant_p(count))
4956 + check_object_size(from, count, true);
4957 +
4958 return __copy_user(to, (__force void __user *) from, count);
4959 }
4960
4961 static inline unsigned long
4962 __copy_from_user (void *to, const void __user *from, unsigned long count)
4963 {
4964 + if (count > INT_MAX)
4965 + return count;
4966 +
4967 + if (!__builtin_constant_p(count))
4968 + check_object_size(to, count, false);
4969 +
4970 return __copy_user((__force void __user *) to, from, count);
4971 }
4972
4973 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4974 ({ \
4975 void __user *__cu_to = (to); \
4976 const void *__cu_from = (from); \
4977 - long __cu_len = (n); \
4978 + unsigned long __cu_len = (n); \
4979 \
4980 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4981 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4982 + if (!__builtin_constant_p(n)) \
4983 + check_object_size(__cu_from, __cu_len, true); \
4984 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4985 + } \
4986 __cu_len; \
4987 })
4988
4989 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4990 ({ \
4991 void *__cu_to = (to); \
4992 const void __user *__cu_from = (from); \
4993 - long __cu_len = (n); \
4994 + unsigned long __cu_len = (n); \
4995 \
4996 __chk_user_ptr(__cu_from); \
4997 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4998 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4999 + if (!__builtin_constant_p(n)) \
5000 + check_object_size(__cu_to, __cu_len, false); \
5001 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5002 + } \
5003 __cu_len; \
5004 })
5005
5006 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5007 index 24603be..948052d 100644
5008 --- a/arch/ia64/kernel/module.c
5009 +++ b/arch/ia64/kernel/module.c
5010 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5011 void
5012 module_free (struct module *mod, void *module_region)
5013 {
5014 - if (mod && mod->arch.init_unw_table &&
5015 - module_region == mod->module_init) {
5016 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5017 unw_remove_unwind_table(mod->arch.init_unw_table);
5018 mod->arch.init_unw_table = NULL;
5019 }
5020 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5021 }
5022
5023 static inline int
5024 +in_init_rx (const struct module *mod, uint64_t addr)
5025 +{
5026 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5027 +}
5028 +
5029 +static inline int
5030 +in_init_rw (const struct module *mod, uint64_t addr)
5031 +{
5032 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5033 +}
5034 +
5035 +static inline int
5036 in_init (const struct module *mod, uint64_t addr)
5037 {
5038 - return addr - (uint64_t) mod->module_init < mod->init_size;
5039 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5040 +}
5041 +
5042 +static inline int
5043 +in_core_rx (const struct module *mod, uint64_t addr)
5044 +{
5045 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5046 +}
5047 +
5048 +static inline int
5049 +in_core_rw (const struct module *mod, uint64_t addr)
5050 +{
5051 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5052 }
5053
5054 static inline int
5055 in_core (const struct module *mod, uint64_t addr)
5056 {
5057 - return addr - (uint64_t) mod->module_core < mod->core_size;
5058 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5059 }
5060
5061 static inline int
5062 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5063 break;
5064
5065 case RV_BDREL:
5066 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5067 + if (in_init_rx(mod, val))
5068 + val -= (uint64_t) mod->module_init_rx;
5069 + else if (in_init_rw(mod, val))
5070 + val -= (uint64_t) mod->module_init_rw;
5071 + else if (in_core_rx(mod, val))
5072 + val -= (uint64_t) mod->module_core_rx;
5073 + else if (in_core_rw(mod, val))
5074 + val -= (uint64_t) mod->module_core_rw;
5075 break;
5076
5077 case RV_LTV:
5078 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5079 * addresses have been selected...
5080 */
5081 uint64_t gp;
5082 - if (mod->core_size > MAX_LTOFF)
5083 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5084 /*
5085 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5086 * at the end of the module.
5087 */
5088 - gp = mod->core_size - MAX_LTOFF / 2;
5089 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5090 else
5091 - gp = mod->core_size / 2;
5092 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5093 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5094 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5095 mod->arch.gp = gp;
5096 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5097 }
5098 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5099 index ab33328..f39506c 100644
5100 --- a/arch/ia64/kernel/palinfo.c
5101 +++ b/arch/ia64/kernel/palinfo.c
5102 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5103 return NOTIFY_OK;
5104 }
5105
5106 -static struct notifier_block __refdata palinfo_cpu_notifier =
5107 +static struct notifier_block palinfo_cpu_notifier =
5108 {
5109 .notifier_call = palinfo_cpu_callback,
5110 .priority = 0,
5111 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5112 index 41e33f8..65180b2 100644
5113 --- a/arch/ia64/kernel/sys_ia64.c
5114 +++ b/arch/ia64/kernel/sys_ia64.c
5115 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5116 unsigned long align_mask = 0;
5117 struct mm_struct *mm = current->mm;
5118 struct vm_unmapped_area_info info;
5119 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5120
5121 if (len > RGN_MAP_LIMIT)
5122 return -ENOMEM;
5123 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5124 if (REGION_NUMBER(addr) == RGN_HPAGE)
5125 addr = 0;
5126 #endif
5127 +
5128 +#ifdef CONFIG_PAX_RANDMMAP
5129 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5130 + addr = mm->free_area_cache;
5131 + else
5132 +#endif
5133 +
5134 if (!addr)
5135 addr = TASK_UNMAPPED_BASE;
5136
5137 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5138 info.high_limit = TASK_SIZE;
5139 info.align_mask = align_mask;
5140 info.align_offset = 0;
5141 + info.threadstack_offset = offset;
5142 return vm_unmapped_area(&info);
5143 }
5144
5145 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5146 index 0ccb28f..8992469 100644
5147 --- a/arch/ia64/kernel/vmlinux.lds.S
5148 +++ b/arch/ia64/kernel/vmlinux.lds.S
5149 @@ -198,7 +198,7 @@ SECTIONS {
5150 /* Per-cpu data: */
5151 . = ALIGN(PERCPU_PAGE_SIZE);
5152 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5153 - __phys_per_cpu_start = __per_cpu_load;
5154 + __phys_per_cpu_start = per_cpu_load;
5155 /*
5156 * ensure percpu data fits
5157 * into percpu page size
5158 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5159 index 6cf0341..d352594 100644
5160 --- a/arch/ia64/mm/fault.c
5161 +++ b/arch/ia64/mm/fault.c
5162 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5163 return pte_present(pte);
5164 }
5165
5166 +#ifdef CONFIG_PAX_PAGEEXEC
5167 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5168 +{
5169 + unsigned long i;
5170 +
5171 + printk(KERN_ERR "PAX: bytes at PC: ");
5172 + for (i = 0; i < 8; i++) {
5173 + unsigned int c;
5174 + if (get_user(c, (unsigned int *)pc+i))
5175 + printk(KERN_CONT "???????? ");
5176 + else
5177 + printk(KERN_CONT "%08x ", c);
5178 + }
5179 + printk("\n");
5180 +}
5181 +#endif
5182 +
5183 # define VM_READ_BIT 0
5184 # define VM_WRITE_BIT 1
5185 # define VM_EXEC_BIT 2
5186 @@ -149,8 +166,21 @@ retry:
5187 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5188 goto bad_area;
5189
5190 - if ((vma->vm_flags & mask) != mask)
5191 + if ((vma->vm_flags & mask) != mask) {
5192 +
5193 +#ifdef CONFIG_PAX_PAGEEXEC
5194 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5195 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5196 + goto bad_area;
5197 +
5198 + up_read(&mm->mmap_sem);
5199 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5200 + do_group_exit(SIGKILL);
5201 + }
5202 +#endif
5203 +
5204 goto bad_area;
5205 + }
5206
5207 /*
5208 * If for any reason at all we couldn't handle the fault, make
5209 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5210 index 76069c1..c2aa816 100644
5211 --- a/arch/ia64/mm/hugetlbpage.c
5212 +++ b/arch/ia64/mm/hugetlbpage.c
5213 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5214 unsigned long pgoff, unsigned long flags)
5215 {
5216 struct vm_unmapped_area_info info;
5217 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5218
5219 if (len > RGN_MAP_LIMIT)
5220 return -ENOMEM;
5221 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5222 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5223 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5224 info.align_offset = 0;
5225 + info.threadstack_offset = offset;
5226 return vm_unmapped_area(&info);
5227 }
5228
5229 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5230 index b6f7f43..c04320d 100644
5231 --- a/arch/ia64/mm/init.c
5232 +++ b/arch/ia64/mm/init.c
5233 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5234 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5235 vma->vm_end = vma->vm_start + PAGE_SIZE;
5236 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5237 +
5238 +#ifdef CONFIG_PAX_PAGEEXEC
5239 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5240 + vma->vm_flags &= ~VM_EXEC;
5241 +
5242 +#ifdef CONFIG_PAX_MPROTECT
5243 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5244 + vma->vm_flags &= ~VM_MAYEXEC;
5245 +#endif
5246 +
5247 + }
5248 +#endif
5249 +
5250 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5251 down_write(&current->mm->mmap_sem);
5252 if (insert_vm_struct(current->mm, vma)) {
5253 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5254 index 40b3ee9..8c2c112 100644
5255 --- a/arch/m32r/include/asm/cache.h
5256 +++ b/arch/m32r/include/asm/cache.h
5257 @@ -1,8 +1,10 @@
5258 #ifndef _ASM_M32R_CACHE_H
5259 #define _ASM_M32R_CACHE_H
5260
5261 +#include <linux/const.h>
5262 +
5263 /* L1 cache line size */
5264 #define L1_CACHE_SHIFT 4
5265 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5266 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5267
5268 #endif /* _ASM_M32R_CACHE_H */
5269 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5270 index 82abd15..d95ae5d 100644
5271 --- a/arch/m32r/lib/usercopy.c
5272 +++ b/arch/m32r/lib/usercopy.c
5273 @@ -14,6 +14,9 @@
5274 unsigned long
5275 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5276 {
5277 + if ((long)n < 0)
5278 + return n;
5279 +
5280 prefetch(from);
5281 if (access_ok(VERIFY_WRITE, to, n))
5282 __copy_user(to,from,n);
5283 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5284 unsigned long
5285 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5286 {
5287 + if ((long)n < 0)
5288 + return n;
5289 +
5290 prefetchw(to);
5291 if (access_ok(VERIFY_READ, from, n))
5292 __copy_user_zeroing(to,from,n);
5293 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5294 index 0395c51..5f26031 100644
5295 --- a/arch/m68k/include/asm/cache.h
5296 +++ b/arch/m68k/include/asm/cache.h
5297 @@ -4,9 +4,11 @@
5298 #ifndef __ARCH_M68K_CACHE_H
5299 #define __ARCH_M68K_CACHE_H
5300
5301 +#include <linux/const.h>
5302 +
5303 /* bytes per L1 cache line */
5304 #define L1_CACHE_SHIFT 4
5305 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5306 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5307
5308 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5309
5310 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5311 index 3c52fa6..11b2ad8 100644
5312 --- a/arch/metag/mm/hugetlbpage.c
5313 +++ b/arch/metag/mm/hugetlbpage.c
5314 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5315 info.high_limit = TASK_SIZE;
5316 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5317 info.align_offset = 0;
5318 + info.threadstack_offset = 0;
5319 return vm_unmapped_area(&info);
5320 }
5321
5322 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5323 index 4efe96a..60e8699 100644
5324 --- a/arch/microblaze/include/asm/cache.h
5325 +++ b/arch/microblaze/include/asm/cache.h
5326 @@ -13,11 +13,12 @@
5327 #ifndef _ASM_MICROBLAZE_CACHE_H
5328 #define _ASM_MICROBLAZE_CACHE_H
5329
5330 +#include <linux/const.h>
5331 #include <asm/registers.h>
5332
5333 #define L1_CACHE_SHIFT 5
5334 /* word-granular cache in microblaze */
5335 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5336 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5337
5338 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5339
5340 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5341 index 08b6079..8b554d2 100644
5342 --- a/arch/mips/include/asm/atomic.h
5343 +++ b/arch/mips/include/asm/atomic.h
5344 @@ -21,15 +21,39 @@
5345 #include <asm/cmpxchg.h>
5346 #include <asm/war.h>
5347
5348 +#ifdef CONFIG_GENERIC_ATOMIC64
5349 +#include <asm-generic/atomic64.h>
5350 +#endif
5351 +
5352 #define ATOMIC_INIT(i) { (i) }
5353
5354 +#ifdef CONFIG_64BIT
5355 +#define _ASM_EXTABLE(from, to) \
5356 +" .section __ex_table,\"a\"\n" \
5357 +" .dword " #from ", " #to"\n" \
5358 +" .previous\n"
5359 +#else
5360 +#define _ASM_EXTABLE(from, to) \
5361 +" .section __ex_table,\"a\"\n" \
5362 +" .word " #from ", " #to"\n" \
5363 +" .previous\n"
5364 +#endif
5365 +
5366 /*
5367 * atomic_read - read atomic variable
5368 * @v: pointer of type atomic_t
5369 *
5370 * Atomically reads the value of @v.
5371 */
5372 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5373 +static inline int atomic_read(const atomic_t *v)
5374 +{
5375 + return (*(volatile const int *) &v->counter);
5376 +}
5377 +
5378 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5379 +{
5380 + return (*(volatile const int *) &v->counter);
5381 +}
5382
5383 /*
5384 * atomic_set - set atomic variable
5385 @@ -38,7 +62,15 @@
5386 *
5387 * Atomically sets the value of @v to @i.
5388 */
5389 -#define atomic_set(v, i) ((v)->counter = (i))
5390 +static inline void atomic_set(atomic_t *v, int i)
5391 +{
5392 + v->counter = i;
5393 +}
5394 +
5395 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5396 +{
5397 + v->counter = i;
5398 +}
5399
5400 /*
5401 * atomic_add - add integer to atomic variable
5402 @@ -47,7 +79,67 @@
5403 *
5404 * Atomically adds @i to @v.
5405 */
5406 -static __inline__ void atomic_add(int i, atomic_t * v)
5407 +static __inline__ void atomic_add(int i, atomic_t *v)
5408 +{
5409 + int temp;
5410 +
5411 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5412 + __asm__ __volatile__(
5413 + " .set mips3 \n"
5414 + "1: ll %0, %1 # atomic_add \n"
5415 +#ifdef CONFIG_PAX_REFCOUNT
5416 + /* Exception on overflow. */
5417 + "2: add %0, %2 \n"
5418 +#else
5419 + " addu %0, %2 \n"
5420 +#endif
5421 + " sc %0, %1 \n"
5422 + " beqzl %0, 1b \n"
5423 +#ifdef CONFIG_PAX_REFCOUNT
5424 + "3: \n"
5425 + _ASM_EXTABLE(2b, 3b)
5426 +#endif
5427 + " .set mips0 \n"
5428 + : "=&r" (temp), "+m" (v->counter)
5429 + : "Ir" (i));
5430 + } else if (kernel_uses_llsc) {
5431 + __asm__ __volatile__(
5432 + " .set mips3 \n"
5433 + "1: ll %0, %1 # atomic_add \n"
5434 +#ifdef CONFIG_PAX_REFCOUNT
5435 + /* Exception on overflow. */
5436 + "2: add %0, %2 \n"
5437 +#else
5438 + " addu %0, %2 \n"
5439 +#endif
5440 + " sc %0, %1 \n"
5441 + " beqz %0, 1b \n"
5442 +#ifdef CONFIG_PAX_REFCOUNT
5443 + "3: \n"
5444 + _ASM_EXTABLE(2b, 3b)
5445 +#endif
5446 + " .set mips0 \n"
5447 + : "=&r" (temp), "+m" (v->counter)
5448 + : "Ir" (i));
5449 + } else {
5450 + unsigned long flags;
5451 +
5452 + raw_local_irq_save(flags);
5453 + __asm__ __volatile__(
5454 +#ifdef CONFIG_PAX_REFCOUNT
5455 + /* Exception on overflow. */
5456 + "1: add %0, %1 \n"
5457 + "2: \n"
5458 + _ASM_EXTABLE(1b, 2b)
5459 +#else
5460 + " addu %0, %1 \n"
5461 +#endif
5462 + : "+r" (v->counter) : "Ir" (i));
5463 + raw_local_irq_restore(flags);
5464 + }
5465 +}
5466 +
5467 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5468 {
5469 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5470 int temp;
5471 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5472 *
5473 * Atomically subtracts @i from @v.
5474 */
5475 -static __inline__ void atomic_sub(int i, atomic_t * v)
5476 +static __inline__ void atomic_sub(int i, atomic_t *v)
5477 +{
5478 + int temp;
5479 +
5480 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5481 + __asm__ __volatile__(
5482 + " .set mips3 \n"
5483 + "1: ll %0, %1 # atomic64_sub \n"
5484 +#ifdef CONFIG_PAX_REFCOUNT
5485 + /* Exception on overflow. */
5486 + "2: sub %0, %2 \n"
5487 +#else
5488 + " subu %0, %2 \n"
5489 +#endif
5490 + " sc %0, %1 \n"
5491 + " beqzl %0, 1b \n"
5492 +#ifdef CONFIG_PAX_REFCOUNT
5493 + "3: \n"
5494 + _ASM_EXTABLE(2b, 3b)
5495 +#endif
5496 + " .set mips0 \n"
5497 + : "=&r" (temp), "+m" (v->counter)
5498 + : "Ir" (i));
5499 + } else if (kernel_uses_llsc) {
5500 + __asm__ __volatile__(
5501 + " .set mips3 \n"
5502 + "1: ll %0, %1 # atomic64_sub \n"
5503 +#ifdef CONFIG_PAX_REFCOUNT
5504 + /* Exception on overflow. */
5505 + "2: sub %0, %2 \n"
5506 +#else
5507 + " subu %0, %2 \n"
5508 +#endif
5509 + " sc %0, %1 \n"
5510 + " beqz %0, 1b \n"
5511 +#ifdef CONFIG_PAX_REFCOUNT
5512 + "3: \n"
5513 + _ASM_EXTABLE(2b, 3b)
5514 +#endif
5515 + " .set mips0 \n"
5516 + : "=&r" (temp), "+m" (v->counter)
5517 + : "Ir" (i));
5518 + } else {
5519 + unsigned long flags;
5520 +
5521 + raw_local_irq_save(flags);
5522 + __asm__ __volatile__(
5523 +#ifdef CONFIG_PAX_REFCOUNT
5524 + /* Exception on overflow. */
5525 + "1: sub %0, %1 \n"
5526 + "2: \n"
5527 + _ASM_EXTABLE(1b, 2b)
5528 +#else
5529 + " subu %0, %1 \n"
5530 +#endif
5531 + : "+r" (v->counter) : "Ir" (i));
5532 + raw_local_irq_restore(flags);
5533 + }
5534 +}
5535 +
5536 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5537 {
5538 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5539 int temp;
5540 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5541 /*
5542 * Same as above, but return the result value
5543 */
5544 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5545 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5546 +{
5547 + int result;
5548 + int temp;
5549 +
5550 + smp_mb__before_llsc();
5551 +
5552 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5553 + __asm__ __volatile__(
5554 + " .set mips3 \n"
5555 + "1: ll %1, %2 # atomic_add_return \n"
5556 +#ifdef CONFIG_PAX_REFCOUNT
5557 + "2: add %0, %1, %3 \n"
5558 +#else
5559 + " addu %0, %1, %3 \n"
5560 +#endif
5561 + " sc %0, %2 \n"
5562 + " beqzl %0, 1b \n"
5563 +#ifdef CONFIG_PAX_REFCOUNT
5564 + " b 4f \n"
5565 + " .set noreorder \n"
5566 + "3: b 5f \n"
5567 + " move %0, %1 \n"
5568 + " .set reorder \n"
5569 + _ASM_EXTABLE(2b, 3b)
5570 +#endif
5571 + "4: addu %0, %1, %3 \n"
5572 +#ifdef CONFIG_PAX_REFCOUNT
5573 + "5: \n"
5574 +#endif
5575 + " .set mips0 \n"
5576 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5577 + : "Ir" (i));
5578 + } else if (kernel_uses_llsc) {
5579 + __asm__ __volatile__(
5580 + " .set mips3 \n"
5581 + "1: ll %1, %2 # atomic_add_return \n"
5582 +#ifdef CONFIG_PAX_REFCOUNT
5583 + "2: add %0, %1, %3 \n"
5584 +#else
5585 + " addu %0, %1, %3 \n"
5586 +#endif
5587 + " sc %0, %2 \n"
5588 + " bnez %0, 4f \n"
5589 + " b 1b \n"
5590 +#ifdef CONFIG_PAX_REFCOUNT
5591 + " .set noreorder \n"
5592 + "3: b 5f \n"
5593 + " move %0, %1 \n"
5594 + " .set reorder \n"
5595 + _ASM_EXTABLE(2b, 3b)
5596 +#endif
5597 + "4: addu %0, %1, %3 \n"
5598 +#ifdef CONFIG_PAX_REFCOUNT
5599 + "5: \n"
5600 +#endif
5601 + " .set mips0 \n"
5602 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5603 + : "Ir" (i));
5604 + } else {
5605 + unsigned long flags;
5606 +
5607 + raw_local_irq_save(flags);
5608 + __asm__ __volatile__(
5609 + " lw %0, %1 \n"
5610 +#ifdef CONFIG_PAX_REFCOUNT
5611 + /* Exception on overflow. */
5612 + "1: add %0, %2 \n"
5613 +#else
5614 + " addu %0, %2 \n"
5615 +#endif
5616 + " sw %0, %1 \n"
5617 +#ifdef CONFIG_PAX_REFCOUNT
5618 + /* Note: Dest reg is not modified on overflow */
5619 + "2: \n"
5620 + _ASM_EXTABLE(1b, 2b)
5621 +#endif
5622 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5623 + raw_local_irq_restore(flags);
5624 + }
5625 +
5626 + smp_llsc_mb();
5627 +
5628 + return result;
5629 +}
5630 +
5631 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5632 {
5633 int result;
5634
5635 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5636 return result;
5637 }
5638
5639 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5640 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5641 +{
5642 + int result;
5643 + int temp;
5644 +
5645 + smp_mb__before_llsc();
5646 +
5647 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5648 + __asm__ __volatile__(
5649 + " .set mips3 \n"
5650 + "1: ll %1, %2 # atomic_sub_return \n"
5651 +#ifdef CONFIG_PAX_REFCOUNT
5652 + "2: sub %0, %1, %3 \n"
5653 +#else
5654 + " subu %0, %1, %3 \n"
5655 +#endif
5656 + " sc %0, %2 \n"
5657 + " beqzl %0, 1b \n"
5658 +#ifdef CONFIG_PAX_REFCOUNT
5659 + " b 4f \n"
5660 + " .set noreorder \n"
5661 + "3: b 5f \n"
5662 + " move %0, %1 \n"
5663 + " .set reorder \n"
5664 + _ASM_EXTABLE(2b, 3b)
5665 +#endif
5666 + "4: subu %0, %1, %3 \n"
5667 +#ifdef CONFIG_PAX_REFCOUNT
5668 + "5: \n"
5669 +#endif
5670 + " .set mips0 \n"
5671 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5672 + : "Ir" (i), "m" (v->counter)
5673 + : "memory");
5674 + } else if (kernel_uses_llsc) {
5675 + __asm__ __volatile__(
5676 + " .set mips3 \n"
5677 + "1: ll %1, %2 # atomic_sub_return \n"
5678 +#ifdef CONFIG_PAX_REFCOUNT
5679 + "2: sub %0, %1, %3 \n"
5680 +#else
5681 + " subu %0, %1, %3 \n"
5682 +#endif
5683 + " sc %0, %2 \n"
5684 + " bnez %0, 4f \n"
5685 + " b 1b \n"
5686 +#ifdef CONFIG_PAX_REFCOUNT
5687 + " .set noreorder \n"
5688 + "3: b 5f \n"
5689 + " move %0, %1 \n"
5690 + " .set reorder \n"
5691 + _ASM_EXTABLE(2b, 3b)
5692 +#endif
5693 + "4: subu %0, %1, %3 \n"
5694 +#ifdef CONFIG_PAX_REFCOUNT
5695 + "5: \n"
5696 +#endif
5697 + " .set mips0 \n"
5698 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5699 + : "Ir" (i));
5700 + } else {
5701 + unsigned long flags;
5702 +
5703 + raw_local_irq_save(flags);
5704 + __asm__ __volatile__(
5705 + " lw %0, %1 \n"
5706 +#ifdef CONFIG_PAX_REFCOUNT
5707 + /* Exception on overflow. */
5708 + "1: sub %0, %2 \n"
5709 +#else
5710 + " subu %0, %2 \n"
5711 +#endif
5712 + " sw %0, %1 \n"
5713 +#ifdef CONFIG_PAX_REFCOUNT
5714 + /* Note: Dest reg is not modified on overflow */
5715 + "2: \n"
5716 + _ASM_EXTABLE(1b, 2b)
5717 +#endif
5718 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5719 + raw_local_irq_restore(flags);
5720 + }
5721 +
5722 + smp_llsc_mb();
5723 +
5724 + return result;
5725 +}
5726 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5727 {
5728 int result;
5729
5730 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5731 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5732 * The function returns the old value of @v minus @i.
5733 */
5734 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5735 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5736 {
5737 int result;
5738
5739 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5740 return result;
5741 }
5742
5743 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5744 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5745 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5746 +{
5747 + return cmpxchg(&v->counter, old, new);
5748 +}
5749 +
5750 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5751 + int new)
5752 +{
5753 + return cmpxchg(&(v->counter), old, new);
5754 +}
5755 +
5756 +static inline int atomic_xchg(atomic_t *v, int new)
5757 +{
5758 + return xchg(&v->counter, new);
5759 +}
5760 +
5761 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5762 +{
5763 + return xchg(&(v->counter), new);
5764 +}
5765
5766 /**
5767 * __atomic_add_unless - add unless the number is a given value
5768 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5769
5770 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5771 #define atomic_inc_return(v) atomic_add_return(1, (v))
5772 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5773 +{
5774 + return atomic_add_return_unchecked(1, v);
5775 +}
5776
5777 /*
5778 * atomic_sub_and_test - subtract value from variable and test result
5779 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5780 * other cases.
5781 */
5782 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5783 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5784 +{
5785 + return atomic_add_return_unchecked(1, v) == 0;
5786 +}
5787
5788 /*
5789 * atomic_dec_and_test - decrement by 1 and test
5790 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5791 * Atomically increments @v by 1.
5792 */
5793 #define atomic_inc(v) atomic_add(1, (v))
5794 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5795 +{
5796 + atomic_add_unchecked(1, v);
5797 +}
5798
5799 /*
5800 * atomic_dec - decrement and test
5801 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5802 * Atomically decrements @v by 1.
5803 */
5804 #define atomic_dec(v) atomic_sub(1, (v))
5805 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5806 +{
5807 + atomic_sub_unchecked(1, v);
5808 +}
5809
5810 /*
5811 * atomic_add_negative - add and test if negative
5812 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5813 * @v: pointer of type atomic64_t
5814 *
5815 */
5816 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5817 +static inline long atomic64_read(const atomic64_t *v)
5818 +{
5819 + return (*(volatile const long *) &v->counter);
5820 +}
5821 +
5822 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5823 +{
5824 + return (*(volatile const long *) &v->counter);
5825 +}
5826
5827 /*
5828 * atomic64_set - set atomic variable
5829 * @v: pointer of type atomic64_t
5830 * @i: required value
5831 */
5832 -#define atomic64_set(v, i) ((v)->counter = (i))
5833 +static inline void atomic64_set(atomic64_t *v, long i)
5834 +{
5835 + v->counter = i;
5836 +}
5837 +
5838 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5839 +{
5840 + v->counter = i;
5841 +}
5842
5843 /*
5844 * atomic64_add - add integer to atomic variable
5845 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5846 *
5847 * Atomically adds @i to @v.
5848 */
5849 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5850 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5851 +{
5852 + long temp;
5853 +
5854 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5855 + __asm__ __volatile__(
5856 + " .set mips3 \n"
5857 + "1: lld %0, %1 # atomic64_add \n"
5858 +#ifdef CONFIG_PAX_REFCOUNT
5859 + /* Exception on overflow. */
5860 + "2: dadd %0, %2 \n"
5861 +#else
5862 + " daddu %0, %2 \n"
5863 +#endif
5864 + " scd %0, %1 \n"
5865 + " beqzl %0, 1b \n"
5866 +#ifdef CONFIG_PAX_REFCOUNT
5867 + "3: \n"
5868 + _ASM_EXTABLE(2b, 3b)
5869 +#endif
5870 + " .set mips0 \n"
5871 + : "=&r" (temp), "+m" (v->counter)
5872 + : "Ir" (i));
5873 + } else if (kernel_uses_llsc) {
5874 + __asm__ __volatile__(
5875 + " .set mips3 \n"
5876 + "1: lld %0, %1 # atomic64_add \n"
5877 +#ifdef CONFIG_PAX_REFCOUNT
5878 + /* Exception on overflow. */
5879 + "2: dadd %0, %2 \n"
5880 +#else
5881 + " daddu %0, %2 \n"
5882 +#endif
5883 + " scd %0, %1 \n"
5884 + " beqz %0, 1b \n"
5885 +#ifdef CONFIG_PAX_REFCOUNT
5886 + "3: \n"
5887 + _ASM_EXTABLE(2b, 3b)
5888 +#endif
5889 + " .set mips0 \n"
5890 + : "=&r" (temp), "+m" (v->counter)
5891 + : "Ir" (i));
5892 + } else {
5893 + unsigned long flags;
5894 +
5895 + raw_local_irq_save(flags);
5896 + __asm__ __volatile__(
5897 +#ifdef CONFIG_PAX_REFCOUNT
5898 + /* Exception on overflow. */
5899 + "1: dadd %0, %1 \n"
5900 + "2: \n"
5901 + _ASM_EXTABLE(1b, 2b)
5902 +#else
5903 + " daddu %0, %1 \n"
5904 +#endif
5905 + : "+r" (v->counter) : "Ir" (i));
5906 + raw_local_irq_restore(flags);
5907 + }
5908 +}
5909 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5910 {
5911 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5912 long temp;
5913 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5914 *
5915 * Atomically subtracts @i from @v.
5916 */
5917 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5918 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5919 +{
5920 + long temp;
5921 +
5922 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5923 + __asm__ __volatile__(
5924 + " .set mips3 \n"
5925 + "1: lld %0, %1 # atomic64_sub \n"
5926 +#ifdef CONFIG_PAX_REFCOUNT
5927 + /* Exception on overflow. */
5928 + "2: dsub %0, %2 \n"
5929 +#else
5930 + " dsubu %0, %2 \n"
5931 +#endif
5932 + " scd %0, %1 \n"
5933 + " beqzl %0, 1b \n"
5934 +#ifdef CONFIG_PAX_REFCOUNT
5935 + "3: \n"
5936 + _ASM_EXTABLE(2b, 3b)
5937 +#endif
5938 + " .set mips0 \n"
5939 + : "=&r" (temp), "+m" (v->counter)
5940 + : "Ir" (i));
5941 + } else if (kernel_uses_llsc) {
5942 + __asm__ __volatile__(
5943 + " .set mips3 \n"
5944 + "1: lld %0, %1 # atomic64_sub \n"
5945 +#ifdef CONFIG_PAX_REFCOUNT
5946 + /* Exception on overflow. */
5947 + "2: dsub %0, %2 \n"
5948 +#else
5949 + " dsubu %0, %2 \n"
5950 +#endif
5951 + " scd %0, %1 \n"
5952 + " beqz %0, 1b \n"
5953 +#ifdef CONFIG_PAX_REFCOUNT
5954 + "3: \n"
5955 + _ASM_EXTABLE(2b, 3b)
5956 +#endif
5957 + " .set mips0 \n"
5958 + : "=&r" (temp), "+m" (v->counter)
5959 + : "Ir" (i));
5960 + } else {
5961 + unsigned long flags;
5962 +
5963 + raw_local_irq_save(flags);
5964 + __asm__ __volatile__(
5965 +#ifdef CONFIG_PAX_REFCOUNT
5966 + /* Exception on overflow. */
5967 + "1: dsub %0, %1 \n"
5968 + "2: \n"
5969 + _ASM_EXTABLE(1b, 2b)
5970 +#else
5971 + " dsubu %0, %1 \n"
5972 +#endif
5973 + : "+r" (v->counter) : "Ir" (i));
5974 + raw_local_irq_restore(flags);
5975 + }
5976 +}
5977 +
5978 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
5979 {
5980 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5981 long temp;
5982 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
5983 /*
5984 * Same as above, but return the result value
5985 */
5986 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
5987 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
5988 +{
5989 + long result;
5990 + long temp;
5991 +
5992 + smp_mb__before_llsc();
5993 +
5994 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5995 + __asm__ __volatile__(
5996 + " .set mips3 \n"
5997 + "1: lld %1, %2 # atomic64_add_return \n"
5998 +#ifdef CONFIG_PAX_REFCOUNT
5999 + "2: dadd %0, %1, %3 \n"
6000 +#else
6001 + " daddu %0, %1, %3 \n"
6002 +#endif
6003 + " scd %0, %2 \n"
6004 + " beqzl %0, 1b \n"
6005 +#ifdef CONFIG_PAX_REFCOUNT
6006 + " b 4f \n"
6007 + " .set noreorder \n"
6008 + "3: b 5f \n"
6009 + " move %0, %1 \n"
6010 + " .set reorder \n"
6011 + _ASM_EXTABLE(2b, 3b)
6012 +#endif
6013 + "4: daddu %0, %1, %3 \n"
6014 +#ifdef CONFIG_PAX_REFCOUNT
6015 + "5: \n"
6016 +#endif
6017 + " .set mips0 \n"
6018 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6019 + : "Ir" (i));
6020 + } else if (kernel_uses_llsc) {
6021 + __asm__ __volatile__(
6022 + " .set mips3 \n"
6023 + "1: lld %1, %2 # atomic64_add_return \n"
6024 +#ifdef CONFIG_PAX_REFCOUNT
6025 + "2: dadd %0, %1, %3 \n"
6026 +#else
6027 + " daddu %0, %1, %3 \n"
6028 +#endif
6029 + " scd %0, %2 \n"
6030 + " bnez %0, 4f \n"
6031 + " b 1b \n"
6032 +#ifdef CONFIG_PAX_REFCOUNT
6033 + " .set noreorder \n"
6034 + "3: b 5f \n"
6035 + " move %0, %1 \n"
6036 + " .set reorder \n"
6037 + _ASM_EXTABLE(2b, 3b)
6038 +#endif
6039 + "4: daddu %0, %1, %3 \n"
6040 +#ifdef CONFIG_PAX_REFCOUNT
6041 + "5: \n"
6042 +#endif
6043 + " .set mips0 \n"
6044 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6045 + : "Ir" (i), "m" (v->counter)
6046 + : "memory");
6047 + } else {
6048 + unsigned long flags;
6049 +
6050 + raw_local_irq_save(flags);
6051 + __asm__ __volatile__(
6052 + " ld %0, %1 \n"
6053 +#ifdef CONFIG_PAX_REFCOUNT
6054 + /* Exception on overflow. */
6055 + "1: dadd %0, %2 \n"
6056 +#else
6057 + " daddu %0, %2 \n"
6058 +#endif
6059 + " sd %0, %1 \n"
6060 +#ifdef CONFIG_PAX_REFCOUNT
6061 + /* Note: Dest reg is not modified on overflow */
6062 + "2: \n"
6063 + _ASM_EXTABLE(1b, 2b)
6064 +#endif
6065 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6066 + raw_local_irq_restore(flags);
6067 + }
6068 +
6069 + smp_llsc_mb();
6070 +
6071 + return result;
6072 +}
6073 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6074 {
6075 long result;
6076
6077 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6078 return result;
6079 }
6080
6081 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6082 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6083 +{
6084 + long result;
6085 + long temp;
6086 +
6087 + smp_mb__before_llsc();
6088 +
6089 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6090 + long temp;
6091 +
6092 + __asm__ __volatile__(
6093 + " .set mips3 \n"
6094 + "1: lld %1, %2 # atomic64_sub_return \n"
6095 +#ifdef CONFIG_PAX_REFCOUNT
6096 + "2: dsub %0, %1, %3 \n"
6097 +#else
6098 + " dsubu %0, %1, %3 \n"
6099 +#endif
6100 + " scd %0, %2 \n"
6101 + " beqzl %0, 1b \n"
6102 +#ifdef CONFIG_PAX_REFCOUNT
6103 + " b 4f \n"
6104 + " .set noreorder \n"
6105 + "3: b 5f \n"
6106 + " move %0, %1 \n"
6107 + " .set reorder \n"
6108 + _ASM_EXTABLE(2b, 3b)
6109 +#endif
6110 + "4: dsubu %0, %1, %3 \n"
6111 +#ifdef CONFIG_PAX_REFCOUNT
6112 + "5: \n"
6113 +#endif
6114 + " .set mips0 \n"
6115 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6116 + : "Ir" (i), "m" (v->counter)
6117 + : "memory");
6118 + } else if (kernel_uses_llsc) {
6119 + __asm__ __volatile__(
6120 + " .set mips3 \n"
6121 + "1: lld %1, %2 # atomic64_sub_return \n"
6122 +#ifdef CONFIG_PAX_REFCOUNT
6123 + "2: dsub %0, %1, %3 \n"
6124 +#else
6125 + " dsubu %0, %1, %3 \n"
6126 +#endif
6127 + " scd %0, %2 \n"
6128 + " bnez %0, 4f \n"
6129 + " b 1b \n"
6130 +#ifdef CONFIG_PAX_REFCOUNT
6131 + " .set noreorder \n"
6132 + "3: b 5f \n"
6133 + " move %0, %1 \n"
6134 + " .set reorder \n"
6135 + _ASM_EXTABLE(2b, 3b)
6136 +#endif
6137 + "4: dsubu %0, %1, %3 \n"
6138 +#ifdef CONFIG_PAX_REFCOUNT
6139 + "5: \n"
6140 +#endif
6141 + " .set mips0 \n"
6142 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6143 + : "Ir" (i), "m" (v->counter)
6144 + : "memory");
6145 + } else {
6146 + unsigned long flags;
6147 +
6148 + raw_local_irq_save(flags);
6149 + __asm__ __volatile__(
6150 + " ld %0, %1 \n"
6151 +#ifdef CONFIG_PAX_REFCOUNT
6152 + /* Exception on overflow. */
6153 + "1: dsub %0, %2 \n"
6154 +#else
6155 + " dsubu %0, %2 \n"
6156 +#endif
6157 + " sd %0, %1 \n"
6158 +#ifdef CONFIG_PAX_REFCOUNT
6159 + /* Note: Dest reg is not modified on overflow */
6160 + "2: \n"
6161 + _ASM_EXTABLE(1b, 2b)
6162 +#endif
6163 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6164 + raw_local_irq_restore(flags);
6165 + }
6166 +
6167 + smp_llsc_mb();
6168 +
6169 + return result;
6170 +}
6171 +
6172 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6173 {
6174 long result;
6175
6176 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6177 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6178 * The function returns the old value of @v minus @i.
6179 */
6180 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6181 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6182 {
6183 long result;
6184
6185 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6186 return result;
6187 }
6188
6189 -#define atomic64_cmpxchg(v, o, n) \
6190 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6191 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6192 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6193 +{
6194 + return cmpxchg(&v->counter, old, new);
6195 +}
6196 +
6197 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6198 + long new)
6199 +{
6200 + return cmpxchg(&(v->counter), old, new);
6201 +}
6202 +
6203 +static inline long atomic64_xchg(atomic64_t *v, long new)
6204 +{
6205 + return xchg(&v->counter, new);
6206 +}
6207 +
6208 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6209 +{
6210 + return xchg(&(v->counter), new);
6211 +}
6212
6213 /**
6214 * atomic64_add_unless - add unless the number is a given value
6215 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6216
6217 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6218 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6219 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6220
6221 /*
6222 * atomic64_sub_and_test - subtract value from variable and test result
6223 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6224 * other cases.
6225 */
6226 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6227 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6228
6229 /*
6230 * atomic64_dec_and_test - decrement by 1 and test
6231 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6232 * Atomically increments @v by 1.
6233 */
6234 #define atomic64_inc(v) atomic64_add(1, (v))
6235 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6236
6237 /*
6238 * atomic64_dec - decrement and test
6239 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6240 * Atomically decrements @v by 1.
6241 */
6242 #define atomic64_dec(v) atomic64_sub(1, (v))
6243 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6244
6245 /*
6246 * atomic64_add_negative - add and test if negative
6247 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6248 index b4db69f..8f3b093 100644
6249 --- a/arch/mips/include/asm/cache.h
6250 +++ b/arch/mips/include/asm/cache.h
6251 @@ -9,10 +9,11 @@
6252 #ifndef _ASM_CACHE_H
6253 #define _ASM_CACHE_H
6254
6255 +#include <linux/const.h>
6256 #include <kmalloc.h>
6257
6258 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6259 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6260 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6261
6262 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6263 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6264 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6265 index cf3ae24..238d22f 100644
6266 --- a/arch/mips/include/asm/elf.h
6267 +++ b/arch/mips/include/asm/elf.h
6268 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6269 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6270 #endif
6271
6272 +#ifdef CONFIG_PAX_ASLR
6273 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6274 +
6275 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6276 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6277 +#endif
6278 +
6279 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6280 struct linux_binprm;
6281 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6282 int uses_interp);
6283
6284 -struct mm_struct;
6285 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6286 -#define arch_randomize_brk arch_randomize_brk
6287 -
6288 #endif /* _ASM_ELF_H */
6289 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6290 index c1f6afa..38cc6e9 100644
6291 --- a/arch/mips/include/asm/exec.h
6292 +++ b/arch/mips/include/asm/exec.h
6293 @@ -12,6 +12,6 @@
6294 #ifndef _ASM_EXEC_H
6295 #define _ASM_EXEC_H
6296
6297 -extern unsigned long arch_align_stack(unsigned long sp);
6298 +#define arch_align_stack(x) ((x) & ~0xfUL)
6299
6300 #endif /* _ASM_EXEC_H */
6301 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6302 index d44622c..64990d2 100644
6303 --- a/arch/mips/include/asm/local.h
6304 +++ b/arch/mips/include/asm/local.h
6305 @@ -12,15 +12,25 @@ typedef struct
6306 atomic_long_t a;
6307 } local_t;
6308
6309 +typedef struct {
6310 + atomic_long_unchecked_t a;
6311 +} local_unchecked_t;
6312 +
6313 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6314
6315 #define local_read(l) atomic_long_read(&(l)->a)
6316 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6317 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6318 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6319
6320 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6321 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6322 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6323 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6324 #define local_inc(l) atomic_long_inc(&(l)->a)
6325 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6326 #define local_dec(l) atomic_long_dec(&(l)->a)
6327 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6328
6329 /*
6330 * Same as above, but return the result value
6331 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6332 return result;
6333 }
6334
6335 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6336 +{
6337 + unsigned long result;
6338 +
6339 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6340 + unsigned long temp;
6341 +
6342 + __asm__ __volatile__(
6343 + " .set mips3 \n"
6344 + "1:" __LL "%1, %2 # local_add_return \n"
6345 + " addu %0, %1, %3 \n"
6346 + __SC "%0, %2 \n"
6347 + " beqzl %0, 1b \n"
6348 + " addu %0, %1, %3 \n"
6349 + " .set mips0 \n"
6350 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6351 + : "Ir" (i), "m" (l->a.counter)
6352 + : "memory");
6353 + } else if (kernel_uses_llsc) {
6354 + unsigned long temp;
6355 +
6356 + __asm__ __volatile__(
6357 + " .set mips3 \n"
6358 + "1:" __LL "%1, %2 # local_add_return \n"
6359 + " addu %0, %1, %3 \n"
6360 + __SC "%0, %2 \n"
6361 + " beqz %0, 1b \n"
6362 + " addu %0, %1, %3 \n"
6363 + " .set mips0 \n"
6364 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6365 + : "Ir" (i), "m" (l->a.counter)
6366 + : "memory");
6367 + } else {
6368 + unsigned long flags;
6369 +
6370 + local_irq_save(flags);
6371 + result = l->a.counter;
6372 + result += i;
6373 + l->a.counter = result;
6374 + local_irq_restore(flags);
6375 + }
6376 +
6377 + return result;
6378 +}
6379 +
6380 static __inline__ long local_sub_return(long i, local_t * l)
6381 {
6382 unsigned long result;
6383 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6384
6385 #define local_cmpxchg(l, o, n) \
6386 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6387 +#define local_cmpxchg_unchecked(l, o, n) \
6388 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6389 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6390
6391 /**
6392 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6393 index f6be474..12ad554 100644
6394 --- a/arch/mips/include/asm/page.h
6395 +++ b/arch/mips/include/asm/page.h
6396 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6397 #ifdef CONFIG_CPU_MIPS32
6398 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6399 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6400 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6401 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6402 #else
6403 typedef struct { unsigned long long pte; } pte_t;
6404 #define pte_val(x) ((x).pte)
6405 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6406 index 881d18b..cea38bc 100644
6407 --- a/arch/mips/include/asm/pgalloc.h
6408 +++ b/arch/mips/include/asm/pgalloc.h
6409 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6410 {
6411 set_pud(pud, __pud((unsigned long)pmd));
6412 }
6413 +
6414 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6415 +{
6416 + pud_populate(mm, pud, pmd);
6417 +}
6418 #endif
6419
6420 /*
6421 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6422 index 25da651..ae2a259 100644
6423 --- a/arch/mips/include/asm/smtc_proc.h
6424 +++ b/arch/mips/include/asm/smtc_proc.h
6425 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6426
6427 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6428
6429 -extern atomic_t smtc_fpu_recoveries;
6430 +extern atomic_unchecked_t smtc_fpu_recoveries;
6431
6432 #endif /* __ASM_SMTC_PROC_H */
6433 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6434 index 61215a3..213ee0e 100644
6435 --- a/arch/mips/include/asm/thread_info.h
6436 +++ b/arch/mips/include/asm/thread_info.h
6437 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6438 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6439 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6440 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6441 +/* li takes a 32bit immediate */
6442 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6443 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6444
6445 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6446 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6447 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6448 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6449 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6450 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6451
6452 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6453 - _TIF_SYSCALL_AUDIT)
6454 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6455
6456 /* work to do in syscall_trace_leave() */
6457 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6458 - _TIF_SYSCALL_AUDIT)
6459 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6460
6461 /* work to do on interrupt/exception return */
6462 #define _TIF_WORK_MASK \
6463 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6464 /* work to do on any return to u-space */
6465 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6466 - _TIF_WORK_SYSCALL_EXIT)
6467 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6468
6469 #endif /* __KERNEL__ */
6470
6471 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6472 index 1188e00..41cf144 100644
6473 --- a/arch/mips/kernel/binfmt_elfn32.c
6474 +++ b/arch/mips/kernel/binfmt_elfn32.c
6475 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6476 #undef ELF_ET_DYN_BASE
6477 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6478
6479 +#ifdef CONFIG_PAX_ASLR
6480 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6481 +
6482 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6483 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6484 +#endif
6485 +
6486 #include <asm/processor.h>
6487 #include <linux/module.h>
6488 #include <linux/elfcore.h>
6489 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6490 index 202e581..689ca79 100644
6491 --- a/arch/mips/kernel/binfmt_elfo32.c
6492 +++ b/arch/mips/kernel/binfmt_elfo32.c
6493 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6494 #undef ELF_ET_DYN_BASE
6495 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6496
6497 +#ifdef CONFIG_PAX_ASLR
6498 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6499 +
6500 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6501 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6502 +#endif
6503 +
6504 #include <asm/processor.h>
6505
6506 /*
6507 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6508 index d1fea7a..45602ea 100644
6509 --- a/arch/mips/kernel/irq.c
6510 +++ b/arch/mips/kernel/irq.c
6511 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6512 printk("unexpected IRQ # %d\n", irq);
6513 }
6514
6515 -atomic_t irq_err_count;
6516 +atomic_unchecked_t irq_err_count;
6517
6518 int arch_show_interrupts(struct seq_file *p, int prec)
6519 {
6520 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6521 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6522 return 0;
6523 }
6524
6525 asmlinkage void spurious_interrupt(void)
6526 {
6527 - atomic_inc(&irq_err_count);
6528 + atomic_inc_unchecked(&irq_err_count);
6529 }
6530
6531 void __init init_IRQ(void)
6532 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6533 index ddc7610..8c58f17 100644
6534 --- a/arch/mips/kernel/process.c
6535 +++ b/arch/mips/kernel/process.c
6536 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6537 out:
6538 return pc;
6539 }
6540 -
6541 -/*
6542 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6543 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6544 - */
6545 -unsigned long arch_align_stack(unsigned long sp)
6546 -{
6547 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6548 - sp -= get_random_int() & ~PAGE_MASK;
6549 -
6550 - return sp & ALMASK;
6551 -}
6552 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6553 index 8ae1ebe..1bcbf47 100644
6554 --- a/arch/mips/kernel/ptrace.c
6555 +++ b/arch/mips/kernel/ptrace.c
6556 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6557 return arch;
6558 }
6559
6560 +#ifdef CONFIG_GRKERNSEC_SETXID
6561 +extern void gr_delayed_cred_worker(void);
6562 +#endif
6563 +
6564 /*
6565 * Notification of system call entry/exit
6566 * - triggered by current->work.syscall_trace
6567 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6568 /* do the secure computing check first */
6569 secure_computing_strict(regs->regs[2]);
6570
6571 +#ifdef CONFIG_GRKERNSEC_SETXID
6572 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6573 + gr_delayed_cred_worker();
6574 +#endif
6575 +
6576 if (!(current->ptrace & PT_PTRACED))
6577 goto out;
6578
6579 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6580 index c10aa84..9ec2e60 100644
6581 --- a/arch/mips/kernel/smtc-proc.c
6582 +++ b/arch/mips/kernel/smtc-proc.c
6583 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6584
6585 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6586
6587 -atomic_t smtc_fpu_recoveries;
6588 +atomic_unchecked_t smtc_fpu_recoveries;
6589
6590 static int smtc_proc_show(struct seq_file *m, void *v)
6591 {
6592 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6593 for(i = 0; i < NR_CPUS; i++)
6594 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6595 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6596 - atomic_read(&smtc_fpu_recoveries));
6597 + atomic_read_unchecked(&smtc_fpu_recoveries));
6598 return 0;
6599 }
6600
6601 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6602 smtc_cpu_stats[i].selfipis = 0;
6603 }
6604
6605 - atomic_set(&smtc_fpu_recoveries, 0);
6606 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6607
6608 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6609 }
6610 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6611 index dfc1b91..11a2c07 100644
6612 --- a/arch/mips/kernel/smtc.c
6613 +++ b/arch/mips/kernel/smtc.c
6614 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6615 }
6616 smtc_ipi_qdump();
6617 printk("%d Recoveries of \"stolen\" FPU\n",
6618 - atomic_read(&smtc_fpu_recoveries));
6619 + atomic_read_unchecked(&smtc_fpu_recoveries));
6620 }
6621
6622
6623 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6624 index 84536bf..79caa4d 100644
6625 --- a/arch/mips/kernel/sync-r4k.c
6626 +++ b/arch/mips/kernel/sync-r4k.c
6627 @@ -21,8 +21,8 @@
6628 #include <asm/mipsregs.h>
6629
6630 static atomic_t count_start_flag = ATOMIC_INIT(0);
6631 -static atomic_t count_count_start = ATOMIC_INIT(0);
6632 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6633 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6634 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6635 static atomic_t count_reference = ATOMIC_INIT(0);
6636
6637 #define COUNTON 100
6638 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6639
6640 for (i = 0; i < NR_LOOPS; i++) {
6641 /* slaves loop on '!= 2' */
6642 - while (atomic_read(&count_count_start) != 1)
6643 + while (atomic_read_unchecked(&count_count_start) != 1)
6644 mb();
6645 - atomic_set(&count_count_stop, 0);
6646 + atomic_set_unchecked(&count_count_stop, 0);
6647 smp_wmb();
6648
6649 /* this lets the slaves write their count register */
6650 - atomic_inc(&count_count_start);
6651 + atomic_inc_unchecked(&count_count_start);
6652
6653 /*
6654 * Everyone initialises count in the last loop:
6655 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6656 /*
6657 * Wait for all slaves to leave the synchronization point:
6658 */
6659 - while (atomic_read(&count_count_stop) != 1)
6660 + while (atomic_read_unchecked(&count_count_stop) != 1)
6661 mb();
6662 - atomic_set(&count_count_start, 0);
6663 + atomic_set_unchecked(&count_count_start, 0);
6664 smp_wmb();
6665 - atomic_inc(&count_count_stop);
6666 + atomic_inc_unchecked(&count_count_stop);
6667 }
6668 /* Arrange for an interrupt in a short while */
6669 write_c0_compare(read_c0_count() + COUNTON);
6670 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6671 initcount = atomic_read(&count_reference);
6672
6673 for (i = 0; i < NR_LOOPS; i++) {
6674 - atomic_inc(&count_count_start);
6675 - while (atomic_read(&count_count_start) != 2)
6676 + atomic_inc_unchecked(&count_count_start);
6677 + while (atomic_read_unchecked(&count_count_start) != 2)
6678 mb();
6679
6680 /*
6681 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6682 if (i == NR_LOOPS-1)
6683 write_c0_count(initcount);
6684
6685 - atomic_inc(&count_count_stop);
6686 - while (atomic_read(&count_count_stop) != 2)
6687 + atomic_inc_unchecked(&count_count_stop);
6688 + while (atomic_read_unchecked(&count_count_stop) != 2)
6689 mb();
6690 }
6691 /* Arrange for an interrupt in a short while */
6692 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6693 index aec3408..74d79d3 100644
6694 --- a/arch/mips/kernel/traps.c
6695 +++ b/arch/mips/kernel/traps.c
6696 @@ -683,7 +683,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6697 siginfo_t info;
6698
6699 prev_state = exception_enter();
6700 - die_if_kernel("Integer overflow", regs);
6701 + if (unlikely(!user_mode(regs))) {
6702 +
6703 +#ifdef CONFIG_PAX_REFCOUNT
6704 + if (fixup_exception(regs)) {
6705 + pax_report_refcount_overflow(regs);
6706 + exception_exit(prev_state);
6707 + return;
6708 + }
6709 +#endif
6710 +
6711 + die("Integer overflow", regs);
6712 + }
6713
6714 info.si_code = FPE_INTOVF;
6715 info.si_signo = SIGFPE;
6716 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6717 index 85df1cd..4f0a4de 100644
6718 --- a/arch/mips/mm/fault.c
6719 +++ b/arch/mips/mm/fault.c
6720 @@ -28,6 +28,23 @@
6721 #include <asm/highmem.h> /* For VMALLOC_END */
6722 #include <linux/kdebug.h>
6723
6724 +#ifdef CONFIG_PAX_PAGEEXEC
6725 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6726 +{
6727 + unsigned long i;
6728 +
6729 + printk(KERN_ERR "PAX: bytes at PC: ");
6730 + for (i = 0; i < 5; i++) {
6731 + unsigned int c;
6732 + if (get_user(c, (unsigned int *)pc+i))
6733 + printk(KERN_CONT "???????? ");
6734 + else
6735 + printk(KERN_CONT "%08x ", c);
6736 + }
6737 + printk("\n");
6738 +}
6739 +#endif
6740 +
6741 /*
6742 * This routine handles page faults. It determines the address,
6743 * and the problem, and then passes it off to one of the appropriate
6744 @@ -197,6 +214,14 @@ bad_area:
6745 bad_area_nosemaphore:
6746 /* User mode accesses just cause a SIGSEGV */
6747 if (user_mode(regs)) {
6748 +
6749 +#ifdef CONFIG_PAX_PAGEEXEC
6750 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6751 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6752 + do_group_exit(SIGKILL);
6753 + }
6754 +#endif
6755 +
6756 tsk->thread.cp0_badvaddr = address;
6757 tsk->thread.error_code = write;
6758 #if 0
6759 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6760 index f1baadd..8537544 100644
6761 --- a/arch/mips/mm/mmap.c
6762 +++ b/arch/mips/mm/mmap.c
6763 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6764 struct vm_area_struct *vma;
6765 unsigned long addr = addr0;
6766 int do_color_align;
6767 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6768 struct vm_unmapped_area_info info;
6769
6770 if (unlikely(len > TASK_SIZE))
6771 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6772 do_color_align = 1;
6773
6774 /* requesting a specific address */
6775 +
6776 +#ifdef CONFIG_PAX_RANDMMAP
6777 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6778 +#endif
6779 +
6780 if (addr) {
6781 if (do_color_align)
6782 addr = COLOUR_ALIGN(addr, pgoff);
6783 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6784 addr = PAGE_ALIGN(addr);
6785
6786 vma = find_vma(mm, addr);
6787 - if (TASK_SIZE - len >= addr &&
6788 - (!vma || addr + len <= vma->vm_start))
6789 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6790 return addr;
6791 }
6792
6793 info.length = len;
6794 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6795 info.align_offset = pgoff << PAGE_SHIFT;
6796 + info.threadstack_offset = offset;
6797
6798 if (dir == DOWN) {
6799 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6800 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6801 {
6802 unsigned long random_factor = 0UL;
6803
6804 +#ifdef CONFIG_PAX_RANDMMAP
6805 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6806 +#endif
6807 +
6808 if (current->flags & PF_RANDOMIZE) {
6809 random_factor = get_random_int();
6810 random_factor = random_factor << PAGE_SHIFT;
6811 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6812
6813 if (mmap_is_legacy()) {
6814 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6815 +
6816 +#ifdef CONFIG_PAX_RANDMMAP
6817 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6818 + mm->mmap_base += mm->delta_mmap;
6819 +#endif
6820 +
6821 mm->get_unmapped_area = arch_get_unmapped_area;
6822 } else {
6823 mm->mmap_base = mmap_base(random_factor);
6824 +
6825 +#ifdef CONFIG_PAX_RANDMMAP
6826 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6827 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6828 +#endif
6829 +
6830 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6831 }
6832 }
6833
6834 -static inline unsigned long brk_rnd(void)
6835 -{
6836 - unsigned long rnd = get_random_int();
6837 -
6838 - rnd = rnd << PAGE_SHIFT;
6839 - /* 8MB for 32bit, 256MB for 64bit */
6840 - if (TASK_IS_32BIT_ADDR)
6841 - rnd = rnd & 0x7ffffful;
6842 - else
6843 - rnd = rnd & 0xffffffful;
6844 -
6845 - return rnd;
6846 -}
6847 -
6848 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6849 -{
6850 - unsigned long base = mm->brk;
6851 - unsigned long ret;
6852 -
6853 - ret = PAGE_ALIGN(base + brk_rnd());
6854 -
6855 - if (ret < mm->brk)
6856 - return mm->brk;
6857 -
6858 - return ret;
6859 -}
6860 -
6861 int __virt_addr_valid(const volatile void *kaddr)
6862 {
6863 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6864 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6865 index a2358b4..7cead4f 100644
6866 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6867 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6868 @@ -187,9 +187,9 @@ void
6869 cont_nmi_dump(void)
6870 {
6871 #ifndef REAL_NMI_SIGNAL
6872 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6873 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6874
6875 - atomic_inc(&nmied_cpus);
6876 + atomic_inc_unchecked(&nmied_cpus);
6877 #endif
6878 /*
6879 * Only allow 1 cpu to proceed
6880 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6881 udelay(10000);
6882 }
6883 #else
6884 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6885 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6886 #endif
6887
6888 /*
6889 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6890 index 967d144..db12197 100644
6891 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6892 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6893 @@ -11,12 +11,14 @@
6894 #ifndef _ASM_PROC_CACHE_H
6895 #define _ASM_PROC_CACHE_H
6896
6897 +#include <linux/const.h>
6898 +
6899 /* L1 cache */
6900
6901 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6902 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6903 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6904 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6905 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6906 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6907
6908 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6909 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6910 index bcb5df2..84fabd2 100644
6911 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6912 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6913 @@ -16,13 +16,15 @@
6914 #ifndef _ASM_PROC_CACHE_H
6915 #define _ASM_PROC_CACHE_H
6916
6917 +#include <linux/const.h>
6918 +
6919 /*
6920 * L1 cache
6921 */
6922 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6923 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6924 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6925 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6926 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6927 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6928
6929 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6930 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6931 index 4ce7a01..449202a 100644
6932 --- a/arch/openrisc/include/asm/cache.h
6933 +++ b/arch/openrisc/include/asm/cache.h
6934 @@ -19,11 +19,13 @@
6935 #ifndef __ASM_OPENRISC_CACHE_H
6936 #define __ASM_OPENRISC_CACHE_H
6937
6938 +#include <linux/const.h>
6939 +
6940 /* FIXME: How can we replace these with values from the CPU...
6941 * they shouldn't be hard-coded!
6942 */
6943
6944 -#define L1_CACHE_BYTES 16
6945 #define L1_CACHE_SHIFT 4
6946 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6947
6948 #endif /* __ASM_OPENRISC_CACHE_H */
6949 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6950 index 472886c..00e7df9 100644
6951 --- a/arch/parisc/include/asm/atomic.h
6952 +++ b/arch/parisc/include/asm/atomic.h
6953 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6954 return dec;
6955 }
6956
6957 +#define atomic64_read_unchecked(v) atomic64_read(v)
6958 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6959 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6960 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6961 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6962 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6963 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6964 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6965 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6966 +
6967 #endif /* !CONFIG_64BIT */
6968
6969
6970 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6971 index 47f11c7..3420df2 100644
6972 --- a/arch/parisc/include/asm/cache.h
6973 +++ b/arch/parisc/include/asm/cache.h
6974 @@ -5,6 +5,7 @@
6975 #ifndef __ARCH_PARISC_CACHE_H
6976 #define __ARCH_PARISC_CACHE_H
6977
6978 +#include <linux/const.h>
6979
6980 /*
6981 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
6982 @@ -15,13 +16,13 @@
6983 * just ruin performance.
6984 */
6985 #ifdef CONFIG_PA20
6986 -#define L1_CACHE_BYTES 64
6987 #define L1_CACHE_SHIFT 6
6988 #else
6989 -#define L1_CACHE_BYTES 32
6990 #define L1_CACHE_SHIFT 5
6991 #endif
6992
6993 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6994 +
6995 #ifndef __ASSEMBLY__
6996
6997 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6998 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
6999 index ad2b503..bdf1651 100644
7000 --- a/arch/parisc/include/asm/elf.h
7001 +++ b/arch/parisc/include/asm/elf.h
7002 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7003
7004 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7005
7006 +#ifdef CONFIG_PAX_ASLR
7007 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7008 +
7009 +#define PAX_DELTA_MMAP_LEN 16
7010 +#define PAX_DELTA_STACK_LEN 16
7011 +#endif
7012 +
7013 /* This yields a mask that user programs can use to figure out what
7014 instruction set this CPU supports. This could be done in user space,
7015 but it's not easy, and we've already done it here. */
7016 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7017 index fc987a1..6e068ef 100644
7018 --- a/arch/parisc/include/asm/pgalloc.h
7019 +++ b/arch/parisc/include/asm/pgalloc.h
7020 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7021 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7022 }
7023
7024 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7025 +{
7026 + pgd_populate(mm, pgd, pmd);
7027 +}
7028 +
7029 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7030 {
7031 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7032 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7033 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7034 #define pmd_free(mm, x) do { } while (0)
7035 #define pgd_populate(mm, pmd, pte) BUG()
7036 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7037
7038 #endif
7039
7040 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7041 index 34899b5..02dd060 100644
7042 --- a/arch/parisc/include/asm/pgtable.h
7043 +++ b/arch/parisc/include/asm/pgtable.h
7044 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7045 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7046 #define PAGE_COPY PAGE_EXECREAD
7047 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7048 +
7049 +#ifdef CONFIG_PAX_PAGEEXEC
7050 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7051 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7052 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7053 +#else
7054 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7055 +# define PAGE_COPY_NOEXEC PAGE_COPY
7056 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7057 +#endif
7058 +
7059 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7060 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7061 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7062 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7063 index e0a8235..ce2f1e1 100644
7064 --- a/arch/parisc/include/asm/uaccess.h
7065 +++ b/arch/parisc/include/asm/uaccess.h
7066 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7067 const void __user *from,
7068 unsigned long n)
7069 {
7070 - int sz = __compiletime_object_size(to);
7071 + size_t sz = __compiletime_object_size(to);
7072 int ret = -EFAULT;
7073
7074 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7075 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7076 ret = __copy_from_user(to, from, n);
7077 else
7078 copy_from_user_overflow();
7079 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7080 index 2a625fb..9908930 100644
7081 --- a/arch/parisc/kernel/module.c
7082 +++ b/arch/parisc/kernel/module.c
7083 @@ -98,16 +98,38 @@
7084
7085 /* three functions to determine where in the module core
7086 * or init pieces the location is */
7087 +static inline int in_init_rx(struct module *me, void *loc)
7088 +{
7089 + return (loc >= me->module_init_rx &&
7090 + loc < (me->module_init_rx + me->init_size_rx));
7091 +}
7092 +
7093 +static inline int in_init_rw(struct module *me, void *loc)
7094 +{
7095 + return (loc >= me->module_init_rw &&
7096 + loc < (me->module_init_rw + me->init_size_rw));
7097 +}
7098 +
7099 static inline int in_init(struct module *me, void *loc)
7100 {
7101 - return (loc >= me->module_init &&
7102 - loc <= (me->module_init + me->init_size));
7103 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7104 +}
7105 +
7106 +static inline int in_core_rx(struct module *me, void *loc)
7107 +{
7108 + return (loc >= me->module_core_rx &&
7109 + loc < (me->module_core_rx + me->core_size_rx));
7110 +}
7111 +
7112 +static inline int in_core_rw(struct module *me, void *loc)
7113 +{
7114 + return (loc >= me->module_core_rw &&
7115 + loc < (me->module_core_rw + me->core_size_rw));
7116 }
7117
7118 static inline int in_core(struct module *me, void *loc)
7119 {
7120 - return (loc >= me->module_core &&
7121 - loc <= (me->module_core + me->core_size));
7122 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7123 }
7124
7125 static inline int in_local(struct module *me, void *loc)
7126 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7127 }
7128
7129 /* align things a bit */
7130 - me->core_size = ALIGN(me->core_size, 16);
7131 - me->arch.got_offset = me->core_size;
7132 - me->core_size += gots * sizeof(struct got_entry);
7133 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7134 + me->arch.got_offset = me->core_size_rw;
7135 + me->core_size_rw += gots * sizeof(struct got_entry);
7136
7137 - me->core_size = ALIGN(me->core_size, 16);
7138 - me->arch.fdesc_offset = me->core_size;
7139 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7140 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7141 + me->arch.fdesc_offset = me->core_size_rw;
7142 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7143
7144 me->arch.got_max = gots;
7145 me->arch.fdesc_max = fdescs;
7146 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7147
7148 BUG_ON(value == 0);
7149
7150 - got = me->module_core + me->arch.got_offset;
7151 + got = me->module_core_rw + me->arch.got_offset;
7152 for (i = 0; got[i].addr; i++)
7153 if (got[i].addr == value)
7154 goto out;
7155 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7156 #ifdef CONFIG_64BIT
7157 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7158 {
7159 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7160 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7161
7162 if (!value) {
7163 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7164 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7165
7166 /* Create new one */
7167 fdesc->addr = value;
7168 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7169 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7170 return (Elf_Addr)fdesc;
7171 }
7172 #endif /* CONFIG_64BIT */
7173 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7174
7175 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7176 end = table + sechdrs[me->arch.unwind_section].sh_size;
7177 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7178 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7179
7180 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7181 me->arch.unwind_section, table, end, gp);
7182 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7183 index 5dfd248..64914ac 100644
7184 --- a/arch/parisc/kernel/sys_parisc.c
7185 +++ b/arch/parisc/kernel/sys_parisc.c
7186 @@ -33,9 +33,11 @@
7187 #include <linux/utsname.h>
7188 #include <linux/personality.h>
7189
7190 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7191 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7192 + unsigned long flags)
7193 {
7194 struct vm_unmapped_area_info info;
7195 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7196
7197 info.flags = 0;
7198 info.length = len;
7199 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7200 info.high_limit = TASK_SIZE;
7201 info.align_mask = 0;
7202 info.align_offset = 0;
7203 + info.threadstack_offset = offset;
7204 return vm_unmapped_area(&info);
7205 }
7206
7207 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7208 return (unsigned long) mapping >> 8;
7209 }
7210
7211 -static unsigned long get_shared_area(struct address_space *mapping,
7212 - unsigned long addr, unsigned long len, unsigned long pgoff)
7213 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7214 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7215 {
7216 struct vm_unmapped_area_info info;
7217 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7218
7219 info.flags = 0;
7220 info.length = len;
7221 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7222 info.high_limit = TASK_SIZE;
7223 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7224 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7225 + info.threadstack_offset = offset;
7226 return vm_unmapped_area(&info);
7227 }
7228
7229 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7230 return -EINVAL;
7231 return addr;
7232 }
7233 - if (!addr)
7234 + if (!addr) {
7235 addr = TASK_UNMAPPED_BASE;
7236
7237 +#ifdef CONFIG_PAX_RANDMMAP
7238 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7239 + addr += current->mm->delta_mmap;
7240 +#endif
7241 +
7242 + }
7243 +
7244 if (filp) {
7245 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7246 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7247 } else if(flags & MAP_SHARED) {
7248 - addr = get_shared_area(NULL, addr, len, pgoff);
7249 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7250 } else {
7251 - addr = get_unshared_area(addr, len);
7252 + addr = get_unshared_area(filp, addr, len, flags);
7253 }
7254 return addr;
7255 }
7256 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7257 index b3f87a3..5d5d03d 100644
7258 --- a/arch/parisc/kernel/traps.c
7259 +++ b/arch/parisc/kernel/traps.c
7260 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7261
7262 down_read(&current->mm->mmap_sem);
7263 vma = find_vma(current->mm,regs->iaoq[0]);
7264 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7265 - && (vma->vm_flags & VM_EXEC)) {
7266 -
7267 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7268 fault_address = regs->iaoq[0];
7269 fault_space = regs->iasq[0];
7270
7271 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7272 index f247a34..dc0f219 100644
7273 --- a/arch/parisc/mm/fault.c
7274 +++ b/arch/parisc/mm/fault.c
7275 @@ -15,6 +15,7 @@
7276 #include <linux/sched.h>
7277 #include <linux/interrupt.h>
7278 #include <linux/module.h>
7279 +#include <linux/unistd.h>
7280
7281 #include <asm/uaccess.h>
7282 #include <asm/traps.h>
7283 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7284 static unsigned long
7285 parisc_acctyp(unsigned long code, unsigned int inst)
7286 {
7287 - if (code == 6 || code == 16)
7288 + if (code == 6 || code == 7 || code == 16)
7289 return VM_EXEC;
7290
7291 switch (inst & 0xf0000000) {
7292 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7293 }
7294 #endif
7295
7296 +#ifdef CONFIG_PAX_PAGEEXEC
7297 +/*
7298 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7299 + *
7300 + * returns 1 when task should be killed
7301 + * 2 when rt_sigreturn trampoline was detected
7302 + * 3 when unpatched PLT trampoline was detected
7303 + */
7304 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7305 +{
7306 +
7307 +#ifdef CONFIG_PAX_EMUPLT
7308 + int err;
7309 +
7310 + do { /* PaX: unpatched PLT emulation */
7311 + unsigned int bl, depwi;
7312 +
7313 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7314 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7315 +
7316 + if (err)
7317 + break;
7318 +
7319 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7320 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7321 +
7322 + err = get_user(ldw, (unsigned int *)addr);
7323 + err |= get_user(bv, (unsigned int *)(addr+4));
7324 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7325 +
7326 + if (err)
7327 + break;
7328 +
7329 + if (ldw == 0x0E801096U &&
7330 + bv == 0xEAC0C000U &&
7331 + ldw2 == 0x0E881095U)
7332 + {
7333 + unsigned int resolver, map;
7334 +
7335 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7336 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7337 + if (err)
7338 + break;
7339 +
7340 + regs->gr[20] = instruction_pointer(regs)+8;
7341 + regs->gr[21] = map;
7342 + regs->gr[22] = resolver;
7343 + regs->iaoq[0] = resolver | 3UL;
7344 + regs->iaoq[1] = regs->iaoq[0] + 4;
7345 + return 3;
7346 + }
7347 + }
7348 + } while (0);
7349 +#endif
7350 +
7351 +#ifdef CONFIG_PAX_EMUTRAMP
7352 +
7353 +#ifndef CONFIG_PAX_EMUSIGRT
7354 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7355 + return 1;
7356 +#endif
7357 +
7358 + do { /* PaX: rt_sigreturn emulation */
7359 + unsigned int ldi1, ldi2, bel, nop;
7360 +
7361 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7362 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7363 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7364 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7365 +
7366 + if (err)
7367 + break;
7368 +
7369 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7370 + ldi2 == 0x3414015AU &&
7371 + bel == 0xE4008200U &&
7372 + nop == 0x08000240U)
7373 + {
7374 + regs->gr[25] = (ldi1 & 2) >> 1;
7375 + regs->gr[20] = __NR_rt_sigreturn;
7376 + regs->gr[31] = regs->iaoq[1] + 16;
7377 + regs->sr[0] = regs->iasq[1];
7378 + regs->iaoq[0] = 0x100UL;
7379 + regs->iaoq[1] = regs->iaoq[0] + 4;
7380 + regs->iasq[0] = regs->sr[2];
7381 + regs->iasq[1] = regs->sr[2];
7382 + return 2;
7383 + }
7384 + } while (0);
7385 +#endif
7386 +
7387 + return 1;
7388 +}
7389 +
7390 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7391 +{
7392 + unsigned long i;
7393 +
7394 + printk(KERN_ERR "PAX: bytes at PC: ");
7395 + for (i = 0; i < 5; i++) {
7396 + unsigned int c;
7397 + if (get_user(c, (unsigned int *)pc+i))
7398 + printk(KERN_CONT "???????? ");
7399 + else
7400 + printk(KERN_CONT "%08x ", c);
7401 + }
7402 + printk("\n");
7403 +}
7404 +#endif
7405 +
7406 int fixup_exception(struct pt_regs *regs)
7407 {
7408 const struct exception_table_entry *fix;
7409 @@ -194,8 +305,33 @@ good_area:
7410
7411 acc_type = parisc_acctyp(code,regs->iir);
7412
7413 - if ((vma->vm_flags & acc_type) != acc_type)
7414 + if ((vma->vm_flags & acc_type) != acc_type) {
7415 +
7416 +#ifdef CONFIG_PAX_PAGEEXEC
7417 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7418 + (address & ~3UL) == instruction_pointer(regs))
7419 + {
7420 + up_read(&mm->mmap_sem);
7421 + switch (pax_handle_fetch_fault(regs)) {
7422 +
7423 +#ifdef CONFIG_PAX_EMUPLT
7424 + case 3:
7425 + return;
7426 +#endif
7427 +
7428 +#ifdef CONFIG_PAX_EMUTRAMP
7429 + case 2:
7430 + return;
7431 +#endif
7432 +
7433 + }
7434 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7435 + do_group_exit(SIGKILL);
7436 + }
7437 +#endif
7438 +
7439 goto bad_area;
7440 + }
7441
7442 /*
7443 * If for any reason at all we couldn't handle the fault, make
7444 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7445 index e3b1d41..8e81edf 100644
7446 --- a/arch/powerpc/include/asm/atomic.h
7447 +++ b/arch/powerpc/include/asm/atomic.h
7448 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7449 return t1;
7450 }
7451
7452 +#define atomic64_read_unchecked(v) atomic64_read(v)
7453 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7454 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7455 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7456 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7457 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7458 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7459 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7460 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7461 +
7462 #endif /* __powerpc64__ */
7463
7464 #endif /* __KERNEL__ */
7465 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7466 index 9e495c9..b6878e5 100644
7467 --- a/arch/powerpc/include/asm/cache.h
7468 +++ b/arch/powerpc/include/asm/cache.h
7469 @@ -3,6 +3,7 @@
7470
7471 #ifdef __KERNEL__
7472
7473 +#include <linux/const.h>
7474
7475 /* bytes per L1 cache line */
7476 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7477 @@ -22,7 +23,7 @@
7478 #define L1_CACHE_SHIFT 7
7479 #endif
7480
7481 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7482 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7483
7484 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7485
7486 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7487 index cc0655a..13eac2e 100644
7488 --- a/arch/powerpc/include/asm/elf.h
7489 +++ b/arch/powerpc/include/asm/elf.h
7490 @@ -28,8 +28,19 @@
7491 the loader. We need to make sure that it is out of the way of the program
7492 that it will "exec", and that there is sufficient room for the brk. */
7493
7494 -extern unsigned long randomize_et_dyn(unsigned long base);
7495 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7496 +#define ELF_ET_DYN_BASE (0x20000000)
7497 +
7498 +#ifdef CONFIG_PAX_ASLR
7499 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7500 +
7501 +#ifdef __powerpc64__
7502 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7503 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7504 +#else
7505 +#define PAX_DELTA_MMAP_LEN 15
7506 +#define PAX_DELTA_STACK_LEN 15
7507 +#endif
7508 +#endif
7509
7510 /*
7511 * Our registers are always unsigned longs, whether we're a 32 bit
7512 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7513 (0x7ff >> (PAGE_SHIFT - 12)) : \
7514 (0x3ffff >> (PAGE_SHIFT - 12)))
7515
7516 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7517 -#define arch_randomize_brk arch_randomize_brk
7518 -
7519 -
7520 #ifdef CONFIG_SPU_BASE
7521 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7522 #define NT_SPU 1
7523 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7524 index 8196e9c..d83a9f3 100644
7525 --- a/arch/powerpc/include/asm/exec.h
7526 +++ b/arch/powerpc/include/asm/exec.h
7527 @@ -4,6 +4,6 @@
7528 #ifndef _ASM_POWERPC_EXEC_H
7529 #define _ASM_POWERPC_EXEC_H
7530
7531 -extern unsigned long arch_align_stack(unsigned long sp);
7532 +#define arch_align_stack(x) ((x) & ~0xfUL)
7533
7534 #endif /* _ASM_POWERPC_EXEC_H */
7535 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7536 index 5acabbd..7ea14fa 100644
7537 --- a/arch/powerpc/include/asm/kmap_types.h
7538 +++ b/arch/powerpc/include/asm/kmap_types.h
7539 @@ -10,7 +10,7 @@
7540 * 2 of the License, or (at your option) any later version.
7541 */
7542
7543 -#define KM_TYPE_NR 16
7544 +#define KM_TYPE_NR 17
7545
7546 #endif /* __KERNEL__ */
7547 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7548 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7549 index 8565c25..2865190 100644
7550 --- a/arch/powerpc/include/asm/mman.h
7551 +++ b/arch/powerpc/include/asm/mman.h
7552 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7553 }
7554 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7555
7556 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7557 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7558 {
7559 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7560 }
7561 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7562 index b9f4262..dcf04f7 100644
7563 --- a/arch/powerpc/include/asm/page.h
7564 +++ b/arch/powerpc/include/asm/page.h
7565 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7566 * and needs to be executable. This means the whole heap ends
7567 * up being executable.
7568 */
7569 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7570 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7571 +#define VM_DATA_DEFAULT_FLAGS32 \
7572 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7573 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7574
7575 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7576 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7577 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7578 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7579 #endif
7580
7581 +#define ktla_ktva(addr) (addr)
7582 +#define ktva_ktla(addr) (addr)
7583 +
7584 #ifndef CONFIG_PPC_BOOK3S_64
7585 /*
7586 * Use the top bit of the higher-level page table entries to indicate whether
7587 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7588 index 88693ce..ac6f9ab 100644
7589 --- a/arch/powerpc/include/asm/page_64.h
7590 +++ b/arch/powerpc/include/asm/page_64.h
7591 @@ -153,15 +153,18 @@ do { \
7592 * stack by default, so in the absence of a PT_GNU_STACK program header
7593 * we turn execute permission off.
7594 */
7595 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7596 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7597 +#define VM_STACK_DEFAULT_FLAGS32 \
7598 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7599 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7600
7601 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7602 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7603
7604 +#ifndef CONFIG_PAX_PAGEEXEC
7605 #define VM_STACK_DEFAULT_FLAGS \
7606 (is_32bit_task() ? \
7607 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7608 +#endif
7609
7610 #include <asm-generic/getorder.h>
7611
7612 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7613 index f65e27b..23ffb5b 100644
7614 --- a/arch/powerpc/include/asm/pgalloc-64.h
7615 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7616 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7617 #ifndef CONFIG_PPC_64K_PAGES
7618
7619 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7620 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7621
7622 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7623 {
7624 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7625 pud_set(pud, (unsigned long)pmd);
7626 }
7627
7628 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7629 +{
7630 + pud_populate(mm, pud, pmd);
7631 +}
7632 +
7633 #define pmd_populate(mm, pmd, pte_page) \
7634 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7635 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7636 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7637 #endif
7638
7639 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7640 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7641
7642 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7643 pte_t *pte)
7644 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7645 index 7d6eacf..14c0240 100644
7646 --- a/arch/powerpc/include/asm/pgtable.h
7647 +++ b/arch/powerpc/include/asm/pgtable.h
7648 @@ -2,6 +2,7 @@
7649 #define _ASM_POWERPC_PGTABLE_H
7650 #ifdef __KERNEL__
7651
7652 +#include <linux/const.h>
7653 #ifndef __ASSEMBLY__
7654 #include <asm/processor.h> /* For TASK_SIZE */
7655 #include <asm/mmu.h>
7656 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7657 index 4aad413..85d86bf 100644
7658 --- a/arch/powerpc/include/asm/pte-hash32.h
7659 +++ b/arch/powerpc/include/asm/pte-hash32.h
7660 @@ -21,6 +21,7 @@
7661 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7662 #define _PAGE_USER 0x004 /* usermode access allowed */
7663 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7664 +#define _PAGE_EXEC _PAGE_GUARDED
7665 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7666 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7667 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7668 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7669 index 99222e2..f629aef 100644
7670 --- a/arch/powerpc/include/asm/reg.h
7671 +++ b/arch/powerpc/include/asm/reg.h
7672 @@ -234,6 +234,7 @@
7673 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7674 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7675 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7676 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7677 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7678 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7679 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7680 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7681 index 48cfc85..891382f 100644
7682 --- a/arch/powerpc/include/asm/smp.h
7683 +++ b/arch/powerpc/include/asm/smp.h
7684 @@ -50,7 +50,7 @@ struct smp_ops_t {
7685 int (*cpu_disable)(void);
7686 void (*cpu_die)(unsigned int nr);
7687 int (*cpu_bootable)(unsigned int nr);
7688 -};
7689 +} __no_const;
7690
7691 extern void smp_send_debugger_break(void);
7692 extern void start_secondary_resume(void);
7693 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7694 index ba7b197..d292e26 100644
7695 --- a/arch/powerpc/include/asm/thread_info.h
7696 +++ b/arch/powerpc/include/asm/thread_info.h
7697 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7698 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7699 TIF_NEED_RESCHED */
7700 #define TIF_32BIT 4 /* 32 bit binary */
7701 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7702 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7703 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7704 #define TIF_SINGLESTEP 8 /* singlestepping active */
7705 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7706 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7707 for stack store? */
7708 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7709 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7710 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7711 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7712
7713 /* as above, but as bit values */
7714 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7715 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7716 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7717 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7718 #define _TIF_NOHZ (1<<TIF_NOHZ)
7719 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7720 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7721 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7722 - _TIF_NOHZ)
7723 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7724
7725 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7726 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7727 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7728 index 9485b43..4718d50 100644
7729 --- a/arch/powerpc/include/asm/uaccess.h
7730 +++ b/arch/powerpc/include/asm/uaccess.h
7731 @@ -318,52 +318,6 @@ do { \
7732 extern unsigned long __copy_tofrom_user(void __user *to,
7733 const void __user *from, unsigned long size);
7734
7735 -#ifndef __powerpc64__
7736 -
7737 -static inline unsigned long copy_from_user(void *to,
7738 - const void __user *from, unsigned long n)
7739 -{
7740 - unsigned long over;
7741 -
7742 - if (access_ok(VERIFY_READ, from, n))
7743 - return __copy_tofrom_user((__force void __user *)to, from, n);
7744 - if ((unsigned long)from < TASK_SIZE) {
7745 - over = (unsigned long)from + n - TASK_SIZE;
7746 - return __copy_tofrom_user((__force void __user *)to, from,
7747 - n - over) + over;
7748 - }
7749 - return n;
7750 -}
7751 -
7752 -static inline unsigned long copy_to_user(void __user *to,
7753 - const void *from, unsigned long n)
7754 -{
7755 - unsigned long over;
7756 -
7757 - if (access_ok(VERIFY_WRITE, to, n))
7758 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7759 - if ((unsigned long)to < TASK_SIZE) {
7760 - over = (unsigned long)to + n - TASK_SIZE;
7761 - return __copy_tofrom_user(to, (__force void __user *)from,
7762 - n - over) + over;
7763 - }
7764 - return n;
7765 -}
7766 -
7767 -#else /* __powerpc64__ */
7768 -
7769 -#define __copy_in_user(to, from, size) \
7770 - __copy_tofrom_user((to), (from), (size))
7771 -
7772 -extern unsigned long copy_from_user(void *to, const void __user *from,
7773 - unsigned long n);
7774 -extern unsigned long copy_to_user(void __user *to, const void *from,
7775 - unsigned long n);
7776 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7777 - unsigned long n);
7778 -
7779 -#endif /* __powerpc64__ */
7780 -
7781 static inline unsigned long __copy_from_user_inatomic(void *to,
7782 const void __user *from, unsigned long n)
7783 {
7784 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7785 if (ret == 0)
7786 return 0;
7787 }
7788 +
7789 + if (!__builtin_constant_p(n))
7790 + check_object_size(to, n, false);
7791 +
7792 return __copy_tofrom_user((__force void __user *)to, from, n);
7793 }
7794
7795 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7796 if (ret == 0)
7797 return 0;
7798 }
7799 +
7800 + if (!__builtin_constant_p(n))
7801 + check_object_size(from, n, true);
7802 +
7803 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7804 }
7805
7806 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7807 return __copy_to_user_inatomic(to, from, size);
7808 }
7809
7810 +#ifndef __powerpc64__
7811 +
7812 +static inline unsigned long __must_check copy_from_user(void *to,
7813 + const void __user *from, unsigned long n)
7814 +{
7815 + unsigned long over;
7816 +
7817 + if ((long)n < 0)
7818 + return n;
7819 +
7820 + if (access_ok(VERIFY_READ, from, n)) {
7821 + if (!__builtin_constant_p(n))
7822 + check_object_size(to, n, false);
7823 + return __copy_tofrom_user((__force void __user *)to, from, n);
7824 + }
7825 + if ((unsigned long)from < TASK_SIZE) {
7826 + over = (unsigned long)from + n - TASK_SIZE;
7827 + if (!__builtin_constant_p(n - over))
7828 + check_object_size(to, n - over, false);
7829 + return __copy_tofrom_user((__force void __user *)to, from,
7830 + n - over) + over;
7831 + }
7832 + return n;
7833 +}
7834 +
7835 +static inline unsigned long __must_check copy_to_user(void __user *to,
7836 + const void *from, unsigned long n)
7837 +{
7838 + unsigned long over;
7839 +
7840 + if ((long)n < 0)
7841 + return n;
7842 +
7843 + if (access_ok(VERIFY_WRITE, to, n)) {
7844 + if (!__builtin_constant_p(n))
7845 + check_object_size(from, n, true);
7846 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7847 + }
7848 + if ((unsigned long)to < TASK_SIZE) {
7849 + over = (unsigned long)to + n - TASK_SIZE;
7850 + if (!__builtin_constant_p(n))
7851 + check_object_size(from, n - over, true);
7852 + return __copy_tofrom_user(to, (__force void __user *)from,
7853 + n - over) + over;
7854 + }
7855 + return n;
7856 +}
7857 +
7858 +#else /* __powerpc64__ */
7859 +
7860 +#define __copy_in_user(to, from, size) \
7861 + __copy_tofrom_user((to), (from), (size))
7862 +
7863 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7864 +{
7865 + if ((long)n < 0 || n > INT_MAX)
7866 + return n;
7867 +
7868 + if (!__builtin_constant_p(n))
7869 + check_object_size(to, n, false);
7870 +
7871 + if (likely(access_ok(VERIFY_READ, from, n)))
7872 + n = __copy_from_user(to, from, n);
7873 + else
7874 + memset(to, 0, n);
7875 + return n;
7876 +}
7877 +
7878 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7879 +{
7880 + if ((long)n < 0 || n > INT_MAX)
7881 + return n;
7882 +
7883 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7884 + if (!__builtin_constant_p(n))
7885 + check_object_size(from, n, true);
7886 + n = __copy_to_user(to, from, n);
7887 + }
7888 + return n;
7889 +}
7890 +
7891 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7892 + unsigned long n);
7893 +
7894 +#endif /* __powerpc64__ */
7895 +
7896 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7897
7898 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7899 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7900 index 645170a..6cf0271 100644
7901 --- a/arch/powerpc/kernel/exceptions-64e.S
7902 +++ b/arch/powerpc/kernel/exceptions-64e.S
7903 @@ -757,6 +757,7 @@ storage_fault_common:
7904 std r14,_DAR(r1)
7905 std r15,_DSISR(r1)
7906 addi r3,r1,STACK_FRAME_OVERHEAD
7907 + bl .save_nvgprs
7908 mr r4,r14
7909 mr r5,r15
7910 ld r14,PACA_EXGEN+EX_R14(r13)
7911 @@ -765,8 +766,7 @@ storage_fault_common:
7912 cmpdi r3,0
7913 bne- 1f
7914 b .ret_from_except_lite
7915 -1: bl .save_nvgprs
7916 - mr r5,r3
7917 +1: mr r5,r3
7918 addi r3,r1,STACK_FRAME_OVERHEAD
7919 ld r4,_DAR(r1)
7920 bl .bad_page_fault
7921 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7922 index 902ca3c..e942155 100644
7923 --- a/arch/powerpc/kernel/exceptions-64s.S
7924 +++ b/arch/powerpc/kernel/exceptions-64s.S
7925 @@ -1357,10 +1357,10 @@ handle_page_fault:
7926 11: ld r4,_DAR(r1)
7927 ld r5,_DSISR(r1)
7928 addi r3,r1,STACK_FRAME_OVERHEAD
7929 + bl .save_nvgprs
7930 bl .do_page_fault
7931 cmpdi r3,0
7932 beq+ 12f
7933 - bl .save_nvgprs
7934 mr r5,r3
7935 addi r3,r1,STACK_FRAME_OVERHEAD
7936 lwz r4,_DAR(r1)
7937 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7938 index 2e3200c..72095ce 100644
7939 --- a/arch/powerpc/kernel/module_32.c
7940 +++ b/arch/powerpc/kernel/module_32.c
7941 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7942 me->arch.core_plt_section = i;
7943 }
7944 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7945 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7946 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7947 return -ENOEXEC;
7948 }
7949
7950 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7951
7952 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7953 /* Init, or core PLT? */
7954 - if (location >= mod->module_core
7955 - && location < mod->module_core + mod->core_size)
7956 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7957 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7958 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7959 - else
7960 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7961 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7962 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7963 + else {
7964 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7965 + return ~0UL;
7966 + }
7967
7968 /* Find this entry, or if that fails, the next avail. entry */
7969 while (entry->jump[0]) {
7970 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7971 index 8083be2..10aa352 100644
7972 --- a/arch/powerpc/kernel/process.c
7973 +++ b/arch/powerpc/kernel/process.c
7974 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
7975 * Lookup NIP late so we have the best change of getting the
7976 * above info out without failing
7977 */
7978 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7979 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7980 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7981 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7982 #endif
7983 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
7984 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
7985 @@ -1349,10 +1349,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7986 newsp = stack[0];
7987 ip = stack[STACK_FRAME_LR_SAVE];
7988 if (!firstframe || ip != lr) {
7989 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
7990 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
7991 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
7992 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
7993 - printk(" (%pS)",
7994 + printk(" (%pA)",
7995 (void *)current->ret_stack[curr_frame].ret);
7996 curr_frame--;
7997 }
7998 @@ -1372,7 +1372,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7999 struct pt_regs *regs = (struct pt_regs *)
8000 (sp + STACK_FRAME_OVERHEAD);
8001 lr = regs->link;
8002 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8003 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8004 regs->trap, (void *)regs->nip, (void *)lr);
8005 firstframe = 1;
8006 }
8007 @@ -1408,58 +1408,3 @@ void notrace __ppc64_runlatch_off(void)
8008 mtspr(SPRN_CTRLT, ctrl);
8009 }
8010 #endif /* CONFIG_PPC64 */
8011 -
8012 -unsigned long arch_align_stack(unsigned long sp)
8013 -{
8014 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8015 - sp -= get_random_int() & ~PAGE_MASK;
8016 - return sp & ~0xf;
8017 -}
8018 -
8019 -static inline unsigned long brk_rnd(void)
8020 -{
8021 - unsigned long rnd = 0;
8022 -
8023 - /* 8MB for 32bit, 1GB for 64bit */
8024 - if (is_32bit_task())
8025 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8026 - else
8027 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8028 -
8029 - return rnd << PAGE_SHIFT;
8030 -}
8031 -
8032 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8033 -{
8034 - unsigned long base = mm->brk;
8035 - unsigned long ret;
8036 -
8037 -#ifdef CONFIG_PPC_STD_MMU_64
8038 - /*
8039 - * If we are using 1TB segments and we are allowed to randomise
8040 - * the heap, we can put it above 1TB so it is backed by a 1TB
8041 - * segment. Otherwise the heap will be in the bottom 1TB
8042 - * which always uses 256MB segments and this may result in a
8043 - * performance penalty.
8044 - */
8045 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8046 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8047 -#endif
8048 -
8049 - ret = PAGE_ALIGN(base + brk_rnd());
8050 -
8051 - if (ret < mm->brk)
8052 - return mm->brk;
8053 -
8054 - return ret;
8055 -}
8056 -
8057 -unsigned long randomize_et_dyn(unsigned long base)
8058 -{
8059 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8060 -
8061 - if (ret < base)
8062 - return base;
8063 -
8064 - return ret;
8065 -}
8066 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8067 index 9a0d24c..e7fbedf 100644
8068 --- a/arch/powerpc/kernel/ptrace.c
8069 +++ b/arch/powerpc/kernel/ptrace.c
8070 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8071 return ret;
8072 }
8073
8074 +#ifdef CONFIG_GRKERNSEC_SETXID
8075 +extern void gr_delayed_cred_worker(void);
8076 +#endif
8077 +
8078 /*
8079 * We must return the syscall number to actually look up in the table.
8080 * This can be -1L to skip running any syscall at all.
8081 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8082
8083 secure_computing_strict(regs->gpr[0]);
8084
8085 +#ifdef CONFIG_GRKERNSEC_SETXID
8086 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8087 + gr_delayed_cred_worker();
8088 +#endif
8089 +
8090 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8091 tracehook_report_syscall_entry(regs))
8092 /*
8093 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8094 {
8095 int step;
8096
8097 +#ifdef CONFIG_GRKERNSEC_SETXID
8098 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8099 + gr_delayed_cred_worker();
8100 +#endif
8101 +
8102 audit_syscall_exit(regs);
8103
8104 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8105 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8106 index 0f83122..c0aca6a 100644
8107 --- a/arch/powerpc/kernel/signal_32.c
8108 +++ b/arch/powerpc/kernel/signal_32.c
8109 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8110 /* Save user registers on the stack */
8111 frame = &rt_sf->uc.uc_mcontext;
8112 addr = frame;
8113 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8114 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8115 sigret = 0;
8116 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8117 } else {
8118 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8119 index 887e99d..310bc11 100644
8120 --- a/arch/powerpc/kernel/signal_64.c
8121 +++ b/arch/powerpc/kernel/signal_64.c
8122 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8123 #endif
8124
8125 /* Set up to return from userspace. */
8126 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8127 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8128 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8129 } else {
8130 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8131 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8132 index e435bc0..41c2964 100644
8133 --- a/arch/powerpc/kernel/traps.c
8134 +++ b/arch/powerpc/kernel/traps.c
8135 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8136 return flags;
8137 }
8138
8139 +extern void gr_handle_kernel_exploit(void);
8140 +
8141 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8142 int signr)
8143 {
8144 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8145 panic("Fatal exception in interrupt");
8146 if (panic_on_oops)
8147 panic("Fatal exception");
8148 +
8149 + gr_handle_kernel_exploit();
8150 +
8151 do_exit(signr);
8152 }
8153
8154 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8155 index 1d9c926..25f4741 100644
8156 --- a/arch/powerpc/kernel/vdso.c
8157 +++ b/arch/powerpc/kernel/vdso.c
8158 @@ -34,6 +34,7 @@
8159 #include <asm/firmware.h>
8160 #include <asm/vdso.h>
8161 #include <asm/vdso_datapage.h>
8162 +#include <asm/mman.h>
8163
8164 #include "setup.h"
8165
8166 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8167 vdso_base = VDSO32_MBASE;
8168 #endif
8169
8170 - current->mm->context.vdso_base = 0;
8171 + current->mm->context.vdso_base = ~0UL;
8172
8173 /* vDSO has a problem and was disabled, just don't "enable" it for the
8174 * process
8175 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8176 vdso_base = get_unmapped_area(NULL, vdso_base,
8177 (vdso_pages << PAGE_SHIFT) +
8178 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8179 - 0, 0);
8180 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8181 if (IS_ERR_VALUE(vdso_base)) {
8182 rc = vdso_base;
8183 goto fail_mmapsem;
8184 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8185 index 5eea6f3..5d10396 100644
8186 --- a/arch/powerpc/lib/usercopy_64.c
8187 +++ b/arch/powerpc/lib/usercopy_64.c
8188 @@ -9,22 +9,6 @@
8189 #include <linux/module.h>
8190 #include <asm/uaccess.h>
8191
8192 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8193 -{
8194 - if (likely(access_ok(VERIFY_READ, from, n)))
8195 - n = __copy_from_user(to, from, n);
8196 - else
8197 - memset(to, 0, n);
8198 - return n;
8199 -}
8200 -
8201 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8202 -{
8203 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8204 - n = __copy_to_user(to, from, n);
8205 - return n;
8206 -}
8207 -
8208 unsigned long copy_in_user(void __user *to, const void __user *from,
8209 unsigned long n)
8210 {
8211 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8212 return n;
8213 }
8214
8215 -EXPORT_SYMBOL(copy_from_user);
8216 -EXPORT_SYMBOL(copy_to_user);
8217 EXPORT_SYMBOL(copy_in_user);
8218
8219 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8220 index 8726779..a33c512 100644
8221 --- a/arch/powerpc/mm/fault.c
8222 +++ b/arch/powerpc/mm/fault.c
8223 @@ -33,6 +33,10 @@
8224 #include <linux/magic.h>
8225 #include <linux/ratelimit.h>
8226 #include <linux/context_tracking.h>
8227 +#include <linux/slab.h>
8228 +#include <linux/pagemap.h>
8229 +#include <linux/compiler.h>
8230 +#include <linux/unistd.h>
8231
8232 #include <asm/firmware.h>
8233 #include <asm/page.h>
8234 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8235 }
8236 #endif
8237
8238 +#ifdef CONFIG_PAX_PAGEEXEC
8239 +/*
8240 + * PaX: decide what to do with offenders (regs->nip = fault address)
8241 + *
8242 + * returns 1 when task should be killed
8243 + */
8244 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8245 +{
8246 + return 1;
8247 +}
8248 +
8249 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8250 +{
8251 + unsigned long i;
8252 +
8253 + printk(KERN_ERR "PAX: bytes at PC: ");
8254 + for (i = 0; i < 5; i++) {
8255 + unsigned int c;
8256 + if (get_user(c, (unsigned int __user *)pc+i))
8257 + printk(KERN_CONT "???????? ");
8258 + else
8259 + printk(KERN_CONT "%08x ", c);
8260 + }
8261 + printk("\n");
8262 +}
8263 +#endif
8264 +
8265 /*
8266 * Check whether the instruction at regs->nip is a store using
8267 * an update addressing form which will update r1.
8268 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8269 * indicate errors in DSISR but can validly be set in SRR1.
8270 */
8271 if (trap == 0x400)
8272 - error_code &= 0x48200000;
8273 + error_code &= 0x58200000;
8274 else
8275 is_write = error_code & DSISR_ISSTORE;
8276 #else
8277 @@ -371,7 +402,7 @@ good_area:
8278 * "undefined". Of those that can be set, this is the only
8279 * one which seems bad.
8280 */
8281 - if (error_code & 0x10000000)
8282 + if (error_code & DSISR_GUARDED)
8283 /* Guarded storage error. */
8284 goto bad_area;
8285 #endif /* CONFIG_8xx */
8286 @@ -386,7 +417,7 @@ good_area:
8287 * processors use the same I/D cache coherency mechanism
8288 * as embedded.
8289 */
8290 - if (error_code & DSISR_PROTFAULT)
8291 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8292 goto bad_area;
8293 #endif /* CONFIG_PPC_STD_MMU */
8294
8295 @@ -471,6 +502,23 @@ bad_area:
8296 bad_area_nosemaphore:
8297 /* User mode accesses cause a SIGSEGV */
8298 if (user_mode(regs)) {
8299 +
8300 +#ifdef CONFIG_PAX_PAGEEXEC
8301 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8302 +#ifdef CONFIG_PPC_STD_MMU
8303 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8304 +#else
8305 + if (is_exec && regs->nip == address) {
8306 +#endif
8307 + switch (pax_handle_fetch_fault(regs)) {
8308 + }
8309 +
8310 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8311 + do_group_exit(SIGKILL);
8312 + }
8313 + }
8314 +#endif
8315 +
8316 _exception(SIGSEGV, regs, code, address);
8317 goto bail;
8318 }
8319 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8320 index cb8bdbe..d770680 100644
8321 --- a/arch/powerpc/mm/mmap.c
8322 +++ b/arch/powerpc/mm/mmap.c
8323 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8324 {
8325 unsigned long rnd = 0;
8326
8327 +#ifdef CONFIG_PAX_RANDMMAP
8328 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8329 +#endif
8330 +
8331 if (current->flags & PF_RANDOMIZE) {
8332 /* 8MB for 32bit, 1GB for 64bit */
8333 if (is_32bit_task())
8334 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8335 */
8336 if (mmap_is_legacy()) {
8337 mm->mmap_base = TASK_UNMAPPED_BASE;
8338 +
8339 +#ifdef CONFIG_PAX_RANDMMAP
8340 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8341 + mm->mmap_base += mm->delta_mmap;
8342 +#endif
8343 +
8344 mm->get_unmapped_area = arch_get_unmapped_area;
8345 } else {
8346 mm->mmap_base = mmap_base();
8347 +
8348 +#ifdef CONFIG_PAX_RANDMMAP
8349 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8350 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8351 +#endif
8352 +
8353 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8354 }
8355 }
8356 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8357 index 3e99c14..f00953c 100644
8358 --- a/arch/powerpc/mm/slice.c
8359 +++ b/arch/powerpc/mm/slice.c
8360 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8361 if ((mm->task_size - len) < addr)
8362 return 0;
8363 vma = find_vma(mm, addr);
8364 - return (!vma || (addr + len) <= vma->vm_start);
8365 + return check_heap_stack_gap(vma, addr, len, 0);
8366 }
8367
8368 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8369 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8370 info.align_offset = 0;
8371
8372 addr = TASK_UNMAPPED_BASE;
8373 +
8374 +#ifdef CONFIG_PAX_RANDMMAP
8375 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8376 + addr += mm->delta_mmap;
8377 +#endif
8378 +
8379 while (addr < TASK_SIZE) {
8380 info.low_limit = addr;
8381 if (!slice_scan_available(addr, available, 1, &addr))
8382 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8383 if (fixed && addr > (mm->task_size - len))
8384 return -EINVAL;
8385
8386 +#ifdef CONFIG_PAX_RANDMMAP
8387 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8388 + addr = 0;
8389 +#endif
8390 +
8391 /* If hint, make sure it matches our alignment restrictions */
8392 if (!fixed && addr) {
8393 addr = _ALIGN_UP(addr, 1ul << pshift);
8394 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8395 index 9098692..3d54cd1 100644
8396 --- a/arch/powerpc/platforms/cell/spufs/file.c
8397 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8398 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8399 return VM_FAULT_NOPAGE;
8400 }
8401
8402 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8403 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8404 unsigned long address,
8405 - void *buf, int len, int write)
8406 + void *buf, size_t len, int write)
8407 {
8408 struct spu_context *ctx = vma->vm_file->private_data;
8409 unsigned long offset = address - vma->vm_start;
8410 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8411 index c797832..ce575c8 100644
8412 --- a/arch/s390/include/asm/atomic.h
8413 +++ b/arch/s390/include/asm/atomic.h
8414 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8415 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8416 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8417
8418 +#define atomic64_read_unchecked(v) atomic64_read(v)
8419 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8420 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8421 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8422 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8423 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8424 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8425 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8426 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8427 +
8428 #define smp_mb__before_atomic_dec() smp_mb()
8429 #define smp_mb__after_atomic_dec() smp_mb()
8430 #define smp_mb__before_atomic_inc() smp_mb()
8431 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8432 index 4d7ccac..d03d0ad 100644
8433 --- a/arch/s390/include/asm/cache.h
8434 +++ b/arch/s390/include/asm/cache.h
8435 @@ -9,8 +9,10 @@
8436 #ifndef __ARCH_S390_CACHE_H
8437 #define __ARCH_S390_CACHE_H
8438
8439 -#define L1_CACHE_BYTES 256
8440 +#include <linux/const.h>
8441 +
8442 #define L1_CACHE_SHIFT 8
8443 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8444 #define NET_SKB_PAD 32
8445
8446 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8447 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8448 index 78f4f87..598ce39 100644
8449 --- a/arch/s390/include/asm/elf.h
8450 +++ b/arch/s390/include/asm/elf.h
8451 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8452 the loader. We need to make sure that it is out of the way of the program
8453 that it will "exec", and that there is sufficient room for the brk. */
8454
8455 -extern unsigned long randomize_et_dyn(unsigned long base);
8456 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8457 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8458 +
8459 +#ifdef CONFIG_PAX_ASLR
8460 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8461 +
8462 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8463 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8464 +#endif
8465
8466 /* This yields a mask that user programs can use to figure out what
8467 instruction set this CPU supports. */
8468 @@ -222,9 +228,6 @@ struct linux_binprm;
8469 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8470 int arch_setup_additional_pages(struct linux_binprm *, int);
8471
8472 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8473 -#define arch_randomize_brk arch_randomize_brk
8474 -
8475 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8476
8477 #endif
8478 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8479 index c4a93d6..4d2a9b4 100644
8480 --- a/arch/s390/include/asm/exec.h
8481 +++ b/arch/s390/include/asm/exec.h
8482 @@ -7,6 +7,6 @@
8483 #ifndef __ASM_EXEC_H
8484 #define __ASM_EXEC_H
8485
8486 -extern unsigned long arch_align_stack(unsigned long sp);
8487 +#define arch_align_stack(x) ((x) & ~0xfUL)
8488
8489 #endif /* __ASM_EXEC_H */
8490 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8491 index 9c33ed4..e40cbef 100644
8492 --- a/arch/s390/include/asm/uaccess.h
8493 +++ b/arch/s390/include/asm/uaccess.h
8494 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8495 copy_to_user(void __user *to, const void *from, unsigned long n)
8496 {
8497 might_fault();
8498 +
8499 + if ((long)n < 0)
8500 + return n;
8501 +
8502 return __copy_to_user(to, from, n);
8503 }
8504
8505 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8506 static inline unsigned long __must_check
8507 __copy_from_user(void *to, const void __user *from, unsigned long n)
8508 {
8509 + if ((long)n < 0)
8510 + return n;
8511 +
8512 if (__builtin_constant_p(n) && (n <= 256))
8513 return uaccess.copy_from_user_small(n, from, to);
8514 else
8515 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8516 static inline unsigned long __must_check
8517 copy_from_user(void *to, const void __user *from, unsigned long n)
8518 {
8519 - unsigned int sz = __compiletime_object_size(to);
8520 + size_t sz = __compiletime_object_size(to);
8521
8522 might_fault();
8523 - if (unlikely(sz != -1 && sz < n)) {
8524 +
8525 + if ((long)n < 0)
8526 + return n;
8527 +
8528 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8529 copy_from_user_overflow();
8530 return n;
8531 }
8532 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8533 index 7845e15..59c4353 100644
8534 --- a/arch/s390/kernel/module.c
8535 +++ b/arch/s390/kernel/module.c
8536 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8537
8538 /* Increase core size by size of got & plt and set start
8539 offsets for got and plt. */
8540 - me->core_size = ALIGN(me->core_size, 4);
8541 - me->arch.got_offset = me->core_size;
8542 - me->core_size += me->arch.got_size;
8543 - me->arch.plt_offset = me->core_size;
8544 - me->core_size += me->arch.plt_size;
8545 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8546 + me->arch.got_offset = me->core_size_rw;
8547 + me->core_size_rw += me->arch.got_size;
8548 + me->arch.plt_offset = me->core_size_rx;
8549 + me->core_size_rx += me->arch.plt_size;
8550 return 0;
8551 }
8552
8553 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8554 if (info->got_initialized == 0) {
8555 Elf_Addr *gotent;
8556
8557 - gotent = me->module_core + me->arch.got_offset +
8558 + gotent = me->module_core_rw + me->arch.got_offset +
8559 info->got_offset;
8560 *gotent = val;
8561 info->got_initialized = 1;
8562 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8563 rc = apply_rela_bits(loc, val, 0, 64, 0);
8564 else if (r_type == R_390_GOTENT ||
8565 r_type == R_390_GOTPLTENT) {
8566 - val += (Elf_Addr) me->module_core - loc;
8567 + val += (Elf_Addr) me->module_core_rw - loc;
8568 rc = apply_rela_bits(loc, val, 1, 32, 1);
8569 }
8570 break;
8571 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8572 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8573 if (info->plt_initialized == 0) {
8574 unsigned int *ip;
8575 - ip = me->module_core + me->arch.plt_offset +
8576 + ip = me->module_core_rx + me->arch.plt_offset +
8577 info->plt_offset;
8578 #ifndef CONFIG_64BIT
8579 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8580 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8581 val - loc + 0xffffUL < 0x1ffffeUL) ||
8582 (r_type == R_390_PLT32DBL &&
8583 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8584 - val = (Elf_Addr) me->module_core +
8585 + val = (Elf_Addr) me->module_core_rx +
8586 me->arch.plt_offset +
8587 info->plt_offset;
8588 val += rela->r_addend - loc;
8589 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8590 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8591 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8592 val = val + rela->r_addend -
8593 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8594 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8595 if (r_type == R_390_GOTOFF16)
8596 rc = apply_rela_bits(loc, val, 0, 16, 0);
8597 else if (r_type == R_390_GOTOFF32)
8598 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8599 break;
8600 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8601 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8602 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8603 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8604 rela->r_addend - loc;
8605 if (r_type == R_390_GOTPC)
8606 rc = apply_rela_bits(loc, val, 1, 32, 0);
8607 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8608 index 2bc3edd..ab9d598 100644
8609 --- a/arch/s390/kernel/process.c
8610 +++ b/arch/s390/kernel/process.c
8611 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
8612 }
8613 return 0;
8614 }
8615 -
8616 -unsigned long arch_align_stack(unsigned long sp)
8617 -{
8618 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8619 - sp -= get_random_int() & ~PAGE_MASK;
8620 - return sp & ~0xf;
8621 -}
8622 -
8623 -static inline unsigned long brk_rnd(void)
8624 -{
8625 - /* 8MB for 32bit, 1GB for 64bit */
8626 - if (is_32bit_task())
8627 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8628 - else
8629 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8630 -}
8631 -
8632 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8633 -{
8634 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8635 -
8636 - if (ret < mm->brk)
8637 - return mm->brk;
8638 - return ret;
8639 -}
8640 -
8641 -unsigned long randomize_et_dyn(unsigned long base)
8642 -{
8643 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8644 -
8645 - if (!(current->flags & PF_RANDOMIZE))
8646 - return base;
8647 - if (ret < base)
8648 - return base;
8649 - return ret;
8650 -}
8651 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8652 index 4002329..99b67cb 100644
8653 --- a/arch/s390/mm/mmap.c
8654 +++ b/arch/s390/mm/mmap.c
8655 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8656 */
8657 if (mmap_is_legacy()) {
8658 mm->mmap_base = TASK_UNMAPPED_BASE;
8659 +
8660 +#ifdef CONFIG_PAX_RANDMMAP
8661 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8662 + mm->mmap_base += mm->delta_mmap;
8663 +#endif
8664 +
8665 mm->get_unmapped_area = arch_get_unmapped_area;
8666 } else {
8667 mm->mmap_base = mmap_base();
8668 +
8669 +#ifdef CONFIG_PAX_RANDMMAP
8670 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8671 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8672 +#endif
8673 +
8674 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8675 }
8676 }
8677 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8678 */
8679 if (mmap_is_legacy()) {
8680 mm->mmap_base = TASK_UNMAPPED_BASE;
8681 +
8682 +#ifdef CONFIG_PAX_RANDMMAP
8683 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8684 + mm->mmap_base += mm->delta_mmap;
8685 +#endif
8686 +
8687 mm->get_unmapped_area = s390_get_unmapped_area;
8688 } else {
8689 mm->mmap_base = mmap_base();
8690 +
8691 +#ifdef CONFIG_PAX_RANDMMAP
8692 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8693 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8694 +#endif
8695 +
8696 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8697 }
8698 }
8699 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8700 index ae3d59f..f65f075 100644
8701 --- a/arch/score/include/asm/cache.h
8702 +++ b/arch/score/include/asm/cache.h
8703 @@ -1,7 +1,9 @@
8704 #ifndef _ASM_SCORE_CACHE_H
8705 #define _ASM_SCORE_CACHE_H
8706
8707 +#include <linux/const.h>
8708 +
8709 #define L1_CACHE_SHIFT 4
8710 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8711 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8712
8713 #endif /* _ASM_SCORE_CACHE_H */
8714 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8715 index f9f3cd5..58ff438 100644
8716 --- a/arch/score/include/asm/exec.h
8717 +++ b/arch/score/include/asm/exec.h
8718 @@ -1,6 +1,6 @@
8719 #ifndef _ASM_SCORE_EXEC_H
8720 #define _ASM_SCORE_EXEC_H
8721
8722 -extern unsigned long arch_align_stack(unsigned long sp);
8723 +#define arch_align_stack(x) (x)
8724
8725 #endif /* _ASM_SCORE_EXEC_H */
8726 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8727 index f4c6d02..e9355c3 100644
8728 --- a/arch/score/kernel/process.c
8729 +++ b/arch/score/kernel/process.c
8730 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8731
8732 return task_pt_regs(task)->cp0_epc;
8733 }
8734 -
8735 -unsigned long arch_align_stack(unsigned long sp)
8736 -{
8737 - return sp;
8738 -}
8739 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8740 index ef9e555..331bd29 100644
8741 --- a/arch/sh/include/asm/cache.h
8742 +++ b/arch/sh/include/asm/cache.h
8743 @@ -9,10 +9,11 @@
8744 #define __ASM_SH_CACHE_H
8745 #ifdef __KERNEL__
8746
8747 +#include <linux/const.h>
8748 #include <linux/init.h>
8749 #include <cpu/cache.h>
8750
8751 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8752 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8753
8754 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8755
8756 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8757 index 6777177..cb5e44f 100644
8758 --- a/arch/sh/mm/mmap.c
8759 +++ b/arch/sh/mm/mmap.c
8760 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8761 struct mm_struct *mm = current->mm;
8762 struct vm_area_struct *vma;
8763 int do_colour_align;
8764 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8765 struct vm_unmapped_area_info info;
8766
8767 if (flags & MAP_FIXED) {
8768 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8769 if (filp || (flags & MAP_SHARED))
8770 do_colour_align = 1;
8771
8772 +#ifdef CONFIG_PAX_RANDMMAP
8773 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8774 +#endif
8775 +
8776 if (addr) {
8777 if (do_colour_align)
8778 addr = COLOUR_ALIGN(addr, pgoff);
8779 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8780 addr = PAGE_ALIGN(addr);
8781
8782 vma = find_vma(mm, addr);
8783 - if (TASK_SIZE - len >= addr &&
8784 - (!vma || addr + len <= vma->vm_start))
8785 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8786 return addr;
8787 }
8788
8789 info.flags = 0;
8790 info.length = len;
8791 - info.low_limit = TASK_UNMAPPED_BASE;
8792 + info.low_limit = mm->mmap_base;
8793 info.high_limit = TASK_SIZE;
8794 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8795 info.align_offset = pgoff << PAGE_SHIFT;
8796 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8797 struct mm_struct *mm = current->mm;
8798 unsigned long addr = addr0;
8799 int do_colour_align;
8800 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8801 struct vm_unmapped_area_info info;
8802
8803 if (flags & MAP_FIXED) {
8804 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8805 if (filp || (flags & MAP_SHARED))
8806 do_colour_align = 1;
8807
8808 +#ifdef CONFIG_PAX_RANDMMAP
8809 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8810 +#endif
8811 +
8812 /* requesting a specific address */
8813 if (addr) {
8814 if (do_colour_align)
8815 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8816 addr = PAGE_ALIGN(addr);
8817
8818 vma = find_vma(mm, addr);
8819 - if (TASK_SIZE - len >= addr &&
8820 - (!vma || addr + len <= vma->vm_start))
8821 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8822 return addr;
8823 }
8824
8825 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8826 VM_BUG_ON(addr != -ENOMEM);
8827 info.flags = 0;
8828 info.low_limit = TASK_UNMAPPED_BASE;
8829 +
8830 +#ifdef CONFIG_PAX_RANDMMAP
8831 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8832 + info.low_limit += mm->delta_mmap;
8833 +#endif
8834 +
8835 info.high_limit = TASK_SIZE;
8836 addr = vm_unmapped_area(&info);
8837 }
8838 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8839 index be56a24..443328f 100644
8840 --- a/arch/sparc/include/asm/atomic_64.h
8841 +++ b/arch/sparc/include/asm/atomic_64.h
8842 @@ -14,18 +14,40 @@
8843 #define ATOMIC64_INIT(i) { (i) }
8844
8845 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8846 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8847 +{
8848 + return v->counter;
8849 +}
8850 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8851 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8852 +{
8853 + return v->counter;
8854 +}
8855
8856 #define atomic_set(v, i) (((v)->counter) = i)
8857 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8858 +{
8859 + v->counter = i;
8860 +}
8861 #define atomic64_set(v, i) (((v)->counter) = i)
8862 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8863 +{
8864 + v->counter = i;
8865 +}
8866
8867 extern void atomic_add(int, atomic_t *);
8868 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8869 extern void atomic64_add(long, atomic64_t *);
8870 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8871 extern void atomic_sub(int, atomic_t *);
8872 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8873 extern void atomic64_sub(long, atomic64_t *);
8874 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8875
8876 extern int atomic_add_ret(int, atomic_t *);
8877 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8878 extern long atomic64_add_ret(long, atomic64_t *);
8879 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8880 extern int atomic_sub_ret(int, atomic_t *);
8881 extern long atomic64_sub_ret(long, atomic64_t *);
8882
8883 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8884 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8885
8886 #define atomic_inc_return(v) atomic_add_ret(1, v)
8887 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8888 +{
8889 + return atomic_add_ret_unchecked(1, v);
8890 +}
8891 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8892 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8893 +{
8894 + return atomic64_add_ret_unchecked(1, v);
8895 +}
8896
8897 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8898 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8899
8900 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8901 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8902 +{
8903 + return atomic_add_ret_unchecked(i, v);
8904 +}
8905 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8906 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8907 +{
8908 + return atomic64_add_ret_unchecked(i, v);
8909 +}
8910
8911 /*
8912 * atomic_inc_and_test - increment and test
8913 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8914 * other cases.
8915 */
8916 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8917 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8918 +{
8919 + return atomic_inc_return_unchecked(v) == 0;
8920 +}
8921 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8922
8923 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8924 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8925 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8926
8927 #define atomic_inc(v) atomic_add(1, v)
8928 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8929 +{
8930 + atomic_add_unchecked(1, v);
8931 +}
8932 #define atomic64_inc(v) atomic64_add(1, v)
8933 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8934 +{
8935 + atomic64_add_unchecked(1, v);
8936 +}
8937
8938 #define atomic_dec(v) atomic_sub(1, v)
8939 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8940 +{
8941 + atomic_sub_unchecked(1, v);
8942 +}
8943 #define atomic64_dec(v) atomic64_sub(1, v)
8944 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8945 +{
8946 + atomic64_sub_unchecked(1, v);
8947 +}
8948
8949 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8950 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8951
8952 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8953 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8954 +{
8955 + return cmpxchg(&v->counter, old, new);
8956 +}
8957 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8958 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8959 +{
8960 + return xchg(&v->counter, new);
8961 +}
8962
8963 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8964 {
8965 - int c, old;
8966 + int c, old, new;
8967 c = atomic_read(v);
8968 for (;;) {
8969 - if (unlikely(c == (u)))
8970 + if (unlikely(c == u))
8971 break;
8972 - old = atomic_cmpxchg((v), c, c + (a));
8973 +
8974 + asm volatile("addcc %2, %0, %0\n"
8975 +
8976 +#ifdef CONFIG_PAX_REFCOUNT
8977 + "tvs %%icc, 6\n"
8978 +#endif
8979 +
8980 + : "=r" (new)
8981 + : "0" (c), "ir" (a)
8982 + : "cc");
8983 +
8984 + old = atomic_cmpxchg(v, c, new);
8985 if (likely(old == c))
8986 break;
8987 c = old;
8988 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8989 #define atomic64_cmpxchg(v, o, n) \
8990 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8991 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8992 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8993 +{
8994 + return xchg(&v->counter, new);
8995 +}
8996
8997 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8998 {
8999 - long c, old;
9000 + long c, old, new;
9001 c = atomic64_read(v);
9002 for (;;) {
9003 - if (unlikely(c == (u)))
9004 + if (unlikely(c == u))
9005 break;
9006 - old = atomic64_cmpxchg((v), c, c + (a));
9007 +
9008 + asm volatile("addcc %2, %0, %0\n"
9009 +
9010 +#ifdef CONFIG_PAX_REFCOUNT
9011 + "tvs %%xcc, 6\n"
9012 +#endif
9013 +
9014 + : "=r" (new)
9015 + : "0" (c), "ir" (a)
9016 + : "cc");
9017 +
9018 + old = atomic64_cmpxchg(v, c, new);
9019 if (likely(old == c))
9020 break;
9021 c = old;
9022 }
9023 - return c != (u);
9024 + return c != u;
9025 }
9026
9027 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9028 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9029 index 5bb6991..5c2132e 100644
9030 --- a/arch/sparc/include/asm/cache.h
9031 +++ b/arch/sparc/include/asm/cache.h
9032 @@ -7,10 +7,12 @@
9033 #ifndef _SPARC_CACHE_H
9034 #define _SPARC_CACHE_H
9035
9036 +#include <linux/const.h>
9037 +
9038 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9039
9040 #define L1_CACHE_SHIFT 5
9041 -#define L1_CACHE_BYTES 32
9042 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9043
9044 #ifdef CONFIG_SPARC32
9045 #define SMP_CACHE_BYTES_SHIFT 5
9046 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9047 index a24e41f..47677ff 100644
9048 --- a/arch/sparc/include/asm/elf_32.h
9049 +++ b/arch/sparc/include/asm/elf_32.h
9050 @@ -114,6 +114,13 @@ typedef struct {
9051
9052 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9053
9054 +#ifdef CONFIG_PAX_ASLR
9055 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9056 +
9057 +#define PAX_DELTA_MMAP_LEN 16
9058 +#define PAX_DELTA_STACK_LEN 16
9059 +#endif
9060 +
9061 /* This yields a mask that user programs can use to figure out what
9062 instruction set this cpu supports. This can NOT be done in userspace
9063 on Sparc. */
9064 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9065 index 370ca1e..d4f4a98 100644
9066 --- a/arch/sparc/include/asm/elf_64.h
9067 +++ b/arch/sparc/include/asm/elf_64.h
9068 @@ -189,6 +189,13 @@ typedef struct {
9069 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9070 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9071
9072 +#ifdef CONFIG_PAX_ASLR
9073 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9074 +
9075 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9076 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9077 +#endif
9078 +
9079 extern unsigned long sparc64_elf_hwcap;
9080 #define ELF_HWCAP sparc64_elf_hwcap
9081
9082 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9083 index 9b1c36d..209298b 100644
9084 --- a/arch/sparc/include/asm/pgalloc_32.h
9085 +++ b/arch/sparc/include/asm/pgalloc_32.h
9086 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9087 }
9088
9089 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9090 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9091
9092 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9093 unsigned long address)
9094 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9095 index bcfe063..b333142 100644
9096 --- a/arch/sparc/include/asm/pgalloc_64.h
9097 +++ b/arch/sparc/include/asm/pgalloc_64.h
9098 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9099 }
9100
9101 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9102 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9103
9104 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9105 {
9106 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9107 index 502f632..da1917f 100644
9108 --- a/arch/sparc/include/asm/pgtable_32.h
9109 +++ b/arch/sparc/include/asm/pgtable_32.h
9110 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9111 #define PAGE_SHARED SRMMU_PAGE_SHARED
9112 #define PAGE_COPY SRMMU_PAGE_COPY
9113 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9114 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9115 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9116 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9117 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9118
9119 /* Top-level page directory - dummy used by init-mm.
9120 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9121
9122 /* xwr */
9123 #define __P000 PAGE_NONE
9124 -#define __P001 PAGE_READONLY
9125 -#define __P010 PAGE_COPY
9126 -#define __P011 PAGE_COPY
9127 +#define __P001 PAGE_READONLY_NOEXEC
9128 +#define __P010 PAGE_COPY_NOEXEC
9129 +#define __P011 PAGE_COPY_NOEXEC
9130 #define __P100 PAGE_READONLY
9131 #define __P101 PAGE_READONLY
9132 #define __P110 PAGE_COPY
9133 #define __P111 PAGE_COPY
9134
9135 #define __S000 PAGE_NONE
9136 -#define __S001 PAGE_READONLY
9137 -#define __S010 PAGE_SHARED
9138 -#define __S011 PAGE_SHARED
9139 +#define __S001 PAGE_READONLY_NOEXEC
9140 +#define __S010 PAGE_SHARED_NOEXEC
9141 +#define __S011 PAGE_SHARED_NOEXEC
9142 #define __S100 PAGE_READONLY
9143 #define __S101 PAGE_READONLY
9144 #define __S110 PAGE_SHARED
9145 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9146 index 79da178..c2eede8 100644
9147 --- a/arch/sparc/include/asm/pgtsrmmu.h
9148 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9149 @@ -115,6 +115,11 @@
9150 SRMMU_EXEC | SRMMU_REF)
9151 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9152 SRMMU_EXEC | SRMMU_REF)
9153 +
9154 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9155 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9156 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9157 +
9158 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9159 SRMMU_DIRTY | SRMMU_REF)
9160
9161 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9162 index 9689176..63c18ea 100644
9163 --- a/arch/sparc/include/asm/spinlock_64.h
9164 +++ b/arch/sparc/include/asm/spinlock_64.h
9165 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9166
9167 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9168
9169 -static void inline arch_read_lock(arch_rwlock_t *lock)
9170 +static inline void arch_read_lock(arch_rwlock_t *lock)
9171 {
9172 unsigned long tmp1, tmp2;
9173
9174 __asm__ __volatile__ (
9175 "1: ldsw [%2], %0\n"
9176 " brlz,pn %0, 2f\n"
9177 -"4: add %0, 1, %1\n"
9178 +"4: addcc %0, 1, %1\n"
9179 +
9180 +#ifdef CONFIG_PAX_REFCOUNT
9181 +" tvs %%icc, 6\n"
9182 +#endif
9183 +
9184 " cas [%2], %0, %1\n"
9185 " cmp %0, %1\n"
9186 " bne,pn %%icc, 1b\n"
9187 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9188 " .previous"
9189 : "=&r" (tmp1), "=&r" (tmp2)
9190 : "r" (lock)
9191 - : "memory");
9192 + : "memory", "cc");
9193 }
9194
9195 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9196 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9197 {
9198 int tmp1, tmp2;
9199
9200 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9201 "1: ldsw [%2], %0\n"
9202 " brlz,a,pn %0, 2f\n"
9203 " mov 0, %0\n"
9204 -" add %0, 1, %1\n"
9205 +" addcc %0, 1, %1\n"
9206 +
9207 +#ifdef CONFIG_PAX_REFCOUNT
9208 +" tvs %%icc, 6\n"
9209 +#endif
9210 +
9211 " cas [%2], %0, %1\n"
9212 " cmp %0, %1\n"
9213 " bne,pn %%icc, 1b\n"
9214 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9215 return tmp1;
9216 }
9217
9218 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9219 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9220 {
9221 unsigned long tmp1, tmp2;
9222
9223 __asm__ __volatile__(
9224 "1: lduw [%2], %0\n"
9225 -" sub %0, 1, %1\n"
9226 +" subcc %0, 1, %1\n"
9227 +
9228 +#ifdef CONFIG_PAX_REFCOUNT
9229 +" tvs %%icc, 6\n"
9230 +#endif
9231 +
9232 " cas [%2], %0, %1\n"
9233 " cmp %0, %1\n"
9234 " bne,pn %%xcc, 1b\n"
9235 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9236 : "memory");
9237 }
9238
9239 -static void inline arch_write_lock(arch_rwlock_t *lock)
9240 +static inline void arch_write_lock(arch_rwlock_t *lock)
9241 {
9242 unsigned long mask, tmp1, tmp2;
9243
9244 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9245 : "memory");
9246 }
9247
9248 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9249 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9250 {
9251 __asm__ __volatile__(
9252 " stw %%g0, [%0]"
9253 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9254 : "memory");
9255 }
9256
9257 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9258 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9259 {
9260 unsigned long mask, tmp1, tmp2, result;
9261
9262 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9263 index dd38075..e7cac83 100644
9264 --- a/arch/sparc/include/asm/thread_info_32.h
9265 +++ b/arch/sparc/include/asm/thread_info_32.h
9266 @@ -49,6 +49,8 @@ struct thread_info {
9267 unsigned long w_saved;
9268
9269 struct restart_block restart_block;
9270 +
9271 + unsigned long lowest_stack;
9272 };
9273
9274 /*
9275 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9276 index d5e5042..9bfee76 100644
9277 --- a/arch/sparc/include/asm/thread_info_64.h
9278 +++ b/arch/sparc/include/asm/thread_info_64.h
9279 @@ -63,6 +63,8 @@ struct thread_info {
9280 struct pt_regs *kern_una_regs;
9281 unsigned int kern_una_insn;
9282
9283 + unsigned long lowest_stack;
9284 +
9285 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9286 };
9287
9288 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9289 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9290 /* flag bit 6 is available */
9291 #define TIF_32BIT 7 /* 32-bit binary */
9292 -/* flag bit 8 is available */
9293 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9294 #define TIF_SECCOMP 9 /* secure computing */
9295 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9296 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9297 +
9298 /* NOTE: Thread flags >= 12 should be ones we have no interest
9299 * in using in assembly, else we can't use the mask as
9300 * an immediate value in instructions such as andcc.
9301 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9302 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9303 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9304 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9305 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9306
9307 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9308 _TIF_DO_NOTIFY_RESUME_MASK | \
9309 _TIF_NEED_RESCHED)
9310 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9311
9312 +#define _TIF_WORK_SYSCALL \
9313 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9314 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9315 +
9316 +
9317 /*
9318 * Thread-synchronous status.
9319 *
9320 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9321 index 0167d26..767bb0c 100644
9322 --- a/arch/sparc/include/asm/uaccess.h
9323 +++ b/arch/sparc/include/asm/uaccess.h
9324 @@ -1,5 +1,6 @@
9325 #ifndef ___ASM_SPARC_UACCESS_H
9326 #define ___ASM_SPARC_UACCESS_H
9327 +
9328 #if defined(__sparc__) && defined(__arch64__)
9329 #include <asm/uaccess_64.h>
9330 #else
9331 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9332 index 53a28dd..50c38c3 100644
9333 --- a/arch/sparc/include/asm/uaccess_32.h
9334 +++ b/arch/sparc/include/asm/uaccess_32.h
9335 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9336
9337 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9338 {
9339 - if (n && __access_ok((unsigned long) to, n))
9340 + if ((long)n < 0)
9341 + return n;
9342 +
9343 + if (n && __access_ok((unsigned long) to, n)) {
9344 + if (!__builtin_constant_p(n))
9345 + check_object_size(from, n, true);
9346 return __copy_user(to, (__force void __user *) from, n);
9347 - else
9348 + } else
9349 return n;
9350 }
9351
9352 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9353 {
9354 + if ((long)n < 0)
9355 + return n;
9356 +
9357 + if (!__builtin_constant_p(n))
9358 + check_object_size(from, n, true);
9359 +
9360 return __copy_user(to, (__force void __user *) from, n);
9361 }
9362
9363 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9364 {
9365 - if (n && __access_ok((unsigned long) from, n))
9366 + if ((long)n < 0)
9367 + return n;
9368 +
9369 + if (n && __access_ok((unsigned long) from, n)) {
9370 + if (!__builtin_constant_p(n))
9371 + check_object_size(to, n, false);
9372 return __copy_user((__force void __user *) to, from, n);
9373 - else
9374 + } else
9375 return n;
9376 }
9377
9378 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9379 {
9380 + if ((long)n < 0)
9381 + return n;
9382 +
9383 return __copy_user((__force void __user *) to, from, n);
9384 }
9385
9386 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9387 index e562d3c..191f176 100644
9388 --- a/arch/sparc/include/asm/uaccess_64.h
9389 +++ b/arch/sparc/include/asm/uaccess_64.h
9390 @@ -10,6 +10,7 @@
9391 #include <linux/compiler.h>
9392 #include <linux/string.h>
9393 #include <linux/thread_info.h>
9394 +#include <linux/kernel.h>
9395 #include <asm/asi.h>
9396 #include <asm/spitfire.h>
9397 #include <asm-generic/uaccess-unaligned.h>
9398 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9399 static inline unsigned long __must_check
9400 copy_from_user(void *to, const void __user *from, unsigned long size)
9401 {
9402 - unsigned long ret = ___copy_from_user(to, from, size);
9403 + unsigned long ret;
9404
9405 + if ((long)size < 0 || size > INT_MAX)
9406 + return size;
9407 +
9408 + if (!__builtin_constant_p(size))
9409 + check_object_size(to, size, false);
9410 +
9411 + ret = ___copy_from_user(to, from, size);
9412 if (unlikely(ret))
9413 ret = copy_from_user_fixup(to, from, size);
9414
9415 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9416 static inline unsigned long __must_check
9417 copy_to_user(void __user *to, const void *from, unsigned long size)
9418 {
9419 - unsigned long ret = ___copy_to_user(to, from, size);
9420 + unsigned long ret;
9421
9422 + if ((long)size < 0 || size > INT_MAX)
9423 + return size;
9424 +
9425 + if (!__builtin_constant_p(size))
9426 + check_object_size(from, size, true);
9427 +
9428 + ret = ___copy_to_user(to, from, size);
9429 if (unlikely(ret))
9430 ret = copy_to_user_fixup(to, from, size);
9431 return ret;
9432 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9433 index d432fb2..6056af1 100644
9434 --- a/arch/sparc/kernel/Makefile
9435 +++ b/arch/sparc/kernel/Makefile
9436 @@ -3,7 +3,7 @@
9437 #
9438
9439 asflags-y := -ansi
9440 -ccflags-y := -Werror
9441 +#ccflags-y := -Werror
9442
9443 extra-y := head_$(BITS).o
9444
9445 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9446 index fdd819d..5af08c8 100644
9447 --- a/arch/sparc/kernel/process_32.c
9448 +++ b/arch/sparc/kernel/process_32.c
9449 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9450
9451 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9452 r->psr, r->pc, r->npc, r->y, print_tainted());
9453 - printk("PC: <%pS>\n", (void *) r->pc);
9454 + printk("PC: <%pA>\n", (void *) r->pc);
9455 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9456 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9457 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9458 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9459 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9460 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9461 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9462 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9463
9464 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9465 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9466 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9467 rw = (struct reg_window32 *) fp;
9468 pc = rw->ins[7];
9469 printk("[%08lx : ", pc);
9470 - printk("%pS ] ", (void *) pc);
9471 + printk("%pA ] ", (void *) pc);
9472 fp = rw->ins[6];
9473 } while (++count < 16);
9474 printk("\n");
9475 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9476 index baebab2..9cd13b1 100644
9477 --- a/arch/sparc/kernel/process_64.c
9478 +++ b/arch/sparc/kernel/process_64.c
9479 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9480 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9481 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9482 if (regs->tstate & TSTATE_PRIV)
9483 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9484 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9485 }
9486
9487 void show_regs(struct pt_regs *regs)
9488 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9489
9490 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9491 regs->tpc, regs->tnpc, regs->y, print_tainted());
9492 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9493 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9494 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9495 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9496 regs->u_regs[3]);
9497 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9498 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9499 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9500 regs->u_regs[15]);
9501 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9502 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9503 show_regwindow(regs);
9504 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9505 }
9506 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9507 ((tp && tp->task) ? tp->task->pid : -1));
9508
9509 if (gp->tstate & TSTATE_PRIV) {
9510 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9511 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9512 (void *) gp->tpc,
9513 (void *) gp->o7,
9514 (void *) gp->i7,
9515 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9516 index 79cc0d1..ec62734 100644
9517 --- a/arch/sparc/kernel/prom_common.c
9518 +++ b/arch/sparc/kernel/prom_common.c
9519 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9520
9521 unsigned int prom_early_allocated __initdata;
9522
9523 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9524 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9525 .nextprop = prom_common_nextprop,
9526 .getproplen = prom_getproplen,
9527 .getproperty = prom_getproperty,
9528 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9529 index 7ff45e4..a58f271 100644
9530 --- a/arch/sparc/kernel/ptrace_64.c
9531 +++ b/arch/sparc/kernel/ptrace_64.c
9532 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
9533 return ret;
9534 }
9535
9536 +#ifdef CONFIG_GRKERNSEC_SETXID
9537 +extern void gr_delayed_cred_worker(void);
9538 +#endif
9539 +
9540 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9541 {
9542 int ret = 0;
9543 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9544 /* do the secure computing check first */
9545 secure_computing_strict(regs->u_regs[UREG_G1]);
9546
9547 +#ifdef CONFIG_GRKERNSEC_SETXID
9548 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9549 + gr_delayed_cred_worker();
9550 +#endif
9551 +
9552 if (test_thread_flag(TIF_SYSCALL_TRACE))
9553 ret = tracehook_report_syscall_entry(regs);
9554
9555 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9556
9557 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9558 {
9559 +#ifdef CONFIG_GRKERNSEC_SETXID
9560 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9561 + gr_delayed_cred_worker();
9562 +#endif
9563 +
9564 audit_syscall_exit(regs);
9565
9566 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9567 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9568 index e142545..fd29654 100644
9569 --- a/arch/sparc/kernel/smp_64.c
9570 +++ b/arch/sparc/kernel/smp_64.c
9571 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9572 extern unsigned long xcall_flush_dcache_page_spitfire;
9573
9574 #ifdef CONFIG_DEBUG_DCFLUSH
9575 -extern atomic_t dcpage_flushes;
9576 -extern atomic_t dcpage_flushes_xcall;
9577 +extern atomic_unchecked_t dcpage_flushes;
9578 +extern atomic_unchecked_t dcpage_flushes_xcall;
9579 #endif
9580
9581 static inline void __local_flush_dcache_page(struct page *page)
9582 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9583 return;
9584
9585 #ifdef CONFIG_DEBUG_DCFLUSH
9586 - atomic_inc(&dcpage_flushes);
9587 + atomic_inc_unchecked(&dcpage_flushes);
9588 #endif
9589
9590 this_cpu = get_cpu();
9591 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9592 xcall_deliver(data0, __pa(pg_addr),
9593 (u64) pg_addr, cpumask_of(cpu));
9594 #ifdef CONFIG_DEBUG_DCFLUSH
9595 - atomic_inc(&dcpage_flushes_xcall);
9596 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9597 #endif
9598 }
9599 }
9600 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9601 preempt_disable();
9602
9603 #ifdef CONFIG_DEBUG_DCFLUSH
9604 - atomic_inc(&dcpage_flushes);
9605 + atomic_inc_unchecked(&dcpage_flushes);
9606 #endif
9607 data0 = 0;
9608 pg_addr = page_address(page);
9609 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9610 xcall_deliver(data0, __pa(pg_addr),
9611 (u64) pg_addr, cpu_online_mask);
9612 #ifdef CONFIG_DEBUG_DCFLUSH
9613 - atomic_inc(&dcpage_flushes_xcall);
9614 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9615 #endif
9616 }
9617 __local_flush_dcache_page(page);
9618 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9619 index 3a8d184..49498a8 100644
9620 --- a/arch/sparc/kernel/sys_sparc_32.c
9621 +++ b/arch/sparc/kernel/sys_sparc_32.c
9622 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9623 if (len > TASK_SIZE - PAGE_SIZE)
9624 return -ENOMEM;
9625 if (!addr)
9626 - addr = TASK_UNMAPPED_BASE;
9627 + addr = current->mm->mmap_base;
9628
9629 info.flags = 0;
9630 info.length = len;
9631 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9632 index 51561b8..8256764 100644
9633 --- a/arch/sparc/kernel/sys_sparc_64.c
9634 +++ b/arch/sparc/kernel/sys_sparc_64.c
9635 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9636 struct vm_area_struct * vma;
9637 unsigned long task_size = TASK_SIZE;
9638 int do_color_align;
9639 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9640 struct vm_unmapped_area_info info;
9641
9642 if (flags & MAP_FIXED) {
9643 /* We do not accept a shared mapping if it would violate
9644 * cache aliasing constraints.
9645 */
9646 - if ((flags & MAP_SHARED) &&
9647 + if ((filp || (flags & MAP_SHARED)) &&
9648 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9649 return -EINVAL;
9650 return addr;
9651 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9652 if (filp || (flags & MAP_SHARED))
9653 do_color_align = 1;
9654
9655 +#ifdef CONFIG_PAX_RANDMMAP
9656 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9657 +#endif
9658 +
9659 if (addr) {
9660 if (do_color_align)
9661 addr = COLOR_ALIGN(addr, pgoff);
9662 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9663 addr = PAGE_ALIGN(addr);
9664
9665 vma = find_vma(mm, addr);
9666 - if (task_size - len >= addr &&
9667 - (!vma || addr + len <= vma->vm_start))
9668 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9669 return addr;
9670 }
9671
9672 info.flags = 0;
9673 info.length = len;
9674 - info.low_limit = TASK_UNMAPPED_BASE;
9675 + info.low_limit = mm->mmap_base;
9676 info.high_limit = min(task_size, VA_EXCLUDE_START);
9677 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9678 info.align_offset = pgoff << PAGE_SHIFT;
9679 + info.threadstack_offset = offset;
9680 addr = vm_unmapped_area(&info);
9681
9682 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9683 VM_BUG_ON(addr != -ENOMEM);
9684 info.low_limit = VA_EXCLUDE_END;
9685 +
9686 +#ifdef CONFIG_PAX_RANDMMAP
9687 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9688 + info.low_limit += mm->delta_mmap;
9689 +#endif
9690 +
9691 info.high_limit = task_size;
9692 addr = vm_unmapped_area(&info);
9693 }
9694 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9695 unsigned long task_size = STACK_TOP32;
9696 unsigned long addr = addr0;
9697 int do_color_align;
9698 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9699 struct vm_unmapped_area_info info;
9700
9701 /* This should only ever run for 32-bit processes. */
9702 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9703 /* We do not accept a shared mapping if it would violate
9704 * cache aliasing constraints.
9705 */
9706 - if ((flags & MAP_SHARED) &&
9707 + if ((filp || (flags & MAP_SHARED)) &&
9708 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9709 return -EINVAL;
9710 return addr;
9711 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9712 if (filp || (flags & MAP_SHARED))
9713 do_color_align = 1;
9714
9715 +#ifdef CONFIG_PAX_RANDMMAP
9716 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9717 +#endif
9718 +
9719 /* requesting a specific address */
9720 if (addr) {
9721 if (do_color_align)
9722 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9723 addr = PAGE_ALIGN(addr);
9724
9725 vma = find_vma(mm, addr);
9726 - if (task_size - len >= addr &&
9727 - (!vma || addr + len <= vma->vm_start))
9728 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9729 return addr;
9730 }
9731
9732 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9733 info.high_limit = mm->mmap_base;
9734 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9735 info.align_offset = pgoff << PAGE_SHIFT;
9736 + info.threadstack_offset = offset;
9737 addr = vm_unmapped_area(&info);
9738
9739 /*
9740 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9741 VM_BUG_ON(addr != -ENOMEM);
9742 info.flags = 0;
9743 info.low_limit = TASK_UNMAPPED_BASE;
9744 +
9745 +#ifdef CONFIG_PAX_RANDMMAP
9746 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9747 + info.low_limit += mm->delta_mmap;
9748 +#endif
9749 +
9750 info.high_limit = STACK_TOP32;
9751 addr = vm_unmapped_area(&info);
9752 }
9753 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9754 EXPORT_SYMBOL(get_fb_unmapped_area);
9755
9756 /* Essentially the same as PowerPC. */
9757 -static unsigned long mmap_rnd(void)
9758 +static unsigned long mmap_rnd(struct mm_struct *mm)
9759 {
9760 unsigned long rnd = 0UL;
9761
9762 +#ifdef CONFIG_PAX_RANDMMAP
9763 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9764 +#endif
9765 +
9766 if (current->flags & PF_RANDOMIZE) {
9767 unsigned long val = get_random_int();
9768 if (test_thread_flag(TIF_32BIT))
9769 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9770
9771 void arch_pick_mmap_layout(struct mm_struct *mm)
9772 {
9773 - unsigned long random_factor = mmap_rnd();
9774 + unsigned long random_factor = mmap_rnd(mm);
9775 unsigned long gap;
9776
9777 /*
9778 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9779 gap == RLIM_INFINITY ||
9780 sysctl_legacy_va_layout) {
9781 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9782 +
9783 +#ifdef CONFIG_PAX_RANDMMAP
9784 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9785 + mm->mmap_base += mm->delta_mmap;
9786 +#endif
9787 +
9788 mm->get_unmapped_area = arch_get_unmapped_area;
9789 } else {
9790 /* We know it's 32-bit */
9791 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9792 gap = (task_size / 6 * 5);
9793
9794 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9795 +
9796 +#ifdef CONFIG_PAX_RANDMMAP
9797 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9798 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9799 +#endif
9800 +
9801 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9802 }
9803 }
9804 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9805 index 73ec8a7..4611979 100644
9806 --- a/arch/sparc/kernel/syscalls.S
9807 +++ b/arch/sparc/kernel/syscalls.S
9808 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9809 #endif
9810 .align 32
9811 1: ldx [%g6 + TI_FLAGS], %l5
9812 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9813 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9814 be,pt %icc, rtrap
9815 nop
9816 call syscall_trace_leave
9817 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9818
9819 srl %i3, 0, %o3 ! IEU0
9820 srl %i2, 0, %o2 ! IEU0 Group
9821 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9822 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9823 bne,pn %icc, linux_syscall_trace32 ! CTI
9824 mov %i0, %l5 ! IEU1
9825 5: call %l7 ! CTI Group brk forced
9826 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9827
9828 mov %i3, %o3 ! IEU1
9829 mov %i4, %o4 ! IEU0 Group
9830 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9831 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9832 bne,pn %icc, linux_syscall_trace ! CTI Group
9833 mov %i0, %l5 ! IEU0
9834 2: call %l7 ! CTI Group brk forced
9835 @@ -223,7 +223,7 @@ ret_sys_call:
9836
9837 cmp %o0, -ERESTART_RESTARTBLOCK
9838 bgeu,pn %xcc, 1f
9839 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9840 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9841 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9842
9843 2:
9844 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9845 index 6629829..036032d 100644
9846 --- a/arch/sparc/kernel/traps_32.c
9847 +++ b/arch/sparc/kernel/traps_32.c
9848 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9849 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9850 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9851
9852 +extern void gr_handle_kernel_exploit(void);
9853 +
9854 void die_if_kernel(char *str, struct pt_regs *regs)
9855 {
9856 static int die_counter;
9857 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9858 count++ < 30 &&
9859 (((unsigned long) rw) >= PAGE_OFFSET) &&
9860 !(((unsigned long) rw) & 0x7)) {
9861 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9862 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9863 (void *) rw->ins[7]);
9864 rw = (struct reg_window32 *)rw->ins[6];
9865 }
9866 }
9867 printk("Instruction DUMP:");
9868 instruction_dump ((unsigned long *) regs->pc);
9869 - if(regs->psr & PSR_PS)
9870 + if(regs->psr & PSR_PS) {
9871 + gr_handle_kernel_exploit();
9872 do_exit(SIGKILL);
9873 + }
9874 do_exit(SIGSEGV);
9875 }
9876
9877 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9878 index b3f833a..f485f80 100644
9879 --- a/arch/sparc/kernel/traps_64.c
9880 +++ b/arch/sparc/kernel/traps_64.c
9881 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9882 i + 1,
9883 p->trapstack[i].tstate, p->trapstack[i].tpc,
9884 p->trapstack[i].tnpc, p->trapstack[i].tt);
9885 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9886 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9887 }
9888 }
9889
9890 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9891
9892 lvl -= 0x100;
9893 if (regs->tstate & TSTATE_PRIV) {
9894 +
9895 +#ifdef CONFIG_PAX_REFCOUNT
9896 + if (lvl == 6)
9897 + pax_report_refcount_overflow(regs);
9898 +#endif
9899 +
9900 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9901 die_if_kernel(buffer, regs);
9902 }
9903 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9904 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9905 {
9906 char buffer[32];
9907 -
9908 +
9909 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9910 0, lvl, SIGTRAP) == NOTIFY_STOP)
9911 return;
9912
9913 +#ifdef CONFIG_PAX_REFCOUNT
9914 + if (lvl == 6)
9915 + pax_report_refcount_overflow(regs);
9916 +#endif
9917 +
9918 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9919
9920 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9921 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9922 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9923 printk("%s" "ERROR(%d): ",
9924 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9925 - printk("TPC<%pS>\n", (void *) regs->tpc);
9926 + printk("TPC<%pA>\n", (void *) regs->tpc);
9927 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9928 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9929 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9930 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9931 smp_processor_id(),
9932 (type & 0x1) ? 'I' : 'D',
9933 regs->tpc);
9934 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9935 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9936 panic("Irrecoverable Cheetah+ parity error.");
9937 }
9938
9939 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9940 smp_processor_id(),
9941 (type & 0x1) ? 'I' : 'D',
9942 regs->tpc);
9943 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9944 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9945 }
9946
9947 struct sun4v_error_entry {
9948 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9949 /*0x38*/u64 reserved_5;
9950 };
9951
9952 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9953 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9954 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9955 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9956
9957 static const char *sun4v_err_type_to_str(u8 type)
9958 {
9959 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9960 }
9961
9962 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9963 - int cpu, const char *pfx, atomic_t *ocnt)
9964 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9965 {
9966 u64 *raw_ptr = (u64 *) ent;
9967 u32 attrs;
9968 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9969
9970 show_regs(regs);
9971
9972 - if ((cnt = atomic_read(ocnt)) != 0) {
9973 - atomic_set(ocnt, 0);
9974 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9975 + atomic_set_unchecked(ocnt, 0);
9976 wmb();
9977 printk("%s: Queue overflowed %d times.\n",
9978 pfx, cnt);
9979 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
9980 */
9981 void sun4v_resum_overflow(struct pt_regs *regs)
9982 {
9983 - atomic_inc(&sun4v_resum_oflow_cnt);
9984 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
9985 }
9986
9987 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
9988 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
9989 /* XXX Actually even this can make not that much sense. Perhaps
9990 * XXX we should just pull the plug and panic directly from here?
9991 */
9992 - atomic_inc(&sun4v_nonresum_oflow_cnt);
9993 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
9994 }
9995
9996 unsigned long sun4v_err_itlb_vaddr;
9997 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
9998
9999 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10000 regs->tpc, tl);
10001 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10002 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10003 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10004 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10005 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10006 (void *) regs->u_regs[UREG_I7]);
10007 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10008 "pte[%lx] error[%lx]\n",
10009 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10010
10011 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10012 regs->tpc, tl);
10013 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10014 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10015 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10016 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10017 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10018 (void *) regs->u_regs[UREG_I7]);
10019 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10020 "pte[%lx] error[%lx]\n",
10021 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10022 fp = (unsigned long)sf->fp + STACK_BIAS;
10023 }
10024
10025 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10026 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10027 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10028 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10029 int index = tsk->curr_ret_stack;
10030 if (tsk->ret_stack && index >= graph) {
10031 pc = tsk->ret_stack[index - graph].ret;
10032 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10033 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10034 graph++;
10035 }
10036 }
10037 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10038 return (struct reg_window *) (fp + STACK_BIAS);
10039 }
10040
10041 +extern void gr_handle_kernel_exploit(void);
10042 +
10043 void die_if_kernel(char *str, struct pt_regs *regs)
10044 {
10045 static int die_counter;
10046 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10047 while (rw &&
10048 count++ < 30 &&
10049 kstack_valid(tp, (unsigned long) rw)) {
10050 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10051 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10052 (void *) rw->ins[7]);
10053
10054 rw = kernel_stack_up(rw);
10055 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10056 }
10057 user_instruction_dump ((unsigned int __user *) regs->tpc);
10058 }
10059 - if (regs->tstate & TSTATE_PRIV)
10060 + if (regs->tstate & TSTATE_PRIV) {
10061 + gr_handle_kernel_exploit();
10062 do_exit(SIGKILL);
10063 + }
10064 do_exit(SIGSEGV);
10065 }
10066 EXPORT_SYMBOL(die_if_kernel);
10067 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10068 index 8201c25e..072a2a7 100644
10069 --- a/arch/sparc/kernel/unaligned_64.c
10070 +++ b/arch/sparc/kernel/unaligned_64.c
10071 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10072 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10073
10074 if (__ratelimit(&ratelimit)) {
10075 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10076 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10077 regs->tpc, (void *) regs->tpc);
10078 }
10079 }
10080 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10081 index dbe119b..089c7c1 100644
10082 --- a/arch/sparc/lib/Makefile
10083 +++ b/arch/sparc/lib/Makefile
10084 @@ -2,7 +2,7 @@
10085 #
10086
10087 asflags-y := -ansi -DST_DIV0=0x02
10088 -ccflags-y := -Werror
10089 +#ccflags-y := -Werror
10090
10091 lib-$(CONFIG_SPARC32) += ashrdi3.o
10092 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10093 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10094 index 85c233d..68500e0 100644
10095 --- a/arch/sparc/lib/atomic_64.S
10096 +++ b/arch/sparc/lib/atomic_64.S
10097 @@ -17,7 +17,12 @@
10098 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10099 BACKOFF_SETUP(%o2)
10100 1: lduw [%o1], %g1
10101 - add %g1, %o0, %g7
10102 + addcc %g1, %o0, %g7
10103 +
10104 +#ifdef CONFIG_PAX_REFCOUNT
10105 + tvs %icc, 6
10106 +#endif
10107 +
10108 cas [%o1], %g1, %g7
10109 cmp %g1, %g7
10110 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10111 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10112 2: BACKOFF_SPIN(%o2, %o3, 1b)
10113 ENDPROC(atomic_add)
10114
10115 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10116 + BACKOFF_SETUP(%o2)
10117 +1: lduw [%o1], %g1
10118 + add %g1, %o0, %g7
10119 + cas [%o1], %g1, %g7
10120 + cmp %g1, %g7
10121 + bne,pn %icc, 2f
10122 + nop
10123 + retl
10124 + nop
10125 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10126 +ENDPROC(atomic_add_unchecked)
10127 +
10128 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10129 BACKOFF_SETUP(%o2)
10130 1: lduw [%o1], %g1
10131 - sub %g1, %o0, %g7
10132 + subcc %g1, %o0, %g7
10133 +
10134 +#ifdef CONFIG_PAX_REFCOUNT
10135 + tvs %icc, 6
10136 +#endif
10137 +
10138 cas [%o1], %g1, %g7
10139 cmp %g1, %g7
10140 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10141 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10142 2: BACKOFF_SPIN(%o2, %o3, 1b)
10143 ENDPROC(atomic_sub)
10144
10145 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10146 + BACKOFF_SETUP(%o2)
10147 +1: lduw [%o1], %g1
10148 + sub %g1, %o0, %g7
10149 + cas [%o1], %g1, %g7
10150 + cmp %g1, %g7
10151 + bne,pn %icc, 2f
10152 + nop
10153 + retl
10154 + nop
10155 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10156 +ENDPROC(atomic_sub_unchecked)
10157 +
10158 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10159 BACKOFF_SETUP(%o2)
10160 1: lduw [%o1], %g1
10161 - add %g1, %o0, %g7
10162 + addcc %g1, %o0, %g7
10163 +
10164 +#ifdef CONFIG_PAX_REFCOUNT
10165 + tvs %icc, 6
10166 +#endif
10167 +
10168 cas [%o1], %g1, %g7
10169 cmp %g1, %g7
10170 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10171 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10172 2: BACKOFF_SPIN(%o2, %o3, 1b)
10173 ENDPROC(atomic_add_ret)
10174
10175 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10176 + BACKOFF_SETUP(%o2)
10177 +1: lduw [%o1], %g1
10178 + addcc %g1, %o0, %g7
10179 + cas [%o1], %g1, %g7
10180 + cmp %g1, %g7
10181 + bne,pn %icc, 2f
10182 + add %g7, %o0, %g7
10183 + sra %g7, 0, %o0
10184 + retl
10185 + nop
10186 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10187 +ENDPROC(atomic_add_ret_unchecked)
10188 +
10189 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10190 BACKOFF_SETUP(%o2)
10191 1: lduw [%o1], %g1
10192 - sub %g1, %o0, %g7
10193 + subcc %g1, %o0, %g7
10194 +
10195 +#ifdef CONFIG_PAX_REFCOUNT
10196 + tvs %icc, 6
10197 +#endif
10198 +
10199 cas [%o1], %g1, %g7
10200 cmp %g1, %g7
10201 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10202 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10203 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10204 BACKOFF_SETUP(%o2)
10205 1: ldx [%o1], %g1
10206 - add %g1, %o0, %g7
10207 + addcc %g1, %o0, %g7
10208 +
10209 +#ifdef CONFIG_PAX_REFCOUNT
10210 + tvs %xcc, 6
10211 +#endif
10212 +
10213 casx [%o1], %g1, %g7
10214 cmp %g1, %g7
10215 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10216 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10217 2: BACKOFF_SPIN(%o2, %o3, 1b)
10218 ENDPROC(atomic64_add)
10219
10220 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10221 + BACKOFF_SETUP(%o2)
10222 +1: ldx [%o1], %g1
10223 + addcc %g1, %o0, %g7
10224 + casx [%o1], %g1, %g7
10225 + cmp %g1, %g7
10226 + bne,pn %xcc, 2f
10227 + nop
10228 + retl
10229 + nop
10230 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10231 +ENDPROC(atomic64_add_unchecked)
10232 +
10233 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10234 BACKOFF_SETUP(%o2)
10235 1: ldx [%o1], %g1
10236 - sub %g1, %o0, %g7
10237 + subcc %g1, %o0, %g7
10238 +
10239 +#ifdef CONFIG_PAX_REFCOUNT
10240 + tvs %xcc, 6
10241 +#endif
10242 +
10243 casx [%o1], %g1, %g7
10244 cmp %g1, %g7
10245 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10246 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10247 2: BACKOFF_SPIN(%o2, %o3, 1b)
10248 ENDPROC(atomic64_sub)
10249
10250 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10251 + BACKOFF_SETUP(%o2)
10252 +1: ldx [%o1], %g1
10253 + subcc %g1, %o0, %g7
10254 + casx [%o1], %g1, %g7
10255 + cmp %g1, %g7
10256 + bne,pn %xcc, 2f
10257 + nop
10258 + retl
10259 + nop
10260 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10261 +ENDPROC(atomic64_sub_unchecked)
10262 +
10263 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10264 BACKOFF_SETUP(%o2)
10265 1: ldx [%o1], %g1
10266 - add %g1, %o0, %g7
10267 + addcc %g1, %o0, %g7
10268 +
10269 +#ifdef CONFIG_PAX_REFCOUNT
10270 + tvs %xcc, 6
10271 +#endif
10272 +
10273 casx [%o1], %g1, %g7
10274 cmp %g1, %g7
10275 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10276 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10277 2: BACKOFF_SPIN(%o2, %o3, 1b)
10278 ENDPROC(atomic64_add_ret)
10279
10280 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10281 + BACKOFF_SETUP(%o2)
10282 +1: ldx [%o1], %g1
10283 + addcc %g1, %o0, %g7
10284 + casx [%o1], %g1, %g7
10285 + cmp %g1, %g7
10286 + bne,pn %xcc, 2f
10287 + add %g7, %o0, %g7
10288 + mov %g7, %o0
10289 + retl
10290 + nop
10291 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10292 +ENDPROC(atomic64_add_ret_unchecked)
10293 +
10294 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10295 BACKOFF_SETUP(%o2)
10296 1: ldx [%o1], %g1
10297 - sub %g1, %o0, %g7
10298 + subcc %g1, %o0, %g7
10299 +
10300 +#ifdef CONFIG_PAX_REFCOUNT
10301 + tvs %xcc, 6
10302 +#endif
10303 +
10304 casx [%o1], %g1, %g7
10305 cmp %g1, %g7
10306 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10307 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10308 index 323335b..ed85ea2 100644
10309 --- a/arch/sparc/lib/ksyms.c
10310 +++ b/arch/sparc/lib/ksyms.c
10311 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10312
10313 /* Atomic counter implementation. */
10314 EXPORT_SYMBOL(atomic_add);
10315 +EXPORT_SYMBOL(atomic_add_unchecked);
10316 EXPORT_SYMBOL(atomic_add_ret);
10317 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10318 EXPORT_SYMBOL(atomic_sub);
10319 +EXPORT_SYMBOL(atomic_sub_unchecked);
10320 EXPORT_SYMBOL(atomic_sub_ret);
10321 EXPORT_SYMBOL(atomic64_add);
10322 +EXPORT_SYMBOL(atomic64_add_unchecked);
10323 EXPORT_SYMBOL(atomic64_add_ret);
10324 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10325 EXPORT_SYMBOL(atomic64_sub);
10326 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10327 EXPORT_SYMBOL(atomic64_sub_ret);
10328 EXPORT_SYMBOL(atomic64_dec_if_positive);
10329
10330 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10331 index 30c3ecc..736f015 100644
10332 --- a/arch/sparc/mm/Makefile
10333 +++ b/arch/sparc/mm/Makefile
10334 @@ -2,7 +2,7 @@
10335 #
10336
10337 asflags-y := -ansi
10338 -ccflags-y := -Werror
10339 +#ccflags-y := -Werror
10340
10341 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10342 obj-y += fault_$(BITS).o
10343 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10344 index e98bfda..ea8d221 100644
10345 --- a/arch/sparc/mm/fault_32.c
10346 +++ b/arch/sparc/mm/fault_32.c
10347 @@ -21,6 +21,9 @@
10348 #include <linux/perf_event.h>
10349 #include <linux/interrupt.h>
10350 #include <linux/kdebug.h>
10351 +#include <linux/slab.h>
10352 +#include <linux/pagemap.h>
10353 +#include <linux/compiler.h>
10354
10355 #include <asm/page.h>
10356 #include <asm/pgtable.h>
10357 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10358 return safe_compute_effective_address(regs, insn);
10359 }
10360
10361 +#ifdef CONFIG_PAX_PAGEEXEC
10362 +#ifdef CONFIG_PAX_DLRESOLVE
10363 +static void pax_emuplt_close(struct vm_area_struct *vma)
10364 +{
10365 + vma->vm_mm->call_dl_resolve = 0UL;
10366 +}
10367 +
10368 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10369 +{
10370 + unsigned int *kaddr;
10371 +
10372 + vmf->page = alloc_page(GFP_HIGHUSER);
10373 + if (!vmf->page)
10374 + return VM_FAULT_OOM;
10375 +
10376 + kaddr = kmap(vmf->page);
10377 + memset(kaddr, 0, PAGE_SIZE);
10378 + kaddr[0] = 0x9DE3BFA8U; /* save */
10379 + flush_dcache_page(vmf->page);
10380 + kunmap(vmf->page);
10381 + return VM_FAULT_MAJOR;
10382 +}
10383 +
10384 +static const struct vm_operations_struct pax_vm_ops = {
10385 + .close = pax_emuplt_close,
10386 + .fault = pax_emuplt_fault
10387 +};
10388 +
10389 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10390 +{
10391 + int ret;
10392 +
10393 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10394 + vma->vm_mm = current->mm;
10395 + vma->vm_start = addr;
10396 + vma->vm_end = addr + PAGE_SIZE;
10397 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10398 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10399 + vma->vm_ops = &pax_vm_ops;
10400 +
10401 + ret = insert_vm_struct(current->mm, vma);
10402 + if (ret)
10403 + return ret;
10404 +
10405 + ++current->mm->total_vm;
10406 + return 0;
10407 +}
10408 +#endif
10409 +
10410 +/*
10411 + * PaX: decide what to do with offenders (regs->pc = fault address)
10412 + *
10413 + * returns 1 when task should be killed
10414 + * 2 when patched PLT trampoline was detected
10415 + * 3 when unpatched PLT trampoline was detected
10416 + */
10417 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10418 +{
10419 +
10420 +#ifdef CONFIG_PAX_EMUPLT
10421 + int err;
10422 +
10423 + do { /* PaX: patched PLT emulation #1 */
10424 + unsigned int sethi1, sethi2, jmpl;
10425 +
10426 + err = get_user(sethi1, (unsigned int *)regs->pc);
10427 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10428 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10429 +
10430 + if (err)
10431 + break;
10432 +
10433 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10434 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10435 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10436 + {
10437 + unsigned int addr;
10438 +
10439 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10440 + addr = regs->u_regs[UREG_G1];
10441 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10442 + regs->pc = addr;
10443 + regs->npc = addr+4;
10444 + return 2;
10445 + }
10446 + } while (0);
10447 +
10448 + do { /* PaX: patched PLT emulation #2 */
10449 + unsigned int ba;
10450 +
10451 + err = get_user(ba, (unsigned int *)regs->pc);
10452 +
10453 + if (err)
10454 + break;
10455 +
10456 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10457 + unsigned int addr;
10458 +
10459 + if ((ba & 0xFFC00000U) == 0x30800000U)
10460 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10461 + else
10462 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10463 + regs->pc = addr;
10464 + regs->npc = addr+4;
10465 + return 2;
10466 + }
10467 + } while (0);
10468 +
10469 + do { /* PaX: patched PLT emulation #3 */
10470 + unsigned int sethi, bajmpl, nop;
10471 +
10472 + err = get_user(sethi, (unsigned int *)regs->pc);
10473 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10474 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10475 +
10476 + if (err)
10477 + break;
10478 +
10479 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10480 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10481 + nop == 0x01000000U)
10482 + {
10483 + unsigned int addr;
10484 +
10485 + addr = (sethi & 0x003FFFFFU) << 10;
10486 + regs->u_regs[UREG_G1] = addr;
10487 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10488 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10489 + else
10490 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10491 + regs->pc = addr;
10492 + regs->npc = addr+4;
10493 + return 2;
10494 + }
10495 + } while (0);
10496 +
10497 + do { /* PaX: unpatched PLT emulation step 1 */
10498 + unsigned int sethi, ba, nop;
10499 +
10500 + err = get_user(sethi, (unsigned int *)regs->pc);
10501 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10502 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10503 +
10504 + if (err)
10505 + break;
10506 +
10507 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10508 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10509 + nop == 0x01000000U)
10510 + {
10511 + unsigned int addr, save, call;
10512 +
10513 + if ((ba & 0xFFC00000U) == 0x30800000U)
10514 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10515 + else
10516 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10517 +
10518 + err = get_user(save, (unsigned int *)addr);
10519 + err |= get_user(call, (unsigned int *)(addr+4));
10520 + err |= get_user(nop, (unsigned int *)(addr+8));
10521 + if (err)
10522 + break;
10523 +
10524 +#ifdef CONFIG_PAX_DLRESOLVE
10525 + if (save == 0x9DE3BFA8U &&
10526 + (call & 0xC0000000U) == 0x40000000U &&
10527 + nop == 0x01000000U)
10528 + {
10529 + struct vm_area_struct *vma;
10530 + unsigned long call_dl_resolve;
10531 +
10532 + down_read(&current->mm->mmap_sem);
10533 + call_dl_resolve = current->mm->call_dl_resolve;
10534 + up_read(&current->mm->mmap_sem);
10535 + if (likely(call_dl_resolve))
10536 + goto emulate;
10537 +
10538 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10539 +
10540 + down_write(&current->mm->mmap_sem);
10541 + if (current->mm->call_dl_resolve) {
10542 + call_dl_resolve = current->mm->call_dl_resolve;
10543 + up_write(&current->mm->mmap_sem);
10544 + if (vma)
10545 + kmem_cache_free(vm_area_cachep, vma);
10546 + goto emulate;
10547 + }
10548 +
10549 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10550 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10551 + up_write(&current->mm->mmap_sem);
10552 + if (vma)
10553 + kmem_cache_free(vm_area_cachep, vma);
10554 + return 1;
10555 + }
10556 +
10557 + if (pax_insert_vma(vma, call_dl_resolve)) {
10558 + up_write(&current->mm->mmap_sem);
10559 + kmem_cache_free(vm_area_cachep, vma);
10560 + return 1;
10561 + }
10562 +
10563 + current->mm->call_dl_resolve = call_dl_resolve;
10564 + up_write(&current->mm->mmap_sem);
10565 +
10566 +emulate:
10567 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10568 + regs->pc = call_dl_resolve;
10569 + regs->npc = addr+4;
10570 + return 3;
10571 + }
10572 +#endif
10573 +
10574 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10575 + if ((save & 0xFFC00000U) == 0x05000000U &&
10576 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10577 + nop == 0x01000000U)
10578 + {
10579 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10580 + regs->u_regs[UREG_G2] = addr + 4;
10581 + addr = (save & 0x003FFFFFU) << 10;
10582 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10583 + regs->pc = addr;
10584 + regs->npc = addr+4;
10585 + return 3;
10586 + }
10587 + }
10588 + } while (0);
10589 +
10590 + do { /* PaX: unpatched PLT emulation step 2 */
10591 + unsigned int save, call, nop;
10592 +
10593 + err = get_user(save, (unsigned int *)(regs->pc-4));
10594 + err |= get_user(call, (unsigned int *)regs->pc);
10595 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10596 + if (err)
10597 + break;
10598 +
10599 + if (save == 0x9DE3BFA8U &&
10600 + (call & 0xC0000000U) == 0x40000000U &&
10601 + nop == 0x01000000U)
10602 + {
10603 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10604 +
10605 + regs->u_regs[UREG_RETPC] = regs->pc;
10606 + regs->pc = dl_resolve;
10607 + regs->npc = dl_resolve+4;
10608 + return 3;
10609 + }
10610 + } while (0);
10611 +#endif
10612 +
10613 + return 1;
10614 +}
10615 +
10616 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10617 +{
10618 + unsigned long i;
10619 +
10620 + printk(KERN_ERR "PAX: bytes at PC: ");
10621 + for (i = 0; i < 8; i++) {
10622 + unsigned int c;
10623 + if (get_user(c, (unsigned int *)pc+i))
10624 + printk(KERN_CONT "???????? ");
10625 + else
10626 + printk(KERN_CONT "%08x ", c);
10627 + }
10628 + printk("\n");
10629 +}
10630 +#endif
10631 +
10632 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10633 int text_fault)
10634 {
10635 @@ -230,6 +504,24 @@ good_area:
10636 if (!(vma->vm_flags & VM_WRITE))
10637 goto bad_area;
10638 } else {
10639 +
10640 +#ifdef CONFIG_PAX_PAGEEXEC
10641 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10642 + up_read(&mm->mmap_sem);
10643 + switch (pax_handle_fetch_fault(regs)) {
10644 +
10645 +#ifdef CONFIG_PAX_EMUPLT
10646 + case 2:
10647 + case 3:
10648 + return;
10649 +#endif
10650 +
10651 + }
10652 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10653 + do_group_exit(SIGKILL);
10654 + }
10655 +#endif
10656 +
10657 /* Allow reads even for write-only mappings */
10658 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10659 goto bad_area;
10660 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10661 index 5062ff3..e0b75f3 100644
10662 --- a/arch/sparc/mm/fault_64.c
10663 +++ b/arch/sparc/mm/fault_64.c
10664 @@ -21,6 +21,9 @@
10665 #include <linux/kprobes.h>
10666 #include <linux/kdebug.h>
10667 #include <linux/percpu.h>
10668 +#include <linux/slab.h>
10669 +#include <linux/pagemap.h>
10670 +#include <linux/compiler.h>
10671
10672 #include <asm/page.h>
10673 #include <asm/pgtable.h>
10674 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10675 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10676 regs->tpc);
10677 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10678 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10679 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10680 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10681 dump_stack();
10682 unhandled_fault(regs->tpc, current, regs);
10683 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10684 show_regs(regs);
10685 }
10686
10687 +#ifdef CONFIG_PAX_PAGEEXEC
10688 +#ifdef CONFIG_PAX_DLRESOLVE
10689 +static void pax_emuplt_close(struct vm_area_struct *vma)
10690 +{
10691 + vma->vm_mm->call_dl_resolve = 0UL;
10692 +}
10693 +
10694 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10695 +{
10696 + unsigned int *kaddr;
10697 +
10698 + vmf->page = alloc_page(GFP_HIGHUSER);
10699 + if (!vmf->page)
10700 + return VM_FAULT_OOM;
10701 +
10702 + kaddr = kmap(vmf->page);
10703 + memset(kaddr, 0, PAGE_SIZE);
10704 + kaddr[0] = 0x9DE3BFA8U; /* save */
10705 + flush_dcache_page(vmf->page);
10706 + kunmap(vmf->page);
10707 + return VM_FAULT_MAJOR;
10708 +}
10709 +
10710 +static const struct vm_operations_struct pax_vm_ops = {
10711 + .close = pax_emuplt_close,
10712 + .fault = pax_emuplt_fault
10713 +};
10714 +
10715 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10716 +{
10717 + int ret;
10718 +
10719 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10720 + vma->vm_mm = current->mm;
10721 + vma->vm_start = addr;
10722 + vma->vm_end = addr + PAGE_SIZE;
10723 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10724 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10725 + vma->vm_ops = &pax_vm_ops;
10726 +
10727 + ret = insert_vm_struct(current->mm, vma);
10728 + if (ret)
10729 + return ret;
10730 +
10731 + ++current->mm->total_vm;
10732 + return 0;
10733 +}
10734 +#endif
10735 +
10736 +/*
10737 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10738 + *
10739 + * returns 1 when task should be killed
10740 + * 2 when patched PLT trampoline was detected
10741 + * 3 when unpatched PLT trampoline was detected
10742 + */
10743 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10744 +{
10745 +
10746 +#ifdef CONFIG_PAX_EMUPLT
10747 + int err;
10748 +
10749 + do { /* PaX: patched PLT emulation #1 */
10750 + unsigned int sethi1, sethi2, jmpl;
10751 +
10752 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10753 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10754 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10755 +
10756 + if (err)
10757 + break;
10758 +
10759 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10760 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10761 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10762 + {
10763 + unsigned long addr;
10764 +
10765 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10766 + addr = regs->u_regs[UREG_G1];
10767 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10768 +
10769 + if (test_thread_flag(TIF_32BIT))
10770 + addr &= 0xFFFFFFFFUL;
10771 +
10772 + regs->tpc = addr;
10773 + regs->tnpc = addr+4;
10774 + return 2;
10775 + }
10776 + } while (0);
10777 +
10778 + do { /* PaX: patched PLT emulation #2 */
10779 + unsigned int ba;
10780 +
10781 + err = get_user(ba, (unsigned int *)regs->tpc);
10782 +
10783 + if (err)
10784 + break;
10785 +
10786 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10787 + unsigned long addr;
10788 +
10789 + if ((ba & 0xFFC00000U) == 0x30800000U)
10790 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10791 + else
10792 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10793 +
10794 + if (test_thread_flag(TIF_32BIT))
10795 + addr &= 0xFFFFFFFFUL;
10796 +
10797 + regs->tpc = addr;
10798 + regs->tnpc = addr+4;
10799 + return 2;
10800 + }
10801 + } while (0);
10802 +
10803 + do { /* PaX: patched PLT emulation #3 */
10804 + unsigned int sethi, bajmpl, nop;
10805 +
10806 + err = get_user(sethi, (unsigned int *)regs->tpc);
10807 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10808 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10809 +
10810 + if (err)
10811 + break;
10812 +
10813 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10814 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10815 + nop == 0x01000000U)
10816 + {
10817 + unsigned long addr;
10818 +
10819 + addr = (sethi & 0x003FFFFFU) << 10;
10820 + regs->u_regs[UREG_G1] = addr;
10821 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10822 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10823 + else
10824 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10825 +
10826 + if (test_thread_flag(TIF_32BIT))
10827 + addr &= 0xFFFFFFFFUL;
10828 +
10829 + regs->tpc = addr;
10830 + regs->tnpc = addr+4;
10831 + return 2;
10832 + }
10833 + } while (0);
10834 +
10835 + do { /* PaX: patched PLT emulation #4 */
10836 + unsigned int sethi, mov1, call, mov2;
10837 +
10838 + err = get_user(sethi, (unsigned int *)regs->tpc);
10839 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10840 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10841 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10842 +
10843 + if (err)
10844 + break;
10845 +
10846 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10847 + mov1 == 0x8210000FU &&
10848 + (call & 0xC0000000U) == 0x40000000U &&
10849 + mov2 == 0x9E100001U)
10850 + {
10851 + unsigned long addr;
10852 +
10853 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10854 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10855 +
10856 + if (test_thread_flag(TIF_32BIT))
10857 + addr &= 0xFFFFFFFFUL;
10858 +
10859 + regs->tpc = addr;
10860 + regs->tnpc = addr+4;
10861 + return 2;
10862 + }
10863 + } while (0);
10864 +
10865 + do { /* PaX: patched PLT emulation #5 */
10866 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10867 +
10868 + err = get_user(sethi, (unsigned int *)regs->tpc);
10869 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10870 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10871 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10872 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10873 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10874 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10875 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10876 +
10877 + if (err)
10878 + break;
10879 +
10880 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10881 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10882 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10883 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10884 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10885 + sllx == 0x83287020U &&
10886 + jmpl == 0x81C04005U &&
10887 + nop == 0x01000000U)
10888 + {
10889 + unsigned long addr;
10890 +
10891 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10892 + regs->u_regs[UREG_G1] <<= 32;
10893 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10894 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10895 + regs->tpc = addr;
10896 + regs->tnpc = addr+4;
10897 + return 2;
10898 + }
10899 + } while (0);
10900 +
10901 + do { /* PaX: patched PLT emulation #6 */
10902 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10903 +
10904 + err = get_user(sethi, (unsigned int *)regs->tpc);
10905 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10906 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10907 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10908 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10909 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10910 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10911 +
10912 + if (err)
10913 + break;
10914 +
10915 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10916 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10917 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10918 + sllx == 0x83287020U &&
10919 + (or & 0xFFFFE000U) == 0x8A116000U &&
10920 + jmpl == 0x81C04005U &&
10921 + nop == 0x01000000U)
10922 + {
10923 + unsigned long addr;
10924 +
10925 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10926 + regs->u_regs[UREG_G1] <<= 32;
10927 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10928 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10929 + regs->tpc = addr;
10930 + regs->tnpc = addr+4;
10931 + return 2;
10932 + }
10933 + } while (0);
10934 +
10935 + do { /* PaX: unpatched PLT emulation step 1 */
10936 + unsigned int sethi, ba, nop;
10937 +
10938 + err = get_user(sethi, (unsigned int *)regs->tpc);
10939 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10940 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10941 +
10942 + if (err)
10943 + break;
10944 +
10945 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10946 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10947 + nop == 0x01000000U)
10948 + {
10949 + unsigned long addr;
10950 + unsigned int save, call;
10951 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10952 +
10953 + if ((ba & 0xFFC00000U) == 0x30800000U)
10954 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10955 + else
10956 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10957 +
10958 + if (test_thread_flag(TIF_32BIT))
10959 + addr &= 0xFFFFFFFFUL;
10960 +
10961 + err = get_user(save, (unsigned int *)addr);
10962 + err |= get_user(call, (unsigned int *)(addr+4));
10963 + err |= get_user(nop, (unsigned int *)(addr+8));
10964 + if (err)
10965 + break;
10966 +
10967 +#ifdef CONFIG_PAX_DLRESOLVE
10968 + if (save == 0x9DE3BFA8U &&
10969 + (call & 0xC0000000U) == 0x40000000U &&
10970 + nop == 0x01000000U)
10971 + {
10972 + struct vm_area_struct *vma;
10973 + unsigned long call_dl_resolve;
10974 +
10975 + down_read(&current->mm->mmap_sem);
10976 + call_dl_resolve = current->mm->call_dl_resolve;
10977 + up_read(&current->mm->mmap_sem);
10978 + if (likely(call_dl_resolve))
10979 + goto emulate;
10980 +
10981 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10982 +
10983 + down_write(&current->mm->mmap_sem);
10984 + if (current->mm->call_dl_resolve) {
10985 + call_dl_resolve = current->mm->call_dl_resolve;
10986 + up_write(&current->mm->mmap_sem);
10987 + if (vma)
10988 + kmem_cache_free(vm_area_cachep, vma);
10989 + goto emulate;
10990 + }
10991 +
10992 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10993 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10994 + up_write(&current->mm->mmap_sem);
10995 + if (vma)
10996 + kmem_cache_free(vm_area_cachep, vma);
10997 + return 1;
10998 + }
10999 +
11000 + if (pax_insert_vma(vma, call_dl_resolve)) {
11001 + up_write(&current->mm->mmap_sem);
11002 + kmem_cache_free(vm_area_cachep, vma);
11003 + return 1;
11004 + }
11005 +
11006 + current->mm->call_dl_resolve = call_dl_resolve;
11007 + up_write(&current->mm->mmap_sem);
11008 +
11009 +emulate:
11010 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11011 + regs->tpc = call_dl_resolve;
11012 + regs->tnpc = addr+4;
11013 + return 3;
11014 + }
11015 +#endif
11016 +
11017 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11018 + if ((save & 0xFFC00000U) == 0x05000000U &&
11019 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11020 + nop == 0x01000000U)
11021 + {
11022 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11023 + regs->u_regs[UREG_G2] = addr + 4;
11024 + addr = (save & 0x003FFFFFU) << 10;
11025 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11026 +
11027 + if (test_thread_flag(TIF_32BIT))
11028 + addr &= 0xFFFFFFFFUL;
11029 +
11030 + regs->tpc = addr;
11031 + regs->tnpc = addr+4;
11032 + return 3;
11033 + }
11034 +
11035 + /* PaX: 64-bit PLT stub */
11036 + err = get_user(sethi1, (unsigned int *)addr);
11037 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11038 + err |= get_user(or1, (unsigned int *)(addr+8));
11039 + err |= get_user(or2, (unsigned int *)(addr+12));
11040 + err |= get_user(sllx, (unsigned int *)(addr+16));
11041 + err |= get_user(add, (unsigned int *)(addr+20));
11042 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11043 + err |= get_user(nop, (unsigned int *)(addr+28));
11044 + if (err)
11045 + break;
11046 +
11047 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11048 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11049 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11050 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11051 + sllx == 0x89293020U &&
11052 + add == 0x8A010005U &&
11053 + jmpl == 0x89C14000U &&
11054 + nop == 0x01000000U)
11055 + {
11056 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11057 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11058 + regs->u_regs[UREG_G4] <<= 32;
11059 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11060 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11061 + regs->u_regs[UREG_G4] = addr + 24;
11062 + addr = regs->u_regs[UREG_G5];
11063 + regs->tpc = addr;
11064 + regs->tnpc = addr+4;
11065 + return 3;
11066 + }
11067 + }
11068 + } while (0);
11069 +
11070 +#ifdef CONFIG_PAX_DLRESOLVE
11071 + do { /* PaX: unpatched PLT emulation step 2 */
11072 + unsigned int save, call, nop;
11073 +
11074 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11075 + err |= get_user(call, (unsigned int *)regs->tpc);
11076 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11077 + if (err)
11078 + break;
11079 +
11080 + if (save == 0x9DE3BFA8U &&
11081 + (call & 0xC0000000U) == 0x40000000U &&
11082 + nop == 0x01000000U)
11083 + {
11084 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11085 +
11086 + if (test_thread_flag(TIF_32BIT))
11087 + dl_resolve &= 0xFFFFFFFFUL;
11088 +
11089 + regs->u_regs[UREG_RETPC] = regs->tpc;
11090 + regs->tpc = dl_resolve;
11091 + regs->tnpc = dl_resolve+4;
11092 + return 3;
11093 + }
11094 + } while (0);
11095 +#endif
11096 +
11097 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11098 + unsigned int sethi, ba, nop;
11099 +
11100 + err = get_user(sethi, (unsigned int *)regs->tpc);
11101 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11102 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11103 +
11104 + if (err)
11105 + break;
11106 +
11107 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11108 + (ba & 0xFFF00000U) == 0x30600000U &&
11109 + nop == 0x01000000U)
11110 + {
11111 + unsigned long addr;
11112 +
11113 + addr = (sethi & 0x003FFFFFU) << 10;
11114 + regs->u_regs[UREG_G1] = addr;
11115 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11116 +
11117 + if (test_thread_flag(TIF_32BIT))
11118 + addr &= 0xFFFFFFFFUL;
11119 +
11120 + regs->tpc = addr;
11121 + regs->tnpc = addr+4;
11122 + return 2;
11123 + }
11124 + } while (0);
11125 +
11126 +#endif
11127 +
11128 + return 1;
11129 +}
11130 +
11131 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11132 +{
11133 + unsigned long i;
11134 +
11135 + printk(KERN_ERR "PAX: bytes at PC: ");
11136 + for (i = 0; i < 8; i++) {
11137 + unsigned int c;
11138 + if (get_user(c, (unsigned int *)pc+i))
11139 + printk(KERN_CONT "???????? ");
11140 + else
11141 + printk(KERN_CONT "%08x ", c);
11142 + }
11143 + printk("\n");
11144 +}
11145 +#endif
11146 +
11147 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11148 {
11149 struct mm_struct *mm = current->mm;
11150 @@ -341,6 +804,29 @@ retry:
11151 if (!vma)
11152 goto bad_area;
11153
11154 +#ifdef CONFIG_PAX_PAGEEXEC
11155 + /* PaX: detect ITLB misses on non-exec pages */
11156 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11157 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11158 + {
11159 + if (address != regs->tpc)
11160 + goto good_area;
11161 +
11162 + up_read(&mm->mmap_sem);
11163 + switch (pax_handle_fetch_fault(regs)) {
11164 +
11165 +#ifdef CONFIG_PAX_EMUPLT
11166 + case 2:
11167 + case 3:
11168 + return;
11169 +#endif
11170 +
11171 + }
11172 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11173 + do_group_exit(SIGKILL);
11174 + }
11175 +#endif
11176 +
11177 /* Pure DTLB misses do not tell us whether the fault causing
11178 * load/store/atomic was a write or not, it only says that there
11179 * was no match. So in such a case we (carefully) read the
11180 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11181 index d2b5944..d878f3c 100644
11182 --- a/arch/sparc/mm/hugetlbpage.c
11183 +++ b/arch/sparc/mm/hugetlbpage.c
11184 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11185 unsigned long addr,
11186 unsigned long len,
11187 unsigned long pgoff,
11188 - unsigned long flags)
11189 + unsigned long flags,
11190 + unsigned long offset)
11191 {
11192 unsigned long task_size = TASK_SIZE;
11193 struct vm_unmapped_area_info info;
11194 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11195
11196 info.flags = 0;
11197 info.length = len;
11198 - info.low_limit = TASK_UNMAPPED_BASE;
11199 + info.low_limit = mm->mmap_base;
11200 info.high_limit = min(task_size, VA_EXCLUDE_START);
11201 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11202 info.align_offset = 0;
11203 + info.threadstack_offset = offset;
11204 addr = vm_unmapped_area(&info);
11205
11206 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11207 VM_BUG_ON(addr != -ENOMEM);
11208 info.low_limit = VA_EXCLUDE_END;
11209 +
11210 +#ifdef CONFIG_PAX_RANDMMAP
11211 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11212 + info.low_limit += mm->delta_mmap;
11213 +#endif
11214 +
11215 info.high_limit = task_size;
11216 addr = vm_unmapped_area(&info);
11217 }
11218 @@ -58,7 +66,8 @@ static unsigned long
11219 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11220 const unsigned long len,
11221 const unsigned long pgoff,
11222 - const unsigned long flags)
11223 + const unsigned long flags,
11224 + const unsigned long offset)
11225 {
11226 struct mm_struct *mm = current->mm;
11227 unsigned long addr = addr0;
11228 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11229 info.high_limit = mm->mmap_base;
11230 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11231 info.align_offset = 0;
11232 + info.threadstack_offset = offset;
11233 addr = vm_unmapped_area(&info);
11234
11235 /*
11236 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11237 VM_BUG_ON(addr != -ENOMEM);
11238 info.flags = 0;
11239 info.low_limit = TASK_UNMAPPED_BASE;
11240 +
11241 +#ifdef CONFIG_PAX_RANDMMAP
11242 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11243 + info.low_limit += mm->delta_mmap;
11244 +#endif
11245 +
11246 info.high_limit = STACK_TOP32;
11247 addr = vm_unmapped_area(&info);
11248 }
11249 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11250 struct mm_struct *mm = current->mm;
11251 struct vm_area_struct *vma;
11252 unsigned long task_size = TASK_SIZE;
11253 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11254
11255 if (test_thread_flag(TIF_32BIT))
11256 task_size = STACK_TOP32;
11257 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11258 return addr;
11259 }
11260
11261 +#ifdef CONFIG_PAX_RANDMMAP
11262 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11263 +#endif
11264 +
11265 if (addr) {
11266 addr = ALIGN(addr, HPAGE_SIZE);
11267 vma = find_vma(mm, addr);
11268 - if (task_size - len >= addr &&
11269 - (!vma || addr + len <= vma->vm_start))
11270 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11271 return addr;
11272 }
11273 if (mm->get_unmapped_area == arch_get_unmapped_area)
11274 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11275 - pgoff, flags);
11276 + pgoff, flags, offset);
11277 else
11278 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11279 - pgoff, flags);
11280 + pgoff, flags, offset);
11281 }
11282
11283 pte_t *huge_pte_alloc(struct mm_struct *mm,
11284 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11285 index ed82eda..0d80e77 100644
11286 --- a/arch/sparc/mm/init_64.c
11287 +++ b/arch/sparc/mm/init_64.c
11288 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11289 int num_kernel_image_mappings;
11290
11291 #ifdef CONFIG_DEBUG_DCFLUSH
11292 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11293 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11294 #ifdef CONFIG_SMP
11295 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11296 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11297 #endif
11298 #endif
11299
11300 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11301 {
11302 BUG_ON(tlb_type == hypervisor);
11303 #ifdef CONFIG_DEBUG_DCFLUSH
11304 - atomic_inc(&dcpage_flushes);
11305 + atomic_inc_unchecked(&dcpage_flushes);
11306 #endif
11307
11308 #ifdef DCACHE_ALIASING_POSSIBLE
11309 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11310
11311 #ifdef CONFIG_DEBUG_DCFLUSH
11312 seq_printf(m, "DCPageFlushes\t: %d\n",
11313 - atomic_read(&dcpage_flushes));
11314 + atomic_read_unchecked(&dcpage_flushes));
11315 #ifdef CONFIG_SMP
11316 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11317 - atomic_read(&dcpage_flushes_xcall));
11318 + atomic_read_unchecked(&dcpage_flushes_xcall));
11319 #endif /* CONFIG_SMP */
11320 #endif /* CONFIG_DEBUG_DCFLUSH */
11321 }
11322 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11323 index f4500c6..889656c 100644
11324 --- a/arch/tile/include/asm/atomic_64.h
11325 +++ b/arch/tile/include/asm/atomic_64.h
11326 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11327
11328 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11329
11330 +#define atomic64_read_unchecked(v) atomic64_read(v)
11331 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11332 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11333 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11334 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11335 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11336 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11337 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11338 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11339 +
11340 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11341 #define smp_mb__before_atomic_dec() smp_mb()
11342 #define smp_mb__after_atomic_dec() smp_mb()
11343 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11344 index a9a5299..0fce79e 100644
11345 --- a/arch/tile/include/asm/cache.h
11346 +++ b/arch/tile/include/asm/cache.h
11347 @@ -15,11 +15,12 @@
11348 #ifndef _ASM_TILE_CACHE_H
11349 #define _ASM_TILE_CACHE_H
11350
11351 +#include <linux/const.h>
11352 #include <arch/chip.h>
11353
11354 /* bytes per L1 data cache line */
11355 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11356 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11357 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11358
11359 /* bytes per L2 cache line */
11360 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11361 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11362 index e4d44bd..99927a3 100644
11363 --- a/arch/tile/include/asm/uaccess.h
11364 +++ b/arch/tile/include/asm/uaccess.h
11365 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11366 const void __user *from,
11367 unsigned long n)
11368 {
11369 - int sz = __compiletime_object_size(to);
11370 + size_t sz = __compiletime_object_size(to);
11371
11372 - if (likely(sz == -1 || sz >= n))
11373 + if (likely(sz == (size_t)-1 || sz >= n))
11374 n = _copy_from_user(to, from, n);
11375 else
11376 copy_from_user_overflow();
11377 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11378 index 650ccff..45fe2d6 100644
11379 --- a/arch/tile/mm/hugetlbpage.c
11380 +++ b/arch/tile/mm/hugetlbpage.c
11381 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11382 info.high_limit = TASK_SIZE;
11383 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11384 info.align_offset = 0;
11385 + info.threadstack_offset = 0;
11386 return vm_unmapped_area(&info);
11387 }
11388
11389 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11390 info.high_limit = current->mm->mmap_base;
11391 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11392 info.align_offset = 0;
11393 + info.threadstack_offset = 0;
11394 addr = vm_unmapped_area(&info);
11395
11396 /*
11397 diff --git a/arch/um/Makefile b/arch/um/Makefile
11398 index 133f7de..1d6f2f1 100644
11399 --- a/arch/um/Makefile
11400 +++ b/arch/um/Makefile
11401 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11402 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11403 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11404
11405 +ifdef CONSTIFY_PLUGIN
11406 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11407 +endif
11408 +
11409 #This will adjust *FLAGS accordingly to the platform.
11410 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11411
11412 diff --git a/arch/um/defconfig b/arch/um/defconfig
11413 index 08107a7..ab22afe 100644
11414 --- a/arch/um/defconfig
11415 +++ b/arch/um/defconfig
11416 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11417 CONFIG_X86_L1_CACHE_SHIFT=5
11418 CONFIG_X86_XADD=y
11419 CONFIG_X86_PPRO_FENCE=y
11420 -CONFIG_X86_WP_WORKS_OK=y
11421 CONFIG_X86_INVLPG=y
11422 CONFIG_X86_BSWAP=y
11423 CONFIG_X86_POPAD_OK=y
11424 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11425 index 19e1bdd..3665b77 100644
11426 --- a/arch/um/include/asm/cache.h
11427 +++ b/arch/um/include/asm/cache.h
11428 @@ -1,6 +1,7 @@
11429 #ifndef __UM_CACHE_H
11430 #define __UM_CACHE_H
11431
11432 +#include <linux/const.h>
11433
11434 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11435 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11436 @@ -12,6 +13,6 @@
11437 # define L1_CACHE_SHIFT 5
11438 #endif
11439
11440 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11441 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11442
11443 #endif
11444 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11445 index 2e0a6b1..a64d0f5 100644
11446 --- a/arch/um/include/asm/kmap_types.h
11447 +++ b/arch/um/include/asm/kmap_types.h
11448 @@ -8,6 +8,6 @@
11449
11450 /* No more #include "asm/arch/kmap_types.h" ! */
11451
11452 -#define KM_TYPE_NR 14
11453 +#define KM_TYPE_NR 15
11454
11455 #endif
11456 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11457 index 5ff53d9..5850cdf 100644
11458 --- a/arch/um/include/asm/page.h
11459 +++ b/arch/um/include/asm/page.h
11460 @@ -14,6 +14,9 @@
11461 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11462 #define PAGE_MASK (~(PAGE_SIZE-1))
11463
11464 +#define ktla_ktva(addr) (addr)
11465 +#define ktva_ktla(addr) (addr)
11466 +
11467 #ifndef __ASSEMBLY__
11468
11469 struct page;
11470 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11471 index 0032f92..cd151e0 100644
11472 --- a/arch/um/include/asm/pgtable-3level.h
11473 +++ b/arch/um/include/asm/pgtable-3level.h
11474 @@ -58,6 +58,7 @@
11475 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11476 #define pud_populate(mm, pud, pmd) \
11477 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11478 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11479
11480 #ifdef CONFIG_64BIT
11481 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11482 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11483 index bbcef52..6a2a483 100644
11484 --- a/arch/um/kernel/process.c
11485 +++ b/arch/um/kernel/process.c
11486 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11487 return 2;
11488 }
11489
11490 -/*
11491 - * Only x86 and x86_64 have an arch_align_stack().
11492 - * All other arches have "#define arch_align_stack(x) (x)"
11493 - * in their asm/system.h
11494 - * As this is included in UML from asm-um/system-generic.h,
11495 - * we can use it to behave as the subarch does.
11496 - */
11497 -#ifndef arch_align_stack
11498 -unsigned long arch_align_stack(unsigned long sp)
11499 -{
11500 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11501 - sp -= get_random_int() % 8192;
11502 - return sp & ~0xf;
11503 -}
11504 -#endif
11505 -
11506 unsigned long get_wchan(struct task_struct *p)
11507 {
11508 unsigned long stack_page, sp, ip;
11509 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11510 index ad8f795..2c7eec6 100644
11511 --- a/arch/unicore32/include/asm/cache.h
11512 +++ b/arch/unicore32/include/asm/cache.h
11513 @@ -12,8 +12,10 @@
11514 #ifndef __UNICORE_CACHE_H__
11515 #define __UNICORE_CACHE_H__
11516
11517 -#define L1_CACHE_SHIFT (5)
11518 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11519 +#include <linux/const.h>
11520 +
11521 +#define L1_CACHE_SHIFT 5
11522 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11523
11524 /*
11525 * Memory returned by kmalloc() may be used for DMA, so we must make
11526 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11527 index b32ebf9..5704f98 100644
11528 --- a/arch/x86/Kconfig
11529 +++ b/arch/x86/Kconfig
11530 @@ -248,7 +248,7 @@ config X86_HT
11531
11532 config X86_32_LAZY_GS
11533 def_bool y
11534 - depends on X86_32 && !CC_STACKPROTECTOR
11535 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11536
11537 config ARCH_HWEIGHT_CFLAGS
11538 string
11539 @@ -1088,6 +1088,7 @@ config MICROCODE_EARLY
11540
11541 config X86_MSR
11542 tristate "/dev/cpu/*/msr - Model-specific register support"
11543 + depends on !GRKERNSEC_KMEM
11544 ---help---
11545 This device gives privileged processes access to the x86
11546 Model-Specific Registers (MSRs). It is a character device with
11547 @@ -1111,7 +1112,7 @@ choice
11548
11549 config NOHIGHMEM
11550 bool "off"
11551 - depends on !X86_NUMAQ
11552 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11553 ---help---
11554 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11555 However, the address space of 32-bit x86 processors is only 4
11556 @@ -1148,7 +1149,7 @@ config NOHIGHMEM
11557
11558 config HIGHMEM4G
11559 bool "4GB"
11560 - depends on !X86_NUMAQ
11561 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11562 ---help---
11563 Select this if you have a 32-bit processor and between 1 and 4
11564 gigabytes of physical RAM.
11565 @@ -1201,7 +1202,7 @@ config PAGE_OFFSET
11566 hex
11567 default 0xB0000000 if VMSPLIT_3G_OPT
11568 default 0x80000000 if VMSPLIT_2G
11569 - default 0x78000000 if VMSPLIT_2G_OPT
11570 + default 0x70000000 if VMSPLIT_2G_OPT
11571 default 0x40000000 if VMSPLIT_1G
11572 default 0xC0000000
11573 depends on X86_32
11574 @@ -1599,6 +1600,7 @@ config SECCOMP
11575
11576 config CC_STACKPROTECTOR
11577 bool "Enable -fstack-protector buffer overflow detection"
11578 + depends on X86_64 || !PAX_MEMORY_UDEREF
11579 ---help---
11580 This option turns on the -fstack-protector GCC feature. This
11581 feature puts, at the beginning of functions, a canary value on
11582 @@ -1718,6 +1720,8 @@ config X86_NEED_RELOCS
11583 config PHYSICAL_ALIGN
11584 hex "Alignment value to which kernel should be aligned" if X86_32
11585 default "0x1000000"
11586 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11587 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11588 range 0x2000 0x1000000
11589 ---help---
11590 This value puts the alignment restrictions on physical address
11591 @@ -1793,9 +1797,10 @@ config DEBUG_HOTPLUG_CPU0
11592 If unsure, say N.
11593
11594 config COMPAT_VDSO
11595 - def_bool y
11596 + def_bool n
11597 prompt "Compat VDSO support"
11598 depends on X86_32 || IA32_EMULATION
11599 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11600 ---help---
11601 Map the 32-bit VDSO to the predictable old-style address too.
11602
11603 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11604 index c026cca..14657ae 100644
11605 --- a/arch/x86/Kconfig.cpu
11606 +++ b/arch/x86/Kconfig.cpu
11607 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11608
11609 config X86_F00F_BUG
11610 def_bool y
11611 - depends on M586MMX || M586TSC || M586 || M486
11612 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11613
11614 config X86_INVD_BUG
11615 def_bool y
11616 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11617
11618 config X86_ALIGNMENT_16
11619 def_bool y
11620 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11621 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11622
11623 config X86_INTEL_USERCOPY
11624 def_bool y
11625 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11626 # generates cmov.
11627 config X86_CMOV
11628 def_bool y
11629 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11630 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11631
11632 config X86_MINIMUM_CPU_FAMILY
11633 int
11634 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11635 index 78d91af..8ceb94b 100644
11636 --- a/arch/x86/Kconfig.debug
11637 +++ b/arch/x86/Kconfig.debug
11638 @@ -74,7 +74,7 @@ config X86_PTDUMP
11639 config DEBUG_RODATA
11640 bool "Write protect kernel read-only data structures"
11641 default y
11642 - depends on DEBUG_KERNEL
11643 + depends on DEBUG_KERNEL && BROKEN
11644 ---help---
11645 Mark the kernel read-only data as write-protected in the pagetables,
11646 in order to catch accidental (and incorrect) writes to such const
11647 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11648
11649 config DEBUG_SET_MODULE_RONX
11650 bool "Set loadable kernel module data as NX and text as RO"
11651 - depends on MODULES
11652 + depends on MODULES && BROKEN
11653 ---help---
11654 This option helps catch unintended modifications to loadable
11655 kernel module's text and read-only data. It also prevents execution
11656 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11657 index 07639c6..6f2c901 100644
11658 --- a/arch/x86/Makefile
11659 +++ b/arch/x86/Makefile
11660 @@ -54,6 +54,7 @@ else
11661 UTS_MACHINE := x86_64
11662 CHECKFLAGS += -D__x86_64__ -m64
11663
11664 + biarch := $(call cc-option,-m64)
11665 KBUILD_AFLAGS += -m64
11666 KBUILD_CFLAGS += -m64
11667
11668 @@ -241,3 +242,12 @@ define archhelp
11669 echo ' FDINITRD=file initrd for the booted kernel'
11670 echo ' kvmconfig - Enable additional options for guest kernel support'
11671 endef
11672 +
11673 +define OLD_LD
11674 +
11675 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11676 +*** Please upgrade your binutils to 2.18 or newer
11677 +endef
11678 +
11679 +archprepare:
11680 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11681 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11682 index 379814b..add62ce 100644
11683 --- a/arch/x86/boot/Makefile
11684 +++ b/arch/x86/boot/Makefile
11685 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11686 $(call cc-option, -fno-stack-protector) \
11687 $(call cc-option, -mpreferred-stack-boundary=2)
11688 KBUILD_CFLAGS += $(call cc-option, -m32)
11689 +ifdef CONSTIFY_PLUGIN
11690 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11691 +endif
11692 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11693 GCOV_PROFILE := n
11694
11695 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11696 index 878e4b9..20537ab 100644
11697 --- a/arch/x86/boot/bitops.h
11698 +++ b/arch/x86/boot/bitops.h
11699 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11700 u8 v;
11701 const u32 *p = (const u32 *)addr;
11702
11703 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11704 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11705 return v;
11706 }
11707
11708 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11709
11710 static inline void set_bit(int nr, void *addr)
11711 {
11712 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11713 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11714 }
11715
11716 #endif /* BOOT_BITOPS_H */
11717 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11718 index 5b75319..331a4ca 100644
11719 --- a/arch/x86/boot/boot.h
11720 +++ b/arch/x86/boot/boot.h
11721 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11722 static inline u16 ds(void)
11723 {
11724 u16 seg;
11725 - asm("movw %%ds,%0" : "=rm" (seg));
11726 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11727 return seg;
11728 }
11729
11730 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11731 static inline int memcmp(const void *s1, const void *s2, size_t len)
11732 {
11733 u8 diff;
11734 - asm("repe; cmpsb; setnz %0"
11735 + asm volatile("repe; cmpsb; setnz %0"
11736 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11737 return diff;
11738 }
11739 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11740 index dcd90df..c830d7d 100644
11741 --- a/arch/x86/boot/compressed/Makefile
11742 +++ b/arch/x86/boot/compressed/Makefile
11743 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11744 KBUILD_CFLAGS += $(cflags-y)
11745 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11746 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11747 +ifdef CONSTIFY_PLUGIN
11748 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11749 +endif
11750
11751 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11752 GCOV_PROFILE := n
11753 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11754 index b7388a4..03844ec 100644
11755 --- a/arch/x86/boot/compressed/eboot.c
11756 +++ b/arch/x86/boot/compressed/eboot.c
11757 @@ -150,7 +150,6 @@ again:
11758 *addr = max_addr;
11759 }
11760
11761 -free_pool:
11762 efi_call_phys1(sys_table->boottime->free_pool, map);
11763
11764 fail:
11765 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11766 if (i == map_size / desc_size)
11767 status = EFI_NOT_FOUND;
11768
11769 -free_pool:
11770 efi_call_phys1(sys_table->boottime->free_pool, map);
11771 fail:
11772 return status;
11773 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11774 index a53440e..c3dbf1e 100644
11775 --- a/arch/x86/boot/compressed/efi_stub_32.S
11776 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11777 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11778 * parameter 2, ..., param n. To make things easy, we save the return
11779 * address of efi_call_phys in a global variable.
11780 */
11781 - popl %ecx
11782 - movl %ecx, saved_return_addr(%edx)
11783 - /* get the function pointer into ECX*/
11784 - popl %ecx
11785 - movl %ecx, efi_rt_function_ptr(%edx)
11786 + popl saved_return_addr(%edx)
11787 + popl efi_rt_function_ptr(%edx)
11788
11789 /*
11790 * 3. Call the physical function.
11791 */
11792 - call *%ecx
11793 + call *efi_rt_function_ptr(%edx)
11794
11795 /*
11796 * 4. Balance the stack. And because EAX contain the return value,
11797 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11798 1: popl %edx
11799 subl $1b, %edx
11800
11801 - movl efi_rt_function_ptr(%edx), %ecx
11802 - pushl %ecx
11803 + pushl efi_rt_function_ptr(%edx)
11804
11805 /*
11806 * 10. Push the saved return address onto the stack and return.
11807 */
11808 - movl saved_return_addr(%edx), %ecx
11809 - pushl %ecx
11810 - ret
11811 + jmpl *saved_return_addr(%edx)
11812 ENDPROC(efi_call_phys)
11813 .previous
11814
11815 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11816 index 1e3184f..0d11e2e 100644
11817 --- a/arch/x86/boot/compressed/head_32.S
11818 +++ b/arch/x86/boot/compressed/head_32.S
11819 @@ -118,7 +118,7 @@ preferred_addr:
11820 notl %eax
11821 andl %eax, %ebx
11822 #else
11823 - movl $LOAD_PHYSICAL_ADDR, %ebx
11824 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11825 #endif
11826
11827 /* Target address to relocate to for decompression */
11828 @@ -204,7 +204,7 @@ relocated:
11829 * and where it was actually loaded.
11830 */
11831 movl %ebp, %ebx
11832 - subl $LOAD_PHYSICAL_ADDR, %ebx
11833 + subl $____LOAD_PHYSICAL_ADDR, %ebx
11834 jz 2f /* Nothing to be done if loaded at compiled addr. */
11835 /*
11836 * Process relocations.
11837 @@ -212,8 +212,7 @@ relocated:
11838
11839 1: subl $4, %edi
11840 movl (%edi), %ecx
11841 - testl %ecx, %ecx
11842 - jz 2f
11843 + jecxz 2f
11844 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
11845 jmp 1b
11846 2:
11847 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11848 index 06e71c2..88a98264 100644
11849 --- a/arch/x86/boot/compressed/head_64.S
11850 +++ b/arch/x86/boot/compressed/head_64.S
11851 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11852 notl %eax
11853 andl %eax, %ebx
11854 #else
11855 - movl $LOAD_PHYSICAL_ADDR, %ebx
11856 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11857 #endif
11858
11859 /* Target address to relocate to for decompression */
11860 @@ -270,7 +270,7 @@ preferred_addr:
11861 notq %rax
11862 andq %rax, %rbp
11863 #else
11864 - movq $LOAD_PHYSICAL_ADDR, %rbp
11865 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11866 #endif
11867
11868 /* Target address to relocate to for decompression */
11869 @@ -361,8 +361,8 @@ gdt:
11870 .long gdt
11871 .word 0
11872 .quad 0x0000000000000000 /* NULL descriptor */
11873 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11874 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11875 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11876 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11877 .quad 0x0080890000000000 /* TS descriptor */
11878 .quad 0x0000000000000000 /* TS continued */
11879 gdt_end:
11880 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11881 index 0319c88..7c1931f 100644
11882 --- a/arch/x86/boot/compressed/misc.c
11883 +++ b/arch/x86/boot/compressed/misc.c
11884 @@ -307,7 +307,7 @@ static void parse_elf(void *output)
11885 case PT_LOAD:
11886 #ifdef CONFIG_RELOCATABLE
11887 dest = output;
11888 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11889 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11890 #else
11891 dest = (void *)(phdr->p_paddr);
11892 #endif
11893 @@ -358,7 +358,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11894 error("Destination address too large");
11895 #endif
11896 #ifndef CONFIG_RELOCATABLE
11897 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11898 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11899 error("Wrong destination address");
11900 #endif
11901
11902 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11903 index 4d3ff03..e4972ff 100644
11904 --- a/arch/x86/boot/cpucheck.c
11905 +++ b/arch/x86/boot/cpucheck.c
11906 @@ -74,7 +74,7 @@ static int has_fpu(void)
11907 u16 fcw = -1, fsw = -1;
11908 u32 cr0;
11909
11910 - asm("movl %%cr0,%0" : "=r" (cr0));
11911 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11912 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11913 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11914 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11915 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11916 {
11917 u32 f0, f1;
11918
11919 - asm("pushfl ; "
11920 + asm volatile("pushfl ; "
11921 "pushfl ; "
11922 "popl %0 ; "
11923 "movl %0,%1 ; "
11924 @@ -115,7 +115,7 @@ static void get_flags(void)
11925 set_bit(X86_FEATURE_FPU, cpu.flags);
11926
11927 if (has_eflag(X86_EFLAGS_ID)) {
11928 - asm("cpuid"
11929 + asm volatile("cpuid"
11930 : "=a" (max_intel_level),
11931 "=b" (cpu_vendor[0]),
11932 "=d" (cpu_vendor[1]),
11933 @@ -124,7 +124,7 @@ static void get_flags(void)
11934
11935 if (max_intel_level >= 0x00000001 &&
11936 max_intel_level <= 0x0000ffff) {
11937 - asm("cpuid"
11938 + asm volatile("cpuid"
11939 : "=a" (tfms),
11940 "=c" (cpu.flags[4]),
11941 "=d" (cpu.flags[0])
11942 @@ -136,7 +136,7 @@ static void get_flags(void)
11943 cpu.model += ((tfms >> 16) & 0xf) << 4;
11944 }
11945
11946 - asm("cpuid"
11947 + asm volatile("cpuid"
11948 : "=a" (max_amd_level)
11949 : "a" (0x80000000)
11950 : "ebx", "ecx", "edx");
11951 @@ -144,7 +144,7 @@ static void get_flags(void)
11952 if (max_amd_level >= 0x80000001 &&
11953 max_amd_level <= 0x8000ffff) {
11954 u32 eax = 0x80000001;
11955 - asm("cpuid"
11956 + asm volatile("cpuid"
11957 : "+a" (eax),
11958 "=c" (cpu.flags[6]),
11959 "=d" (cpu.flags[1])
11960 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11961 u32 ecx = MSR_K7_HWCR;
11962 u32 eax, edx;
11963
11964 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11965 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11966 eax &= ~(1 << 15);
11967 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11968 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11969
11970 get_flags(); /* Make sure it really did something */
11971 err = check_flags();
11972 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11973 u32 ecx = MSR_VIA_FCR;
11974 u32 eax, edx;
11975
11976 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11977 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11978 eax |= (1<<1)|(1<<7);
11979 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11980 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11981
11982 set_bit(X86_FEATURE_CX8, cpu.flags);
11983 err = check_flags();
11984 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11985 u32 eax, edx;
11986 u32 level = 1;
11987
11988 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11989 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11990 - asm("cpuid"
11991 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11992 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11993 + asm volatile("cpuid"
11994 : "+a" (level), "=d" (cpu.flags[0])
11995 : : "ecx", "ebx");
11996 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11997 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11998
11999 err = check_flags();
12000 }
12001 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12002 index 9ec06a1..2c25e79 100644
12003 --- a/arch/x86/boot/header.S
12004 +++ b/arch/x86/boot/header.S
12005 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12006 # single linked list of
12007 # struct setup_data
12008
12009 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12010 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12011
12012 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12013 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12014 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12015 +#else
12016 #define VO_INIT_SIZE (VO__end - VO__text)
12017 +#endif
12018 #if ZO_INIT_SIZE > VO_INIT_SIZE
12019 #define INIT_SIZE ZO_INIT_SIZE
12020 #else
12021 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12022 index db75d07..8e6d0af 100644
12023 --- a/arch/x86/boot/memory.c
12024 +++ b/arch/x86/boot/memory.c
12025 @@ -19,7 +19,7 @@
12026
12027 static int detect_memory_e820(void)
12028 {
12029 - int count = 0;
12030 + unsigned int count = 0;
12031 struct biosregs ireg, oreg;
12032 struct e820entry *desc = boot_params.e820_map;
12033 static struct e820entry buf; /* static so it is zeroed */
12034 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12035 index 11e8c6e..fdbb1ed 100644
12036 --- a/arch/x86/boot/video-vesa.c
12037 +++ b/arch/x86/boot/video-vesa.c
12038 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12039
12040 boot_params.screen_info.vesapm_seg = oreg.es;
12041 boot_params.screen_info.vesapm_off = oreg.di;
12042 + boot_params.screen_info.vesapm_size = oreg.cx;
12043 }
12044
12045 /*
12046 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12047 index 43eda28..5ab5fdb 100644
12048 --- a/arch/x86/boot/video.c
12049 +++ b/arch/x86/boot/video.c
12050 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12051 static unsigned int get_entry(void)
12052 {
12053 char entry_buf[4];
12054 - int i, len = 0;
12055 + unsigned int i, len = 0;
12056 int key;
12057 unsigned int v;
12058
12059 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12060 index 9105655..5e37f27 100644
12061 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12062 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12063 @@ -8,6 +8,8 @@
12064 * including this sentence is retained in full.
12065 */
12066
12067 +#include <asm/alternative-asm.h>
12068 +
12069 .extern crypto_ft_tab
12070 .extern crypto_it_tab
12071 .extern crypto_fl_tab
12072 @@ -70,6 +72,8 @@
12073 je B192; \
12074 leaq 32(r9),r9;
12075
12076 +#define ret pax_force_retaddr 0, 1; ret
12077 +
12078 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12079 movq r1,r2; \
12080 movq r3,r4; \
12081 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12082 index 477e9d7..3ab339f 100644
12083 --- a/arch/x86/crypto/aesni-intel_asm.S
12084 +++ b/arch/x86/crypto/aesni-intel_asm.S
12085 @@ -31,6 +31,7 @@
12086
12087 #include <linux/linkage.h>
12088 #include <asm/inst.h>
12089 +#include <asm/alternative-asm.h>
12090
12091 #ifdef __x86_64__
12092 .data
12093 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12094 pop %r14
12095 pop %r13
12096 pop %r12
12097 + pax_force_retaddr 0, 1
12098 ret
12099 ENDPROC(aesni_gcm_dec)
12100
12101 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12102 pop %r14
12103 pop %r13
12104 pop %r12
12105 + pax_force_retaddr 0, 1
12106 ret
12107 ENDPROC(aesni_gcm_enc)
12108
12109 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12110 pxor %xmm1, %xmm0
12111 movaps %xmm0, (TKEYP)
12112 add $0x10, TKEYP
12113 + pax_force_retaddr_bts
12114 ret
12115 ENDPROC(_key_expansion_128)
12116 ENDPROC(_key_expansion_256a)
12117 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12118 shufps $0b01001110, %xmm2, %xmm1
12119 movaps %xmm1, 0x10(TKEYP)
12120 add $0x20, TKEYP
12121 + pax_force_retaddr_bts
12122 ret
12123 ENDPROC(_key_expansion_192a)
12124
12125 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12126
12127 movaps %xmm0, (TKEYP)
12128 add $0x10, TKEYP
12129 + pax_force_retaddr_bts
12130 ret
12131 ENDPROC(_key_expansion_192b)
12132
12133 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12134 pxor %xmm1, %xmm2
12135 movaps %xmm2, (TKEYP)
12136 add $0x10, TKEYP
12137 + pax_force_retaddr_bts
12138 ret
12139 ENDPROC(_key_expansion_256b)
12140
12141 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12142 #ifndef __x86_64__
12143 popl KEYP
12144 #endif
12145 + pax_force_retaddr 0, 1
12146 ret
12147 ENDPROC(aesni_set_key)
12148
12149 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12150 popl KLEN
12151 popl KEYP
12152 #endif
12153 + pax_force_retaddr 0, 1
12154 ret
12155 ENDPROC(aesni_enc)
12156
12157 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12158 AESENC KEY STATE
12159 movaps 0x70(TKEYP), KEY
12160 AESENCLAST KEY STATE
12161 + pax_force_retaddr_bts
12162 ret
12163 ENDPROC(_aesni_enc1)
12164
12165 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12166 AESENCLAST KEY STATE2
12167 AESENCLAST KEY STATE3
12168 AESENCLAST KEY STATE4
12169 + pax_force_retaddr_bts
12170 ret
12171 ENDPROC(_aesni_enc4)
12172
12173 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12174 popl KLEN
12175 popl KEYP
12176 #endif
12177 + pax_force_retaddr 0, 1
12178 ret
12179 ENDPROC(aesni_dec)
12180
12181 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12182 AESDEC KEY STATE
12183 movaps 0x70(TKEYP), KEY
12184 AESDECLAST KEY STATE
12185 + pax_force_retaddr_bts
12186 ret
12187 ENDPROC(_aesni_dec1)
12188
12189 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12190 AESDECLAST KEY STATE2
12191 AESDECLAST KEY STATE3
12192 AESDECLAST KEY STATE4
12193 + pax_force_retaddr_bts
12194 ret
12195 ENDPROC(_aesni_dec4)
12196
12197 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12198 popl KEYP
12199 popl LEN
12200 #endif
12201 + pax_force_retaddr 0, 1
12202 ret
12203 ENDPROC(aesni_ecb_enc)
12204
12205 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12206 popl KEYP
12207 popl LEN
12208 #endif
12209 + pax_force_retaddr 0, 1
12210 ret
12211 ENDPROC(aesni_ecb_dec)
12212
12213 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12214 popl LEN
12215 popl IVP
12216 #endif
12217 + pax_force_retaddr 0, 1
12218 ret
12219 ENDPROC(aesni_cbc_enc)
12220
12221 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12222 popl LEN
12223 popl IVP
12224 #endif
12225 + pax_force_retaddr 0, 1
12226 ret
12227 ENDPROC(aesni_cbc_dec)
12228
12229 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12230 mov $1, TCTR_LOW
12231 MOVQ_R64_XMM TCTR_LOW INC
12232 MOVQ_R64_XMM CTR TCTR_LOW
12233 + pax_force_retaddr_bts
12234 ret
12235 ENDPROC(_aesni_inc_init)
12236
12237 @@ -2579,6 +2598,7 @@ _aesni_inc:
12238 .Linc_low:
12239 movaps CTR, IV
12240 PSHUFB_XMM BSWAP_MASK IV
12241 + pax_force_retaddr_bts
12242 ret
12243 ENDPROC(_aesni_inc)
12244
12245 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12246 .Lctr_enc_ret:
12247 movups IV, (IVP)
12248 .Lctr_enc_just_ret:
12249 + pax_force_retaddr 0, 1
12250 ret
12251 ENDPROC(aesni_ctr_enc)
12252
12253 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12254 pxor INC, STATE4
12255 movdqu STATE4, 0x70(OUTP)
12256
12257 + pax_force_retaddr 0, 1
12258 ret
12259 ENDPROC(aesni_xts_crypt8)
12260
12261 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12262 index 246c670..4d1ed00 100644
12263 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12264 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12265 @@ -21,6 +21,7 @@
12266 */
12267
12268 #include <linux/linkage.h>
12269 +#include <asm/alternative-asm.h>
12270
12271 .file "blowfish-x86_64-asm.S"
12272 .text
12273 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12274 jnz .L__enc_xor;
12275
12276 write_block();
12277 + pax_force_retaddr 0, 1
12278 ret;
12279 .L__enc_xor:
12280 xor_block();
12281 + pax_force_retaddr 0, 1
12282 ret;
12283 ENDPROC(__blowfish_enc_blk)
12284
12285 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12286
12287 movq %r11, %rbp;
12288
12289 + pax_force_retaddr 0, 1
12290 ret;
12291 ENDPROC(blowfish_dec_blk)
12292
12293 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12294
12295 popq %rbx;
12296 popq %rbp;
12297 + pax_force_retaddr 0, 1
12298 ret;
12299
12300 .L__enc_xor4:
12301 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12302
12303 popq %rbx;
12304 popq %rbp;
12305 + pax_force_retaddr 0, 1
12306 ret;
12307 ENDPROC(__blowfish_enc_blk_4way)
12308
12309 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12310 popq %rbx;
12311 popq %rbp;
12312
12313 + pax_force_retaddr 0, 1
12314 ret;
12315 ENDPROC(blowfish_dec_blk_4way)
12316 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12317 index ce71f92..2dd5b1e 100644
12318 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12319 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12320 @@ -16,6 +16,7 @@
12321 */
12322
12323 #include <linux/linkage.h>
12324 +#include <asm/alternative-asm.h>
12325
12326 #define CAMELLIA_TABLE_BYTE_LEN 272
12327
12328 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12329 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12330 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12331 %rcx, (%r9));
12332 + pax_force_retaddr_bts
12333 ret;
12334 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12335
12336 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12337 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12338 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12339 %rax, (%r9));
12340 + pax_force_retaddr_bts
12341 ret;
12342 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12343
12344 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12345 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12346 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12347
12348 + pax_force_retaddr_bts
12349 ret;
12350
12351 .align 8
12352 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12353 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12354 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12355
12356 + pax_force_retaddr_bts
12357 ret;
12358
12359 .align 8
12360 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12361 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12362 %xmm8, %rsi);
12363
12364 + pax_force_retaddr 0, 1
12365 ret;
12366 ENDPROC(camellia_ecb_enc_16way)
12367
12368 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12369 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12370 %xmm8, %rsi);
12371
12372 + pax_force_retaddr 0, 1
12373 ret;
12374 ENDPROC(camellia_ecb_dec_16way)
12375
12376 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12377 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12378 %xmm8, %rsi);
12379
12380 + pax_force_retaddr 0, 1
12381 ret;
12382 ENDPROC(camellia_cbc_dec_16way)
12383
12384 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12385 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12386 %xmm8, %rsi);
12387
12388 + pax_force_retaddr 0, 1
12389 ret;
12390 ENDPROC(camellia_ctr_16way)
12391
12392 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12393 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12394 %xmm8, %rsi);
12395
12396 + pax_force_retaddr 0, 1
12397 ret;
12398 ENDPROC(camellia_xts_crypt_16way)
12399
12400 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12401 index 0e0b886..8fc756a 100644
12402 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12403 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12404 @@ -11,6 +11,7 @@
12405 */
12406
12407 #include <linux/linkage.h>
12408 +#include <asm/alternative-asm.h>
12409
12410 #define CAMELLIA_TABLE_BYTE_LEN 272
12411
12412 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12413 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12414 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12415 %rcx, (%r9));
12416 + pax_force_retaddr_bts
12417 ret;
12418 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12419
12420 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12421 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12422 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12423 %rax, (%r9));
12424 + pax_force_retaddr_bts
12425 ret;
12426 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12427
12428 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12429 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12430 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12431
12432 + pax_force_retaddr_bts
12433 ret;
12434
12435 .align 8
12436 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12437 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12438 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12439
12440 + pax_force_retaddr_bts
12441 ret;
12442
12443 .align 8
12444 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12445
12446 vzeroupper;
12447
12448 + pax_force_retaddr 0, 1
12449 ret;
12450 ENDPROC(camellia_ecb_enc_32way)
12451
12452 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12453
12454 vzeroupper;
12455
12456 + pax_force_retaddr 0, 1
12457 ret;
12458 ENDPROC(camellia_ecb_dec_32way)
12459
12460 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12461
12462 vzeroupper;
12463
12464 + pax_force_retaddr 0, 1
12465 ret;
12466 ENDPROC(camellia_cbc_dec_32way)
12467
12468 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12469
12470 vzeroupper;
12471
12472 + pax_force_retaddr 0, 1
12473 ret;
12474 ENDPROC(camellia_ctr_32way)
12475
12476 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12477
12478 vzeroupper;
12479
12480 + pax_force_retaddr 0, 1
12481 ret;
12482 ENDPROC(camellia_xts_crypt_32way)
12483
12484 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12485 index 310319c..ce174a4 100644
12486 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12487 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12488 @@ -21,6 +21,7 @@
12489 */
12490
12491 #include <linux/linkage.h>
12492 +#include <asm/alternative-asm.h>
12493
12494 .file "camellia-x86_64-asm_64.S"
12495 .text
12496 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12497 enc_outunpack(mov, RT1);
12498
12499 movq RRBP, %rbp;
12500 + pax_force_retaddr 0, 1
12501 ret;
12502
12503 .L__enc_xor:
12504 enc_outunpack(xor, RT1);
12505
12506 movq RRBP, %rbp;
12507 + pax_force_retaddr 0, 1
12508 ret;
12509 ENDPROC(__camellia_enc_blk)
12510
12511 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12512 dec_outunpack();
12513
12514 movq RRBP, %rbp;
12515 + pax_force_retaddr 0, 1
12516 ret;
12517 ENDPROC(camellia_dec_blk)
12518
12519 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12520
12521 movq RRBP, %rbp;
12522 popq %rbx;
12523 + pax_force_retaddr 0, 1
12524 ret;
12525
12526 .L__enc2_xor:
12527 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12528
12529 movq RRBP, %rbp;
12530 popq %rbx;
12531 + pax_force_retaddr 0, 1
12532 ret;
12533 ENDPROC(__camellia_enc_blk_2way)
12534
12535 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12536
12537 movq RRBP, %rbp;
12538 movq RXOR, %rbx;
12539 + pax_force_retaddr 0, 1
12540 ret;
12541 ENDPROC(camellia_dec_blk_2way)
12542 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12543 index c35fd5d..c1ee236 100644
12544 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12545 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12546 @@ -24,6 +24,7 @@
12547 */
12548
12549 #include <linux/linkage.h>
12550 +#include <asm/alternative-asm.h>
12551
12552 .file "cast5-avx-x86_64-asm_64.S"
12553
12554 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12555 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12556 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12557
12558 + pax_force_retaddr 0, 1
12559 ret;
12560 ENDPROC(__cast5_enc_blk16)
12561
12562 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12563 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12564 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12565
12566 + pax_force_retaddr 0, 1
12567 ret;
12568
12569 .L__skip_dec:
12570 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12571 vmovdqu RR4, (6*4*4)(%r11);
12572 vmovdqu RL4, (7*4*4)(%r11);
12573
12574 + pax_force_retaddr
12575 ret;
12576 ENDPROC(cast5_ecb_enc_16way)
12577
12578 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12579 vmovdqu RR4, (6*4*4)(%r11);
12580 vmovdqu RL4, (7*4*4)(%r11);
12581
12582 + pax_force_retaddr
12583 ret;
12584 ENDPROC(cast5_ecb_dec_16way)
12585
12586 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12587
12588 popq %r12;
12589
12590 + pax_force_retaddr
12591 ret;
12592 ENDPROC(cast5_cbc_dec_16way)
12593
12594 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12595
12596 popq %r12;
12597
12598 + pax_force_retaddr
12599 ret;
12600 ENDPROC(cast5_ctr_16way)
12601 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12602 index e3531f8..18ded3a 100644
12603 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12604 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12605 @@ -24,6 +24,7 @@
12606 */
12607
12608 #include <linux/linkage.h>
12609 +#include <asm/alternative-asm.h>
12610 #include "glue_helper-asm-avx.S"
12611
12612 .file "cast6-avx-x86_64-asm_64.S"
12613 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12614 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12615 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12616
12617 + pax_force_retaddr 0, 1
12618 ret;
12619 ENDPROC(__cast6_enc_blk8)
12620
12621 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12622 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12623 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12624
12625 + pax_force_retaddr 0, 1
12626 ret;
12627 ENDPROC(__cast6_dec_blk8)
12628
12629 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12630
12631 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12632
12633 + pax_force_retaddr
12634 ret;
12635 ENDPROC(cast6_ecb_enc_8way)
12636
12637 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12638
12639 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12640
12641 + pax_force_retaddr
12642 ret;
12643 ENDPROC(cast6_ecb_dec_8way)
12644
12645 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12646
12647 popq %r12;
12648
12649 + pax_force_retaddr
12650 ret;
12651 ENDPROC(cast6_cbc_dec_8way)
12652
12653 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12654
12655 popq %r12;
12656
12657 + pax_force_retaddr
12658 ret;
12659 ENDPROC(cast6_ctr_8way)
12660
12661 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12662 /* dst <= regs xor IVs(in dst) */
12663 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12664
12665 + pax_force_retaddr
12666 ret;
12667 ENDPROC(cast6_xts_enc_8way)
12668
12669 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12670 /* dst <= regs xor IVs(in dst) */
12671 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12672
12673 + pax_force_retaddr
12674 ret;
12675 ENDPROC(cast6_xts_dec_8way)
12676 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12677 index dbc4339..3d868c5 100644
12678 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12679 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12680 @@ -45,6 +45,7 @@
12681
12682 #include <asm/inst.h>
12683 #include <linux/linkage.h>
12684 +#include <asm/alternative-asm.h>
12685
12686 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12687
12688 @@ -312,6 +313,7 @@ do_return:
12689 popq %rsi
12690 popq %rdi
12691 popq %rbx
12692 + pax_force_retaddr 0, 1
12693 ret
12694
12695 ################################################################
12696 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12697 index 586f41a..d02851e 100644
12698 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12699 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12700 @@ -18,6 +18,7 @@
12701
12702 #include <linux/linkage.h>
12703 #include <asm/inst.h>
12704 +#include <asm/alternative-asm.h>
12705
12706 .data
12707
12708 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12709 psrlq $1, T2
12710 pxor T2, T1
12711 pxor T1, DATA
12712 + pax_force_retaddr
12713 ret
12714 ENDPROC(__clmul_gf128mul_ble)
12715
12716 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12717 call __clmul_gf128mul_ble
12718 PSHUFB_XMM BSWAP DATA
12719 movups DATA, (%rdi)
12720 + pax_force_retaddr
12721 ret
12722 ENDPROC(clmul_ghash_mul)
12723
12724 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12725 PSHUFB_XMM BSWAP DATA
12726 movups DATA, (%rdi)
12727 .Lupdate_just_ret:
12728 + pax_force_retaddr
12729 ret
12730 ENDPROC(clmul_ghash_update)
12731
12732 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12733 pand .Lpoly, %xmm1
12734 pxor %xmm1, %xmm0
12735 movups %xmm0, (%rdi)
12736 + pax_force_retaddr
12737 ret
12738 ENDPROC(clmul_ghash_setkey)
12739 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12740 index 9279e0b..9270820 100644
12741 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12742 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12743 @@ -1,4 +1,5 @@
12744 #include <linux/linkage.h>
12745 +#include <asm/alternative-asm.h>
12746
12747 # enter salsa20_encrypt_bytes
12748 ENTRY(salsa20_encrypt_bytes)
12749 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12750 add %r11,%rsp
12751 mov %rdi,%rax
12752 mov %rsi,%rdx
12753 + pax_force_retaddr 0, 1
12754 ret
12755 # bytesatleast65:
12756 ._bytesatleast65:
12757 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12758 add %r11,%rsp
12759 mov %rdi,%rax
12760 mov %rsi,%rdx
12761 + pax_force_retaddr
12762 ret
12763 ENDPROC(salsa20_keysetup)
12764
12765 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12766 add %r11,%rsp
12767 mov %rdi,%rax
12768 mov %rsi,%rdx
12769 + pax_force_retaddr
12770 ret
12771 ENDPROC(salsa20_ivsetup)
12772 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12773 index 2f202f4..d9164d6 100644
12774 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12775 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12776 @@ -24,6 +24,7 @@
12777 */
12778
12779 #include <linux/linkage.h>
12780 +#include <asm/alternative-asm.h>
12781 #include "glue_helper-asm-avx.S"
12782
12783 .file "serpent-avx-x86_64-asm_64.S"
12784 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12785 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12786 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12787
12788 + pax_force_retaddr
12789 ret;
12790 ENDPROC(__serpent_enc_blk8_avx)
12791
12792 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12793 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12794 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12795
12796 + pax_force_retaddr
12797 ret;
12798 ENDPROC(__serpent_dec_blk8_avx)
12799
12800 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12801
12802 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12803
12804 + pax_force_retaddr
12805 ret;
12806 ENDPROC(serpent_ecb_enc_8way_avx)
12807
12808 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12809
12810 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12811
12812 + pax_force_retaddr
12813 ret;
12814 ENDPROC(serpent_ecb_dec_8way_avx)
12815
12816 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12817
12818 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12819
12820 + pax_force_retaddr
12821 ret;
12822 ENDPROC(serpent_cbc_dec_8way_avx)
12823
12824 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12825
12826 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12827
12828 + pax_force_retaddr
12829 ret;
12830 ENDPROC(serpent_ctr_8way_avx)
12831
12832 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12833 /* dst <= regs xor IVs(in dst) */
12834 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12835
12836 + pax_force_retaddr
12837 ret;
12838 ENDPROC(serpent_xts_enc_8way_avx)
12839
12840 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12841 /* dst <= regs xor IVs(in dst) */
12842 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12843
12844 + pax_force_retaddr
12845 ret;
12846 ENDPROC(serpent_xts_dec_8way_avx)
12847 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12848 index b222085..abd483c 100644
12849 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12850 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12851 @@ -15,6 +15,7 @@
12852 */
12853
12854 #include <linux/linkage.h>
12855 +#include <asm/alternative-asm.h>
12856 #include "glue_helper-asm-avx2.S"
12857
12858 .file "serpent-avx2-asm_64.S"
12859 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12860 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12861 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12862
12863 + pax_force_retaddr
12864 ret;
12865 ENDPROC(__serpent_enc_blk16)
12866
12867 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12868 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12869 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12870
12871 + pax_force_retaddr
12872 ret;
12873 ENDPROC(__serpent_dec_blk16)
12874
12875 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12876
12877 vzeroupper;
12878
12879 + pax_force_retaddr
12880 ret;
12881 ENDPROC(serpent_ecb_enc_16way)
12882
12883 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12884
12885 vzeroupper;
12886
12887 + pax_force_retaddr
12888 ret;
12889 ENDPROC(serpent_ecb_dec_16way)
12890
12891 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12892
12893 vzeroupper;
12894
12895 + pax_force_retaddr
12896 ret;
12897 ENDPROC(serpent_cbc_dec_16way)
12898
12899 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12900
12901 vzeroupper;
12902
12903 + pax_force_retaddr
12904 ret;
12905 ENDPROC(serpent_ctr_16way)
12906
12907 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12908
12909 vzeroupper;
12910
12911 + pax_force_retaddr
12912 ret;
12913 ENDPROC(serpent_xts_enc_16way)
12914
12915 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12916
12917 vzeroupper;
12918
12919 + pax_force_retaddr
12920 ret;
12921 ENDPROC(serpent_xts_dec_16way)
12922 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12923 index acc066c..1559cc4 100644
12924 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12925 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12926 @@ -25,6 +25,7 @@
12927 */
12928
12929 #include <linux/linkage.h>
12930 +#include <asm/alternative-asm.h>
12931
12932 .file "serpent-sse2-x86_64-asm_64.S"
12933 .text
12934 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12935 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12936 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12937
12938 + pax_force_retaddr
12939 ret;
12940
12941 .L__enc_xor8:
12942 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12943 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12944
12945 + pax_force_retaddr
12946 ret;
12947 ENDPROC(__serpent_enc_blk_8way)
12948
12949 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12950 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12951 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12952
12953 + pax_force_retaddr
12954 ret;
12955 ENDPROC(serpent_dec_blk_8way)
12956 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12957 index a410950..3356d42 100644
12958 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12959 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12960 @@ -29,6 +29,7 @@
12961 */
12962
12963 #include <linux/linkage.h>
12964 +#include <asm/alternative-asm.h>
12965
12966 #define CTX %rdi // arg1
12967 #define BUF %rsi // arg2
12968 @@ -104,6 +105,7 @@
12969 pop %r12
12970 pop %rbp
12971 pop %rbx
12972 + pax_force_retaddr 0, 1
12973 ret
12974
12975 ENDPROC(\name)
12976 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
12977 index 642f156..4ab07b9 100644
12978 --- a/arch/x86/crypto/sha256-avx-asm.S
12979 +++ b/arch/x86/crypto/sha256-avx-asm.S
12980 @@ -49,6 +49,7 @@
12981
12982 #ifdef CONFIG_AS_AVX
12983 #include <linux/linkage.h>
12984 +#include <asm/alternative-asm.h>
12985
12986 ## assume buffers not aligned
12987 #define VMOVDQ vmovdqu
12988 @@ -460,6 +461,7 @@ done_hash:
12989 popq %r13
12990 popq %rbp
12991 popq %rbx
12992 + pax_force_retaddr 0, 1
12993 ret
12994 ENDPROC(sha256_transform_avx)
12995
12996 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
12997 index 9e86944..2e7f95a 100644
12998 --- a/arch/x86/crypto/sha256-avx2-asm.S
12999 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13000 @@ -50,6 +50,7 @@
13001
13002 #ifdef CONFIG_AS_AVX2
13003 #include <linux/linkage.h>
13004 +#include <asm/alternative-asm.h>
13005
13006 ## assume buffers not aligned
13007 #define VMOVDQ vmovdqu
13008 @@ -720,6 +721,7 @@ done_hash:
13009 popq %r12
13010 popq %rbp
13011 popq %rbx
13012 + pax_force_retaddr 0, 1
13013 ret
13014 ENDPROC(sha256_transform_rorx)
13015
13016 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13017 index f833b74..c36ed14 100644
13018 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13019 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13020 @@ -47,6 +47,7 @@
13021 ########################################################################
13022
13023 #include <linux/linkage.h>
13024 +#include <asm/alternative-asm.h>
13025
13026 ## assume buffers not aligned
13027 #define MOVDQ movdqu
13028 @@ -471,6 +472,7 @@ done_hash:
13029 popq %rbp
13030 popq %rbx
13031
13032 + pax_force_retaddr 0, 1
13033 ret
13034 ENDPROC(sha256_transform_ssse3)
13035
13036 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13037 index 974dde9..4533d34 100644
13038 --- a/arch/x86/crypto/sha512-avx-asm.S
13039 +++ b/arch/x86/crypto/sha512-avx-asm.S
13040 @@ -49,6 +49,7 @@
13041
13042 #ifdef CONFIG_AS_AVX
13043 #include <linux/linkage.h>
13044 +#include <asm/alternative-asm.h>
13045
13046 .text
13047
13048 @@ -364,6 +365,7 @@ updateblock:
13049 mov frame_RSPSAVE(%rsp), %rsp
13050
13051 nowork:
13052 + pax_force_retaddr 0, 1
13053 ret
13054 ENDPROC(sha512_transform_avx)
13055
13056 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13057 index 568b961..061ef1d 100644
13058 --- a/arch/x86/crypto/sha512-avx2-asm.S
13059 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13060 @@ -51,6 +51,7 @@
13061
13062 #ifdef CONFIG_AS_AVX2
13063 #include <linux/linkage.h>
13064 +#include <asm/alternative-asm.h>
13065
13066 .text
13067
13068 @@ -678,6 +679,7 @@ done_hash:
13069
13070 # Restore Stack Pointer
13071 mov frame_RSPSAVE(%rsp), %rsp
13072 + pax_force_retaddr 0, 1
13073 ret
13074 ENDPROC(sha512_transform_rorx)
13075
13076 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13077 index fb56855..e23914f 100644
13078 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13079 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13080 @@ -48,6 +48,7 @@
13081 ########################################################################
13082
13083 #include <linux/linkage.h>
13084 +#include <asm/alternative-asm.h>
13085
13086 .text
13087
13088 @@ -363,6 +364,7 @@ updateblock:
13089 mov frame_RSPSAVE(%rsp), %rsp
13090
13091 nowork:
13092 + pax_force_retaddr 0, 1
13093 ret
13094 ENDPROC(sha512_transform_ssse3)
13095
13096 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13097 index 0505813..63b1d00 100644
13098 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13099 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13100 @@ -24,6 +24,7 @@
13101 */
13102
13103 #include <linux/linkage.h>
13104 +#include <asm/alternative-asm.h>
13105 #include "glue_helper-asm-avx.S"
13106
13107 .file "twofish-avx-x86_64-asm_64.S"
13108 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13109 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13110 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13111
13112 + pax_force_retaddr 0, 1
13113 ret;
13114 ENDPROC(__twofish_enc_blk8)
13115
13116 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13117 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13118 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13119
13120 + pax_force_retaddr 0, 1
13121 ret;
13122 ENDPROC(__twofish_dec_blk8)
13123
13124 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13125
13126 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13127
13128 + pax_force_retaddr 0, 1
13129 ret;
13130 ENDPROC(twofish_ecb_enc_8way)
13131
13132 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13133
13134 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13135
13136 + pax_force_retaddr 0, 1
13137 ret;
13138 ENDPROC(twofish_ecb_dec_8way)
13139
13140 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13141
13142 popq %r12;
13143
13144 + pax_force_retaddr 0, 1
13145 ret;
13146 ENDPROC(twofish_cbc_dec_8way)
13147
13148 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13149
13150 popq %r12;
13151
13152 + pax_force_retaddr 0, 1
13153 ret;
13154 ENDPROC(twofish_ctr_8way)
13155
13156 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13157 /* dst <= regs xor IVs(in dst) */
13158 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13159
13160 + pax_force_retaddr 0, 1
13161 ret;
13162 ENDPROC(twofish_xts_enc_8way)
13163
13164 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13165 /* dst <= regs xor IVs(in dst) */
13166 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13167
13168 + pax_force_retaddr 0, 1
13169 ret;
13170 ENDPROC(twofish_xts_dec_8way)
13171 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13172 index 1c3b7ce..b365c5e 100644
13173 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13174 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13175 @@ -21,6 +21,7 @@
13176 */
13177
13178 #include <linux/linkage.h>
13179 +#include <asm/alternative-asm.h>
13180
13181 .file "twofish-x86_64-asm-3way.S"
13182 .text
13183 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13184 popq %r13;
13185 popq %r14;
13186 popq %r15;
13187 + pax_force_retaddr 0, 1
13188 ret;
13189
13190 .L__enc_xor3:
13191 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13192 popq %r13;
13193 popq %r14;
13194 popq %r15;
13195 + pax_force_retaddr 0, 1
13196 ret;
13197 ENDPROC(__twofish_enc_blk_3way)
13198
13199 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13200 popq %r13;
13201 popq %r14;
13202 popq %r15;
13203 + pax_force_retaddr 0, 1
13204 ret;
13205 ENDPROC(twofish_dec_blk_3way)
13206 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13207 index a039d21..29e7615 100644
13208 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13209 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13210 @@ -22,6 +22,7 @@
13211
13212 #include <linux/linkage.h>
13213 #include <asm/asm-offsets.h>
13214 +#include <asm/alternative-asm.h>
13215
13216 #define a_offset 0
13217 #define b_offset 4
13218 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13219
13220 popq R1
13221 movq $1,%rax
13222 + pax_force_retaddr 0, 1
13223 ret
13224 ENDPROC(twofish_enc_blk)
13225
13226 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13227
13228 popq R1
13229 movq $1,%rax
13230 + pax_force_retaddr 0, 1
13231 ret
13232 ENDPROC(twofish_dec_blk)
13233 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13234 index bae3aba..c1788c1 100644
13235 --- a/arch/x86/ia32/ia32_aout.c
13236 +++ b/arch/x86/ia32/ia32_aout.c
13237 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13238 unsigned long dump_start, dump_size;
13239 struct user32 dump;
13240
13241 + memset(&dump, 0, sizeof(dump));
13242 +
13243 fs = get_fs();
13244 set_fs(KERNEL_DS);
13245 has_dumped = 1;
13246 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13247 index 665a730..8e7a67a 100644
13248 --- a/arch/x86/ia32/ia32_signal.c
13249 +++ b/arch/x86/ia32/ia32_signal.c
13250 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13251 sp -= frame_size;
13252 /* Align the stack pointer according to the i386 ABI,
13253 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13254 - sp = ((sp + 4) & -16ul) - 4;
13255 + sp = ((sp - 12) & -16ul) - 4;
13256 return (void __user *) sp;
13257 }
13258
13259 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13260 * These are actually not used anymore, but left because some
13261 * gdb versions depend on them as a marker.
13262 */
13263 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13264 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13265 } put_user_catch(err);
13266
13267 if (err)
13268 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13269 0xb8,
13270 __NR_ia32_rt_sigreturn,
13271 0x80cd,
13272 - 0,
13273 + 0
13274 };
13275
13276 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13277 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13278
13279 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13280 restorer = ksig->ka.sa.sa_restorer;
13281 + else if (current->mm->context.vdso)
13282 + /* Return stub is in 32bit vsyscall page */
13283 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13284 else
13285 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13286 - rt_sigreturn);
13287 + restorer = &frame->retcode;
13288 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13289
13290 /*
13291 * Not actually used anymore, but left because some gdb
13292 * versions need it.
13293 */
13294 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13295 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13296 } put_user_catch(err);
13297
13298 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13299 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13300 index 474dc1b..9297c58 100644
13301 --- a/arch/x86/ia32/ia32entry.S
13302 +++ b/arch/x86/ia32/ia32entry.S
13303 @@ -15,8 +15,10 @@
13304 #include <asm/irqflags.h>
13305 #include <asm/asm.h>
13306 #include <asm/smap.h>
13307 +#include <asm/pgtable.h>
13308 #include <linux/linkage.h>
13309 #include <linux/err.h>
13310 +#include <asm/alternative-asm.h>
13311
13312 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13313 #include <linux/elf-em.h>
13314 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13315 ENDPROC(native_irq_enable_sysexit)
13316 #endif
13317
13318 + .macro pax_enter_kernel_user
13319 + pax_set_fptr_mask
13320 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13321 + call pax_enter_kernel_user
13322 +#endif
13323 + .endm
13324 +
13325 + .macro pax_exit_kernel_user
13326 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13327 + call pax_exit_kernel_user
13328 +#endif
13329 +#ifdef CONFIG_PAX_RANDKSTACK
13330 + pushq %rax
13331 + pushq %r11
13332 + call pax_randomize_kstack
13333 + popq %r11
13334 + popq %rax
13335 +#endif
13336 + .endm
13337 +
13338 + .macro pax_erase_kstack
13339 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13340 + call pax_erase_kstack
13341 +#endif
13342 + .endm
13343 +
13344 /*
13345 * 32bit SYSENTER instruction entry.
13346 *
13347 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13348 CFI_REGISTER rsp,rbp
13349 SWAPGS_UNSAFE_STACK
13350 movq PER_CPU_VAR(kernel_stack), %rsp
13351 - addq $(KERNEL_STACK_OFFSET),%rsp
13352 - /*
13353 - * No need to follow this irqs on/off section: the syscall
13354 - * disabled irqs, here we enable it straight after entry:
13355 - */
13356 - ENABLE_INTERRUPTS(CLBR_NONE)
13357 movl %ebp,%ebp /* zero extension */
13358 pushq_cfi $__USER32_DS
13359 /*CFI_REL_OFFSET ss,0*/
13360 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13361 CFI_REL_OFFSET rsp,0
13362 pushfq_cfi
13363 /*CFI_REL_OFFSET rflags,0*/
13364 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13365 - CFI_REGISTER rip,r10
13366 + orl $X86_EFLAGS_IF,(%rsp)
13367 + GET_THREAD_INFO(%r11)
13368 + movl TI_sysenter_return(%r11), %r11d
13369 + CFI_REGISTER rip,r11
13370 pushq_cfi $__USER32_CS
13371 /*CFI_REL_OFFSET cs,0*/
13372 movl %eax, %eax
13373 - pushq_cfi %r10
13374 + pushq_cfi %r11
13375 CFI_REL_OFFSET rip,0
13376 pushq_cfi %rax
13377 cld
13378 SAVE_ARGS 0,1,0
13379 + pax_enter_kernel_user
13380 +
13381 +#ifdef CONFIG_PAX_RANDKSTACK
13382 + pax_erase_kstack
13383 +#endif
13384 +
13385 + /*
13386 + * No need to follow this irqs on/off section: the syscall
13387 + * disabled irqs, here we enable it straight after entry:
13388 + */
13389 + ENABLE_INTERRUPTS(CLBR_NONE)
13390 /* no need to do an access_ok check here because rbp has been
13391 32bit zero extended */
13392 +
13393 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13394 + addq pax_user_shadow_base,%rbp
13395 + ASM_PAX_OPEN_USERLAND
13396 +#endif
13397 +
13398 ASM_STAC
13399 1: movl (%rbp),%ebp
13400 _ASM_EXTABLE(1b,ia32_badarg)
13401 ASM_CLAC
13402 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13403 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13404 +
13405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13406 + ASM_PAX_CLOSE_USERLAND
13407 +#endif
13408 +
13409 + GET_THREAD_INFO(%r11)
13410 + orl $TS_COMPAT,TI_status(%r11)
13411 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13412 CFI_REMEMBER_STATE
13413 jnz sysenter_tracesys
13414 cmpq $(IA32_NR_syscalls-1),%rax
13415 @@ -162,12 +209,15 @@ sysenter_do_call:
13416 sysenter_dispatch:
13417 call *ia32_sys_call_table(,%rax,8)
13418 movq %rax,RAX-ARGOFFSET(%rsp)
13419 + GET_THREAD_INFO(%r11)
13420 DISABLE_INTERRUPTS(CLBR_NONE)
13421 TRACE_IRQS_OFF
13422 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13423 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13424 jnz sysexit_audit
13425 sysexit_from_sys_call:
13426 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13427 + pax_exit_kernel_user
13428 + pax_erase_kstack
13429 + andl $~TS_COMPAT,TI_status(%r11)
13430 /* clear IF, that popfq doesn't enable interrupts early */
13431 andl $~0x200,EFLAGS-R11(%rsp)
13432 movl RIP-R11(%rsp),%edx /* User %eip */
13433 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13434 movl %eax,%esi /* 2nd arg: syscall number */
13435 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13436 call __audit_syscall_entry
13437 +
13438 + pax_erase_kstack
13439 +
13440 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13441 cmpq $(IA32_NR_syscalls-1),%rax
13442 ja ia32_badsys
13443 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13444 .endm
13445
13446 .macro auditsys_exit exit
13447 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13448 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13449 jnz ia32_ret_from_sys_call
13450 TRACE_IRQS_ON
13451 ENABLE_INTERRUPTS(CLBR_NONE)
13452 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13453 1: setbe %al /* 1 if error, 0 if not */
13454 movzbl %al,%edi /* zero-extend that into %edi */
13455 call __audit_syscall_exit
13456 + GET_THREAD_INFO(%r11)
13457 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13458 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13459 DISABLE_INTERRUPTS(CLBR_NONE)
13460 TRACE_IRQS_OFF
13461 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13462 + testl %edi,TI_flags(%r11)
13463 jz \exit
13464 CLEAR_RREGS -ARGOFFSET
13465 jmp int_with_check
13466 @@ -237,7 +291,7 @@ sysexit_audit:
13467
13468 sysenter_tracesys:
13469 #ifdef CONFIG_AUDITSYSCALL
13470 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13471 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13472 jz sysenter_auditsys
13473 #endif
13474 SAVE_REST
13475 @@ -249,6 +303,9 @@ sysenter_tracesys:
13476 RESTORE_REST
13477 cmpq $(IA32_NR_syscalls-1),%rax
13478 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13479 +
13480 + pax_erase_kstack
13481 +
13482 jmp sysenter_do_call
13483 CFI_ENDPROC
13484 ENDPROC(ia32_sysenter_target)
13485 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13486 ENTRY(ia32_cstar_target)
13487 CFI_STARTPROC32 simple
13488 CFI_SIGNAL_FRAME
13489 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13490 + CFI_DEF_CFA rsp,0
13491 CFI_REGISTER rip,rcx
13492 /*CFI_REGISTER rflags,r11*/
13493 SWAPGS_UNSAFE_STACK
13494 movl %esp,%r8d
13495 CFI_REGISTER rsp,r8
13496 movq PER_CPU_VAR(kernel_stack),%rsp
13497 + SAVE_ARGS 8*6,0,0
13498 + pax_enter_kernel_user
13499 +
13500 +#ifdef CONFIG_PAX_RANDKSTACK
13501 + pax_erase_kstack
13502 +#endif
13503 +
13504 /*
13505 * No need to follow this irqs on/off section: the syscall
13506 * disabled irqs and here we enable it straight after entry:
13507 */
13508 ENABLE_INTERRUPTS(CLBR_NONE)
13509 - SAVE_ARGS 8,0,0
13510 movl %eax,%eax /* zero extension */
13511 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13512 movq %rcx,RIP-ARGOFFSET(%rsp)
13513 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13514 /* no need to do an access_ok check here because r8 has been
13515 32bit zero extended */
13516 /* hardware stack frame is complete now */
13517 +
13518 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13519 + ASM_PAX_OPEN_USERLAND
13520 + movq pax_user_shadow_base,%r8
13521 + addq RSP-ARGOFFSET(%rsp),%r8
13522 +#endif
13523 +
13524 ASM_STAC
13525 1: movl (%r8),%r9d
13526 _ASM_EXTABLE(1b,ia32_badarg)
13527 ASM_CLAC
13528 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13529 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13530 +
13531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13532 + ASM_PAX_CLOSE_USERLAND
13533 +#endif
13534 +
13535 + GET_THREAD_INFO(%r11)
13536 + orl $TS_COMPAT,TI_status(%r11)
13537 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13538 CFI_REMEMBER_STATE
13539 jnz cstar_tracesys
13540 cmpq $IA32_NR_syscalls-1,%rax
13541 @@ -319,12 +395,15 @@ cstar_do_call:
13542 cstar_dispatch:
13543 call *ia32_sys_call_table(,%rax,8)
13544 movq %rax,RAX-ARGOFFSET(%rsp)
13545 + GET_THREAD_INFO(%r11)
13546 DISABLE_INTERRUPTS(CLBR_NONE)
13547 TRACE_IRQS_OFF
13548 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13549 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13550 jnz sysretl_audit
13551 sysretl_from_sys_call:
13552 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13553 + pax_exit_kernel_user
13554 + pax_erase_kstack
13555 + andl $~TS_COMPAT,TI_status(%r11)
13556 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13557 movl RIP-ARGOFFSET(%rsp),%ecx
13558 CFI_REGISTER rip,rcx
13559 @@ -352,7 +431,7 @@ sysretl_audit:
13560
13561 cstar_tracesys:
13562 #ifdef CONFIG_AUDITSYSCALL
13563 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13564 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13565 jz cstar_auditsys
13566 #endif
13567 xchgl %r9d,%ebp
13568 @@ -366,11 +445,19 @@ cstar_tracesys:
13569 xchgl %ebp,%r9d
13570 cmpq $(IA32_NR_syscalls-1),%rax
13571 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13572 +
13573 + pax_erase_kstack
13574 +
13575 jmp cstar_do_call
13576 END(ia32_cstar_target)
13577
13578 ia32_badarg:
13579 ASM_CLAC
13580 +
13581 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13582 + ASM_PAX_CLOSE_USERLAND
13583 +#endif
13584 +
13585 movq $-EFAULT,%rax
13586 jmp ia32_sysret
13587 CFI_ENDPROC
13588 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13589 CFI_REL_OFFSET rip,RIP-RIP
13590 PARAVIRT_ADJUST_EXCEPTION_FRAME
13591 SWAPGS
13592 - /*
13593 - * No need to follow this irqs on/off section: the syscall
13594 - * disabled irqs and here we enable it straight after entry:
13595 - */
13596 - ENABLE_INTERRUPTS(CLBR_NONE)
13597 movl %eax,%eax
13598 pushq_cfi %rax
13599 cld
13600 /* note the registers are not zero extended to the sf.
13601 this could be a problem. */
13602 SAVE_ARGS 0,1,0
13603 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13604 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13605 + pax_enter_kernel_user
13606 +
13607 +#ifdef CONFIG_PAX_RANDKSTACK
13608 + pax_erase_kstack
13609 +#endif
13610 +
13611 + /*
13612 + * No need to follow this irqs on/off section: the syscall
13613 + * disabled irqs and here we enable it straight after entry:
13614 + */
13615 + ENABLE_INTERRUPTS(CLBR_NONE)
13616 + GET_THREAD_INFO(%r11)
13617 + orl $TS_COMPAT,TI_status(%r11)
13618 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13619 jnz ia32_tracesys
13620 cmpq $(IA32_NR_syscalls-1),%rax
13621 ja ia32_badsys
13622 @@ -442,6 +536,9 @@ ia32_tracesys:
13623 RESTORE_REST
13624 cmpq $(IA32_NR_syscalls-1),%rax
13625 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13626 +
13627 + pax_erase_kstack
13628 +
13629 jmp ia32_do_call
13630 END(ia32_syscall)
13631
13632 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13633 index 8e0ceec..af13504 100644
13634 --- a/arch/x86/ia32/sys_ia32.c
13635 +++ b/arch/x86/ia32/sys_ia32.c
13636 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13637 */
13638 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13639 {
13640 - typeof(ubuf->st_uid) uid = 0;
13641 - typeof(ubuf->st_gid) gid = 0;
13642 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13643 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13644 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13645 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13646 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13647 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13648 index 372231c..a5aa1a1 100644
13649 --- a/arch/x86/include/asm/alternative-asm.h
13650 +++ b/arch/x86/include/asm/alternative-asm.h
13651 @@ -18,6 +18,45 @@
13652 .endm
13653 #endif
13654
13655 +#ifdef KERNEXEC_PLUGIN
13656 + .macro pax_force_retaddr_bts rip=0
13657 + btsq $63,\rip(%rsp)
13658 + .endm
13659 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13660 + .macro pax_force_retaddr rip=0, reload=0
13661 + btsq $63,\rip(%rsp)
13662 + .endm
13663 + .macro pax_force_fptr ptr
13664 + btsq $63,\ptr
13665 + .endm
13666 + .macro pax_set_fptr_mask
13667 + .endm
13668 +#endif
13669 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13670 + .macro pax_force_retaddr rip=0, reload=0
13671 + .if \reload
13672 + pax_set_fptr_mask
13673 + .endif
13674 + orq %r10,\rip(%rsp)
13675 + .endm
13676 + .macro pax_force_fptr ptr
13677 + orq %r10,\ptr
13678 + .endm
13679 + .macro pax_set_fptr_mask
13680 + movabs $0x8000000000000000,%r10
13681 + .endm
13682 +#endif
13683 +#else
13684 + .macro pax_force_retaddr rip=0, reload=0
13685 + .endm
13686 + .macro pax_force_fptr ptr
13687 + .endm
13688 + .macro pax_force_retaddr_bts rip=0
13689 + .endm
13690 + .macro pax_set_fptr_mask
13691 + .endm
13692 +#endif
13693 +
13694 .macro altinstruction_entry orig alt feature orig_len alt_len
13695 .long \orig - .
13696 .long \alt - .
13697 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13698 index 58ed6d9..f1cbe58 100644
13699 --- a/arch/x86/include/asm/alternative.h
13700 +++ b/arch/x86/include/asm/alternative.h
13701 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13702 ".pushsection .discard,\"aw\",@progbits\n" \
13703 DISCARD_ENTRY(1) \
13704 ".popsection\n" \
13705 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13706 + ".pushsection .altinstr_replacement, \"a\"\n" \
13707 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13708 ".popsection"
13709
13710 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13711 DISCARD_ENTRY(1) \
13712 DISCARD_ENTRY(2) \
13713 ".popsection\n" \
13714 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13715 + ".pushsection .altinstr_replacement, \"a\"\n" \
13716 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13717 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13718 ".popsection"
13719 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13720 index f8119b5..7209d5b 100644
13721 --- a/arch/x86/include/asm/apic.h
13722 +++ b/arch/x86/include/asm/apic.h
13723 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13724
13725 #ifdef CONFIG_X86_LOCAL_APIC
13726
13727 -extern unsigned int apic_verbosity;
13728 +extern int apic_verbosity;
13729 extern int local_apic_timer_c2_ok;
13730
13731 extern int disable_apic;
13732 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13733 index 20370c6..a2eb9b0 100644
13734 --- a/arch/x86/include/asm/apm.h
13735 +++ b/arch/x86/include/asm/apm.h
13736 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13737 __asm__ __volatile__(APM_DO_ZERO_SEGS
13738 "pushl %%edi\n\t"
13739 "pushl %%ebp\n\t"
13740 - "lcall *%%cs:apm_bios_entry\n\t"
13741 + "lcall *%%ss:apm_bios_entry\n\t"
13742 "setc %%al\n\t"
13743 "popl %%ebp\n\t"
13744 "popl %%edi\n\t"
13745 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13746 __asm__ __volatile__(APM_DO_ZERO_SEGS
13747 "pushl %%edi\n\t"
13748 "pushl %%ebp\n\t"
13749 - "lcall *%%cs:apm_bios_entry\n\t"
13750 + "lcall *%%ss:apm_bios_entry\n\t"
13751 "setc %%bl\n\t"
13752 "popl %%ebp\n\t"
13753 "popl %%edi\n\t"
13754 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13755 index 722aa3b..3a0bb27 100644
13756 --- a/arch/x86/include/asm/atomic.h
13757 +++ b/arch/x86/include/asm/atomic.h
13758 @@ -22,7 +22,18 @@
13759 */
13760 static inline int atomic_read(const atomic_t *v)
13761 {
13762 - return (*(volatile int *)&(v)->counter);
13763 + return (*(volatile const int *)&(v)->counter);
13764 +}
13765 +
13766 +/**
13767 + * atomic_read_unchecked - read atomic variable
13768 + * @v: pointer of type atomic_unchecked_t
13769 + *
13770 + * Atomically reads the value of @v.
13771 + */
13772 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13773 +{
13774 + return (*(volatile const int *)&(v)->counter);
13775 }
13776
13777 /**
13778 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13779 }
13780
13781 /**
13782 + * atomic_set_unchecked - set atomic variable
13783 + * @v: pointer of type atomic_unchecked_t
13784 + * @i: required value
13785 + *
13786 + * Atomically sets the value of @v to @i.
13787 + */
13788 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13789 +{
13790 + v->counter = i;
13791 +}
13792 +
13793 +/**
13794 * atomic_add - add integer to atomic variable
13795 * @i: integer value to add
13796 * @v: pointer of type atomic_t
13797 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13798 */
13799 static inline void atomic_add(int i, atomic_t *v)
13800 {
13801 - asm volatile(LOCK_PREFIX "addl %1,%0"
13802 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13803 +
13804 +#ifdef CONFIG_PAX_REFCOUNT
13805 + "jno 0f\n"
13806 + LOCK_PREFIX "subl %1,%0\n"
13807 + "int $4\n0:\n"
13808 + _ASM_EXTABLE(0b, 0b)
13809 +#endif
13810 +
13811 + : "+m" (v->counter)
13812 + : "ir" (i));
13813 +}
13814 +
13815 +/**
13816 + * atomic_add_unchecked - add integer to atomic variable
13817 + * @i: integer value to add
13818 + * @v: pointer of type atomic_unchecked_t
13819 + *
13820 + * Atomically adds @i to @v.
13821 + */
13822 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13823 +{
13824 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13825 : "+m" (v->counter)
13826 : "ir" (i));
13827 }
13828 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13829 */
13830 static inline void atomic_sub(int i, atomic_t *v)
13831 {
13832 - asm volatile(LOCK_PREFIX "subl %1,%0"
13833 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13834 +
13835 +#ifdef CONFIG_PAX_REFCOUNT
13836 + "jno 0f\n"
13837 + LOCK_PREFIX "addl %1,%0\n"
13838 + "int $4\n0:\n"
13839 + _ASM_EXTABLE(0b, 0b)
13840 +#endif
13841 +
13842 + : "+m" (v->counter)
13843 + : "ir" (i));
13844 +}
13845 +
13846 +/**
13847 + * atomic_sub_unchecked - subtract integer from atomic variable
13848 + * @i: integer value to subtract
13849 + * @v: pointer of type atomic_unchecked_t
13850 + *
13851 + * Atomically subtracts @i from @v.
13852 + */
13853 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13854 +{
13855 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13856 : "+m" (v->counter)
13857 : "ir" (i));
13858 }
13859 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13860 {
13861 unsigned char c;
13862
13863 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13864 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13865 +
13866 +#ifdef CONFIG_PAX_REFCOUNT
13867 + "jno 0f\n"
13868 + LOCK_PREFIX "addl %2,%0\n"
13869 + "int $4\n0:\n"
13870 + _ASM_EXTABLE(0b, 0b)
13871 +#endif
13872 +
13873 + "sete %1\n"
13874 : "+m" (v->counter), "=qm" (c)
13875 : "ir" (i) : "memory");
13876 return c;
13877 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13878 */
13879 static inline void atomic_inc(atomic_t *v)
13880 {
13881 - asm volatile(LOCK_PREFIX "incl %0"
13882 + asm volatile(LOCK_PREFIX "incl %0\n"
13883 +
13884 +#ifdef CONFIG_PAX_REFCOUNT
13885 + "jno 0f\n"
13886 + LOCK_PREFIX "decl %0\n"
13887 + "int $4\n0:\n"
13888 + _ASM_EXTABLE(0b, 0b)
13889 +#endif
13890 +
13891 + : "+m" (v->counter));
13892 +}
13893 +
13894 +/**
13895 + * atomic_inc_unchecked - increment atomic variable
13896 + * @v: pointer of type atomic_unchecked_t
13897 + *
13898 + * Atomically increments @v by 1.
13899 + */
13900 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13901 +{
13902 + asm volatile(LOCK_PREFIX "incl %0\n"
13903 : "+m" (v->counter));
13904 }
13905
13906 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13907 */
13908 static inline void atomic_dec(atomic_t *v)
13909 {
13910 - asm volatile(LOCK_PREFIX "decl %0"
13911 + asm volatile(LOCK_PREFIX "decl %0\n"
13912 +
13913 +#ifdef CONFIG_PAX_REFCOUNT
13914 + "jno 0f\n"
13915 + LOCK_PREFIX "incl %0\n"
13916 + "int $4\n0:\n"
13917 + _ASM_EXTABLE(0b, 0b)
13918 +#endif
13919 +
13920 + : "+m" (v->counter));
13921 +}
13922 +
13923 +/**
13924 + * atomic_dec_unchecked - decrement atomic variable
13925 + * @v: pointer of type atomic_unchecked_t
13926 + *
13927 + * Atomically decrements @v by 1.
13928 + */
13929 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13930 +{
13931 + asm volatile(LOCK_PREFIX "decl %0\n"
13932 : "+m" (v->counter));
13933 }
13934
13935 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13936 {
13937 unsigned char c;
13938
13939 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13940 + asm volatile(LOCK_PREFIX "decl %0\n"
13941 +
13942 +#ifdef CONFIG_PAX_REFCOUNT
13943 + "jno 0f\n"
13944 + LOCK_PREFIX "incl %0\n"
13945 + "int $4\n0:\n"
13946 + _ASM_EXTABLE(0b, 0b)
13947 +#endif
13948 +
13949 + "sete %1\n"
13950 : "+m" (v->counter), "=qm" (c)
13951 : : "memory");
13952 return c != 0;
13953 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13954 {
13955 unsigned char c;
13956
13957 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13958 + asm volatile(LOCK_PREFIX "incl %0\n"
13959 +
13960 +#ifdef CONFIG_PAX_REFCOUNT
13961 + "jno 0f\n"
13962 + LOCK_PREFIX "decl %0\n"
13963 + "int $4\n0:\n"
13964 + _ASM_EXTABLE(0b, 0b)
13965 +#endif
13966 +
13967 + "sete %1\n"
13968 + : "+m" (v->counter), "=qm" (c)
13969 + : : "memory");
13970 + return c != 0;
13971 +}
13972 +
13973 +/**
13974 + * atomic_inc_and_test_unchecked - increment and test
13975 + * @v: pointer of type atomic_unchecked_t
13976 + *
13977 + * Atomically increments @v by 1
13978 + * and returns true if the result is zero, or false for all
13979 + * other cases.
13980 + */
13981 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
13982 +{
13983 + unsigned char c;
13984 +
13985 + asm volatile(LOCK_PREFIX "incl %0\n"
13986 + "sete %1\n"
13987 : "+m" (v->counter), "=qm" (c)
13988 : : "memory");
13989 return c != 0;
13990 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13991 {
13992 unsigned char c;
13993
13994 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
13995 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
13996 +
13997 +#ifdef CONFIG_PAX_REFCOUNT
13998 + "jno 0f\n"
13999 + LOCK_PREFIX "subl %2,%0\n"
14000 + "int $4\n0:\n"
14001 + _ASM_EXTABLE(0b, 0b)
14002 +#endif
14003 +
14004 + "sets %1\n"
14005 : "+m" (v->counter), "=qm" (c)
14006 : "ir" (i) : "memory");
14007 return c;
14008 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14009 */
14010 static inline int atomic_add_return(int i, atomic_t *v)
14011 {
14012 + return i + xadd_check_overflow(&v->counter, i);
14013 +}
14014 +
14015 +/**
14016 + * atomic_add_return_unchecked - add integer and return
14017 + * @i: integer value to add
14018 + * @v: pointer of type atomic_unchecked_t
14019 + *
14020 + * Atomically adds @i to @v and returns @i + @v
14021 + */
14022 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14023 +{
14024 return i + xadd(&v->counter, i);
14025 }
14026
14027 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14028 }
14029
14030 #define atomic_inc_return(v) (atomic_add_return(1, v))
14031 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14032 +{
14033 + return atomic_add_return_unchecked(1, v);
14034 +}
14035 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14036
14037 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14038 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14039 return cmpxchg(&v->counter, old, new);
14040 }
14041
14042 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14043 +{
14044 + return cmpxchg(&v->counter, old, new);
14045 +}
14046 +
14047 static inline int atomic_xchg(atomic_t *v, int new)
14048 {
14049 return xchg(&v->counter, new);
14050 }
14051
14052 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14053 +{
14054 + return xchg(&v->counter, new);
14055 +}
14056 +
14057 /**
14058 * __atomic_add_unless - add unless the number is already a given value
14059 * @v: pointer of type atomic_t
14060 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14061 */
14062 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14063 {
14064 - int c, old;
14065 + int c, old, new;
14066 c = atomic_read(v);
14067 for (;;) {
14068 - if (unlikely(c == (u)))
14069 + if (unlikely(c == u))
14070 break;
14071 - old = atomic_cmpxchg((v), c, c + (a));
14072 +
14073 + asm volatile("addl %2,%0\n"
14074 +
14075 +#ifdef CONFIG_PAX_REFCOUNT
14076 + "jno 0f\n"
14077 + "subl %2,%0\n"
14078 + "int $4\n0:\n"
14079 + _ASM_EXTABLE(0b, 0b)
14080 +#endif
14081 +
14082 + : "=r" (new)
14083 + : "0" (c), "ir" (a));
14084 +
14085 + old = atomic_cmpxchg(v, c, new);
14086 if (likely(old == c))
14087 break;
14088 c = old;
14089 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14090 }
14091
14092 /**
14093 + * atomic_inc_not_zero_hint - increment if not null
14094 + * @v: pointer of type atomic_t
14095 + * @hint: probable value of the atomic before the increment
14096 + *
14097 + * This version of atomic_inc_not_zero() gives a hint of probable
14098 + * value of the atomic. This helps processor to not read the memory
14099 + * before doing the atomic read/modify/write cycle, lowering
14100 + * number of bus transactions on some arches.
14101 + *
14102 + * Returns: 0 if increment was not done, 1 otherwise.
14103 + */
14104 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14105 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14106 +{
14107 + int val, c = hint, new;
14108 +
14109 + /* sanity test, should be removed by compiler if hint is a constant */
14110 + if (!hint)
14111 + return __atomic_add_unless(v, 1, 0);
14112 +
14113 + do {
14114 + asm volatile("incl %0\n"
14115 +
14116 +#ifdef CONFIG_PAX_REFCOUNT
14117 + "jno 0f\n"
14118 + "decl %0\n"
14119 + "int $4\n0:\n"
14120 + _ASM_EXTABLE(0b, 0b)
14121 +#endif
14122 +
14123 + : "=r" (new)
14124 + : "0" (c));
14125 +
14126 + val = atomic_cmpxchg(v, c, new);
14127 + if (val == c)
14128 + return 1;
14129 + c = val;
14130 + } while (c);
14131 +
14132 + return 0;
14133 +}
14134 +
14135 +/**
14136 * atomic_inc_short - increment of a short integer
14137 * @v: pointer to type int
14138 *
14139 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14140 #endif
14141
14142 /* These are x86-specific, used by some header files */
14143 -#define atomic_clear_mask(mask, addr) \
14144 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14145 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14146 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14147 +{
14148 + asm volatile(LOCK_PREFIX "andl %1,%0"
14149 + : "+m" (v->counter)
14150 + : "r" (~(mask))
14151 + : "memory");
14152 +}
14153
14154 -#define atomic_set_mask(mask, addr) \
14155 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14156 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14157 - : "memory")
14158 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14159 +{
14160 + asm volatile(LOCK_PREFIX "andl %1,%0"
14161 + : "+m" (v->counter)
14162 + : "r" (~(mask))
14163 + : "memory");
14164 +}
14165 +
14166 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14167 +{
14168 + asm volatile(LOCK_PREFIX "orl %1,%0"
14169 + : "+m" (v->counter)
14170 + : "r" (mask)
14171 + : "memory");
14172 +}
14173 +
14174 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14175 +{
14176 + asm volatile(LOCK_PREFIX "orl %1,%0"
14177 + : "+m" (v->counter)
14178 + : "r" (mask)
14179 + : "memory");
14180 +}
14181
14182 /* Atomic operations are already serializing on x86 */
14183 #define smp_mb__before_atomic_dec() barrier()
14184 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14185 index b154de7..aadebd8 100644
14186 --- a/arch/x86/include/asm/atomic64_32.h
14187 +++ b/arch/x86/include/asm/atomic64_32.h
14188 @@ -12,6 +12,14 @@ typedef struct {
14189 u64 __aligned(8) counter;
14190 } atomic64_t;
14191
14192 +#ifdef CONFIG_PAX_REFCOUNT
14193 +typedef struct {
14194 + u64 __aligned(8) counter;
14195 +} atomic64_unchecked_t;
14196 +#else
14197 +typedef atomic64_t atomic64_unchecked_t;
14198 +#endif
14199 +
14200 #define ATOMIC64_INIT(val) { (val) }
14201
14202 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14203 @@ -37,21 +45,31 @@ typedef struct {
14204 ATOMIC64_DECL_ONE(sym##_386)
14205
14206 ATOMIC64_DECL_ONE(add_386);
14207 +ATOMIC64_DECL_ONE(add_unchecked_386);
14208 ATOMIC64_DECL_ONE(sub_386);
14209 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14210 ATOMIC64_DECL_ONE(inc_386);
14211 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14212 ATOMIC64_DECL_ONE(dec_386);
14213 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14214 #endif
14215
14216 #define alternative_atomic64(f, out, in...) \
14217 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14218
14219 ATOMIC64_DECL(read);
14220 +ATOMIC64_DECL(read_unchecked);
14221 ATOMIC64_DECL(set);
14222 +ATOMIC64_DECL(set_unchecked);
14223 ATOMIC64_DECL(xchg);
14224 ATOMIC64_DECL(add_return);
14225 +ATOMIC64_DECL(add_return_unchecked);
14226 ATOMIC64_DECL(sub_return);
14227 +ATOMIC64_DECL(sub_return_unchecked);
14228 ATOMIC64_DECL(inc_return);
14229 +ATOMIC64_DECL(inc_return_unchecked);
14230 ATOMIC64_DECL(dec_return);
14231 +ATOMIC64_DECL(dec_return_unchecked);
14232 ATOMIC64_DECL(dec_if_positive);
14233 ATOMIC64_DECL(inc_not_zero);
14234 ATOMIC64_DECL(add_unless);
14235 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14236 }
14237
14238 /**
14239 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14240 + * @p: pointer to type atomic64_unchecked_t
14241 + * @o: expected value
14242 + * @n: new value
14243 + *
14244 + * Atomically sets @v to @n if it was equal to @o and returns
14245 + * the old value.
14246 + */
14247 +
14248 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14249 +{
14250 + return cmpxchg64(&v->counter, o, n);
14251 +}
14252 +
14253 +/**
14254 * atomic64_xchg - xchg atomic64 variable
14255 * @v: pointer to type atomic64_t
14256 * @n: value to assign
14257 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14258 }
14259
14260 /**
14261 + * atomic64_set_unchecked - set atomic64 variable
14262 + * @v: pointer to type atomic64_unchecked_t
14263 + * @n: value to assign
14264 + *
14265 + * Atomically sets the value of @v to @n.
14266 + */
14267 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14268 +{
14269 + unsigned high = (unsigned)(i >> 32);
14270 + unsigned low = (unsigned)i;
14271 + alternative_atomic64(set, /* no output */,
14272 + "S" (v), "b" (low), "c" (high)
14273 + : "eax", "edx", "memory");
14274 +}
14275 +
14276 +/**
14277 * atomic64_read - read atomic64 variable
14278 * @v: pointer to type atomic64_t
14279 *
14280 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14281 }
14282
14283 /**
14284 + * atomic64_read_unchecked - read atomic64 variable
14285 + * @v: pointer to type atomic64_unchecked_t
14286 + *
14287 + * Atomically reads the value of @v and returns it.
14288 + */
14289 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14290 +{
14291 + long long r;
14292 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14293 + return r;
14294 + }
14295 +
14296 +/**
14297 * atomic64_add_return - add and return
14298 * @i: integer value to add
14299 * @v: pointer to type atomic64_t
14300 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14301 return i;
14302 }
14303
14304 +/**
14305 + * atomic64_add_return_unchecked - add and return
14306 + * @i: integer value to add
14307 + * @v: pointer to type atomic64_unchecked_t
14308 + *
14309 + * Atomically adds @i to @v and returns @i + *@v
14310 + */
14311 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14312 +{
14313 + alternative_atomic64(add_return_unchecked,
14314 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14315 + ASM_NO_INPUT_CLOBBER("memory"));
14316 + return i;
14317 +}
14318 +
14319 /*
14320 * Other variants with different arithmetic operators:
14321 */
14322 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14323 return a;
14324 }
14325
14326 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14327 +{
14328 + long long a;
14329 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14330 + "S" (v) : "memory", "ecx");
14331 + return a;
14332 +}
14333 +
14334 static inline long long atomic64_dec_return(atomic64_t *v)
14335 {
14336 long long a;
14337 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14338 }
14339
14340 /**
14341 + * atomic64_add_unchecked - add integer to atomic64 variable
14342 + * @i: integer value to add
14343 + * @v: pointer to type atomic64_unchecked_t
14344 + *
14345 + * Atomically adds @i to @v.
14346 + */
14347 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14348 +{
14349 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14350 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14351 + ASM_NO_INPUT_CLOBBER("memory"));
14352 + return i;
14353 +}
14354 +
14355 +/**
14356 * atomic64_sub - subtract the atomic64 variable
14357 * @i: integer value to subtract
14358 * @v: pointer to type atomic64_t
14359 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14360 index 0e1cbfc..5623683 100644
14361 --- a/arch/x86/include/asm/atomic64_64.h
14362 +++ b/arch/x86/include/asm/atomic64_64.h
14363 @@ -18,7 +18,19 @@
14364 */
14365 static inline long atomic64_read(const atomic64_t *v)
14366 {
14367 - return (*(volatile long *)&(v)->counter);
14368 + return (*(volatile const long *)&(v)->counter);
14369 +}
14370 +
14371 +/**
14372 + * atomic64_read_unchecked - read atomic64 variable
14373 + * @v: pointer of type atomic64_unchecked_t
14374 + *
14375 + * Atomically reads the value of @v.
14376 + * Doesn't imply a read memory barrier.
14377 + */
14378 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14379 +{
14380 + return (*(volatile const long *)&(v)->counter);
14381 }
14382
14383 /**
14384 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14385 }
14386
14387 /**
14388 + * atomic64_set_unchecked - set atomic64 variable
14389 + * @v: pointer to type atomic64_unchecked_t
14390 + * @i: required value
14391 + *
14392 + * Atomically sets the value of @v to @i.
14393 + */
14394 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14395 +{
14396 + v->counter = i;
14397 +}
14398 +
14399 +/**
14400 * atomic64_add - add integer to atomic64 variable
14401 * @i: integer value to add
14402 * @v: pointer to type atomic64_t
14403 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14404 */
14405 static inline void atomic64_add(long i, atomic64_t *v)
14406 {
14407 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14408 +
14409 +#ifdef CONFIG_PAX_REFCOUNT
14410 + "jno 0f\n"
14411 + LOCK_PREFIX "subq %1,%0\n"
14412 + "int $4\n0:\n"
14413 + _ASM_EXTABLE(0b, 0b)
14414 +#endif
14415 +
14416 + : "=m" (v->counter)
14417 + : "er" (i), "m" (v->counter));
14418 +}
14419 +
14420 +/**
14421 + * atomic64_add_unchecked - add integer to atomic64 variable
14422 + * @i: integer value to add
14423 + * @v: pointer to type atomic64_unchecked_t
14424 + *
14425 + * Atomically adds @i to @v.
14426 + */
14427 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14428 +{
14429 asm volatile(LOCK_PREFIX "addq %1,%0"
14430 : "=m" (v->counter)
14431 : "er" (i), "m" (v->counter));
14432 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14433 */
14434 static inline void atomic64_sub(long i, atomic64_t *v)
14435 {
14436 - asm volatile(LOCK_PREFIX "subq %1,%0"
14437 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14438 +
14439 +#ifdef CONFIG_PAX_REFCOUNT
14440 + "jno 0f\n"
14441 + LOCK_PREFIX "addq %1,%0\n"
14442 + "int $4\n0:\n"
14443 + _ASM_EXTABLE(0b, 0b)
14444 +#endif
14445 +
14446 + : "=m" (v->counter)
14447 + : "er" (i), "m" (v->counter));
14448 +}
14449 +
14450 +/**
14451 + * atomic64_sub_unchecked - subtract the atomic64 variable
14452 + * @i: integer value to subtract
14453 + * @v: pointer to type atomic64_unchecked_t
14454 + *
14455 + * Atomically subtracts @i from @v.
14456 + */
14457 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14458 +{
14459 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14460 : "=m" (v->counter)
14461 : "er" (i), "m" (v->counter));
14462 }
14463 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14464 {
14465 unsigned char c;
14466
14467 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14468 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14469 +
14470 +#ifdef CONFIG_PAX_REFCOUNT
14471 + "jno 0f\n"
14472 + LOCK_PREFIX "addq %2,%0\n"
14473 + "int $4\n0:\n"
14474 + _ASM_EXTABLE(0b, 0b)
14475 +#endif
14476 +
14477 + "sete %1\n"
14478 : "=m" (v->counter), "=qm" (c)
14479 : "er" (i), "m" (v->counter) : "memory");
14480 return c;
14481 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14482 */
14483 static inline void atomic64_inc(atomic64_t *v)
14484 {
14485 + asm volatile(LOCK_PREFIX "incq %0\n"
14486 +
14487 +#ifdef CONFIG_PAX_REFCOUNT
14488 + "jno 0f\n"
14489 + LOCK_PREFIX "decq %0\n"
14490 + "int $4\n0:\n"
14491 + _ASM_EXTABLE(0b, 0b)
14492 +#endif
14493 +
14494 + : "=m" (v->counter)
14495 + : "m" (v->counter));
14496 +}
14497 +
14498 +/**
14499 + * atomic64_inc_unchecked - increment atomic64 variable
14500 + * @v: pointer to type atomic64_unchecked_t
14501 + *
14502 + * Atomically increments @v by 1.
14503 + */
14504 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14505 +{
14506 asm volatile(LOCK_PREFIX "incq %0"
14507 : "=m" (v->counter)
14508 : "m" (v->counter));
14509 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14510 */
14511 static inline void atomic64_dec(atomic64_t *v)
14512 {
14513 - asm volatile(LOCK_PREFIX "decq %0"
14514 + asm volatile(LOCK_PREFIX "decq %0\n"
14515 +
14516 +#ifdef CONFIG_PAX_REFCOUNT
14517 + "jno 0f\n"
14518 + LOCK_PREFIX "incq %0\n"
14519 + "int $4\n0:\n"
14520 + _ASM_EXTABLE(0b, 0b)
14521 +#endif
14522 +
14523 + : "=m" (v->counter)
14524 + : "m" (v->counter));
14525 +}
14526 +
14527 +/**
14528 + * atomic64_dec_unchecked - decrement atomic64 variable
14529 + * @v: pointer to type atomic64_t
14530 + *
14531 + * Atomically decrements @v by 1.
14532 + */
14533 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14534 +{
14535 + asm volatile(LOCK_PREFIX "decq %0\n"
14536 : "=m" (v->counter)
14537 : "m" (v->counter));
14538 }
14539 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14540 {
14541 unsigned char c;
14542
14543 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14544 + asm volatile(LOCK_PREFIX "decq %0\n"
14545 +
14546 +#ifdef CONFIG_PAX_REFCOUNT
14547 + "jno 0f\n"
14548 + LOCK_PREFIX "incq %0\n"
14549 + "int $4\n0:\n"
14550 + _ASM_EXTABLE(0b, 0b)
14551 +#endif
14552 +
14553 + "sete %1\n"
14554 : "=m" (v->counter), "=qm" (c)
14555 : "m" (v->counter) : "memory");
14556 return c != 0;
14557 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14558 {
14559 unsigned char c;
14560
14561 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14562 + asm volatile(LOCK_PREFIX "incq %0\n"
14563 +
14564 +#ifdef CONFIG_PAX_REFCOUNT
14565 + "jno 0f\n"
14566 + LOCK_PREFIX "decq %0\n"
14567 + "int $4\n0:\n"
14568 + _ASM_EXTABLE(0b, 0b)
14569 +#endif
14570 +
14571 + "sete %1\n"
14572 : "=m" (v->counter), "=qm" (c)
14573 : "m" (v->counter) : "memory");
14574 return c != 0;
14575 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14576 {
14577 unsigned char c;
14578
14579 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14580 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14581 +
14582 +#ifdef CONFIG_PAX_REFCOUNT
14583 + "jno 0f\n"
14584 + LOCK_PREFIX "subq %2,%0\n"
14585 + "int $4\n0:\n"
14586 + _ASM_EXTABLE(0b, 0b)
14587 +#endif
14588 +
14589 + "sets %1\n"
14590 : "=m" (v->counter), "=qm" (c)
14591 : "er" (i), "m" (v->counter) : "memory");
14592 return c;
14593 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14594 */
14595 static inline long atomic64_add_return(long i, atomic64_t *v)
14596 {
14597 + return i + xadd_check_overflow(&v->counter, i);
14598 +}
14599 +
14600 +/**
14601 + * atomic64_add_return_unchecked - add and return
14602 + * @i: integer value to add
14603 + * @v: pointer to type atomic64_unchecked_t
14604 + *
14605 + * Atomically adds @i to @v and returns @i + @v
14606 + */
14607 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14608 +{
14609 return i + xadd(&v->counter, i);
14610 }
14611
14612 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14613 }
14614
14615 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14616 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14617 +{
14618 + return atomic64_add_return_unchecked(1, v);
14619 +}
14620 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14621
14622 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14623 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14624 return cmpxchg(&v->counter, old, new);
14625 }
14626
14627 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14628 +{
14629 + return cmpxchg(&v->counter, old, new);
14630 +}
14631 +
14632 static inline long atomic64_xchg(atomic64_t *v, long new)
14633 {
14634 return xchg(&v->counter, new);
14635 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14636 */
14637 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14638 {
14639 - long c, old;
14640 + long c, old, new;
14641 c = atomic64_read(v);
14642 for (;;) {
14643 - if (unlikely(c == (u)))
14644 + if (unlikely(c == u))
14645 break;
14646 - old = atomic64_cmpxchg((v), c, c + (a));
14647 +
14648 + asm volatile("add %2,%0\n"
14649 +
14650 +#ifdef CONFIG_PAX_REFCOUNT
14651 + "jno 0f\n"
14652 + "sub %2,%0\n"
14653 + "int $4\n0:\n"
14654 + _ASM_EXTABLE(0b, 0b)
14655 +#endif
14656 +
14657 + : "=r" (new)
14658 + : "0" (c), "ir" (a));
14659 +
14660 + old = atomic64_cmpxchg(v, c, new);
14661 if (likely(old == c))
14662 break;
14663 c = old;
14664 }
14665 - return c != (u);
14666 + return c != u;
14667 }
14668
14669 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14670 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14671 index 6dfd019..28e188d 100644
14672 --- a/arch/x86/include/asm/bitops.h
14673 +++ b/arch/x86/include/asm/bitops.h
14674 @@ -40,7 +40,7 @@
14675 * a mask operation on a byte.
14676 */
14677 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14678 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14679 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14680 #define CONST_MASK(nr) (1 << ((nr) & 7))
14681
14682 /**
14683 @@ -486,7 +486,7 @@ static inline int fls(int x)
14684 * at position 64.
14685 */
14686 #ifdef CONFIG_X86_64
14687 -static __always_inline int fls64(__u64 x)
14688 +static __always_inline long fls64(__u64 x)
14689 {
14690 int bitpos = -1;
14691 /*
14692 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14693 index 4fa687a..60f2d39 100644
14694 --- a/arch/x86/include/asm/boot.h
14695 +++ b/arch/x86/include/asm/boot.h
14696 @@ -6,10 +6,15 @@
14697 #include <uapi/asm/boot.h>
14698
14699 /* Physical address where kernel should be loaded. */
14700 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14701 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14702 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14703 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14704
14705 +#ifndef __ASSEMBLY__
14706 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14707 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14708 +#endif
14709 +
14710 /* Minimum kernel alignment, as a power of two */
14711 #ifdef CONFIG_X86_64
14712 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14713 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14714 index 48f99f1..d78ebf9 100644
14715 --- a/arch/x86/include/asm/cache.h
14716 +++ b/arch/x86/include/asm/cache.h
14717 @@ -5,12 +5,13 @@
14718
14719 /* L1 cache line size */
14720 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14721 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14722 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14723
14724 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14725 +#define __read_only __attribute__((__section__(".data..read_only")))
14726
14727 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14728 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14729 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14730
14731 #ifdef CONFIG_X86_VSMP
14732 #ifdef CONFIG_SMP
14733 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14734 index 9863ee3..4a1f8e1 100644
14735 --- a/arch/x86/include/asm/cacheflush.h
14736 +++ b/arch/x86/include/asm/cacheflush.h
14737 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14738 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14739
14740 if (pg_flags == _PGMT_DEFAULT)
14741 - return -1;
14742 + return ~0UL;
14743 else if (pg_flags == _PGMT_WC)
14744 return _PAGE_CACHE_WC;
14745 else if (pg_flags == _PGMT_UC_MINUS)
14746 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14747 index f50de69..2b0a458 100644
14748 --- a/arch/x86/include/asm/checksum_32.h
14749 +++ b/arch/x86/include/asm/checksum_32.h
14750 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14751 int len, __wsum sum,
14752 int *src_err_ptr, int *dst_err_ptr);
14753
14754 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14755 + int len, __wsum sum,
14756 + int *src_err_ptr, int *dst_err_ptr);
14757 +
14758 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14759 + int len, __wsum sum,
14760 + int *src_err_ptr, int *dst_err_ptr);
14761 +
14762 /*
14763 * Note: when you get a NULL pointer exception here this means someone
14764 * passed in an incorrect kernel address to one of these functions.
14765 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14766
14767 might_sleep();
14768 stac();
14769 - ret = csum_partial_copy_generic((__force void *)src, dst,
14770 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14771 len, sum, err_ptr, NULL);
14772 clac();
14773
14774 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14775 might_sleep();
14776 if (access_ok(VERIFY_WRITE, dst, len)) {
14777 stac();
14778 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14779 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14780 len, sum, NULL, err_ptr);
14781 clac();
14782 return ret;
14783 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14784 index d47786a..ce1b05d 100644
14785 --- a/arch/x86/include/asm/cmpxchg.h
14786 +++ b/arch/x86/include/asm/cmpxchg.h
14787 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14788 __compiletime_error("Bad argument size for cmpxchg");
14789 extern void __xadd_wrong_size(void)
14790 __compiletime_error("Bad argument size for xadd");
14791 +extern void __xadd_check_overflow_wrong_size(void)
14792 + __compiletime_error("Bad argument size for xadd_check_overflow");
14793 extern void __add_wrong_size(void)
14794 __compiletime_error("Bad argument size for add");
14795 +extern void __add_check_overflow_wrong_size(void)
14796 + __compiletime_error("Bad argument size for add_check_overflow");
14797
14798 /*
14799 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14800 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14801 __ret; \
14802 })
14803
14804 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14805 + ({ \
14806 + __typeof__ (*(ptr)) __ret = (arg); \
14807 + switch (sizeof(*(ptr))) { \
14808 + case __X86_CASE_L: \
14809 + asm volatile (lock #op "l %0, %1\n" \
14810 + "jno 0f\n" \
14811 + "mov %0,%1\n" \
14812 + "int $4\n0:\n" \
14813 + _ASM_EXTABLE(0b, 0b) \
14814 + : "+r" (__ret), "+m" (*(ptr)) \
14815 + : : "memory", "cc"); \
14816 + break; \
14817 + case __X86_CASE_Q: \
14818 + asm volatile (lock #op "q %q0, %1\n" \
14819 + "jno 0f\n" \
14820 + "mov %0,%1\n" \
14821 + "int $4\n0:\n" \
14822 + _ASM_EXTABLE(0b, 0b) \
14823 + : "+r" (__ret), "+m" (*(ptr)) \
14824 + : : "memory", "cc"); \
14825 + break; \
14826 + default: \
14827 + __ ## op ## _check_overflow_wrong_size(); \
14828 + } \
14829 + __ret; \
14830 + })
14831 +
14832 /*
14833 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14834 * Since this is generally used to protect other memory information, we
14835 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14836 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14837 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14838
14839 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14840 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14841 +
14842 #define __add(ptr, inc, lock) \
14843 ({ \
14844 __typeof__ (*(ptr)) __ret = (inc); \
14845 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14846 index 59c6c40..5e0b22c 100644
14847 --- a/arch/x86/include/asm/compat.h
14848 +++ b/arch/x86/include/asm/compat.h
14849 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14850 typedef u32 compat_uint_t;
14851 typedef u32 compat_ulong_t;
14852 typedef u64 __attribute__((aligned(4))) compat_u64;
14853 -typedef u32 compat_uptr_t;
14854 +typedef u32 __user compat_uptr_t;
14855
14856 struct compat_timespec {
14857 compat_time_t tv_sec;
14858 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14859 index 7290585..717e89e 100644
14860 --- a/arch/x86/include/asm/cpufeature.h
14861 +++ b/arch/x86/include/asm/cpufeature.h
14862 @@ -203,7 +203,7 @@
14863 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14864 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14865 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14866 -
14867 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14868
14869 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14870 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14871 @@ -211,7 +211,7 @@
14872 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14873 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14874 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14875 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14876 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14877 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14878 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14879 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14880 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14881 #undef cpu_has_centaur_mcr
14882 #define cpu_has_centaur_mcr 0
14883
14884 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14885 #endif /* CONFIG_X86_64 */
14886
14887 #if __GNUC__ >= 4
14888 @@ -403,7 +404,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14889
14890 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14891 t_warn:
14892 - warn_pre_alternatives();
14893 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14894 + warn_pre_alternatives();
14895 return false;
14896 #endif
14897 #else /* GCC_VERSION >= 40500 */
14898 @@ -421,7 +423,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14899 ".section .discard,\"aw\",@progbits\n"
14900 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14901 ".previous\n"
14902 - ".section .altinstr_replacement,\"ax\"\n"
14903 + ".section .altinstr_replacement,\"a\"\n"
14904 "3: movb $1,%0\n"
14905 "4:\n"
14906 ".previous\n"
14907 @@ -457,7 +459,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14908 " .byte 2b - 1b\n" /* src len */
14909 " .byte 4f - 3f\n" /* repl len */
14910 ".previous\n"
14911 - ".section .altinstr_replacement,\"ax\"\n"
14912 + ".section .altinstr_replacement,\"a\"\n"
14913 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14914 "4:\n"
14915 ".previous\n"
14916 @@ -490,7 +492,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14917 ".section .discard,\"aw\",@progbits\n"
14918 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14919 ".previous\n"
14920 - ".section .altinstr_replacement,\"ax\"\n"
14921 + ".section .altinstr_replacement,\"a\"\n"
14922 "3: movb $0,%0\n"
14923 "4:\n"
14924 ".previous\n"
14925 @@ -504,7 +506,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14926 ".section .discard,\"aw\",@progbits\n"
14927 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14928 ".previous\n"
14929 - ".section .altinstr_replacement,\"ax\"\n"
14930 + ".section .altinstr_replacement,\"a\"\n"
14931 "5: movb $1,%0\n"
14932 "6:\n"
14933 ".previous\n"
14934 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14935 index b90e5df..b462c91 100644
14936 --- a/arch/x86/include/asm/desc.h
14937 +++ b/arch/x86/include/asm/desc.h
14938 @@ -4,6 +4,7 @@
14939 #include <asm/desc_defs.h>
14940 #include <asm/ldt.h>
14941 #include <asm/mmu.h>
14942 +#include <asm/pgtable.h>
14943
14944 #include <linux/smp.h>
14945 #include <linux/percpu.h>
14946 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14947
14948 desc->type = (info->read_exec_only ^ 1) << 1;
14949 desc->type |= info->contents << 2;
14950 + desc->type |= info->seg_not_present ^ 1;
14951
14952 desc->s = 1;
14953 desc->dpl = 0x3;
14954 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14955 }
14956
14957 extern struct desc_ptr idt_descr;
14958 -extern gate_desc idt_table[];
14959 -extern struct desc_ptr debug_idt_descr;
14960 -extern gate_desc debug_idt_table[];
14961 -
14962 -struct gdt_page {
14963 - struct desc_struct gdt[GDT_ENTRIES];
14964 -} __attribute__((aligned(PAGE_SIZE)));
14965 -
14966 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14967 +extern gate_desc idt_table[IDT_ENTRIES];
14968 +extern const struct desc_ptr debug_idt_descr;
14969 +extern gate_desc debug_idt_table[IDT_ENTRIES];
14970
14971 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14972 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14973 {
14974 - return per_cpu(gdt_page, cpu).gdt;
14975 + return cpu_gdt_table[cpu];
14976 }
14977
14978 #ifdef CONFIG_X86_64
14979 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
14980 unsigned long base, unsigned dpl, unsigned flags,
14981 unsigned short seg)
14982 {
14983 - gate->a = (seg << 16) | (base & 0xffff);
14984 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
14985 + gate->gate.offset_low = base;
14986 + gate->gate.seg = seg;
14987 + gate->gate.reserved = 0;
14988 + gate->gate.type = type;
14989 + gate->gate.s = 0;
14990 + gate->gate.dpl = dpl;
14991 + gate->gate.p = 1;
14992 + gate->gate.offset_high = base >> 16;
14993 }
14994
14995 #endif
14996 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
14997
14998 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
14999 {
15000 + pax_open_kernel();
15001 memcpy(&idt[entry], gate, sizeof(*gate));
15002 + pax_close_kernel();
15003 }
15004
15005 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15006 {
15007 + pax_open_kernel();
15008 memcpy(&ldt[entry], desc, 8);
15009 + pax_close_kernel();
15010 }
15011
15012 static inline void
15013 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15014 default: size = sizeof(*gdt); break;
15015 }
15016
15017 + pax_open_kernel();
15018 memcpy(&gdt[entry], desc, size);
15019 + pax_close_kernel();
15020 }
15021
15022 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15023 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15024
15025 static inline void native_load_tr_desc(void)
15026 {
15027 + pax_open_kernel();
15028 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15029 + pax_close_kernel();
15030 }
15031
15032 static inline void native_load_gdt(const struct desc_ptr *dtr)
15033 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15034 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15035 unsigned int i;
15036
15037 + pax_open_kernel();
15038 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15039 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15040 + pax_close_kernel();
15041 }
15042
15043 #define _LDT_empty(info) \
15044 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15045 preempt_enable();
15046 }
15047
15048 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15049 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15050 {
15051 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15052 }
15053 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15054 }
15055
15056 #ifdef CONFIG_X86_64
15057 -static inline void set_nmi_gate(int gate, void *addr)
15058 +static inline void set_nmi_gate(int gate, const void *addr)
15059 {
15060 gate_desc s;
15061
15062 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15063 #endif
15064
15065 #ifdef CONFIG_TRACING
15066 -extern struct desc_ptr trace_idt_descr;
15067 -extern gate_desc trace_idt_table[];
15068 +extern const struct desc_ptr trace_idt_descr;
15069 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15070 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15071 {
15072 write_idt_entry(trace_idt_table, entry, gate);
15073 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15074 }
15075 #endif
15076
15077 -static inline void _set_gate(int gate, unsigned type, void *addr,
15078 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15079 unsigned dpl, unsigned ist, unsigned seg)
15080 {
15081 gate_desc s;
15082 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15083 * Pentium F0 0F bugfix can have resulted in the mapped
15084 * IDT being write-protected.
15085 */
15086 -static inline void set_intr_gate(unsigned int n, void *addr)
15087 +static inline void set_intr_gate(unsigned int n, const void *addr)
15088 {
15089 BUG_ON((unsigned)n > 0xFF);
15090 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15091 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15092 /*
15093 * This routine sets up an interrupt gate at directory privilege level 3.
15094 */
15095 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15096 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15097 {
15098 BUG_ON((unsigned)n > 0xFF);
15099 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15100 }
15101
15102 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15103 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15104 {
15105 BUG_ON((unsigned)n > 0xFF);
15106 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15107 }
15108
15109 -static inline void set_trap_gate(unsigned int n, void *addr)
15110 +static inline void set_trap_gate(unsigned int n, const void *addr)
15111 {
15112 BUG_ON((unsigned)n > 0xFF);
15113 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15114 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15115 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15116 {
15117 BUG_ON((unsigned)n > 0xFF);
15118 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15119 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15120 }
15121
15122 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15123 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15124 {
15125 BUG_ON((unsigned)n > 0xFF);
15126 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15127 }
15128
15129 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15130 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15131 {
15132 BUG_ON((unsigned)n > 0xFF);
15133 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15134 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15135 else
15136 load_idt((const struct desc_ptr *)&idt_descr);
15137 }
15138 +
15139 +#ifdef CONFIG_X86_32
15140 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15141 +{
15142 + struct desc_struct d;
15143 +
15144 + if (likely(limit))
15145 + limit = (limit - 1UL) >> PAGE_SHIFT;
15146 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15147 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15148 +}
15149 +#endif
15150 +
15151 #endif /* _ASM_X86_DESC_H */
15152 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15153 index 278441f..b95a174 100644
15154 --- a/arch/x86/include/asm/desc_defs.h
15155 +++ b/arch/x86/include/asm/desc_defs.h
15156 @@ -31,6 +31,12 @@ struct desc_struct {
15157 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15158 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15159 };
15160 + struct {
15161 + u16 offset_low;
15162 + u16 seg;
15163 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15164 + unsigned offset_high: 16;
15165 + } gate;
15166 };
15167 } __attribute__((packed));
15168
15169 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15170 index ced283a..ffe04cc 100644
15171 --- a/arch/x86/include/asm/div64.h
15172 +++ b/arch/x86/include/asm/div64.h
15173 @@ -39,7 +39,7 @@
15174 __mod; \
15175 })
15176
15177 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15178 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15179 {
15180 union {
15181 u64 v64;
15182 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15183 index 9c999c1..3860cb8 100644
15184 --- a/arch/x86/include/asm/elf.h
15185 +++ b/arch/x86/include/asm/elf.h
15186 @@ -243,7 +243,25 @@ extern int force_personality32;
15187 the loader. We need to make sure that it is out of the way of the program
15188 that it will "exec", and that there is sufficient room for the brk. */
15189
15190 +#ifdef CONFIG_PAX_SEGMEXEC
15191 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15192 +#else
15193 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15194 +#endif
15195 +
15196 +#ifdef CONFIG_PAX_ASLR
15197 +#ifdef CONFIG_X86_32
15198 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15199 +
15200 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15201 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15202 +#else
15203 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15204 +
15205 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15206 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15207 +#endif
15208 +#endif
15209
15210 /* This yields a mask that user programs can use to figure out what
15211 instruction set this CPU supports. This could be done in user space,
15212 @@ -296,16 +314,12 @@ do { \
15213
15214 #define ARCH_DLINFO \
15215 do { \
15216 - if (vdso_enabled) \
15217 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15218 - (unsigned long)current->mm->context.vdso); \
15219 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15220 } while (0)
15221
15222 #define ARCH_DLINFO_X32 \
15223 do { \
15224 - if (vdso_enabled) \
15225 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15226 - (unsigned long)current->mm->context.vdso); \
15227 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15228 } while (0)
15229
15230 #define AT_SYSINFO 32
15231 @@ -320,7 +334,7 @@ else \
15232
15233 #endif /* !CONFIG_X86_32 */
15234
15235 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15236 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15237
15238 #define VDSO_ENTRY \
15239 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15240 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15241 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15242 #define compat_arch_setup_additional_pages syscall32_setup_pages
15243
15244 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15245 -#define arch_randomize_brk arch_randomize_brk
15246 -
15247 /*
15248 * True on X86_32 or when emulating IA32 on X86_64
15249 */
15250 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15251 index 77a99ac..39ff7f5 100644
15252 --- a/arch/x86/include/asm/emergency-restart.h
15253 +++ b/arch/x86/include/asm/emergency-restart.h
15254 @@ -1,6 +1,6 @@
15255 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15256 #define _ASM_X86_EMERGENCY_RESTART_H
15257
15258 -extern void machine_emergency_restart(void);
15259 +extern void machine_emergency_restart(void) __noreturn;
15260
15261 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15262 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15263 index 4d0bda7..221da4d 100644
15264 --- a/arch/x86/include/asm/fpu-internal.h
15265 +++ b/arch/x86/include/asm/fpu-internal.h
15266 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15267 #define user_insn(insn, output, input...) \
15268 ({ \
15269 int err; \
15270 + pax_open_userland(); \
15271 asm volatile(ASM_STAC "\n" \
15272 - "1:" #insn "\n\t" \
15273 + "1:" \
15274 + __copyuser_seg \
15275 + #insn "\n\t" \
15276 "2: " ASM_CLAC "\n" \
15277 ".section .fixup,\"ax\"\n" \
15278 "3: movl $-1,%[err]\n" \
15279 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15280 _ASM_EXTABLE(1b, 3b) \
15281 : [err] "=r" (err), output \
15282 : "0"(0), input); \
15283 + pax_close_userland(); \
15284 err; \
15285 })
15286
15287 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15288 "emms\n\t" /* clear stack tags */
15289 "fildl %P[addr]", /* set F?P to defined value */
15290 X86_FEATURE_FXSAVE_LEAK,
15291 - [addr] "m" (tsk->thread.fpu.has_fpu));
15292 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15293
15294 return fpu_restore_checking(&tsk->thread.fpu);
15295 }
15296 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15297 index be27ba1..04a8801 100644
15298 --- a/arch/x86/include/asm/futex.h
15299 +++ b/arch/x86/include/asm/futex.h
15300 @@ -12,6 +12,7 @@
15301 #include <asm/smap.h>
15302
15303 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15304 + typecheck(u32 __user *, uaddr); \
15305 asm volatile("\t" ASM_STAC "\n" \
15306 "1:\t" insn "\n" \
15307 "2:\t" ASM_CLAC "\n" \
15308 @@ -20,15 +21,16 @@
15309 "\tjmp\t2b\n" \
15310 "\t.previous\n" \
15311 _ASM_EXTABLE(1b, 3b) \
15312 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15313 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15314 : "i" (-EFAULT), "0" (oparg), "1" (0))
15315
15316 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15317 + typecheck(u32 __user *, uaddr); \
15318 asm volatile("\t" ASM_STAC "\n" \
15319 "1:\tmovl %2, %0\n" \
15320 "\tmovl\t%0, %3\n" \
15321 "\t" insn "\n" \
15322 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15323 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15324 "\tjnz\t1b\n" \
15325 "3:\t" ASM_CLAC "\n" \
15326 "\t.section .fixup,\"ax\"\n" \
15327 @@ -38,7 +40,7 @@
15328 _ASM_EXTABLE(1b, 4b) \
15329 _ASM_EXTABLE(2b, 4b) \
15330 : "=&a" (oldval), "=&r" (ret), \
15331 - "+m" (*uaddr), "=&r" (tem) \
15332 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15333 : "r" (oparg), "i" (-EFAULT), "1" (0))
15334
15335 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15336 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15337
15338 pagefault_disable();
15339
15340 + pax_open_userland();
15341 switch (op) {
15342 case FUTEX_OP_SET:
15343 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15344 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15345 break;
15346 case FUTEX_OP_ADD:
15347 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15348 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15349 uaddr, oparg);
15350 break;
15351 case FUTEX_OP_OR:
15352 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15353 default:
15354 ret = -ENOSYS;
15355 }
15356 + pax_close_userland();
15357
15358 pagefault_enable();
15359
15360 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15361 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15362 return -EFAULT;
15363
15364 + pax_open_userland();
15365 asm volatile("\t" ASM_STAC "\n"
15366 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15367 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15368 "2:\t" ASM_CLAC "\n"
15369 "\t.section .fixup, \"ax\"\n"
15370 "3:\tmov %3, %0\n"
15371 "\tjmp 2b\n"
15372 "\t.previous\n"
15373 _ASM_EXTABLE(1b, 3b)
15374 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15375 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15376 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15377 : "memory"
15378 );
15379 + pax_close_userland();
15380
15381 *uval = oldval;
15382 return ret;
15383 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15384 index e4ac559..c1c0c87 100644
15385 --- a/arch/x86/include/asm/hw_irq.h
15386 +++ b/arch/x86/include/asm/hw_irq.h
15387 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15388 extern void enable_IO_APIC(void);
15389
15390 /* Statistics */
15391 -extern atomic_t irq_err_count;
15392 -extern atomic_t irq_mis_count;
15393 +extern atomic_unchecked_t irq_err_count;
15394 +extern atomic_unchecked_t irq_mis_count;
15395
15396 /* EISA */
15397 extern void eisa_set_level_irq(unsigned int irq);
15398 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15399 index a203659..9889f1c 100644
15400 --- a/arch/x86/include/asm/i8259.h
15401 +++ b/arch/x86/include/asm/i8259.h
15402 @@ -62,7 +62,7 @@ struct legacy_pic {
15403 void (*init)(int auto_eoi);
15404 int (*irq_pending)(unsigned int irq);
15405 void (*make_irq)(unsigned int irq);
15406 -};
15407 +} __do_const;
15408
15409 extern struct legacy_pic *legacy_pic;
15410 extern struct legacy_pic null_legacy_pic;
15411 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15412 index 34f69cb..6d95446 100644
15413 --- a/arch/x86/include/asm/io.h
15414 +++ b/arch/x86/include/asm/io.h
15415 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15416 "m" (*(volatile type __force *)addr) barrier); }
15417
15418 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15419 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15420 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15421 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15422 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15423
15424 build_mmio_read(__readb, "b", unsigned char, "=q", )
15425 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15426 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15427 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15428 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15429
15430 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15431 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15432 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15433 return ioremap_nocache(offset, size);
15434 }
15435
15436 -extern void iounmap(volatile void __iomem *addr);
15437 +extern void iounmap(const volatile void __iomem *addr);
15438
15439 extern void set_iounmap_nonlazy(void);
15440
15441 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15442
15443 #include <linux/vmalloc.h>
15444
15445 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15446 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15447 +{
15448 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15449 +}
15450 +
15451 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15452 +{
15453 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15454 +}
15455 +
15456 /*
15457 * Convert a virtual cached pointer to an uncached pointer
15458 */
15459 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15460 index bba3cf8..06bc8da 100644
15461 --- a/arch/x86/include/asm/irqflags.h
15462 +++ b/arch/x86/include/asm/irqflags.h
15463 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15464 sti; \
15465 sysexit
15466
15467 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15468 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15469 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15470 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15471 +
15472 #else
15473 #define INTERRUPT_RETURN iret
15474 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15475 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15476 index 5a6d287..f815789 100644
15477 --- a/arch/x86/include/asm/kprobes.h
15478 +++ b/arch/x86/include/asm/kprobes.h
15479 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15480 #define RELATIVEJUMP_SIZE 5
15481 #define RELATIVECALL_OPCODE 0xe8
15482 #define RELATIVE_ADDR_SIZE 4
15483 -#define MAX_STACK_SIZE 64
15484 -#define MIN_STACK_SIZE(ADDR) \
15485 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15486 - THREAD_SIZE - (unsigned long)(ADDR))) \
15487 - ? (MAX_STACK_SIZE) \
15488 - : (((unsigned long)current_thread_info()) + \
15489 - THREAD_SIZE - (unsigned long)(ADDR)))
15490 +#define MAX_STACK_SIZE 64UL
15491 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15492
15493 #define flush_insn_slot(p) do { } while (0)
15494
15495 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15496 index 2d89e39..baee879 100644
15497 --- a/arch/x86/include/asm/local.h
15498 +++ b/arch/x86/include/asm/local.h
15499 @@ -10,33 +10,97 @@ typedef struct {
15500 atomic_long_t a;
15501 } local_t;
15502
15503 +typedef struct {
15504 + atomic_long_unchecked_t a;
15505 +} local_unchecked_t;
15506 +
15507 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15508
15509 #define local_read(l) atomic_long_read(&(l)->a)
15510 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15511 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15512 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15513
15514 static inline void local_inc(local_t *l)
15515 {
15516 - asm volatile(_ASM_INC "%0"
15517 + asm volatile(_ASM_INC "%0\n"
15518 +
15519 +#ifdef CONFIG_PAX_REFCOUNT
15520 + "jno 0f\n"
15521 + _ASM_DEC "%0\n"
15522 + "int $4\n0:\n"
15523 + _ASM_EXTABLE(0b, 0b)
15524 +#endif
15525 +
15526 + : "+m" (l->a.counter));
15527 +}
15528 +
15529 +static inline void local_inc_unchecked(local_unchecked_t *l)
15530 +{
15531 + asm volatile(_ASM_INC "%0\n"
15532 : "+m" (l->a.counter));
15533 }
15534
15535 static inline void local_dec(local_t *l)
15536 {
15537 - asm volatile(_ASM_DEC "%0"
15538 + asm volatile(_ASM_DEC "%0\n"
15539 +
15540 +#ifdef CONFIG_PAX_REFCOUNT
15541 + "jno 0f\n"
15542 + _ASM_INC "%0\n"
15543 + "int $4\n0:\n"
15544 + _ASM_EXTABLE(0b, 0b)
15545 +#endif
15546 +
15547 + : "+m" (l->a.counter));
15548 +}
15549 +
15550 +static inline void local_dec_unchecked(local_unchecked_t *l)
15551 +{
15552 + asm volatile(_ASM_DEC "%0\n"
15553 : "+m" (l->a.counter));
15554 }
15555
15556 static inline void local_add(long i, local_t *l)
15557 {
15558 - asm volatile(_ASM_ADD "%1,%0"
15559 + asm volatile(_ASM_ADD "%1,%0\n"
15560 +
15561 +#ifdef CONFIG_PAX_REFCOUNT
15562 + "jno 0f\n"
15563 + _ASM_SUB "%1,%0\n"
15564 + "int $4\n0:\n"
15565 + _ASM_EXTABLE(0b, 0b)
15566 +#endif
15567 +
15568 + : "+m" (l->a.counter)
15569 + : "ir" (i));
15570 +}
15571 +
15572 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15573 +{
15574 + asm volatile(_ASM_ADD "%1,%0\n"
15575 : "+m" (l->a.counter)
15576 : "ir" (i));
15577 }
15578
15579 static inline void local_sub(long i, local_t *l)
15580 {
15581 - asm volatile(_ASM_SUB "%1,%0"
15582 + asm volatile(_ASM_SUB "%1,%0\n"
15583 +
15584 +#ifdef CONFIG_PAX_REFCOUNT
15585 + "jno 0f\n"
15586 + _ASM_ADD "%1,%0\n"
15587 + "int $4\n0:\n"
15588 + _ASM_EXTABLE(0b, 0b)
15589 +#endif
15590 +
15591 + : "+m" (l->a.counter)
15592 + : "ir" (i));
15593 +}
15594 +
15595 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15596 +{
15597 + asm volatile(_ASM_SUB "%1,%0\n"
15598 : "+m" (l->a.counter)
15599 : "ir" (i));
15600 }
15601 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15602 {
15603 unsigned char c;
15604
15605 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15606 + asm volatile(_ASM_SUB "%2,%0\n"
15607 +
15608 +#ifdef CONFIG_PAX_REFCOUNT
15609 + "jno 0f\n"
15610 + _ASM_ADD "%2,%0\n"
15611 + "int $4\n0:\n"
15612 + _ASM_EXTABLE(0b, 0b)
15613 +#endif
15614 +
15615 + "sete %1\n"
15616 : "+m" (l->a.counter), "=qm" (c)
15617 : "ir" (i) : "memory");
15618 return c;
15619 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15620 {
15621 unsigned char c;
15622
15623 - asm volatile(_ASM_DEC "%0; sete %1"
15624 + asm volatile(_ASM_DEC "%0\n"
15625 +
15626 +#ifdef CONFIG_PAX_REFCOUNT
15627 + "jno 0f\n"
15628 + _ASM_INC "%0\n"
15629 + "int $4\n0:\n"
15630 + _ASM_EXTABLE(0b, 0b)
15631 +#endif
15632 +
15633 + "sete %1\n"
15634 : "+m" (l->a.counter), "=qm" (c)
15635 : : "memory");
15636 return c != 0;
15637 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15638 {
15639 unsigned char c;
15640
15641 - asm volatile(_ASM_INC "%0; sete %1"
15642 + asm volatile(_ASM_INC "%0\n"
15643 +
15644 +#ifdef CONFIG_PAX_REFCOUNT
15645 + "jno 0f\n"
15646 + _ASM_DEC "%0\n"
15647 + "int $4\n0:\n"
15648 + _ASM_EXTABLE(0b, 0b)
15649 +#endif
15650 +
15651 + "sete %1\n"
15652 : "+m" (l->a.counter), "=qm" (c)
15653 : : "memory");
15654 return c != 0;
15655 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15656 {
15657 unsigned char c;
15658
15659 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15660 + asm volatile(_ASM_ADD "%2,%0\n"
15661 +
15662 +#ifdef CONFIG_PAX_REFCOUNT
15663 + "jno 0f\n"
15664 + _ASM_SUB "%2,%0\n"
15665 + "int $4\n0:\n"
15666 + _ASM_EXTABLE(0b, 0b)
15667 +#endif
15668 +
15669 + "sets %1\n"
15670 : "+m" (l->a.counter), "=qm" (c)
15671 : "ir" (i) : "memory");
15672 return c;
15673 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15674 static inline long local_add_return(long i, local_t *l)
15675 {
15676 long __i = i;
15677 + asm volatile(_ASM_XADD "%0, %1\n"
15678 +
15679 +#ifdef CONFIG_PAX_REFCOUNT
15680 + "jno 0f\n"
15681 + _ASM_MOV "%0,%1\n"
15682 + "int $4\n0:\n"
15683 + _ASM_EXTABLE(0b, 0b)
15684 +#endif
15685 +
15686 + : "+r" (i), "+m" (l->a.counter)
15687 + : : "memory");
15688 + return i + __i;
15689 +}
15690 +
15691 +/**
15692 + * local_add_return_unchecked - add and return
15693 + * @i: integer value to add
15694 + * @l: pointer to type local_unchecked_t
15695 + *
15696 + * Atomically adds @i to @l and returns @i + @l
15697 + */
15698 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15699 +{
15700 + long __i = i;
15701 asm volatile(_ASM_XADD "%0, %1;"
15702 : "+r" (i), "+m" (l->a.counter)
15703 : : "memory");
15704 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15705
15706 #define local_cmpxchg(l, o, n) \
15707 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15708 +#define local_cmpxchg_unchecked(l, o, n) \
15709 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15710 /* Always has a lock prefix */
15711 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15712
15713 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15714 new file mode 100644
15715 index 0000000..2bfd3ba
15716 --- /dev/null
15717 +++ b/arch/x86/include/asm/mman.h
15718 @@ -0,0 +1,15 @@
15719 +#ifndef _X86_MMAN_H
15720 +#define _X86_MMAN_H
15721 +
15722 +#include <uapi/asm/mman.h>
15723 +
15724 +#ifdef __KERNEL__
15725 +#ifndef __ASSEMBLY__
15726 +#ifdef CONFIG_X86_32
15727 +#define arch_mmap_check i386_mmap_check
15728 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15729 +#endif
15730 +#endif
15731 +#endif
15732 +
15733 +#endif /* X86_MMAN_H */
15734 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15735 index 5f55e69..e20bfb1 100644
15736 --- a/arch/x86/include/asm/mmu.h
15737 +++ b/arch/x86/include/asm/mmu.h
15738 @@ -9,7 +9,7 @@
15739 * we put the segment information here.
15740 */
15741 typedef struct {
15742 - void *ldt;
15743 + struct desc_struct *ldt;
15744 int size;
15745
15746 #ifdef CONFIG_X86_64
15747 @@ -18,7 +18,19 @@ typedef struct {
15748 #endif
15749
15750 struct mutex lock;
15751 - void *vdso;
15752 + unsigned long vdso;
15753 +
15754 +#ifdef CONFIG_X86_32
15755 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15756 + unsigned long user_cs_base;
15757 + unsigned long user_cs_limit;
15758 +
15759 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15760 + cpumask_t cpu_user_cs_mask;
15761 +#endif
15762 +
15763 +#endif
15764 +#endif
15765 } mm_context_t;
15766
15767 #ifdef CONFIG_SMP
15768 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15769 index be12c53..4d24039 100644
15770 --- a/arch/x86/include/asm/mmu_context.h
15771 +++ b/arch/x86/include/asm/mmu_context.h
15772 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15773
15774 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15775 {
15776 +
15777 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15778 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15779 + unsigned int i;
15780 + pgd_t *pgd;
15781 +
15782 + pax_open_kernel();
15783 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15784 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15785 + set_pgd_batched(pgd+i, native_make_pgd(0));
15786 + pax_close_kernel();
15787 + }
15788 +#endif
15789 +
15790 #ifdef CONFIG_SMP
15791 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15792 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15793 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15794 struct task_struct *tsk)
15795 {
15796 unsigned cpu = smp_processor_id();
15797 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15798 + int tlbstate = TLBSTATE_OK;
15799 +#endif
15800
15801 if (likely(prev != next)) {
15802 #ifdef CONFIG_SMP
15803 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15804 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15805 +#endif
15806 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15807 this_cpu_write(cpu_tlbstate.active_mm, next);
15808 #endif
15809 cpumask_set_cpu(cpu, mm_cpumask(next));
15810
15811 /* Re-load page tables */
15812 +#ifdef CONFIG_PAX_PER_CPU_PGD
15813 + pax_open_kernel();
15814 +
15815 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15816 + if (static_cpu_has(X86_FEATURE_PCID))
15817 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15818 + else
15819 +#endif
15820 +
15821 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15822 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15823 + pax_close_kernel();
15824 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
15825 +
15826 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15827 + if (static_cpu_has(X86_FEATURE_PCID)) {
15828 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15829 + u64 descriptor[2];
15830 + descriptor[0] = PCID_USER;
15831 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15832 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15833 + descriptor[0] = PCID_KERNEL;
15834 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15835 + }
15836 + } else {
15837 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15838 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15839 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15840 + else
15841 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15842 + }
15843 + } else
15844 +#endif
15845 +
15846 + load_cr3(get_cpu_pgd(cpu, kernel));
15847 +#else
15848 load_cr3(next->pgd);
15849 +#endif
15850
15851 /* Stop flush ipis for the previous mm */
15852 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15853 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15854 /* Load the LDT, if the LDT is different: */
15855 if (unlikely(prev->context.ldt != next->context.ldt))
15856 load_LDT_nolock(&next->context);
15857 +
15858 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15859 + if (!(__supported_pte_mask & _PAGE_NX)) {
15860 + smp_mb__before_clear_bit();
15861 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15862 + smp_mb__after_clear_bit();
15863 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15864 + }
15865 +#endif
15866 +
15867 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15868 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15869 + prev->context.user_cs_limit != next->context.user_cs_limit))
15870 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15871 +#ifdef CONFIG_SMP
15872 + else if (unlikely(tlbstate != TLBSTATE_OK))
15873 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15874 +#endif
15875 +#endif
15876 +
15877 }
15878 + else {
15879 +
15880 +#ifdef CONFIG_PAX_PER_CPU_PGD
15881 + pax_open_kernel();
15882 +
15883 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15884 + if (static_cpu_has(X86_FEATURE_PCID))
15885 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15886 + else
15887 +#endif
15888 +
15889 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15890 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15891 + pax_close_kernel();
15892 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
15893 +
15894 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15895 + if (static_cpu_has(X86_FEATURE_PCID)) {
15896 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15897 + u64 descriptor[2];
15898 + descriptor[0] = PCID_USER;
15899 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15900 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15901 + descriptor[0] = PCID_KERNEL;
15902 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15903 + }
15904 + } else {
15905 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15906 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15907 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15908 + else
15909 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15910 + }
15911 + } else
15912 +#endif
15913 +
15914 + load_cr3(get_cpu_pgd(cpu, kernel));
15915 +#endif
15916 +
15917 #ifdef CONFIG_SMP
15918 - else {
15919 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15920 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15921
15922 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15923 * tlb flush IPI delivery. We must reload CR3
15924 * to make sure to use no freed page tables.
15925 */
15926 +
15927 +#ifndef CONFIG_PAX_PER_CPU_PGD
15928 load_cr3(next->pgd);
15929 +#endif
15930 +
15931 load_LDT_nolock(&next->context);
15932 +
15933 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15934 + if (!(__supported_pte_mask & _PAGE_NX))
15935 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15936 +#endif
15937 +
15938 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15939 +#ifdef CONFIG_PAX_PAGEEXEC
15940 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15941 +#endif
15942 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15943 +#endif
15944 +
15945 }
15946 +#endif
15947 }
15948 -#endif
15949 }
15950
15951 #define activate_mm(prev, next) \
15952 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15953 index e3b7819..b257c64 100644
15954 --- a/arch/x86/include/asm/module.h
15955 +++ b/arch/x86/include/asm/module.h
15956 @@ -5,6 +5,7 @@
15957
15958 #ifdef CONFIG_X86_64
15959 /* X86_64 does not define MODULE_PROC_FAMILY */
15960 +#define MODULE_PROC_FAMILY ""
15961 #elif defined CONFIG_M486
15962 #define MODULE_PROC_FAMILY "486 "
15963 #elif defined CONFIG_M586
15964 @@ -57,8 +58,20 @@
15965 #error unknown processor family
15966 #endif
15967
15968 -#ifdef CONFIG_X86_32
15969 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
15970 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
15971 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
15972 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
15973 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
15974 +#else
15975 +#define MODULE_PAX_KERNEXEC ""
15976 #endif
15977
15978 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15979 +#define MODULE_PAX_UDEREF "UDEREF "
15980 +#else
15981 +#define MODULE_PAX_UDEREF ""
15982 +#endif
15983 +
15984 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
15985 +
15986 #endif /* _ASM_X86_MODULE_H */
15987 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
15988 index 86f9301..b365cda 100644
15989 --- a/arch/x86/include/asm/nmi.h
15990 +++ b/arch/x86/include/asm/nmi.h
15991 @@ -40,11 +40,11 @@ struct nmiaction {
15992 nmi_handler_t handler;
15993 unsigned long flags;
15994 const char *name;
15995 -};
15996 +} __do_const;
15997
15998 #define register_nmi_handler(t, fn, fg, n, init...) \
15999 ({ \
16000 - static struct nmiaction init fn##_na = { \
16001 + static const struct nmiaction init fn##_na = { \
16002 .handler = (fn), \
16003 .name = (n), \
16004 .flags = (fg), \
16005 @@ -52,7 +52,7 @@ struct nmiaction {
16006 __register_nmi_handler((t), &fn##_na); \
16007 })
16008
16009 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16010 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16011
16012 void unregister_nmi_handler(unsigned int, const char *);
16013
16014 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16015 index c878924..21f4889 100644
16016 --- a/arch/x86/include/asm/page.h
16017 +++ b/arch/x86/include/asm/page.h
16018 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16019 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16020
16021 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16022 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16023
16024 #define __boot_va(x) __va(x)
16025 #define __boot_pa(x) __pa(x)
16026 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16027 index 0f1ddee..e2fc3d1 100644
16028 --- a/arch/x86/include/asm/page_64.h
16029 +++ b/arch/x86/include/asm/page_64.h
16030 @@ -7,9 +7,9 @@
16031
16032 /* duplicated to the one in bootmem.h */
16033 extern unsigned long max_pfn;
16034 -extern unsigned long phys_base;
16035 +extern const unsigned long phys_base;
16036
16037 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16038 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16039 {
16040 unsigned long y = x - __START_KERNEL_map;
16041
16042 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16043 index cfdc9ee..3f7b5d6 100644
16044 --- a/arch/x86/include/asm/paravirt.h
16045 +++ b/arch/x86/include/asm/paravirt.h
16046 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16047 return (pmd_t) { ret };
16048 }
16049
16050 -static inline pmdval_t pmd_val(pmd_t pmd)
16051 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16052 {
16053 pmdval_t ret;
16054
16055 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16056 val);
16057 }
16058
16059 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16060 +{
16061 + pgdval_t val = native_pgd_val(pgd);
16062 +
16063 + if (sizeof(pgdval_t) > sizeof(long))
16064 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16065 + val, (u64)val >> 32);
16066 + else
16067 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16068 + val);
16069 +}
16070 +
16071 static inline void pgd_clear(pgd_t *pgdp)
16072 {
16073 set_pgd(pgdp, __pgd(0));
16074 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16075 pv_mmu_ops.set_fixmap(idx, phys, flags);
16076 }
16077
16078 +#ifdef CONFIG_PAX_KERNEXEC
16079 +static inline unsigned long pax_open_kernel(void)
16080 +{
16081 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16082 +}
16083 +
16084 +static inline unsigned long pax_close_kernel(void)
16085 +{
16086 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16087 +}
16088 +#else
16089 +static inline unsigned long pax_open_kernel(void) { return 0; }
16090 +static inline unsigned long pax_close_kernel(void) { return 0; }
16091 +#endif
16092 +
16093 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16094
16095 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
16096 @@ -926,7 +953,7 @@ extern void default_banner(void);
16097
16098 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16099 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16100 -#define PARA_INDIRECT(addr) *%cs:addr
16101 +#define PARA_INDIRECT(addr) *%ss:addr
16102 #endif
16103
16104 #define INTERRUPT_RETURN \
16105 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
16106 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16107 CLBR_NONE, \
16108 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16109 +
16110 +#define GET_CR0_INTO_RDI \
16111 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16112 + mov %rax,%rdi
16113 +
16114 +#define SET_RDI_INTO_CR0 \
16115 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16116 +
16117 +#define GET_CR3_INTO_RDI \
16118 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16119 + mov %rax,%rdi
16120 +
16121 +#define SET_RDI_INTO_CR3 \
16122 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16123 +
16124 #endif /* CONFIG_X86_32 */
16125
16126 #endif /* __ASSEMBLY__ */
16127 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16128 index 0db1fca..52310cc 100644
16129 --- a/arch/x86/include/asm/paravirt_types.h
16130 +++ b/arch/x86/include/asm/paravirt_types.h
16131 @@ -84,7 +84,7 @@ struct pv_init_ops {
16132 */
16133 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16134 unsigned long addr, unsigned len);
16135 -};
16136 +} __no_const;
16137
16138
16139 struct pv_lazy_ops {
16140 @@ -98,7 +98,7 @@ struct pv_time_ops {
16141 unsigned long long (*sched_clock)(void);
16142 unsigned long long (*steal_clock)(int cpu);
16143 unsigned long (*get_tsc_khz)(void);
16144 -};
16145 +} __no_const;
16146
16147 struct pv_cpu_ops {
16148 /* hooks for various privileged instructions */
16149 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16150
16151 void (*start_context_switch)(struct task_struct *prev);
16152 void (*end_context_switch)(struct task_struct *next);
16153 -};
16154 +} __no_const;
16155
16156 struct pv_irq_ops {
16157 /*
16158 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16159 unsigned long start_eip,
16160 unsigned long start_esp);
16161 #endif
16162 -};
16163 +} __no_const;
16164
16165 struct pv_mmu_ops {
16166 unsigned long (*read_cr2)(void);
16167 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16168 struct paravirt_callee_save make_pud;
16169
16170 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16171 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16172 #endif /* PAGETABLE_LEVELS == 4 */
16173 #endif /* PAGETABLE_LEVELS >= 3 */
16174
16175 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16176 an mfn. We can tell which is which from the index. */
16177 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16178 phys_addr_t phys, pgprot_t flags);
16179 +
16180 +#ifdef CONFIG_PAX_KERNEXEC
16181 + unsigned long (*pax_open_kernel)(void);
16182 + unsigned long (*pax_close_kernel)(void);
16183 +#endif
16184 +
16185 };
16186
16187 struct arch_spinlock;
16188 @@ -334,7 +341,7 @@ struct pv_lock_ops {
16189 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
16190 int (*spin_trylock)(struct arch_spinlock *lock);
16191 void (*spin_unlock)(struct arch_spinlock *lock);
16192 -};
16193 +} __no_const;
16194
16195 /* This contains all the paravirt structures: we get a convenient
16196 * number for each function using the offset which we use to indicate
16197 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16198 index b4389a4..7024269 100644
16199 --- a/arch/x86/include/asm/pgalloc.h
16200 +++ b/arch/x86/include/asm/pgalloc.h
16201 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16202 pmd_t *pmd, pte_t *pte)
16203 {
16204 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16205 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16206 +}
16207 +
16208 +static inline void pmd_populate_user(struct mm_struct *mm,
16209 + pmd_t *pmd, pte_t *pte)
16210 +{
16211 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16212 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16213 }
16214
16215 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16216
16217 #ifdef CONFIG_X86_PAE
16218 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16219 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16220 +{
16221 + pud_populate(mm, pudp, pmd);
16222 +}
16223 #else /* !CONFIG_X86_PAE */
16224 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16225 {
16226 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16227 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16228 }
16229 +
16230 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16231 +{
16232 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16233 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16234 +}
16235 #endif /* CONFIG_X86_PAE */
16236
16237 #if PAGETABLE_LEVELS > 3
16238 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16239 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16240 }
16241
16242 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16243 +{
16244 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16245 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16246 +}
16247 +
16248 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16249 {
16250 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16251 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16252 index 3bf2dd0..23d2a9f 100644
16253 --- a/arch/x86/include/asm/pgtable-2level.h
16254 +++ b/arch/x86/include/asm/pgtable-2level.h
16255 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16256
16257 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16258 {
16259 + pax_open_kernel();
16260 *pmdp = pmd;
16261 + pax_close_kernel();
16262 }
16263
16264 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16265 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16266 index 81bb91b..9392125 100644
16267 --- a/arch/x86/include/asm/pgtable-3level.h
16268 +++ b/arch/x86/include/asm/pgtable-3level.h
16269 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16270
16271 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16272 {
16273 + pax_open_kernel();
16274 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16275 + pax_close_kernel();
16276 }
16277
16278 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16279 {
16280 + pax_open_kernel();
16281 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16282 + pax_close_kernel();
16283 }
16284
16285 /*
16286 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16287 index 1c00631..845f898 100644
16288 --- a/arch/x86/include/asm/pgtable.h
16289 +++ b/arch/x86/include/asm/pgtable.h
16290 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16291
16292 #ifndef __PAGETABLE_PUD_FOLDED
16293 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16294 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16295 #define pgd_clear(pgd) native_pgd_clear(pgd)
16296 #endif
16297
16298 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16299
16300 #define arch_end_context_switch(prev) do {} while(0)
16301
16302 +#define pax_open_kernel() native_pax_open_kernel()
16303 +#define pax_close_kernel() native_pax_close_kernel()
16304 #endif /* CONFIG_PARAVIRT */
16305
16306 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16307 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16308 +
16309 +#ifdef CONFIG_PAX_KERNEXEC
16310 +static inline unsigned long native_pax_open_kernel(void)
16311 +{
16312 + unsigned long cr0;
16313 +
16314 + preempt_disable();
16315 + barrier();
16316 + cr0 = read_cr0() ^ X86_CR0_WP;
16317 + BUG_ON(cr0 & X86_CR0_WP);
16318 + write_cr0(cr0);
16319 + return cr0 ^ X86_CR0_WP;
16320 +}
16321 +
16322 +static inline unsigned long native_pax_close_kernel(void)
16323 +{
16324 + unsigned long cr0;
16325 +
16326 + cr0 = read_cr0() ^ X86_CR0_WP;
16327 + BUG_ON(!(cr0 & X86_CR0_WP));
16328 + write_cr0(cr0);
16329 + barrier();
16330 + preempt_enable_no_resched();
16331 + return cr0 ^ X86_CR0_WP;
16332 +}
16333 +#else
16334 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16335 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16336 +#endif
16337 +
16338 /*
16339 * The following only work if pte_present() is true.
16340 * Undefined behaviour if not..
16341 */
16342 +static inline int pte_user(pte_t pte)
16343 +{
16344 + return pte_val(pte) & _PAGE_USER;
16345 +}
16346 +
16347 static inline int pte_dirty(pte_t pte)
16348 {
16349 return pte_flags(pte) & _PAGE_DIRTY;
16350 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16351 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16352 }
16353
16354 +static inline unsigned long pgd_pfn(pgd_t pgd)
16355 +{
16356 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16357 +}
16358 +
16359 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16360
16361 static inline int pmd_large(pmd_t pte)
16362 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16363 return pte_clear_flags(pte, _PAGE_RW);
16364 }
16365
16366 +static inline pte_t pte_mkread(pte_t pte)
16367 +{
16368 + return __pte(pte_val(pte) | _PAGE_USER);
16369 +}
16370 +
16371 static inline pte_t pte_mkexec(pte_t pte)
16372 {
16373 - return pte_clear_flags(pte, _PAGE_NX);
16374 +#ifdef CONFIG_X86_PAE
16375 + if (__supported_pte_mask & _PAGE_NX)
16376 + return pte_clear_flags(pte, _PAGE_NX);
16377 + else
16378 +#endif
16379 + return pte_set_flags(pte, _PAGE_USER);
16380 +}
16381 +
16382 +static inline pte_t pte_exprotect(pte_t pte)
16383 +{
16384 +#ifdef CONFIG_X86_PAE
16385 + if (__supported_pte_mask & _PAGE_NX)
16386 + return pte_set_flags(pte, _PAGE_NX);
16387 + else
16388 +#endif
16389 + return pte_clear_flags(pte, _PAGE_USER);
16390 }
16391
16392 static inline pte_t pte_mkdirty(pte_t pte)
16393 @@ -444,6 +509,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16394 #endif
16395
16396 #ifndef __ASSEMBLY__
16397 +
16398 +#ifdef CONFIG_PAX_PER_CPU_PGD
16399 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16400 +enum cpu_pgd_type {kernel = 0, user = 1};
16401 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16402 +{
16403 + return cpu_pgd[cpu][type];
16404 +}
16405 +#endif
16406 +
16407 #include <linux/mm_types.h>
16408 #include <linux/log2.h>
16409
16410 @@ -576,7 +651,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16411 * Currently stuck as a macro due to indirect forward reference to
16412 * linux/mmzone.h's __section_mem_map_addr() definition:
16413 */
16414 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16415 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16416
16417 /* Find an entry in the second-level page table.. */
16418 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16419 @@ -616,7 +691,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16420 * Currently stuck as a macro due to indirect forward reference to
16421 * linux/mmzone.h's __section_mem_map_addr() definition:
16422 */
16423 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16424 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16425
16426 /* to find an entry in a page-table-directory. */
16427 static inline unsigned long pud_index(unsigned long address)
16428 @@ -631,7 +706,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16429
16430 static inline int pgd_bad(pgd_t pgd)
16431 {
16432 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16433 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16434 }
16435
16436 static inline int pgd_none(pgd_t pgd)
16437 @@ -654,7 +729,12 @@ static inline int pgd_none(pgd_t pgd)
16438 * pgd_offset() returns a (pgd_t *)
16439 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16440 */
16441 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16442 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16443 +
16444 +#ifdef CONFIG_PAX_PER_CPU_PGD
16445 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16446 +#endif
16447 +
16448 /*
16449 * a shortcut which implies the use of the kernel's pgd, instead
16450 * of a process's
16451 @@ -665,6 +745,23 @@ static inline int pgd_none(pgd_t pgd)
16452 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16453 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16454
16455 +#ifdef CONFIG_X86_32
16456 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16457 +#else
16458 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16459 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16460 +
16461 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16462 +#ifdef __ASSEMBLY__
16463 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16464 +#else
16465 +extern unsigned long pax_user_shadow_base;
16466 +extern pgdval_t clone_pgd_mask;
16467 +#endif
16468 +#endif
16469 +
16470 +#endif
16471 +
16472 #ifndef __ASSEMBLY__
16473
16474 extern int direct_gbpages;
16475 @@ -831,11 +928,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16476 * dst and src can be on the same page, but the range must not overlap,
16477 * and must not cross a page boundary.
16478 */
16479 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16480 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16481 {
16482 - memcpy(dst, src, count * sizeof(pgd_t));
16483 + pax_open_kernel();
16484 + while (count--)
16485 + *dst++ = *src++;
16486 + pax_close_kernel();
16487 }
16488
16489 +#ifdef CONFIG_PAX_PER_CPU_PGD
16490 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16491 +#endif
16492 +
16493 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16494 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16495 +#else
16496 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16497 +#endif
16498 +
16499 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16500 static inline int page_level_shift(enum pg_level level)
16501 {
16502 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16503 index 9ee3221..b979c6b 100644
16504 --- a/arch/x86/include/asm/pgtable_32.h
16505 +++ b/arch/x86/include/asm/pgtable_32.h
16506 @@ -25,9 +25,6 @@
16507 struct mm_struct;
16508 struct vm_area_struct;
16509
16510 -extern pgd_t swapper_pg_dir[1024];
16511 -extern pgd_t initial_page_table[1024];
16512 -
16513 static inline void pgtable_cache_init(void) { }
16514 static inline void check_pgt_cache(void) { }
16515 void paging_init(void);
16516 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16517 # include <asm/pgtable-2level.h>
16518 #endif
16519
16520 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16521 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16522 +#ifdef CONFIG_X86_PAE
16523 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16524 +#endif
16525 +
16526 #if defined(CONFIG_HIGHPTE)
16527 #define pte_offset_map(dir, address) \
16528 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16529 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16530 /* Clear a kernel PTE and flush it from the TLB */
16531 #define kpte_clear_flush(ptep, vaddr) \
16532 do { \
16533 + pax_open_kernel(); \
16534 pte_clear(&init_mm, (vaddr), (ptep)); \
16535 + pax_close_kernel(); \
16536 __flush_tlb_one((vaddr)); \
16537 } while (0)
16538
16539 #endif /* !__ASSEMBLY__ */
16540
16541 +#define HAVE_ARCH_UNMAPPED_AREA
16542 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16543 +
16544 /*
16545 * kern_addr_valid() is (1) for FLATMEM and (0) for
16546 * SPARSEMEM and DISCONTIGMEM
16547 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16548 index ed5903b..c7fe163 100644
16549 --- a/arch/x86/include/asm/pgtable_32_types.h
16550 +++ b/arch/x86/include/asm/pgtable_32_types.h
16551 @@ -8,7 +8,7 @@
16552 */
16553 #ifdef CONFIG_X86_PAE
16554 # include <asm/pgtable-3level_types.h>
16555 -# define PMD_SIZE (1UL << PMD_SHIFT)
16556 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16557 # define PMD_MASK (~(PMD_SIZE - 1))
16558 #else
16559 # include <asm/pgtable-2level_types.h>
16560 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16561 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16562 #endif
16563
16564 +#ifdef CONFIG_PAX_KERNEXEC
16565 +#ifndef __ASSEMBLY__
16566 +extern unsigned char MODULES_EXEC_VADDR[];
16567 +extern unsigned char MODULES_EXEC_END[];
16568 +#endif
16569 +#include <asm/boot.h>
16570 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16571 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16572 +#else
16573 +#define ktla_ktva(addr) (addr)
16574 +#define ktva_ktla(addr) (addr)
16575 +#endif
16576 +
16577 #define MODULES_VADDR VMALLOC_START
16578 #define MODULES_END VMALLOC_END
16579 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16580 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16581 index e22c1db..23a625a 100644
16582 --- a/arch/x86/include/asm/pgtable_64.h
16583 +++ b/arch/x86/include/asm/pgtable_64.h
16584 @@ -16,10 +16,14 @@
16585
16586 extern pud_t level3_kernel_pgt[512];
16587 extern pud_t level3_ident_pgt[512];
16588 +extern pud_t level3_vmalloc_start_pgt[512];
16589 +extern pud_t level3_vmalloc_end_pgt[512];
16590 +extern pud_t level3_vmemmap_pgt[512];
16591 +extern pud_t level2_vmemmap_pgt[512];
16592 extern pmd_t level2_kernel_pgt[512];
16593 extern pmd_t level2_fixmap_pgt[512];
16594 -extern pmd_t level2_ident_pgt[512];
16595 -extern pgd_t init_level4_pgt[];
16596 +extern pmd_t level2_ident_pgt[512*2];
16597 +extern pgd_t init_level4_pgt[512];
16598
16599 #define swapper_pg_dir init_level4_pgt
16600
16601 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16602
16603 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16604 {
16605 + pax_open_kernel();
16606 *pmdp = pmd;
16607 + pax_close_kernel();
16608 }
16609
16610 static inline void native_pmd_clear(pmd_t *pmd)
16611 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16612
16613 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16614 {
16615 + pax_open_kernel();
16616 *pudp = pud;
16617 + pax_close_kernel();
16618 }
16619
16620 static inline void native_pud_clear(pud_t *pud)
16621 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16622
16623 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16624 {
16625 + pax_open_kernel();
16626 + *pgdp = pgd;
16627 + pax_close_kernel();
16628 +}
16629 +
16630 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16631 +{
16632 *pgdp = pgd;
16633 }
16634
16635 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16636 index 2d88344..4679fc3 100644
16637 --- a/arch/x86/include/asm/pgtable_64_types.h
16638 +++ b/arch/x86/include/asm/pgtable_64_types.h
16639 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16640 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16641 #define MODULES_END _AC(0xffffffffff000000, UL)
16642 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16643 +#define MODULES_EXEC_VADDR MODULES_VADDR
16644 +#define MODULES_EXEC_END MODULES_END
16645 +
16646 +#define ktla_ktva(addr) (addr)
16647 +#define ktva_ktla(addr) (addr)
16648
16649 #define EARLY_DYNAMIC_PAGE_TABLES 64
16650
16651 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16652 index f4843e0..a2526f8 100644
16653 --- a/arch/x86/include/asm/pgtable_types.h
16654 +++ b/arch/x86/include/asm/pgtable_types.h
16655 @@ -16,13 +16,12 @@
16656 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16657 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16658 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16659 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16660 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16661 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16662 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16663 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16664 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16665 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16666 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16667 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16668 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16669 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16670
16671 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16672 @@ -40,7 +39,6 @@
16673 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16674 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16675 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16676 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16677 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16678 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16679 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16680 @@ -84,8 +82,10 @@
16681
16682 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16683 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16684 -#else
16685 +#elif defined(CONFIG_KMEMCHECK)
16686 #define _PAGE_NX (_AT(pteval_t, 0))
16687 +#else
16688 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16689 #endif
16690
16691 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16692 @@ -143,6 +143,9 @@
16693 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16694 _PAGE_ACCESSED)
16695
16696 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16697 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16698 +
16699 #define __PAGE_KERNEL_EXEC \
16700 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16701 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16702 @@ -153,7 +156,7 @@
16703 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16704 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16705 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16706 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16707 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16708 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16709 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16710 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16711 @@ -215,8 +218,8 @@
16712 * bits are combined, this will alow user to access the high address mapped
16713 * VDSO in the presence of CONFIG_COMPAT_VDSO
16714 */
16715 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16716 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16717 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16718 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16719 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16720 #endif
16721
16722 @@ -254,7 +257,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16723 {
16724 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16725 }
16726 +#endif
16727
16728 +#if PAGETABLE_LEVELS == 3
16729 +#include <asm-generic/pgtable-nopud.h>
16730 +#endif
16731 +
16732 +#if PAGETABLE_LEVELS == 2
16733 +#include <asm-generic/pgtable-nopmd.h>
16734 +#endif
16735 +
16736 +#ifndef __ASSEMBLY__
16737 #if PAGETABLE_LEVELS > 3
16738 typedef struct { pudval_t pud; } pud_t;
16739
16740 @@ -268,8 +281,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16741 return pud.pud;
16742 }
16743 #else
16744 -#include <asm-generic/pgtable-nopud.h>
16745 -
16746 static inline pudval_t native_pud_val(pud_t pud)
16747 {
16748 return native_pgd_val(pud.pgd);
16749 @@ -289,8 +300,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16750 return pmd.pmd;
16751 }
16752 #else
16753 -#include <asm-generic/pgtable-nopmd.h>
16754 -
16755 static inline pmdval_t native_pmd_val(pmd_t pmd)
16756 {
16757 return native_pgd_val(pmd.pud.pgd);
16758 @@ -330,7 +339,6 @@ typedef struct page *pgtable_t;
16759
16760 extern pteval_t __supported_pte_mask;
16761 extern void set_nx(void);
16762 -extern int nx_enabled;
16763
16764 #define pgprot_writecombine pgprot_writecombine
16765 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16766 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16767 index 24cf5ae..4d9fa2d 100644
16768 --- a/arch/x86/include/asm/processor.h
16769 +++ b/arch/x86/include/asm/processor.h
16770 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16771 : "memory");
16772 }
16773
16774 +/* invpcid (%rdx),%rax */
16775 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16776 +
16777 +#define INVPCID_SINGLE_ADDRESS 0UL
16778 +#define INVPCID_SINGLE_CONTEXT 1UL
16779 +#define INVPCID_ALL_GLOBAL 2UL
16780 +#define INVPCID_ALL_MONGLOBAL 3UL
16781 +
16782 +#define PCID_KERNEL 0UL
16783 +#define PCID_USER 1UL
16784 +#define PCID_NOFLUSH (1UL << 63)
16785 +
16786 static inline void load_cr3(pgd_t *pgdir)
16787 {
16788 - write_cr3(__pa(pgdir));
16789 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16790 }
16791
16792 #ifdef CONFIG_X86_32
16793 @@ -283,7 +295,7 @@ struct tss_struct {
16794
16795 } ____cacheline_aligned;
16796
16797 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16798 +extern struct tss_struct init_tss[NR_CPUS];
16799
16800 /*
16801 * Save the original ist values for checking stack pointers during debugging
16802 @@ -453,6 +465,7 @@ struct thread_struct {
16803 unsigned short ds;
16804 unsigned short fsindex;
16805 unsigned short gsindex;
16806 + unsigned short ss;
16807 #endif
16808 #ifdef CONFIG_X86_32
16809 unsigned long ip;
16810 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16811 extern unsigned long mmu_cr4_features;
16812 extern u32 *trampoline_cr4_features;
16813
16814 -static inline void set_in_cr4(unsigned long mask)
16815 -{
16816 - unsigned long cr4;
16817 -
16818 - mmu_cr4_features |= mask;
16819 - if (trampoline_cr4_features)
16820 - *trampoline_cr4_features = mmu_cr4_features;
16821 - cr4 = read_cr4();
16822 - cr4 |= mask;
16823 - write_cr4(cr4);
16824 -}
16825 -
16826 -static inline void clear_in_cr4(unsigned long mask)
16827 -{
16828 - unsigned long cr4;
16829 -
16830 - mmu_cr4_features &= ~mask;
16831 - if (trampoline_cr4_features)
16832 - *trampoline_cr4_features = mmu_cr4_features;
16833 - cr4 = read_cr4();
16834 - cr4 &= ~mask;
16835 - write_cr4(cr4);
16836 -}
16837 +extern void set_in_cr4(unsigned long mask);
16838 +extern void clear_in_cr4(unsigned long mask);
16839
16840 typedef struct {
16841 unsigned long seg;
16842 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16843 */
16844 #define TASK_SIZE PAGE_OFFSET
16845 #define TASK_SIZE_MAX TASK_SIZE
16846 +
16847 +#ifdef CONFIG_PAX_SEGMEXEC
16848 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16849 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16850 +#else
16851 #define STACK_TOP TASK_SIZE
16852 -#define STACK_TOP_MAX STACK_TOP
16853 +#endif
16854 +
16855 +#define STACK_TOP_MAX TASK_SIZE
16856
16857 #define INIT_THREAD { \
16858 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16859 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16860 .vm86_info = NULL, \
16861 .sysenter_cs = __KERNEL_CS, \
16862 .io_bitmap_ptr = NULL, \
16863 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16864 */
16865 #define INIT_TSS { \
16866 .x86_tss = { \
16867 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16868 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16869 .ss0 = __KERNEL_DS, \
16870 .ss1 = __KERNEL_CS, \
16871 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16872 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16873 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16874
16875 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16876 -#define KSTK_TOP(info) \
16877 -({ \
16878 - unsigned long *__ptr = (unsigned long *)(info); \
16879 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16880 -})
16881 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16882
16883 /*
16884 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16885 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16886 #define task_pt_regs(task) \
16887 ({ \
16888 struct pt_regs *__regs__; \
16889 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16890 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16891 __regs__ - 1; \
16892 })
16893
16894 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16895 /*
16896 * User space process size. 47bits minus one guard page.
16897 */
16898 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16899 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16900
16901 /* This decides where the kernel will search for a free chunk of vm
16902 * space during mmap's.
16903 */
16904 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16905 - 0xc0000000 : 0xFFFFe000)
16906 + 0xc0000000 : 0xFFFFf000)
16907
16908 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16909 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16910 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16911 #define STACK_TOP_MAX TASK_SIZE_MAX
16912
16913 #define INIT_THREAD { \
16914 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16915 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16916 }
16917
16918 #define INIT_TSS { \
16919 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16920 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16921 }
16922
16923 /*
16924 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16925 */
16926 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16927
16928 +#ifdef CONFIG_PAX_SEGMEXEC
16929 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16930 +#endif
16931 +
16932 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16933
16934 /* Get/set a process' ability to use the timestamp counter instruction */
16935 @@ -943,7 +942,8 @@ extern int set_tsc_mode(unsigned int val);
16936 extern u16 amd_get_nb_id(int cpu);
16937
16938 struct aperfmperf {
16939 - u64 aperf, mperf;
16940 + u64 aperf __intentional_overflow(0);
16941 + u64 mperf __intentional_overflow(0);
16942 };
16943
16944 static inline void get_aperfmperf(struct aperfmperf *am)
16945 @@ -971,7 +971,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
16946 return ratio;
16947 }
16948
16949 -extern unsigned long arch_align_stack(unsigned long sp);
16950 +#define arch_align_stack(x) ((x) & ~0xfUL)
16951 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16952
16953 void default_idle(void);
16954 @@ -981,6 +981,6 @@ bool xen_set_default_idle(void);
16955 #define xen_set_default_idle 0
16956 #endif
16957
16958 -void stop_this_cpu(void *dummy);
16959 +void stop_this_cpu(void *dummy) __noreturn;
16960 void df_debug(struct pt_regs *regs, long error_code);
16961 #endif /* _ASM_X86_PROCESSOR_H */
16962 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16963 index 942a086..6c26446 100644
16964 --- a/arch/x86/include/asm/ptrace.h
16965 +++ b/arch/x86/include/asm/ptrace.h
16966 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16967 }
16968
16969 /*
16970 - * user_mode_vm(regs) determines whether a register set came from user mode.
16971 + * user_mode(regs) determines whether a register set came from user mode.
16972 * This is true if V8086 mode was enabled OR if the register set was from
16973 * protected mode with RPL-3 CS value. This tricky test checks that with
16974 * one comparison. Many places in the kernel can bypass this full check
16975 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
16976 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
16977 + * be used.
16978 */
16979 -static inline int user_mode(struct pt_regs *regs)
16980 +static inline int user_mode_novm(struct pt_regs *regs)
16981 {
16982 #ifdef CONFIG_X86_32
16983 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
16984 #else
16985 - return !!(regs->cs & 3);
16986 + return !!(regs->cs & SEGMENT_RPL_MASK);
16987 #endif
16988 }
16989
16990 -static inline int user_mode_vm(struct pt_regs *regs)
16991 +static inline int user_mode(struct pt_regs *regs)
16992 {
16993 #ifdef CONFIG_X86_32
16994 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
16995 USER_RPL;
16996 #else
16997 - return user_mode(regs);
16998 + return user_mode_novm(regs);
16999 #endif
17000 }
17001
17002 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17003 #ifdef CONFIG_X86_64
17004 static inline bool user_64bit_mode(struct pt_regs *regs)
17005 {
17006 + unsigned long cs = regs->cs & 0xffff;
17007 #ifndef CONFIG_PARAVIRT
17008 /*
17009 * On non-paravirt systems, this is the only long mode CPL 3
17010 * selector. We do not allow long mode selectors in the LDT.
17011 */
17012 - return regs->cs == __USER_CS;
17013 + return cs == __USER_CS;
17014 #else
17015 /* Headers are too twisted for this to go in paravirt.h. */
17016 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17017 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17018 #endif
17019 }
17020
17021 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17022 * Traps from the kernel do not save sp and ss.
17023 * Use the helper function to retrieve sp.
17024 */
17025 - if (offset == offsetof(struct pt_regs, sp) &&
17026 - regs->cs == __KERNEL_CS)
17027 - return kernel_stack_pointer(regs);
17028 + if (offset == offsetof(struct pt_regs, sp)) {
17029 + unsigned long cs = regs->cs & 0xffff;
17030 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17031 + return kernel_stack_pointer(regs);
17032 + }
17033 #endif
17034 return *(unsigned long *)((unsigned long)regs + offset);
17035 }
17036 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17037 index 9c6b890..5305f53 100644
17038 --- a/arch/x86/include/asm/realmode.h
17039 +++ b/arch/x86/include/asm/realmode.h
17040 @@ -22,16 +22,14 @@ struct real_mode_header {
17041 #endif
17042 /* APM/BIOS reboot */
17043 u32 machine_real_restart_asm;
17044 -#ifdef CONFIG_X86_64
17045 u32 machine_real_restart_seg;
17046 -#endif
17047 };
17048
17049 /* This must match data at trampoline_32/64.S */
17050 struct trampoline_header {
17051 #ifdef CONFIG_X86_32
17052 u32 start;
17053 - u16 gdt_pad;
17054 + u16 boot_cs;
17055 u16 gdt_limit;
17056 u32 gdt_base;
17057 #else
17058 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17059 index a82c4f1..ac45053 100644
17060 --- a/arch/x86/include/asm/reboot.h
17061 +++ b/arch/x86/include/asm/reboot.h
17062 @@ -6,13 +6,13 @@
17063 struct pt_regs;
17064
17065 struct machine_ops {
17066 - void (*restart)(char *cmd);
17067 - void (*halt)(void);
17068 - void (*power_off)(void);
17069 + void (* __noreturn restart)(char *cmd);
17070 + void (* __noreturn halt)(void);
17071 + void (* __noreturn power_off)(void);
17072 void (*shutdown)(void);
17073 void (*crash_shutdown)(struct pt_regs *);
17074 - void (*emergency_restart)(void);
17075 -};
17076 + void (* __noreturn emergency_restart)(void);
17077 +} __no_const;
17078
17079 extern struct machine_ops machine_ops;
17080
17081 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17082 index cad82c9..2e5c5c1 100644
17083 --- a/arch/x86/include/asm/rwsem.h
17084 +++ b/arch/x86/include/asm/rwsem.h
17085 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17086 {
17087 asm volatile("# beginning down_read\n\t"
17088 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17089 +
17090 +#ifdef CONFIG_PAX_REFCOUNT
17091 + "jno 0f\n"
17092 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17093 + "int $4\n0:\n"
17094 + _ASM_EXTABLE(0b, 0b)
17095 +#endif
17096 +
17097 /* adds 0x00000001 */
17098 " jns 1f\n"
17099 " call call_rwsem_down_read_failed\n"
17100 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17101 "1:\n\t"
17102 " mov %1,%2\n\t"
17103 " add %3,%2\n\t"
17104 +
17105 +#ifdef CONFIG_PAX_REFCOUNT
17106 + "jno 0f\n"
17107 + "sub %3,%2\n"
17108 + "int $4\n0:\n"
17109 + _ASM_EXTABLE(0b, 0b)
17110 +#endif
17111 +
17112 " jle 2f\n\t"
17113 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17114 " jnz 1b\n\t"
17115 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17116 long tmp;
17117 asm volatile("# beginning down_write\n\t"
17118 LOCK_PREFIX " xadd %1,(%2)\n\t"
17119 +
17120 +#ifdef CONFIG_PAX_REFCOUNT
17121 + "jno 0f\n"
17122 + "mov %1,(%2)\n"
17123 + "int $4\n0:\n"
17124 + _ASM_EXTABLE(0b, 0b)
17125 +#endif
17126 +
17127 /* adds 0xffff0001, returns the old value */
17128 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17129 /* was the active mask 0 before? */
17130 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17131 long tmp;
17132 asm volatile("# beginning __up_read\n\t"
17133 LOCK_PREFIX " xadd %1,(%2)\n\t"
17134 +
17135 +#ifdef CONFIG_PAX_REFCOUNT
17136 + "jno 0f\n"
17137 + "mov %1,(%2)\n"
17138 + "int $4\n0:\n"
17139 + _ASM_EXTABLE(0b, 0b)
17140 +#endif
17141 +
17142 /* subtracts 1, returns the old value */
17143 " jns 1f\n\t"
17144 " call call_rwsem_wake\n" /* expects old value in %edx */
17145 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17146 long tmp;
17147 asm volatile("# beginning __up_write\n\t"
17148 LOCK_PREFIX " xadd %1,(%2)\n\t"
17149 +
17150 +#ifdef CONFIG_PAX_REFCOUNT
17151 + "jno 0f\n"
17152 + "mov %1,(%2)\n"
17153 + "int $4\n0:\n"
17154 + _ASM_EXTABLE(0b, 0b)
17155 +#endif
17156 +
17157 /* subtracts 0xffff0001, returns the old value */
17158 " jns 1f\n\t"
17159 " call call_rwsem_wake\n" /* expects old value in %edx */
17160 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17161 {
17162 asm volatile("# beginning __downgrade_write\n\t"
17163 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17164 +
17165 +#ifdef CONFIG_PAX_REFCOUNT
17166 + "jno 0f\n"
17167 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17168 + "int $4\n0:\n"
17169 + _ASM_EXTABLE(0b, 0b)
17170 +#endif
17171 +
17172 /*
17173 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17174 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17175 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17176 */
17177 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17178 {
17179 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17180 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17181 +
17182 +#ifdef CONFIG_PAX_REFCOUNT
17183 + "jno 0f\n"
17184 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17185 + "int $4\n0:\n"
17186 + _ASM_EXTABLE(0b, 0b)
17187 +#endif
17188 +
17189 : "+m" (sem->count)
17190 : "er" (delta));
17191 }
17192 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17193 */
17194 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17195 {
17196 - return delta + xadd(&sem->count, delta);
17197 + return delta + xadd_check_overflow(&sem->count, delta);
17198 }
17199
17200 #endif /* __KERNEL__ */
17201 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17202 index c48a950..bc40804 100644
17203 --- a/arch/x86/include/asm/segment.h
17204 +++ b/arch/x86/include/asm/segment.h
17205 @@ -64,10 +64,15 @@
17206 * 26 - ESPFIX small SS
17207 * 27 - per-cpu [ offset to per-cpu data area ]
17208 * 28 - stack_canary-20 [ for stack protector ]
17209 - * 29 - unused
17210 - * 30 - unused
17211 + * 29 - PCI BIOS CS
17212 + * 30 - PCI BIOS DS
17213 * 31 - TSS for double fault handler
17214 */
17215 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17216 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17217 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17218 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17219 +
17220 #define GDT_ENTRY_TLS_MIN 6
17221 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17222
17223 @@ -79,6 +84,8 @@
17224
17225 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17226
17227 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17228 +
17229 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17230
17231 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17232 @@ -104,6 +111,12 @@
17233 #define __KERNEL_STACK_CANARY 0
17234 #endif
17235
17236 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17237 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17238 +
17239 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17240 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17241 +
17242 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17243
17244 /*
17245 @@ -141,7 +154,7 @@
17246 */
17247
17248 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17249 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17250 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17251
17252
17253 #else
17254 @@ -165,6 +178,8 @@
17255 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17256 #define __USER32_DS __USER_DS
17257
17258 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17259 +
17260 #define GDT_ENTRY_TSS 8 /* needs two entries */
17261 #define GDT_ENTRY_LDT 10 /* needs two entries */
17262 #define GDT_ENTRY_TLS_MIN 12
17263 @@ -173,6 +188,8 @@
17264 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17265 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17266
17267 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17268 +
17269 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17270 #define FS_TLS 0
17271 #define GS_TLS 1
17272 @@ -180,12 +197,14 @@
17273 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17274 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17275
17276 -#define GDT_ENTRIES 16
17277 +#define GDT_ENTRIES 17
17278
17279 #endif
17280
17281 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17282 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17283 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17284 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17285 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17286 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17287 #ifndef CONFIG_PARAVIRT
17288 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17289 {
17290 unsigned long __limit;
17291 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17292 - return __limit + 1;
17293 + return __limit;
17294 }
17295
17296 #endif /* !__ASSEMBLY__ */
17297 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17298 index 8d3120f..352b440 100644
17299 --- a/arch/x86/include/asm/smap.h
17300 +++ b/arch/x86/include/asm/smap.h
17301 @@ -25,11 +25,40 @@
17302
17303 #include <asm/alternative-asm.h>
17304
17305 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17306 +#define ASM_PAX_OPEN_USERLAND \
17307 + 661: jmp 663f; \
17308 + .pushsection .altinstr_replacement, "a" ; \
17309 + 662: pushq %rax; nop; \
17310 + .popsection ; \
17311 + .pushsection .altinstructions, "a" ; \
17312 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17313 + .popsection ; \
17314 + call __pax_open_userland; \
17315 + popq %rax; \
17316 + 663:
17317 +
17318 +#define ASM_PAX_CLOSE_USERLAND \
17319 + 661: jmp 663f; \
17320 + .pushsection .altinstr_replacement, "a" ; \
17321 + 662: pushq %rax; nop; \
17322 + .popsection; \
17323 + .pushsection .altinstructions, "a" ; \
17324 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17325 + .popsection; \
17326 + call __pax_close_userland; \
17327 + popq %rax; \
17328 + 663:
17329 +#else
17330 +#define ASM_PAX_OPEN_USERLAND
17331 +#define ASM_PAX_CLOSE_USERLAND
17332 +#endif
17333 +
17334 #ifdef CONFIG_X86_SMAP
17335
17336 #define ASM_CLAC \
17337 661: ASM_NOP3 ; \
17338 - .pushsection .altinstr_replacement, "ax" ; \
17339 + .pushsection .altinstr_replacement, "a" ; \
17340 662: __ASM_CLAC ; \
17341 .popsection ; \
17342 .pushsection .altinstructions, "a" ; \
17343 @@ -38,7 +67,7 @@
17344
17345 #define ASM_STAC \
17346 661: ASM_NOP3 ; \
17347 - .pushsection .altinstr_replacement, "ax" ; \
17348 + .pushsection .altinstr_replacement, "a" ; \
17349 662: __ASM_STAC ; \
17350 .popsection ; \
17351 .pushsection .altinstructions, "a" ; \
17352 @@ -56,6 +85,37 @@
17353
17354 #include <asm/alternative.h>
17355
17356 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17357 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17358 +
17359 +extern void __pax_open_userland(void);
17360 +static __always_inline unsigned long pax_open_userland(void)
17361 +{
17362 +
17363 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17364 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17365 + :
17366 + : [open] "i" (__pax_open_userland)
17367 + : "memory", "rax");
17368 +#endif
17369 +
17370 + return 0;
17371 +}
17372 +
17373 +extern void __pax_close_userland(void);
17374 +static __always_inline unsigned long pax_close_userland(void)
17375 +{
17376 +
17377 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17378 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17379 + :
17380 + : [close] "i" (__pax_close_userland)
17381 + : "memory", "rax");
17382 +#endif
17383 +
17384 + return 0;
17385 +}
17386 +
17387 #ifdef CONFIG_X86_SMAP
17388
17389 static __always_inline void clac(void)
17390 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17391 index 4137890..03fa172 100644
17392 --- a/arch/x86/include/asm/smp.h
17393 +++ b/arch/x86/include/asm/smp.h
17394 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17395 /* cpus sharing the last level cache: */
17396 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17397 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17398 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17399 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17400
17401 static inline struct cpumask *cpu_sibling_mask(int cpu)
17402 {
17403 @@ -79,7 +79,7 @@ struct smp_ops {
17404
17405 void (*send_call_func_ipi)(const struct cpumask *mask);
17406 void (*send_call_func_single_ipi)(int cpu);
17407 -};
17408 +} __no_const;
17409
17410 /* Globals due to paravirt */
17411 extern void set_cpu_sibling_map(int cpu);
17412 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17413 extern int safe_smp_processor_id(void);
17414
17415 #elif defined(CONFIG_X86_64_SMP)
17416 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17417 -
17418 -#define stack_smp_processor_id() \
17419 -({ \
17420 - struct thread_info *ti; \
17421 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17422 - ti->cpu; \
17423 -})
17424 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17425 +#define stack_smp_processor_id() raw_smp_processor_id()
17426 #define safe_smp_processor_id() smp_processor_id()
17427
17428 #endif
17429 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17430 index e3ddd7d..3611fce 100644
17431 --- a/arch/x86/include/asm/spinlock.h
17432 +++ b/arch/x86/include/asm/spinlock.h
17433 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17434 static inline void arch_read_lock(arch_rwlock_t *rw)
17435 {
17436 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17437 +
17438 +#ifdef CONFIG_PAX_REFCOUNT
17439 + "jno 0f\n"
17440 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17441 + "int $4\n0:\n"
17442 + _ASM_EXTABLE(0b, 0b)
17443 +#endif
17444 +
17445 "jns 1f\n"
17446 "call __read_lock_failed\n\t"
17447 "1:\n"
17448 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17449 static inline void arch_write_lock(arch_rwlock_t *rw)
17450 {
17451 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17452 +
17453 +#ifdef CONFIG_PAX_REFCOUNT
17454 + "jno 0f\n"
17455 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17456 + "int $4\n0:\n"
17457 + _ASM_EXTABLE(0b, 0b)
17458 +#endif
17459 +
17460 "jz 1f\n"
17461 "call __write_lock_failed\n\t"
17462 "1:\n"
17463 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17464
17465 static inline void arch_read_unlock(arch_rwlock_t *rw)
17466 {
17467 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17468 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17469 +
17470 +#ifdef CONFIG_PAX_REFCOUNT
17471 + "jno 0f\n"
17472 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17473 + "int $4\n0:\n"
17474 + _ASM_EXTABLE(0b, 0b)
17475 +#endif
17476 +
17477 :"+m" (rw->lock) : : "memory");
17478 }
17479
17480 static inline void arch_write_unlock(arch_rwlock_t *rw)
17481 {
17482 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17483 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17484 +
17485 +#ifdef CONFIG_PAX_REFCOUNT
17486 + "jno 0f\n"
17487 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17488 + "int $4\n0:\n"
17489 + _ASM_EXTABLE(0b, 0b)
17490 +#endif
17491 +
17492 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17493 }
17494
17495 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17496 index 6a99859..03cb807 100644
17497 --- a/arch/x86/include/asm/stackprotector.h
17498 +++ b/arch/x86/include/asm/stackprotector.h
17499 @@ -47,7 +47,7 @@
17500 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17501 */
17502 #define GDT_STACK_CANARY_INIT \
17503 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17504 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17505
17506 /*
17507 * Initialize the stackprotector canary value.
17508 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17509
17510 static inline void load_stack_canary_segment(void)
17511 {
17512 -#ifdef CONFIG_X86_32
17513 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17514 asm volatile ("mov %0, %%gs" : : "r" (0));
17515 #endif
17516 }
17517 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17518 index 70bbe39..4ae2bd4 100644
17519 --- a/arch/x86/include/asm/stacktrace.h
17520 +++ b/arch/x86/include/asm/stacktrace.h
17521 @@ -11,28 +11,20 @@
17522
17523 extern int kstack_depth_to_print;
17524
17525 -struct thread_info;
17526 +struct task_struct;
17527 struct stacktrace_ops;
17528
17529 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17530 - unsigned long *stack,
17531 - unsigned long bp,
17532 - const struct stacktrace_ops *ops,
17533 - void *data,
17534 - unsigned long *end,
17535 - int *graph);
17536 +typedef unsigned long walk_stack_t(struct task_struct *task,
17537 + void *stack_start,
17538 + unsigned long *stack,
17539 + unsigned long bp,
17540 + const struct stacktrace_ops *ops,
17541 + void *data,
17542 + unsigned long *end,
17543 + int *graph);
17544
17545 -extern unsigned long
17546 -print_context_stack(struct thread_info *tinfo,
17547 - unsigned long *stack, unsigned long bp,
17548 - const struct stacktrace_ops *ops, void *data,
17549 - unsigned long *end, int *graph);
17550 -
17551 -extern unsigned long
17552 -print_context_stack_bp(struct thread_info *tinfo,
17553 - unsigned long *stack, unsigned long bp,
17554 - const struct stacktrace_ops *ops, void *data,
17555 - unsigned long *end, int *graph);
17556 +extern walk_stack_t print_context_stack;
17557 +extern walk_stack_t print_context_stack_bp;
17558
17559 /* Generic stack tracer with callbacks */
17560
17561 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17562 void (*address)(void *data, unsigned long address, int reliable);
17563 /* On negative return stop dumping */
17564 int (*stack)(void *data, char *name);
17565 - walk_stack_t walk_stack;
17566 + walk_stack_t *walk_stack;
17567 };
17568
17569 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17570 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17571 index 4ec45b3..a4f0a8a 100644
17572 --- a/arch/x86/include/asm/switch_to.h
17573 +++ b/arch/x86/include/asm/switch_to.h
17574 @@ -108,7 +108,7 @@ do { \
17575 "call __switch_to\n\t" \
17576 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17577 __switch_canary \
17578 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17579 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17580 "movq %%rax,%%rdi\n\t" \
17581 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17582 "jnz ret_from_fork\n\t" \
17583 @@ -119,7 +119,7 @@ do { \
17584 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17585 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17586 [_tif_fork] "i" (_TIF_FORK), \
17587 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17588 + [thread_info] "m" (current_tinfo), \
17589 [current_task] "m" (current_task) \
17590 __switch_canary_iparam \
17591 : "memory", "cc" __EXTRA_CLOBBER)
17592 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17593 index 2781119..618b59b 100644
17594 --- a/arch/x86/include/asm/thread_info.h
17595 +++ b/arch/x86/include/asm/thread_info.h
17596 @@ -10,6 +10,7 @@
17597 #include <linux/compiler.h>
17598 #include <asm/page.h>
17599 #include <asm/types.h>
17600 +#include <asm/percpu.h>
17601
17602 /*
17603 * low level task data that entry.S needs immediate access to
17604 @@ -23,7 +24,6 @@ struct exec_domain;
17605 #include <linux/atomic.h>
17606
17607 struct thread_info {
17608 - struct task_struct *task; /* main task structure */
17609 struct exec_domain *exec_domain; /* execution domain */
17610 __u32 flags; /* low level flags */
17611 __u32 status; /* thread synchronous flags */
17612 @@ -33,19 +33,13 @@ struct thread_info {
17613 mm_segment_t addr_limit;
17614 struct restart_block restart_block;
17615 void __user *sysenter_return;
17616 -#ifdef CONFIG_X86_32
17617 - unsigned long previous_esp; /* ESP of the previous stack in
17618 - case of nested (IRQ) stacks
17619 - */
17620 - __u8 supervisor_stack[0];
17621 -#endif
17622 + unsigned long lowest_stack;
17623 unsigned int sig_on_uaccess_error:1;
17624 unsigned int uaccess_err:1; /* uaccess failed */
17625 };
17626
17627 -#define INIT_THREAD_INFO(tsk) \
17628 +#define INIT_THREAD_INFO \
17629 { \
17630 - .task = &tsk, \
17631 .exec_domain = &default_exec_domain, \
17632 .flags = 0, \
17633 .cpu = 0, \
17634 @@ -56,7 +50,7 @@ struct thread_info {
17635 }, \
17636 }
17637
17638 -#define init_thread_info (init_thread_union.thread_info)
17639 +#define init_thread_info (init_thread_union.stack)
17640 #define init_stack (init_thread_union.stack)
17641
17642 #else /* !__ASSEMBLY__ */
17643 @@ -96,6 +90,7 @@ struct thread_info {
17644 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17645 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17646 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17647 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17648
17649 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17650 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17651 @@ -119,17 +114,18 @@ struct thread_info {
17652 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17653 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17654 #define _TIF_X32 (1 << TIF_X32)
17655 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17656
17657 /* work to do in syscall_trace_enter() */
17658 #define _TIF_WORK_SYSCALL_ENTRY \
17659 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17660 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17661 - _TIF_NOHZ)
17662 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17663
17664 /* work to do in syscall_trace_leave() */
17665 #define _TIF_WORK_SYSCALL_EXIT \
17666 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17667 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17668 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17669
17670 /* work to do on interrupt/exception return */
17671 #define _TIF_WORK_MASK \
17672 @@ -140,7 +136,7 @@ struct thread_info {
17673 /* work to do on any return to user space */
17674 #define _TIF_ALLWORK_MASK \
17675 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17676 - _TIF_NOHZ)
17677 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17678
17679 /* Only used for 64 bit */
17680 #define _TIF_DO_NOTIFY_MASK \
17681 @@ -156,45 +152,40 @@ struct thread_info {
17682
17683 #define PREEMPT_ACTIVE 0x10000000
17684
17685 -#ifdef CONFIG_X86_32
17686 -
17687 -#define STACK_WARN (THREAD_SIZE/8)
17688 -/*
17689 - * macros/functions for gaining access to the thread information structure
17690 - *
17691 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17692 - */
17693 -#ifndef __ASSEMBLY__
17694 -
17695 -
17696 -/* how to get the current stack pointer from C */
17697 -register unsigned long current_stack_pointer asm("esp") __used;
17698 -
17699 -/* how to get the thread information struct from C */
17700 -static inline struct thread_info *current_thread_info(void)
17701 -{
17702 - return (struct thread_info *)
17703 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17704 -}
17705 -
17706 -#else /* !__ASSEMBLY__ */
17707 -
17708 +#ifdef __ASSEMBLY__
17709 /* how to get the thread information struct from ASM */
17710 #define GET_THREAD_INFO(reg) \
17711 - movl $-THREAD_SIZE, reg; \
17712 - andl %esp, reg
17713 + mov PER_CPU_VAR(current_tinfo), reg
17714
17715 /* use this one if reg already contains %esp */
17716 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17717 - andl $-THREAD_SIZE, reg
17718 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17719 +#else
17720 +/* how to get the thread information struct from C */
17721 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17722 +
17723 +static __always_inline struct thread_info *current_thread_info(void)
17724 +{
17725 + return this_cpu_read_stable(current_tinfo);
17726 +}
17727 +#endif
17728 +
17729 +#ifdef CONFIG_X86_32
17730 +
17731 +#define STACK_WARN (THREAD_SIZE/8)
17732 +/*
17733 + * macros/functions for gaining access to the thread information structure
17734 + *
17735 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17736 + */
17737 +#ifndef __ASSEMBLY__
17738 +
17739 +/* how to get the current stack pointer from C */
17740 +register unsigned long current_stack_pointer asm("esp") __used;
17741
17742 #endif
17743
17744 #else /* X86_32 */
17745
17746 -#include <asm/percpu.h>
17747 -#define KERNEL_STACK_OFFSET (5*8)
17748 -
17749 /*
17750 * macros/functions for gaining access to the thread information structure
17751 * preempt_count needs to be 1 initially, until the scheduler is functional.
17752 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17753 #ifndef __ASSEMBLY__
17754 DECLARE_PER_CPU(unsigned long, kernel_stack);
17755
17756 -static inline struct thread_info *current_thread_info(void)
17757 -{
17758 - struct thread_info *ti;
17759 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17760 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17761 - return ti;
17762 -}
17763 -
17764 -#else /* !__ASSEMBLY__ */
17765 -
17766 -/* how to get the thread information struct from ASM */
17767 -#define GET_THREAD_INFO(reg) \
17768 - movq PER_CPU_VAR(kernel_stack),reg ; \
17769 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17770 -
17771 -/*
17772 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17773 - * a certain register (to be used in assembler memory operands).
17774 - */
17775 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17776 -
17777 +/* how to get the current stack pointer from C */
17778 +register unsigned long current_stack_pointer asm("rsp") __used;
17779 #endif
17780
17781 #endif /* !X86_32 */
17782 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17783 extern void arch_task_cache_init(void);
17784 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17785 extern void arch_release_task_struct(struct task_struct *tsk);
17786 +
17787 +#define __HAVE_THREAD_FUNCTIONS
17788 +#define task_thread_info(task) (&(task)->tinfo)
17789 +#define task_stack_page(task) ((task)->stack)
17790 +#define setup_thread_stack(p, org) do {} while (0)
17791 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17792 +
17793 #endif
17794 #endif /* _ASM_X86_THREAD_INFO_H */
17795 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17796 index cf51200..63ff068 100644
17797 --- a/arch/x86/include/asm/tlbflush.h
17798 +++ b/arch/x86/include/asm/tlbflush.h
17799 @@ -17,18 +17,44 @@
17800
17801 static inline void __native_flush_tlb(void)
17802 {
17803 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17804 + u64 descriptor[2];
17805 +
17806 + descriptor[0] = PCID_KERNEL;
17807 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17808 + return;
17809 + }
17810 +
17811 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17812 + if (static_cpu_has(X86_FEATURE_PCID)) {
17813 + unsigned int cpu = raw_get_cpu();
17814 +
17815 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17816 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17817 + raw_put_cpu_no_resched();
17818 + return;
17819 + }
17820 +#endif
17821 +
17822 native_write_cr3(native_read_cr3());
17823 }
17824
17825 static inline void __native_flush_tlb_global_irq_disabled(void)
17826 {
17827 - unsigned long cr4;
17828 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17829 + u64 descriptor[2];
17830
17831 - cr4 = native_read_cr4();
17832 - /* clear PGE */
17833 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17834 - /* write old PGE again and flush TLBs */
17835 - native_write_cr4(cr4);
17836 + descriptor[0] = PCID_KERNEL;
17837 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17838 + } else {
17839 + unsigned long cr4;
17840 +
17841 + cr4 = native_read_cr4();
17842 + /* clear PGE */
17843 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17844 + /* write old PGE again and flush TLBs */
17845 + native_write_cr4(cr4);
17846 + }
17847 }
17848
17849 static inline void __native_flush_tlb_global(void)
17850 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17851
17852 static inline void __native_flush_tlb_single(unsigned long addr)
17853 {
17854 +
17855 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17856 + u64 descriptor[2];
17857 +
17858 + descriptor[0] = PCID_KERNEL;
17859 + descriptor[1] = addr;
17860 +
17861 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17862 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17863 + if (addr < TASK_SIZE_MAX)
17864 + descriptor[1] += pax_user_shadow_base;
17865 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17866 + }
17867 +
17868 + descriptor[0] = PCID_USER;
17869 + descriptor[1] = addr;
17870 +#endif
17871 +
17872 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17873 + return;
17874 + }
17875 +
17876 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17877 + if (static_cpu_has(X86_FEATURE_PCID)) {
17878 + unsigned int cpu = raw_get_cpu();
17879 +
17880 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17881 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17882 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17883 + raw_put_cpu_no_resched();
17884 +
17885 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17886 + addr += pax_user_shadow_base;
17887 + }
17888 +#endif
17889 +
17890 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17891 }
17892
17893 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17894 index 5ee2687..74590b9 100644
17895 --- a/arch/x86/include/asm/uaccess.h
17896 +++ b/arch/x86/include/asm/uaccess.h
17897 @@ -7,6 +7,7 @@
17898 #include <linux/compiler.h>
17899 #include <linux/thread_info.h>
17900 #include <linux/string.h>
17901 +#include <linux/sched.h>
17902 #include <asm/asm.h>
17903 #include <asm/page.h>
17904 #include <asm/smap.h>
17905 @@ -29,7 +30,12 @@
17906
17907 #define get_ds() (KERNEL_DS)
17908 #define get_fs() (current_thread_info()->addr_limit)
17909 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17910 +void __set_fs(mm_segment_t x);
17911 +void set_fs(mm_segment_t x);
17912 +#else
17913 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17914 +#endif
17915
17916 #define segment_eq(a, b) ((a).seg == (b).seg)
17917
17918 @@ -77,8 +83,33 @@
17919 * checks that the pointer is in the user space range - after calling
17920 * this function, memory access functions may still return -EFAULT.
17921 */
17922 -#define access_ok(type, addr, size) \
17923 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17924 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17925 +#define access_ok(type, addr, size) \
17926 +({ \
17927 + long __size = size; \
17928 + unsigned long __addr = (unsigned long)addr; \
17929 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17930 + unsigned long __end_ao = __addr + __size - 1; \
17931 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17932 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17933 + while(__addr_ao <= __end_ao) { \
17934 + char __c_ao; \
17935 + __addr_ao += PAGE_SIZE; \
17936 + if (__size > PAGE_SIZE) \
17937 + cond_resched(); \
17938 + if (__get_user(__c_ao, (char __user *)__addr)) \
17939 + break; \
17940 + if (type != VERIFY_WRITE) { \
17941 + __addr = __addr_ao; \
17942 + continue; \
17943 + } \
17944 + if (__put_user(__c_ao, (char __user *)__addr)) \
17945 + break; \
17946 + __addr = __addr_ao; \
17947 + } \
17948 + } \
17949 + __ret_ao; \
17950 +})
17951
17952 /*
17953 * The exception table consists of pairs of addresses relative to the
17954 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17955 register __inttype(*(ptr)) __val_gu asm("%edx"); \
17956 __chk_user_ptr(ptr); \
17957 might_fault(); \
17958 + pax_open_userland(); \
17959 asm volatile("call __get_user_%P3" \
17960 : "=a" (__ret_gu), "=r" (__val_gu) \
17961 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17962 (x) = (__typeof__(*(ptr))) __val_gu; \
17963 + pax_close_userland(); \
17964 __ret_gu; \
17965 })
17966
17967 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17968 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17969 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17970
17971 -
17972 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17973 +#define __copyuser_seg "gs;"
17974 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17975 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
17976 +#else
17977 +#define __copyuser_seg
17978 +#define __COPYUSER_SET_ES
17979 +#define __COPYUSER_RESTORE_ES
17980 +#endif
17981
17982 #ifdef CONFIG_X86_32
17983 #define __put_user_asm_u64(x, addr, err, errret) \
17984 asm volatile(ASM_STAC "\n" \
17985 - "1: movl %%eax,0(%2)\n" \
17986 - "2: movl %%edx,4(%2)\n" \
17987 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
17988 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
17989 "3: " ASM_CLAC "\n" \
17990 ".section .fixup,\"ax\"\n" \
17991 "4: movl %3,%0\n" \
17992 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17993
17994 #define __put_user_asm_ex_u64(x, addr) \
17995 asm volatile(ASM_STAC "\n" \
17996 - "1: movl %%eax,0(%1)\n" \
17997 - "2: movl %%edx,4(%1)\n" \
17998 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
17999 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18000 "3: " ASM_CLAC "\n" \
18001 _ASM_EXTABLE_EX(1b, 2b) \
18002 _ASM_EXTABLE_EX(2b, 3b) \
18003 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
18004 __typeof__(*(ptr)) __pu_val; \
18005 __chk_user_ptr(ptr); \
18006 might_fault(); \
18007 - __pu_val = x; \
18008 + __pu_val = (x); \
18009 + pax_open_userland(); \
18010 switch (sizeof(*(ptr))) { \
18011 case 1: \
18012 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18013 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
18014 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18015 break; \
18016 } \
18017 + pax_close_userland(); \
18018 __ret_pu; \
18019 })
18020
18021 @@ -344,8 +387,10 @@ do { \
18022 } while (0)
18023
18024 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18025 +do { \
18026 + pax_open_userland(); \
18027 asm volatile(ASM_STAC "\n" \
18028 - "1: mov"itype" %2,%"rtype"1\n" \
18029 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18030 "2: " ASM_CLAC "\n" \
18031 ".section .fixup,\"ax\"\n" \
18032 "3: mov %3,%0\n" \
18033 @@ -353,8 +398,10 @@ do { \
18034 " jmp 2b\n" \
18035 ".previous\n" \
18036 _ASM_EXTABLE(1b, 3b) \
18037 - : "=r" (err), ltype(x) \
18038 - : "m" (__m(addr)), "i" (errret), "0" (err))
18039 + : "=r" (err), ltype (x) \
18040 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18041 + pax_close_userland(); \
18042 +} while (0)
18043
18044 #define __get_user_size_ex(x, ptr, size) \
18045 do { \
18046 @@ -378,7 +425,7 @@ do { \
18047 } while (0)
18048
18049 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18050 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18051 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18052 "2:\n" \
18053 _ASM_EXTABLE_EX(1b, 2b) \
18054 : ltype(x) : "m" (__m(addr)))
18055 @@ -395,13 +442,24 @@ do { \
18056 int __gu_err; \
18057 unsigned long __gu_val; \
18058 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18059 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18060 + (x) = (__typeof__(*(ptr)))__gu_val; \
18061 __gu_err; \
18062 })
18063
18064 /* FIXME: this hack is definitely wrong -AK */
18065 struct __large_struct { unsigned long buf[100]; };
18066 -#define __m(x) (*(struct __large_struct __user *)(x))
18067 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18068 +#define ____m(x) \
18069 +({ \
18070 + unsigned long ____x = (unsigned long)(x); \
18071 + if (____x < pax_user_shadow_base) \
18072 + ____x += pax_user_shadow_base; \
18073 + (typeof(x))____x; \
18074 +})
18075 +#else
18076 +#define ____m(x) (x)
18077 +#endif
18078 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18079
18080 /*
18081 * Tell gcc we read from memory instead of writing: this is because
18082 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
18083 * aliasing issues.
18084 */
18085 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18086 +do { \
18087 + pax_open_userland(); \
18088 asm volatile(ASM_STAC "\n" \
18089 - "1: mov"itype" %"rtype"1,%2\n" \
18090 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18091 "2: " ASM_CLAC "\n" \
18092 ".section .fixup,\"ax\"\n" \
18093 "3: mov %3,%0\n" \
18094 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
18095 ".previous\n" \
18096 _ASM_EXTABLE(1b, 3b) \
18097 : "=r"(err) \
18098 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18099 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18100 + pax_close_userland(); \
18101 +} while (0)
18102
18103 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18104 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18105 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18106 "2:\n" \
18107 _ASM_EXTABLE_EX(1b, 2b) \
18108 : : ltype(x), "m" (__m(addr)))
18109 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
18110 */
18111 #define uaccess_try do { \
18112 current_thread_info()->uaccess_err = 0; \
18113 + pax_open_userland(); \
18114 stac(); \
18115 barrier();
18116
18117 #define uaccess_catch(err) \
18118 clac(); \
18119 + pax_close_userland(); \
18120 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18121 } while (0)
18122
18123 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
18124 * On error, the variable @x is set to zero.
18125 */
18126
18127 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18128 +#define __get_user(x, ptr) get_user((x), (ptr))
18129 +#else
18130 #define __get_user(x, ptr) \
18131 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18132 +#endif
18133
18134 /**
18135 * __put_user: - Write a simple value into user space, with less checking.
18136 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
18137 * Returns zero on success, or -EFAULT on error.
18138 */
18139
18140 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18141 +#define __put_user(x, ptr) put_user((x), (ptr))
18142 +#else
18143 #define __put_user(x, ptr) \
18144 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18145 +#endif
18146
18147 #define __get_user_unaligned __get_user
18148 #define __put_user_unaligned __put_user
18149 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
18150 #define get_user_ex(x, ptr) do { \
18151 unsigned long __gue_val; \
18152 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18153 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18154 + (x) = (__typeof__(*(ptr)))__gue_val; \
18155 } while (0)
18156
18157 #define put_user_try uaccess_try
18158 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
18159 extern __must_check long strlen_user(const char __user *str);
18160 extern __must_check long strnlen_user(const char __user *str, long n);
18161
18162 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
18163 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
18164 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18165 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18166
18167 /*
18168 * movsl can be slow when source and dest are not both 8-byte aligned
18169 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18170 index 7f760a9..04b1c65 100644
18171 --- a/arch/x86/include/asm/uaccess_32.h
18172 +++ b/arch/x86/include/asm/uaccess_32.h
18173 @@ -11,15 +11,15 @@
18174 #include <asm/page.h>
18175
18176 unsigned long __must_check __copy_to_user_ll
18177 - (void __user *to, const void *from, unsigned long n);
18178 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
18179 unsigned long __must_check __copy_from_user_ll
18180 - (void *to, const void __user *from, unsigned long n);
18181 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18182 unsigned long __must_check __copy_from_user_ll_nozero
18183 - (void *to, const void __user *from, unsigned long n);
18184 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18185 unsigned long __must_check __copy_from_user_ll_nocache
18186 - (void *to, const void __user *from, unsigned long n);
18187 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18188 unsigned long __must_check __copy_from_user_ll_nocache_nozero
18189 - (void *to, const void __user *from, unsigned long n);
18190 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18191
18192 /**
18193 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
18194 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18195 static __always_inline unsigned long __must_check
18196 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18197 {
18198 + if ((long)n < 0)
18199 + return n;
18200 +
18201 + check_object_size(from, n, true);
18202 +
18203 if (__builtin_constant_p(n)) {
18204 unsigned long ret;
18205
18206 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18207 __copy_to_user(void __user *to, const void *from, unsigned long n)
18208 {
18209 might_fault();
18210 +
18211 return __copy_to_user_inatomic(to, from, n);
18212 }
18213
18214 static __always_inline unsigned long
18215 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18216 {
18217 + if ((long)n < 0)
18218 + return n;
18219 +
18220 /* Avoid zeroing the tail if the copy fails..
18221 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18222 * but as the zeroing behaviour is only significant when n is not
18223 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18224 __copy_from_user(void *to, const void __user *from, unsigned long n)
18225 {
18226 might_fault();
18227 +
18228 + if ((long)n < 0)
18229 + return n;
18230 +
18231 + check_object_size(to, n, false);
18232 +
18233 if (__builtin_constant_p(n)) {
18234 unsigned long ret;
18235
18236 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18237 const void __user *from, unsigned long n)
18238 {
18239 might_fault();
18240 +
18241 + if ((long)n < 0)
18242 + return n;
18243 +
18244 if (__builtin_constant_p(n)) {
18245 unsigned long ret;
18246
18247 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18248 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18249 unsigned long n)
18250 {
18251 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18252 + if ((long)n < 0)
18253 + return n;
18254 +
18255 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18256 }
18257
18258 -unsigned long __must_check copy_to_user(void __user *to,
18259 - const void *from, unsigned long n);
18260 -unsigned long __must_check _copy_from_user(void *to,
18261 - const void __user *from,
18262 - unsigned long n);
18263 -
18264 +extern void copy_to_user_overflow(void)
18265 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18266 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18267 +#else
18268 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18269 +#endif
18270 +;
18271
18272 extern void copy_from_user_overflow(void)
18273 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18274 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18275 #endif
18276 ;
18277
18278 -static inline unsigned long __must_check copy_from_user(void *to,
18279 - const void __user *from,
18280 - unsigned long n)
18281 +/**
18282 + * copy_to_user: - Copy a block of data into user space.
18283 + * @to: Destination address, in user space.
18284 + * @from: Source address, in kernel space.
18285 + * @n: Number of bytes to copy.
18286 + *
18287 + * Context: User context only. This function may sleep.
18288 + *
18289 + * Copy data from kernel space to user space.
18290 + *
18291 + * Returns number of bytes that could not be copied.
18292 + * On success, this will be zero.
18293 + */
18294 +static inline unsigned long __must_check
18295 +copy_to_user(void __user *to, const void *from, unsigned long n)
18296 {
18297 - int sz = __compiletime_object_size(to);
18298 + size_t sz = __compiletime_object_size(from);
18299
18300 - if (likely(sz == -1 || sz >= n))
18301 - n = _copy_from_user(to, from, n);
18302 - else
18303 + if (unlikely(sz != (size_t)-1 && sz < n))
18304 + copy_to_user_overflow();
18305 + else if (access_ok(VERIFY_WRITE, to, n))
18306 + n = __copy_to_user(to, from, n);
18307 + return n;
18308 +}
18309 +
18310 +/**
18311 + * copy_from_user: - Copy a block of data from user space.
18312 + * @to: Destination address, in kernel space.
18313 + * @from: Source address, in user space.
18314 + * @n: Number of bytes to copy.
18315 + *
18316 + * Context: User context only. This function may sleep.
18317 + *
18318 + * Copy data from user space to kernel space.
18319 + *
18320 + * Returns number of bytes that could not be copied.
18321 + * On success, this will be zero.
18322 + *
18323 + * If some data could not be copied, this function will pad the copied
18324 + * data to the requested size using zero bytes.
18325 + */
18326 +static inline unsigned long __must_check
18327 +copy_from_user(void *to, const void __user *from, unsigned long n)
18328 +{
18329 + size_t sz = __compiletime_object_size(to);
18330 +
18331 + check_object_size(to, n, false);
18332 +
18333 + if (unlikely(sz != (size_t)-1 && sz < n))
18334 copy_from_user_overflow();
18335 -
18336 + else if (access_ok(VERIFY_READ, from, n))
18337 + n = __copy_from_user(to, from, n);
18338 + else if ((long)n > 0)
18339 + memset(to, 0, n);
18340 return n;
18341 }
18342
18343 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18344 index 4f7923d..d3526c1 100644
18345 --- a/arch/x86/include/asm/uaccess_64.h
18346 +++ b/arch/x86/include/asm/uaccess_64.h
18347 @@ -10,6 +10,9 @@
18348 #include <asm/alternative.h>
18349 #include <asm/cpufeature.h>
18350 #include <asm/page.h>
18351 +#include <asm/pgtable.h>
18352 +
18353 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18354
18355 /*
18356 * Copy To/From Userspace
18357 @@ -17,14 +20,14 @@
18358
18359 /* Handles exceptions in both to and from, but doesn't do access_ok */
18360 __must_check unsigned long
18361 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18362 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18363 __must_check unsigned long
18364 -copy_user_generic_string(void *to, const void *from, unsigned len);
18365 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18366 __must_check unsigned long
18367 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18368 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18369
18370 -static __always_inline __must_check unsigned long
18371 -copy_user_generic(void *to, const void *from, unsigned len)
18372 +static __always_inline __must_check __size_overflow(3) unsigned long
18373 +copy_user_generic(void *to, const void *from, unsigned long len)
18374 {
18375 unsigned ret;
18376
18377 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
18378 return ret;
18379 }
18380
18381 +static __always_inline __must_check unsigned long
18382 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18383 +static __always_inline __must_check unsigned long
18384 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18385 __must_check unsigned long
18386 -_copy_to_user(void __user *to, const void *from, unsigned len);
18387 -__must_check unsigned long
18388 -_copy_from_user(void *to, const void __user *from, unsigned len);
18389 -__must_check unsigned long
18390 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18391 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18392 +
18393 +extern void copy_to_user_overflow(void)
18394 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18395 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18396 +#else
18397 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18398 +#endif
18399 +;
18400 +
18401 +extern void copy_from_user_overflow(void)
18402 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18403 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18404 +#else
18405 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18406 +#endif
18407 +;
18408
18409 static inline unsigned long __must_check copy_from_user(void *to,
18410 const void __user *from,
18411 unsigned long n)
18412 {
18413 - int sz = __compiletime_object_size(to);
18414 -
18415 might_fault();
18416 - if (likely(sz == -1 || sz >= n))
18417 - n = _copy_from_user(to, from, n);
18418 -#ifdef CONFIG_DEBUG_VM
18419 - else
18420 - WARN(1, "Buffer overflow detected!\n");
18421 -#endif
18422 +
18423 + check_object_size(to, n, false);
18424 +
18425 + if (access_ok(VERIFY_READ, from, n))
18426 + n = __copy_from_user(to, from, n);
18427 + else if (n < INT_MAX)
18428 + memset(to, 0, n);
18429 return n;
18430 }
18431
18432 static __always_inline __must_check
18433 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18434 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18435 {
18436 might_fault();
18437
18438 - return _copy_to_user(dst, src, size);
18439 + if (access_ok(VERIFY_WRITE, dst, size))
18440 + size = __copy_to_user(dst, src, size);
18441 + return size;
18442 }
18443
18444 static __always_inline __must_check
18445 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18446 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18447 {
18448 - int ret = 0;
18449 + size_t sz = __compiletime_object_size(dst);
18450 + unsigned ret = 0;
18451
18452 might_fault();
18453 +
18454 + if (size > INT_MAX)
18455 + return size;
18456 +
18457 + check_object_size(dst, size, false);
18458 +
18459 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18460 + if (!__access_ok(VERIFY_READ, src, size))
18461 + return size;
18462 +#endif
18463 +
18464 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18465 + copy_from_user_overflow();
18466 + return size;
18467 + }
18468 +
18469 if (!__builtin_constant_p(size))
18470 - return copy_user_generic(dst, (__force void *)src, size);
18471 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18472 switch (size) {
18473 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18474 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18475 ret, "b", "b", "=q", 1);
18476 return ret;
18477 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18478 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18479 ret, "w", "w", "=r", 2);
18480 return ret;
18481 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18482 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18483 ret, "l", "k", "=r", 4);
18484 return ret;
18485 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18486 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18487 ret, "q", "", "=r", 8);
18488 return ret;
18489 case 10:
18490 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18491 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18492 ret, "q", "", "=r", 10);
18493 if (unlikely(ret))
18494 return ret;
18495 __get_user_asm(*(u16 *)(8 + (char *)dst),
18496 - (u16 __user *)(8 + (char __user *)src),
18497 + (const u16 __user *)(8 + (const char __user *)src),
18498 ret, "w", "w", "=r", 2);
18499 return ret;
18500 case 16:
18501 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18502 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18503 ret, "q", "", "=r", 16);
18504 if (unlikely(ret))
18505 return ret;
18506 __get_user_asm(*(u64 *)(8 + (char *)dst),
18507 - (u64 __user *)(8 + (char __user *)src),
18508 + (const u64 __user *)(8 + (const char __user *)src),
18509 ret, "q", "", "=r", 8);
18510 return ret;
18511 default:
18512 - return copy_user_generic(dst, (__force void *)src, size);
18513 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18514 }
18515 }
18516
18517 static __always_inline __must_check
18518 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18519 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18520 {
18521 - int ret = 0;
18522 + size_t sz = __compiletime_object_size(src);
18523 + unsigned ret = 0;
18524
18525 might_fault();
18526 +
18527 + if (size > INT_MAX)
18528 + return size;
18529 +
18530 + check_object_size(src, size, true);
18531 +
18532 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18533 + if (!__access_ok(VERIFY_WRITE, dst, size))
18534 + return size;
18535 +#endif
18536 +
18537 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18538 + copy_to_user_overflow();
18539 + return size;
18540 + }
18541 +
18542 if (!__builtin_constant_p(size))
18543 - return copy_user_generic((__force void *)dst, src, size);
18544 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18545 switch (size) {
18546 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18547 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18548 ret, "b", "b", "iq", 1);
18549 return ret;
18550 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18551 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18552 ret, "w", "w", "ir", 2);
18553 return ret;
18554 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18555 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18556 ret, "l", "k", "ir", 4);
18557 return ret;
18558 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18559 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18560 ret, "q", "", "er", 8);
18561 return ret;
18562 case 10:
18563 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18564 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18565 ret, "q", "", "er", 10);
18566 if (unlikely(ret))
18567 return ret;
18568 asm("":::"memory");
18569 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18570 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18571 ret, "w", "w", "ir", 2);
18572 return ret;
18573 case 16:
18574 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18575 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18576 ret, "q", "", "er", 16);
18577 if (unlikely(ret))
18578 return ret;
18579 asm("":::"memory");
18580 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18581 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18582 ret, "q", "", "er", 8);
18583 return ret;
18584 default:
18585 - return copy_user_generic((__force void *)dst, src, size);
18586 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18587 }
18588 }
18589
18590 static __always_inline __must_check
18591 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18592 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18593 {
18594 - int ret = 0;
18595 + unsigned ret = 0;
18596
18597 might_fault();
18598 +
18599 + if (size > INT_MAX)
18600 + return size;
18601 +
18602 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18603 + if (!__access_ok(VERIFY_READ, src, size))
18604 + return size;
18605 + if (!__access_ok(VERIFY_WRITE, dst, size))
18606 + return size;
18607 +#endif
18608 +
18609 if (!__builtin_constant_p(size))
18610 - return copy_user_generic((__force void *)dst,
18611 - (__force void *)src, size);
18612 + return copy_user_generic((__force_kernel void *)____m(dst),
18613 + (__force_kernel const void *)____m(src), size);
18614 switch (size) {
18615 case 1: {
18616 u8 tmp;
18617 - __get_user_asm(tmp, (u8 __user *)src,
18618 + __get_user_asm(tmp, (const u8 __user *)src,
18619 ret, "b", "b", "=q", 1);
18620 if (likely(!ret))
18621 __put_user_asm(tmp, (u8 __user *)dst,
18622 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18623 }
18624 case 2: {
18625 u16 tmp;
18626 - __get_user_asm(tmp, (u16 __user *)src,
18627 + __get_user_asm(tmp, (const u16 __user *)src,
18628 ret, "w", "w", "=r", 2);
18629 if (likely(!ret))
18630 __put_user_asm(tmp, (u16 __user *)dst,
18631 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18632
18633 case 4: {
18634 u32 tmp;
18635 - __get_user_asm(tmp, (u32 __user *)src,
18636 + __get_user_asm(tmp, (const u32 __user *)src,
18637 ret, "l", "k", "=r", 4);
18638 if (likely(!ret))
18639 __put_user_asm(tmp, (u32 __user *)dst,
18640 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18641 }
18642 case 8: {
18643 u64 tmp;
18644 - __get_user_asm(tmp, (u64 __user *)src,
18645 + __get_user_asm(tmp, (const u64 __user *)src,
18646 ret, "q", "", "=r", 8);
18647 if (likely(!ret))
18648 __put_user_asm(tmp, (u64 __user *)dst,
18649 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18650 return ret;
18651 }
18652 default:
18653 - return copy_user_generic((__force void *)dst,
18654 - (__force void *)src, size);
18655 + return copy_user_generic((__force_kernel void *)____m(dst),
18656 + (__force_kernel const void *)____m(src), size);
18657 }
18658 }
18659
18660 -static __must_check __always_inline int
18661 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18662 +static __must_check __always_inline unsigned long
18663 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18664 {
18665 - return copy_user_generic(dst, (__force const void *)src, size);
18666 + if (size > INT_MAX)
18667 + return size;
18668 +
18669 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18670 + if (!__access_ok(VERIFY_READ, src, size))
18671 + return size;
18672 +#endif
18673 +
18674 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18675 }
18676
18677 -static __must_check __always_inline int
18678 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18679 +static __must_check __always_inline unsigned long
18680 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18681 {
18682 - return copy_user_generic((__force void *)dst, src, size);
18683 + if (size > INT_MAX)
18684 + return size;
18685 +
18686 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18687 + if (!__access_ok(VERIFY_WRITE, dst, size))
18688 + return size;
18689 +#endif
18690 +
18691 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18692 }
18693
18694 -extern long __copy_user_nocache(void *dst, const void __user *src,
18695 - unsigned size, int zerorest);
18696 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18697 + unsigned long size, int zerorest) __size_overflow(3);
18698
18699 -static inline int
18700 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18701 +static inline unsigned long
18702 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18703 {
18704 might_fault();
18705 +
18706 + if (size > INT_MAX)
18707 + return size;
18708 +
18709 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18710 + if (!__access_ok(VERIFY_READ, src, size))
18711 + return size;
18712 +#endif
18713 +
18714 return __copy_user_nocache(dst, src, size, 1);
18715 }
18716
18717 -static inline int
18718 +static inline unsigned long
18719 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18720 - unsigned size)
18721 + unsigned long size)
18722 {
18723 + if (size > INT_MAX)
18724 + return size;
18725 +
18726 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18727 + if (!__access_ok(VERIFY_READ, src, size))
18728 + return size;
18729 +#endif
18730 +
18731 return __copy_user_nocache(dst, src, size, 0);
18732 }
18733
18734 unsigned long
18735 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18736 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18737
18738 #endif /* _ASM_X86_UACCESS_64_H */
18739 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18740 index 5b238981..77fdd78 100644
18741 --- a/arch/x86/include/asm/word-at-a-time.h
18742 +++ b/arch/x86/include/asm/word-at-a-time.h
18743 @@ -11,7 +11,7 @@
18744 * and shift, for example.
18745 */
18746 struct word_at_a_time {
18747 - const unsigned long one_bits, high_bits;
18748 + unsigned long one_bits, high_bits;
18749 };
18750
18751 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18752 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18753 index 828a156..650e625 100644
18754 --- a/arch/x86/include/asm/x86_init.h
18755 +++ b/arch/x86/include/asm/x86_init.h
18756 @@ -129,7 +129,7 @@ struct x86_init_ops {
18757 struct x86_init_timers timers;
18758 struct x86_init_iommu iommu;
18759 struct x86_init_pci pci;
18760 -};
18761 +} __no_const;
18762
18763 /**
18764 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18765 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18766 void (*setup_percpu_clockev)(void);
18767 void (*early_percpu_clock_init)(void);
18768 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18769 -};
18770 +} __no_const;
18771
18772 struct timespec;
18773
18774 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18775 void (*save_sched_clock_state)(void);
18776 void (*restore_sched_clock_state)(void);
18777 void (*apic_post_init)(void);
18778 -};
18779 +} __no_const;
18780
18781 struct pci_dev;
18782 struct msi_msg;
18783 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18784 void (*teardown_msi_irqs)(struct pci_dev *dev);
18785 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18786 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18787 -};
18788 +} __no_const;
18789
18790 struct IO_APIC_route_entry;
18791 struct io_apic_irq_attr;
18792 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18793 unsigned int destination, int vector,
18794 struct io_apic_irq_attr *attr);
18795 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18796 -};
18797 +} __no_const;
18798
18799 extern struct x86_init_ops x86_init;
18800 extern struct x86_cpuinit_ops x86_cpuinit;
18801 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18802 index 0415cda..3b22adc 100644
18803 --- a/arch/x86/include/asm/xsave.h
18804 +++ b/arch/x86/include/asm/xsave.h
18805 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18806 if (unlikely(err))
18807 return -EFAULT;
18808
18809 + pax_open_userland();
18810 __asm__ __volatile__(ASM_STAC "\n"
18811 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18812 + "1:"
18813 + __copyuser_seg
18814 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18815 "2: " ASM_CLAC "\n"
18816 ".section .fixup,\"ax\"\n"
18817 "3: movl $-1,%[err]\n"
18818 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18819 : [err] "=r" (err)
18820 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18821 : "memory");
18822 + pax_close_userland();
18823 return err;
18824 }
18825
18826 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18827 {
18828 int err;
18829 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18830 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18831 u32 lmask = mask;
18832 u32 hmask = mask >> 32;
18833
18834 + pax_open_userland();
18835 __asm__ __volatile__(ASM_STAC "\n"
18836 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18837 + "1:"
18838 + __copyuser_seg
18839 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18840 "2: " ASM_CLAC "\n"
18841 ".section .fixup,\"ax\"\n"
18842 "3: movl $-1,%[err]\n"
18843 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18844 : [err] "=r" (err)
18845 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18846 : "memory"); /* memory required? */
18847 + pax_close_userland();
18848 return err;
18849 }
18850
18851 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18852 index bbae024..e1528f9 100644
18853 --- a/arch/x86/include/uapi/asm/e820.h
18854 +++ b/arch/x86/include/uapi/asm/e820.h
18855 @@ -63,7 +63,7 @@ struct e820map {
18856 #define ISA_START_ADDRESS 0xa0000
18857 #define ISA_END_ADDRESS 0x100000
18858
18859 -#define BIOS_BEGIN 0x000a0000
18860 +#define BIOS_BEGIN 0x000c0000
18861 #define BIOS_END 0x00100000
18862
18863 #define BIOS_ROM_BASE 0xffe00000
18864 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18865 index 88d99ea..9fc7e17 100644
18866 --- a/arch/x86/kernel/Makefile
18867 +++ b/arch/x86/kernel/Makefile
18868 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18869 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18870 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18871 obj-y += probe_roms.o
18872 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18873 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18874 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18875 obj-y += syscall_$(BITS).o
18876 obj-$(CONFIG_X86_64) += vsyscall_64.o
18877 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18878 index 2627a81..cd8325e 100644
18879 --- a/arch/x86/kernel/acpi/boot.c
18880 +++ b/arch/x86/kernel/acpi/boot.c
18881 @@ -1368,7 +1368,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18882 * If your system is blacklisted here, but you find that acpi=force
18883 * works for you, please contact linux-acpi@vger.kernel.org
18884 */
18885 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18886 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18887 /*
18888 * Boxes that need ACPI disabled
18889 */
18890 @@ -1443,7 +1443,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18891 };
18892
18893 /* second table for DMI checks that should run after early-quirks */
18894 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18895 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18896 /*
18897 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18898 * which includes some code which overrides all temperature
18899 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18900 index 3312010..a65ca7b 100644
18901 --- a/arch/x86/kernel/acpi/sleep.c
18902 +++ b/arch/x86/kernel/acpi/sleep.c
18903 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18904 #else /* CONFIG_64BIT */
18905 #ifdef CONFIG_SMP
18906 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18907 +
18908 + pax_open_kernel();
18909 early_gdt_descr.address =
18910 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18911 + pax_close_kernel();
18912 +
18913 initial_gs = per_cpu_offset(smp_processor_id());
18914 #endif
18915 initial_code = (unsigned long)wakeup_long64;
18916 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18917 index d1daa66..59fecba 100644
18918 --- a/arch/x86/kernel/acpi/wakeup_32.S
18919 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18920 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18921 # and restore the stack ... but you need gdt for this to work
18922 movl saved_context_esp, %esp
18923
18924 - movl %cs:saved_magic, %eax
18925 - cmpl $0x12345678, %eax
18926 + cmpl $0x12345678, saved_magic
18927 jne bogus_magic
18928
18929 # jump to place where we left off
18930 - movl saved_eip, %eax
18931 - jmp *%eax
18932 + jmp *(saved_eip)
18933
18934 bogus_magic:
18935 jmp bogus_magic
18936 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18937 index c15cf9a..0e63558 100644
18938 --- a/arch/x86/kernel/alternative.c
18939 +++ b/arch/x86/kernel/alternative.c
18940 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18941 */
18942 for (a = start; a < end; a++) {
18943 instr = (u8 *)&a->instr_offset + a->instr_offset;
18944 +
18945 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18946 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18947 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18948 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18949 +#endif
18950 +
18951 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18952 BUG_ON(a->replacementlen > a->instrlen);
18953 BUG_ON(a->instrlen > sizeof(insnbuf));
18954 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18955 for (poff = start; poff < end; poff++) {
18956 u8 *ptr = (u8 *)poff + *poff;
18957
18958 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18959 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18960 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18961 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18962 +#endif
18963 +
18964 if (!*poff || ptr < text || ptr >= text_end)
18965 continue;
18966 /* turn DS segment override prefix into lock prefix */
18967 - if (*ptr == 0x3e)
18968 + if (*ktla_ktva(ptr) == 0x3e)
18969 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18970 }
18971 mutex_unlock(&text_mutex);
18972 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18973 for (poff = start; poff < end; poff++) {
18974 u8 *ptr = (u8 *)poff + *poff;
18975
18976 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18977 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18978 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18979 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18980 +#endif
18981 +
18982 if (!*poff || ptr < text || ptr >= text_end)
18983 continue;
18984 /* turn lock prefix into DS segment override prefix */
18985 - if (*ptr == 0xf0)
18986 + if (*ktla_ktva(ptr) == 0xf0)
18987 text_poke(ptr, ((unsigned char []){0x3E}), 1);
18988 }
18989 mutex_unlock(&text_mutex);
18990 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
18991
18992 BUG_ON(p->len > MAX_PATCH_LEN);
18993 /* prep the buffer with the original instructions */
18994 - memcpy(insnbuf, p->instr, p->len);
18995 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
18996 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
18997 (unsigned long)p->instr, p->len);
18998
18999 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
19000 if (!uniproc_patched || num_possible_cpus() == 1)
19001 free_init_pages("SMP alternatives",
19002 (unsigned long)__smp_locks,
19003 - (unsigned long)__smp_locks_end);
19004 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19005 #endif
19006
19007 apply_paravirt(__parainstructions, __parainstructions_end);
19008 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
19009 * instructions. And on the local CPU you need to be protected again NMI or MCE
19010 * handlers seeing an inconsistent instruction while you patch.
19011 */
19012 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19013 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19014 size_t len)
19015 {
19016 unsigned long flags;
19017 local_irq_save(flags);
19018 - memcpy(addr, opcode, len);
19019 +
19020 + pax_open_kernel();
19021 + memcpy(ktla_ktva(addr), opcode, len);
19022 sync_core();
19023 + pax_close_kernel();
19024 +
19025 local_irq_restore(flags);
19026 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19027 that causes hangs on some VIA CPUs. */
19028 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19029 */
19030 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19031 {
19032 - unsigned long flags;
19033 - char *vaddr;
19034 + unsigned char *vaddr = ktla_ktva(addr);
19035 struct page *pages[2];
19036 - int i;
19037 + size_t i;
19038
19039 if (!core_kernel_text((unsigned long)addr)) {
19040 - pages[0] = vmalloc_to_page(addr);
19041 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19042 + pages[0] = vmalloc_to_page(vaddr);
19043 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19044 } else {
19045 - pages[0] = virt_to_page(addr);
19046 + pages[0] = virt_to_page(vaddr);
19047 WARN_ON(!PageReserved(pages[0]));
19048 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19049 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19050 }
19051 BUG_ON(!pages[0]);
19052 - local_irq_save(flags);
19053 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19054 - if (pages[1])
19055 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19056 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19057 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19058 - clear_fixmap(FIX_TEXT_POKE0);
19059 - if (pages[1])
19060 - clear_fixmap(FIX_TEXT_POKE1);
19061 - local_flush_tlb();
19062 - sync_core();
19063 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19064 - that causes hangs on some VIA CPUs. */
19065 + text_poke_early(addr, opcode, len);
19066 for (i = 0; i < len; i++)
19067 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19068 - local_irq_restore(flags);
19069 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19070 return addr;
19071 }
19072
19073 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19074 index eca89c5..d566b78 100644
19075 --- a/arch/x86/kernel/apic/apic.c
19076 +++ b/arch/x86/kernel/apic/apic.c
19077 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19078 /*
19079 * Debug level, exported for io_apic.c
19080 */
19081 -unsigned int apic_verbosity;
19082 +int apic_verbosity;
19083
19084 int pic_mode;
19085
19086 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19087 apic_write(APIC_ESR, 0);
19088 v1 = apic_read(APIC_ESR);
19089 ack_APIC_irq();
19090 - atomic_inc(&irq_err_count);
19091 + atomic_inc_unchecked(&irq_err_count);
19092
19093 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19094 smp_processor_id(), v0 , v1);
19095 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19096 index 00c77cf..2dc6a2d 100644
19097 --- a/arch/x86/kernel/apic/apic_flat_64.c
19098 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19099 @@ -157,7 +157,7 @@ static int flat_probe(void)
19100 return 1;
19101 }
19102
19103 -static struct apic apic_flat = {
19104 +static struct apic apic_flat __read_only = {
19105 .name = "flat",
19106 .probe = flat_probe,
19107 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19108 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19109 return 0;
19110 }
19111
19112 -static struct apic apic_physflat = {
19113 +static struct apic apic_physflat __read_only = {
19114
19115 .name = "physical flat",
19116 .probe = physflat_probe,
19117 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19118 index e145f28..2752888 100644
19119 --- a/arch/x86/kernel/apic/apic_noop.c
19120 +++ b/arch/x86/kernel/apic/apic_noop.c
19121 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19122 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19123 }
19124
19125 -struct apic apic_noop = {
19126 +struct apic apic_noop __read_only = {
19127 .name = "noop",
19128 .probe = noop_probe,
19129 .acpi_madt_oem_check = NULL,
19130 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19131 index d50e364..543bee3 100644
19132 --- a/arch/x86/kernel/apic/bigsmp_32.c
19133 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19134 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19135 return dmi_bigsmp;
19136 }
19137
19138 -static struct apic apic_bigsmp = {
19139 +static struct apic apic_bigsmp __read_only = {
19140
19141 .name = "bigsmp",
19142 .probe = probe_bigsmp,
19143 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19144 index c552247..587a316 100644
19145 --- a/arch/x86/kernel/apic/es7000_32.c
19146 +++ b/arch/x86/kernel/apic/es7000_32.c
19147 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19148 return ret && es7000_apic_is_cluster();
19149 }
19150
19151 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19152 -static struct apic __refdata apic_es7000_cluster = {
19153 +static struct apic apic_es7000_cluster __read_only = {
19154
19155 .name = "es7000",
19156 .probe = probe_es7000,
19157 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19158 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19159 };
19160
19161 -static struct apic __refdata apic_es7000 = {
19162 +static struct apic apic_es7000 __read_only = {
19163
19164 .name = "es7000",
19165 .probe = probe_es7000,
19166 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19167 index 9ed796c..e930fe4 100644
19168 --- a/arch/x86/kernel/apic/io_apic.c
19169 +++ b/arch/x86/kernel/apic/io_apic.c
19170 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19171 }
19172 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19173
19174 -void lock_vector_lock(void)
19175 +void lock_vector_lock(void) __acquires(vector_lock)
19176 {
19177 /* Used to the online set of cpus does not change
19178 * during assign_irq_vector.
19179 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19180 raw_spin_lock(&vector_lock);
19181 }
19182
19183 -void unlock_vector_lock(void)
19184 +void unlock_vector_lock(void) __releases(vector_lock)
19185 {
19186 raw_spin_unlock(&vector_lock);
19187 }
19188 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
19189 ack_APIC_irq();
19190 }
19191
19192 -atomic_t irq_mis_count;
19193 +atomic_unchecked_t irq_mis_count;
19194
19195 #ifdef CONFIG_GENERIC_PENDING_IRQ
19196 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19197 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
19198 * at the cpu.
19199 */
19200 if (!(v & (1 << (i & 0x1f)))) {
19201 - atomic_inc(&irq_mis_count);
19202 + atomic_inc_unchecked(&irq_mis_count);
19203
19204 eoi_ioapic_irq(irq, cfg);
19205 }
19206 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19207 index 1e42e8f..daacf44 100644
19208 --- a/arch/x86/kernel/apic/numaq_32.c
19209 +++ b/arch/x86/kernel/apic/numaq_32.c
19210 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19211 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19212 }
19213
19214 -/* Use __refdata to keep false positive warning calm. */
19215 -static struct apic __refdata apic_numaq = {
19216 +static struct apic apic_numaq __read_only = {
19217
19218 .name = "NUMAQ",
19219 .probe = probe_numaq,
19220 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19221 index eb35ef9..f184a21 100644
19222 --- a/arch/x86/kernel/apic/probe_32.c
19223 +++ b/arch/x86/kernel/apic/probe_32.c
19224 @@ -72,7 +72,7 @@ static int probe_default(void)
19225 return 1;
19226 }
19227
19228 -static struct apic apic_default = {
19229 +static struct apic apic_default __read_only = {
19230
19231 .name = "default",
19232 .probe = probe_default,
19233 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19234 index 77c95c0..434f8a4 100644
19235 --- a/arch/x86/kernel/apic/summit_32.c
19236 +++ b/arch/x86/kernel/apic/summit_32.c
19237 @@ -486,7 +486,7 @@ void setup_summit(void)
19238 }
19239 #endif
19240
19241 -static struct apic apic_summit = {
19242 +static struct apic apic_summit __read_only = {
19243
19244 .name = "summit",
19245 .probe = probe_summit,
19246 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19247 index 140e29d..d88bc95 100644
19248 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19249 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19250 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19251 return notifier_from_errno(err);
19252 }
19253
19254 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19255 +static struct notifier_block x2apic_cpu_notifier = {
19256 .notifier_call = update_clusterinfo,
19257 };
19258
19259 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19260 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19261 }
19262
19263 -static struct apic apic_x2apic_cluster = {
19264 +static struct apic apic_x2apic_cluster __read_only = {
19265
19266 .name = "cluster x2apic",
19267 .probe = x2apic_cluster_probe,
19268 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19269 index 562a76d..a003c0f 100644
19270 --- a/arch/x86/kernel/apic/x2apic_phys.c
19271 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19272 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19273 return apic == &apic_x2apic_phys;
19274 }
19275
19276 -static struct apic apic_x2apic_phys = {
19277 +static struct apic apic_x2apic_phys __read_only = {
19278
19279 .name = "physical x2apic",
19280 .probe = x2apic_phys_probe,
19281 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19282 index a419814..1dd34a0 100644
19283 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19284 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19285 @@ -357,7 +357,7 @@ static int uv_probe(void)
19286 return apic == &apic_x2apic_uv_x;
19287 }
19288
19289 -static struct apic __refdata apic_x2apic_uv_x = {
19290 +static struct apic apic_x2apic_uv_x __read_only = {
19291
19292 .name = "UV large system",
19293 .probe = uv_probe,
19294 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19295 index 53a4e27..038760a 100644
19296 --- a/arch/x86/kernel/apm_32.c
19297 +++ b/arch/x86/kernel/apm_32.c
19298 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19299 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19300 * even though they are called in protected mode.
19301 */
19302 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19303 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19304 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19305
19306 static const char driver_version[] = "1.16ac"; /* no spaces */
19307 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19308 BUG_ON(cpu != 0);
19309 gdt = get_cpu_gdt_table(cpu);
19310 save_desc_40 = gdt[0x40 / 8];
19311 +
19312 + pax_open_kernel();
19313 gdt[0x40 / 8] = bad_bios_desc;
19314 + pax_close_kernel();
19315
19316 apm_irq_save(flags);
19317 APM_DO_SAVE_SEGS;
19318 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19319 &call->esi);
19320 APM_DO_RESTORE_SEGS;
19321 apm_irq_restore(flags);
19322 +
19323 + pax_open_kernel();
19324 gdt[0x40 / 8] = save_desc_40;
19325 + pax_close_kernel();
19326 +
19327 put_cpu();
19328
19329 return call->eax & 0xff;
19330 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19331 BUG_ON(cpu != 0);
19332 gdt = get_cpu_gdt_table(cpu);
19333 save_desc_40 = gdt[0x40 / 8];
19334 +
19335 + pax_open_kernel();
19336 gdt[0x40 / 8] = bad_bios_desc;
19337 + pax_close_kernel();
19338
19339 apm_irq_save(flags);
19340 APM_DO_SAVE_SEGS;
19341 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19342 &call->eax);
19343 APM_DO_RESTORE_SEGS;
19344 apm_irq_restore(flags);
19345 +
19346 + pax_open_kernel();
19347 gdt[0x40 / 8] = save_desc_40;
19348 + pax_close_kernel();
19349 +
19350 put_cpu();
19351 return error;
19352 }
19353 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19354 * code to that CPU.
19355 */
19356 gdt = get_cpu_gdt_table(0);
19357 +
19358 + pax_open_kernel();
19359 set_desc_base(&gdt[APM_CS >> 3],
19360 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19361 set_desc_base(&gdt[APM_CS_16 >> 3],
19362 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19363 set_desc_base(&gdt[APM_DS >> 3],
19364 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19365 + pax_close_kernel();
19366
19367 proc_create("apm", 0, NULL, &apm_file_ops);
19368
19369 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19370 index 2861082..6d4718e 100644
19371 --- a/arch/x86/kernel/asm-offsets.c
19372 +++ b/arch/x86/kernel/asm-offsets.c
19373 @@ -33,6 +33,8 @@ void common(void) {
19374 OFFSET(TI_status, thread_info, status);
19375 OFFSET(TI_addr_limit, thread_info, addr_limit);
19376 OFFSET(TI_preempt_count, thread_info, preempt_count);
19377 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19378 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19379
19380 BLANK();
19381 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19382 @@ -53,8 +55,26 @@ void common(void) {
19383 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19384 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19385 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19386 +
19387 +#ifdef CONFIG_PAX_KERNEXEC
19388 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19389 #endif
19390
19391 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19392 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19393 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19394 +#ifdef CONFIG_X86_64
19395 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19396 +#endif
19397 +#endif
19398 +
19399 +#endif
19400 +
19401 + BLANK();
19402 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19403 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19404 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19405 +
19406 #ifdef CONFIG_XEN
19407 BLANK();
19408 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19409 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19410 index e7c798b..2b2019b 100644
19411 --- a/arch/x86/kernel/asm-offsets_64.c
19412 +++ b/arch/x86/kernel/asm-offsets_64.c
19413 @@ -77,6 +77,7 @@ int main(void)
19414 BLANK();
19415 #undef ENTRY
19416
19417 + DEFINE(TSS_size, sizeof(struct tss_struct));
19418 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19419 BLANK();
19420
19421 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19422 index 47b56a7..efc2bc6 100644
19423 --- a/arch/x86/kernel/cpu/Makefile
19424 +++ b/arch/x86/kernel/cpu/Makefile
19425 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19426 CFLAGS_REMOVE_perf_event.o = -pg
19427 endif
19428
19429 -# Make sure load_percpu_segment has no stackprotector
19430 -nostackp := $(call cc-option, -fno-stack-protector)
19431 -CFLAGS_common.o := $(nostackp)
19432 -
19433 obj-y := intel_cacheinfo.o scattered.o topology.o
19434 obj-y += proc.o capflags.o powerflags.o common.o
19435 obj-y += rdrand.o
19436 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19437 index 08a0890..e557865 100644
19438 --- a/arch/x86/kernel/cpu/amd.c
19439 +++ b/arch/x86/kernel/cpu/amd.c
19440 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19441 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19442 {
19443 /* AMD errata T13 (order #21922) */
19444 - if ((c->x86 == 6)) {
19445 + if (c->x86 == 6) {
19446 /* Duron Rev A0 */
19447 if (c->x86_model == 3 && c->x86_mask == 0)
19448 size = 64;
19449 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19450 index 25eb274..3a92d93 100644
19451 --- a/arch/x86/kernel/cpu/common.c
19452 +++ b/arch/x86/kernel/cpu/common.c
19453 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19454
19455 static const struct cpu_dev *this_cpu = &default_cpu;
19456
19457 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19458 -#ifdef CONFIG_X86_64
19459 - /*
19460 - * We need valid kernel segments for data and code in long mode too
19461 - * IRET will check the segment types kkeil 2000/10/28
19462 - * Also sysret mandates a special GDT layout
19463 - *
19464 - * TLS descriptors are currently at a different place compared to i386.
19465 - * Hopefully nobody expects them at a fixed place (Wine?)
19466 - */
19467 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19468 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19469 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19470 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19471 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19472 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19473 -#else
19474 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19475 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19476 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19477 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19478 - /*
19479 - * Segments used for calling PnP BIOS have byte granularity.
19480 - * They code segments and data segments have fixed 64k limits,
19481 - * the transfer segment sizes are set at run time.
19482 - */
19483 - /* 32-bit code */
19484 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19485 - /* 16-bit code */
19486 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19487 - /* 16-bit data */
19488 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19489 - /* 16-bit data */
19490 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19491 - /* 16-bit data */
19492 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19493 - /*
19494 - * The APM segments have byte granularity and their bases
19495 - * are set at run time. All have 64k limits.
19496 - */
19497 - /* 32-bit code */
19498 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19499 - /* 16-bit code */
19500 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19501 - /* data */
19502 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19503 -
19504 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19505 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19506 - GDT_STACK_CANARY_INIT
19507 -#endif
19508 -} };
19509 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19510 -
19511 static int __init x86_xsave_setup(char *s)
19512 {
19513 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19514 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19515 set_in_cr4(X86_CR4_SMAP);
19516 }
19517
19518 +#ifdef CONFIG_X86_64
19519 +static __init int setup_disable_pcid(char *arg)
19520 +{
19521 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19522 +
19523 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19524 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19525 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19526 +#endif
19527 +
19528 + return 1;
19529 +}
19530 +__setup("nopcid", setup_disable_pcid);
19531 +
19532 +static void setup_pcid(struct cpuinfo_x86 *c)
19533 +{
19534 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19535 +
19536 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19537 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19538 + pax_open_kernel();
19539 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19540 + pax_close_kernel();
19541 + printk("PAX: slow and weak UDEREF enabled\n");
19542 + } else
19543 + printk("PAX: UDEREF disabled\n");
19544 +#endif
19545 +
19546 + return;
19547 + }
19548 +
19549 + printk("PAX: PCID detected\n");
19550 + set_in_cr4(X86_CR4_PCIDE);
19551 +
19552 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19553 + pax_open_kernel();
19554 + clone_pgd_mask = ~(pgdval_t)0UL;
19555 + pax_close_kernel();
19556 + if (pax_user_shadow_base)
19557 + printk("PAX: weak UDEREF enabled\n");
19558 + else {
19559 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19560 + printk("PAX: strong UDEREF enabled\n");
19561 + }
19562 +#endif
19563 +
19564 + if (cpu_has(c, X86_FEATURE_INVPCID))
19565 + printk("PAX: INVPCID detected\n");
19566 +}
19567 +#endif
19568 +
19569 /*
19570 * Some CPU features depend on higher CPUID levels, which may not always
19571 * be available due to CPUID level capping or broken virtualization
19572 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19573 {
19574 struct desc_ptr gdt_descr;
19575
19576 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19577 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19578 gdt_descr.size = GDT_SIZE - 1;
19579 load_gdt(&gdt_descr);
19580 /* Reload the per-cpu base */
19581 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19582 setup_smep(c);
19583 setup_smap(c);
19584
19585 +#ifdef CONFIG_X86_64
19586 + setup_pcid(c);
19587 +#endif
19588 +
19589 /*
19590 * The vendor-specific functions might have changed features.
19591 * Now we do "generic changes."
19592 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19593 /* Filter out anything that depends on CPUID levels we don't have */
19594 filter_cpuid_features(c, true);
19595
19596 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19597 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19598 +#endif
19599 +
19600 /* If the model name is still unset, do table lookup. */
19601 if (!c->x86_model_id[0]) {
19602 const char *p;
19603 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19604 }
19605 __setup("clearcpuid=", setup_disablecpuid);
19606
19607 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19608 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19609 +
19610 #ifdef CONFIG_X86_64
19611 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19612 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19613 - (unsigned long) debug_idt_table };
19614 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19615 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19616
19617 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19618 irq_stack_union) __aligned(PAGE_SIZE);
19619 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19620 EXPORT_PER_CPU_SYMBOL(current_task);
19621
19622 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19623 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19624 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19625 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19626
19627 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19628 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19629 load_ucode_ap();
19630
19631 cpu = stack_smp_processor_id();
19632 - t = &per_cpu(init_tss, cpu);
19633 + t = init_tss + cpu;
19634 oist = &per_cpu(orig_ist, cpu);
19635
19636 #ifdef CONFIG_NUMA
19637 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19638 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19639 barrier();
19640
19641 - x86_configure_nx();
19642 enable_x2apic();
19643
19644 /*
19645 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19646 {
19647 int cpu = smp_processor_id();
19648 struct task_struct *curr = current;
19649 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19650 + struct tss_struct *t = init_tss + cpu;
19651 struct thread_struct *thread = &curr->thread;
19652
19653 show_ucode_info_early();
19654 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19655 index 1414c90..1159406 100644
19656 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19657 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19658 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19659 };
19660
19661 #ifdef CONFIG_AMD_NB
19662 +static struct attribute *default_attrs_amd_nb[] = {
19663 + &type.attr,
19664 + &level.attr,
19665 + &coherency_line_size.attr,
19666 + &physical_line_partition.attr,
19667 + &ways_of_associativity.attr,
19668 + &number_of_sets.attr,
19669 + &size.attr,
19670 + &shared_cpu_map.attr,
19671 + &shared_cpu_list.attr,
19672 + NULL,
19673 + NULL,
19674 + NULL,
19675 + NULL
19676 +};
19677 +
19678 static struct attribute **amd_l3_attrs(void)
19679 {
19680 static struct attribute **attrs;
19681 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19682
19683 n = ARRAY_SIZE(default_attrs);
19684
19685 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19686 - n += 2;
19687 -
19688 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19689 - n += 1;
19690 -
19691 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19692 - if (attrs == NULL)
19693 - return attrs = default_attrs;
19694 -
19695 - for (n = 0; default_attrs[n]; n++)
19696 - attrs[n] = default_attrs[n];
19697 + attrs = default_attrs_amd_nb;
19698
19699 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19700 attrs[n++] = &cache_disable_0.attr;
19701 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19702 .default_attrs = default_attrs,
19703 };
19704
19705 +#ifdef CONFIG_AMD_NB
19706 +static struct kobj_type ktype_cache_amd_nb = {
19707 + .sysfs_ops = &sysfs_ops,
19708 + .default_attrs = default_attrs_amd_nb,
19709 +};
19710 +#endif
19711 +
19712 static struct kobj_type ktype_percpu_entry = {
19713 .sysfs_ops = &sysfs_ops,
19714 };
19715 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19716 return retval;
19717 }
19718
19719 +#ifdef CONFIG_AMD_NB
19720 + amd_l3_attrs();
19721 +#endif
19722 +
19723 for (i = 0; i < num_cache_leaves; i++) {
19724 + struct kobj_type *ktype;
19725 +
19726 this_object = INDEX_KOBJECT_PTR(cpu, i);
19727 this_object->cpu = cpu;
19728 this_object->index = i;
19729
19730 this_leaf = CPUID4_INFO_IDX(cpu, i);
19731
19732 - ktype_cache.default_attrs = default_attrs;
19733 + ktype = &ktype_cache;
19734 #ifdef CONFIG_AMD_NB
19735 if (this_leaf->base.nb)
19736 - ktype_cache.default_attrs = amd_l3_attrs();
19737 + ktype = &ktype_cache_amd_nb;
19738 #endif
19739 retval = kobject_init_and_add(&(this_object->kobj),
19740 - &ktype_cache,
19741 + ktype,
19742 per_cpu(ici_cache_kobject, cpu),
19743 "index%1lu", i);
19744 if (unlikely(retval)) {
19745 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19746 index 87a65c9..92fcce6 100644
19747 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19748 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19749 @@ -45,6 +45,7 @@
19750 #include <asm/processor.h>
19751 #include <asm/mce.h>
19752 #include <asm/msr.h>
19753 +#include <asm/local.h>
19754
19755 #include "mce-internal.h"
19756
19757 @@ -249,7 +250,7 @@ static void print_mce(struct mce *m)
19758 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19759 m->cs, m->ip);
19760
19761 - if (m->cs == __KERNEL_CS)
19762 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19763 print_symbol("{%s}", m->ip);
19764 pr_cont("\n");
19765 }
19766 @@ -282,10 +283,10 @@ static void print_mce(struct mce *m)
19767
19768 #define PANIC_TIMEOUT 5 /* 5 seconds */
19769
19770 -static atomic_t mce_paniced;
19771 +static atomic_unchecked_t mce_paniced;
19772
19773 static int fake_panic;
19774 -static atomic_t mce_fake_paniced;
19775 +static atomic_unchecked_t mce_fake_paniced;
19776
19777 /* Panic in progress. Enable interrupts and wait for final IPI */
19778 static void wait_for_panic(void)
19779 @@ -309,7 +310,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19780 /*
19781 * Make sure only one CPU runs in machine check panic
19782 */
19783 - if (atomic_inc_return(&mce_paniced) > 1)
19784 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19785 wait_for_panic();
19786 barrier();
19787
19788 @@ -317,7 +318,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19789 console_verbose();
19790 } else {
19791 /* Don't log too much for fake panic */
19792 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19793 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19794 return;
19795 }
19796 /* First print corrected ones that are still unlogged */
19797 @@ -356,7 +357,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19798 if (!fake_panic) {
19799 if (panic_timeout == 0)
19800 panic_timeout = mca_cfg.panic_timeout;
19801 - panic(msg);
19802 + panic("%s", msg);
19803 } else
19804 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19805 }
19806 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
19807 * might have been modified by someone else.
19808 */
19809 rmb();
19810 - if (atomic_read(&mce_paniced))
19811 + if (atomic_read_unchecked(&mce_paniced))
19812 wait_for_panic();
19813 if (!mca_cfg.monarch_timeout)
19814 goto out;
19815 @@ -1657,7 +1658,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19816 }
19817
19818 /* Call the installed machine check handler for this CPU setup. */
19819 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19820 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19821 unexpected_machine_check;
19822
19823 /*
19824 @@ -1680,7 +1681,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19825 return;
19826 }
19827
19828 + pax_open_kernel();
19829 machine_check_vector = do_machine_check;
19830 + pax_close_kernel();
19831
19832 __mcheck_cpu_init_generic();
19833 __mcheck_cpu_init_vendor(c);
19834 @@ -1694,7 +1697,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19835 */
19836
19837 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19838 -static int mce_chrdev_open_count; /* #times opened */
19839 +static local_t mce_chrdev_open_count; /* #times opened */
19840 static int mce_chrdev_open_exclu; /* already open exclusive? */
19841
19842 static int mce_chrdev_open(struct inode *inode, struct file *file)
19843 @@ -1702,7 +1705,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19844 spin_lock(&mce_chrdev_state_lock);
19845
19846 if (mce_chrdev_open_exclu ||
19847 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19848 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19849 spin_unlock(&mce_chrdev_state_lock);
19850
19851 return -EBUSY;
19852 @@ -1710,7 +1713,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19853
19854 if (file->f_flags & O_EXCL)
19855 mce_chrdev_open_exclu = 1;
19856 - mce_chrdev_open_count++;
19857 + local_inc(&mce_chrdev_open_count);
19858
19859 spin_unlock(&mce_chrdev_state_lock);
19860
19861 @@ -1721,7 +1724,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19862 {
19863 spin_lock(&mce_chrdev_state_lock);
19864
19865 - mce_chrdev_open_count--;
19866 + local_dec(&mce_chrdev_open_count);
19867 mce_chrdev_open_exclu = 0;
19868
19869 spin_unlock(&mce_chrdev_state_lock);
19870 @@ -2376,7 +2379,7 @@ static __init void mce_init_banks(void)
19871
19872 for (i = 0; i < mca_cfg.banks; i++) {
19873 struct mce_bank *b = &mce_banks[i];
19874 - struct device_attribute *a = &b->attr;
19875 + device_attribute_no_const *a = &b->attr;
19876
19877 sysfs_attr_init(&a->attr);
19878 a->attr.name = b->attrname;
19879 @@ -2444,7 +2447,7 @@ struct dentry *mce_get_debugfs_dir(void)
19880 static void mce_reset(void)
19881 {
19882 cpu_missing = 0;
19883 - atomic_set(&mce_fake_paniced, 0);
19884 + atomic_set_unchecked(&mce_fake_paniced, 0);
19885 atomic_set(&mce_executing, 0);
19886 atomic_set(&mce_callin, 0);
19887 atomic_set(&global_nwo, 0);
19888 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19889 index 1c044b1..37a2a43 100644
19890 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19891 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19892 @@ -11,6 +11,7 @@
19893 #include <asm/processor.h>
19894 #include <asm/mce.h>
19895 #include <asm/msr.h>
19896 +#include <asm/pgtable.h>
19897
19898 /* By default disabled */
19899 int mce_p5_enabled __read_mostly;
19900 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19901 if (!cpu_has(c, X86_FEATURE_MCE))
19902 return;
19903
19904 + pax_open_kernel();
19905 machine_check_vector = pentium_machine_check;
19906 + pax_close_kernel();
19907 /* Make sure the vector pointer is visible before we enable MCEs: */
19908 wmb();
19909
19910 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19911 index e9a701a..35317d6 100644
19912 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19913 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19914 @@ -10,6 +10,7 @@
19915 #include <asm/processor.h>
19916 #include <asm/mce.h>
19917 #include <asm/msr.h>
19918 +#include <asm/pgtable.h>
19919
19920 /* Machine check handler for WinChip C6: */
19921 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19922 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19923 {
19924 u32 lo, hi;
19925
19926 + pax_open_kernel();
19927 machine_check_vector = winchip_machine_check;
19928 + pax_close_kernel();
19929 /* Make sure the vector pointer is visible before we enable MCEs: */
19930 wmb();
19931
19932 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19933 index f961de9..8a9d332 100644
19934 --- a/arch/x86/kernel/cpu/mtrr/main.c
19935 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19936 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19937 u64 size_or_mask, size_and_mask;
19938 static bool mtrr_aps_delayed_init;
19939
19940 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19941 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19942
19943 const struct mtrr_ops *mtrr_if;
19944
19945 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19946 index df5e41f..816c719 100644
19947 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19948 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19949 @@ -25,7 +25,7 @@ struct mtrr_ops {
19950 int (*validate_add_page)(unsigned long base, unsigned long size,
19951 unsigned int type);
19952 int (*have_wrcomb)(void);
19953 -};
19954 +} __do_const;
19955
19956 extern int generic_get_free_region(unsigned long base, unsigned long size,
19957 int replace_reg);
19958 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19959 index a7c7305..b9705ab 100644
19960 --- a/arch/x86/kernel/cpu/perf_event.c
19961 +++ b/arch/x86/kernel/cpu/perf_event.c
19962 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19963 pr_info("no hardware sampling interrupt available.\n");
19964 }
19965
19966 -static struct attribute_group x86_pmu_format_group = {
19967 +static attribute_group_no_const x86_pmu_format_group = {
19968 .name = "format",
19969 .attrs = NULL,
19970 };
19971 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19972 NULL,
19973 };
19974
19975 -static struct attribute_group x86_pmu_events_group = {
19976 +static attribute_group_no_const x86_pmu_events_group = {
19977 .name = "events",
19978 .attrs = events_attr,
19979 };
19980 @@ -1957,7 +1957,7 @@ static unsigned long get_segment_base(unsigned int segment)
19981 if (idx > GDT_ENTRIES)
19982 return 0;
19983
19984 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
19985 + desc = get_cpu_gdt_table(smp_processor_id());
19986 }
19987
19988 return get_desc_base(desc + idx);
19989 @@ -2047,7 +2047,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
19990 break;
19991
19992 perf_callchain_store(entry, frame.return_address);
19993 - fp = frame.next_frame;
19994 + fp = (const void __force_user *)frame.next_frame;
19995 }
19996 }
19997
19998 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
19999 index 639d128..e92d7e5 100644
20000 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20001 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20002 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20003 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20004 {
20005 struct attribute **attrs;
20006 - struct attribute_group *attr_group;
20007 + attribute_group_no_const *attr_group;
20008 int i = 0, j;
20009
20010 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20011 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20012 index a45d8d4..8abd32c 100644
20013 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20014 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20015 @@ -2099,10 +2099,10 @@ __init int intel_pmu_init(void)
20016 * v2 and above have a perf capabilities MSR
20017 */
20018 if (version > 1) {
20019 - u64 capabilities;
20020 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20021
20022 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20023 - x86_pmu.intel_cap.capabilities = capabilities;
20024 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20025 + x86_pmu.intel_cap.capabilities = capabilities;
20026 }
20027
20028 intel_ds_init();
20029 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20030 index 1fb6c72..f5fa2a3 100644
20031 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20032 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20033 @@ -3095,7 +3095,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20034 static int __init uncore_type_init(struct intel_uncore_type *type)
20035 {
20036 struct intel_uncore_pmu *pmus;
20037 - struct attribute_group *attr_group;
20038 + attribute_group_no_const *attr_group;
20039 struct attribute **attrs;
20040 int i, j;
20041
20042 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20043 index 47b3d00c..2cf1751 100644
20044 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20045 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20046 @@ -488,7 +488,7 @@ struct intel_uncore_box {
20047 struct uncore_event_desc {
20048 struct kobj_attribute attr;
20049 const char *config;
20050 -};
20051 +} __do_const;
20052
20053 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20054 { \
20055 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20056 index 7d9481c..99c7e4b 100644
20057 --- a/arch/x86/kernel/cpuid.c
20058 +++ b/arch/x86/kernel/cpuid.c
20059 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20060 return notifier_from_errno(err);
20061 }
20062
20063 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20064 +static struct notifier_block cpuid_class_cpu_notifier =
20065 {
20066 .notifier_call = cpuid_class_cpu_callback,
20067 };
20068 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20069 index 74467fe..18793d5 100644
20070 --- a/arch/x86/kernel/crash.c
20071 +++ b/arch/x86/kernel/crash.c
20072 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20073 {
20074 #ifdef CONFIG_X86_32
20075 struct pt_regs fixed_regs;
20076 -#endif
20077
20078 -#ifdef CONFIG_X86_32
20079 - if (!user_mode_vm(regs)) {
20080 + if (!user_mode(regs)) {
20081 crash_fixup_ss_esp(&fixed_regs, regs);
20082 regs = &fixed_regs;
20083 }
20084 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20085 index afa64ad..dce67dd 100644
20086 --- a/arch/x86/kernel/crash_dump_64.c
20087 +++ b/arch/x86/kernel/crash_dump_64.c
20088 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20089 return -ENOMEM;
20090
20091 if (userbuf) {
20092 - if (copy_to_user(buf, vaddr + offset, csize)) {
20093 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20094 iounmap(vaddr);
20095 return -EFAULT;
20096 }
20097 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20098 index 5d3fe8d..02e1429 100644
20099 --- a/arch/x86/kernel/doublefault.c
20100 +++ b/arch/x86/kernel/doublefault.c
20101 @@ -13,7 +13,7 @@
20102
20103 #define DOUBLEFAULT_STACKSIZE (1024)
20104 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20105 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20106 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20107
20108 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20109
20110 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20111 unsigned long gdt, tss;
20112
20113 native_store_gdt(&gdt_desc);
20114 - gdt = gdt_desc.address;
20115 + gdt = (unsigned long)gdt_desc.address;
20116
20117 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20118
20119 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20120 /* 0x2 bit is always set */
20121 .flags = X86_EFLAGS_SF | 0x2,
20122 .sp = STACK_START,
20123 - .es = __USER_DS,
20124 + .es = __KERNEL_DS,
20125 .cs = __KERNEL_CS,
20126 .ss = __KERNEL_DS,
20127 - .ds = __USER_DS,
20128 + .ds = __KERNEL_DS,
20129 .fs = __KERNEL_PERCPU,
20130
20131 .__cr3 = __pa_nodebug(swapper_pg_dir),
20132 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20133 index deb6421..76bbc12 100644
20134 --- a/arch/x86/kernel/dumpstack.c
20135 +++ b/arch/x86/kernel/dumpstack.c
20136 @@ -2,6 +2,9 @@
20137 * Copyright (C) 1991, 1992 Linus Torvalds
20138 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20139 */
20140 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20141 +#define __INCLUDED_BY_HIDESYM 1
20142 +#endif
20143 #include <linux/kallsyms.h>
20144 #include <linux/kprobes.h>
20145 #include <linux/uaccess.h>
20146 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20147 static void
20148 print_ftrace_graph_addr(unsigned long addr, void *data,
20149 const struct stacktrace_ops *ops,
20150 - struct thread_info *tinfo, int *graph)
20151 + struct task_struct *task, int *graph)
20152 {
20153 - struct task_struct *task;
20154 unsigned long ret_addr;
20155 int index;
20156
20157 if (addr != (unsigned long)return_to_handler)
20158 return;
20159
20160 - task = tinfo->task;
20161 index = task->curr_ret_stack;
20162
20163 if (!task->ret_stack || index < *graph)
20164 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20165 static inline void
20166 print_ftrace_graph_addr(unsigned long addr, void *data,
20167 const struct stacktrace_ops *ops,
20168 - struct thread_info *tinfo, int *graph)
20169 + struct task_struct *task, int *graph)
20170 { }
20171 #endif
20172
20173 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20174 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20175 */
20176
20177 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20178 - void *p, unsigned int size, void *end)
20179 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20180 {
20181 - void *t = tinfo;
20182 if (end) {
20183 if (p < end && p >= (end-THREAD_SIZE))
20184 return 1;
20185 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20186 }
20187
20188 unsigned long
20189 -print_context_stack(struct thread_info *tinfo,
20190 +print_context_stack(struct task_struct *task, void *stack_start,
20191 unsigned long *stack, unsigned long bp,
20192 const struct stacktrace_ops *ops, void *data,
20193 unsigned long *end, int *graph)
20194 {
20195 struct stack_frame *frame = (struct stack_frame *)bp;
20196
20197 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20198 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20199 unsigned long addr;
20200
20201 addr = *stack;
20202 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20203 } else {
20204 ops->address(data, addr, 0);
20205 }
20206 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20207 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20208 }
20209 stack++;
20210 }
20211 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20212 EXPORT_SYMBOL_GPL(print_context_stack);
20213
20214 unsigned long
20215 -print_context_stack_bp(struct thread_info *tinfo,
20216 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20217 unsigned long *stack, unsigned long bp,
20218 const struct stacktrace_ops *ops, void *data,
20219 unsigned long *end, int *graph)
20220 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20221 struct stack_frame *frame = (struct stack_frame *)bp;
20222 unsigned long *ret_addr = &frame->return_address;
20223
20224 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20225 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20226 unsigned long addr = *ret_addr;
20227
20228 if (!__kernel_text_address(addr))
20229 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20230 ops->address(data, addr, 1);
20231 frame = frame->next_frame;
20232 ret_addr = &frame->return_address;
20233 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20234 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20235 }
20236
20237 return (unsigned long)frame;
20238 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20239 static void print_trace_address(void *data, unsigned long addr, int reliable)
20240 {
20241 touch_nmi_watchdog();
20242 - printk(data);
20243 + printk("%s", (char *)data);
20244 printk_address(addr, reliable);
20245 }
20246
20247 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20248 }
20249 EXPORT_SYMBOL_GPL(oops_begin);
20250
20251 +extern void gr_handle_kernel_exploit(void);
20252 +
20253 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20254 {
20255 if (regs && kexec_should_crash(current))
20256 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20257 panic("Fatal exception in interrupt");
20258 if (panic_on_oops)
20259 panic("Fatal exception");
20260 - do_exit(signr);
20261 +
20262 + gr_handle_kernel_exploit();
20263 +
20264 + do_group_exit(signr);
20265 }
20266
20267 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20268 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20269 print_modules();
20270 show_regs(regs);
20271 #ifdef CONFIG_X86_32
20272 - if (user_mode_vm(regs)) {
20273 + if (user_mode(regs)) {
20274 sp = regs->sp;
20275 ss = regs->ss & 0xffff;
20276 } else {
20277 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20278 unsigned long flags = oops_begin();
20279 int sig = SIGSEGV;
20280
20281 - if (!user_mode_vm(regs))
20282 + if (!user_mode(regs))
20283 report_bug(regs->ip, regs);
20284
20285 if (__die(str, regs, err))
20286 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20287 index f2a1770..540657f 100644
20288 --- a/arch/x86/kernel/dumpstack_32.c
20289 +++ b/arch/x86/kernel/dumpstack_32.c
20290 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20291 bp = stack_frame(task, regs);
20292
20293 for (;;) {
20294 - struct thread_info *context;
20295 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20296
20297 - context = (struct thread_info *)
20298 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20299 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20300 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20301
20302 - stack = (unsigned long *)context->previous_esp;
20303 - if (!stack)
20304 + if (stack_start == task_stack_page(task))
20305 break;
20306 + stack = *(unsigned long **)stack_start;
20307 if (ops->stack(data, "IRQ") < 0)
20308 break;
20309 touch_nmi_watchdog();
20310 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20311 int i;
20312
20313 show_regs_print_info(KERN_EMERG);
20314 - __show_regs(regs, !user_mode_vm(regs));
20315 + __show_regs(regs, !user_mode(regs));
20316
20317 /*
20318 * When in-kernel, we also print out the stack and code at the
20319 * time of the fault..
20320 */
20321 - if (!user_mode_vm(regs)) {
20322 + if (!user_mode(regs)) {
20323 unsigned int code_prologue = code_bytes * 43 / 64;
20324 unsigned int code_len = code_bytes;
20325 unsigned char c;
20326 u8 *ip;
20327 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20328
20329 pr_emerg("Stack:\n");
20330 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20331
20332 pr_emerg("Code:");
20333
20334 - ip = (u8 *)regs->ip - code_prologue;
20335 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20336 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20337 /* try starting at IP */
20338 - ip = (u8 *)regs->ip;
20339 + ip = (u8 *)regs->ip + cs_base;
20340 code_len = code_len - code_prologue + 1;
20341 }
20342 for (i = 0; i < code_len; i++, ip++) {
20343 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20344 pr_cont(" Bad EIP value.");
20345 break;
20346 }
20347 - if (ip == (u8 *)regs->ip)
20348 + if (ip == (u8 *)regs->ip + cs_base)
20349 pr_cont(" <%02x>", c);
20350 else
20351 pr_cont(" %02x", c);
20352 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20353 {
20354 unsigned short ud2;
20355
20356 + ip = ktla_ktva(ip);
20357 if (ip < PAGE_OFFSET)
20358 return 0;
20359 if (probe_kernel_address((unsigned short *)ip, ud2))
20360 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20361
20362 return ud2 == 0x0b0f;
20363 }
20364 +
20365 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20366 +void pax_check_alloca(unsigned long size)
20367 +{
20368 + unsigned long sp = (unsigned long)&sp, stack_left;
20369 +
20370 + /* all kernel stacks are of the same size */
20371 + stack_left = sp & (THREAD_SIZE - 1);
20372 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20373 +}
20374 +EXPORT_SYMBOL(pax_check_alloca);
20375 +#endif
20376 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20377 index addb207..99635fa 100644
20378 --- a/arch/x86/kernel/dumpstack_64.c
20379 +++ b/arch/x86/kernel/dumpstack_64.c
20380 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20381 unsigned long *irq_stack_end =
20382 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20383 unsigned used = 0;
20384 - struct thread_info *tinfo;
20385 int graph = 0;
20386 unsigned long dummy;
20387 + void *stack_start;
20388
20389 if (!task)
20390 task = current;
20391 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20392 * current stack address. If the stacks consist of nested
20393 * exceptions
20394 */
20395 - tinfo = task_thread_info(task);
20396 for (;;) {
20397 char *id;
20398 unsigned long *estack_end;
20399 +
20400 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20401 &used, &id);
20402
20403 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20404 if (ops->stack(data, id) < 0)
20405 break;
20406
20407 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20408 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20409 data, estack_end, &graph);
20410 ops->stack(data, "<EOE>");
20411 /*
20412 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20413 * second-to-last pointer (index -2 to end) in the
20414 * exception stack:
20415 */
20416 + if ((u16)estack_end[-1] != __KERNEL_DS)
20417 + goto out;
20418 stack = (unsigned long *) estack_end[-2];
20419 continue;
20420 }
20421 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20422 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20423 if (ops->stack(data, "IRQ") < 0)
20424 break;
20425 - bp = ops->walk_stack(tinfo, stack, bp,
20426 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20427 ops, data, irq_stack_end, &graph);
20428 /*
20429 * We link to the next stack (which would be
20430 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20431 /*
20432 * This handles the process stack:
20433 */
20434 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20435 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20436 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20437 +out:
20438 put_cpu();
20439 }
20440 EXPORT_SYMBOL(dump_trace);
20441 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20442
20443 return ud2 == 0x0b0f;
20444 }
20445 +
20446 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20447 +void pax_check_alloca(unsigned long size)
20448 +{
20449 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20450 + unsigned cpu, used;
20451 + char *id;
20452 +
20453 + /* check the process stack first */
20454 + stack_start = (unsigned long)task_stack_page(current);
20455 + stack_end = stack_start + THREAD_SIZE;
20456 + if (likely(stack_start <= sp && sp < stack_end)) {
20457 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20458 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20459 + return;
20460 + }
20461 +
20462 + cpu = get_cpu();
20463 +
20464 + /* check the irq stacks */
20465 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20466 + stack_start = stack_end - IRQ_STACK_SIZE;
20467 + if (stack_start <= sp && sp < stack_end) {
20468 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20469 + put_cpu();
20470 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20471 + return;
20472 + }
20473 +
20474 + /* check the exception stacks */
20475 + used = 0;
20476 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20477 + stack_start = stack_end - EXCEPTION_STKSZ;
20478 + if (stack_end && stack_start <= sp && sp < stack_end) {
20479 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20480 + put_cpu();
20481 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20482 + return;
20483 + }
20484 +
20485 + put_cpu();
20486 +
20487 + /* unknown stack */
20488 + BUG();
20489 +}
20490 +EXPORT_SYMBOL(pax_check_alloca);
20491 +#endif
20492 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20493 index 174da5f..5e55606 100644
20494 --- a/arch/x86/kernel/e820.c
20495 +++ b/arch/x86/kernel/e820.c
20496 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20497
20498 static void early_panic(char *msg)
20499 {
20500 - early_printk(msg);
20501 - panic(msg);
20502 + early_printk("%s", msg);
20503 + panic("%s", msg);
20504 }
20505
20506 static int userdef __initdata;
20507 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20508 index d15f575..d692043 100644
20509 --- a/arch/x86/kernel/early_printk.c
20510 +++ b/arch/x86/kernel/early_printk.c
20511 @@ -7,6 +7,7 @@
20512 #include <linux/pci_regs.h>
20513 #include <linux/pci_ids.h>
20514 #include <linux/errno.h>
20515 +#include <linux/sched.h>
20516 #include <asm/io.h>
20517 #include <asm/processor.h>
20518 #include <asm/fcntl.h>
20519 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20520 index 2cfbc3a..b756682 100644
20521 --- a/arch/x86/kernel/entry_32.S
20522 +++ b/arch/x86/kernel/entry_32.S
20523 @@ -177,13 +177,153 @@
20524 /*CFI_REL_OFFSET gs, PT_GS*/
20525 .endm
20526 .macro SET_KERNEL_GS reg
20527 +
20528 +#ifdef CONFIG_CC_STACKPROTECTOR
20529 movl $(__KERNEL_STACK_CANARY), \reg
20530 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20531 + movl $(__USER_DS), \reg
20532 +#else
20533 + xorl \reg, \reg
20534 +#endif
20535 +
20536 movl \reg, %gs
20537 .endm
20538
20539 #endif /* CONFIG_X86_32_LAZY_GS */
20540
20541 -.macro SAVE_ALL
20542 +.macro pax_enter_kernel
20543 +#ifdef CONFIG_PAX_KERNEXEC
20544 + call pax_enter_kernel
20545 +#endif
20546 +.endm
20547 +
20548 +.macro pax_exit_kernel
20549 +#ifdef CONFIG_PAX_KERNEXEC
20550 + call pax_exit_kernel
20551 +#endif
20552 +.endm
20553 +
20554 +#ifdef CONFIG_PAX_KERNEXEC
20555 +ENTRY(pax_enter_kernel)
20556 +#ifdef CONFIG_PARAVIRT
20557 + pushl %eax
20558 + pushl %ecx
20559 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20560 + mov %eax, %esi
20561 +#else
20562 + mov %cr0, %esi
20563 +#endif
20564 + bts $16, %esi
20565 + jnc 1f
20566 + mov %cs, %esi
20567 + cmp $__KERNEL_CS, %esi
20568 + jz 3f
20569 + ljmp $__KERNEL_CS, $3f
20570 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20571 +2:
20572 +#ifdef CONFIG_PARAVIRT
20573 + mov %esi, %eax
20574 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20575 +#else
20576 + mov %esi, %cr0
20577 +#endif
20578 +3:
20579 +#ifdef CONFIG_PARAVIRT
20580 + popl %ecx
20581 + popl %eax
20582 +#endif
20583 + ret
20584 +ENDPROC(pax_enter_kernel)
20585 +
20586 +ENTRY(pax_exit_kernel)
20587 +#ifdef CONFIG_PARAVIRT
20588 + pushl %eax
20589 + pushl %ecx
20590 +#endif
20591 + mov %cs, %esi
20592 + cmp $__KERNEXEC_KERNEL_CS, %esi
20593 + jnz 2f
20594 +#ifdef CONFIG_PARAVIRT
20595 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20596 + mov %eax, %esi
20597 +#else
20598 + mov %cr0, %esi
20599 +#endif
20600 + btr $16, %esi
20601 + ljmp $__KERNEL_CS, $1f
20602 +1:
20603 +#ifdef CONFIG_PARAVIRT
20604 + mov %esi, %eax
20605 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20606 +#else
20607 + mov %esi, %cr0
20608 +#endif
20609 +2:
20610 +#ifdef CONFIG_PARAVIRT
20611 + popl %ecx
20612 + popl %eax
20613 +#endif
20614 + ret
20615 +ENDPROC(pax_exit_kernel)
20616 +#endif
20617 +
20618 + .macro pax_erase_kstack
20619 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20620 + call pax_erase_kstack
20621 +#endif
20622 + .endm
20623 +
20624 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20625 +/*
20626 + * ebp: thread_info
20627 + */
20628 +ENTRY(pax_erase_kstack)
20629 + pushl %edi
20630 + pushl %ecx
20631 + pushl %eax
20632 +
20633 + mov TI_lowest_stack(%ebp), %edi
20634 + mov $-0xBEEF, %eax
20635 + std
20636 +
20637 +1: mov %edi, %ecx
20638 + and $THREAD_SIZE_asm - 1, %ecx
20639 + shr $2, %ecx
20640 + repne scasl
20641 + jecxz 2f
20642 +
20643 + cmp $2*16, %ecx
20644 + jc 2f
20645 +
20646 + mov $2*16, %ecx
20647 + repe scasl
20648 + jecxz 2f
20649 + jne 1b
20650 +
20651 +2: cld
20652 + mov %esp, %ecx
20653 + sub %edi, %ecx
20654 +
20655 + cmp $THREAD_SIZE_asm, %ecx
20656 + jb 3f
20657 + ud2
20658 +3:
20659 +
20660 + shr $2, %ecx
20661 + rep stosl
20662 +
20663 + mov TI_task_thread_sp0(%ebp), %edi
20664 + sub $128, %edi
20665 + mov %edi, TI_lowest_stack(%ebp)
20666 +
20667 + popl %eax
20668 + popl %ecx
20669 + popl %edi
20670 + ret
20671 +ENDPROC(pax_erase_kstack)
20672 +#endif
20673 +
20674 +.macro __SAVE_ALL _DS
20675 cld
20676 PUSH_GS
20677 pushl_cfi %fs
20678 @@ -206,7 +346,7 @@
20679 CFI_REL_OFFSET ecx, 0
20680 pushl_cfi %ebx
20681 CFI_REL_OFFSET ebx, 0
20682 - movl $(__USER_DS), %edx
20683 + movl $\_DS, %edx
20684 movl %edx, %ds
20685 movl %edx, %es
20686 movl $(__KERNEL_PERCPU), %edx
20687 @@ -214,6 +354,15 @@
20688 SET_KERNEL_GS %edx
20689 .endm
20690
20691 +.macro SAVE_ALL
20692 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20693 + __SAVE_ALL __KERNEL_DS
20694 + pax_enter_kernel
20695 +#else
20696 + __SAVE_ALL __USER_DS
20697 +#endif
20698 +.endm
20699 +
20700 .macro RESTORE_INT_REGS
20701 popl_cfi %ebx
20702 CFI_RESTORE ebx
20703 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20704 popfl_cfi
20705 jmp syscall_exit
20706 CFI_ENDPROC
20707 -END(ret_from_fork)
20708 +ENDPROC(ret_from_fork)
20709
20710 ENTRY(ret_from_kernel_thread)
20711 CFI_STARTPROC
20712 @@ -344,7 +493,15 @@ ret_from_intr:
20713 andl $SEGMENT_RPL_MASK, %eax
20714 #endif
20715 cmpl $USER_RPL, %eax
20716 +
20717 +#ifdef CONFIG_PAX_KERNEXEC
20718 + jae resume_userspace
20719 +
20720 + pax_exit_kernel
20721 + jmp resume_kernel
20722 +#else
20723 jb resume_kernel # not returning to v8086 or userspace
20724 +#endif
20725
20726 ENTRY(resume_userspace)
20727 LOCKDEP_SYS_EXIT
20728 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20729 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20730 # int/exception return?
20731 jne work_pending
20732 - jmp restore_all
20733 -END(ret_from_exception)
20734 + jmp restore_all_pax
20735 +ENDPROC(ret_from_exception)
20736
20737 #ifdef CONFIG_PREEMPT
20738 ENTRY(resume_kernel)
20739 @@ -372,7 +529,7 @@ need_resched:
20740 jz restore_all
20741 call preempt_schedule_irq
20742 jmp need_resched
20743 -END(resume_kernel)
20744 +ENDPROC(resume_kernel)
20745 #endif
20746 CFI_ENDPROC
20747 /*
20748 @@ -406,30 +563,45 @@ sysenter_past_esp:
20749 /*CFI_REL_OFFSET cs, 0*/
20750 /*
20751 * Push current_thread_info()->sysenter_return to the stack.
20752 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20753 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20754 */
20755 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20756 + pushl_cfi $0
20757 CFI_REL_OFFSET eip, 0
20758
20759 pushl_cfi %eax
20760 SAVE_ALL
20761 + GET_THREAD_INFO(%ebp)
20762 + movl TI_sysenter_return(%ebp),%ebp
20763 + movl %ebp,PT_EIP(%esp)
20764 ENABLE_INTERRUPTS(CLBR_NONE)
20765
20766 /*
20767 * Load the potential sixth argument from user stack.
20768 * Careful about security.
20769 */
20770 + movl PT_OLDESP(%esp),%ebp
20771 +
20772 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20773 + mov PT_OLDSS(%esp),%ds
20774 +1: movl %ds:(%ebp),%ebp
20775 + push %ss
20776 + pop %ds
20777 +#else
20778 cmpl $__PAGE_OFFSET-3,%ebp
20779 jae syscall_fault
20780 ASM_STAC
20781 1: movl (%ebp),%ebp
20782 ASM_CLAC
20783 +#endif
20784 +
20785 movl %ebp,PT_EBP(%esp)
20786 _ASM_EXTABLE(1b,syscall_fault)
20787
20788 GET_THREAD_INFO(%ebp)
20789
20790 +#ifdef CONFIG_PAX_RANDKSTACK
20791 + pax_erase_kstack
20792 +#endif
20793 +
20794 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20795 jnz sysenter_audit
20796 sysenter_do_call:
20797 @@ -444,12 +616,24 @@ sysenter_do_call:
20798 testl $_TIF_ALLWORK_MASK, %ecx
20799 jne sysexit_audit
20800 sysenter_exit:
20801 +
20802 +#ifdef CONFIG_PAX_RANDKSTACK
20803 + pushl_cfi %eax
20804 + movl %esp, %eax
20805 + call pax_randomize_kstack
20806 + popl_cfi %eax
20807 +#endif
20808 +
20809 + pax_erase_kstack
20810 +
20811 /* if something modifies registers it must also disable sysexit */
20812 movl PT_EIP(%esp), %edx
20813 movl PT_OLDESP(%esp), %ecx
20814 xorl %ebp,%ebp
20815 TRACE_IRQS_ON
20816 1: mov PT_FS(%esp), %fs
20817 +2: mov PT_DS(%esp), %ds
20818 +3: mov PT_ES(%esp), %es
20819 PTGS_TO_GS
20820 ENABLE_INTERRUPTS_SYSEXIT
20821
20822 @@ -466,6 +650,9 @@ sysenter_audit:
20823 movl %eax,%edx /* 2nd arg: syscall number */
20824 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20825 call __audit_syscall_entry
20826 +
20827 + pax_erase_kstack
20828 +
20829 pushl_cfi %ebx
20830 movl PT_EAX(%esp),%eax /* reload syscall number */
20831 jmp sysenter_do_call
20832 @@ -491,10 +678,16 @@ sysexit_audit:
20833
20834 CFI_ENDPROC
20835 .pushsection .fixup,"ax"
20836 -2: movl $0,PT_FS(%esp)
20837 +4: movl $0,PT_FS(%esp)
20838 + jmp 1b
20839 +5: movl $0,PT_DS(%esp)
20840 + jmp 1b
20841 +6: movl $0,PT_ES(%esp)
20842 jmp 1b
20843 .popsection
20844 - _ASM_EXTABLE(1b,2b)
20845 + _ASM_EXTABLE(1b,4b)
20846 + _ASM_EXTABLE(2b,5b)
20847 + _ASM_EXTABLE(3b,6b)
20848 PTGS_TO_GS_EX
20849 ENDPROC(ia32_sysenter_target)
20850
20851 @@ -509,6 +702,11 @@ ENTRY(system_call)
20852 pushl_cfi %eax # save orig_eax
20853 SAVE_ALL
20854 GET_THREAD_INFO(%ebp)
20855 +
20856 +#ifdef CONFIG_PAX_RANDKSTACK
20857 + pax_erase_kstack
20858 +#endif
20859 +
20860 # system call tracing in operation / emulation
20861 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20862 jnz syscall_trace_entry
20863 @@ -527,6 +725,15 @@ syscall_exit:
20864 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20865 jne syscall_exit_work
20866
20867 +restore_all_pax:
20868 +
20869 +#ifdef CONFIG_PAX_RANDKSTACK
20870 + movl %esp, %eax
20871 + call pax_randomize_kstack
20872 +#endif
20873 +
20874 + pax_erase_kstack
20875 +
20876 restore_all:
20877 TRACE_IRQS_IRET
20878 restore_all_notrace:
20879 @@ -583,14 +790,34 @@ ldt_ss:
20880 * compensating for the offset by changing to the ESPFIX segment with
20881 * a base address that matches for the difference.
20882 */
20883 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20884 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20885 mov %esp, %edx /* load kernel esp */
20886 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20887 mov %dx, %ax /* eax: new kernel esp */
20888 sub %eax, %edx /* offset (low word is 0) */
20889 +#ifdef CONFIG_SMP
20890 + movl PER_CPU_VAR(cpu_number), %ebx
20891 + shll $PAGE_SHIFT_asm, %ebx
20892 + addl $cpu_gdt_table, %ebx
20893 +#else
20894 + movl $cpu_gdt_table, %ebx
20895 +#endif
20896 shr $16, %edx
20897 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20898 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20899 +
20900 +#ifdef CONFIG_PAX_KERNEXEC
20901 + mov %cr0, %esi
20902 + btr $16, %esi
20903 + mov %esi, %cr0
20904 +#endif
20905 +
20906 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20907 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20908 +
20909 +#ifdef CONFIG_PAX_KERNEXEC
20910 + bts $16, %esi
20911 + mov %esi, %cr0
20912 +#endif
20913 +
20914 pushl_cfi $__ESPFIX_SS
20915 pushl_cfi %eax /* new kernel esp */
20916 /* Disable interrupts, but do not irqtrace this section: we
20917 @@ -619,20 +846,18 @@ work_resched:
20918 movl TI_flags(%ebp), %ecx
20919 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20920 # than syscall tracing?
20921 - jz restore_all
20922 + jz restore_all_pax
20923 testb $_TIF_NEED_RESCHED, %cl
20924 jnz work_resched
20925
20926 work_notifysig: # deal with pending signals and
20927 # notify-resume requests
20928 + movl %esp, %eax
20929 #ifdef CONFIG_VM86
20930 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20931 - movl %esp, %eax
20932 jne work_notifysig_v86 # returning to kernel-space or
20933 # vm86-space
20934 1:
20935 -#else
20936 - movl %esp, %eax
20937 #endif
20938 TRACE_IRQS_ON
20939 ENABLE_INTERRUPTS(CLBR_NONE)
20940 @@ -653,7 +878,7 @@ work_notifysig_v86:
20941 movl %eax, %esp
20942 jmp 1b
20943 #endif
20944 -END(work_pending)
20945 +ENDPROC(work_pending)
20946
20947 # perform syscall exit tracing
20948 ALIGN
20949 @@ -661,11 +886,14 @@ syscall_trace_entry:
20950 movl $-ENOSYS,PT_EAX(%esp)
20951 movl %esp, %eax
20952 call syscall_trace_enter
20953 +
20954 + pax_erase_kstack
20955 +
20956 /* What it returned is what we'll actually use. */
20957 cmpl $(NR_syscalls), %eax
20958 jnae syscall_call
20959 jmp syscall_exit
20960 -END(syscall_trace_entry)
20961 +ENDPROC(syscall_trace_entry)
20962
20963 # perform syscall exit tracing
20964 ALIGN
20965 @@ -678,21 +906,25 @@ syscall_exit_work:
20966 movl %esp, %eax
20967 call syscall_trace_leave
20968 jmp resume_userspace
20969 -END(syscall_exit_work)
20970 +ENDPROC(syscall_exit_work)
20971 CFI_ENDPROC
20972
20973 RING0_INT_FRAME # can't unwind into user space anyway
20974 syscall_fault:
20975 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20976 + push %ss
20977 + pop %ds
20978 +#endif
20979 ASM_CLAC
20980 GET_THREAD_INFO(%ebp)
20981 movl $-EFAULT,PT_EAX(%esp)
20982 jmp resume_userspace
20983 -END(syscall_fault)
20984 +ENDPROC(syscall_fault)
20985
20986 syscall_badsys:
20987 movl $-ENOSYS,PT_EAX(%esp)
20988 jmp resume_userspace
20989 -END(syscall_badsys)
20990 +ENDPROC(syscall_badsys)
20991 CFI_ENDPROC
20992 /*
20993 * End of kprobes section
20994 @@ -708,8 +940,15 @@ END(syscall_badsys)
20995 * normal stack and adjusts ESP with the matching offset.
20996 */
20997 /* fixup the stack */
20998 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
20999 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21000 +#ifdef CONFIG_SMP
21001 + movl PER_CPU_VAR(cpu_number), %ebx
21002 + shll $PAGE_SHIFT_asm, %ebx
21003 + addl $cpu_gdt_table, %ebx
21004 +#else
21005 + movl $cpu_gdt_table, %ebx
21006 +#endif
21007 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21008 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21009 shl $16, %eax
21010 addl %esp, %eax /* the adjusted stack pointer */
21011 pushl_cfi $__KERNEL_DS
21012 @@ -762,7 +1001,7 @@ vector=vector+1
21013 .endr
21014 2: jmp common_interrupt
21015 .endr
21016 -END(irq_entries_start)
21017 +ENDPROC(irq_entries_start)
21018
21019 .previous
21020 END(interrupt)
21021 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21022 pushl_cfi $do_coprocessor_error
21023 jmp error_code
21024 CFI_ENDPROC
21025 -END(coprocessor_error)
21026 +ENDPROC(coprocessor_error)
21027
21028 ENTRY(simd_coprocessor_error)
21029 RING0_INT_FRAME
21030 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21031 .section .altinstructions,"a"
21032 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21033 .previous
21034 -.section .altinstr_replacement,"ax"
21035 +.section .altinstr_replacement,"a"
21036 663: pushl $do_simd_coprocessor_error
21037 664:
21038 .previous
21039 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21040 #endif
21041 jmp error_code
21042 CFI_ENDPROC
21043 -END(simd_coprocessor_error)
21044 +ENDPROC(simd_coprocessor_error)
21045
21046 ENTRY(device_not_available)
21047 RING0_INT_FRAME
21048 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21049 pushl_cfi $do_device_not_available
21050 jmp error_code
21051 CFI_ENDPROC
21052 -END(device_not_available)
21053 +ENDPROC(device_not_available)
21054
21055 #ifdef CONFIG_PARAVIRT
21056 ENTRY(native_iret)
21057 iret
21058 _ASM_EXTABLE(native_iret, iret_exc)
21059 -END(native_iret)
21060 +ENDPROC(native_iret)
21061
21062 ENTRY(native_irq_enable_sysexit)
21063 sti
21064 sysexit
21065 -END(native_irq_enable_sysexit)
21066 +ENDPROC(native_irq_enable_sysexit)
21067 #endif
21068
21069 ENTRY(overflow)
21070 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21071 pushl_cfi $do_overflow
21072 jmp error_code
21073 CFI_ENDPROC
21074 -END(overflow)
21075 +ENDPROC(overflow)
21076
21077 ENTRY(bounds)
21078 RING0_INT_FRAME
21079 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21080 pushl_cfi $do_bounds
21081 jmp error_code
21082 CFI_ENDPROC
21083 -END(bounds)
21084 +ENDPROC(bounds)
21085
21086 ENTRY(invalid_op)
21087 RING0_INT_FRAME
21088 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21089 pushl_cfi $do_invalid_op
21090 jmp error_code
21091 CFI_ENDPROC
21092 -END(invalid_op)
21093 +ENDPROC(invalid_op)
21094
21095 ENTRY(coprocessor_segment_overrun)
21096 RING0_INT_FRAME
21097 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21098 pushl_cfi $do_coprocessor_segment_overrun
21099 jmp error_code
21100 CFI_ENDPROC
21101 -END(coprocessor_segment_overrun)
21102 +ENDPROC(coprocessor_segment_overrun)
21103
21104 ENTRY(invalid_TSS)
21105 RING0_EC_FRAME
21106 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21107 pushl_cfi $do_invalid_TSS
21108 jmp error_code
21109 CFI_ENDPROC
21110 -END(invalid_TSS)
21111 +ENDPROC(invalid_TSS)
21112
21113 ENTRY(segment_not_present)
21114 RING0_EC_FRAME
21115 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21116 pushl_cfi $do_segment_not_present
21117 jmp error_code
21118 CFI_ENDPROC
21119 -END(segment_not_present)
21120 +ENDPROC(segment_not_present)
21121
21122 ENTRY(stack_segment)
21123 RING0_EC_FRAME
21124 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21125 pushl_cfi $do_stack_segment
21126 jmp error_code
21127 CFI_ENDPROC
21128 -END(stack_segment)
21129 +ENDPROC(stack_segment)
21130
21131 ENTRY(alignment_check)
21132 RING0_EC_FRAME
21133 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21134 pushl_cfi $do_alignment_check
21135 jmp error_code
21136 CFI_ENDPROC
21137 -END(alignment_check)
21138 +ENDPROC(alignment_check)
21139
21140 ENTRY(divide_error)
21141 RING0_INT_FRAME
21142 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21143 pushl_cfi $do_divide_error
21144 jmp error_code
21145 CFI_ENDPROC
21146 -END(divide_error)
21147 +ENDPROC(divide_error)
21148
21149 #ifdef CONFIG_X86_MCE
21150 ENTRY(machine_check)
21151 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21152 pushl_cfi machine_check_vector
21153 jmp error_code
21154 CFI_ENDPROC
21155 -END(machine_check)
21156 +ENDPROC(machine_check)
21157 #endif
21158
21159 ENTRY(spurious_interrupt_bug)
21160 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21161 pushl_cfi $do_spurious_interrupt_bug
21162 jmp error_code
21163 CFI_ENDPROC
21164 -END(spurious_interrupt_bug)
21165 +ENDPROC(spurious_interrupt_bug)
21166 /*
21167 * End of kprobes section
21168 */
21169 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21170
21171 ENTRY(mcount)
21172 ret
21173 -END(mcount)
21174 +ENDPROC(mcount)
21175
21176 ENTRY(ftrace_caller)
21177 cmpl $0, function_trace_stop
21178 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21179 .globl ftrace_stub
21180 ftrace_stub:
21181 ret
21182 -END(ftrace_caller)
21183 +ENDPROC(ftrace_caller)
21184
21185 ENTRY(ftrace_regs_caller)
21186 pushf /* push flags before compare (in cs location) */
21187 @@ -1207,7 +1446,7 @@ trace:
21188 popl %ecx
21189 popl %eax
21190 jmp ftrace_stub
21191 -END(mcount)
21192 +ENDPROC(mcount)
21193 #endif /* CONFIG_DYNAMIC_FTRACE */
21194 #endif /* CONFIG_FUNCTION_TRACER */
21195
21196 @@ -1225,7 +1464,7 @@ ENTRY(ftrace_graph_caller)
21197 popl %ecx
21198 popl %eax
21199 ret
21200 -END(ftrace_graph_caller)
21201 +ENDPROC(ftrace_graph_caller)
21202
21203 .globl return_to_handler
21204 return_to_handler:
21205 @@ -1281,15 +1520,18 @@ error_code:
21206 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21207 REG_TO_PTGS %ecx
21208 SET_KERNEL_GS %ecx
21209 - movl $(__USER_DS), %ecx
21210 + movl $(__KERNEL_DS), %ecx
21211 movl %ecx, %ds
21212 movl %ecx, %es
21213 +
21214 + pax_enter_kernel
21215 +
21216 TRACE_IRQS_OFF
21217 movl %esp,%eax # pt_regs pointer
21218 call *%edi
21219 jmp ret_from_exception
21220 CFI_ENDPROC
21221 -END(page_fault)
21222 +ENDPROC(page_fault)
21223
21224 /*
21225 * Debug traps and NMI can happen at the one SYSENTER instruction
21226 @@ -1332,7 +1574,7 @@ debug_stack_correct:
21227 call do_debug
21228 jmp ret_from_exception
21229 CFI_ENDPROC
21230 -END(debug)
21231 +ENDPROC(debug)
21232
21233 /*
21234 * NMI is doubly nasty. It can happen _while_ we're handling
21235 @@ -1370,6 +1612,9 @@ nmi_stack_correct:
21236 xorl %edx,%edx # zero error code
21237 movl %esp,%eax # pt_regs pointer
21238 call do_nmi
21239 +
21240 + pax_exit_kernel
21241 +
21242 jmp restore_all_notrace
21243 CFI_ENDPROC
21244
21245 @@ -1406,12 +1651,15 @@ nmi_espfix_stack:
21246 FIXUP_ESPFIX_STACK # %eax == %esp
21247 xorl %edx,%edx # zero error code
21248 call do_nmi
21249 +
21250 + pax_exit_kernel
21251 +
21252 RESTORE_REGS
21253 lss 12+4(%esp), %esp # back to espfix stack
21254 CFI_ADJUST_CFA_OFFSET -24
21255 jmp irq_return
21256 CFI_ENDPROC
21257 -END(nmi)
21258 +ENDPROC(nmi)
21259
21260 ENTRY(int3)
21261 RING0_INT_FRAME
21262 @@ -1424,14 +1672,14 @@ ENTRY(int3)
21263 call do_int3
21264 jmp ret_from_exception
21265 CFI_ENDPROC
21266 -END(int3)
21267 +ENDPROC(int3)
21268
21269 ENTRY(general_protection)
21270 RING0_EC_FRAME
21271 pushl_cfi $do_general_protection
21272 jmp error_code
21273 CFI_ENDPROC
21274 -END(general_protection)
21275 +ENDPROC(general_protection)
21276
21277 #ifdef CONFIG_KVM_GUEST
21278 ENTRY(async_page_fault)
21279 @@ -1440,7 +1688,7 @@ ENTRY(async_page_fault)
21280 pushl_cfi $do_async_page_fault
21281 jmp error_code
21282 CFI_ENDPROC
21283 -END(async_page_fault)
21284 +ENDPROC(async_page_fault)
21285 #endif
21286
21287 /*
21288 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21289 index 1b69951..8430a6d 100644
21290 --- a/arch/x86/kernel/entry_64.S
21291 +++ b/arch/x86/kernel/entry_64.S
21292 @@ -59,6 +59,8 @@
21293 #include <asm/context_tracking.h>
21294 #include <asm/smap.h>
21295 #include <linux/err.h>
21296 +#include <asm/pgtable.h>
21297 +#include <asm/alternative-asm.h>
21298
21299 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21300 #include <linux/elf-em.h>
21301 @@ -80,8 +82,9 @@
21302 #ifdef CONFIG_DYNAMIC_FTRACE
21303
21304 ENTRY(function_hook)
21305 + pax_force_retaddr
21306 retq
21307 -END(function_hook)
21308 +ENDPROC(function_hook)
21309
21310 /* skip is set if stack has been adjusted */
21311 .macro ftrace_caller_setup skip=0
21312 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21313 #endif
21314
21315 GLOBAL(ftrace_stub)
21316 + pax_force_retaddr
21317 retq
21318 -END(ftrace_caller)
21319 +ENDPROC(ftrace_caller)
21320
21321 ENTRY(ftrace_regs_caller)
21322 /* Save the current flags before compare (in SS location)*/
21323 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21324 popfq
21325 jmp ftrace_stub
21326
21327 -END(ftrace_regs_caller)
21328 +ENDPROC(ftrace_regs_caller)
21329
21330
21331 #else /* ! CONFIG_DYNAMIC_FTRACE */
21332 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21333 #endif
21334
21335 GLOBAL(ftrace_stub)
21336 + pax_force_retaddr
21337 retq
21338
21339 trace:
21340 @@ -225,12 +230,13 @@ trace:
21341 #endif
21342 subq $MCOUNT_INSN_SIZE, %rdi
21343
21344 + pax_force_fptr ftrace_trace_function
21345 call *ftrace_trace_function
21346
21347 MCOUNT_RESTORE_FRAME
21348
21349 jmp ftrace_stub
21350 -END(function_hook)
21351 +ENDPROC(function_hook)
21352 #endif /* CONFIG_DYNAMIC_FTRACE */
21353 #endif /* CONFIG_FUNCTION_TRACER */
21354
21355 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21356
21357 MCOUNT_RESTORE_FRAME
21358
21359 + pax_force_retaddr
21360 retq
21361 -END(ftrace_graph_caller)
21362 +ENDPROC(ftrace_graph_caller)
21363
21364 GLOBAL(return_to_handler)
21365 subq $24, %rsp
21366 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21367 movq 8(%rsp), %rdx
21368 movq (%rsp), %rax
21369 addq $24, %rsp
21370 + pax_force_fptr %rdi
21371 jmp *%rdi
21372 +ENDPROC(return_to_handler)
21373 #endif
21374
21375
21376 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21377 ENDPROC(native_usergs_sysret64)
21378 #endif /* CONFIG_PARAVIRT */
21379
21380 + .macro ljmpq sel, off
21381 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21382 + .byte 0x48; ljmp *1234f(%rip)
21383 + .pushsection .rodata
21384 + .align 16
21385 + 1234: .quad \off; .word \sel
21386 + .popsection
21387 +#else
21388 + pushq $\sel
21389 + pushq $\off
21390 + lretq
21391 +#endif
21392 + .endm
21393 +
21394 + .macro pax_enter_kernel
21395 + pax_set_fptr_mask
21396 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21397 + call pax_enter_kernel
21398 +#endif
21399 + .endm
21400 +
21401 + .macro pax_exit_kernel
21402 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21403 + call pax_exit_kernel
21404 +#endif
21405 +
21406 + .endm
21407 +
21408 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21409 +ENTRY(pax_enter_kernel)
21410 + pushq %rdi
21411 +
21412 +#ifdef CONFIG_PARAVIRT
21413 + PV_SAVE_REGS(CLBR_RDI)
21414 +#endif
21415 +
21416 +#ifdef CONFIG_PAX_KERNEXEC
21417 + GET_CR0_INTO_RDI
21418 + bts $16,%rdi
21419 + jnc 3f
21420 + mov %cs,%edi
21421 + cmp $__KERNEL_CS,%edi
21422 + jnz 2f
21423 +1:
21424 +#endif
21425 +
21426 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21427 + 661: jmp 111f
21428 + .pushsection .altinstr_replacement, "a"
21429 + 662: ASM_NOP2
21430 + .popsection
21431 + .pushsection .altinstructions, "a"
21432 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21433 + .popsection
21434 + GET_CR3_INTO_RDI
21435 + cmp $0,%dil
21436 + jnz 112f
21437 + mov $__KERNEL_DS,%edi
21438 + mov %edi,%ss
21439 + jmp 111f
21440 +112: cmp $1,%dil
21441 + jz 113f
21442 + ud2
21443 +113: sub $4097,%rdi
21444 + bts $63,%rdi
21445 + SET_RDI_INTO_CR3
21446 + mov $__UDEREF_KERNEL_DS,%edi
21447 + mov %edi,%ss
21448 +111:
21449 +#endif
21450 +
21451 +#ifdef CONFIG_PARAVIRT
21452 + PV_RESTORE_REGS(CLBR_RDI)
21453 +#endif
21454 +
21455 + popq %rdi
21456 + pax_force_retaddr
21457 + retq
21458 +
21459 +#ifdef CONFIG_PAX_KERNEXEC
21460 +2: ljmpq __KERNEL_CS,1b
21461 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21462 +4: SET_RDI_INTO_CR0
21463 + jmp 1b
21464 +#endif
21465 +ENDPROC(pax_enter_kernel)
21466 +
21467 +ENTRY(pax_exit_kernel)
21468 + pushq %rdi
21469 +
21470 +#ifdef CONFIG_PARAVIRT
21471 + PV_SAVE_REGS(CLBR_RDI)
21472 +#endif
21473 +
21474 +#ifdef CONFIG_PAX_KERNEXEC
21475 + mov %cs,%rdi
21476 + cmp $__KERNEXEC_KERNEL_CS,%edi
21477 + jz 2f
21478 + GET_CR0_INTO_RDI
21479 + bts $16,%rdi
21480 + jnc 4f
21481 +1:
21482 +#endif
21483 +
21484 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21485 + 661: jmp 111f
21486 + .pushsection .altinstr_replacement, "a"
21487 + 662: ASM_NOP2
21488 + .popsection
21489 + .pushsection .altinstructions, "a"
21490 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21491 + .popsection
21492 + mov %ss,%edi
21493 + cmp $__UDEREF_KERNEL_DS,%edi
21494 + jnz 111f
21495 + GET_CR3_INTO_RDI
21496 + cmp $0,%dil
21497 + jz 112f
21498 + ud2
21499 +112: add $4097,%rdi
21500 + bts $63,%rdi
21501 + SET_RDI_INTO_CR3
21502 + mov $__KERNEL_DS,%edi
21503 + mov %edi,%ss
21504 +111:
21505 +#endif
21506 +
21507 +#ifdef CONFIG_PARAVIRT
21508 + PV_RESTORE_REGS(CLBR_RDI);
21509 +#endif
21510 +
21511 + popq %rdi
21512 + pax_force_retaddr
21513 + retq
21514 +
21515 +#ifdef CONFIG_PAX_KERNEXEC
21516 +2: GET_CR0_INTO_RDI
21517 + btr $16,%rdi
21518 + jnc 4f
21519 + ljmpq __KERNEL_CS,3f
21520 +3: SET_RDI_INTO_CR0
21521 + jmp 1b
21522 +4: ud2
21523 + jmp 4b
21524 +#endif
21525 +ENDPROC(pax_exit_kernel)
21526 +#endif
21527 +
21528 + .macro pax_enter_kernel_user
21529 + pax_set_fptr_mask
21530 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21531 + call pax_enter_kernel_user
21532 +#endif
21533 + .endm
21534 +
21535 + .macro pax_exit_kernel_user
21536 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21537 + call pax_exit_kernel_user
21538 +#endif
21539 +#ifdef CONFIG_PAX_RANDKSTACK
21540 + pushq %rax
21541 + pushq %r11
21542 + call pax_randomize_kstack
21543 + popq %r11
21544 + popq %rax
21545 +#endif
21546 + .endm
21547 +
21548 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21549 +ENTRY(pax_enter_kernel_user)
21550 + pushq %rdi
21551 + pushq %rbx
21552 +
21553 +#ifdef CONFIG_PARAVIRT
21554 + PV_SAVE_REGS(CLBR_RDI)
21555 +#endif
21556 +
21557 + 661: jmp 111f
21558 + .pushsection .altinstr_replacement, "a"
21559 + 662: ASM_NOP2
21560 + .popsection
21561 + .pushsection .altinstructions, "a"
21562 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21563 + .popsection
21564 + GET_CR3_INTO_RDI
21565 + cmp $1,%dil
21566 + jnz 4f
21567 + sub $4097,%rdi
21568 + bts $63,%rdi
21569 + SET_RDI_INTO_CR3
21570 + jmp 3f
21571 +111:
21572 +
21573 + GET_CR3_INTO_RDI
21574 + mov %rdi,%rbx
21575 + add $__START_KERNEL_map,%rbx
21576 + sub phys_base(%rip),%rbx
21577 +
21578 +#ifdef CONFIG_PARAVIRT
21579 + cmpl $0, pv_info+PARAVIRT_enabled
21580 + jz 1f
21581 + pushq %rdi
21582 + i = 0
21583 + .rept USER_PGD_PTRS
21584 + mov i*8(%rbx),%rsi
21585 + mov $0,%sil
21586 + lea i*8(%rbx),%rdi
21587 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21588 + i = i + 1
21589 + .endr
21590 + popq %rdi
21591 + jmp 2f
21592 +1:
21593 +#endif
21594 +
21595 + i = 0
21596 + .rept USER_PGD_PTRS
21597 + movb $0,i*8(%rbx)
21598 + i = i + 1
21599 + .endr
21600 +
21601 +2: SET_RDI_INTO_CR3
21602 +
21603 +#ifdef CONFIG_PAX_KERNEXEC
21604 + GET_CR0_INTO_RDI
21605 + bts $16,%rdi
21606 + SET_RDI_INTO_CR0
21607 +#endif
21608 +
21609 +3:
21610 +
21611 +#ifdef CONFIG_PARAVIRT
21612 + PV_RESTORE_REGS(CLBR_RDI)
21613 +#endif
21614 +
21615 + popq %rbx
21616 + popq %rdi
21617 + pax_force_retaddr
21618 + retq
21619 +4: ud2
21620 +ENDPROC(pax_enter_kernel_user)
21621 +
21622 +ENTRY(pax_exit_kernel_user)
21623 + pushq %rdi
21624 + pushq %rbx
21625 +
21626 +#ifdef CONFIG_PARAVIRT
21627 + PV_SAVE_REGS(CLBR_RDI)
21628 +#endif
21629 +
21630 + GET_CR3_INTO_RDI
21631 + 661: jmp 1f
21632 + .pushsection .altinstr_replacement, "a"
21633 + 662: ASM_NOP2
21634 + .popsection
21635 + .pushsection .altinstructions, "a"
21636 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21637 + .popsection
21638 + cmp $0,%dil
21639 + jnz 3f
21640 + add $4097,%rdi
21641 + bts $63,%rdi
21642 + SET_RDI_INTO_CR3
21643 + jmp 2f
21644 +1:
21645 +
21646 + mov %rdi,%rbx
21647 +
21648 +#ifdef CONFIG_PAX_KERNEXEC
21649 + GET_CR0_INTO_RDI
21650 + btr $16,%rdi
21651 + jnc 3f
21652 + SET_RDI_INTO_CR0
21653 +#endif
21654 +
21655 + add $__START_KERNEL_map,%rbx
21656 + sub phys_base(%rip),%rbx
21657 +
21658 +#ifdef CONFIG_PARAVIRT
21659 + cmpl $0, pv_info+PARAVIRT_enabled
21660 + jz 1f
21661 + i = 0
21662 + .rept USER_PGD_PTRS
21663 + mov i*8(%rbx),%rsi
21664 + mov $0x67,%sil
21665 + lea i*8(%rbx),%rdi
21666 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21667 + i = i + 1
21668 + .endr
21669 + jmp 2f
21670 +1:
21671 +#endif
21672 +
21673 + i = 0
21674 + .rept USER_PGD_PTRS
21675 + movb $0x67,i*8(%rbx)
21676 + i = i + 1
21677 + .endr
21678 +2:
21679 +
21680 +#ifdef CONFIG_PARAVIRT
21681 + PV_RESTORE_REGS(CLBR_RDI)
21682 +#endif
21683 +
21684 + popq %rbx
21685 + popq %rdi
21686 + pax_force_retaddr
21687 + retq
21688 +3: ud2
21689 +ENDPROC(pax_exit_kernel_user)
21690 +#endif
21691 +
21692 + .macro pax_enter_kernel_nmi
21693 + pax_set_fptr_mask
21694 +
21695 +#ifdef CONFIG_PAX_KERNEXEC
21696 + GET_CR0_INTO_RDI
21697 + bts $16,%rdi
21698 + jc 110f
21699 + SET_RDI_INTO_CR0
21700 + or $2,%ebx
21701 +110:
21702 +#endif
21703 +
21704 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21705 + 661: jmp 111f
21706 + .pushsection .altinstr_replacement, "a"
21707 + 662: ASM_NOP2
21708 + .popsection
21709 + .pushsection .altinstructions, "a"
21710 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21711 + .popsection
21712 + GET_CR3_INTO_RDI
21713 + cmp $0,%dil
21714 + jz 111f
21715 + sub $4097,%rdi
21716 + or $4,%ebx
21717 + bts $63,%rdi
21718 + SET_RDI_INTO_CR3
21719 + mov $__UDEREF_KERNEL_DS,%edi
21720 + mov %edi,%ss
21721 +111:
21722 +#endif
21723 + .endm
21724 +
21725 + .macro pax_exit_kernel_nmi
21726 +#ifdef CONFIG_PAX_KERNEXEC
21727 + btr $1,%ebx
21728 + jnc 110f
21729 + GET_CR0_INTO_RDI
21730 + btr $16,%rdi
21731 + SET_RDI_INTO_CR0
21732 +110:
21733 +#endif
21734 +
21735 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21736 + btr $2,%ebx
21737 + jnc 111f
21738 + GET_CR3_INTO_RDI
21739 + add $4097,%rdi
21740 + bts $63,%rdi
21741 + SET_RDI_INTO_CR3
21742 + mov $__KERNEL_DS,%edi
21743 + mov %edi,%ss
21744 +111:
21745 +#endif
21746 + .endm
21747 +
21748 + .macro pax_erase_kstack
21749 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21750 + call pax_erase_kstack
21751 +#endif
21752 + .endm
21753 +
21754 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21755 +ENTRY(pax_erase_kstack)
21756 + pushq %rdi
21757 + pushq %rcx
21758 + pushq %rax
21759 + pushq %r11
21760 +
21761 + GET_THREAD_INFO(%r11)
21762 + mov TI_lowest_stack(%r11), %rdi
21763 + mov $-0xBEEF, %rax
21764 + std
21765 +
21766 +1: mov %edi, %ecx
21767 + and $THREAD_SIZE_asm - 1, %ecx
21768 + shr $3, %ecx
21769 + repne scasq
21770 + jecxz 2f
21771 +
21772 + cmp $2*8, %ecx
21773 + jc 2f
21774 +
21775 + mov $2*8, %ecx
21776 + repe scasq
21777 + jecxz 2f
21778 + jne 1b
21779 +
21780 +2: cld
21781 + mov %esp, %ecx
21782 + sub %edi, %ecx
21783 +
21784 + cmp $THREAD_SIZE_asm, %rcx
21785 + jb 3f
21786 + ud2
21787 +3:
21788 +
21789 + shr $3, %ecx
21790 + rep stosq
21791 +
21792 + mov TI_task_thread_sp0(%r11), %rdi
21793 + sub $256, %rdi
21794 + mov %rdi, TI_lowest_stack(%r11)
21795 +
21796 + popq %r11
21797 + popq %rax
21798 + popq %rcx
21799 + popq %rdi
21800 + pax_force_retaddr
21801 + ret
21802 +ENDPROC(pax_erase_kstack)
21803 +#endif
21804
21805 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21806 #ifdef CONFIG_TRACE_IRQFLAGS
21807 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21808 .endm
21809
21810 .macro UNFAKE_STACK_FRAME
21811 - addq $8*6, %rsp
21812 - CFI_ADJUST_CFA_OFFSET -(6*8)
21813 + addq $8*6 + ARG_SKIP, %rsp
21814 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21815 .endm
21816
21817 /*
21818 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21819 movq %rsp, %rsi
21820
21821 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21822 - testl $3, CS-RBP(%rsi)
21823 + testb $3, CS-RBP(%rsi)
21824 je 1f
21825 SWAPGS
21826 /*
21827 @@ -498,9 +931,10 @@ ENTRY(save_rest)
21828 movq_cfi r15, R15+16
21829 movq %r11, 8(%rsp) /* return address */
21830 FIXUP_TOP_OF_STACK %r11, 16
21831 + pax_force_retaddr
21832 ret
21833 CFI_ENDPROC
21834 -END(save_rest)
21835 +ENDPROC(save_rest)
21836
21837 /* save complete stack frame */
21838 .pushsection .kprobes.text, "ax"
21839 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
21840 js 1f /* negative -> in kernel */
21841 SWAPGS
21842 xorl %ebx,%ebx
21843 -1: ret
21844 +1: pax_force_retaddr_bts
21845 + ret
21846 CFI_ENDPROC
21847 -END(save_paranoid)
21848 +ENDPROC(save_paranoid)
21849 .popsection
21850
21851 /*
21852 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
21853
21854 RESTORE_REST
21855
21856 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21857 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21858 jz 1f
21859
21860 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21861 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
21862 RESTORE_REST
21863 jmp int_ret_from_sys_call
21864 CFI_ENDPROC
21865 -END(ret_from_fork)
21866 +ENDPROC(ret_from_fork)
21867
21868 /*
21869 * System call entry. Up to 6 arguments in registers are supported.
21870 @@ -608,7 +1043,7 @@ END(ret_from_fork)
21871 ENTRY(system_call)
21872 CFI_STARTPROC simple
21873 CFI_SIGNAL_FRAME
21874 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21875 + CFI_DEF_CFA rsp,0
21876 CFI_REGISTER rip,rcx
21877 /*CFI_REGISTER rflags,r11*/
21878 SWAPGS_UNSAFE_STACK
21879 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
21880
21881 movq %rsp,PER_CPU_VAR(old_rsp)
21882 movq PER_CPU_VAR(kernel_stack),%rsp
21883 + SAVE_ARGS 8*6,0
21884 + pax_enter_kernel_user
21885 +
21886 +#ifdef CONFIG_PAX_RANDKSTACK
21887 + pax_erase_kstack
21888 +#endif
21889 +
21890 /*
21891 * No need to follow this irqs off/on section - it's straight
21892 * and short:
21893 */
21894 ENABLE_INTERRUPTS(CLBR_NONE)
21895 - SAVE_ARGS 8,0
21896 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21897 movq %rcx,RIP-ARGOFFSET(%rsp)
21898 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21899 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21900 + GET_THREAD_INFO(%rcx)
21901 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21902 jnz tracesys
21903 system_call_fastpath:
21904 #if __SYSCALL_MASK == ~0
21905 @@ -640,7 +1082,7 @@ system_call_fastpath:
21906 cmpl $__NR_syscall_max,%eax
21907 #endif
21908 ja badsys
21909 - movq %r10,%rcx
21910 + movq R10-ARGOFFSET(%rsp),%rcx
21911 call *sys_call_table(,%rax,8) # XXX: rip relative
21912 movq %rax,RAX-ARGOFFSET(%rsp)
21913 /*
21914 @@ -654,10 +1096,13 @@ sysret_check:
21915 LOCKDEP_SYS_EXIT
21916 DISABLE_INTERRUPTS(CLBR_NONE)
21917 TRACE_IRQS_OFF
21918 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21919 + GET_THREAD_INFO(%rcx)
21920 + movl TI_flags(%rcx),%edx
21921 andl %edi,%edx
21922 jnz sysret_careful
21923 CFI_REMEMBER_STATE
21924 + pax_exit_kernel_user
21925 + pax_erase_kstack
21926 /*
21927 * sysretq will re-enable interrupts:
21928 */
21929 @@ -709,14 +1154,18 @@ badsys:
21930 * jump back to the normal fast path.
21931 */
21932 auditsys:
21933 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21934 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21935 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21936 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21937 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21938 movq %rax,%rsi /* 2nd arg: syscall number */
21939 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21940 call __audit_syscall_entry
21941 +
21942 + pax_erase_kstack
21943 +
21944 LOAD_ARGS 0 /* reload call-clobbered registers */
21945 + pax_set_fptr_mask
21946 jmp system_call_fastpath
21947
21948 /*
21949 @@ -737,7 +1186,7 @@ sysret_audit:
21950 /* Do syscall tracing */
21951 tracesys:
21952 #ifdef CONFIG_AUDITSYSCALL
21953 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21954 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21955 jz auditsys
21956 #endif
21957 SAVE_REST
21958 @@ -745,12 +1194,16 @@ tracesys:
21959 FIXUP_TOP_OF_STACK %rdi
21960 movq %rsp,%rdi
21961 call syscall_trace_enter
21962 +
21963 + pax_erase_kstack
21964 +
21965 /*
21966 * Reload arg registers from stack in case ptrace changed them.
21967 * We don't reload %rax because syscall_trace_enter() returned
21968 * the value it wants us to use in the table lookup.
21969 */
21970 LOAD_ARGS ARGOFFSET, 1
21971 + pax_set_fptr_mask
21972 RESTORE_REST
21973 #if __SYSCALL_MASK == ~0
21974 cmpq $__NR_syscall_max,%rax
21975 @@ -759,7 +1212,7 @@ tracesys:
21976 cmpl $__NR_syscall_max,%eax
21977 #endif
21978 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21979 - movq %r10,%rcx /* fixup for C */
21980 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21981 call *sys_call_table(,%rax,8)
21982 movq %rax,RAX-ARGOFFSET(%rsp)
21983 /* Use IRET because user could have changed frame */
21984 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
21985 andl %edi,%edx
21986 jnz int_careful
21987 andl $~TS_COMPAT,TI_status(%rcx)
21988 - jmp retint_swapgs
21989 + pax_exit_kernel_user
21990 + pax_erase_kstack
21991 + jmp retint_swapgs_pax
21992
21993 /* Either reschedule or signal or syscall exit tracking needed. */
21994 /* First do a reschedule test. */
21995 @@ -826,7 +1281,7 @@ int_restore_rest:
21996 TRACE_IRQS_OFF
21997 jmp int_with_check
21998 CFI_ENDPROC
21999 -END(system_call)
22000 +ENDPROC(system_call)
22001
22002 .macro FORK_LIKE func
22003 ENTRY(stub_\func)
22004 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
22005 DEFAULT_FRAME 0 8 /* offset 8: return address */
22006 call sys_\func
22007 RESTORE_TOP_OF_STACK %r11, 8
22008 + pax_force_retaddr
22009 ret $REST_SKIP /* pop extended registers */
22010 CFI_ENDPROC
22011 -END(stub_\func)
22012 +ENDPROC(stub_\func)
22013 .endm
22014
22015 .macro FIXED_FRAME label,func
22016 @@ -851,9 +1307,10 @@ ENTRY(\label)
22017 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22018 call \func
22019 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22020 + pax_force_retaddr
22021 ret
22022 CFI_ENDPROC
22023 -END(\label)
22024 +ENDPROC(\label)
22025 .endm
22026
22027 FORK_LIKE clone
22028 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
22029 movq_cfi_restore R12+8, r12
22030 movq_cfi_restore RBP+8, rbp
22031 movq_cfi_restore RBX+8, rbx
22032 + pax_force_retaddr
22033 ret $REST_SKIP /* pop extended registers */
22034 CFI_ENDPROC
22035 -END(ptregscall_common)
22036 +ENDPROC(ptregscall_common)
22037
22038 ENTRY(stub_execve)
22039 CFI_STARTPROC
22040 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
22041 RESTORE_REST
22042 jmp int_ret_from_sys_call
22043 CFI_ENDPROC
22044 -END(stub_execve)
22045 +ENDPROC(stub_execve)
22046
22047 /*
22048 * sigreturn is special because it needs to restore all registers on return.
22049 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
22050 RESTORE_REST
22051 jmp int_ret_from_sys_call
22052 CFI_ENDPROC
22053 -END(stub_rt_sigreturn)
22054 +ENDPROC(stub_rt_sigreturn)
22055
22056 #ifdef CONFIG_X86_X32_ABI
22057 ENTRY(stub_x32_rt_sigreturn)
22058 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
22059 RESTORE_REST
22060 jmp int_ret_from_sys_call
22061 CFI_ENDPROC
22062 -END(stub_x32_rt_sigreturn)
22063 +ENDPROC(stub_x32_rt_sigreturn)
22064
22065 ENTRY(stub_x32_execve)
22066 CFI_STARTPROC
22067 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
22068 RESTORE_REST
22069 jmp int_ret_from_sys_call
22070 CFI_ENDPROC
22071 -END(stub_x32_execve)
22072 +ENDPROC(stub_x32_execve)
22073
22074 #endif
22075
22076 @@ -967,7 +1425,7 @@ vector=vector+1
22077 2: jmp common_interrupt
22078 .endr
22079 CFI_ENDPROC
22080 -END(irq_entries_start)
22081 +ENDPROC(irq_entries_start)
22082
22083 .previous
22084 END(interrupt)
22085 @@ -987,6 +1445,16 @@ END(interrupt)
22086 subq $ORIG_RAX-RBP, %rsp
22087 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22088 SAVE_ARGS_IRQ
22089 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22090 + testb $3, CS(%rdi)
22091 + jnz 1f
22092 + pax_enter_kernel
22093 + jmp 2f
22094 +1: pax_enter_kernel_user
22095 +2:
22096 +#else
22097 + pax_enter_kernel
22098 +#endif
22099 call \func
22100 .endm
22101
22102 @@ -1019,7 +1487,7 @@ ret_from_intr:
22103
22104 exit_intr:
22105 GET_THREAD_INFO(%rcx)
22106 - testl $3,CS-ARGOFFSET(%rsp)
22107 + testb $3,CS-ARGOFFSET(%rsp)
22108 je retint_kernel
22109
22110 /* Interrupt came from user space */
22111 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
22112 * The iretq could re-enable interrupts:
22113 */
22114 DISABLE_INTERRUPTS(CLBR_ANY)
22115 + pax_exit_kernel_user
22116 +retint_swapgs_pax:
22117 TRACE_IRQS_IRETQ
22118 SWAPGS
22119 jmp restore_args
22120
22121 retint_restore_args: /* return to kernel space */
22122 DISABLE_INTERRUPTS(CLBR_ANY)
22123 + pax_exit_kernel
22124 + pax_force_retaddr (RIP-ARGOFFSET)
22125 /*
22126 * The iretq could re-enable interrupts:
22127 */
22128 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
22129 #endif
22130
22131 CFI_ENDPROC
22132 -END(common_interrupt)
22133 +ENDPROC(common_interrupt)
22134 /*
22135 * End of kprobes section
22136 */
22137 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
22138 interrupt \do_sym
22139 jmp ret_from_intr
22140 CFI_ENDPROC
22141 -END(\sym)
22142 +ENDPROC(\sym)
22143 .endm
22144
22145 #ifdef CONFIG_TRACING
22146 @@ -1230,12 +1702,22 @@ ENTRY(\sym)
22147 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22148 call error_entry
22149 DEFAULT_FRAME 0
22150 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22151 + testb $3, CS(%rsp)
22152 + jnz 1f
22153 + pax_enter_kernel
22154 + jmp 2f
22155 +1: pax_enter_kernel_user
22156 +2:
22157 +#else
22158 + pax_enter_kernel
22159 +#endif
22160 movq %rsp,%rdi /* pt_regs pointer */
22161 xorl %esi,%esi /* no error code */
22162 call \do_sym
22163 jmp error_exit /* %ebx: no swapgs flag */
22164 CFI_ENDPROC
22165 -END(\sym)
22166 +ENDPROC(\sym)
22167 .endm
22168
22169 .macro paranoidzeroentry sym do_sym
22170 @@ -1248,15 +1730,25 @@ ENTRY(\sym)
22171 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22172 call save_paranoid
22173 TRACE_IRQS_OFF
22174 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22175 + testb $3, CS(%rsp)
22176 + jnz 1f
22177 + pax_enter_kernel
22178 + jmp 2f
22179 +1: pax_enter_kernel_user
22180 +2:
22181 +#else
22182 + pax_enter_kernel
22183 +#endif
22184 movq %rsp,%rdi /* pt_regs pointer */
22185 xorl %esi,%esi /* no error code */
22186 call \do_sym
22187 jmp paranoid_exit /* %ebx: no swapgs flag */
22188 CFI_ENDPROC
22189 -END(\sym)
22190 +ENDPROC(\sym)
22191 .endm
22192
22193 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22194 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22195 .macro paranoidzeroentry_ist sym do_sym ist
22196 ENTRY(\sym)
22197 INTR_FRAME
22198 @@ -1267,14 +1759,30 @@ ENTRY(\sym)
22199 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22200 call save_paranoid
22201 TRACE_IRQS_OFF_DEBUG
22202 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22203 + testb $3, CS(%rsp)
22204 + jnz 1f
22205 + pax_enter_kernel
22206 + jmp 2f
22207 +1: pax_enter_kernel_user
22208 +2:
22209 +#else
22210 + pax_enter_kernel
22211 +#endif
22212 movq %rsp,%rdi /* pt_regs pointer */
22213 xorl %esi,%esi /* no error code */
22214 +#ifdef CONFIG_SMP
22215 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22216 + lea init_tss(%r12), %r12
22217 +#else
22218 + lea init_tss(%rip), %r12
22219 +#endif
22220 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22221 call \do_sym
22222 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22223 jmp paranoid_exit /* %ebx: no swapgs flag */
22224 CFI_ENDPROC
22225 -END(\sym)
22226 +ENDPROC(\sym)
22227 .endm
22228
22229 .macro errorentry sym do_sym
22230 @@ -1286,13 +1794,23 @@ ENTRY(\sym)
22231 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22232 call error_entry
22233 DEFAULT_FRAME 0
22234 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22235 + testb $3, CS(%rsp)
22236 + jnz 1f
22237 + pax_enter_kernel
22238 + jmp 2f
22239 +1: pax_enter_kernel_user
22240 +2:
22241 +#else
22242 + pax_enter_kernel
22243 +#endif
22244 movq %rsp,%rdi /* pt_regs pointer */
22245 movq ORIG_RAX(%rsp),%rsi /* get error code */
22246 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22247 call \do_sym
22248 jmp error_exit /* %ebx: no swapgs flag */
22249 CFI_ENDPROC
22250 -END(\sym)
22251 +ENDPROC(\sym)
22252 .endm
22253
22254 /* error code is on the stack already */
22255 @@ -1306,13 +1824,23 @@ ENTRY(\sym)
22256 call save_paranoid
22257 DEFAULT_FRAME 0
22258 TRACE_IRQS_OFF
22259 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22260 + testb $3, CS(%rsp)
22261 + jnz 1f
22262 + pax_enter_kernel
22263 + jmp 2f
22264 +1: pax_enter_kernel_user
22265 +2:
22266 +#else
22267 + pax_enter_kernel
22268 +#endif
22269 movq %rsp,%rdi /* pt_regs pointer */
22270 movq ORIG_RAX(%rsp),%rsi /* get error code */
22271 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22272 call \do_sym
22273 jmp paranoid_exit /* %ebx: no swapgs flag */
22274 CFI_ENDPROC
22275 -END(\sym)
22276 +ENDPROC(\sym)
22277 .endm
22278
22279 zeroentry divide_error do_divide_error
22280 @@ -1342,9 +1870,10 @@ gs_change:
22281 2: mfence /* workaround */
22282 SWAPGS
22283 popfq_cfi
22284 + pax_force_retaddr
22285 ret
22286 CFI_ENDPROC
22287 -END(native_load_gs_index)
22288 +ENDPROC(native_load_gs_index)
22289
22290 _ASM_EXTABLE(gs_change,bad_gs)
22291 .section .fixup,"ax"
22292 @@ -1372,9 +1901,10 @@ ENTRY(call_softirq)
22293 CFI_DEF_CFA_REGISTER rsp
22294 CFI_ADJUST_CFA_OFFSET -8
22295 decl PER_CPU_VAR(irq_count)
22296 + pax_force_retaddr
22297 ret
22298 CFI_ENDPROC
22299 -END(call_softirq)
22300 +ENDPROC(call_softirq)
22301
22302 #ifdef CONFIG_XEN
22303 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22304 @@ -1412,7 +1942,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22305 decl PER_CPU_VAR(irq_count)
22306 jmp error_exit
22307 CFI_ENDPROC
22308 -END(xen_do_hypervisor_callback)
22309 +ENDPROC(xen_do_hypervisor_callback)
22310
22311 /*
22312 * Hypervisor uses this for application faults while it executes.
22313 @@ -1471,7 +2001,7 @@ ENTRY(xen_failsafe_callback)
22314 SAVE_ALL
22315 jmp error_exit
22316 CFI_ENDPROC
22317 -END(xen_failsafe_callback)
22318 +ENDPROC(xen_failsafe_callback)
22319
22320 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22321 xen_hvm_callback_vector xen_evtchn_do_upcall
22322 @@ -1523,18 +2053,33 @@ ENTRY(paranoid_exit)
22323 DEFAULT_FRAME
22324 DISABLE_INTERRUPTS(CLBR_NONE)
22325 TRACE_IRQS_OFF_DEBUG
22326 - testl %ebx,%ebx /* swapgs needed? */
22327 + testl $1,%ebx /* swapgs needed? */
22328 jnz paranoid_restore
22329 - testl $3,CS(%rsp)
22330 + testb $3,CS(%rsp)
22331 jnz paranoid_userspace
22332 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22333 + pax_exit_kernel
22334 + TRACE_IRQS_IRETQ 0
22335 + SWAPGS_UNSAFE_STACK
22336 + RESTORE_ALL 8
22337 + pax_force_retaddr_bts
22338 + jmp irq_return
22339 +#endif
22340 paranoid_swapgs:
22341 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22342 + pax_exit_kernel_user
22343 +#else
22344 + pax_exit_kernel
22345 +#endif
22346 TRACE_IRQS_IRETQ 0
22347 SWAPGS_UNSAFE_STACK
22348 RESTORE_ALL 8
22349 jmp irq_return
22350 paranoid_restore:
22351 + pax_exit_kernel
22352 TRACE_IRQS_IRETQ_DEBUG 0
22353 RESTORE_ALL 8
22354 + pax_force_retaddr_bts
22355 jmp irq_return
22356 paranoid_userspace:
22357 GET_THREAD_INFO(%rcx)
22358 @@ -1563,7 +2108,7 @@ paranoid_schedule:
22359 TRACE_IRQS_OFF
22360 jmp paranoid_userspace
22361 CFI_ENDPROC
22362 -END(paranoid_exit)
22363 +ENDPROC(paranoid_exit)
22364
22365 /*
22366 * Exception entry point. This expects an error code/orig_rax on the stack.
22367 @@ -1590,12 +2135,13 @@ ENTRY(error_entry)
22368 movq_cfi r14, R14+8
22369 movq_cfi r15, R15+8
22370 xorl %ebx,%ebx
22371 - testl $3,CS+8(%rsp)
22372 + testb $3,CS+8(%rsp)
22373 je error_kernelspace
22374 error_swapgs:
22375 SWAPGS
22376 error_sti:
22377 TRACE_IRQS_OFF
22378 + pax_force_retaddr_bts
22379 ret
22380
22381 /*
22382 @@ -1622,7 +2168,7 @@ bstep_iret:
22383 movq %rcx,RIP+8(%rsp)
22384 jmp error_swapgs
22385 CFI_ENDPROC
22386 -END(error_entry)
22387 +ENDPROC(error_entry)
22388
22389
22390 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22391 @@ -1633,7 +2179,7 @@ ENTRY(error_exit)
22392 DISABLE_INTERRUPTS(CLBR_NONE)
22393 TRACE_IRQS_OFF
22394 GET_THREAD_INFO(%rcx)
22395 - testl %eax,%eax
22396 + testl $1,%eax
22397 jne retint_kernel
22398 LOCKDEP_SYS_EXIT_IRQ
22399 movl TI_flags(%rcx),%edx
22400 @@ -1642,7 +2188,7 @@ ENTRY(error_exit)
22401 jnz retint_careful
22402 jmp retint_swapgs
22403 CFI_ENDPROC
22404 -END(error_exit)
22405 +ENDPROC(error_exit)
22406
22407 /*
22408 * Test if a given stack is an NMI stack or not.
22409 @@ -1700,9 +2246,11 @@ ENTRY(nmi)
22410 * If %cs was not the kernel segment, then the NMI triggered in user
22411 * space, which means it is definitely not nested.
22412 */
22413 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22414 + je 1f
22415 cmpl $__KERNEL_CS, 16(%rsp)
22416 jne first_nmi
22417 -
22418 +1:
22419 /*
22420 * Check the special variable on the stack to see if NMIs are
22421 * executing.
22422 @@ -1736,8 +2284,7 @@ nested_nmi:
22423
22424 1:
22425 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22426 - leaq -1*8(%rsp), %rdx
22427 - movq %rdx, %rsp
22428 + subq $8, %rsp
22429 CFI_ADJUST_CFA_OFFSET 1*8
22430 leaq -10*8(%rsp), %rdx
22431 pushq_cfi $__KERNEL_DS
22432 @@ -1755,6 +2302,7 @@ nested_nmi_out:
22433 CFI_RESTORE rdx
22434
22435 /* No need to check faults here */
22436 +# pax_force_retaddr_bts
22437 INTERRUPT_RETURN
22438
22439 CFI_RESTORE_STATE
22440 @@ -1871,6 +2419,8 @@ end_repeat_nmi:
22441 */
22442 movq %cr2, %r12
22443
22444 + pax_enter_kernel_nmi
22445 +
22446 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22447 movq %rsp,%rdi
22448 movq $-1,%rsi
22449 @@ -1883,26 +2433,31 @@ end_repeat_nmi:
22450 movq %r12, %cr2
22451 1:
22452
22453 - testl %ebx,%ebx /* swapgs needed? */
22454 + testl $1,%ebx /* swapgs needed? */
22455 jnz nmi_restore
22456 nmi_swapgs:
22457 SWAPGS_UNSAFE_STACK
22458 nmi_restore:
22459 + pax_exit_kernel_nmi
22460 /* Pop the extra iret frame at once */
22461 RESTORE_ALL 6*8
22462 + testb $3, 8(%rsp)
22463 + jnz 1f
22464 + pax_force_retaddr_bts
22465 +1:
22466
22467 /* Clear the NMI executing stack variable */
22468 movq $0, 5*8(%rsp)
22469 jmp irq_return
22470 CFI_ENDPROC
22471 -END(nmi)
22472 +ENDPROC(nmi)
22473
22474 ENTRY(ignore_sysret)
22475 CFI_STARTPROC
22476 mov $-ENOSYS,%eax
22477 sysret
22478 CFI_ENDPROC
22479 -END(ignore_sysret)
22480 +ENDPROC(ignore_sysret)
22481
22482 /*
22483 * End of kprobes section
22484 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22485 index 42a392a..fbbd930 100644
22486 --- a/arch/x86/kernel/ftrace.c
22487 +++ b/arch/x86/kernel/ftrace.c
22488 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22489 {
22490 unsigned char replaced[MCOUNT_INSN_SIZE];
22491
22492 + ip = ktla_ktva(ip);
22493 +
22494 /*
22495 * Note: Due to modules and __init, code can
22496 * disappear and change, we need to protect against faulting
22497 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22498 unsigned char old[MCOUNT_INSN_SIZE], *new;
22499 int ret;
22500
22501 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22502 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22503 new = ftrace_call_replace(ip, (unsigned long)func);
22504
22505 /* See comment above by declaration of modifying_ftrace_code */
22506 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22507 /* Also update the regs callback function */
22508 if (!ret) {
22509 ip = (unsigned long)(&ftrace_regs_call);
22510 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22511 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22512 new = ftrace_call_replace(ip, (unsigned long)func);
22513 ret = ftrace_modify_code(ip, old, new);
22514 }
22515 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22516 * kernel identity mapping to modify code.
22517 */
22518 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22519 - ip = (unsigned long)__va(__pa_symbol(ip));
22520 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22521
22522 return probe_kernel_write((void *)ip, val, size);
22523 }
22524 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22525 unsigned char replaced[MCOUNT_INSN_SIZE];
22526 unsigned char brk = BREAKPOINT_INSTRUCTION;
22527
22528 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22529 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22530 return -EFAULT;
22531
22532 /* Make sure it is what we expect it to be */
22533 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22534 return ret;
22535
22536 fail_update:
22537 - probe_kernel_write((void *)ip, &old_code[0], 1);
22538 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22539 goto out;
22540 }
22541
22542 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22543 {
22544 unsigned char code[MCOUNT_INSN_SIZE];
22545
22546 + ip = ktla_ktva(ip);
22547 +
22548 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22549 return -EFAULT;
22550
22551 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22552 index 55b6761..a6456fc 100644
22553 --- a/arch/x86/kernel/head64.c
22554 +++ b/arch/x86/kernel/head64.c
22555 @@ -67,12 +67,12 @@ again:
22556 pgd = *pgd_p;
22557
22558 /*
22559 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22560 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22561 + * The use of __early_va rather than __va here is critical:
22562 + * __va would point us back into the dynamic
22563 * range and we might end up looping forever...
22564 */
22565 if (pgd)
22566 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22567 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22568 else {
22569 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22570 reset_early_page_tables();
22571 @@ -82,13 +82,13 @@ again:
22572 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22573 for (i = 0; i < PTRS_PER_PUD; i++)
22574 pud_p[i] = 0;
22575 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22576 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22577 }
22578 pud_p += pud_index(address);
22579 pud = *pud_p;
22580
22581 if (pud)
22582 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22583 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22584 else {
22585 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22586 reset_early_page_tables();
22587 @@ -98,7 +98,7 @@ again:
22588 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22589 for (i = 0; i < PTRS_PER_PMD; i++)
22590 pmd_p[i] = 0;
22591 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22592 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22593 }
22594 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22595 pmd_p[pmd_index(address)] = pmd;
22596 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
22597 if (console_loglevel == 10)
22598 early_printk("Kernel alive\n");
22599
22600 - clear_page(init_level4_pgt);
22601 /* set init_level4_pgt kernel high mapping*/
22602 init_level4_pgt[511] = early_level4_pgt[511];
22603
22604 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22605 index 5dd87a8..d68b3f4 100644
22606 --- a/arch/x86/kernel/head_32.S
22607 +++ b/arch/x86/kernel/head_32.S
22608 @@ -26,6 +26,12 @@
22609 /* Physical address */
22610 #define pa(X) ((X) - __PAGE_OFFSET)
22611
22612 +#ifdef CONFIG_PAX_KERNEXEC
22613 +#define ta(X) (X)
22614 +#else
22615 +#define ta(X) ((X) - __PAGE_OFFSET)
22616 +#endif
22617 +
22618 /*
22619 * References to members of the new_cpu_data structure.
22620 */
22621 @@ -55,11 +61,7 @@
22622 * and small than max_low_pfn, otherwise will waste some page table entries
22623 */
22624
22625 -#if PTRS_PER_PMD > 1
22626 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22627 -#else
22628 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22629 -#endif
22630 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22631
22632 /* Number of possible pages in the lowmem region */
22633 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22634 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22635 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22636
22637 /*
22638 + * Real beginning of normal "text" segment
22639 + */
22640 +ENTRY(stext)
22641 +ENTRY(_stext)
22642 +
22643 +/*
22644 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22645 * %esi points to the real-mode code as a 32-bit pointer.
22646 * CS and DS must be 4 GB flat segments, but we don't depend on
22647 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22648 * can.
22649 */
22650 __HEAD
22651 +
22652 +#ifdef CONFIG_PAX_KERNEXEC
22653 + jmp startup_32
22654 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22655 +.fill PAGE_SIZE-5,1,0xcc
22656 +#endif
22657 +
22658 ENTRY(startup_32)
22659 movl pa(stack_start),%ecx
22660
22661 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22662 2:
22663 leal -__PAGE_OFFSET(%ecx),%esp
22664
22665 +#ifdef CONFIG_SMP
22666 + movl $pa(cpu_gdt_table),%edi
22667 + movl $__per_cpu_load,%eax
22668 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22669 + rorl $16,%eax
22670 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22671 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22672 + movl $__per_cpu_end - 1,%eax
22673 + subl $__per_cpu_start,%eax
22674 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22675 +#endif
22676 +
22677 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22678 + movl $NR_CPUS,%ecx
22679 + movl $pa(cpu_gdt_table),%edi
22680 +1:
22681 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22682 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22683 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22684 + addl $PAGE_SIZE_asm,%edi
22685 + loop 1b
22686 +#endif
22687 +
22688 +#ifdef CONFIG_PAX_KERNEXEC
22689 + movl $pa(boot_gdt),%edi
22690 + movl $__LOAD_PHYSICAL_ADDR,%eax
22691 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22692 + rorl $16,%eax
22693 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22694 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22695 + rorl $16,%eax
22696 +
22697 + ljmp $(__BOOT_CS),$1f
22698 +1:
22699 +
22700 + movl $NR_CPUS,%ecx
22701 + movl $pa(cpu_gdt_table),%edi
22702 + addl $__PAGE_OFFSET,%eax
22703 +1:
22704 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22705 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22706 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22707 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22708 + rorl $16,%eax
22709 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22710 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22711 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22712 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22713 + rorl $16,%eax
22714 + addl $PAGE_SIZE_asm,%edi
22715 + loop 1b
22716 +#endif
22717 +
22718 /*
22719 * Clear BSS first so that there are no surprises...
22720 */
22721 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22722 movl %eax, pa(max_pfn_mapped)
22723
22724 /* Do early initialization of the fixmap area */
22725 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22726 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22727 +#ifdef CONFIG_COMPAT_VDSO
22728 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22729 +#else
22730 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22731 +#endif
22732 #else /* Not PAE */
22733
22734 page_pde_offset = (__PAGE_OFFSET >> 20);
22735 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22736 movl %eax, pa(max_pfn_mapped)
22737
22738 /* Do early initialization of the fixmap area */
22739 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22740 - movl %eax,pa(initial_page_table+0xffc)
22741 +#ifdef CONFIG_COMPAT_VDSO
22742 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22743 +#else
22744 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22745 +#endif
22746 #endif
22747
22748 #ifdef CONFIG_PARAVIRT
22749 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22750 cmpl $num_subarch_entries, %eax
22751 jae bad_subarch
22752
22753 - movl pa(subarch_entries)(,%eax,4), %eax
22754 - subl $__PAGE_OFFSET, %eax
22755 - jmp *%eax
22756 + jmp *pa(subarch_entries)(,%eax,4)
22757
22758 bad_subarch:
22759 WEAK(lguest_entry)
22760 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22761 __INITDATA
22762
22763 subarch_entries:
22764 - .long default_entry /* normal x86/PC */
22765 - .long lguest_entry /* lguest hypervisor */
22766 - .long xen_entry /* Xen hypervisor */
22767 - .long default_entry /* Moorestown MID */
22768 + .long ta(default_entry) /* normal x86/PC */
22769 + .long ta(lguest_entry) /* lguest hypervisor */
22770 + .long ta(xen_entry) /* Xen hypervisor */
22771 + .long ta(default_entry) /* Moorestown MID */
22772 num_subarch_entries = (. - subarch_entries) / 4
22773 .previous
22774 #else
22775 @@ -354,6 +426,7 @@ default_entry:
22776 movl pa(mmu_cr4_features),%eax
22777 movl %eax,%cr4
22778
22779 +#ifdef CONFIG_X86_PAE
22780 testb $X86_CR4_PAE, %al # check if PAE is enabled
22781 jz enable_paging
22782
22783 @@ -382,6 +455,9 @@ default_entry:
22784 /* Make changes effective */
22785 wrmsr
22786
22787 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22788 +#endif
22789 +
22790 enable_paging:
22791
22792 /*
22793 @@ -449,14 +525,20 @@ is486:
22794 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22795 movl %eax,%ss # after changing gdt.
22796
22797 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22798 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22799 movl %eax,%ds
22800 movl %eax,%es
22801
22802 movl $(__KERNEL_PERCPU), %eax
22803 movl %eax,%fs # set this cpu's percpu
22804
22805 +#ifdef CONFIG_CC_STACKPROTECTOR
22806 movl $(__KERNEL_STACK_CANARY),%eax
22807 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22808 + movl $(__USER_DS),%eax
22809 +#else
22810 + xorl %eax,%eax
22811 +#endif
22812 movl %eax,%gs
22813
22814 xorl %eax,%eax # Clear LDT
22815 @@ -512,8 +594,11 @@ setup_once:
22816 * relocation. Manually set base address in stack canary
22817 * segment descriptor.
22818 */
22819 - movl $gdt_page,%eax
22820 + movl $cpu_gdt_table,%eax
22821 movl $stack_canary,%ecx
22822 +#ifdef CONFIG_SMP
22823 + addl $__per_cpu_load,%ecx
22824 +#endif
22825 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22826 shrl $16, %ecx
22827 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22828 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22829 /* This is global to keep gas from relaxing the jumps */
22830 ENTRY(early_idt_handler)
22831 cld
22832 - cmpl $2,%ss:early_recursion_flag
22833 + cmpl $1,%ss:early_recursion_flag
22834 je hlt_loop
22835 incl %ss:early_recursion_flag
22836
22837 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22838 pushl (20+6*4)(%esp) /* trapno */
22839 pushl $fault_msg
22840 call printk
22841 -#endif
22842 call dump_stack
22843 +#endif
22844 hlt_loop:
22845 hlt
22846 jmp hlt_loop
22847 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22848 /* This is the default interrupt "handler" :-) */
22849 ALIGN
22850 ignore_int:
22851 - cld
22852 #ifdef CONFIG_PRINTK
22853 + cmpl $2,%ss:early_recursion_flag
22854 + je hlt_loop
22855 + incl %ss:early_recursion_flag
22856 + cld
22857 pushl %eax
22858 pushl %ecx
22859 pushl %edx
22860 @@ -612,9 +700,6 @@ ignore_int:
22861 movl $(__KERNEL_DS),%eax
22862 movl %eax,%ds
22863 movl %eax,%es
22864 - cmpl $2,early_recursion_flag
22865 - je hlt_loop
22866 - incl early_recursion_flag
22867 pushl 16(%esp)
22868 pushl 24(%esp)
22869 pushl 32(%esp)
22870 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22871 /*
22872 * BSS section
22873 */
22874 -__PAGE_ALIGNED_BSS
22875 - .align PAGE_SIZE
22876 #ifdef CONFIG_X86_PAE
22877 +.section .initial_pg_pmd,"a",@progbits
22878 initial_pg_pmd:
22879 .fill 1024*KPMDS,4,0
22880 #else
22881 +.section .initial_page_table,"a",@progbits
22882 ENTRY(initial_page_table)
22883 .fill 1024,4,0
22884 #endif
22885 +.section .initial_pg_fixmap,"a",@progbits
22886 initial_pg_fixmap:
22887 .fill 1024,4,0
22888 +.section .empty_zero_page,"a",@progbits
22889 ENTRY(empty_zero_page)
22890 .fill 4096,1,0
22891 +.section .swapper_pg_dir,"a",@progbits
22892 ENTRY(swapper_pg_dir)
22893 +#ifdef CONFIG_X86_PAE
22894 + .fill 4,8,0
22895 +#else
22896 .fill 1024,4,0
22897 +#endif
22898
22899 /*
22900 * This starts the data section.
22901 */
22902 #ifdef CONFIG_X86_PAE
22903 -__PAGE_ALIGNED_DATA
22904 - /* Page-aligned for the benefit of paravirt? */
22905 - .align PAGE_SIZE
22906 +.section .initial_page_table,"a",@progbits
22907 ENTRY(initial_page_table)
22908 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22909 # if KPMDS == 3
22910 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22911 # error "Kernel PMDs should be 1, 2 or 3"
22912 # endif
22913 .align PAGE_SIZE /* needs to be page-sized too */
22914 +
22915 +#ifdef CONFIG_PAX_PER_CPU_PGD
22916 +ENTRY(cpu_pgd)
22917 + .rept 2*NR_CPUS
22918 + .fill 4,8,0
22919 + .endr
22920 +#endif
22921 +
22922 #endif
22923
22924 .data
22925 .balign 4
22926 ENTRY(stack_start)
22927 - .long init_thread_union+THREAD_SIZE
22928 + .long init_thread_union+THREAD_SIZE-8
22929
22930 __INITRODATA
22931 int_msg:
22932 @@ -722,7 +820,7 @@ fault_msg:
22933 * segment size, and 32-bit linear address value:
22934 */
22935
22936 - .data
22937 +.section .rodata,"a",@progbits
22938 .globl boot_gdt_descr
22939 .globl idt_descr
22940
22941 @@ -731,7 +829,7 @@ fault_msg:
22942 .word 0 # 32 bit align gdt_desc.address
22943 boot_gdt_descr:
22944 .word __BOOT_DS+7
22945 - .long boot_gdt - __PAGE_OFFSET
22946 + .long pa(boot_gdt)
22947
22948 .word 0 # 32-bit align idt_desc.address
22949 idt_descr:
22950 @@ -742,7 +840,7 @@ idt_descr:
22951 .word 0 # 32 bit align gdt_desc.address
22952 ENTRY(early_gdt_descr)
22953 .word GDT_ENTRIES*8-1
22954 - .long gdt_page /* Overwritten for secondary CPUs */
22955 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22956
22957 /*
22958 * The boot_gdt must mirror the equivalent in setup.S and is
22959 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22960 .align L1_CACHE_BYTES
22961 ENTRY(boot_gdt)
22962 .fill GDT_ENTRY_BOOT_CS,8,0
22963 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22964 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22965 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22966 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22967 +
22968 + .align PAGE_SIZE_asm
22969 +ENTRY(cpu_gdt_table)
22970 + .rept NR_CPUS
22971 + .quad 0x0000000000000000 /* NULL descriptor */
22972 + .quad 0x0000000000000000 /* 0x0b reserved */
22973 + .quad 0x0000000000000000 /* 0x13 reserved */
22974 + .quad 0x0000000000000000 /* 0x1b reserved */
22975 +
22976 +#ifdef CONFIG_PAX_KERNEXEC
22977 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22978 +#else
22979 + .quad 0x0000000000000000 /* 0x20 unused */
22980 +#endif
22981 +
22982 + .quad 0x0000000000000000 /* 0x28 unused */
22983 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22984 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22985 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22986 + .quad 0x0000000000000000 /* 0x4b reserved */
22987 + .quad 0x0000000000000000 /* 0x53 reserved */
22988 + .quad 0x0000000000000000 /* 0x5b reserved */
22989 +
22990 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
22991 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
22992 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
22993 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
22994 +
22995 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
22996 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
22997 +
22998 + /*
22999 + * Segments used for calling PnP BIOS have byte granularity.
23000 + * The code segments and data segments have fixed 64k limits,
23001 + * the transfer segment sizes are set at run time.
23002 + */
23003 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23004 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23005 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23006 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23007 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23008 +
23009 + /*
23010 + * The APM segments have byte granularity and their bases
23011 + * are set at run time. All have 64k limits.
23012 + */
23013 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23014 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23015 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23016 +
23017 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23018 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23019 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23020 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23021 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23022 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23023 +
23024 + /* Be sure this is zeroed to avoid false validations in Xen */
23025 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23026 + .endr
23027 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23028 index e1aabdb..73dcad8 100644
23029 --- a/arch/x86/kernel/head_64.S
23030 +++ b/arch/x86/kernel/head_64.S
23031 @@ -20,6 +20,8 @@
23032 #include <asm/processor-flags.h>
23033 #include <asm/percpu.h>
23034 #include <asm/nops.h>
23035 +#include <asm/cpufeature.h>
23036 +#include <asm/alternative-asm.h>
23037
23038 #ifdef CONFIG_PARAVIRT
23039 #include <asm/asm-offsets.h>
23040 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23041 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23042 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23043 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23044 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23045 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23046 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23047 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23048 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23049 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23050
23051 .text
23052 __HEAD
23053 @@ -89,11 +97,23 @@ startup_64:
23054 * Fixup the physical addresses in the page table
23055 */
23056 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23057 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23058 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23059 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23060 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23061 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23062
23063 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23064 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23065 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23066 +#ifndef CONFIG_XEN
23067 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23068 +#endif
23069
23070 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23071 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23072 +
23073 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23074 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23075 +
23076 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23077
23078 /*
23079 * Set up the identity mapping for the switchover. These
23080 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
23081 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23082 1:
23083
23084 - /* Enable PAE mode and PGE */
23085 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23086 + /* Enable PAE mode and PSE/PGE */
23087 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23088 movq %rcx, %cr4
23089
23090 /* Setup early boot stage 4 level pagetables. */
23091 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
23092 movl $MSR_EFER, %ecx
23093 rdmsr
23094 btsl $_EFER_SCE, %eax /* Enable System Call */
23095 - btl $20,%edi /* No Execute supported? */
23096 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23097 jnc 1f
23098 btsl $_EFER_NX, %eax
23099 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23100 + leaq init_level4_pgt(%rip), %rdi
23101 +#ifndef CONFIG_EFI
23102 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
23103 +#endif
23104 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
23105 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
23106 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
23107 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23108 1: wrmsr /* Make changes effective */
23109
23110 /* Setup cr0 */
23111 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
23112 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23113 * address given in m16:64.
23114 */
23115 + pax_set_fptr_mask
23116 movq initial_code(%rip),%rax
23117 pushq $0 # fake return address to stop unwinder
23118 pushq $__KERNEL_CS # set correct cs
23119 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
23120 call dump_stack
23121 #ifdef CONFIG_KALLSYMS
23122 leaq early_idt_ripmsg(%rip),%rdi
23123 - movq 40(%rsp),%rsi # %rip again
23124 + movq 88(%rsp),%rsi # %rip again
23125 call __print_symbol
23126 #endif
23127 #endif /* EARLY_PRINTK */
23128 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
23129 early_recursion_flag:
23130 .long 0
23131
23132 + .section .rodata,"a",@progbits
23133 #ifdef CONFIG_EARLY_PRINTK
23134 early_idt_msg:
23135 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23136 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
23137 NEXT_PAGE(early_dynamic_pgts)
23138 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23139
23140 - .data
23141 + .section .rodata,"a",@progbits
23142
23143 -#ifndef CONFIG_XEN
23144 NEXT_PAGE(init_level4_pgt)
23145 - .fill 512,8,0
23146 -#else
23147 -NEXT_PAGE(init_level4_pgt)
23148 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23149 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23150 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23151 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23152 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23153 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23154 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23155 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23156 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23157 .org init_level4_pgt + L4_START_KERNEL*8, 0
23158 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23159 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23160
23161 +#ifdef CONFIG_PAX_PER_CPU_PGD
23162 +NEXT_PAGE(cpu_pgd)
23163 + .rept 2*NR_CPUS
23164 + .fill 512,8,0
23165 + .endr
23166 +#endif
23167 +
23168 NEXT_PAGE(level3_ident_pgt)
23169 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23170 +#ifdef CONFIG_XEN
23171 .fill 511, 8, 0
23172 +#else
23173 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23174 + .fill 510,8,0
23175 +#endif
23176 +
23177 +NEXT_PAGE(level3_vmalloc_start_pgt)
23178 + .fill 512,8,0
23179 +
23180 +NEXT_PAGE(level3_vmalloc_end_pgt)
23181 + .fill 512,8,0
23182 +
23183 +NEXT_PAGE(level3_vmemmap_pgt)
23184 + .fill L3_VMEMMAP_START,8,0
23185 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23186 +
23187 NEXT_PAGE(level2_ident_pgt)
23188 - /* Since I easily can, map the first 1G.
23189 + /* Since I easily can, map the first 2G.
23190 * Don't set NX because code runs from these pages.
23191 */
23192 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23193 -#endif
23194 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23195
23196 NEXT_PAGE(level3_kernel_pgt)
23197 .fill L3_START_KERNEL,8,0
23198 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
23199 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23200 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23201
23202 +NEXT_PAGE(level2_vmemmap_pgt)
23203 + .fill 512,8,0
23204 +
23205 NEXT_PAGE(level2_kernel_pgt)
23206 /*
23207 * 512 MB kernel mapping. We spend a full page on this pagetable
23208 @@ -488,30 +544,62 @@ NEXT_PAGE(level2_kernel_pgt)
23209 KERNEL_IMAGE_SIZE/PMD_SIZE)
23210
23211 NEXT_PAGE(level2_fixmap_pgt)
23212 - .fill 506,8,0
23213 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23214 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23215 - .fill 5,8,0
23216 + .fill 507,8,0
23217 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23218 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23219 + .fill 4,8,0
23220
23221 -NEXT_PAGE(level1_fixmap_pgt)
23222 +NEXT_PAGE(level1_vsyscall_pgt)
23223 .fill 512,8,0
23224
23225 #undef PMDS
23226
23227 - .data
23228 + .align PAGE_SIZE
23229 +ENTRY(cpu_gdt_table)
23230 + .rept NR_CPUS
23231 + .quad 0x0000000000000000 /* NULL descriptor */
23232 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23233 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23234 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23235 + .quad 0x00cffb000000ffff /* __USER32_CS */
23236 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23237 + .quad 0x00affb000000ffff /* __USER_CS */
23238 +
23239 +#ifdef CONFIG_PAX_KERNEXEC
23240 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23241 +#else
23242 + .quad 0x0 /* unused */
23243 +#endif
23244 +
23245 + .quad 0,0 /* TSS */
23246 + .quad 0,0 /* LDT */
23247 + .quad 0,0,0 /* three TLS descriptors */
23248 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23249 + /* asm/segment.h:GDT_ENTRIES must match this */
23250 +
23251 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23252 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23253 +#else
23254 + .quad 0x0 /* unused */
23255 +#endif
23256 +
23257 + /* zero the remaining page */
23258 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23259 + .endr
23260 +
23261 .align 16
23262 .globl early_gdt_descr
23263 early_gdt_descr:
23264 .word GDT_ENTRIES*8-1
23265 early_gdt_descr_base:
23266 - .quad INIT_PER_CPU_VAR(gdt_page)
23267 + .quad cpu_gdt_table
23268
23269 ENTRY(phys_base)
23270 /* This must match the first entry in level2_kernel_pgt */
23271 .quad 0x0000000000000000
23272
23273 #include "../../x86/xen/xen-head.S"
23274 -
23275 - __PAGE_ALIGNED_BSS
23276 +
23277 + .section .rodata,"a",@progbits
23278 NEXT_PAGE(empty_zero_page)
23279 .skip PAGE_SIZE
23280 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23281 index 0fa6912..b37438b 100644
23282 --- a/arch/x86/kernel/i386_ksyms_32.c
23283 +++ b/arch/x86/kernel/i386_ksyms_32.c
23284 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23285 EXPORT_SYMBOL(cmpxchg8b_emu);
23286 #endif
23287
23288 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23289 +
23290 /* Networking helper routines. */
23291 EXPORT_SYMBOL(csum_partial_copy_generic);
23292 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23293 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23294
23295 EXPORT_SYMBOL(__get_user_1);
23296 EXPORT_SYMBOL(__get_user_2);
23297 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23298
23299 EXPORT_SYMBOL(csum_partial);
23300 EXPORT_SYMBOL(empty_zero_page);
23301 +
23302 +#ifdef CONFIG_PAX_KERNEXEC
23303 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23304 +#endif
23305 +
23306 +#ifdef CONFIG_PAX_PER_CPU_PGD
23307 +EXPORT_SYMBOL(cpu_pgd);
23308 +#endif
23309 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23310 index 5d576ab..1403a03 100644
23311 --- a/arch/x86/kernel/i387.c
23312 +++ b/arch/x86/kernel/i387.c
23313 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23314 static inline bool interrupted_user_mode(void)
23315 {
23316 struct pt_regs *regs = get_irq_regs();
23317 - return regs && user_mode_vm(regs);
23318 + return regs && user_mode(regs);
23319 }
23320
23321 /*
23322 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23323 index 9a5c460..84868423 100644
23324 --- a/arch/x86/kernel/i8259.c
23325 +++ b/arch/x86/kernel/i8259.c
23326 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23327 static void make_8259A_irq(unsigned int irq)
23328 {
23329 disable_irq_nosync(irq);
23330 - io_apic_irqs &= ~(1<<irq);
23331 + io_apic_irqs &= ~(1UL<<irq);
23332 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23333 i8259A_chip.name);
23334 enable_irq(irq);
23335 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23336 "spurious 8259A interrupt: IRQ%d.\n", irq);
23337 spurious_irq_mask |= irqmask;
23338 }
23339 - atomic_inc(&irq_err_count);
23340 + atomic_inc_unchecked(&irq_err_count);
23341 /*
23342 * Theoretically we do not have to handle this IRQ,
23343 * but in Linux this does not cause problems and is
23344 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23345 /* (slave's support for AEOI in flat mode is to be investigated) */
23346 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23347
23348 + pax_open_kernel();
23349 if (auto_eoi)
23350 /*
23351 * In AEOI mode we just have to mask the interrupt
23352 * when acking.
23353 */
23354 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23355 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23356 else
23357 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23358 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23359 + pax_close_kernel();
23360
23361 udelay(100); /* wait for 8259A to initialize */
23362
23363 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23364 index a979b5b..1d6db75 100644
23365 --- a/arch/x86/kernel/io_delay.c
23366 +++ b/arch/x86/kernel/io_delay.c
23367 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23368 * Quirk table for systems that misbehave (lock up, etc.) if port
23369 * 0x80 is used:
23370 */
23371 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23372 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23373 {
23374 .callback = dmi_io_delay_0xed_port,
23375 .ident = "Compaq Presario V6000",
23376 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23377 index 4ddaf66..6292f4e 100644
23378 --- a/arch/x86/kernel/ioport.c
23379 +++ b/arch/x86/kernel/ioport.c
23380 @@ -6,6 +6,7 @@
23381 #include <linux/sched.h>
23382 #include <linux/kernel.h>
23383 #include <linux/capability.h>
23384 +#include <linux/security.h>
23385 #include <linux/errno.h>
23386 #include <linux/types.h>
23387 #include <linux/ioport.h>
23388 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23389
23390 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23391 return -EINVAL;
23392 +#ifdef CONFIG_GRKERNSEC_IO
23393 + if (turn_on && grsec_disable_privio) {
23394 + gr_handle_ioperm();
23395 + return -EPERM;
23396 + }
23397 +#endif
23398 if (turn_on && !capable(CAP_SYS_RAWIO))
23399 return -EPERM;
23400
23401 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23402 * because the ->io_bitmap_max value must match the bitmap
23403 * contents:
23404 */
23405 - tss = &per_cpu(init_tss, get_cpu());
23406 + tss = init_tss + get_cpu();
23407
23408 if (turn_on)
23409 bitmap_clear(t->io_bitmap_ptr, from, num);
23410 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23411 return -EINVAL;
23412 /* Trying to gain more privileges? */
23413 if (level > old) {
23414 +#ifdef CONFIG_GRKERNSEC_IO
23415 + if (grsec_disable_privio) {
23416 + gr_handle_iopl();
23417 + return -EPERM;
23418 + }
23419 +#endif
23420 if (!capable(CAP_SYS_RAWIO))
23421 return -EPERM;
23422 }
23423 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23424 index 3a8185c..3c042ee 100644
23425 --- a/arch/x86/kernel/irq.c
23426 +++ b/arch/x86/kernel/irq.c
23427 @@ -21,7 +21,7 @@
23428 #define CREATE_TRACE_POINTS
23429 #include <asm/trace/irq_vectors.h>
23430
23431 -atomic_t irq_err_count;
23432 +atomic_unchecked_t irq_err_count;
23433
23434 /* Function pointer for generic interrupt vector handling */
23435 void (*x86_platform_ipi_callback)(void) = NULL;
23436 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23437 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23438 seq_printf(p, " Machine check polls\n");
23439 #endif
23440 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23441 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23442 #if defined(CONFIG_X86_IO_APIC)
23443 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23444 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23445 #endif
23446 return 0;
23447 }
23448 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23449
23450 u64 arch_irq_stat(void)
23451 {
23452 - u64 sum = atomic_read(&irq_err_count);
23453 + u64 sum = atomic_read_unchecked(&irq_err_count);
23454 return sum;
23455 }
23456
23457 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23458 index 4186755..784efa0 100644
23459 --- a/arch/x86/kernel/irq_32.c
23460 +++ b/arch/x86/kernel/irq_32.c
23461 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23462 __asm__ __volatile__("andl %%esp,%0" :
23463 "=r" (sp) : "0" (THREAD_SIZE - 1));
23464
23465 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23466 + return sp < STACK_WARN;
23467 }
23468
23469 static void print_stack_overflow(void)
23470 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23471 * per-CPU IRQ handling contexts (thread information and stack)
23472 */
23473 union irq_ctx {
23474 - struct thread_info tinfo;
23475 - u32 stack[THREAD_SIZE/sizeof(u32)];
23476 + unsigned long previous_esp;
23477 + u32 stack[THREAD_SIZE/sizeof(u32)];
23478 } __attribute__((aligned(THREAD_SIZE)));
23479
23480 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23481 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23482 static inline int
23483 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23484 {
23485 - union irq_ctx *curctx, *irqctx;
23486 + union irq_ctx *irqctx;
23487 u32 *isp, arg1, arg2;
23488
23489 - curctx = (union irq_ctx *) current_thread_info();
23490 irqctx = __this_cpu_read(hardirq_ctx);
23491
23492 /*
23493 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23494 * handler) we can't do that and just have to keep using the
23495 * current stack (which is the irq stack already after all)
23496 */
23497 - if (unlikely(curctx == irqctx))
23498 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23499 return 0;
23500
23501 /* build the stack frame on the IRQ stack */
23502 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23503 - irqctx->tinfo.task = curctx->tinfo.task;
23504 - irqctx->tinfo.previous_esp = current_stack_pointer;
23505 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23506 + irqctx->previous_esp = current_stack_pointer;
23507
23508 - /* Copy the preempt_count so that the [soft]irq checks work. */
23509 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23510 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23511 + __set_fs(MAKE_MM_SEG(0));
23512 +#endif
23513
23514 if (unlikely(overflow))
23515 call_on_stack(print_stack_overflow, isp);
23516 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23517 : "0" (irq), "1" (desc), "2" (isp),
23518 "D" (desc->handle_irq)
23519 : "memory", "cc", "ecx");
23520 +
23521 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23522 + __set_fs(current_thread_info()->addr_limit);
23523 +#endif
23524 +
23525 return 1;
23526 }
23527
23528 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23529 */
23530 void irq_ctx_init(int cpu)
23531 {
23532 - union irq_ctx *irqctx;
23533 -
23534 if (per_cpu(hardirq_ctx, cpu))
23535 return;
23536
23537 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23538 - THREADINFO_GFP,
23539 - THREAD_SIZE_ORDER));
23540 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23541 - irqctx->tinfo.cpu = cpu;
23542 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23543 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23544 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23545 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23546
23547 - per_cpu(hardirq_ctx, cpu) = irqctx;
23548 -
23549 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23550 - THREADINFO_GFP,
23551 - THREAD_SIZE_ORDER));
23552 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23553 - irqctx->tinfo.cpu = cpu;
23554 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23555 -
23556 - per_cpu(softirq_ctx, cpu) = irqctx;
23557 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23558 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23559
23560 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23561 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23562 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23563 asmlinkage void do_softirq(void)
23564 {
23565 unsigned long flags;
23566 - struct thread_info *curctx;
23567 union irq_ctx *irqctx;
23568 u32 *isp;
23569
23570 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23571 local_irq_save(flags);
23572
23573 if (local_softirq_pending()) {
23574 - curctx = current_thread_info();
23575 irqctx = __this_cpu_read(softirq_ctx);
23576 - irqctx->tinfo.task = curctx->task;
23577 - irqctx->tinfo.previous_esp = current_stack_pointer;
23578 + irqctx->previous_esp = current_stack_pointer;
23579
23580 /* build the stack frame on the softirq stack */
23581 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23582 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23583 +
23584 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23585 + __set_fs(MAKE_MM_SEG(0));
23586 +#endif
23587
23588 call_on_stack(__do_softirq, isp);
23589 +
23590 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23591 + __set_fs(current_thread_info()->addr_limit);
23592 +#endif
23593 +
23594 /*
23595 * Shouldn't happen, we returned above if in_interrupt():
23596 */
23597 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23598 if (unlikely(!desc))
23599 return false;
23600
23601 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23602 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23603 if (unlikely(overflow))
23604 print_stack_overflow();
23605 desc->handle_irq(irq, desc);
23606 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23607 index d04d3ec..ea4b374 100644
23608 --- a/arch/x86/kernel/irq_64.c
23609 +++ b/arch/x86/kernel/irq_64.c
23610 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23611 u64 estack_top, estack_bottom;
23612 u64 curbase = (u64)task_stack_page(current);
23613
23614 - if (user_mode_vm(regs))
23615 + if (user_mode(regs))
23616 return;
23617
23618 if (regs->sp >= curbase + sizeof(struct thread_info) +
23619 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
23620 index dc1404b..bbc43e7 100644
23621 --- a/arch/x86/kernel/kdebugfs.c
23622 +++ b/arch/x86/kernel/kdebugfs.c
23623 @@ -27,7 +27,7 @@ struct setup_data_node {
23624 u32 len;
23625 };
23626
23627 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
23628 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
23629 size_t count, loff_t *ppos)
23630 {
23631 struct setup_data_node *node = file->private_data;
23632 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23633 index 836f832..a8bda67 100644
23634 --- a/arch/x86/kernel/kgdb.c
23635 +++ b/arch/x86/kernel/kgdb.c
23636 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23637 #ifdef CONFIG_X86_32
23638 switch (regno) {
23639 case GDB_SS:
23640 - if (!user_mode_vm(regs))
23641 + if (!user_mode(regs))
23642 *(unsigned long *)mem = __KERNEL_DS;
23643 break;
23644 case GDB_SP:
23645 - if (!user_mode_vm(regs))
23646 + if (!user_mode(regs))
23647 *(unsigned long *)mem = kernel_stack_pointer(regs);
23648 break;
23649 case GDB_GS:
23650 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23651 bp->attr.bp_addr = breakinfo[breakno].addr;
23652 bp->attr.bp_len = breakinfo[breakno].len;
23653 bp->attr.bp_type = breakinfo[breakno].type;
23654 - info->address = breakinfo[breakno].addr;
23655 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23656 + info->address = ktla_ktva(breakinfo[breakno].addr);
23657 + else
23658 + info->address = breakinfo[breakno].addr;
23659 info->len = breakinfo[breakno].len;
23660 info->type = breakinfo[breakno].type;
23661 val = arch_install_hw_breakpoint(bp);
23662 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23663 case 'k':
23664 /* clear the trace bit */
23665 linux_regs->flags &= ~X86_EFLAGS_TF;
23666 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23667 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23668
23669 /* set the trace bit if we're stepping */
23670 if (remcomInBuffer[0] == 's') {
23671 linux_regs->flags |= X86_EFLAGS_TF;
23672 - atomic_set(&kgdb_cpu_doing_single_step,
23673 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23674 raw_smp_processor_id());
23675 }
23676
23677 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23678
23679 switch (cmd) {
23680 case DIE_DEBUG:
23681 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23682 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23683 if (user_mode(regs))
23684 return single_step_cont(regs, args);
23685 break;
23686 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23687 #endif /* CONFIG_DEBUG_RODATA */
23688
23689 bpt->type = BP_BREAKPOINT;
23690 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23691 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23692 BREAK_INSTR_SIZE);
23693 if (err)
23694 return err;
23695 - err = probe_kernel_write((char *)bpt->bpt_addr,
23696 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23697 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23698 #ifdef CONFIG_DEBUG_RODATA
23699 if (!err)
23700 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23701 return -EBUSY;
23702 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23703 BREAK_INSTR_SIZE);
23704 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23705 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23706 if (err)
23707 return err;
23708 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23709 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23710 if (mutex_is_locked(&text_mutex))
23711 goto knl_write;
23712 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23713 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23714 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23715 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23716 goto knl_write;
23717 return err;
23718 knl_write:
23719 #endif /* CONFIG_DEBUG_RODATA */
23720 - return probe_kernel_write((char *)bpt->bpt_addr,
23721 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23722 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23723 }
23724
23725 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23726 index 211bce4..6e2580a 100644
23727 --- a/arch/x86/kernel/kprobes/core.c
23728 +++ b/arch/x86/kernel/kprobes/core.c
23729 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23730 s32 raddr;
23731 } __packed *insn;
23732
23733 - insn = (struct __arch_relative_insn *)from;
23734 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23735 +
23736 + pax_open_kernel();
23737 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23738 insn->op = op;
23739 + pax_close_kernel();
23740 }
23741
23742 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23743 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23744 kprobe_opcode_t opcode;
23745 kprobe_opcode_t *orig_opcodes = opcodes;
23746
23747 - if (search_exception_tables((unsigned long)opcodes))
23748 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23749 return 0; /* Page fault may occur on this address. */
23750
23751 retry:
23752 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23753 * for the first byte, we can recover the original instruction
23754 * from it and kp->opcode.
23755 */
23756 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23757 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23758 buf[0] = kp->opcode;
23759 - return (unsigned long)buf;
23760 + return ktva_ktla((unsigned long)buf);
23761 }
23762
23763 /*
23764 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23765 /* Another subsystem puts a breakpoint, failed to recover */
23766 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23767 return 0;
23768 + pax_open_kernel();
23769 memcpy(dest, insn.kaddr, insn.length);
23770 + pax_close_kernel();
23771
23772 #ifdef CONFIG_X86_64
23773 if (insn_rip_relative(&insn)) {
23774 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23775 return 0;
23776 }
23777 disp = (u8 *) dest + insn_offset_displacement(&insn);
23778 + pax_open_kernel();
23779 *(s32 *) disp = (s32) newdisp;
23780 + pax_close_kernel();
23781 }
23782 #endif
23783 return insn.length;
23784 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23785 * nor set current_kprobe, because it doesn't use single
23786 * stepping.
23787 */
23788 - regs->ip = (unsigned long)p->ainsn.insn;
23789 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23790 preempt_enable_no_resched();
23791 return;
23792 }
23793 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23794 regs->flags &= ~X86_EFLAGS_IF;
23795 /* single step inline if the instruction is an int3 */
23796 if (p->opcode == BREAKPOINT_INSTRUCTION)
23797 - regs->ip = (unsigned long)p->addr;
23798 + regs->ip = ktla_ktva((unsigned long)p->addr);
23799 else
23800 - regs->ip = (unsigned long)p->ainsn.insn;
23801 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23802 }
23803
23804 /*
23805 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23806 setup_singlestep(p, regs, kcb, 0);
23807 return 1;
23808 }
23809 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23810 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23811 /*
23812 * The breakpoint instruction was removed right
23813 * after we hit it. Another cpu has removed
23814 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23815 " movq %rax, 152(%rsp)\n"
23816 RESTORE_REGS_STRING
23817 " popfq\n"
23818 +#ifdef KERNEXEC_PLUGIN
23819 + " btsq $63,(%rsp)\n"
23820 +#endif
23821 #else
23822 " pushf\n"
23823 SAVE_REGS_STRING
23824 @@ -779,7 +789,7 @@ static void __kprobes
23825 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23826 {
23827 unsigned long *tos = stack_addr(regs);
23828 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23829 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23830 unsigned long orig_ip = (unsigned long)p->addr;
23831 kprobe_opcode_t *insn = p->ainsn.insn;
23832
23833 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23834 struct die_args *args = data;
23835 int ret = NOTIFY_DONE;
23836
23837 - if (args->regs && user_mode_vm(args->regs))
23838 + if (args->regs && user_mode(args->regs))
23839 return ret;
23840
23841 switch (val) {
23842 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23843 index 76dc6f0..66bdfc3 100644
23844 --- a/arch/x86/kernel/kprobes/opt.c
23845 +++ b/arch/x86/kernel/kprobes/opt.c
23846 @@ -79,6 +79,7 @@ found:
23847 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23848 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23849 {
23850 + pax_open_kernel();
23851 #ifdef CONFIG_X86_64
23852 *addr++ = 0x48;
23853 *addr++ = 0xbf;
23854 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23855 *addr++ = 0xb8;
23856 #endif
23857 *(unsigned long *)addr = val;
23858 + pax_close_kernel();
23859 }
23860
23861 static void __used __kprobes kprobes_optinsn_template_holder(void)
23862 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23863 * Verify if the address gap is in 2GB range, because this uses
23864 * a relative jump.
23865 */
23866 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23867 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23868 if (abs(rel) > 0x7fffffff)
23869 return -ERANGE;
23870
23871 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23872 op->optinsn.size = ret;
23873
23874 /* Copy arch-dep-instance from template */
23875 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23876 + pax_open_kernel();
23877 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23878 + pax_close_kernel();
23879
23880 /* Set probe information */
23881 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23882
23883 /* Set probe function call */
23884 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23885 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23886
23887 /* Set returning jmp instruction at the tail of out-of-line buffer */
23888 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23889 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23890 (u8 *)op->kp.addr + op->optinsn.size);
23891
23892 flush_icache_range((unsigned long) buf,
23893 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
23894 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
23895
23896 /* Backup instructions which will be replaced by jump address */
23897 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23898 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23899 RELATIVE_ADDR_SIZE);
23900
23901 insn_buf[0] = RELATIVEJUMP_OPCODE;
23902 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23903 /* This kprobe is really able to run optimized path. */
23904 op = container_of(p, struct optimized_kprobe, kp);
23905 /* Detour through copied instructions */
23906 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23907 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23908 if (!reenter)
23909 reset_current_kprobe();
23910 preempt_enable_no_resched();
23911 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23912 index ebc9873..1b9724b 100644
23913 --- a/arch/x86/kernel/ldt.c
23914 +++ b/arch/x86/kernel/ldt.c
23915 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23916 if (reload) {
23917 #ifdef CONFIG_SMP
23918 preempt_disable();
23919 - load_LDT(pc);
23920 + load_LDT_nolock(pc);
23921 if (!cpumask_equal(mm_cpumask(current->mm),
23922 cpumask_of(smp_processor_id())))
23923 smp_call_function(flush_ldt, current->mm, 1);
23924 preempt_enable();
23925 #else
23926 - load_LDT(pc);
23927 + load_LDT_nolock(pc);
23928 #endif
23929 }
23930 if (oldsize) {
23931 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23932 return err;
23933
23934 for (i = 0; i < old->size; i++)
23935 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23936 + write_ldt_entry(new->ldt, i, old->ldt + i);
23937 return 0;
23938 }
23939
23940 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23941 retval = copy_ldt(&mm->context, &old_mm->context);
23942 mutex_unlock(&old_mm->context.lock);
23943 }
23944 +
23945 + if (tsk == current) {
23946 + mm->context.vdso = 0;
23947 +
23948 +#ifdef CONFIG_X86_32
23949 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23950 + mm->context.user_cs_base = 0UL;
23951 + mm->context.user_cs_limit = ~0UL;
23952 +
23953 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23954 + cpus_clear(mm->context.cpu_user_cs_mask);
23955 +#endif
23956 +
23957 +#endif
23958 +#endif
23959 +
23960 + }
23961 +
23962 return retval;
23963 }
23964
23965 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23966 }
23967 }
23968
23969 +#ifdef CONFIG_PAX_SEGMEXEC
23970 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23971 + error = -EINVAL;
23972 + goto out_unlock;
23973 + }
23974 +#endif
23975 +
23976 fill_ldt(&ldt, &ldt_info);
23977 if (oldmode)
23978 ldt.avl = 0;
23979 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
23980 index 5b19e4d..6476a76 100644
23981 --- a/arch/x86/kernel/machine_kexec_32.c
23982 +++ b/arch/x86/kernel/machine_kexec_32.c
23983 @@ -26,7 +26,7 @@
23984 #include <asm/cacheflush.h>
23985 #include <asm/debugreg.h>
23986
23987 -static void set_idt(void *newidt, __u16 limit)
23988 +static void set_idt(struct desc_struct *newidt, __u16 limit)
23989 {
23990 struct desc_ptr curidt;
23991
23992 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
23993 }
23994
23995
23996 -static void set_gdt(void *newgdt, __u16 limit)
23997 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
23998 {
23999 struct desc_ptr curgdt;
24000
24001 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24002 }
24003
24004 control_page = page_address(image->control_code_page);
24005 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24006 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24007
24008 relocate_kernel_ptr = control_page;
24009 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24010 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24011 index 15c9876..0a43909 100644
24012 --- a/arch/x86/kernel/microcode_core.c
24013 +++ b/arch/x86/kernel/microcode_core.c
24014 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24015 return NOTIFY_OK;
24016 }
24017
24018 -static struct notifier_block __refdata mc_cpu_notifier = {
24019 +static struct notifier_block mc_cpu_notifier = {
24020 .notifier_call = mc_cpu_callback,
24021 };
24022
24023 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24024 index 5fb2ceb..3ae90bb 100644
24025 --- a/arch/x86/kernel/microcode_intel.c
24026 +++ b/arch/x86/kernel/microcode_intel.c
24027 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24028
24029 static int get_ucode_user(void *to, const void *from, size_t n)
24030 {
24031 - return copy_from_user(to, from, n);
24032 + return copy_from_user(to, (const void __force_user *)from, n);
24033 }
24034
24035 static enum ucode_state
24036 request_microcode_user(int cpu, const void __user *buf, size_t size)
24037 {
24038 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24039 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24040 }
24041
24042 static void microcode_fini_cpu(int cpu)
24043 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24044 index 216a4d7..228255a 100644
24045 --- a/arch/x86/kernel/module.c
24046 +++ b/arch/x86/kernel/module.c
24047 @@ -43,15 +43,60 @@ do { \
24048 } while (0)
24049 #endif
24050
24051 -void *module_alloc(unsigned long size)
24052 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24053 {
24054 - if (PAGE_ALIGN(size) > MODULES_LEN)
24055 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24056 return NULL;
24057 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24058 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24059 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24060 -1, __builtin_return_address(0));
24061 }
24062
24063 +void *module_alloc(unsigned long size)
24064 +{
24065 +
24066 +#ifdef CONFIG_PAX_KERNEXEC
24067 + return __module_alloc(size, PAGE_KERNEL);
24068 +#else
24069 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24070 +#endif
24071 +
24072 +}
24073 +
24074 +#ifdef CONFIG_PAX_KERNEXEC
24075 +#ifdef CONFIG_X86_32
24076 +void *module_alloc_exec(unsigned long size)
24077 +{
24078 + struct vm_struct *area;
24079 +
24080 + if (size == 0)
24081 + return NULL;
24082 +
24083 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24084 + return area ? area->addr : NULL;
24085 +}
24086 +EXPORT_SYMBOL(module_alloc_exec);
24087 +
24088 +void module_free_exec(struct module *mod, void *module_region)
24089 +{
24090 + vunmap(module_region);
24091 +}
24092 +EXPORT_SYMBOL(module_free_exec);
24093 +#else
24094 +void module_free_exec(struct module *mod, void *module_region)
24095 +{
24096 + module_free(mod, module_region);
24097 +}
24098 +EXPORT_SYMBOL(module_free_exec);
24099 +
24100 +void *module_alloc_exec(unsigned long size)
24101 +{
24102 + return __module_alloc(size, PAGE_KERNEL_RX);
24103 +}
24104 +EXPORT_SYMBOL(module_alloc_exec);
24105 +#endif
24106 +#endif
24107 +
24108 #ifdef CONFIG_X86_32
24109 int apply_relocate(Elf32_Shdr *sechdrs,
24110 const char *strtab,
24111 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24112 unsigned int i;
24113 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24114 Elf32_Sym *sym;
24115 - uint32_t *location;
24116 + uint32_t *plocation, location;
24117
24118 DEBUGP("Applying relocate section %u to %u\n",
24119 relsec, sechdrs[relsec].sh_info);
24120 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24121 /* This is where to make the change */
24122 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24123 - + rel[i].r_offset;
24124 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24125 + location = (uint32_t)plocation;
24126 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24127 + plocation = ktla_ktva((void *)plocation);
24128 /* This is the symbol it is referring to. Note that all
24129 undefined symbols have been resolved. */
24130 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24131 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24132 switch (ELF32_R_TYPE(rel[i].r_info)) {
24133 case R_386_32:
24134 /* We add the value into the location given */
24135 - *location += sym->st_value;
24136 + pax_open_kernel();
24137 + *plocation += sym->st_value;
24138 + pax_close_kernel();
24139 break;
24140 case R_386_PC32:
24141 /* Add the value, subtract its position */
24142 - *location += sym->st_value - (uint32_t)location;
24143 + pax_open_kernel();
24144 + *plocation += sym->st_value - location;
24145 + pax_close_kernel();
24146 break;
24147 default:
24148 pr_err("%s: Unknown relocation: %u\n",
24149 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24150 case R_X86_64_NONE:
24151 break;
24152 case R_X86_64_64:
24153 + pax_open_kernel();
24154 *(u64 *)loc = val;
24155 + pax_close_kernel();
24156 break;
24157 case R_X86_64_32:
24158 + pax_open_kernel();
24159 *(u32 *)loc = val;
24160 + pax_close_kernel();
24161 if (val != *(u32 *)loc)
24162 goto overflow;
24163 break;
24164 case R_X86_64_32S:
24165 + pax_open_kernel();
24166 *(s32 *)loc = val;
24167 + pax_close_kernel();
24168 if ((s64)val != *(s32 *)loc)
24169 goto overflow;
24170 break;
24171 case R_X86_64_PC32:
24172 val -= (u64)loc;
24173 + pax_open_kernel();
24174 *(u32 *)loc = val;
24175 + pax_close_kernel();
24176 +
24177 #if 0
24178 if ((s64)val != *(s32 *)loc)
24179 goto overflow;
24180 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24181 index 88458fa..349f7a4 100644
24182 --- a/arch/x86/kernel/msr.c
24183 +++ b/arch/x86/kernel/msr.c
24184 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24185 return notifier_from_errno(err);
24186 }
24187
24188 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24189 +static struct notifier_block msr_class_cpu_notifier = {
24190 .notifier_call = msr_class_cpu_callback,
24191 };
24192
24193 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24194 index ba77ebc..65da999 100644
24195 --- a/arch/x86/kernel/nmi.c
24196 +++ b/arch/x86/kernel/nmi.c
24197 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24198 return handled;
24199 }
24200
24201 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24202 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24203 {
24204 struct nmi_desc *desc = nmi_to_desc(type);
24205 unsigned long flags;
24206 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24207 * event confuses some handlers (kdump uses this flag)
24208 */
24209 if (action->flags & NMI_FLAG_FIRST)
24210 - list_add_rcu(&action->list, &desc->head);
24211 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24212 else
24213 - list_add_tail_rcu(&action->list, &desc->head);
24214 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24215
24216 spin_unlock_irqrestore(&desc->lock, flags);
24217 return 0;
24218 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24219 if (!strcmp(n->name, name)) {
24220 WARN(in_nmi(),
24221 "Trying to free NMI (%s) from NMI context!\n", n->name);
24222 - list_del_rcu(&n->list);
24223 + pax_list_del_rcu((struct list_head *)&n->list);
24224 break;
24225 }
24226 }
24227 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24228 dotraplinkage notrace __kprobes void
24229 do_nmi(struct pt_regs *regs, long error_code)
24230 {
24231 +
24232 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24233 + if (!user_mode(regs)) {
24234 + unsigned long cs = regs->cs & 0xFFFF;
24235 + unsigned long ip = ktva_ktla(regs->ip);
24236 +
24237 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24238 + regs->ip = ip;
24239 + }
24240 +#endif
24241 +
24242 nmi_nesting_preprocess(regs);
24243
24244 nmi_enter();
24245 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24246 index 6d9582e..f746287 100644
24247 --- a/arch/x86/kernel/nmi_selftest.c
24248 +++ b/arch/x86/kernel/nmi_selftest.c
24249 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24250 {
24251 /* trap all the unknown NMIs we may generate */
24252 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24253 - __initdata);
24254 + __initconst);
24255 }
24256
24257 static void __init cleanup_nmi_testsuite(void)
24258 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24259 unsigned long timeout;
24260
24261 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24262 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24263 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24264 nmi_fail = FAILURE;
24265 return;
24266 }
24267 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24268 index 676b8c7..870ba04 100644
24269 --- a/arch/x86/kernel/paravirt-spinlocks.c
24270 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24271 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
24272 arch_spin_lock(lock);
24273 }
24274
24275 -struct pv_lock_ops pv_lock_ops = {
24276 +struct pv_lock_ops pv_lock_ops __read_only = {
24277 #ifdef CONFIG_SMP
24278 .spin_is_locked = __ticket_spin_is_locked,
24279 .spin_is_contended = __ticket_spin_is_contended,
24280 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24281 index cd6de64..27c6af0 100644
24282 --- a/arch/x86/kernel/paravirt.c
24283 +++ b/arch/x86/kernel/paravirt.c
24284 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24285 {
24286 return x;
24287 }
24288 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24289 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24290 +#endif
24291
24292 void __init default_banner(void)
24293 {
24294 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24295 if (opfunc == NULL)
24296 /* If there's no function, patch it with a ud2a (BUG) */
24297 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24298 - else if (opfunc == _paravirt_nop)
24299 + else if (opfunc == (void *)_paravirt_nop)
24300 /* If the operation is a nop, then nop the callsite */
24301 ret = paravirt_patch_nop();
24302
24303 /* identity functions just return their single argument */
24304 - else if (opfunc == _paravirt_ident_32)
24305 + else if (opfunc == (void *)_paravirt_ident_32)
24306 ret = paravirt_patch_ident_32(insnbuf, len);
24307 - else if (opfunc == _paravirt_ident_64)
24308 + else if (opfunc == (void *)_paravirt_ident_64)
24309 ret = paravirt_patch_ident_64(insnbuf, len);
24310 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24311 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24312 + ret = paravirt_patch_ident_64(insnbuf, len);
24313 +#endif
24314
24315 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24316 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24317 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24318 if (insn_len > len || start == NULL)
24319 insn_len = len;
24320 else
24321 - memcpy(insnbuf, start, insn_len);
24322 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24323
24324 return insn_len;
24325 }
24326 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24327 return this_cpu_read(paravirt_lazy_mode);
24328 }
24329
24330 -struct pv_info pv_info = {
24331 +struct pv_info pv_info __read_only = {
24332 .name = "bare hardware",
24333 .paravirt_enabled = 0,
24334 .kernel_rpl = 0,
24335 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
24336 #endif
24337 };
24338
24339 -struct pv_init_ops pv_init_ops = {
24340 +struct pv_init_ops pv_init_ops __read_only = {
24341 .patch = native_patch,
24342 };
24343
24344 -struct pv_time_ops pv_time_ops = {
24345 +struct pv_time_ops pv_time_ops __read_only = {
24346 .sched_clock = native_sched_clock,
24347 .steal_clock = native_steal_clock,
24348 };
24349
24350 -struct pv_irq_ops pv_irq_ops = {
24351 +struct pv_irq_ops pv_irq_ops __read_only = {
24352 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24353 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24354 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24355 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
24356 #endif
24357 };
24358
24359 -struct pv_cpu_ops pv_cpu_ops = {
24360 +struct pv_cpu_ops pv_cpu_ops __read_only = {
24361 .cpuid = native_cpuid,
24362 .get_debugreg = native_get_debugreg,
24363 .set_debugreg = native_set_debugreg,
24364 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
24365 .end_context_switch = paravirt_nop,
24366 };
24367
24368 -struct pv_apic_ops pv_apic_ops = {
24369 +struct pv_apic_ops pv_apic_ops __read_only= {
24370 #ifdef CONFIG_X86_LOCAL_APIC
24371 .startup_ipi_hook = paravirt_nop,
24372 #endif
24373 };
24374
24375 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24376 +#ifdef CONFIG_X86_32
24377 +#ifdef CONFIG_X86_PAE
24378 +/* 64-bit pagetable entries */
24379 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24380 +#else
24381 /* 32-bit pagetable entries */
24382 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24383 +#endif
24384 #else
24385 /* 64-bit pagetable entries */
24386 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24387 #endif
24388
24389 -struct pv_mmu_ops pv_mmu_ops = {
24390 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24391
24392 .read_cr2 = native_read_cr2,
24393 .write_cr2 = native_write_cr2,
24394 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24395 .make_pud = PTE_IDENT,
24396
24397 .set_pgd = native_set_pgd,
24398 + .set_pgd_batched = native_set_pgd_batched,
24399 #endif
24400 #endif /* PAGETABLE_LEVELS >= 3 */
24401
24402 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24403 },
24404
24405 .set_fixmap = native_set_fixmap,
24406 +
24407 +#ifdef CONFIG_PAX_KERNEXEC
24408 + .pax_open_kernel = native_pax_open_kernel,
24409 + .pax_close_kernel = native_pax_close_kernel,
24410 +#endif
24411 +
24412 };
24413
24414 EXPORT_SYMBOL_GPL(pv_time_ops);
24415 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24416 index 299d493..2ccb0ee 100644
24417 --- a/arch/x86/kernel/pci-calgary_64.c
24418 +++ b/arch/x86/kernel/pci-calgary_64.c
24419 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24420 tce_space = be64_to_cpu(readq(target));
24421 tce_space = tce_space & TAR_SW_BITS;
24422
24423 - tce_space = tce_space & (~specified_table_size);
24424 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24425 info->tce_space = (u64 *)__va(tce_space);
24426 }
24427 }
24428 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24429 index 35ccf75..7a15747 100644
24430 --- a/arch/x86/kernel/pci-iommu_table.c
24431 +++ b/arch/x86/kernel/pci-iommu_table.c
24432 @@ -2,7 +2,7 @@
24433 #include <asm/iommu_table.h>
24434 #include <linux/string.h>
24435 #include <linux/kallsyms.h>
24436 -
24437 +#include <linux/sched.h>
24438
24439 #define DEBUG 1
24440
24441 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24442 index 6c483ba..d10ce2f 100644
24443 --- a/arch/x86/kernel/pci-swiotlb.c
24444 +++ b/arch/x86/kernel/pci-swiotlb.c
24445 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24446 void *vaddr, dma_addr_t dma_addr,
24447 struct dma_attrs *attrs)
24448 {
24449 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24450 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24451 }
24452
24453 static struct dma_map_ops swiotlb_dma_ops = {
24454 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24455 index 83369e5..52b93f0 100644
24456 --- a/arch/x86/kernel/process.c
24457 +++ b/arch/x86/kernel/process.c
24458 @@ -36,7 +36,8 @@
24459 * section. Since TSS's are completely CPU-local, we want them
24460 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24461 */
24462 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24463 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24464 +EXPORT_SYMBOL(init_tss);
24465
24466 #ifdef CONFIG_X86_64
24467 static DEFINE_PER_CPU(unsigned char, is_idle);
24468 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24469 task_xstate_cachep =
24470 kmem_cache_create("task_xstate", xstate_size,
24471 __alignof__(union thread_xstate),
24472 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24473 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24474 }
24475
24476 /*
24477 @@ -105,7 +106,7 @@ void exit_thread(void)
24478 unsigned long *bp = t->io_bitmap_ptr;
24479
24480 if (bp) {
24481 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24482 + struct tss_struct *tss = init_tss + get_cpu();
24483
24484 t->io_bitmap_ptr = NULL;
24485 clear_thread_flag(TIF_IO_BITMAP);
24486 @@ -125,6 +126,9 @@ void flush_thread(void)
24487 {
24488 struct task_struct *tsk = current;
24489
24490 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24491 + loadsegment(gs, 0);
24492 +#endif
24493 flush_ptrace_hw_breakpoint(tsk);
24494 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24495 drop_init_fpu(tsk);
24496 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24497 void exit_idle(void)
24498 {
24499 /* idle loop has pid 0 */
24500 - if (current->pid)
24501 + if (task_pid_nr(current))
24502 return;
24503 __exit_idle();
24504 }
24505 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24506 return ret;
24507 }
24508 #endif
24509 -void stop_this_cpu(void *dummy)
24510 +__noreturn void stop_this_cpu(void *dummy)
24511 {
24512 local_irq_disable();
24513 /*
24514 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24515 }
24516 early_param("idle", idle_setup);
24517
24518 -unsigned long arch_align_stack(unsigned long sp)
24519 +#ifdef CONFIG_PAX_RANDKSTACK
24520 +void pax_randomize_kstack(struct pt_regs *regs)
24521 {
24522 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24523 - sp -= get_random_int() % 8192;
24524 - return sp & ~0xf;
24525 -}
24526 + struct thread_struct *thread = &current->thread;
24527 + unsigned long time;
24528
24529 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24530 -{
24531 - unsigned long range_end = mm->brk + 0x02000000;
24532 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24533 -}
24534 + if (!randomize_va_space)
24535 + return;
24536 +
24537 + if (v8086_mode(regs))
24538 + return;
24539
24540 + rdtscl(time);
24541 +
24542 + /* P4 seems to return a 0 LSB, ignore it */
24543 +#ifdef CONFIG_MPENTIUM4
24544 + time &= 0x3EUL;
24545 + time <<= 2;
24546 +#elif defined(CONFIG_X86_64)
24547 + time &= 0xFUL;
24548 + time <<= 4;
24549 +#else
24550 + time &= 0x1FUL;
24551 + time <<= 3;
24552 +#endif
24553 +
24554 + thread->sp0 ^= time;
24555 + load_sp0(init_tss + smp_processor_id(), thread);
24556 +
24557 +#ifdef CONFIG_X86_64
24558 + this_cpu_write(kernel_stack, thread->sp0);
24559 +#endif
24560 +}
24561 +#endif
24562 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24563 index f8adefc..4bce3d6 100644
24564 --- a/arch/x86/kernel/process_32.c
24565 +++ b/arch/x86/kernel/process_32.c
24566 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24567 unsigned long thread_saved_pc(struct task_struct *tsk)
24568 {
24569 return ((unsigned long *)tsk->thread.sp)[3];
24570 +//XXX return tsk->thread.eip;
24571 }
24572
24573 void __show_regs(struct pt_regs *regs, int all)
24574 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24575 unsigned long sp;
24576 unsigned short ss, gs;
24577
24578 - if (user_mode_vm(regs)) {
24579 + if (user_mode(regs)) {
24580 sp = regs->sp;
24581 ss = regs->ss & 0xffff;
24582 - gs = get_user_gs(regs);
24583 } else {
24584 sp = kernel_stack_pointer(regs);
24585 savesegment(ss, ss);
24586 - savesegment(gs, gs);
24587 }
24588 + gs = get_user_gs(regs);
24589
24590 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24591 (u16)regs->cs, regs->ip, regs->flags,
24592 - smp_processor_id());
24593 + raw_smp_processor_id());
24594 print_symbol("EIP is at %s\n", regs->ip);
24595
24596 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24597 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24598 int copy_thread(unsigned long clone_flags, unsigned long sp,
24599 unsigned long arg, struct task_struct *p)
24600 {
24601 - struct pt_regs *childregs = task_pt_regs(p);
24602 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24603 struct task_struct *tsk;
24604 int err;
24605
24606 p->thread.sp = (unsigned long) childregs;
24607 p->thread.sp0 = (unsigned long) (childregs+1);
24608 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24609
24610 if (unlikely(p->flags & PF_KTHREAD)) {
24611 /* kernel thread */
24612 memset(childregs, 0, sizeof(struct pt_regs));
24613 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24614 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24615 - childregs->ds = __USER_DS;
24616 - childregs->es = __USER_DS;
24617 + savesegment(gs, childregs->gs);
24618 + childregs->ds = __KERNEL_DS;
24619 + childregs->es = __KERNEL_DS;
24620 childregs->fs = __KERNEL_PERCPU;
24621 childregs->bx = sp; /* function */
24622 childregs->bp = arg;
24623 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24624 struct thread_struct *prev = &prev_p->thread,
24625 *next = &next_p->thread;
24626 int cpu = smp_processor_id();
24627 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24628 + struct tss_struct *tss = init_tss + cpu;
24629 fpu_switch_t fpu;
24630
24631 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24632 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24633 */
24634 lazy_save_gs(prev->gs);
24635
24636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24637 + __set_fs(task_thread_info(next_p)->addr_limit);
24638 +#endif
24639 +
24640 /*
24641 * Load the per-thread Thread-Local Storage descriptor.
24642 */
24643 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24644 */
24645 arch_end_context_switch(next_p);
24646
24647 + this_cpu_write(current_task, next_p);
24648 + this_cpu_write(current_tinfo, &next_p->tinfo);
24649 +
24650 /*
24651 * Restore %gs if needed (which is common)
24652 */
24653 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24654
24655 switch_fpu_finish(next_p, fpu);
24656
24657 - this_cpu_write(current_task, next_p);
24658 -
24659 return prev_p;
24660 }
24661
24662 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24663 } while (count++ < 16);
24664 return 0;
24665 }
24666 -
24667 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24668 index 05646ba..0c2906d 100644
24669 --- a/arch/x86/kernel/process_64.c
24670 +++ b/arch/x86/kernel/process_64.c
24671 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24672 struct pt_regs *childregs;
24673 struct task_struct *me = current;
24674
24675 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24676 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24677 childregs = task_pt_regs(p);
24678 p->thread.sp = (unsigned long) childregs;
24679 p->thread.usersp = me->thread.usersp;
24680 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24681 set_tsk_thread_flag(p, TIF_FORK);
24682 p->fpu_counter = 0;
24683 p->thread.io_bitmap_ptr = NULL;
24684 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24685 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24686 savesegment(es, p->thread.es);
24687 savesegment(ds, p->thread.ds);
24688 + savesegment(ss, p->thread.ss);
24689 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24690 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24691
24692 if (unlikely(p->flags & PF_KTHREAD)) {
24693 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24694 struct thread_struct *prev = &prev_p->thread;
24695 struct thread_struct *next = &next_p->thread;
24696 int cpu = smp_processor_id();
24697 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24698 + struct tss_struct *tss = init_tss + cpu;
24699 unsigned fsindex, gsindex;
24700 fpu_switch_t fpu;
24701
24702 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24703 if (unlikely(next->ds | prev->ds))
24704 loadsegment(ds, next->ds);
24705
24706 + savesegment(ss, prev->ss);
24707 + if (unlikely(next->ss != prev->ss))
24708 + loadsegment(ss, next->ss);
24709
24710 /* We must save %fs and %gs before load_TLS() because
24711 * %fs and %gs may be cleared by load_TLS().
24712 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24713 prev->usersp = this_cpu_read(old_rsp);
24714 this_cpu_write(old_rsp, next->usersp);
24715 this_cpu_write(current_task, next_p);
24716 + this_cpu_write(current_tinfo, &next_p->tinfo);
24717
24718 - this_cpu_write(kernel_stack,
24719 - (unsigned long)task_stack_page(next_p) +
24720 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24721 + this_cpu_write(kernel_stack, next->sp0);
24722
24723 /*
24724 * Now maybe reload the debug registers and handle I/O bitmaps
24725 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24726 if (!p || p == current || p->state == TASK_RUNNING)
24727 return 0;
24728 stack = (unsigned long)task_stack_page(p);
24729 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24730 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24731 return 0;
24732 fp = *(u64 *)(p->thread.sp);
24733 do {
24734 - if (fp < (unsigned long)stack ||
24735 - fp >= (unsigned long)stack+THREAD_SIZE)
24736 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24737 return 0;
24738 ip = *(u64 *)(fp+8);
24739 if (!in_sched_functions(ip))
24740 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24741 index 7461f50..1334029 100644
24742 --- a/arch/x86/kernel/ptrace.c
24743 +++ b/arch/x86/kernel/ptrace.c
24744 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24745 {
24746 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24747 unsigned long sp = (unsigned long)&regs->sp;
24748 - struct thread_info *tinfo;
24749
24750 - if (context == (sp & ~(THREAD_SIZE - 1)))
24751 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24752 return sp;
24753
24754 - tinfo = (struct thread_info *)context;
24755 - if (tinfo->previous_esp)
24756 - return tinfo->previous_esp;
24757 + sp = *(unsigned long *)context;
24758 + if (sp)
24759 + return sp;
24760
24761 return (unsigned long)regs;
24762 }
24763 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24764 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24765 {
24766 int i;
24767 - int dr7 = 0;
24768 + unsigned long dr7 = 0;
24769 struct arch_hw_breakpoint *info;
24770
24771 for (i = 0; i < HBP_NUM; i++) {
24772 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24773 unsigned long addr, unsigned long data)
24774 {
24775 int ret;
24776 - unsigned long __user *datap = (unsigned long __user *)data;
24777 + unsigned long __user *datap = (__force unsigned long __user *)data;
24778
24779 switch (request) {
24780 /* read the word at location addr in the USER area. */
24781 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24782 if ((int) addr < 0)
24783 return -EIO;
24784 ret = do_get_thread_area(child, addr,
24785 - (struct user_desc __user *)data);
24786 + (__force struct user_desc __user *) data);
24787 break;
24788
24789 case PTRACE_SET_THREAD_AREA:
24790 if ((int) addr < 0)
24791 return -EIO;
24792 ret = do_set_thread_area(child, addr,
24793 - (struct user_desc __user *)data, 0);
24794 + (__force struct user_desc __user *) data, 0);
24795 break;
24796 #endif
24797
24798 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24799
24800 #ifdef CONFIG_X86_64
24801
24802 -static struct user_regset x86_64_regsets[] __read_mostly = {
24803 +static user_regset_no_const x86_64_regsets[] __read_only = {
24804 [REGSET_GENERAL] = {
24805 .core_note_type = NT_PRSTATUS,
24806 .n = sizeof(struct user_regs_struct) / sizeof(long),
24807 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24808 #endif /* CONFIG_X86_64 */
24809
24810 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24811 -static struct user_regset x86_32_regsets[] __read_mostly = {
24812 +static user_regset_no_const x86_32_regsets[] __read_only = {
24813 [REGSET_GENERAL] = {
24814 .core_note_type = NT_PRSTATUS,
24815 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24816 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24817 */
24818 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24819
24820 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24821 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24822 {
24823 #ifdef CONFIG_X86_64
24824 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24825 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24826 memset(info, 0, sizeof(*info));
24827 info->si_signo = SIGTRAP;
24828 info->si_code = si_code;
24829 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24830 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24831 }
24832
24833 void user_single_step_siginfo(struct task_struct *tsk,
24834 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24835 # define IS_IA32 0
24836 #endif
24837
24838 +#ifdef CONFIG_GRKERNSEC_SETXID
24839 +extern void gr_delayed_cred_worker(void);
24840 +#endif
24841 +
24842 /*
24843 * We must return the syscall number to actually look up in the table.
24844 * This can be -1L to skip running any syscall at all.
24845 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24846
24847 user_exit();
24848
24849 +#ifdef CONFIG_GRKERNSEC_SETXID
24850 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24851 + gr_delayed_cred_worker();
24852 +#endif
24853 +
24854 /*
24855 * If we stepped into a sysenter/syscall insn, it trapped in
24856 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24857 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24858 */
24859 user_exit();
24860
24861 +#ifdef CONFIG_GRKERNSEC_SETXID
24862 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24863 + gr_delayed_cred_worker();
24864 +#endif
24865 +
24866 audit_syscall_exit(regs);
24867
24868 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24869 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24870 index 2cb9470..ff1fd80 100644
24871 --- a/arch/x86/kernel/pvclock.c
24872 +++ b/arch/x86/kernel/pvclock.c
24873 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24874 return pv_tsc_khz;
24875 }
24876
24877 -static atomic64_t last_value = ATOMIC64_INIT(0);
24878 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24879
24880 void pvclock_resume(void)
24881 {
24882 - atomic64_set(&last_value, 0);
24883 + atomic64_set_unchecked(&last_value, 0);
24884 }
24885
24886 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24887 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24888 * updating at the same time, and one of them could be slightly behind,
24889 * making the assumption that last_value always go forward fail to hold.
24890 */
24891 - last = atomic64_read(&last_value);
24892 + last = atomic64_read_unchecked(&last_value);
24893 do {
24894 if (ret < last)
24895 return last;
24896 - last = atomic64_cmpxchg(&last_value, last, ret);
24897 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24898 } while (unlikely(last != ret));
24899
24900 return ret;
24901 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24902 index 5f4ad27..9d96c99 100644
24903 --- a/arch/x86/kernel/reboot.c
24904 +++ b/arch/x86/kernel/reboot.c
24905 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24906
24907 void __noreturn machine_real_restart(unsigned int type)
24908 {
24909 +
24910 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24911 + struct desc_struct *gdt;
24912 +#endif
24913 +
24914 local_irq_disable();
24915
24916 /*
24917 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24918
24919 /* Jump to the identity-mapped low memory code */
24920 #ifdef CONFIG_X86_32
24921 - asm volatile("jmpl *%0" : :
24922 +
24923 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24924 + gdt = get_cpu_gdt_table(smp_processor_id());
24925 + pax_open_kernel();
24926 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24927 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24928 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24929 + loadsegment(ds, __KERNEL_DS);
24930 + loadsegment(es, __KERNEL_DS);
24931 + loadsegment(ss, __KERNEL_DS);
24932 +#endif
24933 +#ifdef CONFIG_PAX_KERNEXEC
24934 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24935 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24936 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24937 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24938 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24939 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24940 +#endif
24941 + pax_close_kernel();
24942 +#endif
24943 +
24944 + asm volatile("ljmpl *%0" : :
24945 "rm" (real_mode_header->machine_real_restart_asm),
24946 "a" (type));
24947 #else
24948 @@ -458,7 +485,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24949 * try to force a triple fault and then cycle between hitting the keyboard
24950 * controller and doing that
24951 */
24952 -static void native_machine_emergency_restart(void)
24953 +static void __noreturn native_machine_emergency_restart(void)
24954 {
24955 int i;
24956 int attempt = 0;
24957 @@ -567,13 +594,13 @@ void native_machine_shutdown(void)
24958 #endif
24959 }
24960
24961 -static void __machine_emergency_restart(int emergency)
24962 +static void __noreturn __machine_emergency_restart(int emergency)
24963 {
24964 reboot_emergency = emergency;
24965 machine_ops.emergency_restart();
24966 }
24967
24968 -static void native_machine_restart(char *__unused)
24969 +static void __noreturn native_machine_restart(char *__unused)
24970 {
24971 pr_notice("machine restart\n");
24972
24973 @@ -582,7 +609,7 @@ static void native_machine_restart(char *__unused)
24974 __machine_emergency_restart(0);
24975 }
24976
24977 -static void native_machine_halt(void)
24978 +static void __noreturn native_machine_halt(void)
24979 {
24980 /* Stop other cpus and apics */
24981 machine_shutdown();
24982 @@ -592,7 +619,7 @@ static void native_machine_halt(void)
24983 stop_this_cpu(NULL);
24984 }
24985
24986 -static void native_machine_power_off(void)
24987 +static void __noreturn native_machine_power_off(void)
24988 {
24989 if (pm_power_off) {
24990 if (!reboot_force)
24991 @@ -601,9 +628,10 @@ static void native_machine_power_off(void)
24992 }
24993 /* A fallback in case there is no PM info available */
24994 tboot_shutdown(TB_SHUTDOWN_HALT);
24995 + unreachable();
24996 }
24997
24998 -struct machine_ops machine_ops = {
24999 +struct machine_ops machine_ops __read_only = {
25000 .power_off = native_machine_power_off,
25001 .shutdown = native_machine_shutdown,
25002 .emergency_restart = native_machine_emergency_restart,
25003 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25004 index c8e41e9..64049ef 100644
25005 --- a/arch/x86/kernel/reboot_fixups_32.c
25006 +++ b/arch/x86/kernel/reboot_fixups_32.c
25007 @@ -57,7 +57,7 @@ struct device_fixup {
25008 unsigned int vendor;
25009 unsigned int device;
25010 void (*reboot_fixup)(struct pci_dev *);
25011 -};
25012 +} __do_const;
25013
25014 /*
25015 * PCI ids solely used for fixups_table go here
25016 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25017 index 3fd2c69..16ef367 100644
25018 --- a/arch/x86/kernel/relocate_kernel_64.S
25019 +++ b/arch/x86/kernel/relocate_kernel_64.S
25020 @@ -11,6 +11,7 @@
25021 #include <asm/kexec.h>
25022 #include <asm/processor-flags.h>
25023 #include <asm/pgtable_types.h>
25024 +#include <asm/alternative-asm.h>
25025
25026 /*
25027 * Must be relocatable PIC code callable as a C function
25028 @@ -96,8 +97,7 @@ relocate_kernel:
25029
25030 /* jump to identity mapped page */
25031 addq $(identity_mapped - relocate_kernel), %r8
25032 - pushq %r8
25033 - ret
25034 + jmp *%r8
25035
25036 identity_mapped:
25037 /* set return address to 0 if not preserving context */
25038 @@ -167,6 +167,7 @@ identity_mapped:
25039 xorl %r14d, %r14d
25040 xorl %r15d, %r15d
25041
25042 + pax_force_retaddr 0, 1
25043 ret
25044
25045 1:
25046 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25047 index 234e1e3..01cd64d 100644
25048 --- a/arch/x86/kernel/setup.c
25049 +++ b/arch/x86/kernel/setup.c
25050 @@ -110,6 +110,7 @@
25051 #include <asm/mce.h>
25052 #include <asm/alternative.h>
25053 #include <asm/prom.h>
25054 +#include <asm/boot.h>
25055
25056 /*
25057 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25058 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25059 #endif
25060
25061
25062 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25063 -unsigned long mmu_cr4_features;
25064 +#ifdef CONFIG_X86_64
25065 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25066 +#elif defined(CONFIG_X86_PAE)
25067 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25068 #else
25069 -unsigned long mmu_cr4_features = X86_CR4_PAE;
25070 +unsigned long mmu_cr4_features __read_only;
25071 #endif
25072
25073 +void set_in_cr4(unsigned long mask)
25074 +{
25075 + unsigned long cr4 = read_cr4();
25076 +
25077 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25078 + return;
25079 +
25080 + pax_open_kernel();
25081 + mmu_cr4_features |= mask;
25082 + pax_close_kernel();
25083 +
25084 + if (trampoline_cr4_features)
25085 + *trampoline_cr4_features = mmu_cr4_features;
25086 + cr4 |= mask;
25087 + write_cr4(cr4);
25088 +}
25089 +EXPORT_SYMBOL(set_in_cr4);
25090 +
25091 +void clear_in_cr4(unsigned long mask)
25092 +{
25093 + unsigned long cr4 = read_cr4();
25094 +
25095 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25096 + return;
25097 +
25098 + pax_open_kernel();
25099 + mmu_cr4_features &= ~mask;
25100 + pax_close_kernel();
25101 +
25102 + if (trampoline_cr4_features)
25103 + *trampoline_cr4_features = mmu_cr4_features;
25104 + cr4 &= ~mask;
25105 + write_cr4(cr4);
25106 +}
25107 +EXPORT_SYMBOL(clear_in_cr4);
25108 +
25109 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25110 int bootloader_type, bootloader_version;
25111
25112 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25113 * area (640->1Mb) as ram even though it is not.
25114 * take them out.
25115 */
25116 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25117 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25118
25119 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25120 }
25121 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25122 /* called before trim_bios_range() to spare extra sanitize */
25123 static void __init e820_add_kernel_range(void)
25124 {
25125 - u64 start = __pa_symbol(_text);
25126 + u64 start = __pa_symbol(ktla_ktva(_text));
25127 u64 size = __pa_symbol(_end) - start;
25128
25129 /*
25130 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25131
25132 void __init setup_arch(char **cmdline_p)
25133 {
25134 +#ifdef CONFIG_X86_32
25135 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25136 +#else
25137 memblock_reserve(__pa_symbol(_text),
25138 (unsigned long)__bss_stop - (unsigned long)_text);
25139 +#endif
25140
25141 early_reserve_initrd();
25142
25143 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25144
25145 if (!boot_params.hdr.root_flags)
25146 root_mountflags &= ~MS_RDONLY;
25147 - init_mm.start_code = (unsigned long) _text;
25148 - init_mm.end_code = (unsigned long) _etext;
25149 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25150 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25151 init_mm.end_data = (unsigned long) _edata;
25152 init_mm.brk = _brk_end;
25153
25154 - code_resource.start = __pa_symbol(_text);
25155 - code_resource.end = __pa_symbol(_etext)-1;
25156 - data_resource.start = __pa_symbol(_etext);
25157 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25158 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25159 + data_resource.start = __pa_symbol(_sdata);
25160 data_resource.end = __pa_symbol(_edata)-1;
25161 bss_resource.start = __pa_symbol(__bss_start);
25162 bss_resource.end = __pa_symbol(__bss_stop)-1;
25163 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25164 index 5cdff03..80fa283 100644
25165 --- a/arch/x86/kernel/setup_percpu.c
25166 +++ b/arch/x86/kernel/setup_percpu.c
25167 @@ -21,19 +21,17 @@
25168 #include <asm/cpu.h>
25169 #include <asm/stackprotector.h>
25170
25171 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25172 +#ifdef CONFIG_SMP
25173 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25174 EXPORT_PER_CPU_SYMBOL(cpu_number);
25175 +#endif
25176
25177 -#ifdef CONFIG_X86_64
25178 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25179 -#else
25180 -#define BOOT_PERCPU_OFFSET 0
25181 -#endif
25182
25183 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25184 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25185
25186 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25187 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25188 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25189 };
25190 EXPORT_SYMBOL(__per_cpu_offset);
25191 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25192 {
25193 #ifdef CONFIG_NEED_MULTIPLE_NODES
25194 pg_data_t *last = NULL;
25195 - unsigned int cpu;
25196 + int cpu;
25197
25198 for_each_possible_cpu(cpu) {
25199 int node = early_cpu_to_node(cpu);
25200 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25201 {
25202 #ifdef CONFIG_X86_32
25203 struct desc_struct gdt;
25204 + unsigned long base = per_cpu_offset(cpu);
25205
25206 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25207 - 0x2 | DESCTYPE_S, 0x8);
25208 - gdt.s = 1;
25209 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25210 + 0x83 | DESCTYPE_S, 0xC);
25211 write_gdt_entry(get_cpu_gdt_table(cpu),
25212 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25213 #endif
25214 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25215 /* alrighty, percpu areas up and running */
25216 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25217 for_each_possible_cpu(cpu) {
25218 +#ifdef CONFIG_CC_STACKPROTECTOR
25219 +#ifdef CONFIG_X86_32
25220 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25221 +#endif
25222 +#endif
25223 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25224 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25225 per_cpu(cpu_number, cpu) = cpu;
25226 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25227 */
25228 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25229 #endif
25230 +#ifdef CONFIG_CC_STACKPROTECTOR
25231 +#ifdef CONFIG_X86_32
25232 + if (!cpu)
25233 + per_cpu(stack_canary.canary, cpu) = canary;
25234 +#endif
25235 +#endif
25236 /*
25237 * Up to this point, the boot CPU has been using .init.data
25238 * area. Reload any changed state for the boot CPU.
25239 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25240 index d859eea..44e17c4 100644
25241 --- a/arch/x86/kernel/signal.c
25242 +++ b/arch/x86/kernel/signal.c
25243 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25244 * Align the stack pointer according to the i386 ABI,
25245 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25246 */
25247 - sp = ((sp + 4) & -16ul) - 4;
25248 + sp = ((sp - 12) & -16ul) - 4;
25249 #else /* !CONFIG_X86_32 */
25250 sp = round_down(sp, 16) - 8;
25251 #endif
25252 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25253 }
25254
25255 if (current->mm->context.vdso)
25256 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25257 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25258 else
25259 - restorer = &frame->retcode;
25260 + restorer = (void __user *)&frame->retcode;
25261 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25262 restorer = ksig->ka.sa.sa_restorer;
25263
25264 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25265 * reasons and because gdb uses it as a signature to notice
25266 * signal handler stack frames.
25267 */
25268 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25269 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25270
25271 if (err)
25272 return -EFAULT;
25273 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25274 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25275
25276 /* Set up to return from userspace. */
25277 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25278 + if (current->mm->context.vdso)
25279 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25280 + else
25281 + restorer = (void __user *)&frame->retcode;
25282 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25283 restorer = ksig->ka.sa.sa_restorer;
25284 put_user_ex(restorer, &frame->pretcode);
25285 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25286 * reasons and because gdb uses it as a signature to notice
25287 * signal handler stack frames.
25288 */
25289 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25290 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25291 } put_user_catch(err);
25292
25293 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25294 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25295 {
25296 int usig = signr_convert(ksig->sig);
25297 sigset_t *set = sigmask_to_save();
25298 - compat_sigset_t *cset = (compat_sigset_t *) set;
25299 + sigset_t sigcopy;
25300 + compat_sigset_t *cset;
25301 +
25302 + sigcopy = *set;
25303 +
25304 + cset = (compat_sigset_t *) &sigcopy;
25305
25306 /* Set up the stack frame */
25307 if (is_ia32_frame()) {
25308 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25309 } else if (is_x32_frame()) {
25310 return x32_setup_rt_frame(ksig, cset, regs);
25311 } else {
25312 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25313 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25314 }
25315 }
25316
25317 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25318 index cdaa347..f5af55d 100644
25319 --- a/arch/x86/kernel/smp.c
25320 +++ b/arch/x86/kernel/smp.c
25321 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25322
25323 __setup("nonmi_ipi", nonmi_ipi_setup);
25324
25325 -struct smp_ops smp_ops = {
25326 +struct smp_ops smp_ops __read_only = {
25327 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25328 .smp_prepare_cpus = native_smp_prepare_cpus,
25329 .smp_cpus_done = native_smp_cpus_done,
25330 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25331 index aecc98a..0244a53 100644
25332 --- a/arch/x86/kernel/smpboot.c
25333 +++ b/arch/x86/kernel/smpboot.c
25334 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25335
25336 enable_start_cpu0 = 0;
25337
25338 -#ifdef CONFIG_X86_32
25339 - /* switch away from the initial page table */
25340 - load_cr3(swapper_pg_dir);
25341 - __flush_tlb_all();
25342 -#endif
25343 -
25344 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25345 barrier();
25346 +
25347 + /* switch away from the initial page table */
25348 +#ifdef CONFIG_PAX_PER_CPU_PGD
25349 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25350 + __flush_tlb_all();
25351 +#elif defined(CONFIG_X86_32)
25352 + load_cr3(swapper_pg_dir);
25353 + __flush_tlb_all();
25354 +#endif
25355 +
25356 /*
25357 * Check TSC synchronization with the BP:
25358 */
25359 @@ -748,6 +752,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25360 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25361 (THREAD_SIZE + task_stack_page(idle))) - 1);
25362 per_cpu(current_task, cpu) = idle;
25363 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25364
25365 #ifdef CONFIG_X86_32
25366 /* Stack for startup_32 can be just as for start_secondary onwards */
25367 @@ -755,11 +760,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25368 #else
25369 clear_tsk_thread_flag(idle, TIF_FORK);
25370 initial_gs = per_cpu_offset(cpu);
25371 - per_cpu(kernel_stack, cpu) =
25372 - (unsigned long)task_stack_page(idle) -
25373 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25374 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25375 #endif
25376 +
25377 + pax_open_kernel();
25378 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25379 + pax_close_kernel();
25380 +
25381 initial_code = (unsigned long)start_secondary;
25382 stack_start = idle->thread.sp;
25383
25384 @@ -908,6 +915,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25385 /* the FPU context is blank, nobody can own it */
25386 __cpu_disable_lazy_restore(cpu);
25387
25388 +#ifdef CONFIG_PAX_PER_CPU_PGD
25389 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25390 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25391 + KERNEL_PGD_PTRS);
25392 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25393 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25394 + KERNEL_PGD_PTRS);
25395 +#endif
25396 +
25397 err = do_boot_cpu(apicid, cpu, tidle);
25398 if (err) {
25399 pr_debug("do_boot_cpu failed %d\n", err);
25400 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25401 index 9b4d51d..5d28b58 100644
25402 --- a/arch/x86/kernel/step.c
25403 +++ b/arch/x86/kernel/step.c
25404 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25405 struct desc_struct *desc;
25406 unsigned long base;
25407
25408 - seg &= ~7UL;
25409 + seg >>= 3;
25410
25411 mutex_lock(&child->mm->context.lock);
25412 - if (unlikely((seg >> 3) >= child->mm->context.size))
25413 + if (unlikely(seg >= child->mm->context.size))
25414 addr = -1L; /* bogus selector, access would fault */
25415 else {
25416 desc = child->mm->context.ldt + seg;
25417 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25418 addr += base;
25419 }
25420 mutex_unlock(&child->mm->context.lock);
25421 - }
25422 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25423 + addr = ktla_ktva(addr);
25424
25425 return addr;
25426 }
25427 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25428 unsigned char opcode[15];
25429 unsigned long addr = convert_ip_to_linear(child, regs);
25430
25431 + if (addr == -EINVAL)
25432 + return 0;
25433 +
25434 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25435 for (i = 0; i < copied; i++) {
25436 switch (opcode[i]) {
25437 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25438 new file mode 100644
25439 index 0000000..5877189
25440 --- /dev/null
25441 +++ b/arch/x86/kernel/sys_i386_32.c
25442 @@ -0,0 +1,189 @@
25443 +/*
25444 + * This file contains various random system calls that
25445 + * have a non-standard calling sequence on the Linux/i386
25446 + * platform.
25447 + */
25448 +
25449 +#include <linux/errno.h>
25450 +#include <linux/sched.h>
25451 +#include <linux/mm.h>
25452 +#include <linux/fs.h>
25453 +#include <linux/smp.h>
25454 +#include <linux/sem.h>
25455 +#include <linux/msg.h>
25456 +#include <linux/shm.h>
25457 +#include <linux/stat.h>
25458 +#include <linux/syscalls.h>
25459 +#include <linux/mman.h>
25460 +#include <linux/file.h>
25461 +#include <linux/utsname.h>
25462 +#include <linux/ipc.h>
25463 +#include <linux/elf.h>
25464 +
25465 +#include <linux/uaccess.h>
25466 +#include <linux/unistd.h>
25467 +
25468 +#include <asm/syscalls.h>
25469 +
25470 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25471 +{
25472 + unsigned long pax_task_size = TASK_SIZE;
25473 +
25474 +#ifdef CONFIG_PAX_SEGMEXEC
25475 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25476 + pax_task_size = SEGMEXEC_TASK_SIZE;
25477 +#endif
25478 +
25479 + if (flags & MAP_FIXED)
25480 + if (len > pax_task_size || addr > pax_task_size - len)
25481 + return -EINVAL;
25482 +
25483 + return 0;
25484 +}
25485 +
25486 +/*
25487 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25488 + */
25489 +static unsigned long get_align_mask(void)
25490 +{
25491 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25492 + return 0;
25493 +
25494 + if (!(current->flags & PF_RANDOMIZE))
25495 + return 0;
25496 +
25497 + return va_align.mask;
25498 +}
25499 +
25500 +unsigned long
25501 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25502 + unsigned long len, unsigned long pgoff, unsigned long flags)
25503 +{
25504 + struct mm_struct *mm = current->mm;
25505 + struct vm_area_struct *vma;
25506 + unsigned long pax_task_size = TASK_SIZE;
25507 + struct vm_unmapped_area_info info;
25508 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25509 +
25510 +#ifdef CONFIG_PAX_SEGMEXEC
25511 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25512 + pax_task_size = SEGMEXEC_TASK_SIZE;
25513 +#endif
25514 +
25515 + pax_task_size -= PAGE_SIZE;
25516 +
25517 + if (len > pax_task_size)
25518 + return -ENOMEM;
25519 +
25520 + if (flags & MAP_FIXED)
25521 + return addr;
25522 +
25523 +#ifdef CONFIG_PAX_RANDMMAP
25524 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25525 +#endif
25526 +
25527 + if (addr) {
25528 + addr = PAGE_ALIGN(addr);
25529 + if (pax_task_size - len >= addr) {
25530 + vma = find_vma(mm, addr);
25531 + if (check_heap_stack_gap(vma, addr, len, offset))
25532 + return addr;
25533 + }
25534 + }
25535 +
25536 + info.flags = 0;
25537 + info.length = len;
25538 + info.align_mask = filp ? get_align_mask() : 0;
25539 + info.align_offset = pgoff << PAGE_SHIFT;
25540 + info.threadstack_offset = offset;
25541 +
25542 +#ifdef CONFIG_PAX_PAGEEXEC
25543 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25544 + info.low_limit = 0x00110000UL;
25545 + info.high_limit = mm->start_code;
25546 +
25547 +#ifdef CONFIG_PAX_RANDMMAP
25548 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25549 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25550 +#endif
25551 +
25552 + if (info.low_limit < info.high_limit) {
25553 + addr = vm_unmapped_area(&info);
25554 + if (!IS_ERR_VALUE(addr))
25555 + return addr;
25556 + }
25557 + } else
25558 +#endif
25559 +
25560 + info.low_limit = mm->mmap_base;
25561 + info.high_limit = pax_task_size;
25562 +
25563 + return vm_unmapped_area(&info);
25564 +}
25565 +
25566 +unsigned long
25567 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25568 + const unsigned long len, const unsigned long pgoff,
25569 + const unsigned long flags)
25570 +{
25571 + struct vm_area_struct *vma;
25572 + struct mm_struct *mm = current->mm;
25573 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25574 + struct vm_unmapped_area_info info;
25575 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25576 +
25577 +#ifdef CONFIG_PAX_SEGMEXEC
25578 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25579 + pax_task_size = SEGMEXEC_TASK_SIZE;
25580 +#endif
25581 +
25582 + pax_task_size -= PAGE_SIZE;
25583 +
25584 + /* requested length too big for entire address space */
25585 + if (len > pax_task_size)
25586 + return -ENOMEM;
25587 +
25588 + if (flags & MAP_FIXED)
25589 + return addr;
25590 +
25591 +#ifdef CONFIG_PAX_PAGEEXEC
25592 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25593 + goto bottomup;
25594 +#endif
25595 +
25596 +#ifdef CONFIG_PAX_RANDMMAP
25597 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25598 +#endif
25599 +
25600 + /* requesting a specific address */
25601 + if (addr) {
25602 + addr = PAGE_ALIGN(addr);
25603 + if (pax_task_size - len >= addr) {
25604 + vma = find_vma(mm, addr);
25605 + if (check_heap_stack_gap(vma, addr, len, offset))
25606 + return addr;
25607 + }
25608 + }
25609 +
25610 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25611 + info.length = len;
25612 + info.low_limit = PAGE_SIZE;
25613 + info.high_limit = mm->mmap_base;
25614 + info.align_mask = filp ? get_align_mask() : 0;
25615 + info.align_offset = pgoff << PAGE_SHIFT;
25616 + info.threadstack_offset = offset;
25617 +
25618 + addr = vm_unmapped_area(&info);
25619 + if (!(addr & ~PAGE_MASK))
25620 + return addr;
25621 + VM_BUG_ON(addr != -ENOMEM);
25622 +
25623 +bottomup:
25624 + /*
25625 + * A failed mmap() very likely causes application failure,
25626 + * so fall back to the bottom-up function here. This scenario
25627 + * can happen with large stack limits and large mmap()
25628 + * allocations.
25629 + */
25630 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25631 +}
25632 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25633 index 30277e2..5664a29 100644
25634 --- a/arch/x86/kernel/sys_x86_64.c
25635 +++ b/arch/x86/kernel/sys_x86_64.c
25636 @@ -81,8 +81,8 @@ out:
25637 return error;
25638 }
25639
25640 -static void find_start_end(unsigned long flags, unsigned long *begin,
25641 - unsigned long *end)
25642 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25643 + unsigned long *begin, unsigned long *end)
25644 {
25645 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25646 unsigned long new_begin;
25647 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25648 *begin = new_begin;
25649 }
25650 } else {
25651 - *begin = current->mm->mmap_legacy_base;
25652 + *begin = mm->mmap_legacy_base;
25653 *end = TASK_SIZE;
25654 }
25655 }
25656 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25657 struct vm_area_struct *vma;
25658 struct vm_unmapped_area_info info;
25659 unsigned long begin, end;
25660 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25661
25662 if (flags & MAP_FIXED)
25663 return addr;
25664
25665 - find_start_end(flags, &begin, &end);
25666 + find_start_end(mm, flags, &begin, &end);
25667
25668 if (len > end)
25669 return -ENOMEM;
25670
25671 +#ifdef CONFIG_PAX_RANDMMAP
25672 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25673 +#endif
25674 +
25675 if (addr) {
25676 addr = PAGE_ALIGN(addr);
25677 vma = find_vma(mm, addr);
25678 - if (end - len >= addr &&
25679 - (!vma || addr + len <= vma->vm_start))
25680 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25681 return addr;
25682 }
25683
25684 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25685 info.high_limit = end;
25686 info.align_mask = filp ? get_align_mask() : 0;
25687 info.align_offset = pgoff << PAGE_SHIFT;
25688 + info.threadstack_offset = offset;
25689 return vm_unmapped_area(&info);
25690 }
25691
25692 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25693 struct mm_struct *mm = current->mm;
25694 unsigned long addr = addr0;
25695 struct vm_unmapped_area_info info;
25696 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25697
25698 /* requested length too big for entire address space */
25699 if (len > TASK_SIZE)
25700 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25701 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25702 goto bottomup;
25703
25704 +#ifdef CONFIG_PAX_RANDMMAP
25705 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25706 +#endif
25707 +
25708 /* requesting a specific address */
25709 if (addr) {
25710 addr = PAGE_ALIGN(addr);
25711 vma = find_vma(mm, addr);
25712 - if (TASK_SIZE - len >= addr &&
25713 - (!vma || addr + len <= vma->vm_start))
25714 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25715 return addr;
25716 }
25717
25718 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25719 info.high_limit = mm->mmap_base;
25720 info.align_mask = filp ? get_align_mask() : 0;
25721 info.align_offset = pgoff << PAGE_SHIFT;
25722 + info.threadstack_offset = offset;
25723 addr = vm_unmapped_area(&info);
25724 if (!(addr & ~PAGE_MASK))
25725 return addr;
25726 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25727 index addf7b5..f960685 100644
25728 --- a/arch/x86/kernel/tboot.c
25729 +++ b/arch/x86/kernel/tboot.c
25730 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25731
25732 void tboot_shutdown(u32 shutdown_type)
25733 {
25734 - void (*shutdown)(void);
25735 + void (* __noreturn shutdown)(void);
25736
25737 if (!tboot_enabled())
25738 return;
25739 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25740
25741 switch_to_tboot_pt();
25742
25743 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25744 + shutdown = (void *)tboot->shutdown_entry;
25745 shutdown();
25746
25747 /* should not reach here */
25748 @@ -301,7 +301,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
25749 return 0;
25750 }
25751
25752 -static atomic_t ap_wfs_count;
25753 +static atomic_unchecked_t ap_wfs_count;
25754
25755 static int tboot_wait_for_aps(int num_aps)
25756 {
25757 @@ -325,9 +325,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25758 {
25759 switch (action) {
25760 case CPU_DYING:
25761 - atomic_inc(&ap_wfs_count);
25762 + atomic_inc_unchecked(&ap_wfs_count);
25763 if (num_online_cpus() == 1)
25764 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25765 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25766 return NOTIFY_BAD;
25767 break;
25768 }
25769 @@ -413,7 +413,7 @@ static __init int tboot_late_init(void)
25770
25771 tboot_create_trampoline();
25772
25773 - atomic_set(&ap_wfs_count, 0);
25774 + atomic_set_unchecked(&ap_wfs_count, 0);
25775 register_hotcpu_notifier(&tboot_cpu_notifier);
25776
25777 #ifdef CONFIG_DEBUG_FS
25778 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25779 index 24d3c91..d06b473 100644
25780 --- a/arch/x86/kernel/time.c
25781 +++ b/arch/x86/kernel/time.c
25782 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25783 {
25784 unsigned long pc = instruction_pointer(regs);
25785
25786 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25787 + if (!user_mode(regs) && in_lock_functions(pc)) {
25788 #ifdef CONFIG_FRAME_POINTER
25789 - return *(unsigned long *)(regs->bp + sizeof(long));
25790 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25791 #else
25792 unsigned long *sp =
25793 (unsigned long *)kernel_stack_pointer(regs);
25794 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25795 * or above a saved flags. Eflags has bits 22-31 zero,
25796 * kernel addresses don't.
25797 */
25798 +
25799 +#ifdef CONFIG_PAX_KERNEXEC
25800 + return ktla_ktva(sp[0]);
25801 +#else
25802 if (sp[0] >> 22)
25803 return sp[0];
25804 if (sp[1] >> 22)
25805 return sp[1];
25806 #endif
25807 +
25808 +#endif
25809 }
25810 return pc;
25811 }
25812 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25813 index f7fec09..9991981 100644
25814 --- a/arch/x86/kernel/tls.c
25815 +++ b/arch/x86/kernel/tls.c
25816 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25817 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25818 return -EINVAL;
25819
25820 +#ifdef CONFIG_PAX_SEGMEXEC
25821 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25822 + return -EINVAL;
25823 +#endif
25824 +
25825 set_tls_desc(p, idx, &info, 1);
25826
25827 return 0;
25828 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25829
25830 if (kbuf)
25831 info = kbuf;
25832 - else if (__copy_from_user(infobuf, ubuf, count))
25833 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25834 return -EFAULT;
25835 else
25836 info = infobuf;
25837 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25838 index 1c113db..287b42e 100644
25839 --- a/arch/x86/kernel/tracepoint.c
25840 +++ b/arch/x86/kernel/tracepoint.c
25841 @@ -9,11 +9,11 @@
25842 #include <linux/atomic.h>
25843
25844 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25845 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25846 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25847 (unsigned long) trace_idt_table };
25848
25849 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25850 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25851 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25852
25853 static int trace_irq_vector_refcount;
25854 static DEFINE_MUTEX(irq_vector_mutex);
25855 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25856 index 1b23a1c..910de0d 100644
25857 --- a/arch/x86/kernel/traps.c
25858 +++ b/arch/x86/kernel/traps.c
25859 @@ -65,7 +65,7 @@
25860 #include <asm/proto.h>
25861
25862 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25863 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25864 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25865 #else
25866 #include <asm/processor-flags.h>
25867 #include <asm/setup.h>
25868 @@ -74,7 +74,7 @@ asmlinkage int system_call(void);
25869 #endif
25870
25871 /* Must be page-aligned because the real IDT is used in a fixmap. */
25872 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25873 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25874
25875 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25876 EXPORT_SYMBOL_GPL(used_vectors);
25877 @@ -106,11 +106,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25878 }
25879
25880 static int __kprobes
25881 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25882 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25883 struct pt_regs *regs, long error_code)
25884 {
25885 #ifdef CONFIG_X86_32
25886 - if (regs->flags & X86_VM_MASK) {
25887 + if (v8086_mode(regs)) {
25888 /*
25889 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25890 * On nmi (interrupt 2), do_trap should not be called.
25891 @@ -123,12 +123,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25892 return -1;
25893 }
25894 #endif
25895 - if (!user_mode(regs)) {
25896 + if (!user_mode_novm(regs)) {
25897 if (!fixup_exception(regs)) {
25898 tsk->thread.error_code = error_code;
25899 tsk->thread.trap_nr = trapnr;
25900 +
25901 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25902 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25903 + str = "PAX: suspicious stack segment fault";
25904 +#endif
25905 +
25906 die(str, regs, error_code);
25907 }
25908 +
25909 +#ifdef CONFIG_PAX_REFCOUNT
25910 + if (trapnr == 4)
25911 + pax_report_refcount_overflow(regs);
25912 +#endif
25913 +
25914 return 0;
25915 }
25916
25917 @@ -136,7 +148,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25918 }
25919
25920 static void __kprobes
25921 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25922 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25923 long error_code, siginfo_t *info)
25924 {
25925 struct task_struct *tsk = current;
25926 @@ -160,7 +172,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25927 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25928 printk_ratelimit()) {
25929 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25930 - tsk->comm, tsk->pid, str,
25931 + tsk->comm, task_pid_nr(tsk), str,
25932 regs->ip, regs->sp, error_code);
25933 print_vma_addr(" in ", regs->ip);
25934 pr_cont("\n");
25935 @@ -276,7 +288,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25936 conditional_sti(regs);
25937
25938 #ifdef CONFIG_X86_32
25939 - if (regs->flags & X86_VM_MASK) {
25940 + if (v8086_mode(regs)) {
25941 local_irq_enable();
25942 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25943 goto exit;
25944 @@ -284,18 +296,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25945 #endif
25946
25947 tsk = current;
25948 - if (!user_mode(regs)) {
25949 + if (!user_mode_novm(regs)) {
25950 if (fixup_exception(regs))
25951 goto exit;
25952
25953 tsk->thread.error_code = error_code;
25954 tsk->thread.trap_nr = X86_TRAP_GP;
25955 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25956 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25957 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25958 +
25959 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25960 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25961 + die("PAX: suspicious general protection fault", regs, error_code);
25962 + else
25963 +#endif
25964 +
25965 die("general protection fault", regs, error_code);
25966 + }
25967 goto exit;
25968 }
25969
25970 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25971 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25972 + struct mm_struct *mm = tsk->mm;
25973 + unsigned long limit;
25974 +
25975 + down_write(&mm->mmap_sem);
25976 + limit = mm->context.user_cs_limit;
25977 + if (limit < TASK_SIZE) {
25978 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
25979 + up_write(&mm->mmap_sem);
25980 + return;
25981 + }
25982 + up_write(&mm->mmap_sem);
25983 + }
25984 +#endif
25985 +
25986 tsk->thread.error_code = error_code;
25987 tsk->thread.trap_nr = X86_TRAP_GP;
25988
25989 @@ -453,7 +489,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25990 /* It's safe to allow irq's after DR6 has been saved */
25991 preempt_conditional_sti(regs);
25992
25993 - if (regs->flags & X86_VM_MASK) {
25994 + if (v8086_mode(regs)) {
25995 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
25996 X86_TRAP_DB);
25997 preempt_conditional_cli(regs);
25998 @@ -468,7 +504,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25999 * We already checked v86 mode above, so we can check for kernel mode
26000 * by just checking the CPL of CS.
26001 */
26002 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26003 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26004 tsk->thread.debugreg6 &= ~DR_STEP;
26005 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26006 regs->flags &= ~X86_EFLAGS_TF;
26007 @@ -500,7 +536,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26008 return;
26009 conditional_sti(regs);
26010
26011 - if (!user_mode_vm(regs))
26012 + if (!user_mode(regs))
26013 {
26014 if (!fixup_exception(regs)) {
26015 task->thread.error_code = error_code;
26016 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26017 index 2ed8459..7cf329f 100644
26018 --- a/arch/x86/kernel/uprobes.c
26019 +++ b/arch/x86/kernel/uprobes.c
26020 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26021 int ret = NOTIFY_DONE;
26022
26023 /* We are only interested in userspace traps */
26024 - if (regs && !user_mode_vm(regs))
26025 + if (regs && !user_mode(regs))
26026 return NOTIFY_DONE;
26027
26028 switch (val) {
26029 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26030
26031 if (ncopied != rasize) {
26032 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26033 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26034 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26035
26036 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26037 }
26038 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26039 index b9242ba..50c5edd 100644
26040 --- a/arch/x86/kernel/verify_cpu.S
26041 +++ b/arch/x86/kernel/verify_cpu.S
26042 @@ -20,6 +20,7 @@
26043 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26044 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26045 * arch/x86/kernel/head_32.S: processor startup
26046 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26047 *
26048 * verify_cpu, returns the status of longmode and SSE in register %eax.
26049 * 0: Success 1: Failure
26050 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26051 index e8edcf5..27f9344 100644
26052 --- a/arch/x86/kernel/vm86_32.c
26053 +++ b/arch/x86/kernel/vm86_32.c
26054 @@ -44,6 +44,7 @@
26055 #include <linux/ptrace.h>
26056 #include <linux/audit.h>
26057 #include <linux/stddef.h>
26058 +#include <linux/grsecurity.h>
26059
26060 #include <asm/uaccess.h>
26061 #include <asm/io.h>
26062 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26063 do_exit(SIGSEGV);
26064 }
26065
26066 - tss = &per_cpu(init_tss, get_cpu());
26067 + tss = init_tss + get_cpu();
26068 current->thread.sp0 = current->thread.saved_sp0;
26069 current->thread.sysenter_cs = __KERNEL_CS;
26070 load_sp0(tss, &current->thread);
26071 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26072
26073 if (tsk->thread.saved_sp0)
26074 return -EPERM;
26075 +
26076 +#ifdef CONFIG_GRKERNSEC_VM86
26077 + if (!capable(CAP_SYS_RAWIO)) {
26078 + gr_handle_vm86();
26079 + return -EPERM;
26080 + }
26081 +#endif
26082 +
26083 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26084 offsetof(struct kernel_vm86_struct, vm86plus) -
26085 sizeof(info.regs));
26086 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26087 int tmp;
26088 struct vm86plus_struct __user *v86;
26089
26090 +#ifdef CONFIG_GRKERNSEC_VM86
26091 + if (!capable(CAP_SYS_RAWIO)) {
26092 + gr_handle_vm86();
26093 + return -EPERM;
26094 + }
26095 +#endif
26096 +
26097 tsk = current;
26098 switch (cmd) {
26099 case VM86_REQUEST_IRQ:
26100 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26101 tsk->thread.saved_fs = info->regs32->fs;
26102 tsk->thread.saved_gs = get_user_gs(info->regs32);
26103
26104 - tss = &per_cpu(init_tss, get_cpu());
26105 + tss = init_tss + get_cpu();
26106 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26107 if (cpu_has_sep)
26108 tsk->thread.sysenter_cs = 0;
26109 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26110 goto cannot_handle;
26111 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26112 goto cannot_handle;
26113 - intr_ptr = (unsigned long __user *) (i << 2);
26114 + intr_ptr = (__force unsigned long __user *) (i << 2);
26115 if (get_user(segoffs, intr_ptr))
26116 goto cannot_handle;
26117 if ((segoffs >> 16) == BIOSSEG)
26118 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26119 index 10c4f30..65408b9 100644
26120 --- a/arch/x86/kernel/vmlinux.lds.S
26121 +++ b/arch/x86/kernel/vmlinux.lds.S
26122 @@ -26,6 +26,13 @@
26123 #include <asm/page_types.h>
26124 #include <asm/cache.h>
26125 #include <asm/boot.h>
26126 +#include <asm/segment.h>
26127 +
26128 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26129 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26130 +#else
26131 +#define __KERNEL_TEXT_OFFSET 0
26132 +#endif
26133
26134 #undef i386 /* in case the preprocessor is a 32bit one */
26135
26136 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26137
26138 PHDRS {
26139 text PT_LOAD FLAGS(5); /* R_E */
26140 +#ifdef CONFIG_X86_32
26141 + module PT_LOAD FLAGS(5); /* R_E */
26142 +#endif
26143 +#ifdef CONFIG_XEN
26144 + rodata PT_LOAD FLAGS(5); /* R_E */
26145 +#else
26146 + rodata PT_LOAD FLAGS(4); /* R__ */
26147 +#endif
26148 data PT_LOAD FLAGS(6); /* RW_ */
26149 -#ifdef CONFIG_X86_64
26150 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26151 #ifdef CONFIG_SMP
26152 percpu PT_LOAD FLAGS(6); /* RW_ */
26153 #endif
26154 + text.init PT_LOAD FLAGS(5); /* R_E */
26155 + text.exit PT_LOAD FLAGS(5); /* R_E */
26156 init PT_LOAD FLAGS(7); /* RWE */
26157 -#endif
26158 note PT_NOTE FLAGS(0); /* ___ */
26159 }
26160
26161 SECTIONS
26162 {
26163 #ifdef CONFIG_X86_32
26164 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26165 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26166 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26167 #else
26168 - . = __START_KERNEL;
26169 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26170 + . = __START_KERNEL;
26171 #endif
26172
26173 /* Text and read-only data */
26174 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26175 - _text = .;
26176 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26177 /* bootstrapping code */
26178 +#ifdef CONFIG_X86_32
26179 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26180 +#else
26181 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26182 +#endif
26183 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26184 + _text = .;
26185 HEAD_TEXT
26186 . = ALIGN(8);
26187 _stext = .;
26188 @@ -104,13 +124,47 @@ SECTIONS
26189 IRQENTRY_TEXT
26190 *(.fixup)
26191 *(.gnu.warning)
26192 - /* End of text section */
26193 - _etext = .;
26194 } :text = 0x9090
26195
26196 - NOTES :text :note
26197 + . += __KERNEL_TEXT_OFFSET;
26198
26199 - EXCEPTION_TABLE(16) :text = 0x9090
26200 +#ifdef CONFIG_X86_32
26201 + . = ALIGN(PAGE_SIZE);
26202 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26203 +
26204 +#ifdef CONFIG_PAX_KERNEXEC
26205 + MODULES_EXEC_VADDR = .;
26206 + BYTE(0)
26207 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26208 + . = ALIGN(HPAGE_SIZE) - 1;
26209 + MODULES_EXEC_END = .;
26210 +#endif
26211 +
26212 + } :module
26213 +#endif
26214 +
26215 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26216 + /* End of text section */
26217 + BYTE(0)
26218 + _etext = . - __KERNEL_TEXT_OFFSET;
26219 + }
26220 +
26221 +#ifdef CONFIG_X86_32
26222 + . = ALIGN(PAGE_SIZE);
26223 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26224 + . = ALIGN(PAGE_SIZE);
26225 + *(.empty_zero_page)
26226 + *(.initial_pg_fixmap)
26227 + *(.initial_pg_pmd)
26228 + *(.initial_page_table)
26229 + *(.swapper_pg_dir)
26230 + } :rodata
26231 +#endif
26232 +
26233 + . = ALIGN(PAGE_SIZE);
26234 + NOTES :rodata :note
26235 +
26236 + EXCEPTION_TABLE(16) :rodata
26237
26238 #if defined(CONFIG_DEBUG_RODATA)
26239 /* .text should occupy whole number of pages */
26240 @@ -122,16 +176,20 @@ SECTIONS
26241
26242 /* Data */
26243 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26244 +
26245 +#ifdef CONFIG_PAX_KERNEXEC
26246 + . = ALIGN(HPAGE_SIZE);
26247 +#else
26248 + . = ALIGN(PAGE_SIZE);
26249 +#endif
26250 +
26251 /* Start of data section */
26252 _sdata = .;
26253
26254 /* init_task */
26255 INIT_TASK_DATA(THREAD_SIZE)
26256
26257 -#ifdef CONFIG_X86_32
26258 - /* 32 bit has nosave before _edata */
26259 NOSAVE_DATA
26260 -#endif
26261
26262 PAGE_ALIGNED_DATA(PAGE_SIZE)
26263
26264 @@ -172,12 +230,19 @@ SECTIONS
26265 #endif /* CONFIG_X86_64 */
26266
26267 /* Init code and data - will be freed after init */
26268 - . = ALIGN(PAGE_SIZE);
26269 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26270 + BYTE(0)
26271 +
26272 +#ifdef CONFIG_PAX_KERNEXEC
26273 + . = ALIGN(HPAGE_SIZE);
26274 +#else
26275 + . = ALIGN(PAGE_SIZE);
26276 +#endif
26277 +
26278 __init_begin = .; /* paired with __init_end */
26279 - }
26280 + } :init.begin
26281
26282 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26283 +#ifdef CONFIG_SMP
26284 /*
26285 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26286 * output PHDR, so the next output section - .init.text - should
26287 @@ -186,12 +251,27 @@ SECTIONS
26288 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26289 #endif
26290
26291 - INIT_TEXT_SECTION(PAGE_SIZE)
26292 -#ifdef CONFIG_X86_64
26293 - :init
26294 -#endif
26295 + . = ALIGN(PAGE_SIZE);
26296 + init_begin = .;
26297 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26298 + VMLINUX_SYMBOL(_sinittext) = .;
26299 + INIT_TEXT
26300 + VMLINUX_SYMBOL(_einittext) = .;
26301 + . = ALIGN(PAGE_SIZE);
26302 + } :text.init
26303
26304 - INIT_DATA_SECTION(16)
26305 + /*
26306 + * .exit.text is discard at runtime, not link time, to deal with
26307 + * references from .altinstructions and .eh_frame
26308 + */
26309 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26310 + EXIT_TEXT
26311 + . = ALIGN(16);
26312 + } :text.exit
26313 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26314 +
26315 + . = ALIGN(PAGE_SIZE);
26316 + INIT_DATA_SECTION(16) :init
26317
26318 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26319 __x86_cpu_dev_start = .;
26320 @@ -253,19 +333,12 @@ SECTIONS
26321 }
26322
26323 . = ALIGN(8);
26324 - /*
26325 - * .exit.text is discard at runtime, not link time, to deal with
26326 - * references from .altinstructions and .eh_frame
26327 - */
26328 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26329 - EXIT_TEXT
26330 - }
26331
26332 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26333 EXIT_DATA
26334 }
26335
26336 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26337 +#ifndef CONFIG_SMP
26338 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26339 #endif
26340
26341 @@ -284,16 +357,10 @@ SECTIONS
26342 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26343 __smp_locks = .;
26344 *(.smp_locks)
26345 - . = ALIGN(PAGE_SIZE);
26346 __smp_locks_end = .;
26347 + . = ALIGN(PAGE_SIZE);
26348 }
26349
26350 -#ifdef CONFIG_X86_64
26351 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26352 - NOSAVE_DATA
26353 - }
26354 -#endif
26355 -
26356 /* BSS */
26357 . = ALIGN(PAGE_SIZE);
26358 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26359 @@ -309,6 +376,7 @@ SECTIONS
26360 __brk_base = .;
26361 . += 64 * 1024; /* 64k alignment slop space */
26362 *(.brk_reservation) /* areas brk users have reserved */
26363 + . = ALIGN(HPAGE_SIZE);
26364 __brk_limit = .;
26365 }
26366
26367 @@ -335,13 +403,12 @@ SECTIONS
26368 * for the boot processor.
26369 */
26370 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26371 -INIT_PER_CPU(gdt_page);
26372 INIT_PER_CPU(irq_stack_union);
26373
26374 /*
26375 * Build-time check on the image size:
26376 */
26377 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26378 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26379 "kernel image bigger than KERNEL_IMAGE_SIZE");
26380
26381 #ifdef CONFIG_SMP
26382 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26383 index 1f96f93..d5c8f7a 100644
26384 --- a/arch/x86/kernel/vsyscall_64.c
26385 +++ b/arch/x86/kernel/vsyscall_64.c
26386 @@ -56,15 +56,13 @@
26387 DEFINE_VVAR(int, vgetcpu_mode);
26388 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26389
26390 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26391 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26392
26393 static int __init vsyscall_setup(char *str)
26394 {
26395 if (str) {
26396 if (!strcmp("emulate", str))
26397 vsyscall_mode = EMULATE;
26398 - else if (!strcmp("native", str))
26399 - vsyscall_mode = NATIVE;
26400 else if (!strcmp("none", str))
26401 vsyscall_mode = NONE;
26402 else
26403 @@ -323,8 +321,7 @@ do_ret:
26404 return true;
26405
26406 sigsegv:
26407 - force_sig(SIGSEGV, current);
26408 - return true;
26409 + do_group_exit(SIGKILL);
26410 }
26411
26412 /*
26413 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26414 extern char __vvar_page;
26415 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26416
26417 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26418 - vsyscall_mode == NATIVE
26419 - ? PAGE_KERNEL_VSYSCALL
26420 - : PAGE_KERNEL_VVAR);
26421 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26422 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26423 (unsigned long)VSYSCALL_START);
26424
26425 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26426 index b014d94..e775258 100644
26427 --- a/arch/x86/kernel/x8664_ksyms_64.c
26428 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26429 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26430 EXPORT_SYMBOL(copy_user_generic_unrolled);
26431 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26432 EXPORT_SYMBOL(__copy_user_nocache);
26433 -EXPORT_SYMBOL(_copy_from_user);
26434 -EXPORT_SYMBOL(_copy_to_user);
26435
26436 EXPORT_SYMBOL(copy_page);
26437 EXPORT_SYMBOL(clear_page);
26438 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26439 #ifndef CONFIG_PARAVIRT
26440 EXPORT_SYMBOL(native_load_gs_index);
26441 #endif
26442 +
26443 +#ifdef CONFIG_PAX_PER_CPU_PGD
26444 +EXPORT_SYMBOL(cpu_pgd);
26445 +#endif
26446 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26447 index 5f24c71..1dadf09 100644
26448 --- a/arch/x86/kernel/x86_init.c
26449 +++ b/arch/x86/kernel/x86_init.c
26450 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26451 static void default_nmi_init(void) { };
26452 static int default_i8042_detect(void) { return 1; };
26453
26454 -struct x86_platform_ops x86_platform = {
26455 +struct x86_platform_ops x86_platform __read_only = {
26456 .calibrate_tsc = native_calibrate_tsc,
26457 .get_wallclock = mach_get_cmos_time,
26458 .set_wallclock = mach_set_rtc_mmss,
26459 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
26460 };
26461
26462 EXPORT_SYMBOL_GPL(x86_platform);
26463 -struct x86_msi_ops x86_msi = {
26464 +struct x86_msi_ops x86_msi __read_only = {
26465 .setup_msi_irqs = native_setup_msi_irqs,
26466 .compose_msi_msg = native_compose_msi_msg,
26467 .teardown_msi_irq = native_teardown_msi_irq,
26468 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
26469 .setup_hpet_msi = default_setup_hpet_msi,
26470 };
26471
26472 -struct x86_io_apic_ops x86_io_apic_ops = {
26473 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26474 .init = native_io_apic_init_mappings,
26475 .read = native_io_apic_read,
26476 .write = native_io_apic_write,
26477 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26478 index 422fd82..c3687ca 100644
26479 --- a/arch/x86/kernel/xsave.c
26480 +++ b/arch/x86/kernel/xsave.c
26481 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26482 {
26483 int err;
26484
26485 + buf = (struct xsave_struct __user *)____m(buf);
26486 if (use_xsave())
26487 err = xsave_user(buf);
26488 else if (use_fxsr())
26489 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26490 */
26491 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26492 {
26493 + buf = (void __user *)____m(buf);
26494 if (use_xsave()) {
26495 if ((unsigned long)buf % 64 || fx_only) {
26496 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26497 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26498 index a20ecb5..d0e2194 100644
26499 --- a/arch/x86/kvm/cpuid.c
26500 +++ b/arch/x86/kvm/cpuid.c
26501 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26502 struct kvm_cpuid2 *cpuid,
26503 struct kvm_cpuid_entry2 __user *entries)
26504 {
26505 - int r;
26506 + int r, i;
26507
26508 r = -E2BIG;
26509 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26510 goto out;
26511 r = -EFAULT;
26512 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26513 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26514 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26515 goto out;
26516 + for (i = 0; i < cpuid->nent; ++i) {
26517 + struct kvm_cpuid_entry2 cpuid_entry;
26518 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26519 + goto out;
26520 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26521 + }
26522 vcpu->arch.cpuid_nent = cpuid->nent;
26523 kvm_apic_set_version(vcpu);
26524 kvm_x86_ops->cpuid_update(vcpu);
26525 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26526 struct kvm_cpuid2 *cpuid,
26527 struct kvm_cpuid_entry2 __user *entries)
26528 {
26529 - int r;
26530 + int r, i;
26531
26532 r = -E2BIG;
26533 if (cpuid->nent < vcpu->arch.cpuid_nent)
26534 goto out;
26535 r = -EFAULT;
26536 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26537 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26538 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26539 goto out;
26540 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26541 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26542 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26543 + goto out;
26544 + }
26545 return 0;
26546
26547 out:
26548 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26549 index afc1124..3e431f2 100644
26550 --- a/arch/x86/kvm/lapic.c
26551 +++ b/arch/x86/kvm/lapic.c
26552 @@ -55,7 +55,7 @@
26553 #define APIC_BUS_CYCLE_NS 1
26554
26555 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26556 -#define apic_debug(fmt, arg...)
26557 +#define apic_debug(fmt, arg...) do {} while (0)
26558
26559 #define APIC_LVT_NUM 6
26560 /* 14 is the version for Xeon and Pentium 8.4.8*/
26561 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26562 index 7769699..c8aca4a7f 100644
26563 --- a/arch/x86/kvm/paging_tmpl.h
26564 +++ b/arch/x86/kvm/paging_tmpl.h
26565 @@ -208,7 +208,7 @@ retry_walk:
26566 if (unlikely(kvm_is_error_hva(host_addr)))
26567 goto error;
26568
26569 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26570 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26571 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26572 goto error;
26573 walker->ptep_user[walker->level - 1] = ptep_user;
26574 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26575 index c0bc803..6837a50 100644
26576 --- a/arch/x86/kvm/svm.c
26577 +++ b/arch/x86/kvm/svm.c
26578 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26579 int cpu = raw_smp_processor_id();
26580
26581 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26582 +
26583 + pax_open_kernel();
26584 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26585 + pax_close_kernel();
26586 +
26587 load_TR_desc();
26588 }
26589
26590 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26591 #endif
26592 #endif
26593
26594 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26595 + __set_fs(current_thread_info()->addr_limit);
26596 +#endif
26597 +
26598 reload_tss(vcpu);
26599
26600 local_irq_disable();
26601 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26602 index 064d0be..f5f758e 100644
26603 --- a/arch/x86/kvm/vmx.c
26604 +++ b/arch/x86/kvm/vmx.c
26605 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26606 #endif
26607 }
26608
26609 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26610 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26611 {
26612 vmcs_writel(field, vmcs_readl(field) & ~mask);
26613 }
26614
26615 -static void vmcs_set_bits(unsigned long field, u32 mask)
26616 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26617 {
26618 vmcs_writel(field, vmcs_readl(field) | mask);
26619 }
26620 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
26621 struct desc_struct *descs;
26622
26623 descs = (void *)gdt->address;
26624 +
26625 + pax_open_kernel();
26626 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26627 + pax_close_kernel();
26628 +
26629 load_TR_desc();
26630 }
26631
26632 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26633 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26634 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26635
26636 +#ifdef CONFIG_PAX_PER_CPU_PGD
26637 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26638 +#endif
26639 +
26640 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26641 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26642 vmx->loaded_vmcs->cpu = cpu;
26643 @@ -2940,8 +2948,11 @@ static __init int hardware_setup(void)
26644 if (!cpu_has_vmx_flexpriority())
26645 flexpriority_enabled = 0;
26646
26647 - if (!cpu_has_vmx_tpr_shadow())
26648 - kvm_x86_ops->update_cr8_intercept = NULL;
26649 + if (!cpu_has_vmx_tpr_shadow()) {
26650 + pax_open_kernel();
26651 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26652 + pax_close_kernel();
26653 + }
26654
26655 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26656 kvm_disable_largepages();
26657 @@ -2952,13 +2963,15 @@ static __init int hardware_setup(void)
26658 if (!cpu_has_vmx_apicv())
26659 enable_apicv = 0;
26660
26661 + pax_open_kernel();
26662 if (enable_apicv)
26663 - kvm_x86_ops->update_cr8_intercept = NULL;
26664 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26665 else {
26666 - kvm_x86_ops->hwapic_irr_update = NULL;
26667 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26668 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26669 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26670 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26671 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26672 }
26673 + pax_close_kernel();
26674
26675 if (nested)
26676 nested_vmx_setup_ctls_msrs();
26677 @@ -4081,7 +4094,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26678
26679 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26680 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26681 +
26682 +#ifndef CONFIG_PAX_PER_CPU_PGD
26683 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26684 +#endif
26685
26686 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26687 #ifdef CONFIG_X86_64
26688 @@ -4103,7 +4119,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26689 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26690 vmx->host_idt_base = dt.address;
26691
26692 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26693 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26694
26695 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26696 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26697 @@ -7039,6 +7055,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26698 "jmp 2f \n\t"
26699 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26700 "2: "
26701 +
26702 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26703 + "ljmp %[cs],$3f\n\t"
26704 + "3: "
26705 +#endif
26706 +
26707 /* Save guest registers, load host registers, keep flags */
26708 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26709 "pop %0 \n\t"
26710 @@ -7091,6 +7113,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26711 #endif
26712 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26713 [wordsize]"i"(sizeof(ulong))
26714 +
26715 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26716 + ,[cs]"i"(__KERNEL_CS)
26717 +#endif
26718 +
26719 : "cc", "memory"
26720 #ifdef CONFIG_X86_64
26721 , "rax", "rbx", "rdi", "rsi"
26722 @@ -7104,7 +7131,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26723 if (debugctlmsr)
26724 update_debugctlmsr(debugctlmsr);
26725
26726 -#ifndef CONFIG_X86_64
26727 +#ifdef CONFIG_X86_32
26728 /*
26729 * The sysexit path does not restore ds/es, so we must set them to
26730 * a reasonable value ourselves.
26731 @@ -7113,8 +7140,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26732 * may be executed in interrupt context, which saves and restore segments
26733 * around it, nullifying its effect.
26734 */
26735 - loadsegment(ds, __USER_DS);
26736 - loadsegment(es, __USER_DS);
26737 + loadsegment(ds, __KERNEL_DS);
26738 + loadsegment(es, __KERNEL_DS);
26739 + loadsegment(ss, __KERNEL_DS);
26740 +
26741 +#ifdef CONFIG_PAX_KERNEXEC
26742 + loadsegment(fs, __KERNEL_PERCPU);
26743 +#endif
26744 +
26745 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26746 + __set_fs(current_thread_info()->addr_limit);
26747 +#endif
26748 +
26749 #endif
26750
26751 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26752 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26753 index d21bce5..fdae9f1 100644
26754 --- a/arch/x86/kvm/x86.c
26755 +++ b/arch/x86/kvm/x86.c
26756 @@ -1766,8 +1766,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26757 {
26758 struct kvm *kvm = vcpu->kvm;
26759 int lm = is_long_mode(vcpu);
26760 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26761 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26762 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26763 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26764 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26765 : kvm->arch.xen_hvm_config.blob_size_32;
26766 u32 page_num = data & ~PAGE_MASK;
26767 @@ -2650,6 +2650,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26768 if (n < msr_list.nmsrs)
26769 goto out;
26770 r = -EFAULT;
26771 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26772 + goto out;
26773 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26774 num_msrs_to_save * sizeof(u32)))
26775 goto out;
26776 @@ -5344,7 +5346,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26777 };
26778 #endif
26779
26780 -int kvm_arch_init(void *opaque)
26781 +int kvm_arch_init(const void *opaque)
26782 {
26783 int r;
26784 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
26785 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26786 index 6a22c19..1763f04 100644
26787 --- a/arch/x86/lguest/boot.c
26788 +++ b/arch/x86/lguest/boot.c
26789 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26790 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26791 * Launcher to reboot us.
26792 */
26793 -static void lguest_restart(char *reason)
26794 +static __noreturn void lguest_restart(char *reason)
26795 {
26796 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26797 + BUG();
26798 }
26799
26800 /*G:050
26801 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26802 index 00933d5..3a64af9 100644
26803 --- a/arch/x86/lib/atomic64_386_32.S
26804 +++ b/arch/x86/lib/atomic64_386_32.S
26805 @@ -48,6 +48,10 @@ BEGIN(read)
26806 movl (v), %eax
26807 movl 4(v), %edx
26808 RET_ENDP
26809 +BEGIN(read_unchecked)
26810 + movl (v), %eax
26811 + movl 4(v), %edx
26812 +RET_ENDP
26813 #undef v
26814
26815 #define v %esi
26816 @@ -55,6 +59,10 @@ BEGIN(set)
26817 movl %ebx, (v)
26818 movl %ecx, 4(v)
26819 RET_ENDP
26820 +BEGIN(set_unchecked)
26821 + movl %ebx, (v)
26822 + movl %ecx, 4(v)
26823 +RET_ENDP
26824 #undef v
26825
26826 #define v %esi
26827 @@ -70,6 +78,20 @@ RET_ENDP
26828 BEGIN(add)
26829 addl %eax, (v)
26830 adcl %edx, 4(v)
26831 +
26832 +#ifdef CONFIG_PAX_REFCOUNT
26833 + jno 0f
26834 + subl %eax, (v)
26835 + sbbl %edx, 4(v)
26836 + int $4
26837 +0:
26838 + _ASM_EXTABLE(0b, 0b)
26839 +#endif
26840 +
26841 +RET_ENDP
26842 +BEGIN(add_unchecked)
26843 + addl %eax, (v)
26844 + adcl %edx, 4(v)
26845 RET_ENDP
26846 #undef v
26847
26848 @@ -77,6 +99,24 @@ RET_ENDP
26849 BEGIN(add_return)
26850 addl (v), %eax
26851 adcl 4(v), %edx
26852 +
26853 +#ifdef CONFIG_PAX_REFCOUNT
26854 + into
26855 +1234:
26856 + _ASM_EXTABLE(1234b, 2f)
26857 +#endif
26858 +
26859 + movl %eax, (v)
26860 + movl %edx, 4(v)
26861 +
26862 +#ifdef CONFIG_PAX_REFCOUNT
26863 +2:
26864 +#endif
26865 +
26866 +RET_ENDP
26867 +BEGIN(add_return_unchecked)
26868 + addl (v), %eax
26869 + adcl 4(v), %edx
26870 movl %eax, (v)
26871 movl %edx, 4(v)
26872 RET_ENDP
26873 @@ -86,6 +126,20 @@ RET_ENDP
26874 BEGIN(sub)
26875 subl %eax, (v)
26876 sbbl %edx, 4(v)
26877 +
26878 +#ifdef CONFIG_PAX_REFCOUNT
26879 + jno 0f
26880 + addl %eax, (v)
26881 + adcl %edx, 4(v)
26882 + int $4
26883 +0:
26884 + _ASM_EXTABLE(0b, 0b)
26885 +#endif
26886 +
26887 +RET_ENDP
26888 +BEGIN(sub_unchecked)
26889 + subl %eax, (v)
26890 + sbbl %edx, 4(v)
26891 RET_ENDP
26892 #undef v
26893
26894 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26895 sbbl $0, %edx
26896 addl (v), %eax
26897 adcl 4(v), %edx
26898 +
26899 +#ifdef CONFIG_PAX_REFCOUNT
26900 + into
26901 +1234:
26902 + _ASM_EXTABLE(1234b, 2f)
26903 +#endif
26904 +
26905 + movl %eax, (v)
26906 + movl %edx, 4(v)
26907 +
26908 +#ifdef CONFIG_PAX_REFCOUNT
26909 +2:
26910 +#endif
26911 +
26912 +RET_ENDP
26913 +BEGIN(sub_return_unchecked)
26914 + negl %edx
26915 + negl %eax
26916 + sbbl $0, %edx
26917 + addl (v), %eax
26918 + adcl 4(v), %edx
26919 movl %eax, (v)
26920 movl %edx, 4(v)
26921 RET_ENDP
26922 @@ -105,6 +180,20 @@ RET_ENDP
26923 BEGIN(inc)
26924 addl $1, (v)
26925 adcl $0, 4(v)
26926 +
26927 +#ifdef CONFIG_PAX_REFCOUNT
26928 + jno 0f
26929 + subl $1, (v)
26930 + sbbl $0, 4(v)
26931 + int $4
26932 +0:
26933 + _ASM_EXTABLE(0b, 0b)
26934 +#endif
26935 +
26936 +RET_ENDP
26937 +BEGIN(inc_unchecked)
26938 + addl $1, (v)
26939 + adcl $0, 4(v)
26940 RET_ENDP
26941 #undef v
26942
26943 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26944 movl 4(v), %edx
26945 addl $1, %eax
26946 adcl $0, %edx
26947 +
26948 +#ifdef CONFIG_PAX_REFCOUNT
26949 + into
26950 +1234:
26951 + _ASM_EXTABLE(1234b, 2f)
26952 +#endif
26953 +
26954 + movl %eax, (v)
26955 + movl %edx, 4(v)
26956 +
26957 +#ifdef CONFIG_PAX_REFCOUNT
26958 +2:
26959 +#endif
26960 +
26961 +RET_ENDP
26962 +BEGIN(inc_return_unchecked)
26963 + movl (v), %eax
26964 + movl 4(v), %edx
26965 + addl $1, %eax
26966 + adcl $0, %edx
26967 movl %eax, (v)
26968 movl %edx, 4(v)
26969 RET_ENDP
26970 @@ -123,6 +232,20 @@ RET_ENDP
26971 BEGIN(dec)
26972 subl $1, (v)
26973 sbbl $0, 4(v)
26974 +
26975 +#ifdef CONFIG_PAX_REFCOUNT
26976 + jno 0f
26977 + addl $1, (v)
26978 + adcl $0, 4(v)
26979 + int $4
26980 +0:
26981 + _ASM_EXTABLE(0b, 0b)
26982 +#endif
26983 +
26984 +RET_ENDP
26985 +BEGIN(dec_unchecked)
26986 + subl $1, (v)
26987 + sbbl $0, 4(v)
26988 RET_ENDP
26989 #undef v
26990
26991 @@ -132,6 +255,26 @@ BEGIN(dec_return)
26992 movl 4(v), %edx
26993 subl $1, %eax
26994 sbbl $0, %edx
26995 +
26996 +#ifdef CONFIG_PAX_REFCOUNT
26997 + into
26998 +1234:
26999 + _ASM_EXTABLE(1234b, 2f)
27000 +#endif
27001 +
27002 + movl %eax, (v)
27003 + movl %edx, 4(v)
27004 +
27005 +#ifdef CONFIG_PAX_REFCOUNT
27006 +2:
27007 +#endif
27008 +
27009 +RET_ENDP
27010 +BEGIN(dec_return_unchecked)
27011 + movl (v), %eax
27012 + movl 4(v), %edx
27013 + subl $1, %eax
27014 + sbbl $0, %edx
27015 movl %eax, (v)
27016 movl %edx, 4(v)
27017 RET_ENDP
27018 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27019 adcl %edx, %edi
27020 addl (v), %eax
27021 adcl 4(v), %edx
27022 +
27023 +#ifdef CONFIG_PAX_REFCOUNT
27024 + into
27025 +1234:
27026 + _ASM_EXTABLE(1234b, 2f)
27027 +#endif
27028 +
27029 cmpl %eax, %ecx
27030 je 3f
27031 1:
27032 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27033 1:
27034 addl $1, %eax
27035 adcl $0, %edx
27036 +
27037 +#ifdef CONFIG_PAX_REFCOUNT
27038 + into
27039 +1234:
27040 + _ASM_EXTABLE(1234b, 2f)
27041 +#endif
27042 +
27043 movl %eax, (v)
27044 movl %edx, 4(v)
27045 movl $1, %eax
27046 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27047 movl 4(v), %edx
27048 subl $1, %eax
27049 sbbl $0, %edx
27050 +
27051 +#ifdef CONFIG_PAX_REFCOUNT
27052 + into
27053 +1234:
27054 + _ASM_EXTABLE(1234b, 1f)
27055 +#endif
27056 +
27057 js 1f
27058 movl %eax, (v)
27059 movl %edx, 4(v)
27060 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27061 index f5cc9eb..51fa319 100644
27062 --- a/arch/x86/lib/atomic64_cx8_32.S
27063 +++ b/arch/x86/lib/atomic64_cx8_32.S
27064 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27065 CFI_STARTPROC
27066
27067 read64 %ecx
27068 + pax_force_retaddr
27069 ret
27070 CFI_ENDPROC
27071 ENDPROC(atomic64_read_cx8)
27072
27073 +ENTRY(atomic64_read_unchecked_cx8)
27074 + CFI_STARTPROC
27075 +
27076 + read64 %ecx
27077 + pax_force_retaddr
27078 + ret
27079 + CFI_ENDPROC
27080 +ENDPROC(atomic64_read_unchecked_cx8)
27081 +
27082 ENTRY(atomic64_set_cx8)
27083 CFI_STARTPROC
27084
27085 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27086 cmpxchg8b (%esi)
27087 jne 1b
27088
27089 + pax_force_retaddr
27090 ret
27091 CFI_ENDPROC
27092 ENDPROC(atomic64_set_cx8)
27093
27094 +ENTRY(atomic64_set_unchecked_cx8)
27095 + CFI_STARTPROC
27096 +
27097 +1:
27098 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27099 + * are atomic on 586 and newer */
27100 + cmpxchg8b (%esi)
27101 + jne 1b
27102 +
27103 + pax_force_retaddr
27104 + ret
27105 + CFI_ENDPROC
27106 +ENDPROC(atomic64_set_unchecked_cx8)
27107 +
27108 ENTRY(atomic64_xchg_cx8)
27109 CFI_STARTPROC
27110
27111 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27112 cmpxchg8b (%esi)
27113 jne 1b
27114
27115 + pax_force_retaddr
27116 ret
27117 CFI_ENDPROC
27118 ENDPROC(atomic64_xchg_cx8)
27119
27120 -.macro addsub_return func ins insc
27121 -ENTRY(atomic64_\func\()_return_cx8)
27122 +.macro addsub_return func ins insc unchecked=""
27123 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27124 CFI_STARTPROC
27125 SAVE ebp
27126 SAVE ebx
27127 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27128 movl %edx, %ecx
27129 \ins\()l %esi, %ebx
27130 \insc\()l %edi, %ecx
27131 +
27132 +.ifb \unchecked
27133 +#ifdef CONFIG_PAX_REFCOUNT
27134 + into
27135 +2:
27136 + _ASM_EXTABLE(2b, 3f)
27137 +#endif
27138 +.endif
27139 +
27140 LOCK_PREFIX
27141 cmpxchg8b (%ebp)
27142 jne 1b
27143 -
27144 -10:
27145 movl %ebx, %eax
27146 movl %ecx, %edx
27147 +
27148 +.ifb \unchecked
27149 +#ifdef CONFIG_PAX_REFCOUNT
27150 +3:
27151 +#endif
27152 +.endif
27153 +
27154 RESTORE edi
27155 RESTORE esi
27156 RESTORE ebx
27157 RESTORE ebp
27158 + pax_force_retaddr
27159 ret
27160 CFI_ENDPROC
27161 -ENDPROC(atomic64_\func\()_return_cx8)
27162 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27163 .endm
27164
27165 addsub_return add add adc
27166 addsub_return sub sub sbb
27167 +addsub_return add add adc _unchecked
27168 +addsub_return sub sub sbb _unchecked
27169
27170 -.macro incdec_return func ins insc
27171 -ENTRY(atomic64_\func\()_return_cx8)
27172 +.macro incdec_return func ins insc unchecked=""
27173 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27174 CFI_STARTPROC
27175 SAVE ebx
27176
27177 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27178 movl %edx, %ecx
27179 \ins\()l $1, %ebx
27180 \insc\()l $0, %ecx
27181 +
27182 +.ifb \unchecked
27183 +#ifdef CONFIG_PAX_REFCOUNT
27184 + into
27185 +2:
27186 + _ASM_EXTABLE(2b, 3f)
27187 +#endif
27188 +.endif
27189 +
27190 LOCK_PREFIX
27191 cmpxchg8b (%esi)
27192 jne 1b
27193
27194 -10:
27195 movl %ebx, %eax
27196 movl %ecx, %edx
27197 +
27198 +.ifb \unchecked
27199 +#ifdef CONFIG_PAX_REFCOUNT
27200 +3:
27201 +#endif
27202 +.endif
27203 +
27204 RESTORE ebx
27205 + pax_force_retaddr
27206 ret
27207 CFI_ENDPROC
27208 -ENDPROC(atomic64_\func\()_return_cx8)
27209 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27210 .endm
27211
27212 incdec_return inc add adc
27213 incdec_return dec sub sbb
27214 +incdec_return inc add adc _unchecked
27215 +incdec_return dec sub sbb _unchecked
27216
27217 ENTRY(atomic64_dec_if_positive_cx8)
27218 CFI_STARTPROC
27219 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27220 movl %edx, %ecx
27221 subl $1, %ebx
27222 sbb $0, %ecx
27223 +
27224 +#ifdef CONFIG_PAX_REFCOUNT
27225 + into
27226 +1234:
27227 + _ASM_EXTABLE(1234b, 2f)
27228 +#endif
27229 +
27230 js 2f
27231 LOCK_PREFIX
27232 cmpxchg8b (%esi)
27233 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27234 movl %ebx, %eax
27235 movl %ecx, %edx
27236 RESTORE ebx
27237 + pax_force_retaddr
27238 ret
27239 CFI_ENDPROC
27240 ENDPROC(atomic64_dec_if_positive_cx8)
27241 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27242 movl %edx, %ecx
27243 addl %ebp, %ebx
27244 adcl %edi, %ecx
27245 +
27246 +#ifdef CONFIG_PAX_REFCOUNT
27247 + into
27248 +1234:
27249 + _ASM_EXTABLE(1234b, 3f)
27250 +#endif
27251 +
27252 LOCK_PREFIX
27253 cmpxchg8b (%esi)
27254 jne 1b
27255 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27256 CFI_ADJUST_CFA_OFFSET -8
27257 RESTORE ebx
27258 RESTORE ebp
27259 + pax_force_retaddr
27260 ret
27261 4:
27262 cmpl %edx, 4(%esp)
27263 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27264 xorl %ecx, %ecx
27265 addl $1, %ebx
27266 adcl %edx, %ecx
27267 +
27268 +#ifdef CONFIG_PAX_REFCOUNT
27269 + into
27270 +1234:
27271 + _ASM_EXTABLE(1234b, 3f)
27272 +#endif
27273 +
27274 LOCK_PREFIX
27275 cmpxchg8b (%esi)
27276 jne 1b
27277 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27278 movl $1, %eax
27279 3:
27280 RESTORE ebx
27281 + pax_force_retaddr
27282 ret
27283 CFI_ENDPROC
27284 ENDPROC(atomic64_inc_not_zero_cx8)
27285 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27286 index e78b8ee..7e173a8 100644
27287 --- a/arch/x86/lib/checksum_32.S
27288 +++ b/arch/x86/lib/checksum_32.S
27289 @@ -29,7 +29,8 @@
27290 #include <asm/dwarf2.h>
27291 #include <asm/errno.h>
27292 #include <asm/asm.h>
27293 -
27294 +#include <asm/segment.h>
27295 +
27296 /*
27297 * computes a partial checksum, e.g. for TCP/UDP fragments
27298 */
27299 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27300
27301 #define ARGBASE 16
27302 #define FP 12
27303 -
27304 -ENTRY(csum_partial_copy_generic)
27305 +
27306 +ENTRY(csum_partial_copy_generic_to_user)
27307 CFI_STARTPROC
27308 +
27309 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27310 + pushl_cfi %gs
27311 + popl_cfi %es
27312 + jmp csum_partial_copy_generic
27313 +#endif
27314 +
27315 +ENTRY(csum_partial_copy_generic_from_user)
27316 +
27317 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27318 + pushl_cfi %gs
27319 + popl_cfi %ds
27320 +#endif
27321 +
27322 +ENTRY(csum_partial_copy_generic)
27323 subl $4,%esp
27324 CFI_ADJUST_CFA_OFFSET 4
27325 pushl_cfi %edi
27326 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27327 jmp 4f
27328 SRC(1: movw (%esi), %bx )
27329 addl $2, %esi
27330 -DST( movw %bx, (%edi) )
27331 +DST( movw %bx, %es:(%edi) )
27332 addl $2, %edi
27333 addw %bx, %ax
27334 adcl $0, %eax
27335 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27336 SRC(1: movl (%esi), %ebx )
27337 SRC( movl 4(%esi), %edx )
27338 adcl %ebx, %eax
27339 -DST( movl %ebx, (%edi) )
27340 +DST( movl %ebx, %es:(%edi) )
27341 adcl %edx, %eax
27342 -DST( movl %edx, 4(%edi) )
27343 +DST( movl %edx, %es:4(%edi) )
27344
27345 SRC( movl 8(%esi), %ebx )
27346 SRC( movl 12(%esi), %edx )
27347 adcl %ebx, %eax
27348 -DST( movl %ebx, 8(%edi) )
27349 +DST( movl %ebx, %es:8(%edi) )
27350 adcl %edx, %eax
27351 -DST( movl %edx, 12(%edi) )
27352 +DST( movl %edx, %es:12(%edi) )
27353
27354 SRC( movl 16(%esi), %ebx )
27355 SRC( movl 20(%esi), %edx )
27356 adcl %ebx, %eax
27357 -DST( movl %ebx, 16(%edi) )
27358 +DST( movl %ebx, %es:16(%edi) )
27359 adcl %edx, %eax
27360 -DST( movl %edx, 20(%edi) )
27361 +DST( movl %edx, %es:20(%edi) )
27362
27363 SRC( movl 24(%esi), %ebx )
27364 SRC( movl 28(%esi), %edx )
27365 adcl %ebx, %eax
27366 -DST( movl %ebx, 24(%edi) )
27367 +DST( movl %ebx, %es:24(%edi) )
27368 adcl %edx, %eax
27369 -DST( movl %edx, 28(%edi) )
27370 +DST( movl %edx, %es:28(%edi) )
27371
27372 lea 32(%esi), %esi
27373 lea 32(%edi), %edi
27374 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27375 shrl $2, %edx # This clears CF
27376 SRC(3: movl (%esi), %ebx )
27377 adcl %ebx, %eax
27378 -DST( movl %ebx, (%edi) )
27379 +DST( movl %ebx, %es:(%edi) )
27380 lea 4(%esi), %esi
27381 lea 4(%edi), %edi
27382 dec %edx
27383 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27384 jb 5f
27385 SRC( movw (%esi), %cx )
27386 leal 2(%esi), %esi
27387 -DST( movw %cx, (%edi) )
27388 +DST( movw %cx, %es:(%edi) )
27389 leal 2(%edi), %edi
27390 je 6f
27391 shll $16,%ecx
27392 SRC(5: movb (%esi), %cl )
27393 -DST( movb %cl, (%edi) )
27394 +DST( movb %cl, %es:(%edi) )
27395 6: addl %ecx, %eax
27396 adcl $0, %eax
27397 7:
27398 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27399
27400 6001:
27401 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27402 - movl $-EFAULT, (%ebx)
27403 + movl $-EFAULT, %ss:(%ebx)
27404
27405 # zero the complete destination - computing the rest
27406 # is too much work
27407 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27408
27409 6002:
27410 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27411 - movl $-EFAULT,(%ebx)
27412 + movl $-EFAULT,%ss:(%ebx)
27413 jmp 5000b
27414
27415 .previous
27416
27417 + pushl_cfi %ss
27418 + popl_cfi %ds
27419 + pushl_cfi %ss
27420 + popl_cfi %es
27421 popl_cfi %ebx
27422 CFI_RESTORE ebx
27423 popl_cfi %esi
27424 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27425 popl_cfi %ecx # equivalent to addl $4,%esp
27426 ret
27427 CFI_ENDPROC
27428 -ENDPROC(csum_partial_copy_generic)
27429 +ENDPROC(csum_partial_copy_generic_to_user)
27430
27431 #else
27432
27433 /* Version for PentiumII/PPro */
27434
27435 #define ROUND1(x) \
27436 + nop; nop; nop; \
27437 SRC(movl x(%esi), %ebx ) ; \
27438 addl %ebx, %eax ; \
27439 - DST(movl %ebx, x(%edi) ) ;
27440 + DST(movl %ebx, %es:x(%edi)) ;
27441
27442 #define ROUND(x) \
27443 + nop; nop; nop; \
27444 SRC(movl x(%esi), %ebx ) ; \
27445 adcl %ebx, %eax ; \
27446 - DST(movl %ebx, x(%edi) ) ;
27447 + DST(movl %ebx, %es:x(%edi)) ;
27448
27449 #define ARGBASE 12
27450 -
27451 -ENTRY(csum_partial_copy_generic)
27452 +
27453 +ENTRY(csum_partial_copy_generic_to_user)
27454 CFI_STARTPROC
27455 +
27456 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27457 + pushl_cfi %gs
27458 + popl_cfi %es
27459 + jmp csum_partial_copy_generic
27460 +#endif
27461 +
27462 +ENTRY(csum_partial_copy_generic_from_user)
27463 +
27464 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27465 + pushl_cfi %gs
27466 + popl_cfi %ds
27467 +#endif
27468 +
27469 +ENTRY(csum_partial_copy_generic)
27470 pushl_cfi %ebx
27471 CFI_REL_OFFSET ebx, 0
27472 pushl_cfi %edi
27473 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27474 subl %ebx, %edi
27475 lea -1(%esi),%edx
27476 andl $-32,%edx
27477 - lea 3f(%ebx,%ebx), %ebx
27478 + lea 3f(%ebx,%ebx,2), %ebx
27479 testl %esi, %esi
27480 jmp *%ebx
27481 1: addl $64,%esi
27482 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27483 jb 5f
27484 SRC( movw (%esi), %dx )
27485 leal 2(%esi), %esi
27486 -DST( movw %dx, (%edi) )
27487 +DST( movw %dx, %es:(%edi) )
27488 leal 2(%edi), %edi
27489 je 6f
27490 shll $16,%edx
27491 5:
27492 SRC( movb (%esi), %dl )
27493 -DST( movb %dl, (%edi) )
27494 +DST( movb %dl, %es:(%edi) )
27495 6: addl %edx, %eax
27496 adcl $0, %eax
27497 7:
27498 .section .fixup, "ax"
27499 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27500 - movl $-EFAULT, (%ebx)
27501 + movl $-EFAULT, %ss:(%ebx)
27502 # zero the complete destination (computing the rest is too much work)
27503 movl ARGBASE+8(%esp),%edi # dst
27504 movl ARGBASE+12(%esp),%ecx # len
27505 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27506 rep; stosb
27507 jmp 7b
27508 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27509 - movl $-EFAULT, (%ebx)
27510 + movl $-EFAULT, %ss:(%ebx)
27511 jmp 7b
27512 .previous
27513
27514 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27515 + pushl_cfi %ss
27516 + popl_cfi %ds
27517 + pushl_cfi %ss
27518 + popl_cfi %es
27519 +#endif
27520 +
27521 popl_cfi %esi
27522 CFI_RESTORE esi
27523 popl_cfi %edi
27524 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27525 CFI_RESTORE ebx
27526 ret
27527 CFI_ENDPROC
27528 -ENDPROC(csum_partial_copy_generic)
27529 +ENDPROC(csum_partial_copy_generic_to_user)
27530
27531 #undef ROUND
27532 #undef ROUND1
27533 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27534 index f2145cf..cea889d 100644
27535 --- a/arch/x86/lib/clear_page_64.S
27536 +++ b/arch/x86/lib/clear_page_64.S
27537 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27538 movl $4096/8,%ecx
27539 xorl %eax,%eax
27540 rep stosq
27541 + pax_force_retaddr
27542 ret
27543 CFI_ENDPROC
27544 ENDPROC(clear_page_c)
27545 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27546 movl $4096,%ecx
27547 xorl %eax,%eax
27548 rep stosb
27549 + pax_force_retaddr
27550 ret
27551 CFI_ENDPROC
27552 ENDPROC(clear_page_c_e)
27553 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27554 leaq 64(%rdi),%rdi
27555 jnz .Lloop
27556 nop
27557 + pax_force_retaddr
27558 ret
27559 CFI_ENDPROC
27560 .Lclear_page_end:
27561 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27562
27563 #include <asm/cpufeature.h>
27564
27565 - .section .altinstr_replacement,"ax"
27566 + .section .altinstr_replacement,"a"
27567 1: .byte 0xeb /* jmp <disp8> */
27568 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27569 2: .byte 0xeb /* jmp <disp8> */
27570 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27571 index 1e572c5..2a162cd 100644
27572 --- a/arch/x86/lib/cmpxchg16b_emu.S
27573 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27574 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27575
27576 popf
27577 mov $1, %al
27578 + pax_force_retaddr
27579 ret
27580
27581 not_same:
27582 popf
27583 xor %al,%al
27584 + pax_force_retaddr
27585 ret
27586
27587 CFI_ENDPROC
27588 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27589 index 176cca6..1166c50 100644
27590 --- a/arch/x86/lib/copy_page_64.S
27591 +++ b/arch/x86/lib/copy_page_64.S
27592 @@ -9,6 +9,7 @@ copy_page_rep:
27593 CFI_STARTPROC
27594 movl $4096/8, %ecx
27595 rep movsq
27596 + pax_force_retaddr
27597 ret
27598 CFI_ENDPROC
27599 ENDPROC(copy_page_rep)
27600 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27601
27602 ENTRY(copy_page)
27603 CFI_STARTPROC
27604 - subq $2*8, %rsp
27605 - CFI_ADJUST_CFA_OFFSET 2*8
27606 + subq $3*8, %rsp
27607 + CFI_ADJUST_CFA_OFFSET 3*8
27608 movq %rbx, (%rsp)
27609 CFI_REL_OFFSET rbx, 0
27610 movq %r12, 1*8(%rsp)
27611 CFI_REL_OFFSET r12, 1*8
27612 + movq %r13, 2*8(%rsp)
27613 + CFI_REL_OFFSET r13, 2*8
27614
27615 movl $(4096/64)-5, %ecx
27616 .p2align 4
27617 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27618 movq 0x8*2(%rsi), %rdx
27619 movq 0x8*3(%rsi), %r8
27620 movq 0x8*4(%rsi), %r9
27621 - movq 0x8*5(%rsi), %r10
27622 + movq 0x8*5(%rsi), %r13
27623 movq 0x8*6(%rsi), %r11
27624 movq 0x8*7(%rsi), %r12
27625
27626 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27627 movq %rdx, 0x8*2(%rdi)
27628 movq %r8, 0x8*3(%rdi)
27629 movq %r9, 0x8*4(%rdi)
27630 - movq %r10, 0x8*5(%rdi)
27631 + movq %r13, 0x8*5(%rdi)
27632 movq %r11, 0x8*6(%rdi)
27633 movq %r12, 0x8*7(%rdi)
27634
27635 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27636 movq 0x8*2(%rsi), %rdx
27637 movq 0x8*3(%rsi), %r8
27638 movq 0x8*4(%rsi), %r9
27639 - movq 0x8*5(%rsi), %r10
27640 + movq 0x8*5(%rsi), %r13
27641 movq 0x8*6(%rsi), %r11
27642 movq 0x8*7(%rsi), %r12
27643
27644 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27645 movq %rdx, 0x8*2(%rdi)
27646 movq %r8, 0x8*3(%rdi)
27647 movq %r9, 0x8*4(%rdi)
27648 - movq %r10, 0x8*5(%rdi)
27649 + movq %r13, 0x8*5(%rdi)
27650 movq %r11, 0x8*6(%rdi)
27651 movq %r12, 0x8*7(%rdi)
27652
27653 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27654 CFI_RESTORE rbx
27655 movq 1*8(%rsp), %r12
27656 CFI_RESTORE r12
27657 - addq $2*8, %rsp
27658 - CFI_ADJUST_CFA_OFFSET -2*8
27659 + movq 2*8(%rsp), %r13
27660 + CFI_RESTORE r13
27661 + addq $3*8, %rsp
27662 + CFI_ADJUST_CFA_OFFSET -3*8
27663 + pax_force_retaddr
27664 ret
27665 .Lcopy_page_end:
27666 CFI_ENDPROC
27667 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27668
27669 #include <asm/cpufeature.h>
27670
27671 - .section .altinstr_replacement,"ax"
27672 + .section .altinstr_replacement,"a"
27673 1: .byte 0xeb /* jmp <disp8> */
27674 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27675 2:
27676 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27677 index a30ca15..6b3f4e1 100644
27678 --- a/arch/x86/lib/copy_user_64.S
27679 +++ b/arch/x86/lib/copy_user_64.S
27680 @@ -18,31 +18,7 @@
27681 #include <asm/alternative-asm.h>
27682 #include <asm/asm.h>
27683 #include <asm/smap.h>
27684 -
27685 -/*
27686 - * By placing feature2 after feature1 in altinstructions section, we logically
27687 - * implement:
27688 - * If CPU has feature2, jmp to alt2 is used
27689 - * else if CPU has feature1, jmp to alt1 is used
27690 - * else jmp to orig is used.
27691 - */
27692 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27693 -0:
27694 - .byte 0xe9 /* 32bit jump */
27695 - .long \orig-1f /* by default jump to orig */
27696 -1:
27697 - .section .altinstr_replacement,"ax"
27698 -2: .byte 0xe9 /* near jump with 32bit immediate */
27699 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27700 -3: .byte 0xe9 /* near jump with 32bit immediate */
27701 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27702 - .previous
27703 -
27704 - .section .altinstructions,"a"
27705 - altinstruction_entry 0b,2b,\feature1,5,5
27706 - altinstruction_entry 0b,3b,\feature2,5,5
27707 - .previous
27708 - .endm
27709 +#include <asm/pgtable.h>
27710
27711 .macro ALIGN_DESTINATION
27712 #ifdef FIX_ALIGNMENT
27713 @@ -70,52 +46,6 @@
27714 #endif
27715 .endm
27716
27717 -/* Standard copy_to_user with segment limit checking */
27718 -ENTRY(_copy_to_user)
27719 - CFI_STARTPROC
27720 - GET_THREAD_INFO(%rax)
27721 - movq %rdi,%rcx
27722 - addq %rdx,%rcx
27723 - jc bad_to_user
27724 - cmpq TI_addr_limit(%rax),%rcx
27725 - ja bad_to_user
27726 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27727 - copy_user_generic_unrolled,copy_user_generic_string, \
27728 - copy_user_enhanced_fast_string
27729 - CFI_ENDPROC
27730 -ENDPROC(_copy_to_user)
27731 -
27732 -/* Standard copy_from_user with segment limit checking */
27733 -ENTRY(_copy_from_user)
27734 - CFI_STARTPROC
27735 - GET_THREAD_INFO(%rax)
27736 - movq %rsi,%rcx
27737 - addq %rdx,%rcx
27738 - jc bad_from_user
27739 - cmpq TI_addr_limit(%rax),%rcx
27740 - ja bad_from_user
27741 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27742 - copy_user_generic_unrolled,copy_user_generic_string, \
27743 - copy_user_enhanced_fast_string
27744 - CFI_ENDPROC
27745 -ENDPROC(_copy_from_user)
27746 -
27747 - .section .fixup,"ax"
27748 - /* must zero dest */
27749 -ENTRY(bad_from_user)
27750 -bad_from_user:
27751 - CFI_STARTPROC
27752 - movl %edx,%ecx
27753 - xorl %eax,%eax
27754 - rep
27755 - stosb
27756 -bad_to_user:
27757 - movl %edx,%eax
27758 - ret
27759 - CFI_ENDPROC
27760 -ENDPROC(bad_from_user)
27761 - .previous
27762 -
27763 /*
27764 * copy_user_generic_unrolled - memory copy with exception handling.
27765 * This version is for CPUs like P4 that don't have efficient micro
27766 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27767 */
27768 ENTRY(copy_user_generic_unrolled)
27769 CFI_STARTPROC
27770 + ASM_PAX_OPEN_USERLAND
27771 ASM_STAC
27772 cmpl $8,%edx
27773 jb 20f /* less then 8 bytes, go to byte copy loop */
27774 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27775 jz 17f
27776 1: movq (%rsi),%r8
27777 2: movq 1*8(%rsi),%r9
27778 -3: movq 2*8(%rsi),%r10
27779 +3: movq 2*8(%rsi),%rax
27780 4: movq 3*8(%rsi),%r11
27781 5: movq %r8,(%rdi)
27782 6: movq %r9,1*8(%rdi)
27783 -7: movq %r10,2*8(%rdi)
27784 +7: movq %rax,2*8(%rdi)
27785 8: movq %r11,3*8(%rdi)
27786 9: movq 4*8(%rsi),%r8
27787 10: movq 5*8(%rsi),%r9
27788 -11: movq 6*8(%rsi),%r10
27789 +11: movq 6*8(%rsi),%rax
27790 12: movq 7*8(%rsi),%r11
27791 13: movq %r8,4*8(%rdi)
27792 14: movq %r9,5*8(%rdi)
27793 -15: movq %r10,6*8(%rdi)
27794 +15: movq %rax,6*8(%rdi)
27795 16: movq %r11,7*8(%rdi)
27796 leaq 64(%rsi),%rsi
27797 leaq 64(%rdi),%rdi
27798 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27799 jnz 21b
27800 23: xor %eax,%eax
27801 ASM_CLAC
27802 + ASM_PAX_CLOSE_USERLAND
27803 + pax_force_retaddr
27804 ret
27805
27806 .section .fixup,"ax"
27807 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27808 */
27809 ENTRY(copy_user_generic_string)
27810 CFI_STARTPROC
27811 + ASM_PAX_OPEN_USERLAND
27812 ASM_STAC
27813 andl %edx,%edx
27814 jz 4f
27815 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27816 movsb
27817 4: xorl %eax,%eax
27818 ASM_CLAC
27819 + ASM_PAX_CLOSE_USERLAND
27820 + pax_force_retaddr
27821 ret
27822
27823 .section .fixup,"ax"
27824 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27825 */
27826 ENTRY(copy_user_enhanced_fast_string)
27827 CFI_STARTPROC
27828 + ASM_PAX_OPEN_USERLAND
27829 ASM_STAC
27830 andl %edx,%edx
27831 jz 2f
27832 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27833 movsb
27834 2: xorl %eax,%eax
27835 ASM_CLAC
27836 + ASM_PAX_CLOSE_USERLAND
27837 + pax_force_retaddr
27838 ret
27839
27840 .section .fixup,"ax"
27841 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27842 index 6a4f43c..55d26f2 100644
27843 --- a/arch/x86/lib/copy_user_nocache_64.S
27844 +++ b/arch/x86/lib/copy_user_nocache_64.S
27845 @@ -8,6 +8,7 @@
27846
27847 #include <linux/linkage.h>
27848 #include <asm/dwarf2.h>
27849 +#include <asm/alternative-asm.h>
27850
27851 #define FIX_ALIGNMENT 1
27852
27853 @@ -16,6 +17,7 @@
27854 #include <asm/thread_info.h>
27855 #include <asm/asm.h>
27856 #include <asm/smap.h>
27857 +#include <asm/pgtable.h>
27858
27859 .macro ALIGN_DESTINATION
27860 #ifdef FIX_ALIGNMENT
27861 @@ -49,6 +51,16 @@
27862 */
27863 ENTRY(__copy_user_nocache)
27864 CFI_STARTPROC
27865 +
27866 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27867 + mov pax_user_shadow_base,%rcx
27868 + cmp %rcx,%rsi
27869 + jae 1f
27870 + add %rcx,%rsi
27871 +1:
27872 +#endif
27873 +
27874 + ASM_PAX_OPEN_USERLAND
27875 ASM_STAC
27876 cmpl $8,%edx
27877 jb 20f /* less then 8 bytes, go to byte copy loop */
27878 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27879 jz 17f
27880 1: movq (%rsi),%r8
27881 2: movq 1*8(%rsi),%r9
27882 -3: movq 2*8(%rsi),%r10
27883 +3: movq 2*8(%rsi),%rax
27884 4: movq 3*8(%rsi),%r11
27885 5: movnti %r8,(%rdi)
27886 6: movnti %r9,1*8(%rdi)
27887 -7: movnti %r10,2*8(%rdi)
27888 +7: movnti %rax,2*8(%rdi)
27889 8: movnti %r11,3*8(%rdi)
27890 9: movq 4*8(%rsi),%r8
27891 10: movq 5*8(%rsi),%r9
27892 -11: movq 6*8(%rsi),%r10
27893 +11: movq 6*8(%rsi),%rax
27894 12: movq 7*8(%rsi),%r11
27895 13: movnti %r8,4*8(%rdi)
27896 14: movnti %r9,5*8(%rdi)
27897 -15: movnti %r10,6*8(%rdi)
27898 +15: movnti %rax,6*8(%rdi)
27899 16: movnti %r11,7*8(%rdi)
27900 leaq 64(%rsi),%rsi
27901 leaq 64(%rdi),%rdi
27902 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27903 jnz 21b
27904 23: xorl %eax,%eax
27905 ASM_CLAC
27906 + ASM_PAX_CLOSE_USERLAND
27907 sfence
27908 + pax_force_retaddr
27909 ret
27910
27911 .section .fixup,"ax"
27912 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27913 index 2419d5f..953ee51 100644
27914 --- a/arch/x86/lib/csum-copy_64.S
27915 +++ b/arch/x86/lib/csum-copy_64.S
27916 @@ -9,6 +9,7 @@
27917 #include <asm/dwarf2.h>
27918 #include <asm/errno.h>
27919 #include <asm/asm.h>
27920 +#include <asm/alternative-asm.h>
27921
27922 /*
27923 * Checksum copy with exception handling.
27924 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27925 CFI_RESTORE rbp
27926 addq $7*8, %rsp
27927 CFI_ADJUST_CFA_OFFSET -7*8
27928 + pax_force_retaddr 0, 1
27929 ret
27930 CFI_RESTORE_STATE
27931
27932 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27933 index 7609e0e..b449b98 100644
27934 --- a/arch/x86/lib/csum-wrappers_64.c
27935 +++ b/arch/x86/lib/csum-wrappers_64.c
27936 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27937 len -= 2;
27938 }
27939 }
27940 + pax_open_userland();
27941 stac();
27942 - isum = csum_partial_copy_generic((__force const void *)src,
27943 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27944 dst, len, isum, errp, NULL);
27945 clac();
27946 + pax_close_userland();
27947 if (unlikely(*errp))
27948 goto out_err;
27949
27950 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27951 }
27952
27953 *errp = 0;
27954 + pax_open_userland();
27955 stac();
27956 - ret = csum_partial_copy_generic(src, (void __force *)dst,
27957 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27958 len, isum, NULL, errp);
27959 clac();
27960 + pax_close_userland();
27961 return ret;
27962 }
27963 EXPORT_SYMBOL(csum_partial_copy_to_user);
27964 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
27965 index a451235..1daa956 100644
27966 --- a/arch/x86/lib/getuser.S
27967 +++ b/arch/x86/lib/getuser.S
27968 @@ -33,17 +33,40 @@
27969 #include <asm/thread_info.h>
27970 #include <asm/asm.h>
27971 #include <asm/smap.h>
27972 +#include <asm/segment.h>
27973 +#include <asm/pgtable.h>
27974 +#include <asm/alternative-asm.h>
27975 +
27976 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27977 +#define __copyuser_seg gs;
27978 +#else
27979 +#define __copyuser_seg
27980 +#endif
27981
27982 .text
27983 ENTRY(__get_user_1)
27984 CFI_STARTPROC
27985 +
27986 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27987 GET_THREAD_INFO(%_ASM_DX)
27988 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27989 jae bad_get_user
27990 ASM_STAC
27991 -1: movzbl (%_ASM_AX),%edx
27992 +
27993 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27994 + mov pax_user_shadow_base,%_ASM_DX
27995 + cmp %_ASM_DX,%_ASM_AX
27996 + jae 1234f
27997 + add %_ASM_DX,%_ASM_AX
27998 +1234:
27999 +#endif
28000 +
28001 +#endif
28002 +
28003 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28004 xor %eax,%eax
28005 ASM_CLAC
28006 + pax_force_retaddr
28007 ret
28008 CFI_ENDPROC
28009 ENDPROC(__get_user_1)
28010 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28011 ENTRY(__get_user_2)
28012 CFI_STARTPROC
28013 add $1,%_ASM_AX
28014 +
28015 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28016 jc bad_get_user
28017 GET_THREAD_INFO(%_ASM_DX)
28018 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28019 jae bad_get_user
28020 ASM_STAC
28021 -2: movzwl -1(%_ASM_AX),%edx
28022 +
28023 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28024 + mov pax_user_shadow_base,%_ASM_DX
28025 + cmp %_ASM_DX,%_ASM_AX
28026 + jae 1234f
28027 + add %_ASM_DX,%_ASM_AX
28028 +1234:
28029 +#endif
28030 +
28031 +#endif
28032 +
28033 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28034 xor %eax,%eax
28035 ASM_CLAC
28036 + pax_force_retaddr
28037 ret
28038 CFI_ENDPROC
28039 ENDPROC(__get_user_2)
28040 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28041 ENTRY(__get_user_4)
28042 CFI_STARTPROC
28043 add $3,%_ASM_AX
28044 +
28045 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28046 jc bad_get_user
28047 GET_THREAD_INFO(%_ASM_DX)
28048 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28049 jae bad_get_user
28050 ASM_STAC
28051 -3: movl -3(%_ASM_AX),%edx
28052 +
28053 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28054 + mov pax_user_shadow_base,%_ASM_DX
28055 + cmp %_ASM_DX,%_ASM_AX
28056 + jae 1234f
28057 + add %_ASM_DX,%_ASM_AX
28058 +1234:
28059 +#endif
28060 +
28061 +#endif
28062 +
28063 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28064 xor %eax,%eax
28065 ASM_CLAC
28066 + pax_force_retaddr
28067 ret
28068 CFI_ENDPROC
28069 ENDPROC(__get_user_4)
28070 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28071 GET_THREAD_INFO(%_ASM_DX)
28072 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28073 jae bad_get_user
28074 +
28075 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28076 + mov pax_user_shadow_base,%_ASM_DX
28077 + cmp %_ASM_DX,%_ASM_AX
28078 + jae 1234f
28079 + add %_ASM_DX,%_ASM_AX
28080 +1234:
28081 +#endif
28082 +
28083 ASM_STAC
28084 4: movq -7(%_ASM_AX),%rdx
28085 xor %eax,%eax
28086 ASM_CLAC
28087 + pax_force_retaddr
28088 ret
28089 #else
28090 add $7,%_ASM_AX
28091 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28092 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28093 jae bad_get_user_8
28094 ASM_STAC
28095 -4: movl -7(%_ASM_AX),%edx
28096 -5: movl -3(%_ASM_AX),%ecx
28097 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28098 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28099 xor %eax,%eax
28100 ASM_CLAC
28101 + pax_force_retaddr
28102 ret
28103 #endif
28104 CFI_ENDPROC
28105 @@ -113,6 +175,7 @@ bad_get_user:
28106 xor %edx,%edx
28107 mov $(-EFAULT),%_ASM_AX
28108 ASM_CLAC
28109 + pax_force_retaddr
28110 ret
28111 CFI_ENDPROC
28112 END(bad_get_user)
28113 @@ -124,6 +187,7 @@ bad_get_user_8:
28114 xor %ecx,%ecx
28115 mov $(-EFAULT),%_ASM_AX
28116 ASM_CLAC
28117 + pax_force_retaddr
28118 ret
28119 CFI_ENDPROC
28120 END(bad_get_user_8)
28121 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28122 index 54fcffe..7be149e 100644
28123 --- a/arch/x86/lib/insn.c
28124 +++ b/arch/x86/lib/insn.c
28125 @@ -20,8 +20,10 @@
28126
28127 #ifdef __KERNEL__
28128 #include <linux/string.h>
28129 +#include <asm/pgtable_types.h>
28130 #else
28131 #include <string.h>
28132 +#define ktla_ktva(addr) addr
28133 #endif
28134 #include <asm/inat.h>
28135 #include <asm/insn.h>
28136 @@ -53,8 +55,8 @@
28137 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28138 {
28139 memset(insn, 0, sizeof(*insn));
28140 - insn->kaddr = kaddr;
28141 - insn->next_byte = kaddr;
28142 + insn->kaddr = ktla_ktva(kaddr);
28143 + insn->next_byte = ktla_ktva(kaddr);
28144 insn->x86_64 = x86_64 ? 1 : 0;
28145 insn->opnd_bytes = 4;
28146 if (x86_64)
28147 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28148 index 05a95e7..326f2fa 100644
28149 --- a/arch/x86/lib/iomap_copy_64.S
28150 +++ b/arch/x86/lib/iomap_copy_64.S
28151 @@ -17,6 +17,7 @@
28152
28153 #include <linux/linkage.h>
28154 #include <asm/dwarf2.h>
28155 +#include <asm/alternative-asm.h>
28156
28157 /*
28158 * override generic version in lib/iomap_copy.c
28159 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28160 CFI_STARTPROC
28161 movl %edx,%ecx
28162 rep movsd
28163 + pax_force_retaddr
28164 ret
28165 CFI_ENDPROC
28166 ENDPROC(__iowrite32_copy)
28167 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28168 index 56313a3..9b59269 100644
28169 --- a/arch/x86/lib/memcpy_64.S
28170 +++ b/arch/x86/lib/memcpy_64.S
28171 @@ -24,7 +24,7 @@
28172 * This gets patched over the unrolled variant (below) via the
28173 * alternative instructions framework:
28174 */
28175 - .section .altinstr_replacement, "ax", @progbits
28176 + .section .altinstr_replacement, "a", @progbits
28177 .Lmemcpy_c:
28178 movq %rdi, %rax
28179 movq %rdx, %rcx
28180 @@ -33,6 +33,7 @@
28181 rep movsq
28182 movl %edx, %ecx
28183 rep movsb
28184 + pax_force_retaddr
28185 ret
28186 .Lmemcpy_e:
28187 .previous
28188 @@ -44,11 +45,12 @@
28189 * This gets patched over the unrolled variant (below) via the
28190 * alternative instructions framework:
28191 */
28192 - .section .altinstr_replacement, "ax", @progbits
28193 + .section .altinstr_replacement, "a", @progbits
28194 .Lmemcpy_c_e:
28195 movq %rdi, %rax
28196 movq %rdx, %rcx
28197 rep movsb
28198 + pax_force_retaddr
28199 ret
28200 .Lmemcpy_e_e:
28201 .previous
28202 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28203 */
28204 movq 0*8(%rsi), %r8
28205 movq 1*8(%rsi), %r9
28206 - movq 2*8(%rsi), %r10
28207 + movq 2*8(%rsi), %rcx
28208 movq 3*8(%rsi), %r11
28209 leaq 4*8(%rsi), %rsi
28210
28211 movq %r8, 0*8(%rdi)
28212 movq %r9, 1*8(%rdi)
28213 - movq %r10, 2*8(%rdi)
28214 + movq %rcx, 2*8(%rdi)
28215 movq %r11, 3*8(%rdi)
28216 leaq 4*8(%rdi), %rdi
28217 jae .Lcopy_forward_loop
28218 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28219 subq $0x20, %rdx
28220 movq -1*8(%rsi), %r8
28221 movq -2*8(%rsi), %r9
28222 - movq -3*8(%rsi), %r10
28223 + movq -3*8(%rsi), %rcx
28224 movq -4*8(%rsi), %r11
28225 leaq -4*8(%rsi), %rsi
28226 movq %r8, -1*8(%rdi)
28227 movq %r9, -2*8(%rdi)
28228 - movq %r10, -3*8(%rdi)
28229 + movq %rcx, -3*8(%rdi)
28230 movq %r11, -4*8(%rdi)
28231 leaq -4*8(%rdi), %rdi
28232 jae .Lcopy_backward_loop
28233 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28234 */
28235 movq 0*8(%rsi), %r8
28236 movq 1*8(%rsi), %r9
28237 - movq -2*8(%rsi, %rdx), %r10
28238 + movq -2*8(%rsi, %rdx), %rcx
28239 movq -1*8(%rsi, %rdx), %r11
28240 movq %r8, 0*8(%rdi)
28241 movq %r9, 1*8(%rdi)
28242 - movq %r10, -2*8(%rdi, %rdx)
28243 + movq %rcx, -2*8(%rdi, %rdx)
28244 movq %r11, -1*8(%rdi, %rdx)
28245 + pax_force_retaddr
28246 retq
28247 .p2align 4
28248 .Lless_16bytes:
28249 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28250 movq -1*8(%rsi, %rdx), %r9
28251 movq %r8, 0*8(%rdi)
28252 movq %r9, -1*8(%rdi, %rdx)
28253 + pax_force_retaddr
28254 retq
28255 .p2align 4
28256 .Lless_8bytes:
28257 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28258 movl -4(%rsi, %rdx), %r8d
28259 movl %ecx, (%rdi)
28260 movl %r8d, -4(%rdi, %rdx)
28261 + pax_force_retaddr
28262 retq
28263 .p2align 4
28264 .Lless_3bytes:
28265 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28266 movb %cl, (%rdi)
28267
28268 .Lend:
28269 + pax_force_retaddr
28270 retq
28271 CFI_ENDPROC
28272 ENDPROC(memcpy)
28273 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28274 index 65268a6..5aa7815 100644
28275 --- a/arch/x86/lib/memmove_64.S
28276 +++ b/arch/x86/lib/memmove_64.S
28277 @@ -61,13 +61,13 @@ ENTRY(memmove)
28278 5:
28279 sub $0x20, %rdx
28280 movq 0*8(%rsi), %r11
28281 - movq 1*8(%rsi), %r10
28282 + movq 1*8(%rsi), %rcx
28283 movq 2*8(%rsi), %r9
28284 movq 3*8(%rsi), %r8
28285 leaq 4*8(%rsi), %rsi
28286
28287 movq %r11, 0*8(%rdi)
28288 - movq %r10, 1*8(%rdi)
28289 + movq %rcx, 1*8(%rdi)
28290 movq %r9, 2*8(%rdi)
28291 movq %r8, 3*8(%rdi)
28292 leaq 4*8(%rdi), %rdi
28293 @@ -81,10 +81,10 @@ ENTRY(memmove)
28294 4:
28295 movq %rdx, %rcx
28296 movq -8(%rsi, %rdx), %r11
28297 - lea -8(%rdi, %rdx), %r10
28298 + lea -8(%rdi, %rdx), %r9
28299 shrq $3, %rcx
28300 rep movsq
28301 - movq %r11, (%r10)
28302 + movq %r11, (%r9)
28303 jmp 13f
28304 .Lmemmove_end_forward:
28305
28306 @@ -95,14 +95,14 @@ ENTRY(memmove)
28307 7:
28308 movq %rdx, %rcx
28309 movq (%rsi), %r11
28310 - movq %rdi, %r10
28311 + movq %rdi, %r9
28312 leaq -8(%rsi, %rdx), %rsi
28313 leaq -8(%rdi, %rdx), %rdi
28314 shrq $3, %rcx
28315 std
28316 rep movsq
28317 cld
28318 - movq %r11, (%r10)
28319 + movq %r11, (%r9)
28320 jmp 13f
28321
28322 /*
28323 @@ -127,13 +127,13 @@ ENTRY(memmove)
28324 8:
28325 subq $0x20, %rdx
28326 movq -1*8(%rsi), %r11
28327 - movq -2*8(%rsi), %r10
28328 + movq -2*8(%rsi), %rcx
28329 movq -3*8(%rsi), %r9
28330 movq -4*8(%rsi), %r8
28331 leaq -4*8(%rsi), %rsi
28332
28333 movq %r11, -1*8(%rdi)
28334 - movq %r10, -2*8(%rdi)
28335 + movq %rcx, -2*8(%rdi)
28336 movq %r9, -3*8(%rdi)
28337 movq %r8, -4*8(%rdi)
28338 leaq -4*8(%rdi), %rdi
28339 @@ -151,11 +151,11 @@ ENTRY(memmove)
28340 * Move data from 16 bytes to 31 bytes.
28341 */
28342 movq 0*8(%rsi), %r11
28343 - movq 1*8(%rsi), %r10
28344 + movq 1*8(%rsi), %rcx
28345 movq -2*8(%rsi, %rdx), %r9
28346 movq -1*8(%rsi, %rdx), %r8
28347 movq %r11, 0*8(%rdi)
28348 - movq %r10, 1*8(%rdi)
28349 + movq %rcx, 1*8(%rdi)
28350 movq %r9, -2*8(%rdi, %rdx)
28351 movq %r8, -1*8(%rdi, %rdx)
28352 jmp 13f
28353 @@ -167,9 +167,9 @@ ENTRY(memmove)
28354 * Move data from 8 bytes to 15 bytes.
28355 */
28356 movq 0*8(%rsi), %r11
28357 - movq -1*8(%rsi, %rdx), %r10
28358 + movq -1*8(%rsi, %rdx), %r9
28359 movq %r11, 0*8(%rdi)
28360 - movq %r10, -1*8(%rdi, %rdx)
28361 + movq %r9, -1*8(%rdi, %rdx)
28362 jmp 13f
28363 10:
28364 cmpq $4, %rdx
28365 @@ -178,9 +178,9 @@ ENTRY(memmove)
28366 * Move data from 4 bytes to 7 bytes.
28367 */
28368 movl (%rsi), %r11d
28369 - movl -4(%rsi, %rdx), %r10d
28370 + movl -4(%rsi, %rdx), %r9d
28371 movl %r11d, (%rdi)
28372 - movl %r10d, -4(%rdi, %rdx)
28373 + movl %r9d, -4(%rdi, %rdx)
28374 jmp 13f
28375 11:
28376 cmp $2, %rdx
28377 @@ -189,9 +189,9 @@ ENTRY(memmove)
28378 * Move data from 2 bytes to 3 bytes.
28379 */
28380 movw (%rsi), %r11w
28381 - movw -2(%rsi, %rdx), %r10w
28382 + movw -2(%rsi, %rdx), %r9w
28383 movw %r11w, (%rdi)
28384 - movw %r10w, -2(%rdi, %rdx)
28385 + movw %r9w, -2(%rdi, %rdx)
28386 jmp 13f
28387 12:
28388 cmp $1, %rdx
28389 @@ -202,14 +202,16 @@ ENTRY(memmove)
28390 movb (%rsi), %r11b
28391 movb %r11b, (%rdi)
28392 13:
28393 + pax_force_retaddr
28394 retq
28395 CFI_ENDPROC
28396
28397 - .section .altinstr_replacement,"ax"
28398 + .section .altinstr_replacement,"a"
28399 .Lmemmove_begin_forward_efs:
28400 /* Forward moving data. */
28401 movq %rdx, %rcx
28402 rep movsb
28403 + pax_force_retaddr
28404 retq
28405 .Lmemmove_end_forward_efs:
28406 .previous
28407 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28408 index 2dcb380..50a78bc 100644
28409 --- a/arch/x86/lib/memset_64.S
28410 +++ b/arch/x86/lib/memset_64.S
28411 @@ -16,7 +16,7 @@
28412 *
28413 * rax original destination
28414 */
28415 - .section .altinstr_replacement, "ax", @progbits
28416 + .section .altinstr_replacement, "a", @progbits
28417 .Lmemset_c:
28418 movq %rdi,%r9
28419 movq %rdx,%rcx
28420 @@ -30,6 +30,7 @@
28421 movl %edx,%ecx
28422 rep stosb
28423 movq %r9,%rax
28424 + pax_force_retaddr
28425 ret
28426 .Lmemset_e:
28427 .previous
28428 @@ -45,13 +46,14 @@
28429 *
28430 * rax original destination
28431 */
28432 - .section .altinstr_replacement, "ax", @progbits
28433 + .section .altinstr_replacement, "a", @progbits
28434 .Lmemset_c_e:
28435 movq %rdi,%r9
28436 movb %sil,%al
28437 movq %rdx,%rcx
28438 rep stosb
28439 movq %r9,%rax
28440 + pax_force_retaddr
28441 ret
28442 .Lmemset_e_e:
28443 .previous
28444 @@ -59,7 +61,7 @@
28445 ENTRY(memset)
28446 ENTRY(__memset)
28447 CFI_STARTPROC
28448 - movq %rdi,%r10
28449 + movq %rdi,%r11
28450
28451 /* expand byte value */
28452 movzbl %sil,%ecx
28453 @@ -117,7 +119,8 @@ ENTRY(__memset)
28454 jnz .Lloop_1
28455
28456 .Lende:
28457 - movq %r10,%rax
28458 + movq %r11,%rax
28459 + pax_force_retaddr
28460 ret
28461
28462 CFI_RESTORE_STATE
28463 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28464 index c9f2d9b..e7fd2c0 100644
28465 --- a/arch/x86/lib/mmx_32.c
28466 +++ b/arch/x86/lib/mmx_32.c
28467 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28468 {
28469 void *p;
28470 int i;
28471 + unsigned long cr0;
28472
28473 if (unlikely(in_interrupt()))
28474 return __memcpy(to, from, len);
28475 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28476 kernel_fpu_begin();
28477
28478 __asm__ __volatile__ (
28479 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28480 - " prefetch 64(%0)\n"
28481 - " prefetch 128(%0)\n"
28482 - " prefetch 192(%0)\n"
28483 - " prefetch 256(%0)\n"
28484 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28485 + " prefetch 64(%1)\n"
28486 + " prefetch 128(%1)\n"
28487 + " prefetch 192(%1)\n"
28488 + " prefetch 256(%1)\n"
28489 "2: \n"
28490 ".section .fixup, \"ax\"\n"
28491 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28492 + "3: \n"
28493 +
28494 +#ifdef CONFIG_PAX_KERNEXEC
28495 + " movl %%cr0, %0\n"
28496 + " movl %0, %%eax\n"
28497 + " andl $0xFFFEFFFF, %%eax\n"
28498 + " movl %%eax, %%cr0\n"
28499 +#endif
28500 +
28501 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28502 +
28503 +#ifdef CONFIG_PAX_KERNEXEC
28504 + " movl %0, %%cr0\n"
28505 +#endif
28506 +
28507 " jmp 2b\n"
28508 ".previous\n"
28509 _ASM_EXTABLE(1b, 3b)
28510 - : : "r" (from));
28511 + : "=&r" (cr0) : "r" (from) : "ax");
28512
28513 for ( ; i > 5; i--) {
28514 __asm__ __volatile__ (
28515 - "1: prefetch 320(%0)\n"
28516 - "2: movq (%0), %%mm0\n"
28517 - " movq 8(%0), %%mm1\n"
28518 - " movq 16(%0), %%mm2\n"
28519 - " movq 24(%0), %%mm3\n"
28520 - " movq %%mm0, (%1)\n"
28521 - " movq %%mm1, 8(%1)\n"
28522 - " movq %%mm2, 16(%1)\n"
28523 - " movq %%mm3, 24(%1)\n"
28524 - " movq 32(%0), %%mm0\n"
28525 - " movq 40(%0), %%mm1\n"
28526 - " movq 48(%0), %%mm2\n"
28527 - " movq 56(%0), %%mm3\n"
28528 - " movq %%mm0, 32(%1)\n"
28529 - " movq %%mm1, 40(%1)\n"
28530 - " movq %%mm2, 48(%1)\n"
28531 - " movq %%mm3, 56(%1)\n"
28532 + "1: prefetch 320(%1)\n"
28533 + "2: movq (%1), %%mm0\n"
28534 + " movq 8(%1), %%mm1\n"
28535 + " movq 16(%1), %%mm2\n"
28536 + " movq 24(%1), %%mm3\n"
28537 + " movq %%mm0, (%2)\n"
28538 + " movq %%mm1, 8(%2)\n"
28539 + " movq %%mm2, 16(%2)\n"
28540 + " movq %%mm3, 24(%2)\n"
28541 + " movq 32(%1), %%mm0\n"
28542 + " movq 40(%1), %%mm1\n"
28543 + " movq 48(%1), %%mm2\n"
28544 + " movq 56(%1), %%mm3\n"
28545 + " movq %%mm0, 32(%2)\n"
28546 + " movq %%mm1, 40(%2)\n"
28547 + " movq %%mm2, 48(%2)\n"
28548 + " movq %%mm3, 56(%2)\n"
28549 ".section .fixup, \"ax\"\n"
28550 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28551 + "3:\n"
28552 +
28553 +#ifdef CONFIG_PAX_KERNEXEC
28554 + " movl %%cr0, %0\n"
28555 + " movl %0, %%eax\n"
28556 + " andl $0xFFFEFFFF, %%eax\n"
28557 + " movl %%eax, %%cr0\n"
28558 +#endif
28559 +
28560 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28561 +
28562 +#ifdef CONFIG_PAX_KERNEXEC
28563 + " movl %0, %%cr0\n"
28564 +#endif
28565 +
28566 " jmp 2b\n"
28567 ".previous\n"
28568 _ASM_EXTABLE(1b, 3b)
28569 - : : "r" (from), "r" (to) : "memory");
28570 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28571
28572 from += 64;
28573 to += 64;
28574 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28575 static void fast_copy_page(void *to, void *from)
28576 {
28577 int i;
28578 + unsigned long cr0;
28579
28580 kernel_fpu_begin();
28581
28582 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28583 * but that is for later. -AV
28584 */
28585 __asm__ __volatile__(
28586 - "1: prefetch (%0)\n"
28587 - " prefetch 64(%0)\n"
28588 - " prefetch 128(%0)\n"
28589 - " prefetch 192(%0)\n"
28590 - " prefetch 256(%0)\n"
28591 + "1: prefetch (%1)\n"
28592 + " prefetch 64(%1)\n"
28593 + " prefetch 128(%1)\n"
28594 + " prefetch 192(%1)\n"
28595 + " prefetch 256(%1)\n"
28596 "2: \n"
28597 ".section .fixup, \"ax\"\n"
28598 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28599 + "3: \n"
28600 +
28601 +#ifdef CONFIG_PAX_KERNEXEC
28602 + " movl %%cr0, %0\n"
28603 + " movl %0, %%eax\n"
28604 + " andl $0xFFFEFFFF, %%eax\n"
28605 + " movl %%eax, %%cr0\n"
28606 +#endif
28607 +
28608 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28609 +
28610 +#ifdef CONFIG_PAX_KERNEXEC
28611 + " movl %0, %%cr0\n"
28612 +#endif
28613 +
28614 " jmp 2b\n"
28615 ".previous\n"
28616 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28617 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28618
28619 for (i = 0; i < (4096-320)/64; i++) {
28620 __asm__ __volatile__ (
28621 - "1: prefetch 320(%0)\n"
28622 - "2: movq (%0), %%mm0\n"
28623 - " movntq %%mm0, (%1)\n"
28624 - " movq 8(%0), %%mm1\n"
28625 - " movntq %%mm1, 8(%1)\n"
28626 - " movq 16(%0), %%mm2\n"
28627 - " movntq %%mm2, 16(%1)\n"
28628 - " movq 24(%0), %%mm3\n"
28629 - " movntq %%mm3, 24(%1)\n"
28630 - " movq 32(%0), %%mm4\n"
28631 - " movntq %%mm4, 32(%1)\n"
28632 - " movq 40(%0), %%mm5\n"
28633 - " movntq %%mm5, 40(%1)\n"
28634 - " movq 48(%0), %%mm6\n"
28635 - " movntq %%mm6, 48(%1)\n"
28636 - " movq 56(%0), %%mm7\n"
28637 - " movntq %%mm7, 56(%1)\n"
28638 + "1: prefetch 320(%1)\n"
28639 + "2: movq (%1), %%mm0\n"
28640 + " movntq %%mm0, (%2)\n"
28641 + " movq 8(%1), %%mm1\n"
28642 + " movntq %%mm1, 8(%2)\n"
28643 + " movq 16(%1), %%mm2\n"
28644 + " movntq %%mm2, 16(%2)\n"
28645 + " movq 24(%1), %%mm3\n"
28646 + " movntq %%mm3, 24(%2)\n"
28647 + " movq 32(%1), %%mm4\n"
28648 + " movntq %%mm4, 32(%2)\n"
28649 + " movq 40(%1), %%mm5\n"
28650 + " movntq %%mm5, 40(%2)\n"
28651 + " movq 48(%1), %%mm6\n"
28652 + " movntq %%mm6, 48(%2)\n"
28653 + " movq 56(%1), %%mm7\n"
28654 + " movntq %%mm7, 56(%2)\n"
28655 ".section .fixup, \"ax\"\n"
28656 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28657 + "3:\n"
28658 +
28659 +#ifdef CONFIG_PAX_KERNEXEC
28660 + " movl %%cr0, %0\n"
28661 + " movl %0, %%eax\n"
28662 + " andl $0xFFFEFFFF, %%eax\n"
28663 + " movl %%eax, %%cr0\n"
28664 +#endif
28665 +
28666 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28667 +
28668 +#ifdef CONFIG_PAX_KERNEXEC
28669 + " movl %0, %%cr0\n"
28670 +#endif
28671 +
28672 " jmp 2b\n"
28673 ".previous\n"
28674 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28675 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28676
28677 from += 64;
28678 to += 64;
28679 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28680 static void fast_copy_page(void *to, void *from)
28681 {
28682 int i;
28683 + unsigned long cr0;
28684
28685 kernel_fpu_begin();
28686
28687 __asm__ __volatile__ (
28688 - "1: prefetch (%0)\n"
28689 - " prefetch 64(%0)\n"
28690 - " prefetch 128(%0)\n"
28691 - " prefetch 192(%0)\n"
28692 - " prefetch 256(%0)\n"
28693 + "1: prefetch (%1)\n"
28694 + " prefetch 64(%1)\n"
28695 + " prefetch 128(%1)\n"
28696 + " prefetch 192(%1)\n"
28697 + " prefetch 256(%1)\n"
28698 "2: \n"
28699 ".section .fixup, \"ax\"\n"
28700 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28701 + "3: \n"
28702 +
28703 +#ifdef CONFIG_PAX_KERNEXEC
28704 + " movl %%cr0, %0\n"
28705 + " movl %0, %%eax\n"
28706 + " andl $0xFFFEFFFF, %%eax\n"
28707 + " movl %%eax, %%cr0\n"
28708 +#endif
28709 +
28710 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28711 +
28712 +#ifdef CONFIG_PAX_KERNEXEC
28713 + " movl %0, %%cr0\n"
28714 +#endif
28715 +
28716 " jmp 2b\n"
28717 ".previous\n"
28718 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28719 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28720
28721 for (i = 0; i < 4096/64; i++) {
28722 __asm__ __volatile__ (
28723 - "1: prefetch 320(%0)\n"
28724 - "2: movq (%0), %%mm0\n"
28725 - " movq 8(%0), %%mm1\n"
28726 - " movq 16(%0), %%mm2\n"
28727 - " movq 24(%0), %%mm3\n"
28728 - " movq %%mm0, (%1)\n"
28729 - " movq %%mm1, 8(%1)\n"
28730 - " movq %%mm2, 16(%1)\n"
28731 - " movq %%mm3, 24(%1)\n"
28732 - " movq 32(%0), %%mm0\n"
28733 - " movq 40(%0), %%mm1\n"
28734 - " movq 48(%0), %%mm2\n"
28735 - " movq 56(%0), %%mm3\n"
28736 - " movq %%mm0, 32(%1)\n"
28737 - " movq %%mm1, 40(%1)\n"
28738 - " movq %%mm2, 48(%1)\n"
28739 - " movq %%mm3, 56(%1)\n"
28740 + "1: prefetch 320(%1)\n"
28741 + "2: movq (%1), %%mm0\n"
28742 + " movq 8(%1), %%mm1\n"
28743 + " movq 16(%1), %%mm2\n"
28744 + " movq 24(%1), %%mm3\n"
28745 + " movq %%mm0, (%2)\n"
28746 + " movq %%mm1, 8(%2)\n"
28747 + " movq %%mm2, 16(%2)\n"
28748 + " movq %%mm3, 24(%2)\n"
28749 + " movq 32(%1), %%mm0\n"
28750 + " movq 40(%1), %%mm1\n"
28751 + " movq 48(%1), %%mm2\n"
28752 + " movq 56(%1), %%mm3\n"
28753 + " movq %%mm0, 32(%2)\n"
28754 + " movq %%mm1, 40(%2)\n"
28755 + " movq %%mm2, 48(%2)\n"
28756 + " movq %%mm3, 56(%2)\n"
28757 ".section .fixup, \"ax\"\n"
28758 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28759 + "3:\n"
28760 +
28761 +#ifdef CONFIG_PAX_KERNEXEC
28762 + " movl %%cr0, %0\n"
28763 + " movl %0, %%eax\n"
28764 + " andl $0xFFFEFFFF, %%eax\n"
28765 + " movl %%eax, %%cr0\n"
28766 +#endif
28767 +
28768 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28769 +
28770 +#ifdef CONFIG_PAX_KERNEXEC
28771 + " movl %0, %%cr0\n"
28772 +#endif
28773 +
28774 " jmp 2b\n"
28775 ".previous\n"
28776 _ASM_EXTABLE(1b, 3b)
28777 - : : "r" (from), "r" (to) : "memory");
28778 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28779
28780 from += 64;
28781 to += 64;
28782 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28783 index f6d13ee..aca5f0b 100644
28784 --- a/arch/x86/lib/msr-reg.S
28785 +++ b/arch/x86/lib/msr-reg.S
28786 @@ -3,6 +3,7 @@
28787 #include <asm/dwarf2.h>
28788 #include <asm/asm.h>
28789 #include <asm/msr.h>
28790 +#include <asm/alternative-asm.h>
28791
28792 #ifdef CONFIG_X86_64
28793 /*
28794 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28795 CFI_STARTPROC
28796 pushq_cfi %rbx
28797 pushq_cfi %rbp
28798 - movq %rdi, %r10 /* Save pointer */
28799 + movq %rdi, %r9 /* Save pointer */
28800 xorl %r11d, %r11d /* Return value */
28801 movl (%rdi), %eax
28802 movl 4(%rdi), %ecx
28803 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28804 movl 28(%rdi), %edi
28805 CFI_REMEMBER_STATE
28806 1: \op
28807 -2: movl %eax, (%r10)
28808 +2: movl %eax, (%r9)
28809 movl %r11d, %eax /* Return value */
28810 - movl %ecx, 4(%r10)
28811 - movl %edx, 8(%r10)
28812 - movl %ebx, 12(%r10)
28813 - movl %ebp, 20(%r10)
28814 - movl %esi, 24(%r10)
28815 - movl %edi, 28(%r10)
28816 + movl %ecx, 4(%r9)
28817 + movl %edx, 8(%r9)
28818 + movl %ebx, 12(%r9)
28819 + movl %ebp, 20(%r9)
28820 + movl %esi, 24(%r9)
28821 + movl %edi, 28(%r9)
28822 popq_cfi %rbp
28823 popq_cfi %rbx
28824 + pax_force_retaddr
28825 ret
28826 3:
28827 CFI_RESTORE_STATE
28828 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28829 index fc6ba17..d4d989d 100644
28830 --- a/arch/x86/lib/putuser.S
28831 +++ b/arch/x86/lib/putuser.S
28832 @@ -16,7 +16,9 @@
28833 #include <asm/errno.h>
28834 #include <asm/asm.h>
28835 #include <asm/smap.h>
28836 -
28837 +#include <asm/segment.h>
28838 +#include <asm/pgtable.h>
28839 +#include <asm/alternative-asm.h>
28840
28841 /*
28842 * __put_user_X
28843 @@ -30,57 +32,125 @@
28844 * as they get called from within inline assembly.
28845 */
28846
28847 -#define ENTER CFI_STARTPROC ; \
28848 - GET_THREAD_INFO(%_ASM_BX)
28849 -#define EXIT ASM_CLAC ; \
28850 - ret ; \
28851 +#define ENTER CFI_STARTPROC
28852 +#define EXIT ASM_CLAC ; \
28853 + pax_force_retaddr ; \
28854 + ret ; \
28855 CFI_ENDPROC
28856
28857 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28858 +#define _DEST %_ASM_CX,%_ASM_BX
28859 +#else
28860 +#define _DEST %_ASM_CX
28861 +#endif
28862 +
28863 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28864 +#define __copyuser_seg gs;
28865 +#else
28866 +#define __copyuser_seg
28867 +#endif
28868 +
28869 .text
28870 ENTRY(__put_user_1)
28871 ENTER
28872 +
28873 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28874 + GET_THREAD_INFO(%_ASM_BX)
28875 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28876 jae bad_put_user
28877 ASM_STAC
28878 -1: movb %al,(%_ASM_CX)
28879 +
28880 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28881 + mov pax_user_shadow_base,%_ASM_BX
28882 + cmp %_ASM_BX,%_ASM_CX
28883 + jb 1234f
28884 + xor %ebx,%ebx
28885 +1234:
28886 +#endif
28887 +
28888 +#endif
28889 +
28890 +1: __copyuser_seg movb %al,(_DEST)
28891 xor %eax,%eax
28892 EXIT
28893 ENDPROC(__put_user_1)
28894
28895 ENTRY(__put_user_2)
28896 ENTER
28897 +
28898 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28899 + GET_THREAD_INFO(%_ASM_BX)
28900 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28901 sub $1,%_ASM_BX
28902 cmp %_ASM_BX,%_ASM_CX
28903 jae bad_put_user
28904 ASM_STAC
28905 -2: movw %ax,(%_ASM_CX)
28906 +
28907 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28908 + mov pax_user_shadow_base,%_ASM_BX
28909 + cmp %_ASM_BX,%_ASM_CX
28910 + jb 1234f
28911 + xor %ebx,%ebx
28912 +1234:
28913 +#endif
28914 +
28915 +#endif
28916 +
28917 +2: __copyuser_seg movw %ax,(_DEST)
28918 xor %eax,%eax
28919 EXIT
28920 ENDPROC(__put_user_2)
28921
28922 ENTRY(__put_user_4)
28923 ENTER
28924 +
28925 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28926 + GET_THREAD_INFO(%_ASM_BX)
28927 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28928 sub $3,%_ASM_BX
28929 cmp %_ASM_BX,%_ASM_CX
28930 jae bad_put_user
28931 ASM_STAC
28932 -3: movl %eax,(%_ASM_CX)
28933 +
28934 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28935 + mov pax_user_shadow_base,%_ASM_BX
28936 + cmp %_ASM_BX,%_ASM_CX
28937 + jb 1234f
28938 + xor %ebx,%ebx
28939 +1234:
28940 +#endif
28941 +
28942 +#endif
28943 +
28944 +3: __copyuser_seg movl %eax,(_DEST)
28945 xor %eax,%eax
28946 EXIT
28947 ENDPROC(__put_user_4)
28948
28949 ENTRY(__put_user_8)
28950 ENTER
28951 +
28952 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28953 + GET_THREAD_INFO(%_ASM_BX)
28954 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28955 sub $7,%_ASM_BX
28956 cmp %_ASM_BX,%_ASM_CX
28957 jae bad_put_user
28958 ASM_STAC
28959 -4: mov %_ASM_AX,(%_ASM_CX)
28960 +
28961 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28962 + mov pax_user_shadow_base,%_ASM_BX
28963 + cmp %_ASM_BX,%_ASM_CX
28964 + jb 1234f
28965 + xor %ebx,%ebx
28966 +1234:
28967 +#endif
28968 +
28969 +#endif
28970 +
28971 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
28972 #ifdef CONFIG_X86_32
28973 -5: movl %edx,4(%_ASM_CX)
28974 +5: __copyuser_seg movl %edx,4(_DEST)
28975 #endif
28976 xor %eax,%eax
28977 EXIT
28978 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
28979 index 1cad221..de671ee 100644
28980 --- a/arch/x86/lib/rwlock.S
28981 +++ b/arch/x86/lib/rwlock.S
28982 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
28983 FRAME
28984 0: LOCK_PREFIX
28985 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
28986 +
28987 +#ifdef CONFIG_PAX_REFCOUNT
28988 + jno 1234f
28989 + LOCK_PREFIX
28990 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
28991 + int $4
28992 +1234:
28993 + _ASM_EXTABLE(1234b, 1234b)
28994 +#endif
28995 +
28996 1: rep; nop
28997 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
28998 jne 1b
28999 LOCK_PREFIX
29000 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29001 +
29002 +#ifdef CONFIG_PAX_REFCOUNT
29003 + jno 1234f
29004 + LOCK_PREFIX
29005 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29006 + int $4
29007 +1234:
29008 + _ASM_EXTABLE(1234b, 1234b)
29009 +#endif
29010 +
29011 jnz 0b
29012 ENDFRAME
29013 + pax_force_retaddr
29014 ret
29015 CFI_ENDPROC
29016 END(__write_lock_failed)
29017 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29018 FRAME
29019 0: LOCK_PREFIX
29020 READ_LOCK_SIZE(inc) (%__lock_ptr)
29021 +
29022 +#ifdef CONFIG_PAX_REFCOUNT
29023 + jno 1234f
29024 + LOCK_PREFIX
29025 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29026 + int $4
29027 +1234:
29028 + _ASM_EXTABLE(1234b, 1234b)
29029 +#endif
29030 +
29031 1: rep; nop
29032 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29033 js 1b
29034 LOCK_PREFIX
29035 READ_LOCK_SIZE(dec) (%__lock_ptr)
29036 +
29037 +#ifdef CONFIG_PAX_REFCOUNT
29038 + jno 1234f
29039 + LOCK_PREFIX
29040 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29041 + int $4
29042 +1234:
29043 + _ASM_EXTABLE(1234b, 1234b)
29044 +#endif
29045 +
29046 js 0b
29047 ENDFRAME
29048 + pax_force_retaddr
29049 ret
29050 CFI_ENDPROC
29051 END(__read_lock_failed)
29052 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29053 index 5dff5f0..cadebf4 100644
29054 --- a/arch/x86/lib/rwsem.S
29055 +++ b/arch/x86/lib/rwsem.S
29056 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29057 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29058 CFI_RESTORE __ASM_REG(dx)
29059 restore_common_regs
29060 + pax_force_retaddr
29061 ret
29062 CFI_ENDPROC
29063 ENDPROC(call_rwsem_down_read_failed)
29064 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29065 movq %rax,%rdi
29066 call rwsem_down_write_failed
29067 restore_common_regs
29068 + pax_force_retaddr
29069 ret
29070 CFI_ENDPROC
29071 ENDPROC(call_rwsem_down_write_failed)
29072 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29073 movq %rax,%rdi
29074 call rwsem_wake
29075 restore_common_regs
29076 -1: ret
29077 +1: pax_force_retaddr
29078 + ret
29079 CFI_ENDPROC
29080 ENDPROC(call_rwsem_wake)
29081
29082 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29083 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29084 CFI_RESTORE __ASM_REG(dx)
29085 restore_common_regs
29086 + pax_force_retaddr
29087 ret
29088 CFI_ENDPROC
29089 ENDPROC(call_rwsem_downgrade_wake)
29090 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29091 index a63efd6..ccecad8 100644
29092 --- a/arch/x86/lib/thunk_64.S
29093 +++ b/arch/x86/lib/thunk_64.S
29094 @@ -8,6 +8,7 @@
29095 #include <linux/linkage.h>
29096 #include <asm/dwarf2.h>
29097 #include <asm/calling.h>
29098 +#include <asm/alternative-asm.h>
29099
29100 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29101 .macro THUNK name, func, put_ret_addr_in_rdi=0
29102 @@ -41,5 +42,6 @@
29103 SAVE_ARGS
29104 restore:
29105 RESTORE_ARGS
29106 + pax_force_retaddr
29107 ret
29108 CFI_ENDPROC
29109 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29110 index 3eb18ac..6890bc3 100644
29111 --- a/arch/x86/lib/usercopy_32.c
29112 +++ b/arch/x86/lib/usercopy_32.c
29113 @@ -42,11 +42,13 @@ do { \
29114 int __d0; \
29115 might_fault(); \
29116 __asm__ __volatile__( \
29117 + __COPYUSER_SET_ES \
29118 ASM_STAC "\n" \
29119 "0: rep; stosl\n" \
29120 " movl %2,%0\n" \
29121 "1: rep; stosb\n" \
29122 "2: " ASM_CLAC "\n" \
29123 + __COPYUSER_RESTORE_ES \
29124 ".section .fixup,\"ax\"\n" \
29125 "3: lea 0(%2,%0,4),%0\n" \
29126 " jmp 2b\n" \
29127 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29128
29129 #ifdef CONFIG_X86_INTEL_USERCOPY
29130 static unsigned long
29131 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29132 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29133 {
29134 int d0, d1;
29135 __asm__ __volatile__(
29136 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29137 " .align 2,0x90\n"
29138 "3: movl 0(%4), %%eax\n"
29139 "4: movl 4(%4), %%edx\n"
29140 - "5: movl %%eax, 0(%3)\n"
29141 - "6: movl %%edx, 4(%3)\n"
29142 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29143 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29144 "7: movl 8(%4), %%eax\n"
29145 "8: movl 12(%4),%%edx\n"
29146 - "9: movl %%eax, 8(%3)\n"
29147 - "10: movl %%edx, 12(%3)\n"
29148 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29149 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29150 "11: movl 16(%4), %%eax\n"
29151 "12: movl 20(%4), %%edx\n"
29152 - "13: movl %%eax, 16(%3)\n"
29153 - "14: movl %%edx, 20(%3)\n"
29154 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29155 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29156 "15: movl 24(%4), %%eax\n"
29157 "16: movl 28(%4), %%edx\n"
29158 - "17: movl %%eax, 24(%3)\n"
29159 - "18: movl %%edx, 28(%3)\n"
29160 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29161 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29162 "19: movl 32(%4), %%eax\n"
29163 "20: movl 36(%4), %%edx\n"
29164 - "21: movl %%eax, 32(%3)\n"
29165 - "22: movl %%edx, 36(%3)\n"
29166 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29167 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29168 "23: movl 40(%4), %%eax\n"
29169 "24: movl 44(%4), %%edx\n"
29170 - "25: movl %%eax, 40(%3)\n"
29171 - "26: movl %%edx, 44(%3)\n"
29172 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29173 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29174 "27: movl 48(%4), %%eax\n"
29175 "28: movl 52(%4), %%edx\n"
29176 - "29: movl %%eax, 48(%3)\n"
29177 - "30: movl %%edx, 52(%3)\n"
29178 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29179 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29180 "31: movl 56(%4), %%eax\n"
29181 "32: movl 60(%4), %%edx\n"
29182 - "33: movl %%eax, 56(%3)\n"
29183 - "34: movl %%edx, 60(%3)\n"
29184 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29185 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29186 " addl $-64, %0\n"
29187 " addl $64, %4\n"
29188 " addl $64, %3\n"
29189 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29190 " shrl $2, %0\n"
29191 " andl $3, %%eax\n"
29192 " cld\n"
29193 + __COPYUSER_SET_ES
29194 "99: rep; movsl\n"
29195 "36: movl %%eax, %0\n"
29196 "37: rep; movsb\n"
29197 "100:\n"
29198 + __COPYUSER_RESTORE_ES
29199 ".section .fixup,\"ax\"\n"
29200 "101: lea 0(%%eax,%0,4),%0\n"
29201 " jmp 100b\n"
29202 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29203 }
29204
29205 static unsigned long
29206 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29207 +{
29208 + int d0, d1;
29209 + __asm__ __volatile__(
29210 + " .align 2,0x90\n"
29211 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29212 + " cmpl $67, %0\n"
29213 + " jbe 3f\n"
29214 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29215 + " .align 2,0x90\n"
29216 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29217 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29218 + "5: movl %%eax, 0(%3)\n"
29219 + "6: movl %%edx, 4(%3)\n"
29220 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29221 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29222 + "9: movl %%eax, 8(%3)\n"
29223 + "10: movl %%edx, 12(%3)\n"
29224 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29225 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29226 + "13: movl %%eax, 16(%3)\n"
29227 + "14: movl %%edx, 20(%3)\n"
29228 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29229 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29230 + "17: movl %%eax, 24(%3)\n"
29231 + "18: movl %%edx, 28(%3)\n"
29232 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29233 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29234 + "21: movl %%eax, 32(%3)\n"
29235 + "22: movl %%edx, 36(%3)\n"
29236 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29237 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29238 + "25: movl %%eax, 40(%3)\n"
29239 + "26: movl %%edx, 44(%3)\n"
29240 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29241 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29242 + "29: movl %%eax, 48(%3)\n"
29243 + "30: movl %%edx, 52(%3)\n"
29244 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29245 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29246 + "33: movl %%eax, 56(%3)\n"
29247 + "34: movl %%edx, 60(%3)\n"
29248 + " addl $-64, %0\n"
29249 + " addl $64, %4\n"
29250 + " addl $64, %3\n"
29251 + " cmpl $63, %0\n"
29252 + " ja 1b\n"
29253 + "35: movl %0, %%eax\n"
29254 + " shrl $2, %0\n"
29255 + " andl $3, %%eax\n"
29256 + " cld\n"
29257 + "99: rep; "__copyuser_seg" movsl\n"
29258 + "36: movl %%eax, %0\n"
29259 + "37: rep; "__copyuser_seg" movsb\n"
29260 + "100:\n"
29261 + ".section .fixup,\"ax\"\n"
29262 + "101: lea 0(%%eax,%0,4),%0\n"
29263 + " jmp 100b\n"
29264 + ".previous\n"
29265 + _ASM_EXTABLE(1b,100b)
29266 + _ASM_EXTABLE(2b,100b)
29267 + _ASM_EXTABLE(3b,100b)
29268 + _ASM_EXTABLE(4b,100b)
29269 + _ASM_EXTABLE(5b,100b)
29270 + _ASM_EXTABLE(6b,100b)
29271 + _ASM_EXTABLE(7b,100b)
29272 + _ASM_EXTABLE(8b,100b)
29273 + _ASM_EXTABLE(9b,100b)
29274 + _ASM_EXTABLE(10b,100b)
29275 + _ASM_EXTABLE(11b,100b)
29276 + _ASM_EXTABLE(12b,100b)
29277 + _ASM_EXTABLE(13b,100b)
29278 + _ASM_EXTABLE(14b,100b)
29279 + _ASM_EXTABLE(15b,100b)
29280 + _ASM_EXTABLE(16b,100b)
29281 + _ASM_EXTABLE(17b,100b)
29282 + _ASM_EXTABLE(18b,100b)
29283 + _ASM_EXTABLE(19b,100b)
29284 + _ASM_EXTABLE(20b,100b)
29285 + _ASM_EXTABLE(21b,100b)
29286 + _ASM_EXTABLE(22b,100b)
29287 + _ASM_EXTABLE(23b,100b)
29288 + _ASM_EXTABLE(24b,100b)
29289 + _ASM_EXTABLE(25b,100b)
29290 + _ASM_EXTABLE(26b,100b)
29291 + _ASM_EXTABLE(27b,100b)
29292 + _ASM_EXTABLE(28b,100b)
29293 + _ASM_EXTABLE(29b,100b)
29294 + _ASM_EXTABLE(30b,100b)
29295 + _ASM_EXTABLE(31b,100b)
29296 + _ASM_EXTABLE(32b,100b)
29297 + _ASM_EXTABLE(33b,100b)
29298 + _ASM_EXTABLE(34b,100b)
29299 + _ASM_EXTABLE(35b,100b)
29300 + _ASM_EXTABLE(36b,100b)
29301 + _ASM_EXTABLE(37b,100b)
29302 + _ASM_EXTABLE(99b,101b)
29303 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29304 + : "1"(to), "2"(from), "0"(size)
29305 + : "eax", "edx", "memory");
29306 + return size;
29307 +}
29308 +
29309 +static unsigned long __size_overflow(3)
29310 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29311 {
29312 int d0, d1;
29313 __asm__ __volatile__(
29314 " .align 2,0x90\n"
29315 - "0: movl 32(%4), %%eax\n"
29316 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29317 " cmpl $67, %0\n"
29318 " jbe 2f\n"
29319 - "1: movl 64(%4), %%eax\n"
29320 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29321 " .align 2,0x90\n"
29322 - "2: movl 0(%4), %%eax\n"
29323 - "21: movl 4(%4), %%edx\n"
29324 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29325 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29326 " movl %%eax, 0(%3)\n"
29327 " movl %%edx, 4(%3)\n"
29328 - "3: movl 8(%4), %%eax\n"
29329 - "31: movl 12(%4),%%edx\n"
29330 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29331 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29332 " movl %%eax, 8(%3)\n"
29333 " movl %%edx, 12(%3)\n"
29334 - "4: movl 16(%4), %%eax\n"
29335 - "41: movl 20(%4), %%edx\n"
29336 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29337 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29338 " movl %%eax, 16(%3)\n"
29339 " movl %%edx, 20(%3)\n"
29340 - "10: movl 24(%4), %%eax\n"
29341 - "51: movl 28(%4), %%edx\n"
29342 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29343 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29344 " movl %%eax, 24(%3)\n"
29345 " movl %%edx, 28(%3)\n"
29346 - "11: movl 32(%4), %%eax\n"
29347 - "61: movl 36(%4), %%edx\n"
29348 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29349 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29350 " movl %%eax, 32(%3)\n"
29351 " movl %%edx, 36(%3)\n"
29352 - "12: movl 40(%4), %%eax\n"
29353 - "71: movl 44(%4), %%edx\n"
29354 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29355 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29356 " movl %%eax, 40(%3)\n"
29357 " movl %%edx, 44(%3)\n"
29358 - "13: movl 48(%4), %%eax\n"
29359 - "81: movl 52(%4), %%edx\n"
29360 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29361 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29362 " movl %%eax, 48(%3)\n"
29363 " movl %%edx, 52(%3)\n"
29364 - "14: movl 56(%4), %%eax\n"
29365 - "91: movl 60(%4), %%edx\n"
29366 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29367 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29368 " movl %%eax, 56(%3)\n"
29369 " movl %%edx, 60(%3)\n"
29370 " addl $-64, %0\n"
29371 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29372 " shrl $2, %0\n"
29373 " andl $3, %%eax\n"
29374 " cld\n"
29375 - "6: rep; movsl\n"
29376 + "6: rep; "__copyuser_seg" movsl\n"
29377 " movl %%eax,%0\n"
29378 - "7: rep; movsb\n"
29379 + "7: rep; "__copyuser_seg" movsb\n"
29380 "8:\n"
29381 ".section .fixup,\"ax\"\n"
29382 "9: lea 0(%%eax,%0,4),%0\n"
29383 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29384 * hyoshiok@miraclelinux.com
29385 */
29386
29387 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29388 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
29389 const void __user *from, unsigned long size)
29390 {
29391 int d0, d1;
29392
29393 __asm__ __volatile__(
29394 " .align 2,0x90\n"
29395 - "0: movl 32(%4), %%eax\n"
29396 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29397 " cmpl $67, %0\n"
29398 " jbe 2f\n"
29399 - "1: movl 64(%4), %%eax\n"
29400 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29401 " .align 2,0x90\n"
29402 - "2: movl 0(%4), %%eax\n"
29403 - "21: movl 4(%4), %%edx\n"
29404 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29405 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29406 " movnti %%eax, 0(%3)\n"
29407 " movnti %%edx, 4(%3)\n"
29408 - "3: movl 8(%4), %%eax\n"
29409 - "31: movl 12(%4),%%edx\n"
29410 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29411 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29412 " movnti %%eax, 8(%3)\n"
29413 " movnti %%edx, 12(%3)\n"
29414 - "4: movl 16(%4), %%eax\n"
29415 - "41: movl 20(%4), %%edx\n"
29416 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29417 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29418 " movnti %%eax, 16(%3)\n"
29419 " movnti %%edx, 20(%3)\n"
29420 - "10: movl 24(%4), %%eax\n"
29421 - "51: movl 28(%4), %%edx\n"
29422 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29423 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29424 " movnti %%eax, 24(%3)\n"
29425 " movnti %%edx, 28(%3)\n"
29426 - "11: movl 32(%4), %%eax\n"
29427 - "61: movl 36(%4), %%edx\n"
29428 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29429 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29430 " movnti %%eax, 32(%3)\n"
29431 " movnti %%edx, 36(%3)\n"
29432 - "12: movl 40(%4), %%eax\n"
29433 - "71: movl 44(%4), %%edx\n"
29434 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29435 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29436 " movnti %%eax, 40(%3)\n"
29437 " movnti %%edx, 44(%3)\n"
29438 - "13: movl 48(%4), %%eax\n"
29439 - "81: movl 52(%4), %%edx\n"
29440 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29441 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29442 " movnti %%eax, 48(%3)\n"
29443 " movnti %%edx, 52(%3)\n"
29444 - "14: movl 56(%4), %%eax\n"
29445 - "91: movl 60(%4), %%edx\n"
29446 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29447 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29448 " movnti %%eax, 56(%3)\n"
29449 " movnti %%edx, 60(%3)\n"
29450 " addl $-64, %0\n"
29451 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29452 " shrl $2, %0\n"
29453 " andl $3, %%eax\n"
29454 " cld\n"
29455 - "6: rep; movsl\n"
29456 + "6: rep; "__copyuser_seg" movsl\n"
29457 " movl %%eax,%0\n"
29458 - "7: rep; movsb\n"
29459 + "7: rep; "__copyuser_seg" movsb\n"
29460 "8:\n"
29461 ".section .fixup,\"ax\"\n"
29462 "9: lea 0(%%eax,%0,4),%0\n"
29463 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29464 return size;
29465 }
29466
29467 -static unsigned long __copy_user_intel_nocache(void *to,
29468 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
29469 const void __user *from, unsigned long size)
29470 {
29471 int d0, d1;
29472
29473 __asm__ __volatile__(
29474 " .align 2,0x90\n"
29475 - "0: movl 32(%4), %%eax\n"
29476 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29477 " cmpl $67, %0\n"
29478 " jbe 2f\n"
29479 - "1: movl 64(%4), %%eax\n"
29480 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29481 " .align 2,0x90\n"
29482 - "2: movl 0(%4), %%eax\n"
29483 - "21: movl 4(%4), %%edx\n"
29484 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29485 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29486 " movnti %%eax, 0(%3)\n"
29487 " movnti %%edx, 4(%3)\n"
29488 - "3: movl 8(%4), %%eax\n"
29489 - "31: movl 12(%4),%%edx\n"
29490 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29491 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29492 " movnti %%eax, 8(%3)\n"
29493 " movnti %%edx, 12(%3)\n"
29494 - "4: movl 16(%4), %%eax\n"
29495 - "41: movl 20(%4), %%edx\n"
29496 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29497 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29498 " movnti %%eax, 16(%3)\n"
29499 " movnti %%edx, 20(%3)\n"
29500 - "10: movl 24(%4), %%eax\n"
29501 - "51: movl 28(%4), %%edx\n"
29502 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29503 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29504 " movnti %%eax, 24(%3)\n"
29505 " movnti %%edx, 28(%3)\n"
29506 - "11: movl 32(%4), %%eax\n"
29507 - "61: movl 36(%4), %%edx\n"
29508 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29509 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29510 " movnti %%eax, 32(%3)\n"
29511 " movnti %%edx, 36(%3)\n"
29512 - "12: movl 40(%4), %%eax\n"
29513 - "71: movl 44(%4), %%edx\n"
29514 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29515 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29516 " movnti %%eax, 40(%3)\n"
29517 " movnti %%edx, 44(%3)\n"
29518 - "13: movl 48(%4), %%eax\n"
29519 - "81: movl 52(%4), %%edx\n"
29520 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29521 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29522 " movnti %%eax, 48(%3)\n"
29523 " movnti %%edx, 52(%3)\n"
29524 - "14: movl 56(%4), %%eax\n"
29525 - "91: movl 60(%4), %%edx\n"
29526 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29527 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29528 " movnti %%eax, 56(%3)\n"
29529 " movnti %%edx, 60(%3)\n"
29530 " addl $-64, %0\n"
29531 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29532 " shrl $2, %0\n"
29533 " andl $3, %%eax\n"
29534 " cld\n"
29535 - "6: rep; movsl\n"
29536 + "6: rep; "__copyuser_seg" movsl\n"
29537 " movl %%eax,%0\n"
29538 - "7: rep; movsb\n"
29539 + "7: rep; "__copyuser_seg" movsb\n"
29540 "8:\n"
29541 ".section .fixup,\"ax\"\n"
29542 "9: lea 0(%%eax,%0,4),%0\n"
29543 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29544 */
29545 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29546 unsigned long size);
29547 -unsigned long __copy_user_intel(void __user *to, const void *from,
29548 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29549 + unsigned long size);
29550 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29551 unsigned long size);
29552 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29553 const void __user *from, unsigned long size);
29554 #endif /* CONFIG_X86_INTEL_USERCOPY */
29555
29556 /* Generic arbitrary sized copy. */
29557 -#define __copy_user(to, from, size) \
29558 +#define __copy_user(to, from, size, prefix, set, restore) \
29559 do { \
29560 int __d0, __d1, __d2; \
29561 __asm__ __volatile__( \
29562 + set \
29563 " cmp $7,%0\n" \
29564 " jbe 1f\n" \
29565 " movl %1,%0\n" \
29566 " negl %0\n" \
29567 " andl $7,%0\n" \
29568 " subl %0,%3\n" \
29569 - "4: rep; movsb\n" \
29570 + "4: rep; "prefix"movsb\n" \
29571 " movl %3,%0\n" \
29572 " shrl $2,%0\n" \
29573 " andl $3,%3\n" \
29574 " .align 2,0x90\n" \
29575 - "0: rep; movsl\n" \
29576 + "0: rep; "prefix"movsl\n" \
29577 " movl %3,%0\n" \
29578 - "1: rep; movsb\n" \
29579 + "1: rep; "prefix"movsb\n" \
29580 "2:\n" \
29581 + restore \
29582 ".section .fixup,\"ax\"\n" \
29583 "5: addl %3,%0\n" \
29584 " jmp 2b\n" \
29585 @@ -538,14 +650,14 @@ do { \
29586 " negl %0\n" \
29587 " andl $7,%0\n" \
29588 " subl %0,%3\n" \
29589 - "4: rep; movsb\n" \
29590 + "4: rep; "__copyuser_seg"movsb\n" \
29591 " movl %3,%0\n" \
29592 " shrl $2,%0\n" \
29593 " andl $3,%3\n" \
29594 " .align 2,0x90\n" \
29595 - "0: rep; movsl\n" \
29596 + "0: rep; "__copyuser_seg"movsl\n" \
29597 " movl %3,%0\n" \
29598 - "1: rep; movsb\n" \
29599 + "1: rep; "__copyuser_seg"movsb\n" \
29600 "2:\n" \
29601 ".section .fixup,\"ax\"\n" \
29602 "5: addl %3,%0\n" \
29603 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29604 {
29605 stac();
29606 if (movsl_is_ok(to, from, n))
29607 - __copy_user(to, from, n);
29608 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29609 else
29610 - n = __copy_user_intel(to, from, n);
29611 + n = __generic_copy_to_user_intel(to, from, n);
29612 clac();
29613 return n;
29614 }
29615 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29616 {
29617 stac();
29618 if (movsl_is_ok(to, from, n))
29619 - __copy_user(to, from, n);
29620 + __copy_user(to, from, n, __copyuser_seg, "", "");
29621 else
29622 - n = __copy_user_intel((void __user *)to,
29623 - (const void *)from, n);
29624 + n = __generic_copy_from_user_intel(to, from, n);
29625 clac();
29626 return n;
29627 }
29628 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29629 if (n > 64 && cpu_has_xmm2)
29630 n = __copy_user_intel_nocache(to, from, n);
29631 else
29632 - __copy_user(to, from, n);
29633 + __copy_user(to, from, n, __copyuser_seg, "", "");
29634 #else
29635 - __copy_user(to, from, n);
29636 + __copy_user(to, from, n, __copyuser_seg, "", "");
29637 #endif
29638 clac();
29639 return n;
29640 }
29641 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29642
29643 -/**
29644 - * copy_to_user: - Copy a block of data into user space.
29645 - * @to: Destination address, in user space.
29646 - * @from: Source address, in kernel space.
29647 - * @n: Number of bytes to copy.
29648 - *
29649 - * Context: User context only. This function may sleep.
29650 - *
29651 - * Copy data from kernel space to user space.
29652 - *
29653 - * Returns number of bytes that could not be copied.
29654 - * On success, this will be zero.
29655 - */
29656 -unsigned long
29657 -copy_to_user(void __user *to, const void *from, unsigned long n)
29658 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29659 +void __set_fs(mm_segment_t x)
29660 {
29661 - if (access_ok(VERIFY_WRITE, to, n))
29662 - n = __copy_to_user(to, from, n);
29663 - return n;
29664 + switch (x.seg) {
29665 + case 0:
29666 + loadsegment(gs, 0);
29667 + break;
29668 + case TASK_SIZE_MAX:
29669 + loadsegment(gs, __USER_DS);
29670 + break;
29671 + case -1UL:
29672 + loadsegment(gs, __KERNEL_DS);
29673 + break;
29674 + default:
29675 + BUG();
29676 + }
29677 }
29678 -EXPORT_SYMBOL(copy_to_user);
29679 +EXPORT_SYMBOL(__set_fs);
29680
29681 -/**
29682 - * copy_from_user: - Copy a block of data from user space.
29683 - * @to: Destination address, in kernel space.
29684 - * @from: Source address, in user space.
29685 - * @n: Number of bytes to copy.
29686 - *
29687 - * Context: User context only. This function may sleep.
29688 - *
29689 - * Copy data from user space to kernel space.
29690 - *
29691 - * Returns number of bytes that could not be copied.
29692 - * On success, this will be zero.
29693 - *
29694 - * If some data could not be copied, this function will pad the copied
29695 - * data to the requested size using zero bytes.
29696 - */
29697 -unsigned long
29698 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29699 +void set_fs(mm_segment_t x)
29700 {
29701 - if (access_ok(VERIFY_READ, from, n))
29702 - n = __copy_from_user(to, from, n);
29703 - else
29704 - memset(to, 0, n);
29705 - return n;
29706 + current_thread_info()->addr_limit = x;
29707 + __set_fs(x);
29708 }
29709 -EXPORT_SYMBOL(_copy_from_user);
29710 +EXPORT_SYMBOL(set_fs);
29711 +#endif
29712 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29713 index 906fea3..0194a18 100644
29714 --- a/arch/x86/lib/usercopy_64.c
29715 +++ b/arch/x86/lib/usercopy_64.c
29716 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29717 might_fault();
29718 /* no memory constraint because it doesn't change any memory gcc knows
29719 about */
29720 + pax_open_userland();
29721 stac();
29722 asm volatile(
29723 " testq %[size8],%[size8]\n"
29724 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29725 _ASM_EXTABLE(0b,3b)
29726 _ASM_EXTABLE(1b,2b)
29727 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29728 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29729 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29730 [zero] "r" (0UL), [eight] "r" (8UL));
29731 clac();
29732 + pax_close_userland();
29733 return size;
29734 }
29735 EXPORT_SYMBOL(__clear_user);
29736 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29737 }
29738 EXPORT_SYMBOL(clear_user);
29739
29740 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29741 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29742 {
29743 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29744 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29745 - }
29746 - return len;
29747 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29748 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29749 + return len;
29750 }
29751 EXPORT_SYMBOL(copy_in_user);
29752
29753 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29754 * it is not necessary to optimize tail handling.
29755 */
29756 unsigned long
29757 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29758 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29759 {
29760 char c;
29761 unsigned zero_len;
29762
29763 + clac();
29764 + pax_close_userland();
29765 for (; len; --len, to++) {
29766 if (__get_user_nocheck(c, from++, sizeof(char)))
29767 break;
29768 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29769 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29770 if (__put_user_nocheck(c, to++, sizeof(char)))
29771 break;
29772 - clac();
29773 return len;
29774 }
29775 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29776 index 23d8e5f..9ccc13a 100644
29777 --- a/arch/x86/mm/Makefile
29778 +++ b/arch/x86/mm/Makefile
29779 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29780 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29781
29782 obj-$(CONFIG_MEMTEST) += memtest.o
29783 +
29784 +quote:="
29785 +obj-$(CONFIG_X86_64) += uderef_64.o
29786 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29787 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29788 index 903ec1e..c4166b2 100644
29789 --- a/arch/x86/mm/extable.c
29790 +++ b/arch/x86/mm/extable.c
29791 @@ -6,12 +6,24 @@
29792 static inline unsigned long
29793 ex_insn_addr(const struct exception_table_entry *x)
29794 {
29795 - return (unsigned long)&x->insn + x->insn;
29796 + unsigned long reloc = 0;
29797 +
29798 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29799 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29800 +#endif
29801 +
29802 + return (unsigned long)&x->insn + x->insn + reloc;
29803 }
29804 static inline unsigned long
29805 ex_fixup_addr(const struct exception_table_entry *x)
29806 {
29807 - return (unsigned long)&x->fixup + x->fixup;
29808 + unsigned long reloc = 0;
29809 +
29810 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29811 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29812 +#endif
29813 +
29814 + return (unsigned long)&x->fixup + x->fixup + reloc;
29815 }
29816
29817 int fixup_exception(struct pt_regs *regs)
29818 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29819 unsigned long new_ip;
29820
29821 #ifdef CONFIG_PNPBIOS
29822 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29823 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29824 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29825 extern u32 pnp_bios_is_utter_crap;
29826 pnp_bios_is_utter_crap = 1;
29827 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29828 i += 4;
29829 p->fixup -= i;
29830 i += 4;
29831 +
29832 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29833 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29834 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29835 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29836 +#endif
29837 +
29838 }
29839 }
29840
29841 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29842 index 654be4a..a4a3da1 100644
29843 --- a/arch/x86/mm/fault.c
29844 +++ b/arch/x86/mm/fault.c
29845 @@ -14,11 +14,18 @@
29846 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29847 #include <linux/prefetch.h> /* prefetchw */
29848 #include <linux/context_tracking.h> /* exception_enter(), ... */
29849 +#include <linux/unistd.h>
29850 +#include <linux/compiler.h>
29851
29852 #include <asm/traps.h> /* dotraplinkage, ... */
29853 #include <asm/pgalloc.h> /* pgd_*(), ... */
29854 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29855 #include <asm/fixmap.h> /* VSYSCALL_START */
29856 +#include <asm/tlbflush.h>
29857 +
29858 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29859 +#include <asm/stacktrace.h>
29860 +#endif
29861
29862 /*
29863 * Page fault error code bits:
29864 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29865 int ret = 0;
29866
29867 /* kprobe_running() needs smp_processor_id() */
29868 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29869 + if (kprobes_built_in() && !user_mode(regs)) {
29870 preempt_disable();
29871 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29872 ret = 1;
29873 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29874 return !instr_lo || (instr_lo>>1) == 1;
29875 case 0x00:
29876 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29877 - if (probe_kernel_address(instr, opcode))
29878 + if (user_mode(regs)) {
29879 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29880 + return 0;
29881 + } else if (probe_kernel_address(instr, opcode))
29882 return 0;
29883
29884 *prefetch = (instr_lo == 0xF) &&
29885 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29886 while (instr < max_instr) {
29887 unsigned char opcode;
29888
29889 - if (probe_kernel_address(instr, opcode))
29890 + if (user_mode(regs)) {
29891 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29892 + break;
29893 + } else if (probe_kernel_address(instr, opcode))
29894 break;
29895
29896 instr++;
29897 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29898 force_sig_info(si_signo, &info, tsk);
29899 }
29900
29901 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29902 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29903 +#endif
29904 +
29905 +#ifdef CONFIG_PAX_EMUTRAMP
29906 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29907 +#endif
29908 +
29909 +#ifdef CONFIG_PAX_PAGEEXEC
29910 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29911 +{
29912 + pgd_t *pgd;
29913 + pud_t *pud;
29914 + pmd_t *pmd;
29915 +
29916 + pgd = pgd_offset(mm, address);
29917 + if (!pgd_present(*pgd))
29918 + return NULL;
29919 + pud = pud_offset(pgd, address);
29920 + if (!pud_present(*pud))
29921 + return NULL;
29922 + pmd = pmd_offset(pud, address);
29923 + if (!pmd_present(*pmd))
29924 + return NULL;
29925 + return pmd;
29926 +}
29927 +#endif
29928 +
29929 DEFINE_SPINLOCK(pgd_lock);
29930 LIST_HEAD(pgd_list);
29931
29932 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29933 for (address = VMALLOC_START & PMD_MASK;
29934 address >= TASK_SIZE && address < FIXADDR_TOP;
29935 address += PMD_SIZE) {
29936 +
29937 +#ifdef CONFIG_PAX_PER_CPU_PGD
29938 + unsigned long cpu;
29939 +#else
29940 struct page *page;
29941 +#endif
29942
29943 spin_lock(&pgd_lock);
29944 +
29945 +#ifdef CONFIG_PAX_PER_CPU_PGD
29946 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29947 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29948 + pmd_t *ret;
29949 +
29950 + ret = vmalloc_sync_one(pgd, address);
29951 + if (!ret)
29952 + break;
29953 + pgd = get_cpu_pgd(cpu, kernel);
29954 +#else
29955 list_for_each_entry(page, &pgd_list, lru) {
29956 + pgd_t *pgd;
29957 spinlock_t *pgt_lock;
29958 pmd_t *ret;
29959
29960 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29961 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29962
29963 spin_lock(pgt_lock);
29964 - ret = vmalloc_sync_one(page_address(page), address);
29965 + pgd = page_address(page);
29966 +#endif
29967 +
29968 + ret = vmalloc_sync_one(pgd, address);
29969 +
29970 +#ifndef CONFIG_PAX_PER_CPU_PGD
29971 spin_unlock(pgt_lock);
29972 +#endif
29973
29974 if (!ret)
29975 break;
29976 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29977 * an interrupt in the middle of a task switch..
29978 */
29979 pgd_paddr = read_cr3();
29980 +
29981 +#ifdef CONFIG_PAX_PER_CPU_PGD
29982 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
29983 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
29984 +#endif
29985 +
29986 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
29987 if (!pmd_k)
29988 return -1;
29989 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29990 * happen within a race in page table update. In the later
29991 * case just flush:
29992 */
29993 - pgd = pgd_offset(current->active_mm, address);
29994 +
29995 pgd_ref = pgd_offset_k(address);
29996 if (pgd_none(*pgd_ref))
29997 return -1;
29998
29999 +#ifdef CONFIG_PAX_PER_CPU_PGD
30000 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30001 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30002 + if (pgd_none(*pgd)) {
30003 + set_pgd(pgd, *pgd_ref);
30004 + arch_flush_lazy_mmu_mode();
30005 + } else {
30006 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30007 + }
30008 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30009 +#else
30010 + pgd = pgd_offset(current->active_mm, address);
30011 +#endif
30012 +
30013 if (pgd_none(*pgd)) {
30014 set_pgd(pgd, *pgd_ref);
30015 arch_flush_lazy_mmu_mode();
30016 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30017 static int is_errata100(struct pt_regs *regs, unsigned long address)
30018 {
30019 #ifdef CONFIG_X86_64
30020 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30021 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30022 return 1;
30023 #endif
30024 return 0;
30025 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30026 }
30027
30028 static const char nx_warning[] = KERN_CRIT
30029 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30030 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30031
30032 static void
30033 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30034 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30035 if (!oops_may_print())
30036 return;
30037
30038 - if (error_code & PF_INSTR) {
30039 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30040 unsigned int level;
30041
30042 pte_t *pte = lookup_address(address, &level);
30043
30044 if (pte && pte_present(*pte) && !pte_exec(*pte))
30045 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30046 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30047 }
30048
30049 +#ifdef CONFIG_PAX_KERNEXEC
30050 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30051 + if (current->signal->curr_ip)
30052 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30053 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30054 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30055 + else
30056 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30057 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30058 + }
30059 +#endif
30060 +
30061 printk(KERN_ALERT "BUG: unable to handle kernel ");
30062 if (address < PAGE_SIZE)
30063 printk(KERN_CONT "NULL pointer dereference");
30064 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30065 return;
30066 }
30067 #endif
30068 +
30069 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30070 + if (pax_is_fetch_fault(regs, error_code, address)) {
30071 +
30072 +#ifdef CONFIG_PAX_EMUTRAMP
30073 + switch (pax_handle_fetch_fault(regs)) {
30074 + case 2:
30075 + return;
30076 + }
30077 +#endif
30078 +
30079 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30080 + do_group_exit(SIGKILL);
30081 + }
30082 +#endif
30083 +
30084 /* Kernel addresses are always protection faults: */
30085 if (address >= TASK_SIZE)
30086 error_code |= PF_PROT;
30087 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30088 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30089 printk(KERN_ERR
30090 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30091 - tsk->comm, tsk->pid, address);
30092 + tsk->comm, task_pid_nr(tsk), address);
30093 code = BUS_MCEERR_AR;
30094 }
30095 #endif
30096 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30097 return 1;
30098 }
30099
30100 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30101 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30102 +{
30103 + pte_t *pte;
30104 + pmd_t *pmd;
30105 + spinlock_t *ptl;
30106 + unsigned char pte_mask;
30107 +
30108 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30109 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30110 + return 0;
30111 +
30112 + /* PaX: it's our fault, let's handle it if we can */
30113 +
30114 + /* PaX: take a look at read faults before acquiring any locks */
30115 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30116 + /* instruction fetch attempt from a protected page in user mode */
30117 + up_read(&mm->mmap_sem);
30118 +
30119 +#ifdef CONFIG_PAX_EMUTRAMP
30120 + switch (pax_handle_fetch_fault(regs)) {
30121 + case 2:
30122 + return 1;
30123 + }
30124 +#endif
30125 +
30126 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30127 + do_group_exit(SIGKILL);
30128 + }
30129 +
30130 + pmd = pax_get_pmd(mm, address);
30131 + if (unlikely(!pmd))
30132 + return 0;
30133 +
30134 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30135 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30136 + pte_unmap_unlock(pte, ptl);
30137 + return 0;
30138 + }
30139 +
30140 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30141 + /* write attempt to a protected page in user mode */
30142 + pte_unmap_unlock(pte, ptl);
30143 + return 0;
30144 + }
30145 +
30146 +#ifdef CONFIG_SMP
30147 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30148 +#else
30149 + if (likely(address > get_limit(regs->cs)))
30150 +#endif
30151 + {
30152 + set_pte(pte, pte_mkread(*pte));
30153 + __flush_tlb_one(address);
30154 + pte_unmap_unlock(pte, ptl);
30155 + up_read(&mm->mmap_sem);
30156 + return 1;
30157 + }
30158 +
30159 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30160 +
30161 + /*
30162 + * PaX: fill DTLB with user rights and retry
30163 + */
30164 + __asm__ __volatile__ (
30165 + "orb %2,(%1)\n"
30166 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30167 +/*
30168 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30169 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30170 + * page fault when examined during a TLB load attempt. this is true not only
30171 + * for PTEs holding a non-present entry but also present entries that will
30172 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30173 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30174 + * for our target pages since their PTEs are simply not in the TLBs at all.
30175 +
30176 + * the best thing in omitting it is that we gain around 15-20% speed in the
30177 + * fast path of the page fault handler and can get rid of tracing since we
30178 + * can no longer flush unintended entries.
30179 + */
30180 + "invlpg (%0)\n"
30181 +#endif
30182 + __copyuser_seg"testb $0,(%0)\n"
30183 + "xorb %3,(%1)\n"
30184 + :
30185 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30186 + : "memory", "cc");
30187 + pte_unmap_unlock(pte, ptl);
30188 + up_read(&mm->mmap_sem);
30189 + return 1;
30190 +}
30191 +#endif
30192 +
30193 /*
30194 * Handle a spurious fault caused by a stale TLB entry.
30195 *
30196 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
30197 static inline int
30198 access_error(unsigned long error_code, struct vm_area_struct *vma)
30199 {
30200 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30201 + return 1;
30202 +
30203 if (error_code & PF_WRITE) {
30204 /* write, present and write, not present: */
30205 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30206 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30207 if (error_code & PF_USER)
30208 return false;
30209
30210 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30211 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30212 return false;
30213
30214 return true;
30215 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30216 {
30217 struct vm_area_struct *vma;
30218 struct task_struct *tsk;
30219 - unsigned long address;
30220 struct mm_struct *mm;
30221 int fault;
30222 int write = error_code & PF_WRITE;
30223 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
30224 (write ? FAULT_FLAG_WRITE : 0);
30225
30226 - tsk = current;
30227 - mm = tsk->mm;
30228 -
30229 /* Get the faulting address: */
30230 - address = read_cr2();
30231 + unsigned long address = read_cr2();
30232 +
30233 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30234 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30235 + if (!search_exception_tables(regs->ip)) {
30236 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30237 + bad_area_nosemaphore(regs, error_code, address);
30238 + return;
30239 + }
30240 + if (address < pax_user_shadow_base) {
30241 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30242 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30243 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30244 + } else
30245 + address -= pax_user_shadow_base;
30246 + }
30247 +#endif
30248 +
30249 + tsk = current;
30250 + mm = tsk->mm;
30251
30252 /*
30253 * Detect and handle instructions that would cause a page fault for
30254 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30255 * User-mode registers count as a user access even for any
30256 * potential system fault or CPU buglet:
30257 */
30258 - if (user_mode_vm(regs)) {
30259 + if (user_mode(regs)) {
30260 local_irq_enable();
30261 error_code |= PF_USER;
30262 } else {
30263 @@ -1142,6 +1365,11 @@ retry:
30264 might_sleep();
30265 }
30266
30267 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30268 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30269 + return;
30270 +#endif
30271 +
30272 vma = find_vma(mm, address);
30273 if (unlikely(!vma)) {
30274 bad_area(regs, error_code, address);
30275 @@ -1153,18 +1381,24 @@ retry:
30276 bad_area(regs, error_code, address);
30277 return;
30278 }
30279 - if (error_code & PF_USER) {
30280 - /*
30281 - * Accessing the stack below %sp is always a bug.
30282 - * The large cushion allows instructions like enter
30283 - * and pusha to work. ("enter $65535, $31" pushes
30284 - * 32 pointers and then decrements %sp by 65535.)
30285 - */
30286 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30287 - bad_area(regs, error_code, address);
30288 - return;
30289 - }
30290 + /*
30291 + * Accessing the stack below %sp is always a bug.
30292 + * The large cushion allows instructions like enter
30293 + * and pusha to work. ("enter $65535, $31" pushes
30294 + * 32 pointers and then decrements %sp by 65535.)
30295 + */
30296 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30297 + bad_area(regs, error_code, address);
30298 + return;
30299 }
30300 +
30301 +#ifdef CONFIG_PAX_SEGMEXEC
30302 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30303 + bad_area(regs, error_code, address);
30304 + return;
30305 + }
30306 +#endif
30307 +
30308 if (unlikely(expand_stack(vma, address))) {
30309 bad_area(regs, error_code, address);
30310 return;
30311 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30312 __do_page_fault(regs, error_code);
30313 exception_exit(prev_state);
30314 }
30315 +
30316 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30317 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30318 +{
30319 + struct mm_struct *mm = current->mm;
30320 + unsigned long ip = regs->ip;
30321 +
30322 + if (v8086_mode(regs))
30323 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30324 +
30325 +#ifdef CONFIG_PAX_PAGEEXEC
30326 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30327 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30328 + return true;
30329 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30330 + return true;
30331 + return false;
30332 + }
30333 +#endif
30334 +
30335 +#ifdef CONFIG_PAX_SEGMEXEC
30336 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30337 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30338 + return true;
30339 + return false;
30340 + }
30341 +#endif
30342 +
30343 + return false;
30344 +}
30345 +#endif
30346 +
30347 +#ifdef CONFIG_PAX_EMUTRAMP
30348 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30349 +{
30350 + int err;
30351 +
30352 + do { /* PaX: libffi trampoline emulation */
30353 + unsigned char mov, jmp;
30354 + unsigned int addr1, addr2;
30355 +
30356 +#ifdef CONFIG_X86_64
30357 + if ((regs->ip + 9) >> 32)
30358 + break;
30359 +#endif
30360 +
30361 + err = get_user(mov, (unsigned char __user *)regs->ip);
30362 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30363 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30364 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30365 +
30366 + if (err)
30367 + break;
30368 +
30369 + if (mov == 0xB8 && jmp == 0xE9) {
30370 + regs->ax = addr1;
30371 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30372 + return 2;
30373 + }
30374 + } while (0);
30375 +
30376 + do { /* PaX: gcc trampoline emulation #1 */
30377 + unsigned char mov1, mov2;
30378 + unsigned short jmp;
30379 + unsigned int addr1, addr2;
30380 +
30381 +#ifdef CONFIG_X86_64
30382 + if ((regs->ip + 11) >> 32)
30383 + break;
30384 +#endif
30385 +
30386 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30387 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30388 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30389 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30390 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30391 +
30392 + if (err)
30393 + break;
30394 +
30395 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30396 + regs->cx = addr1;
30397 + regs->ax = addr2;
30398 + regs->ip = addr2;
30399 + return 2;
30400 + }
30401 + } while (0);
30402 +
30403 + do { /* PaX: gcc trampoline emulation #2 */
30404 + unsigned char mov, jmp;
30405 + unsigned int addr1, addr2;
30406 +
30407 +#ifdef CONFIG_X86_64
30408 + if ((regs->ip + 9) >> 32)
30409 + break;
30410 +#endif
30411 +
30412 + err = get_user(mov, (unsigned char __user *)regs->ip);
30413 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30414 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30415 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30416 +
30417 + if (err)
30418 + break;
30419 +
30420 + if (mov == 0xB9 && jmp == 0xE9) {
30421 + regs->cx = addr1;
30422 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30423 + return 2;
30424 + }
30425 + } while (0);
30426 +
30427 + return 1; /* PaX in action */
30428 +}
30429 +
30430 +#ifdef CONFIG_X86_64
30431 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30432 +{
30433 + int err;
30434 +
30435 + do { /* PaX: libffi trampoline emulation */
30436 + unsigned short mov1, mov2, jmp1;
30437 + unsigned char stcclc, jmp2;
30438 + unsigned long addr1, addr2;
30439 +
30440 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30441 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30442 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30443 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30444 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30445 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30446 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30447 +
30448 + if (err)
30449 + break;
30450 +
30451 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30452 + regs->r11 = addr1;
30453 + regs->r10 = addr2;
30454 + if (stcclc == 0xF8)
30455 + regs->flags &= ~X86_EFLAGS_CF;
30456 + else
30457 + regs->flags |= X86_EFLAGS_CF;
30458 + regs->ip = addr1;
30459 + return 2;
30460 + }
30461 + } while (0);
30462 +
30463 + do { /* PaX: gcc trampoline emulation #1 */
30464 + unsigned short mov1, mov2, jmp1;
30465 + unsigned char jmp2;
30466 + unsigned int addr1;
30467 + unsigned long addr2;
30468 +
30469 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30470 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30471 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30472 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30473 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30474 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30475 +
30476 + if (err)
30477 + break;
30478 +
30479 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30480 + regs->r11 = addr1;
30481 + regs->r10 = addr2;
30482 + regs->ip = addr1;
30483 + return 2;
30484 + }
30485 + } while (0);
30486 +
30487 + do { /* PaX: gcc trampoline emulation #2 */
30488 + unsigned short mov1, mov2, jmp1;
30489 + unsigned char jmp2;
30490 + unsigned long addr1, addr2;
30491 +
30492 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30493 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30494 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30495 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30496 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30497 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30498 +
30499 + if (err)
30500 + break;
30501 +
30502 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30503 + regs->r11 = addr1;
30504 + regs->r10 = addr2;
30505 + regs->ip = addr1;
30506 + return 2;
30507 + }
30508 + } while (0);
30509 +
30510 + return 1; /* PaX in action */
30511 +}
30512 +#endif
30513 +
30514 +/*
30515 + * PaX: decide what to do with offenders (regs->ip = fault address)
30516 + *
30517 + * returns 1 when task should be killed
30518 + * 2 when gcc trampoline was detected
30519 + */
30520 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30521 +{
30522 + if (v8086_mode(regs))
30523 + return 1;
30524 +
30525 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30526 + return 1;
30527 +
30528 +#ifdef CONFIG_X86_32
30529 + return pax_handle_fetch_fault_32(regs);
30530 +#else
30531 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30532 + return pax_handle_fetch_fault_32(regs);
30533 + else
30534 + return pax_handle_fetch_fault_64(regs);
30535 +#endif
30536 +}
30537 +#endif
30538 +
30539 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30540 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30541 +{
30542 + long i;
30543 +
30544 + printk(KERN_ERR "PAX: bytes at PC: ");
30545 + for (i = 0; i < 20; i++) {
30546 + unsigned char c;
30547 + if (get_user(c, (unsigned char __force_user *)pc+i))
30548 + printk(KERN_CONT "?? ");
30549 + else
30550 + printk(KERN_CONT "%02x ", c);
30551 + }
30552 + printk("\n");
30553 +
30554 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30555 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30556 + unsigned long c;
30557 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30558 +#ifdef CONFIG_X86_32
30559 + printk(KERN_CONT "???????? ");
30560 +#else
30561 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30562 + printk(KERN_CONT "???????? ???????? ");
30563 + else
30564 + printk(KERN_CONT "???????????????? ");
30565 +#endif
30566 + } else {
30567 +#ifdef CONFIG_X86_64
30568 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30569 + printk(KERN_CONT "%08x ", (unsigned int)c);
30570 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30571 + } else
30572 +#endif
30573 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30574 + }
30575 + }
30576 + printk("\n");
30577 +}
30578 +#endif
30579 +
30580 +/**
30581 + * probe_kernel_write(): safely attempt to write to a location
30582 + * @dst: address to write to
30583 + * @src: pointer to the data that shall be written
30584 + * @size: size of the data chunk
30585 + *
30586 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30587 + * happens, handle that and return -EFAULT.
30588 + */
30589 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30590 +{
30591 + long ret;
30592 + mm_segment_t old_fs = get_fs();
30593 +
30594 + set_fs(KERNEL_DS);
30595 + pagefault_disable();
30596 + pax_open_kernel();
30597 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30598 + pax_close_kernel();
30599 + pagefault_enable();
30600 + set_fs(old_fs);
30601 +
30602 + return ret ? -EFAULT : 0;
30603 +}
30604 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30605 index dd74e46..7d26398 100644
30606 --- a/arch/x86/mm/gup.c
30607 +++ b/arch/x86/mm/gup.c
30608 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30609 addr = start;
30610 len = (unsigned long) nr_pages << PAGE_SHIFT;
30611 end = start + len;
30612 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30613 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30614 (void __user *)start, len)))
30615 return 0;
30616
30617 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30618 index 4500142..53a363c 100644
30619 --- a/arch/x86/mm/highmem_32.c
30620 +++ b/arch/x86/mm/highmem_32.c
30621 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30622 idx = type + KM_TYPE_NR*smp_processor_id();
30623 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30624 BUG_ON(!pte_none(*(kmap_pte-idx)));
30625 +
30626 + pax_open_kernel();
30627 set_pte(kmap_pte-idx, mk_pte(page, prot));
30628 + pax_close_kernel();
30629 +
30630 arch_flush_lazy_mmu_mode();
30631
30632 return (void *)vaddr;
30633 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30634 index 7e73e8c..11d3b86 100644
30635 --- a/arch/x86/mm/hugetlbpage.c
30636 +++ b/arch/x86/mm/hugetlbpage.c
30637 @@ -84,23 +84,30 @@ int pud_huge(pud_t pud)
30638 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30639 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30640 unsigned long addr, unsigned long len,
30641 - unsigned long pgoff, unsigned long flags)
30642 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30643 {
30644 struct hstate *h = hstate_file(file);
30645 struct vm_unmapped_area_info info;
30646 -
30647 +
30648 info.flags = 0;
30649 info.length = len;
30650 info.low_limit = TASK_UNMAPPED_BASE;
30651 +
30652 +#ifdef CONFIG_PAX_RANDMMAP
30653 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30654 + info.low_limit += current->mm->delta_mmap;
30655 +#endif
30656 +
30657 info.high_limit = TASK_SIZE;
30658 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30659 info.align_offset = 0;
30660 + info.threadstack_offset = offset;
30661 return vm_unmapped_area(&info);
30662 }
30663
30664 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30665 unsigned long addr0, unsigned long len,
30666 - unsigned long pgoff, unsigned long flags)
30667 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30668 {
30669 struct hstate *h = hstate_file(file);
30670 struct vm_unmapped_area_info info;
30671 @@ -112,6 +119,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30672 info.high_limit = current->mm->mmap_base;
30673 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30674 info.align_offset = 0;
30675 + info.threadstack_offset = offset;
30676 addr = vm_unmapped_area(&info);
30677
30678 /*
30679 @@ -124,6 +132,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30680 VM_BUG_ON(addr != -ENOMEM);
30681 info.flags = 0;
30682 info.low_limit = TASK_UNMAPPED_BASE;
30683 +
30684 +#ifdef CONFIG_PAX_RANDMMAP
30685 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30686 + info.low_limit += current->mm->delta_mmap;
30687 +#endif
30688 +
30689 info.high_limit = TASK_SIZE;
30690 addr = vm_unmapped_area(&info);
30691 }
30692 @@ -138,10 +152,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30693 struct hstate *h = hstate_file(file);
30694 struct mm_struct *mm = current->mm;
30695 struct vm_area_struct *vma;
30696 + unsigned long pax_task_size = TASK_SIZE;
30697 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30698
30699 if (len & ~huge_page_mask(h))
30700 return -EINVAL;
30701 - if (len > TASK_SIZE)
30702 +
30703 +#ifdef CONFIG_PAX_SEGMEXEC
30704 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30705 + pax_task_size = SEGMEXEC_TASK_SIZE;
30706 +#endif
30707 +
30708 + pax_task_size -= PAGE_SIZE;
30709 +
30710 + if (len > pax_task_size)
30711 return -ENOMEM;
30712
30713 if (flags & MAP_FIXED) {
30714 @@ -150,19 +174,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30715 return addr;
30716 }
30717
30718 +#ifdef CONFIG_PAX_RANDMMAP
30719 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30720 +#endif
30721 +
30722 if (addr) {
30723 addr = ALIGN(addr, huge_page_size(h));
30724 vma = find_vma(mm, addr);
30725 - if (TASK_SIZE - len >= addr &&
30726 - (!vma || addr + len <= vma->vm_start))
30727 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30728 return addr;
30729 }
30730 if (mm->get_unmapped_area == arch_get_unmapped_area)
30731 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30732 - pgoff, flags);
30733 + pgoff, flags, offset);
30734 else
30735 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30736 - pgoff, flags);
30737 + pgoff, flags, offset);
30738 }
30739
30740 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30741 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30742 index 04664cd..dae6e5d 100644
30743 --- a/arch/x86/mm/init.c
30744 +++ b/arch/x86/mm/init.c
30745 @@ -4,6 +4,7 @@
30746 #include <linux/swap.h>
30747 #include <linux/memblock.h>
30748 #include <linux/bootmem.h> /* for max_low_pfn */
30749 +#include <linux/tboot.h>
30750
30751 #include <asm/cacheflush.h>
30752 #include <asm/e820.h>
30753 @@ -17,6 +18,8 @@
30754 #include <asm/proto.h>
30755 #include <asm/dma.h> /* for MAX_DMA_PFN */
30756 #include <asm/microcode.h>
30757 +#include <asm/desc.h>
30758 +#include <asm/bios_ebda.h>
30759
30760 #include "mm_internal.h"
30761
30762 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30763 early_ioremap_page_table_range_init();
30764 #endif
30765
30766 +#ifdef CONFIG_PAX_PER_CPU_PGD
30767 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30768 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30769 + KERNEL_PGD_PTRS);
30770 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30771 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30772 + KERNEL_PGD_PTRS);
30773 + load_cr3(get_cpu_pgd(0, kernel));
30774 +#else
30775 load_cr3(swapper_pg_dir);
30776 +#endif
30777 +
30778 __flush_tlb_all();
30779
30780 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30781 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30782 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30783 * mmio resources as well as potential bios/acpi data regions.
30784 */
30785 +
30786 +#ifdef CONFIG_GRKERNSEC_KMEM
30787 +static unsigned int ebda_start __read_only;
30788 +static unsigned int ebda_end __read_only;
30789 +#endif
30790 +
30791 int devmem_is_allowed(unsigned long pagenr)
30792 {
30793 - if (pagenr < 256)
30794 +#ifdef CONFIG_GRKERNSEC_KMEM
30795 + /* allow BDA */
30796 + if (!pagenr)
30797 return 1;
30798 + /* allow EBDA */
30799 + if (pagenr >= ebda_start && pagenr < ebda_end)
30800 + return 1;
30801 + /* if tboot is in use, allow access to its hardcoded serial log range */
30802 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30803 + return 1;
30804 +#else
30805 + if (!pagenr)
30806 + return 1;
30807 +#ifdef CONFIG_VM86
30808 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30809 + return 1;
30810 +#endif
30811 +#endif
30812 +
30813 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30814 + return 1;
30815 +#ifdef CONFIG_GRKERNSEC_KMEM
30816 + /* throw out everything else below 1MB */
30817 + if (pagenr <= 256)
30818 + return 0;
30819 +#endif
30820 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30821 return 0;
30822 if (!page_is_ram(pagenr))
30823 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30824 #endif
30825 }
30826
30827 +#ifdef CONFIG_GRKERNSEC_KMEM
30828 +static inline void gr_init_ebda(void)
30829 +{
30830 + unsigned int ebda_addr;
30831 + unsigned int ebda_size = 0;
30832 +
30833 + ebda_addr = get_bios_ebda();
30834 + if (ebda_addr) {
30835 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30836 + ebda_size <<= 10;
30837 + }
30838 + if (ebda_addr && ebda_size) {
30839 + ebda_start = ebda_addr >> PAGE_SHIFT;
30840 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30841 + } else {
30842 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30843 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30844 + }
30845 +}
30846 +#else
30847 +static inline void gr_init_ebda(void) { }
30848 +#endif
30849 +
30850 void free_initmem(void)
30851 {
30852 +#ifdef CONFIG_PAX_KERNEXEC
30853 +#ifdef CONFIG_X86_32
30854 + /* PaX: limit KERNEL_CS to actual size */
30855 + unsigned long addr, limit;
30856 + struct desc_struct d;
30857 + int cpu;
30858 +#else
30859 + pgd_t *pgd;
30860 + pud_t *pud;
30861 + pmd_t *pmd;
30862 + unsigned long addr, end;
30863 +#endif
30864 +#endif
30865 +
30866 + gr_init_ebda();
30867 +
30868 +#ifdef CONFIG_PAX_KERNEXEC
30869 +#ifdef CONFIG_X86_32
30870 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30871 + limit = (limit - 1UL) >> PAGE_SHIFT;
30872 +
30873 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30874 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30875 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30876 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30877 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30878 + }
30879 +
30880 + /* PaX: make KERNEL_CS read-only */
30881 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30882 + if (!paravirt_enabled())
30883 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30884 +/*
30885 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30886 + pgd = pgd_offset_k(addr);
30887 + pud = pud_offset(pgd, addr);
30888 + pmd = pmd_offset(pud, addr);
30889 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30890 + }
30891 +*/
30892 +#ifdef CONFIG_X86_PAE
30893 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30894 +/*
30895 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30896 + pgd = pgd_offset_k(addr);
30897 + pud = pud_offset(pgd, addr);
30898 + pmd = pmd_offset(pud, addr);
30899 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30900 + }
30901 +*/
30902 +#endif
30903 +
30904 +#ifdef CONFIG_MODULES
30905 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30906 +#endif
30907 +
30908 +#else
30909 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30910 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30911 + pgd = pgd_offset_k(addr);
30912 + pud = pud_offset(pgd, addr);
30913 + pmd = pmd_offset(pud, addr);
30914 + if (!pmd_present(*pmd))
30915 + continue;
30916 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30917 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30918 + else
30919 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30920 + }
30921 +
30922 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30923 + end = addr + KERNEL_IMAGE_SIZE;
30924 + for (; addr < end; addr += PMD_SIZE) {
30925 + pgd = pgd_offset_k(addr);
30926 + pud = pud_offset(pgd, addr);
30927 + pmd = pmd_offset(pud, addr);
30928 + if (!pmd_present(*pmd))
30929 + continue;
30930 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30931 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30932 + }
30933 +#endif
30934 +
30935 + flush_tlb_all();
30936 +#endif
30937 +
30938 free_init_pages("unused kernel",
30939 (unsigned long)(&__init_begin),
30940 (unsigned long)(&__init_end));
30941 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30942 index 4287f1f..3b99c71 100644
30943 --- a/arch/x86/mm/init_32.c
30944 +++ b/arch/x86/mm/init_32.c
30945 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30946 bool __read_mostly __vmalloc_start_set = false;
30947
30948 /*
30949 - * Creates a middle page table and puts a pointer to it in the
30950 - * given global directory entry. This only returns the gd entry
30951 - * in non-PAE compilation mode, since the middle layer is folded.
30952 - */
30953 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30954 -{
30955 - pud_t *pud;
30956 - pmd_t *pmd_table;
30957 -
30958 -#ifdef CONFIG_X86_PAE
30959 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30960 - pmd_table = (pmd_t *)alloc_low_page();
30961 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30962 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30963 - pud = pud_offset(pgd, 0);
30964 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30965 -
30966 - return pmd_table;
30967 - }
30968 -#endif
30969 - pud = pud_offset(pgd, 0);
30970 - pmd_table = pmd_offset(pud, 0);
30971 -
30972 - return pmd_table;
30973 -}
30974 -
30975 -/*
30976 * Create a page table and place a pointer to it in a middle page
30977 * directory entry:
30978 */
30979 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30980 pte_t *page_table = (pte_t *)alloc_low_page();
30981
30982 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
30983 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30984 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
30985 +#else
30986 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
30987 +#endif
30988 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
30989 }
30990
30991 return pte_offset_kernel(pmd, 0);
30992 }
30993
30994 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
30995 +{
30996 + pud_t *pud;
30997 + pmd_t *pmd_table;
30998 +
30999 + pud = pud_offset(pgd, 0);
31000 + pmd_table = pmd_offset(pud, 0);
31001 +
31002 + return pmd_table;
31003 +}
31004 +
31005 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31006 {
31007 int pgd_idx = pgd_index(vaddr);
31008 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31009 int pgd_idx, pmd_idx;
31010 unsigned long vaddr;
31011 pgd_t *pgd;
31012 + pud_t *pud;
31013 pmd_t *pmd;
31014 pte_t *pte = NULL;
31015 unsigned long count = page_table_range_init_count(start, end);
31016 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31017 pgd = pgd_base + pgd_idx;
31018
31019 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31020 - pmd = one_md_table_init(pgd);
31021 - pmd = pmd + pmd_index(vaddr);
31022 + pud = pud_offset(pgd, vaddr);
31023 + pmd = pmd_offset(pud, vaddr);
31024 +
31025 +#ifdef CONFIG_X86_PAE
31026 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31027 +#endif
31028 +
31029 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31030 pmd++, pmd_idx++) {
31031 pte = page_table_kmap_check(one_page_table_init(pmd),
31032 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31033 }
31034 }
31035
31036 -static inline int is_kernel_text(unsigned long addr)
31037 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31038 {
31039 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31040 - return 1;
31041 - return 0;
31042 + if ((start > ktla_ktva((unsigned long)_etext) ||
31043 + end <= ktla_ktva((unsigned long)_stext)) &&
31044 + (start > ktla_ktva((unsigned long)_einittext) ||
31045 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31046 +
31047 +#ifdef CONFIG_ACPI_SLEEP
31048 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31049 +#endif
31050 +
31051 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31052 + return 0;
31053 + return 1;
31054 }
31055
31056 /*
31057 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31058 unsigned long last_map_addr = end;
31059 unsigned long start_pfn, end_pfn;
31060 pgd_t *pgd_base = swapper_pg_dir;
31061 - int pgd_idx, pmd_idx, pte_ofs;
31062 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31063 unsigned long pfn;
31064 pgd_t *pgd;
31065 + pud_t *pud;
31066 pmd_t *pmd;
31067 pte_t *pte;
31068 unsigned pages_2m, pages_4k;
31069 @@ -291,8 +295,13 @@ repeat:
31070 pfn = start_pfn;
31071 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31072 pgd = pgd_base + pgd_idx;
31073 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31074 - pmd = one_md_table_init(pgd);
31075 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31076 + pud = pud_offset(pgd, 0);
31077 + pmd = pmd_offset(pud, 0);
31078 +
31079 +#ifdef CONFIG_X86_PAE
31080 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31081 +#endif
31082
31083 if (pfn >= end_pfn)
31084 continue;
31085 @@ -304,14 +313,13 @@ repeat:
31086 #endif
31087 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31088 pmd++, pmd_idx++) {
31089 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31090 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31091
31092 /*
31093 * Map with big pages if possible, otherwise
31094 * create normal page tables:
31095 */
31096 if (use_pse) {
31097 - unsigned int addr2;
31098 pgprot_t prot = PAGE_KERNEL_LARGE;
31099 /*
31100 * first pass will use the same initial
31101 @@ -322,11 +330,7 @@ repeat:
31102 _PAGE_PSE);
31103
31104 pfn &= PMD_MASK >> PAGE_SHIFT;
31105 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31106 - PAGE_OFFSET + PAGE_SIZE-1;
31107 -
31108 - if (is_kernel_text(addr) ||
31109 - is_kernel_text(addr2))
31110 + if (is_kernel_text(address, address + PMD_SIZE))
31111 prot = PAGE_KERNEL_LARGE_EXEC;
31112
31113 pages_2m++;
31114 @@ -343,7 +347,7 @@ repeat:
31115 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31116 pte += pte_ofs;
31117 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31118 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31119 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31120 pgprot_t prot = PAGE_KERNEL;
31121 /*
31122 * first pass will use the same initial
31123 @@ -351,7 +355,7 @@ repeat:
31124 */
31125 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31126
31127 - if (is_kernel_text(addr))
31128 + if (is_kernel_text(address, address + PAGE_SIZE))
31129 prot = PAGE_KERNEL_EXEC;
31130
31131 pages_4k++;
31132 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31133
31134 pud = pud_offset(pgd, va);
31135 pmd = pmd_offset(pud, va);
31136 - if (!pmd_present(*pmd))
31137 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31138 break;
31139
31140 /* should not be large page here */
31141 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31142
31143 static void __init pagetable_init(void)
31144 {
31145 - pgd_t *pgd_base = swapper_pg_dir;
31146 -
31147 - permanent_kmaps_init(pgd_base);
31148 + permanent_kmaps_init(swapper_pg_dir);
31149 }
31150
31151 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31152 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31153 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31154
31155 /* user-defined highmem size */
31156 @@ -787,10 +789,10 @@ void __init mem_init(void)
31157 ((unsigned long)&__init_end -
31158 (unsigned long)&__init_begin) >> 10,
31159
31160 - (unsigned long)&_etext, (unsigned long)&_edata,
31161 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31162 + (unsigned long)&_sdata, (unsigned long)&_edata,
31163 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31164
31165 - (unsigned long)&_text, (unsigned long)&_etext,
31166 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31167 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31168
31169 /*
31170 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31171 if (!kernel_set_to_readonly)
31172 return;
31173
31174 + start = ktla_ktva(start);
31175 pr_debug("Set kernel text: %lx - %lx for read write\n",
31176 start, start+size);
31177
31178 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31179 if (!kernel_set_to_readonly)
31180 return;
31181
31182 + start = ktla_ktva(start);
31183 pr_debug("Set kernel text: %lx - %lx for read only\n",
31184 start, start+size);
31185
31186 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31187 unsigned long start = PFN_ALIGN(_text);
31188 unsigned long size = PFN_ALIGN(_etext) - start;
31189
31190 + start = ktla_ktva(start);
31191 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31192 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31193 size >> 10);
31194 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31195 index 104d56a..62ba13f1 100644
31196 --- a/arch/x86/mm/init_64.c
31197 +++ b/arch/x86/mm/init_64.c
31198 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31199 * around without checking the pgd every time.
31200 */
31201
31202 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31203 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31204 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31205
31206 int force_personality32;
31207 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31208
31209 for (address = start; address <= end; address += PGDIR_SIZE) {
31210 const pgd_t *pgd_ref = pgd_offset_k(address);
31211 +
31212 +#ifdef CONFIG_PAX_PER_CPU_PGD
31213 + unsigned long cpu;
31214 +#else
31215 struct page *page;
31216 +#endif
31217
31218 if (pgd_none(*pgd_ref))
31219 continue;
31220
31221 spin_lock(&pgd_lock);
31222 +
31223 +#ifdef CONFIG_PAX_PER_CPU_PGD
31224 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31225 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31226 +
31227 + if (pgd_none(*pgd))
31228 + set_pgd(pgd, *pgd_ref);
31229 + else
31230 + BUG_ON(pgd_page_vaddr(*pgd)
31231 + != pgd_page_vaddr(*pgd_ref));
31232 + pgd = pgd_offset_cpu(cpu, kernel, address);
31233 +#else
31234 list_for_each_entry(page, &pgd_list, lru) {
31235 pgd_t *pgd;
31236 spinlock_t *pgt_lock;
31237 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31238 /* the pgt_lock only for Xen */
31239 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31240 spin_lock(pgt_lock);
31241 +#endif
31242
31243 if (pgd_none(*pgd))
31244 set_pgd(pgd, *pgd_ref);
31245 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31246 BUG_ON(pgd_page_vaddr(*pgd)
31247 != pgd_page_vaddr(*pgd_ref));
31248
31249 +#ifndef CONFIG_PAX_PER_CPU_PGD
31250 spin_unlock(pgt_lock);
31251 +#endif
31252 +
31253 }
31254 spin_unlock(&pgd_lock);
31255 }
31256 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31257 {
31258 if (pgd_none(*pgd)) {
31259 pud_t *pud = (pud_t *)spp_getpage();
31260 - pgd_populate(&init_mm, pgd, pud);
31261 + pgd_populate_kernel(&init_mm, pgd, pud);
31262 if (pud != pud_offset(pgd, 0))
31263 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31264 pud, pud_offset(pgd, 0));
31265 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31266 {
31267 if (pud_none(*pud)) {
31268 pmd_t *pmd = (pmd_t *) spp_getpage();
31269 - pud_populate(&init_mm, pud, pmd);
31270 + pud_populate_kernel(&init_mm, pud, pmd);
31271 if (pmd != pmd_offset(pud, 0))
31272 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31273 pmd, pmd_offset(pud, 0));
31274 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31275 pmd = fill_pmd(pud, vaddr);
31276 pte = fill_pte(pmd, vaddr);
31277
31278 + pax_open_kernel();
31279 set_pte(pte, new_pte);
31280 + pax_close_kernel();
31281
31282 /*
31283 * It's enough to flush this one mapping.
31284 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31285 pgd = pgd_offset_k((unsigned long)__va(phys));
31286 if (pgd_none(*pgd)) {
31287 pud = (pud_t *) spp_getpage();
31288 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31289 - _PAGE_USER));
31290 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31291 }
31292 pud = pud_offset(pgd, (unsigned long)__va(phys));
31293 if (pud_none(*pud)) {
31294 pmd = (pmd_t *) spp_getpage();
31295 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31296 - _PAGE_USER));
31297 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31298 }
31299 pmd = pmd_offset(pud, phys);
31300 BUG_ON(!pmd_none(*pmd));
31301 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31302 prot);
31303
31304 spin_lock(&init_mm.page_table_lock);
31305 - pud_populate(&init_mm, pud, pmd);
31306 + pud_populate_kernel(&init_mm, pud, pmd);
31307 spin_unlock(&init_mm.page_table_lock);
31308 }
31309 __flush_tlb_all();
31310 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31311 page_size_mask);
31312
31313 spin_lock(&init_mm.page_table_lock);
31314 - pgd_populate(&init_mm, pgd, pud);
31315 + pgd_populate_kernel(&init_mm, pgd, pud);
31316 spin_unlock(&init_mm.page_table_lock);
31317 pgd_changed = true;
31318 }
31319 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31320 static struct vm_area_struct gate_vma = {
31321 .vm_start = VSYSCALL_START,
31322 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31323 - .vm_page_prot = PAGE_READONLY_EXEC,
31324 - .vm_flags = VM_READ | VM_EXEC
31325 + .vm_page_prot = PAGE_READONLY,
31326 + .vm_flags = VM_READ
31327 };
31328
31329 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31330 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31331
31332 const char *arch_vma_name(struct vm_area_struct *vma)
31333 {
31334 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31335 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31336 return "[vdso]";
31337 if (vma == &gate_vma)
31338 return "[vsyscall]";
31339 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31340 index 7b179b4..6bd17777 100644
31341 --- a/arch/x86/mm/iomap_32.c
31342 +++ b/arch/x86/mm/iomap_32.c
31343 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31344 type = kmap_atomic_idx_push();
31345 idx = type + KM_TYPE_NR * smp_processor_id();
31346 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31347 +
31348 + pax_open_kernel();
31349 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31350 + pax_close_kernel();
31351 +
31352 arch_flush_lazy_mmu_mode();
31353
31354 return (void *)vaddr;
31355 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31356 index 0215e2c..1c62dab 100644
31357 --- a/arch/x86/mm/ioremap.c
31358 +++ b/arch/x86/mm/ioremap.c
31359 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31360 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31361 int is_ram = page_is_ram(pfn);
31362
31363 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31364 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31365 return NULL;
31366 WARN_ON_ONCE(is_ram);
31367 }
31368 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31369 *
31370 * Caller must ensure there is only one unmapping for the same pointer.
31371 */
31372 -void iounmap(volatile void __iomem *addr)
31373 +void iounmap(const volatile void __iomem *addr)
31374 {
31375 struct vm_struct *p, *o;
31376
31377 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31378
31379 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31380 if (page_is_ram(start >> PAGE_SHIFT))
31381 +#ifdef CONFIG_HIGHMEM
31382 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31383 +#endif
31384 return __va(phys);
31385
31386 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31387 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31388 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31389 {
31390 if (page_is_ram(phys >> PAGE_SHIFT))
31391 +#ifdef CONFIG_HIGHMEM
31392 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31393 +#endif
31394 return;
31395
31396 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31397 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31398 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31399
31400 static __initdata int after_paging_init;
31401 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31402 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31403
31404 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31405 {
31406 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31407 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31408
31409 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31410 - memset(bm_pte, 0, sizeof(bm_pte));
31411 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31412 + pmd_populate_user(&init_mm, pmd, bm_pte);
31413
31414 /*
31415 * The boot-ioremap range spans multiple pmds, for which
31416 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31417 index d87dd6d..bf3fa66 100644
31418 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31419 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31420 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31421 * memory (e.g. tracked pages)? For now, we need this to avoid
31422 * invoking kmemcheck for PnP BIOS calls.
31423 */
31424 - if (regs->flags & X86_VM_MASK)
31425 + if (v8086_mode(regs))
31426 return false;
31427 - if (regs->cs != __KERNEL_CS)
31428 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31429 return false;
31430
31431 pte = kmemcheck_pte_lookup(address);
31432 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31433 index 25e7e13..1964579 100644
31434 --- a/arch/x86/mm/mmap.c
31435 +++ b/arch/x86/mm/mmap.c
31436 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31437 * Leave an at least ~128 MB hole with possible stack randomization.
31438 */
31439 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31440 -#define MAX_GAP (TASK_SIZE/6*5)
31441 +#define MAX_GAP (pax_task_size/6*5)
31442
31443 static int mmap_is_legacy(void)
31444 {
31445 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31446 return rnd << PAGE_SHIFT;
31447 }
31448
31449 -static unsigned long mmap_base(void)
31450 +static unsigned long mmap_base(struct mm_struct *mm)
31451 {
31452 unsigned long gap = rlimit(RLIMIT_STACK);
31453 + unsigned long pax_task_size = TASK_SIZE;
31454 +
31455 +#ifdef CONFIG_PAX_SEGMEXEC
31456 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31457 + pax_task_size = SEGMEXEC_TASK_SIZE;
31458 +#endif
31459
31460 if (gap < MIN_GAP)
31461 gap = MIN_GAP;
31462 else if (gap > MAX_GAP)
31463 gap = MAX_GAP;
31464
31465 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31466 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31467 }
31468
31469 /*
31470 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31471 * does, but not when emulating X86_32
31472 */
31473 -static unsigned long mmap_legacy_base(void)
31474 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31475 {
31476 - if (mmap_is_ia32())
31477 + if (mmap_is_ia32()) {
31478 +
31479 +#ifdef CONFIG_PAX_SEGMEXEC
31480 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31481 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31482 + else
31483 +#endif
31484 +
31485 return TASK_UNMAPPED_BASE;
31486 - else
31487 + } else
31488 return TASK_UNMAPPED_BASE + mmap_rnd();
31489 }
31490
31491 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31492 */
31493 void arch_pick_mmap_layout(struct mm_struct *mm)
31494 {
31495 - mm->mmap_legacy_base = mmap_legacy_base();
31496 - mm->mmap_base = mmap_base();
31497 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31498 + mm->mmap_base = mmap_base(mm);
31499 +
31500 +#ifdef CONFIG_PAX_RANDMMAP
31501 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31502 + mm->mmap_legacy_base += mm->delta_mmap;
31503 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31504 + }
31505 +#endif
31506
31507 if (mmap_is_legacy()) {
31508 mm->mmap_base = mm->mmap_legacy_base;
31509 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31510 index 0057a7a..95c7edd 100644
31511 --- a/arch/x86/mm/mmio-mod.c
31512 +++ b/arch/x86/mm/mmio-mod.c
31513 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31514 break;
31515 default:
31516 {
31517 - unsigned char *ip = (unsigned char *)instptr;
31518 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31519 my_trace->opcode = MMIO_UNKNOWN_OP;
31520 my_trace->width = 0;
31521 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31522 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31523 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31524 void __iomem *addr)
31525 {
31526 - static atomic_t next_id;
31527 + static atomic_unchecked_t next_id;
31528 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31529 /* These are page-unaligned. */
31530 struct mmiotrace_map map = {
31531 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31532 .private = trace
31533 },
31534 .phys = offset,
31535 - .id = atomic_inc_return(&next_id)
31536 + .id = atomic_inc_return_unchecked(&next_id)
31537 };
31538 map.map_id = trace->id;
31539
31540 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31541 ioremap_trace_core(offset, size, addr);
31542 }
31543
31544 -static void iounmap_trace_core(volatile void __iomem *addr)
31545 +static void iounmap_trace_core(const volatile void __iomem *addr)
31546 {
31547 struct mmiotrace_map map = {
31548 .phys = 0,
31549 @@ -328,7 +328,7 @@ not_enabled:
31550 }
31551 }
31552
31553 -void mmiotrace_iounmap(volatile void __iomem *addr)
31554 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31555 {
31556 might_sleep();
31557 if (is_enabled()) /* recheck and proper locking in *_core() */
31558 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31559 index 8bf93ba..dbcd670 100644
31560 --- a/arch/x86/mm/numa.c
31561 +++ b/arch/x86/mm/numa.c
31562 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31563 return true;
31564 }
31565
31566 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31567 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31568 {
31569 unsigned long uninitialized_var(pfn_align);
31570 int i, nid;
31571 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31572 index d0b1773..4c3327c 100644
31573 --- a/arch/x86/mm/pageattr-test.c
31574 +++ b/arch/x86/mm/pageattr-test.c
31575 @@ -36,7 +36,7 @@ enum {
31576
31577 static int pte_testbit(pte_t pte)
31578 {
31579 - return pte_flags(pte) & _PAGE_UNUSED1;
31580 + return pte_flags(pte) & _PAGE_CPA_TEST;
31581 }
31582
31583 struct split_state {
31584 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31585 index bb32480..75f2f5e 100644
31586 --- a/arch/x86/mm/pageattr.c
31587 +++ b/arch/x86/mm/pageattr.c
31588 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31589 */
31590 #ifdef CONFIG_PCI_BIOS
31591 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31592 - pgprot_val(forbidden) |= _PAGE_NX;
31593 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31594 #endif
31595
31596 /*
31597 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31598 * Does not cover __inittext since that is gone later on. On
31599 * 64bit we do not enforce !NX on the low mapping
31600 */
31601 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31602 - pgprot_val(forbidden) |= _PAGE_NX;
31603 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31604 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31605
31606 +#ifdef CONFIG_DEBUG_RODATA
31607 /*
31608 * The .rodata section needs to be read-only. Using the pfn
31609 * catches all aliases.
31610 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31611 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31612 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31613 pgprot_val(forbidden) |= _PAGE_RW;
31614 +#endif
31615
31616 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31617 /*
31618 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31619 }
31620 #endif
31621
31622 +#ifdef CONFIG_PAX_KERNEXEC
31623 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31624 + pgprot_val(forbidden) |= _PAGE_RW;
31625 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31626 + }
31627 +#endif
31628 +
31629 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31630
31631 return prot;
31632 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31633 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31634 {
31635 /* change init_mm */
31636 + pax_open_kernel();
31637 set_pte_atomic(kpte, pte);
31638 +
31639 #ifdef CONFIG_X86_32
31640 if (!SHARED_KERNEL_PMD) {
31641 +
31642 +#ifdef CONFIG_PAX_PER_CPU_PGD
31643 + unsigned long cpu;
31644 +#else
31645 struct page *page;
31646 +#endif
31647
31648 +#ifdef CONFIG_PAX_PER_CPU_PGD
31649 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31650 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31651 +#else
31652 list_for_each_entry(page, &pgd_list, lru) {
31653 - pgd_t *pgd;
31654 + pgd_t *pgd = (pgd_t *)page_address(page);
31655 +#endif
31656 +
31657 pud_t *pud;
31658 pmd_t *pmd;
31659
31660 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31661 + pgd += pgd_index(address);
31662 pud = pud_offset(pgd, address);
31663 pmd = pmd_offset(pud, address);
31664 set_pte_atomic((pte_t *)pmd, pte);
31665 }
31666 }
31667 #endif
31668 + pax_close_kernel();
31669 }
31670
31671 static int
31672 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31673 index 6574388..87e9bef 100644
31674 --- a/arch/x86/mm/pat.c
31675 +++ b/arch/x86/mm/pat.c
31676 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31677
31678 if (!entry) {
31679 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31680 - current->comm, current->pid, start, end - 1);
31681 + current->comm, task_pid_nr(current), start, end - 1);
31682 return -EINVAL;
31683 }
31684
31685 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31686
31687 while (cursor < to) {
31688 if (!devmem_is_allowed(pfn)) {
31689 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31690 - current->comm, from, to - 1);
31691 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31692 + current->comm, from, to - 1, cursor);
31693 return 0;
31694 }
31695 cursor += PAGE_SIZE;
31696 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31697 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31698 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31699 "for [mem %#010Lx-%#010Lx]\n",
31700 - current->comm, current->pid,
31701 + current->comm, task_pid_nr(current),
31702 cattr_name(flags),
31703 base, (unsigned long long)(base + size-1));
31704 return -EINVAL;
31705 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31706 flags = lookup_memtype(paddr);
31707 if (want_flags != flags) {
31708 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31709 - current->comm, current->pid,
31710 + current->comm, task_pid_nr(current),
31711 cattr_name(want_flags),
31712 (unsigned long long)paddr,
31713 (unsigned long long)(paddr + size - 1),
31714 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31715 free_memtype(paddr, paddr + size);
31716 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31717 " for [mem %#010Lx-%#010Lx], got %s\n",
31718 - current->comm, current->pid,
31719 + current->comm, task_pid_nr(current),
31720 cattr_name(want_flags),
31721 (unsigned long long)paddr,
31722 (unsigned long long)(paddr + size - 1),
31723 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31724 index 415f6c4..d319983 100644
31725 --- a/arch/x86/mm/pat_rbtree.c
31726 +++ b/arch/x86/mm/pat_rbtree.c
31727 @@ -160,7 +160,7 @@ success:
31728
31729 failure:
31730 printk(KERN_INFO "%s:%d conflicting memory types "
31731 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31732 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31733 end, cattr_name(found_type), cattr_name(match->type));
31734 return -EBUSY;
31735 }
31736 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31737 index 9f0614d..92ae64a 100644
31738 --- a/arch/x86/mm/pf_in.c
31739 +++ b/arch/x86/mm/pf_in.c
31740 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31741 int i;
31742 enum reason_type rv = OTHERS;
31743
31744 - p = (unsigned char *)ins_addr;
31745 + p = (unsigned char *)ktla_ktva(ins_addr);
31746 p += skip_prefix(p, &prf);
31747 p += get_opcode(p, &opcode);
31748
31749 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31750 struct prefix_bits prf;
31751 int i;
31752
31753 - p = (unsigned char *)ins_addr;
31754 + p = (unsigned char *)ktla_ktva(ins_addr);
31755 p += skip_prefix(p, &prf);
31756 p += get_opcode(p, &opcode);
31757
31758 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31759 struct prefix_bits prf;
31760 int i;
31761
31762 - p = (unsigned char *)ins_addr;
31763 + p = (unsigned char *)ktla_ktva(ins_addr);
31764 p += skip_prefix(p, &prf);
31765 p += get_opcode(p, &opcode);
31766
31767 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31768 struct prefix_bits prf;
31769 int i;
31770
31771 - p = (unsigned char *)ins_addr;
31772 + p = (unsigned char *)ktla_ktva(ins_addr);
31773 p += skip_prefix(p, &prf);
31774 p += get_opcode(p, &opcode);
31775 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31776 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31777 struct prefix_bits prf;
31778 int i;
31779
31780 - p = (unsigned char *)ins_addr;
31781 + p = (unsigned char *)ktla_ktva(ins_addr);
31782 p += skip_prefix(p, &prf);
31783 p += get_opcode(p, &opcode);
31784 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31785 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31786 index dfa537a..fd45c64 100644
31787 --- a/arch/x86/mm/pgtable.c
31788 +++ b/arch/x86/mm/pgtable.c
31789 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31790 list_del(&page->lru);
31791 }
31792
31793 -#define UNSHARED_PTRS_PER_PGD \
31794 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31795 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31796 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31797
31798 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31799 +{
31800 + unsigned int count = USER_PGD_PTRS;
31801
31802 + if (!pax_user_shadow_base)
31803 + return;
31804 +
31805 + while (count--)
31806 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31807 +}
31808 +#endif
31809 +
31810 +#ifdef CONFIG_PAX_PER_CPU_PGD
31811 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31812 +{
31813 + unsigned int count = USER_PGD_PTRS;
31814 +
31815 + while (count--) {
31816 + pgd_t pgd;
31817 +
31818 +#ifdef CONFIG_X86_64
31819 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31820 +#else
31821 + pgd = *src++;
31822 +#endif
31823 +
31824 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31825 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31826 +#endif
31827 +
31828 + *dst++ = pgd;
31829 + }
31830 +
31831 +}
31832 +#endif
31833 +
31834 +#ifdef CONFIG_X86_64
31835 +#define pxd_t pud_t
31836 +#define pyd_t pgd_t
31837 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31838 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31839 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31840 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31841 +#define PYD_SIZE PGDIR_SIZE
31842 +#else
31843 +#define pxd_t pmd_t
31844 +#define pyd_t pud_t
31845 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31846 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31847 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31848 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31849 +#define PYD_SIZE PUD_SIZE
31850 +#endif
31851 +
31852 +#ifdef CONFIG_PAX_PER_CPU_PGD
31853 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31854 +static inline void pgd_dtor(pgd_t *pgd) {}
31855 +#else
31856 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31857 {
31858 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31859 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31860 pgd_list_del(pgd);
31861 spin_unlock(&pgd_lock);
31862 }
31863 +#endif
31864
31865 /*
31866 * List of all pgd's needed for non-PAE so it can invalidate entries
31867 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31868 * -- nyc
31869 */
31870
31871 -#ifdef CONFIG_X86_PAE
31872 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31873 /*
31874 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31875 * updating the top-level pagetable entries to guarantee the
31876 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31877 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31878 * and initialize the kernel pmds here.
31879 */
31880 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31881 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31882
31883 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31884 {
31885 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31886 */
31887 flush_tlb_mm(mm);
31888 }
31889 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31890 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31891 #else /* !CONFIG_X86_PAE */
31892
31893 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31894 -#define PREALLOCATED_PMDS 0
31895 +#define PREALLOCATED_PXDS 0
31896
31897 #endif /* CONFIG_X86_PAE */
31898
31899 -static void free_pmds(pmd_t *pmds[])
31900 +static void free_pxds(pxd_t *pxds[])
31901 {
31902 int i;
31903
31904 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31905 - if (pmds[i])
31906 - free_page((unsigned long)pmds[i]);
31907 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31908 + if (pxds[i])
31909 + free_page((unsigned long)pxds[i]);
31910 }
31911
31912 -static int preallocate_pmds(pmd_t *pmds[])
31913 +static int preallocate_pxds(pxd_t *pxds[])
31914 {
31915 int i;
31916 bool failed = false;
31917
31918 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31919 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31920 - if (pmd == NULL)
31921 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31922 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31923 + if (pxd == NULL)
31924 failed = true;
31925 - pmds[i] = pmd;
31926 + pxds[i] = pxd;
31927 }
31928
31929 if (failed) {
31930 - free_pmds(pmds);
31931 + free_pxds(pxds);
31932 return -ENOMEM;
31933 }
31934
31935 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31936 * preallocate which never got a corresponding vma will need to be
31937 * freed manually.
31938 */
31939 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31940 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31941 {
31942 int i;
31943
31944 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31945 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31946 pgd_t pgd = pgdp[i];
31947
31948 if (pgd_val(pgd) != 0) {
31949 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31950 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31951
31952 - pgdp[i] = native_make_pgd(0);
31953 + set_pgd(pgdp + i, native_make_pgd(0));
31954
31955 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31956 - pmd_free(mm, pmd);
31957 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31958 + pxd_free(mm, pxd);
31959 }
31960 }
31961 }
31962
31963 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31964 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31965 {
31966 - pud_t *pud;
31967 + pyd_t *pyd;
31968 int i;
31969
31970 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31971 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31972 return;
31973
31974 - pud = pud_offset(pgd, 0);
31975 -
31976 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
31977 - pmd_t *pmd = pmds[i];
31978 +#ifdef CONFIG_X86_64
31979 + pyd = pyd_offset(mm, 0L);
31980 +#else
31981 + pyd = pyd_offset(pgd, 0L);
31982 +#endif
31983
31984 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
31985 + pxd_t *pxd = pxds[i];
31986 if (i >= KERNEL_PGD_BOUNDARY)
31987 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31988 - sizeof(pmd_t) * PTRS_PER_PMD);
31989 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31990 + sizeof(pxd_t) * PTRS_PER_PMD);
31991
31992 - pud_populate(mm, pud, pmd);
31993 + pyd_populate(mm, pyd, pxd);
31994 }
31995 }
31996
31997 pgd_t *pgd_alloc(struct mm_struct *mm)
31998 {
31999 pgd_t *pgd;
32000 - pmd_t *pmds[PREALLOCATED_PMDS];
32001 + pxd_t *pxds[PREALLOCATED_PXDS];
32002
32003 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32004
32005 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32006
32007 mm->pgd = pgd;
32008
32009 - if (preallocate_pmds(pmds) != 0)
32010 + if (preallocate_pxds(pxds) != 0)
32011 goto out_free_pgd;
32012
32013 if (paravirt_pgd_alloc(mm) != 0)
32014 - goto out_free_pmds;
32015 + goto out_free_pxds;
32016
32017 /*
32018 * Make sure that pre-populating the pmds is atomic with
32019 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32020 spin_lock(&pgd_lock);
32021
32022 pgd_ctor(mm, pgd);
32023 - pgd_prepopulate_pmd(mm, pgd, pmds);
32024 + pgd_prepopulate_pxd(mm, pgd, pxds);
32025
32026 spin_unlock(&pgd_lock);
32027
32028 return pgd;
32029
32030 -out_free_pmds:
32031 - free_pmds(pmds);
32032 +out_free_pxds:
32033 + free_pxds(pxds);
32034 out_free_pgd:
32035 free_page((unsigned long)pgd);
32036 out:
32037 @@ -300,7 +363,7 @@ out:
32038
32039 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32040 {
32041 - pgd_mop_up_pmds(mm, pgd);
32042 + pgd_mop_up_pxds(mm, pgd);
32043 pgd_dtor(pgd);
32044 paravirt_pgd_free(mm, pgd);
32045 free_page((unsigned long)pgd);
32046 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32047 index a69bcb8..19068ab 100644
32048 --- a/arch/x86/mm/pgtable_32.c
32049 +++ b/arch/x86/mm/pgtable_32.c
32050 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32051 return;
32052 }
32053 pte = pte_offset_kernel(pmd, vaddr);
32054 +
32055 + pax_open_kernel();
32056 if (pte_val(pteval))
32057 set_pte_at(&init_mm, vaddr, pte, pteval);
32058 else
32059 pte_clear(&init_mm, vaddr, pte);
32060 + pax_close_kernel();
32061
32062 /*
32063 * It's enough to flush this one mapping.
32064 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32065 index e666cbb..61788c45 100644
32066 --- a/arch/x86/mm/physaddr.c
32067 +++ b/arch/x86/mm/physaddr.c
32068 @@ -10,7 +10,7 @@
32069 #ifdef CONFIG_X86_64
32070
32071 #ifdef CONFIG_DEBUG_VIRTUAL
32072 -unsigned long __phys_addr(unsigned long x)
32073 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32074 {
32075 unsigned long y = x - __START_KERNEL_map;
32076
32077 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32078 #else
32079
32080 #ifdef CONFIG_DEBUG_VIRTUAL
32081 -unsigned long __phys_addr(unsigned long x)
32082 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32083 {
32084 unsigned long phys_addr = x - PAGE_OFFSET;
32085 /* VMALLOC_* aren't constants */
32086 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32087 index 90555bf..f5f1828 100644
32088 --- a/arch/x86/mm/setup_nx.c
32089 +++ b/arch/x86/mm/setup_nx.c
32090 @@ -5,8 +5,10 @@
32091 #include <asm/pgtable.h>
32092 #include <asm/proto.h>
32093
32094 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32095 static int disable_nx;
32096
32097 +#ifndef CONFIG_PAX_PAGEEXEC
32098 /*
32099 * noexec = on|off
32100 *
32101 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32102 return 0;
32103 }
32104 early_param("noexec", noexec_setup);
32105 +#endif
32106 +
32107 +#endif
32108
32109 void x86_configure_nx(void)
32110 {
32111 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32112 if (cpu_has_nx && !disable_nx)
32113 __supported_pte_mask |= _PAGE_NX;
32114 else
32115 +#endif
32116 __supported_pte_mask &= ~_PAGE_NX;
32117 }
32118
32119 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32120 index 282375f..e03a98f 100644
32121 --- a/arch/x86/mm/tlb.c
32122 +++ b/arch/x86/mm/tlb.c
32123 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32124 BUG();
32125 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32126 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32127 +
32128 +#ifndef CONFIG_PAX_PER_CPU_PGD
32129 load_cr3(swapper_pg_dir);
32130 +#endif
32131 +
32132 }
32133 }
32134 EXPORT_SYMBOL_GPL(leave_mm);
32135 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32136 new file mode 100644
32137 index 0000000..dace51c
32138 --- /dev/null
32139 +++ b/arch/x86/mm/uderef_64.c
32140 @@ -0,0 +1,37 @@
32141 +#include <linux/mm.h>
32142 +#include <asm/pgtable.h>
32143 +#include <asm/uaccess.h>
32144 +
32145 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32146 +/* PaX: due to the special call convention these functions must
32147 + * - remain leaf functions under all configurations,
32148 + * - never be called directly, only dereferenced from the wrappers.
32149 + */
32150 +void __pax_open_userland(void)
32151 +{
32152 + unsigned int cpu;
32153 +
32154 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32155 + return;
32156 +
32157 + cpu = raw_get_cpu();
32158 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32159 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32160 + raw_put_cpu_no_resched();
32161 +}
32162 +EXPORT_SYMBOL(__pax_open_userland);
32163 +
32164 +void __pax_close_userland(void)
32165 +{
32166 + unsigned int cpu;
32167 +
32168 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32169 + return;
32170 +
32171 + cpu = raw_get_cpu();
32172 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32173 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32174 + raw_put_cpu_no_resched();
32175 +}
32176 +EXPORT_SYMBOL(__pax_close_userland);
32177 +#endif
32178 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32179 index 877b9a1..a8ecf42 100644
32180 --- a/arch/x86/net/bpf_jit.S
32181 +++ b/arch/x86/net/bpf_jit.S
32182 @@ -9,6 +9,7 @@
32183 */
32184 #include <linux/linkage.h>
32185 #include <asm/dwarf2.h>
32186 +#include <asm/alternative-asm.h>
32187
32188 /*
32189 * Calling convention :
32190 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32191 jle bpf_slow_path_word
32192 mov (SKBDATA,%rsi),%eax
32193 bswap %eax /* ntohl() */
32194 + pax_force_retaddr
32195 ret
32196
32197 sk_load_half:
32198 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32199 jle bpf_slow_path_half
32200 movzwl (SKBDATA,%rsi),%eax
32201 rol $8,%ax # ntohs()
32202 + pax_force_retaddr
32203 ret
32204
32205 sk_load_byte:
32206 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32207 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32208 jle bpf_slow_path_byte
32209 movzbl (SKBDATA,%rsi),%eax
32210 + pax_force_retaddr
32211 ret
32212
32213 /**
32214 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32215 movzbl (SKBDATA,%rsi),%ebx
32216 and $15,%bl
32217 shl $2,%bl
32218 + pax_force_retaddr
32219 ret
32220
32221 /* rsi contains offset and can be scratched */
32222 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32223 js bpf_error
32224 mov -12(%rbp),%eax
32225 bswap %eax
32226 + pax_force_retaddr
32227 ret
32228
32229 bpf_slow_path_half:
32230 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32231 mov -12(%rbp),%ax
32232 rol $8,%ax
32233 movzwl %ax,%eax
32234 + pax_force_retaddr
32235 ret
32236
32237 bpf_slow_path_byte:
32238 bpf_slow_path_common(1)
32239 js bpf_error
32240 movzbl -12(%rbp),%eax
32241 + pax_force_retaddr
32242 ret
32243
32244 bpf_slow_path_byte_msh:
32245 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32246 and $15,%al
32247 shl $2,%al
32248 xchg %eax,%ebx
32249 + pax_force_retaddr
32250 ret
32251
32252 #define sk_negative_common(SIZE) \
32253 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32254 sk_negative_common(4)
32255 mov (%rax), %eax
32256 bswap %eax
32257 + pax_force_retaddr
32258 ret
32259
32260 bpf_slow_path_half_neg:
32261 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32262 mov (%rax),%ax
32263 rol $8,%ax
32264 movzwl %ax,%eax
32265 + pax_force_retaddr
32266 ret
32267
32268 bpf_slow_path_byte_neg:
32269 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32270 .globl sk_load_byte_negative_offset
32271 sk_negative_common(1)
32272 movzbl (%rax), %eax
32273 + pax_force_retaddr
32274 ret
32275
32276 bpf_slow_path_byte_msh_neg:
32277 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32278 and $15,%al
32279 shl $2,%al
32280 xchg %eax,%ebx
32281 + pax_force_retaddr
32282 ret
32283
32284 bpf_error:
32285 @@ -197,4 +210,5 @@ bpf_error:
32286 xor %eax,%eax
32287 mov -8(%rbp),%rbx
32288 leaveq
32289 + pax_force_retaddr
32290 ret
32291 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32292 index 79c216a..08d39cc 100644
32293 --- a/arch/x86/net/bpf_jit_comp.c
32294 +++ b/arch/x86/net/bpf_jit_comp.c
32295 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32296 return ptr + len;
32297 }
32298
32299 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32300 +#define MAX_INSTR_CODE_SIZE 96
32301 +#else
32302 +#define MAX_INSTR_CODE_SIZE 64
32303 +#endif
32304 +
32305 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32306
32307 #define EMIT1(b1) EMIT(b1, 1)
32308 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32309 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32310 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32311 +
32312 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32313 +/* original constant will appear in ecx */
32314 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32315 +do { \
32316 + /* mov ecx, randkey */ \
32317 + EMIT1(0xb9); \
32318 + EMIT(_key, 4); \
32319 + /* xor ecx, randkey ^ off */ \
32320 + EMIT2(0x81, 0xf1); \
32321 + EMIT((_key) ^ (_off), 4); \
32322 +} while (0)
32323 +
32324 +#define EMIT1_off32(b1, _off) \
32325 +do { \
32326 + switch (b1) { \
32327 + case 0x05: /* add eax, imm32 */ \
32328 + case 0x2d: /* sub eax, imm32 */ \
32329 + case 0x25: /* and eax, imm32 */ \
32330 + case 0x0d: /* or eax, imm32 */ \
32331 + case 0xb8: /* mov eax, imm32 */ \
32332 + case 0x35: /* xor eax, imm32 */ \
32333 + case 0x3d: /* cmp eax, imm32 */ \
32334 + case 0xa9: /* test eax, imm32 */ \
32335 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32336 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32337 + break; \
32338 + case 0xbb: /* mov ebx, imm32 */ \
32339 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32340 + /* mov ebx, ecx */ \
32341 + EMIT2(0x89, 0xcb); \
32342 + break; \
32343 + case 0xbe: /* mov esi, imm32 */ \
32344 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32345 + /* mov esi, ecx */ \
32346 + EMIT2(0x89, 0xce); \
32347 + break; \
32348 + case 0xe8: /* call rel imm32, always to known funcs */ \
32349 + EMIT1(b1); \
32350 + EMIT(_off, 4); \
32351 + break; \
32352 + case 0xe9: /* jmp rel imm32 */ \
32353 + EMIT1(b1); \
32354 + EMIT(_off, 4); \
32355 + /* prevent fall-through, we're not called if off = 0 */ \
32356 + EMIT(0xcccccccc, 4); \
32357 + EMIT(0xcccccccc, 4); \
32358 + break; \
32359 + default: \
32360 + BUILD_BUG(); \
32361 + } \
32362 +} while (0)
32363 +
32364 +#define EMIT2_off32(b1, b2, _off) \
32365 +do { \
32366 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32367 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32368 + EMIT(randkey, 4); \
32369 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32370 + EMIT((_off) - randkey, 4); \
32371 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32372 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32373 + /* imul eax, ecx */ \
32374 + EMIT3(0x0f, 0xaf, 0xc1); \
32375 + } else { \
32376 + BUILD_BUG(); \
32377 + } \
32378 +} while (0)
32379 +#else
32380 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32381 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32382 +#endif
32383
32384 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32385 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32386 @@ -91,6 +168,24 @@ do { \
32387 #define X86_JBE 0x76
32388 #define X86_JA 0x77
32389
32390 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32391 +#define APPEND_FLOW_VERIFY() \
32392 +do { \
32393 + /* mov ecx, randkey */ \
32394 + EMIT1(0xb9); \
32395 + EMIT(randkey, 4); \
32396 + /* cmp ecx, randkey */ \
32397 + EMIT2(0x81, 0xf9); \
32398 + EMIT(randkey, 4); \
32399 + /* jz after 8 int 3s */ \
32400 + EMIT2(0x74, 0x08); \
32401 + EMIT(0xcccccccc, 4); \
32402 + EMIT(0xcccccccc, 4); \
32403 +} while (0)
32404 +#else
32405 +#define APPEND_FLOW_VERIFY() do { } while (0)
32406 +#endif
32407 +
32408 #define EMIT_COND_JMP(op, offset) \
32409 do { \
32410 if (is_near(offset)) \
32411 @@ -98,6 +193,7 @@ do { \
32412 else { \
32413 EMIT2(0x0f, op + 0x10); \
32414 EMIT(offset, 4); /* jxx .+off32 */ \
32415 + APPEND_FLOW_VERIFY(); \
32416 } \
32417 } while (0)
32418
32419 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32420 return -1;
32421 }
32422
32423 -struct bpf_binary_header {
32424 - unsigned int pages;
32425 - /* Note : for security reasons, bpf code will follow a randomly
32426 - * sized amount of int3 instructions
32427 - */
32428 - u8 image[];
32429 -};
32430 -
32431 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32432 +/* Note : for security reasons, bpf code will follow a randomly
32433 + * sized amount of int3 instructions
32434 + */
32435 +static u8 *bpf_alloc_binary(unsigned int proglen,
32436 u8 **image_ptr)
32437 {
32438 unsigned int sz, hole;
32439 - struct bpf_binary_header *header;
32440 + u8 *header;
32441
32442 /* Most of BPF filters are really small,
32443 * but if some of them fill a page, allow at least
32444 * 128 extra bytes to insert a random section of int3
32445 */
32446 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32447 - header = module_alloc(sz);
32448 + sz = round_up(proglen + 128, PAGE_SIZE);
32449 + header = module_alloc_exec(sz);
32450 if (!header)
32451 return NULL;
32452
32453 + pax_open_kernel();
32454 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32455 + pax_close_kernel();
32456
32457 - header->pages = sz / PAGE_SIZE;
32458 - hole = sz - (proglen + sizeof(*header));
32459 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32460
32461 /* insert a random number of int3 instructions before BPF code */
32462 - *image_ptr = &header->image[prandom_u32() % hole];
32463 + *image_ptr = &header[prandom_u32() % hole];
32464 return header;
32465 }
32466
32467 void bpf_jit_compile(struct sk_filter *fp)
32468 {
32469 - u8 temp[64];
32470 + u8 temp[MAX_INSTR_CODE_SIZE];
32471 u8 *prog;
32472 unsigned int proglen, oldproglen = 0;
32473 int ilen, i;
32474 int t_offset, f_offset;
32475 u8 t_op, f_op, seen = 0, pass;
32476 u8 *image = NULL;
32477 - struct bpf_binary_header *header = NULL;
32478 + u8 *header = NULL;
32479 u8 *func;
32480 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32481 unsigned int cleanup_addr; /* epilogue code offset */
32482 unsigned int *addrs;
32483 const struct sock_filter *filter = fp->insns;
32484 int flen = fp->len;
32485 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32486 + unsigned int randkey;
32487 +#endif
32488
32489 if (!bpf_jit_enable)
32490 return;
32491 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32492 if (addrs == NULL)
32493 return;
32494
32495 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32496 + randkey = get_random_int();
32497 +#endif
32498 +
32499 /* Before first pass, make a rough estimation of addrs[]
32500 - * each bpf instruction is translated to less than 64 bytes
32501 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32502 */
32503 for (proglen = 0, i = 0; i < flen; i++) {
32504 - proglen += 64;
32505 + proglen += MAX_INSTR_CODE_SIZE;
32506 addrs[i] = proglen;
32507 }
32508 cleanup_addr = proglen; /* epilogue address */
32509 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32510 case BPF_S_ALU_MUL_K: /* A *= K */
32511 if (is_imm8(K))
32512 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32513 - else {
32514 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32515 - EMIT(K, 4);
32516 - }
32517 + else
32518 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32519 break;
32520 case BPF_S_ALU_DIV_X: /* A /= X; */
32521 seen |= SEEN_XREG;
32522 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32523 break;
32524 case BPF_S_ALU_MOD_K: /* A %= K; */
32525 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32526 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32527 + DILUTE_CONST_SEQUENCE(K, randkey);
32528 +#else
32529 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32530 +#endif
32531 EMIT2(0xf7, 0xf1); /* div %ecx */
32532 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32533 break;
32534 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32535 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32536 + DILUTE_CONST_SEQUENCE(K, randkey);
32537 + // imul rax, rcx
32538 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32539 +#else
32540 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32541 EMIT(K, 4);
32542 +#endif
32543 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32544 break;
32545 case BPF_S_ALU_AND_X:
32546 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32547 if (is_imm8(K)) {
32548 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32549 } else {
32550 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32551 - EMIT(K, 4);
32552 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32553 }
32554 } else {
32555 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32556 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32557 if (unlikely(proglen + ilen > oldproglen)) {
32558 pr_err("bpb_jit_compile fatal error\n");
32559 kfree(addrs);
32560 - module_free(NULL, header);
32561 + module_free_exec(NULL, image);
32562 return;
32563 }
32564 + pax_open_kernel();
32565 memcpy(image + proglen, temp, ilen);
32566 + pax_close_kernel();
32567 }
32568 proglen += ilen;
32569 addrs[i] = proglen;
32570 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32571
32572 if (image) {
32573 bpf_flush_icache(header, image + proglen);
32574 - set_memory_ro((unsigned long)header, header->pages);
32575 fp->bpf_func = (void *)image;
32576 }
32577 out:
32578 @@ -776,9 +883,7 @@ void bpf_jit_free(struct sk_filter *fp)
32579 {
32580 if (fp->bpf_func != sk_run_filter) {
32581 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32582 - struct bpf_binary_header *header = (void *)addr;
32583 -
32584 - set_memory_rw(addr, header->pages);
32585 - module_free(NULL, header);
32586 + set_memory_rw(addr, 1);
32587 + module_free_exec(NULL, (void *)addr);
32588 }
32589 }
32590 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32591 index d6aa6e8..266395a 100644
32592 --- a/arch/x86/oprofile/backtrace.c
32593 +++ b/arch/x86/oprofile/backtrace.c
32594 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32595 struct stack_frame_ia32 *fp;
32596 unsigned long bytes;
32597
32598 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32599 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32600 if (bytes != sizeof(bufhead))
32601 return NULL;
32602
32603 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32604 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32605
32606 oprofile_add_trace(bufhead[0].return_address);
32607
32608 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32609 struct stack_frame bufhead[2];
32610 unsigned long bytes;
32611
32612 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32613 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32614 if (bytes != sizeof(bufhead))
32615 return NULL;
32616
32617 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32618 {
32619 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32620
32621 - if (!user_mode_vm(regs)) {
32622 + if (!user_mode(regs)) {
32623 unsigned long stack = kernel_stack_pointer(regs);
32624 if (depth)
32625 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32626 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32627 index 48768df..ba9143c 100644
32628 --- a/arch/x86/oprofile/nmi_int.c
32629 +++ b/arch/x86/oprofile/nmi_int.c
32630 @@ -23,6 +23,7 @@
32631 #include <asm/nmi.h>
32632 #include <asm/msr.h>
32633 #include <asm/apic.h>
32634 +#include <asm/pgtable.h>
32635
32636 #include "op_counter.h"
32637 #include "op_x86_model.h"
32638 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32639 if (ret)
32640 return ret;
32641
32642 - if (!model->num_virt_counters)
32643 - model->num_virt_counters = model->num_counters;
32644 + if (!model->num_virt_counters) {
32645 + pax_open_kernel();
32646 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32647 + pax_close_kernel();
32648 + }
32649
32650 mux_init(ops);
32651
32652 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32653 index b2b9443..be58856 100644
32654 --- a/arch/x86/oprofile/op_model_amd.c
32655 +++ b/arch/x86/oprofile/op_model_amd.c
32656 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32657 num_counters = AMD64_NUM_COUNTERS;
32658 }
32659
32660 - op_amd_spec.num_counters = num_counters;
32661 - op_amd_spec.num_controls = num_counters;
32662 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32663 + pax_open_kernel();
32664 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32665 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32666 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32667 + pax_close_kernel();
32668
32669 return 0;
32670 }
32671 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32672 index d90528e..0127e2b 100644
32673 --- a/arch/x86/oprofile/op_model_ppro.c
32674 +++ b/arch/x86/oprofile/op_model_ppro.c
32675 @@ -19,6 +19,7 @@
32676 #include <asm/msr.h>
32677 #include <asm/apic.h>
32678 #include <asm/nmi.h>
32679 +#include <asm/pgtable.h>
32680
32681 #include "op_x86_model.h"
32682 #include "op_counter.h"
32683 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32684
32685 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32686
32687 - op_arch_perfmon_spec.num_counters = num_counters;
32688 - op_arch_perfmon_spec.num_controls = num_counters;
32689 + pax_open_kernel();
32690 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32691 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32692 + pax_close_kernel();
32693 }
32694
32695 static int arch_perfmon_init(struct oprofile_operations *ignore)
32696 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32697 index 71e8a67..6a313bb 100644
32698 --- a/arch/x86/oprofile/op_x86_model.h
32699 +++ b/arch/x86/oprofile/op_x86_model.h
32700 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32701 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32702 struct op_msrs const * const msrs);
32703 #endif
32704 -};
32705 +} __do_const;
32706
32707 struct op_counter_config;
32708
32709 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32710 index 372e9b8..e775a6c 100644
32711 --- a/arch/x86/pci/irq.c
32712 +++ b/arch/x86/pci/irq.c
32713 @@ -50,7 +50,7 @@ struct irq_router {
32714 struct irq_router_handler {
32715 u16 vendor;
32716 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32717 -};
32718 +} __do_const;
32719
32720 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32721 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32722 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32723 return 0;
32724 }
32725
32726 -static __initdata struct irq_router_handler pirq_routers[] = {
32727 +static __initconst const struct irq_router_handler pirq_routers[] = {
32728 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32729 { PCI_VENDOR_ID_AL, ali_router_probe },
32730 { PCI_VENDOR_ID_ITE, ite_router_probe },
32731 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32732 static void __init pirq_find_router(struct irq_router *r)
32733 {
32734 struct irq_routing_table *rt = pirq_table;
32735 - struct irq_router_handler *h;
32736 + const struct irq_router_handler *h;
32737
32738 #ifdef CONFIG_PCI_BIOS
32739 if (!rt->signature) {
32740 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32741 return 0;
32742 }
32743
32744 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32745 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32746 {
32747 .callback = fix_broken_hp_bios_irq9,
32748 .ident = "HP Pavilion N5400 Series Laptop",
32749 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32750 index 6eb18c4..20d83de 100644
32751 --- a/arch/x86/pci/mrst.c
32752 +++ b/arch/x86/pci/mrst.c
32753 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
32754 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
32755 pci_mmcfg_late_init();
32756 pcibios_enable_irq = mrst_pci_irq_enable;
32757 - pci_root_ops = pci_mrst_ops;
32758 + pax_open_kernel();
32759 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32760 + pax_close_kernel();
32761 pci_soc_mode = 1;
32762 /* Continue with standard init */
32763 return 1;
32764 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32765 index c77b24a..c979855 100644
32766 --- a/arch/x86/pci/pcbios.c
32767 +++ b/arch/x86/pci/pcbios.c
32768 @@ -79,7 +79,7 @@ union bios32 {
32769 static struct {
32770 unsigned long address;
32771 unsigned short segment;
32772 -} bios32_indirect = { 0, __KERNEL_CS };
32773 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32774
32775 /*
32776 * Returns the entry point for the given service, NULL on error
32777 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32778 unsigned long length; /* %ecx */
32779 unsigned long entry; /* %edx */
32780 unsigned long flags;
32781 + struct desc_struct d, *gdt;
32782
32783 local_irq_save(flags);
32784 - __asm__("lcall *(%%edi); cld"
32785 +
32786 + gdt = get_cpu_gdt_table(smp_processor_id());
32787 +
32788 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32789 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32790 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32791 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32792 +
32793 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32794 : "=a" (return_code),
32795 "=b" (address),
32796 "=c" (length),
32797 "=d" (entry)
32798 : "0" (service),
32799 "1" (0),
32800 - "D" (&bios32_indirect));
32801 + "D" (&bios32_indirect),
32802 + "r"(__PCIBIOS_DS)
32803 + : "memory");
32804 +
32805 + pax_open_kernel();
32806 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32807 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32808 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32809 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32810 + pax_close_kernel();
32811 +
32812 local_irq_restore(flags);
32813
32814 switch (return_code) {
32815 - case 0:
32816 - return address + entry;
32817 - case 0x80: /* Not present */
32818 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32819 - return 0;
32820 - default: /* Shouldn't happen */
32821 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32822 - service, return_code);
32823 + case 0: {
32824 + int cpu;
32825 + unsigned char flags;
32826 +
32827 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32828 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32829 + printk(KERN_WARNING "bios32_service: not valid\n");
32830 return 0;
32831 + }
32832 + address = address + PAGE_OFFSET;
32833 + length += 16UL; /* some BIOSs underreport this... */
32834 + flags = 4;
32835 + if (length >= 64*1024*1024) {
32836 + length >>= PAGE_SHIFT;
32837 + flags |= 8;
32838 + }
32839 +
32840 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32841 + gdt = get_cpu_gdt_table(cpu);
32842 + pack_descriptor(&d, address, length, 0x9b, flags);
32843 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32844 + pack_descriptor(&d, address, length, 0x93, flags);
32845 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32846 + }
32847 + return entry;
32848 + }
32849 + case 0x80: /* Not present */
32850 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32851 + return 0;
32852 + default: /* Shouldn't happen */
32853 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32854 + service, return_code);
32855 + return 0;
32856 }
32857 }
32858
32859 static struct {
32860 unsigned long address;
32861 unsigned short segment;
32862 -} pci_indirect = { 0, __KERNEL_CS };
32863 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32864
32865 -static int pci_bios_present;
32866 +static int pci_bios_present __read_only;
32867
32868 static int check_pcibios(void)
32869 {
32870 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32871 unsigned long flags, pcibios_entry;
32872
32873 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32874 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32875 + pci_indirect.address = pcibios_entry;
32876
32877 local_irq_save(flags);
32878 - __asm__(
32879 - "lcall *(%%edi); cld\n\t"
32880 + __asm__("movw %w6, %%ds\n\t"
32881 + "lcall *%%ss:(%%edi); cld\n\t"
32882 + "push %%ss\n\t"
32883 + "pop %%ds\n\t"
32884 "jc 1f\n\t"
32885 "xor %%ah, %%ah\n"
32886 "1:"
32887 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32888 "=b" (ebx),
32889 "=c" (ecx)
32890 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32891 - "D" (&pci_indirect)
32892 + "D" (&pci_indirect),
32893 + "r" (__PCIBIOS_DS)
32894 : "memory");
32895 local_irq_restore(flags);
32896
32897 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32898
32899 switch (len) {
32900 case 1:
32901 - __asm__("lcall *(%%esi); cld\n\t"
32902 + __asm__("movw %w6, %%ds\n\t"
32903 + "lcall *%%ss:(%%esi); cld\n\t"
32904 + "push %%ss\n\t"
32905 + "pop %%ds\n\t"
32906 "jc 1f\n\t"
32907 "xor %%ah, %%ah\n"
32908 "1:"
32909 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32910 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32911 "b" (bx),
32912 "D" ((long)reg),
32913 - "S" (&pci_indirect));
32914 + "S" (&pci_indirect),
32915 + "r" (__PCIBIOS_DS));
32916 /*
32917 * Zero-extend the result beyond 8 bits, do not trust the
32918 * BIOS having done it:
32919 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32920 *value &= 0xff;
32921 break;
32922 case 2:
32923 - __asm__("lcall *(%%esi); cld\n\t"
32924 + __asm__("movw %w6, %%ds\n\t"
32925 + "lcall *%%ss:(%%esi); cld\n\t"
32926 + "push %%ss\n\t"
32927 + "pop %%ds\n\t"
32928 "jc 1f\n\t"
32929 "xor %%ah, %%ah\n"
32930 "1:"
32931 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32932 : "1" (PCIBIOS_READ_CONFIG_WORD),
32933 "b" (bx),
32934 "D" ((long)reg),
32935 - "S" (&pci_indirect));
32936 + "S" (&pci_indirect),
32937 + "r" (__PCIBIOS_DS));
32938 /*
32939 * Zero-extend the result beyond 16 bits, do not trust the
32940 * BIOS having done it:
32941 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32942 *value &= 0xffff;
32943 break;
32944 case 4:
32945 - __asm__("lcall *(%%esi); cld\n\t"
32946 + __asm__("movw %w6, %%ds\n\t"
32947 + "lcall *%%ss:(%%esi); cld\n\t"
32948 + "push %%ss\n\t"
32949 + "pop %%ds\n\t"
32950 "jc 1f\n\t"
32951 "xor %%ah, %%ah\n"
32952 "1:"
32953 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32954 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32955 "b" (bx),
32956 "D" ((long)reg),
32957 - "S" (&pci_indirect));
32958 + "S" (&pci_indirect),
32959 + "r" (__PCIBIOS_DS));
32960 break;
32961 }
32962
32963 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32964
32965 switch (len) {
32966 case 1:
32967 - __asm__("lcall *(%%esi); cld\n\t"
32968 + __asm__("movw %w6, %%ds\n\t"
32969 + "lcall *%%ss:(%%esi); cld\n\t"
32970 + "push %%ss\n\t"
32971 + "pop %%ds\n\t"
32972 "jc 1f\n\t"
32973 "xor %%ah, %%ah\n"
32974 "1:"
32975 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32976 "c" (value),
32977 "b" (bx),
32978 "D" ((long)reg),
32979 - "S" (&pci_indirect));
32980 + "S" (&pci_indirect),
32981 + "r" (__PCIBIOS_DS));
32982 break;
32983 case 2:
32984 - __asm__("lcall *(%%esi); cld\n\t"
32985 + __asm__("movw %w6, %%ds\n\t"
32986 + "lcall *%%ss:(%%esi); cld\n\t"
32987 + "push %%ss\n\t"
32988 + "pop %%ds\n\t"
32989 "jc 1f\n\t"
32990 "xor %%ah, %%ah\n"
32991 "1:"
32992 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32993 "c" (value),
32994 "b" (bx),
32995 "D" ((long)reg),
32996 - "S" (&pci_indirect));
32997 + "S" (&pci_indirect),
32998 + "r" (__PCIBIOS_DS));
32999 break;
33000 case 4:
33001 - __asm__("lcall *(%%esi); cld\n\t"
33002 + __asm__("movw %w6, %%ds\n\t"
33003 + "lcall *%%ss:(%%esi); cld\n\t"
33004 + "push %%ss\n\t"
33005 + "pop %%ds\n\t"
33006 "jc 1f\n\t"
33007 "xor %%ah, %%ah\n"
33008 "1:"
33009 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33010 "c" (value),
33011 "b" (bx),
33012 "D" ((long)reg),
33013 - "S" (&pci_indirect));
33014 + "S" (&pci_indirect),
33015 + "r" (__PCIBIOS_DS));
33016 break;
33017 }
33018
33019 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33020
33021 DBG("PCI: Fetching IRQ routing table... ");
33022 __asm__("push %%es\n\t"
33023 + "movw %w8, %%ds\n\t"
33024 "push %%ds\n\t"
33025 "pop %%es\n\t"
33026 - "lcall *(%%esi); cld\n\t"
33027 + "lcall *%%ss:(%%esi); cld\n\t"
33028 "pop %%es\n\t"
33029 + "push %%ss\n\t"
33030 + "pop %%ds\n"
33031 "jc 1f\n\t"
33032 "xor %%ah, %%ah\n"
33033 "1:"
33034 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33035 "1" (0),
33036 "D" ((long) &opt),
33037 "S" (&pci_indirect),
33038 - "m" (opt)
33039 + "m" (opt),
33040 + "r" (__PCIBIOS_DS)
33041 : "memory");
33042 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33043 if (ret & 0xff00)
33044 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33045 {
33046 int ret;
33047
33048 - __asm__("lcall *(%%esi); cld\n\t"
33049 + __asm__("movw %w5, %%ds\n\t"
33050 + "lcall *%%ss:(%%esi); cld\n\t"
33051 + "push %%ss\n\t"
33052 + "pop %%ds\n"
33053 "jc 1f\n\t"
33054 "xor %%ah, %%ah\n"
33055 "1:"
33056 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33057 : "0" (PCIBIOS_SET_PCI_HW_INT),
33058 "b" ((dev->bus->number << 8) | dev->devfn),
33059 "c" ((irq << 8) | (pin + 10)),
33060 - "S" (&pci_indirect));
33061 + "S" (&pci_indirect),
33062 + "r" (__PCIBIOS_DS));
33063 return !(ret & 0xff00);
33064 }
33065 EXPORT_SYMBOL(pcibios_set_irq_routing);
33066 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33067 index 40e4469..d915bf9 100644
33068 --- a/arch/x86/platform/efi/efi_32.c
33069 +++ b/arch/x86/platform/efi/efi_32.c
33070 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33071 {
33072 struct desc_ptr gdt_descr;
33073
33074 +#ifdef CONFIG_PAX_KERNEXEC
33075 + struct desc_struct d;
33076 +#endif
33077 +
33078 local_irq_save(efi_rt_eflags);
33079
33080 load_cr3(initial_page_table);
33081 __flush_tlb_all();
33082
33083 +#ifdef CONFIG_PAX_KERNEXEC
33084 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33085 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33086 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33087 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33088 +#endif
33089 +
33090 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33091 gdt_descr.size = GDT_SIZE - 1;
33092 load_gdt(&gdt_descr);
33093 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33094 {
33095 struct desc_ptr gdt_descr;
33096
33097 +#ifdef CONFIG_PAX_KERNEXEC
33098 + struct desc_struct d;
33099 +
33100 + memset(&d, 0, sizeof d);
33101 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33102 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33103 +#endif
33104 +
33105 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33106 gdt_descr.size = GDT_SIZE - 1;
33107 load_gdt(&gdt_descr);
33108
33109 +#ifdef CONFIG_PAX_PER_CPU_PGD
33110 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33111 +#else
33112 load_cr3(swapper_pg_dir);
33113 +#endif
33114 +
33115 __flush_tlb_all();
33116
33117 local_irq_restore(efi_rt_eflags);
33118 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33119 index 39a0e7f1..872396e 100644
33120 --- a/arch/x86/platform/efi/efi_64.c
33121 +++ b/arch/x86/platform/efi/efi_64.c
33122 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33123 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33124 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33125 }
33126 +
33127 +#ifdef CONFIG_PAX_PER_CPU_PGD
33128 + load_cr3(swapper_pg_dir);
33129 +#endif
33130 +
33131 __flush_tlb_all();
33132 }
33133
33134 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33135 for (pgd = 0; pgd < n_pgds; pgd++)
33136 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33137 kfree(save_pgd);
33138 +
33139 +#ifdef CONFIG_PAX_PER_CPU_PGD
33140 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33141 +#endif
33142 +
33143 __flush_tlb_all();
33144 local_irq_restore(efi_flags);
33145 early_code_mapping_set_exec(0);
33146 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33147 index fbe66e6..eae5e38 100644
33148 --- a/arch/x86/platform/efi/efi_stub_32.S
33149 +++ b/arch/x86/platform/efi/efi_stub_32.S
33150 @@ -6,7 +6,9 @@
33151 */
33152
33153 #include <linux/linkage.h>
33154 +#include <linux/init.h>
33155 #include <asm/page_types.h>
33156 +#include <asm/segment.h>
33157
33158 /*
33159 * efi_call_phys(void *, ...) is a function with variable parameters.
33160 @@ -20,7 +22,7 @@
33161 * service functions will comply with gcc calling convention, too.
33162 */
33163
33164 -.text
33165 +__INIT
33166 ENTRY(efi_call_phys)
33167 /*
33168 * 0. The function can only be called in Linux kernel. So CS has been
33169 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33170 * The mapping of lower virtual memory has been created in prelog and
33171 * epilog.
33172 */
33173 - movl $1f, %edx
33174 - subl $__PAGE_OFFSET, %edx
33175 - jmp *%edx
33176 +#ifdef CONFIG_PAX_KERNEXEC
33177 + movl $(__KERNEXEC_EFI_DS), %edx
33178 + mov %edx, %ds
33179 + mov %edx, %es
33180 + mov %edx, %ss
33181 + addl $2f,(1f)
33182 + ljmp *(1f)
33183 +
33184 +__INITDATA
33185 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33186 +.previous
33187 +
33188 +2:
33189 + subl $2b,(1b)
33190 +#else
33191 + jmp 1f-__PAGE_OFFSET
33192 1:
33193 +#endif
33194
33195 /*
33196 * 2. Now on the top of stack is the return
33197 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33198 * parameter 2, ..., param n. To make things easy, we save the return
33199 * address of efi_call_phys in a global variable.
33200 */
33201 - popl %edx
33202 - movl %edx, saved_return_addr
33203 - /* get the function pointer into ECX*/
33204 - popl %ecx
33205 - movl %ecx, efi_rt_function_ptr
33206 - movl $2f, %edx
33207 - subl $__PAGE_OFFSET, %edx
33208 - pushl %edx
33209 + popl (saved_return_addr)
33210 + popl (efi_rt_function_ptr)
33211
33212 /*
33213 * 3. Clear PG bit in %CR0.
33214 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33215 /*
33216 * 5. Call the physical function.
33217 */
33218 - jmp *%ecx
33219 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33220
33221 -2:
33222 /*
33223 * 6. After EFI runtime service returns, control will return to
33224 * following instruction. We'd better readjust stack pointer first.
33225 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33226 movl %cr0, %edx
33227 orl $0x80000000, %edx
33228 movl %edx, %cr0
33229 - jmp 1f
33230 -1:
33231 +
33232 /*
33233 * 8. Now restore the virtual mode from flat mode by
33234 * adding EIP with PAGE_OFFSET.
33235 */
33236 - movl $1f, %edx
33237 - jmp *%edx
33238 +#ifdef CONFIG_PAX_KERNEXEC
33239 + movl $(__KERNEL_DS), %edx
33240 + mov %edx, %ds
33241 + mov %edx, %es
33242 + mov %edx, %ss
33243 + ljmp $(__KERNEL_CS),$1f
33244 +#else
33245 + jmp 1f+__PAGE_OFFSET
33246 +#endif
33247 1:
33248
33249 /*
33250 * 9. Balance the stack. And because EAX contain the return value,
33251 * we'd better not clobber it.
33252 */
33253 - leal efi_rt_function_ptr, %edx
33254 - movl (%edx), %ecx
33255 - pushl %ecx
33256 + pushl (efi_rt_function_ptr)
33257
33258 /*
33259 - * 10. Push the saved return address onto the stack and return.
33260 + * 10. Return to the saved return address.
33261 */
33262 - leal saved_return_addr, %edx
33263 - movl (%edx), %ecx
33264 - pushl %ecx
33265 - ret
33266 + jmpl *(saved_return_addr)
33267 ENDPROC(efi_call_phys)
33268 .previous
33269
33270 -.data
33271 +__INITDATA
33272 saved_return_addr:
33273 .long 0
33274 efi_rt_function_ptr:
33275 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33276 index 4c07cca..2c8427d 100644
33277 --- a/arch/x86/platform/efi/efi_stub_64.S
33278 +++ b/arch/x86/platform/efi/efi_stub_64.S
33279 @@ -7,6 +7,7 @@
33280 */
33281
33282 #include <linux/linkage.h>
33283 +#include <asm/alternative-asm.h>
33284
33285 #define SAVE_XMM \
33286 mov %rsp, %rax; \
33287 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33288 call *%rdi
33289 addq $32, %rsp
33290 RESTORE_XMM
33291 + pax_force_retaddr 0, 1
33292 ret
33293 ENDPROC(efi_call0)
33294
33295 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33296 call *%rdi
33297 addq $32, %rsp
33298 RESTORE_XMM
33299 + pax_force_retaddr 0, 1
33300 ret
33301 ENDPROC(efi_call1)
33302
33303 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33304 call *%rdi
33305 addq $32, %rsp
33306 RESTORE_XMM
33307 + pax_force_retaddr 0, 1
33308 ret
33309 ENDPROC(efi_call2)
33310
33311 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33312 call *%rdi
33313 addq $32, %rsp
33314 RESTORE_XMM
33315 + pax_force_retaddr 0, 1
33316 ret
33317 ENDPROC(efi_call3)
33318
33319 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33320 call *%rdi
33321 addq $32, %rsp
33322 RESTORE_XMM
33323 + pax_force_retaddr 0, 1
33324 ret
33325 ENDPROC(efi_call4)
33326
33327 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33328 call *%rdi
33329 addq $48, %rsp
33330 RESTORE_XMM
33331 + pax_force_retaddr 0, 1
33332 ret
33333 ENDPROC(efi_call5)
33334
33335 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33336 call *%rdi
33337 addq $48, %rsp
33338 RESTORE_XMM
33339 + pax_force_retaddr 0, 1
33340 ret
33341 ENDPROC(efi_call6)
33342 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33343 index 47fe66f..6206449 100644
33344 --- a/arch/x86/platform/mrst/mrst.c
33345 +++ b/arch/x86/platform/mrst/mrst.c
33346 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33347 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33348 int sfi_mrtc_num;
33349
33350 -static void mrst_power_off(void)
33351 +static __noreturn void mrst_power_off(void)
33352 {
33353 + BUG();
33354 }
33355
33356 -static void mrst_reboot(void)
33357 +static __noreturn void mrst_reboot(void)
33358 {
33359 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33360 + BUG();
33361 }
33362
33363 /* parse all the mtimer info to a static mtimer array */
33364 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33365 index d6ee929..3637cb5 100644
33366 --- a/arch/x86/platform/olpc/olpc_dt.c
33367 +++ b/arch/x86/platform/olpc/olpc_dt.c
33368 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33369 return res;
33370 }
33371
33372 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33373 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33374 .nextprop = olpc_dt_nextprop,
33375 .getproplen = olpc_dt_getproplen,
33376 .getproperty = olpc_dt_getproperty,
33377 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33378 index 1cf5b30..fd45732 100644
33379 --- a/arch/x86/power/cpu.c
33380 +++ b/arch/x86/power/cpu.c
33381 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33382 static void fix_processor_context(void)
33383 {
33384 int cpu = smp_processor_id();
33385 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33386 -#ifdef CONFIG_X86_64
33387 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33388 - tss_desc tss;
33389 -#endif
33390 + struct tss_struct *t = init_tss + cpu;
33391 +
33392 set_tss_desc(cpu, t); /*
33393 * This just modifies memory; should not be
33394 * necessary. But... This is necessary, because
33395 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33396 */
33397
33398 #ifdef CONFIG_X86_64
33399 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33400 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33401 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33402 -
33403 syscall_init(); /* This sets MSR_*STAR and related */
33404 #endif
33405 load_TR_desc(); /* This does ltr */
33406 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33407 index a44f457..9140171 100644
33408 --- a/arch/x86/realmode/init.c
33409 +++ b/arch/x86/realmode/init.c
33410 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33411 __va(real_mode_header->trampoline_header);
33412
33413 #ifdef CONFIG_X86_32
33414 - trampoline_header->start = __pa_symbol(startup_32_smp);
33415 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33416 +
33417 +#ifdef CONFIG_PAX_KERNEXEC
33418 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33419 +#endif
33420 +
33421 + trampoline_header->boot_cs = __BOOT_CS;
33422 trampoline_header->gdt_limit = __BOOT_DS + 7;
33423 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33424 #else
33425 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33426 *trampoline_cr4_features = read_cr4();
33427
33428 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33429 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33430 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33431 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33432 #endif
33433 }
33434 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33435 index 8869287..d577672 100644
33436 --- a/arch/x86/realmode/rm/Makefile
33437 +++ b/arch/x86/realmode/rm/Makefile
33438 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33439 $(call cc-option, -fno-unit-at-a-time)) \
33440 $(call cc-option, -fno-stack-protector) \
33441 $(call cc-option, -mpreferred-stack-boundary=2)
33442 +ifdef CONSTIFY_PLUGIN
33443 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33444 +endif
33445 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33446 GCOV_PROFILE := n
33447 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33448 index a28221d..93c40f1 100644
33449 --- a/arch/x86/realmode/rm/header.S
33450 +++ b/arch/x86/realmode/rm/header.S
33451 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33452 #endif
33453 /* APM/BIOS reboot */
33454 .long pa_machine_real_restart_asm
33455 -#ifdef CONFIG_X86_64
33456 +#ifdef CONFIG_X86_32
33457 + .long __KERNEL_CS
33458 +#else
33459 .long __KERNEL32_CS
33460 #endif
33461 END(real_mode_header)
33462 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33463 index c1b2791..f9e31c7 100644
33464 --- a/arch/x86/realmode/rm/trampoline_32.S
33465 +++ b/arch/x86/realmode/rm/trampoline_32.S
33466 @@ -25,6 +25,12 @@
33467 #include <asm/page_types.h>
33468 #include "realmode.h"
33469
33470 +#ifdef CONFIG_PAX_KERNEXEC
33471 +#define ta(X) (X)
33472 +#else
33473 +#define ta(X) (pa_ ## X)
33474 +#endif
33475 +
33476 .text
33477 .code16
33478
33479 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33480
33481 cli # We should be safe anyway
33482
33483 - movl tr_start, %eax # where we need to go
33484 -
33485 movl $0xA5A5A5A5, trampoline_status
33486 # write marker for master knows we're running
33487
33488 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33489 movw $1, %dx # protected mode (PE) bit
33490 lmsw %dx # into protected mode
33491
33492 - ljmpl $__BOOT_CS, $pa_startup_32
33493 + ljmpl *(trampoline_header)
33494
33495 .section ".text32","ax"
33496 .code32
33497 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33498 .balign 8
33499 GLOBAL(trampoline_header)
33500 tr_start: .space 4
33501 - tr_gdt_pad: .space 2
33502 + tr_boot_cs: .space 2
33503 tr_gdt: .space 6
33504 END(trampoline_header)
33505
33506 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33507 index bb360dc..d0fd8f8 100644
33508 --- a/arch/x86/realmode/rm/trampoline_64.S
33509 +++ b/arch/x86/realmode/rm/trampoline_64.S
33510 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33511 movl %edx, %gs
33512
33513 movl pa_tr_cr4, %eax
33514 + andl $~X86_CR4_PCIDE, %eax
33515 movl %eax, %cr4 # Enable PAE mode
33516
33517 # Setup trampoline 4 level pagetables
33518 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33519 wrmsr
33520
33521 # Enable paging and in turn activate Long Mode
33522 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33523 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33524 movl %eax, %cr0
33525
33526 /*
33527 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33528 index e812034..c747134 100644
33529 --- a/arch/x86/tools/Makefile
33530 +++ b/arch/x86/tools/Makefile
33531 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33532
33533 $(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
33534
33535 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33536 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33537 hostprogs-y += relocs
33538 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33539 relocs: $(obj)/relocs
33540 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33541 index f7bab68..b6d9886 100644
33542 --- a/arch/x86/tools/relocs.c
33543 +++ b/arch/x86/tools/relocs.c
33544 @@ -1,5 +1,7 @@
33545 /* This is included from relocs_32/64.c */
33546
33547 +#include "../../../include/generated/autoconf.h"
33548 +
33549 #define ElfW(type) _ElfW(ELF_BITS, type)
33550 #define _ElfW(bits, type) __ElfW(bits, type)
33551 #define __ElfW(bits, type) Elf##bits##_##type
33552 @@ -11,6 +13,7 @@
33553 #define Elf_Sym ElfW(Sym)
33554
33555 static Elf_Ehdr ehdr;
33556 +static Elf_Phdr *phdr;
33557
33558 struct relocs {
33559 uint32_t *offset;
33560 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33561 }
33562 }
33563
33564 +static void read_phdrs(FILE *fp)
33565 +{
33566 + unsigned int i;
33567 +
33568 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33569 + if (!phdr) {
33570 + die("Unable to allocate %d program headers\n",
33571 + ehdr.e_phnum);
33572 + }
33573 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33574 + die("Seek to %d failed: %s\n",
33575 + ehdr.e_phoff, strerror(errno));
33576 + }
33577 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33578 + die("Cannot read ELF program headers: %s\n",
33579 + strerror(errno));
33580 + }
33581 + for(i = 0; i < ehdr.e_phnum; i++) {
33582 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33583 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33584 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33585 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33586 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33587 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33588 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33589 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33590 + }
33591 +
33592 +}
33593 +
33594 static void read_shdrs(FILE *fp)
33595 {
33596 - int i;
33597 + unsigned int i;
33598 Elf_Shdr shdr;
33599
33600 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33601 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33602
33603 static void read_strtabs(FILE *fp)
33604 {
33605 - int i;
33606 + unsigned int i;
33607 for (i = 0; i < ehdr.e_shnum; i++) {
33608 struct section *sec = &secs[i];
33609 if (sec->shdr.sh_type != SHT_STRTAB) {
33610 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33611
33612 static void read_symtabs(FILE *fp)
33613 {
33614 - int i,j;
33615 + unsigned int i,j;
33616 for (i = 0; i < ehdr.e_shnum; i++) {
33617 struct section *sec = &secs[i];
33618 if (sec->shdr.sh_type != SHT_SYMTAB) {
33619 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33620 }
33621
33622
33623 -static void read_relocs(FILE *fp)
33624 +static void read_relocs(FILE *fp, int use_real_mode)
33625 {
33626 - int i,j;
33627 + unsigned int i,j;
33628 + uint32_t base;
33629 +
33630 for (i = 0; i < ehdr.e_shnum; i++) {
33631 struct section *sec = &secs[i];
33632 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33633 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33634 die("Cannot read symbol table: %s\n",
33635 strerror(errno));
33636 }
33637 + base = 0;
33638 +
33639 +#ifdef CONFIG_X86_32
33640 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33641 + if (phdr[j].p_type != PT_LOAD )
33642 + continue;
33643 + if (secs[sec->shdr.sh_info].shdr.sh_offset < phdr[j].p_offset || secs[sec->shdr.sh_info].shdr.sh_offset >= phdr[j].p_offset + phdr[j].p_filesz)
33644 + continue;
33645 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33646 + break;
33647 + }
33648 +#endif
33649 +
33650 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33651 Elf_Rel *rel = &sec->reltab[j];
33652 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33653 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33654 rel->r_info = elf_xword_to_cpu(rel->r_info);
33655 #if (SHT_REL_TYPE == SHT_RELA)
33656 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33657 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33658
33659 static void print_absolute_symbols(void)
33660 {
33661 - int i;
33662 + unsigned int i;
33663 const char *format;
33664
33665 if (ELF_BITS == 64)
33666 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33667 for (i = 0; i < ehdr.e_shnum; i++) {
33668 struct section *sec = &secs[i];
33669 char *sym_strtab;
33670 - int j;
33671 + unsigned int j;
33672
33673 if (sec->shdr.sh_type != SHT_SYMTAB) {
33674 continue;
33675 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33676
33677 static void print_absolute_relocs(void)
33678 {
33679 - int i, printed = 0;
33680 + unsigned int i, printed = 0;
33681 const char *format;
33682
33683 if (ELF_BITS == 64)
33684 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33685 struct section *sec_applies, *sec_symtab;
33686 char *sym_strtab;
33687 Elf_Sym *sh_symtab;
33688 - int j;
33689 + unsigned int j;
33690 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33691 continue;
33692 }
33693 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33694 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33695 Elf_Sym *sym, const char *symname))
33696 {
33697 - int i;
33698 + unsigned int i;
33699 /* Walk through the relocations */
33700 for (i = 0; i < ehdr.e_shnum; i++) {
33701 char *sym_strtab;
33702 Elf_Sym *sh_symtab;
33703 struct section *sec_applies, *sec_symtab;
33704 - int j;
33705 + unsigned int j;
33706 struct section *sec = &secs[i];
33707
33708 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33709 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33710 {
33711 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33712 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33713 + char *sym_strtab = sec->link->link->strtab;
33714 +
33715 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33716 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33717 + return 0;
33718 +
33719 +#ifdef CONFIG_PAX_KERNEXEC
33720 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33721 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33722 + return 0;
33723 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33724 + return 0;
33725 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33726 + return 0;
33727 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33728 + return 0;
33729 +#endif
33730
33731 switch (r_type) {
33732 case R_386_NONE:
33733 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33734
33735 static void emit_relocs(int as_text, int use_real_mode)
33736 {
33737 - int i;
33738 + unsigned int i;
33739 int (*write_reloc)(uint32_t, FILE *) = write32;
33740 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33741 const char *symname);
33742 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33743 {
33744 regex_init(use_real_mode);
33745 read_ehdr(fp);
33746 + read_phdrs(fp);
33747 read_shdrs(fp);
33748 read_strtabs(fp);
33749 read_symtabs(fp);
33750 - read_relocs(fp);
33751 + read_relocs(fp, use_real_mode);
33752 if (ELF_BITS == 64)
33753 percpu_init();
33754 if (show_absolute_syms) {
33755 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33756 index 80ffa5b..a33bd15 100644
33757 --- a/arch/x86/um/tls_32.c
33758 +++ b/arch/x86/um/tls_32.c
33759 @@ -260,7 +260,7 @@ out:
33760 if (unlikely(task == current &&
33761 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33762 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33763 - "without flushed TLS.", current->pid);
33764 + "without flushed TLS.", task_pid_nr(current));
33765 }
33766
33767 return 0;
33768 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33769 index fd14be1..e3c79c0 100644
33770 --- a/arch/x86/vdso/Makefile
33771 +++ b/arch/x86/vdso/Makefile
33772 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33773 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33774 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33775
33776 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33777 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33778 GCOV_PROFILE := n
33779
33780 #
33781 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33782 index d6bfb87..876ee18 100644
33783 --- a/arch/x86/vdso/vdso32-setup.c
33784 +++ b/arch/x86/vdso/vdso32-setup.c
33785 @@ -25,6 +25,7 @@
33786 #include <asm/tlbflush.h>
33787 #include <asm/vdso.h>
33788 #include <asm/proto.h>
33789 +#include <asm/mman.h>
33790
33791 enum {
33792 VDSO_DISABLED = 0,
33793 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33794 void enable_sep_cpu(void)
33795 {
33796 int cpu = get_cpu();
33797 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33798 + struct tss_struct *tss = init_tss + cpu;
33799
33800 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33801 put_cpu();
33802 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33803 gate_vma.vm_start = FIXADDR_USER_START;
33804 gate_vma.vm_end = FIXADDR_USER_END;
33805 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33806 - gate_vma.vm_page_prot = __P101;
33807 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33808
33809 return 0;
33810 }
33811 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33812 if (compat)
33813 addr = VDSO_HIGH_BASE;
33814 else {
33815 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33816 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33817 if (IS_ERR_VALUE(addr)) {
33818 ret = addr;
33819 goto up_fail;
33820 }
33821 }
33822
33823 - current->mm->context.vdso = (void *)addr;
33824 + current->mm->context.vdso = addr;
33825
33826 if (compat_uses_vma || !compat) {
33827 /*
33828 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33829 }
33830
33831 current_thread_info()->sysenter_return =
33832 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33833 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33834
33835 up_fail:
33836 if (ret)
33837 - current->mm->context.vdso = NULL;
33838 + current->mm->context.vdso = 0;
33839
33840 up_write(&mm->mmap_sem);
33841
33842 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33843
33844 const char *arch_vma_name(struct vm_area_struct *vma)
33845 {
33846 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33847 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33848 return "[vdso]";
33849 +
33850 +#ifdef CONFIG_PAX_SEGMEXEC
33851 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33852 + return "[vdso]";
33853 +#endif
33854 +
33855 return NULL;
33856 }
33857
33858 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33859 * Check to see if the corresponding task was created in compat vdso
33860 * mode.
33861 */
33862 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33863 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33864 return &gate_vma;
33865 return NULL;
33866 }
33867 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33868 index 431e875..cbb23f3 100644
33869 --- a/arch/x86/vdso/vma.c
33870 +++ b/arch/x86/vdso/vma.c
33871 @@ -16,8 +16,6 @@
33872 #include <asm/vdso.h>
33873 #include <asm/page.h>
33874
33875 -unsigned int __read_mostly vdso_enabled = 1;
33876 -
33877 extern char vdso_start[], vdso_end[];
33878 extern unsigned short vdso_sync_cpuid;
33879
33880 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33881 * unaligned here as a result of stack start randomization.
33882 */
33883 addr = PAGE_ALIGN(addr);
33884 - addr = align_vdso_addr(addr);
33885
33886 return addr;
33887 }
33888 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33889 unsigned size)
33890 {
33891 struct mm_struct *mm = current->mm;
33892 - unsigned long addr;
33893 + unsigned long addr = 0;
33894 int ret;
33895
33896 - if (!vdso_enabled)
33897 - return 0;
33898 -
33899 down_write(&mm->mmap_sem);
33900 +
33901 +#ifdef CONFIG_PAX_RANDMMAP
33902 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33903 +#endif
33904 +
33905 addr = vdso_addr(mm->start_stack, size);
33906 + addr = align_vdso_addr(addr);
33907 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33908 if (IS_ERR_VALUE(addr)) {
33909 ret = addr;
33910 goto up_fail;
33911 }
33912
33913 - current->mm->context.vdso = (void *)addr;
33914 + mm->context.vdso = addr;
33915
33916 ret = install_special_mapping(mm, addr, size,
33917 VM_READ|VM_EXEC|
33918 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33919 pages);
33920 - if (ret) {
33921 - current->mm->context.vdso = NULL;
33922 - goto up_fail;
33923 - }
33924 + if (ret)
33925 + mm->context.vdso = 0;
33926
33927 up_fail:
33928 up_write(&mm->mmap_sem);
33929 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33930 vdsox32_size);
33931 }
33932 #endif
33933 -
33934 -static __init int vdso_setup(char *s)
33935 -{
33936 - vdso_enabled = simple_strtoul(s, NULL, 0);
33937 - return 0;
33938 -}
33939 -__setup("vdso=", vdso_setup);
33940 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33941 index 193097e..7590269 100644
33942 --- a/arch/x86/xen/enlighten.c
33943 +++ b/arch/x86/xen/enlighten.c
33944 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33945
33946 struct shared_info xen_dummy_shared_info;
33947
33948 -void *xen_initial_gdt;
33949 -
33950 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33951 __read_mostly int xen_have_vector_callback;
33952 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33953 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33954 {
33955 unsigned long va = dtr->address;
33956 unsigned int size = dtr->size + 1;
33957 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33958 - unsigned long frames[pages];
33959 + unsigned long frames[65536 / PAGE_SIZE];
33960 int f;
33961
33962 /*
33963 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33964 {
33965 unsigned long va = dtr->address;
33966 unsigned int size = dtr->size + 1;
33967 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33968 - unsigned long frames[pages];
33969 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33970 int f;
33971
33972 /*
33973 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33974 * 8-byte entries, or 16 4k pages..
33975 */
33976
33977 - BUG_ON(size > 65536);
33978 + BUG_ON(size > GDT_SIZE);
33979 BUG_ON(va & ~PAGE_MASK);
33980
33981 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33982 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
33983 return 0;
33984 }
33985
33986 -static void set_xen_basic_apic_ops(void)
33987 +static void __init set_xen_basic_apic_ops(void)
33988 {
33989 apic->read = xen_apic_read;
33990 apic->write = xen_apic_write;
33991 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
33992 #endif
33993 };
33994
33995 -static void xen_reboot(int reason)
33996 +static __noreturn void xen_reboot(int reason)
33997 {
33998 struct sched_shutdown r = { .reason = reason };
33999
34000 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34001 - BUG();
34002 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34003 + BUG();
34004 }
34005
34006 -static void xen_restart(char *msg)
34007 +static __noreturn void xen_restart(char *msg)
34008 {
34009 xen_reboot(SHUTDOWN_reboot);
34010 }
34011
34012 -static void xen_emergency_restart(void)
34013 +static __noreturn void xen_emergency_restart(void)
34014 {
34015 xen_reboot(SHUTDOWN_reboot);
34016 }
34017
34018 -static void xen_machine_halt(void)
34019 +static __noreturn void xen_machine_halt(void)
34020 {
34021 xen_reboot(SHUTDOWN_poweroff);
34022 }
34023
34024 -static void xen_machine_power_off(void)
34025 +static __noreturn void xen_machine_power_off(void)
34026 {
34027 if (pm_power_off)
34028 pm_power_off();
34029 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
34030 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34031
34032 /* Work out if we support NX */
34033 - x86_configure_nx();
34034 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34035 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34036 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34037 + unsigned l, h;
34038 +
34039 + __supported_pte_mask |= _PAGE_NX;
34040 + rdmsr(MSR_EFER, l, h);
34041 + l |= EFER_NX;
34042 + wrmsr(MSR_EFER, l, h);
34043 + }
34044 +#endif
34045
34046 xen_setup_features();
34047
34048 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
34049
34050 machine_ops = xen_machine_ops;
34051
34052 - /*
34053 - * The only reliable way to retain the initial address of the
34054 - * percpu gdt_page is to remember it here, so we can go and
34055 - * mark it RW later, when the initial percpu area is freed.
34056 - */
34057 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34058 -
34059 xen_smp_init();
34060
34061 #ifdef CONFIG_ACPI_NUMA
34062 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34063 index fdc3ba2..3daee39 100644
34064 --- a/arch/x86/xen/mmu.c
34065 +++ b/arch/x86/xen/mmu.c
34066 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34067 /* L3_k[510] -> level2_kernel_pgt
34068 * L3_i[511] -> level2_fixmap_pgt */
34069 convert_pfn_mfn(level3_kernel_pgt);
34070 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34071 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34072 + convert_pfn_mfn(level3_vmemmap_pgt);
34073
34074 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34075 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34076 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34077 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34078 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34079 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34080 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34081 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34082 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34083 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34084 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34085 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34086 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34087 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34088
34089 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34090 pv_mmu_ops.set_pud = xen_set_pud;
34091 #if PAGETABLE_LEVELS == 4
34092 pv_mmu_ops.set_pgd = xen_set_pgd;
34093 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34094 #endif
34095
34096 /* This will work as long as patching hasn't happened yet
34097 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34098 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34099 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34100 .set_pgd = xen_set_pgd_hyper,
34101 + .set_pgd_batched = xen_set_pgd_hyper,
34102
34103 .alloc_pud = xen_alloc_pmd_init,
34104 .release_pud = xen_release_pmd_init,
34105 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34106 index b81c88e..2cbe7b8 100644
34107 --- a/arch/x86/xen/smp.c
34108 +++ b/arch/x86/xen/smp.c
34109 @@ -272,11 +272,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
34110 {
34111 BUG_ON(smp_processor_id() != 0);
34112 native_smp_prepare_boot_cpu();
34113 -
34114 - /* We've switched to the "real" per-cpu gdt, so make sure the
34115 - old memory can be recycled */
34116 - make_lowmem_page_readwrite(xen_initial_gdt);
34117 -
34118 xen_filter_cpu_maps();
34119 xen_setup_vcpu_info_placement();
34120 }
34121 @@ -346,7 +341,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34122 ctxt->user_regs.ss = __KERNEL_DS;
34123 #ifdef CONFIG_X86_32
34124 ctxt->user_regs.fs = __KERNEL_PERCPU;
34125 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34126 + savesegment(gs, ctxt->user_regs.gs);
34127 #else
34128 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34129 #endif
34130 @@ -356,8 +351,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34131
34132 {
34133 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34134 - ctxt->user_regs.ds = __USER_DS;
34135 - ctxt->user_regs.es = __USER_DS;
34136 + ctxt->user_regs.ds = __KERNEL_DS;
34137 + ctxt->user_regs.es = __KERNEL_DS;
34138
34139 xen_copy_trap_info(ctxt->trap_ctxt);
34140
34141 @@ -402,13 +397,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34142 int rc;
34143
34144 per_cpu(current_task, cpu) = idle;
34145 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34146 #ifdef CONFIG_X86_32
34147 irq_ctx_init(cpu);
34148 #else
34149 clear_tsk_thread_flag(idle, TIF_FORK);
34150 - per_cpu(kernel_stack, cpu) =
34151 - (unsigned long)task_stack_page(idle) -
34152 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34153 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34154 #endif
34155 xen_setup_runstate_info(cpu);
34156 xen_setup_timer(cpu);
34157 @@ -678,7 +672,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34158
34159 void __init xen_smp_init(void)
34160 {
34161 - smp_ops = xen_smp_ops;
34162 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34163 xen_fill_possible_map();
34164 xen_init_spinlocks();
34165 }
34166 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34167 index 33ca6e4..0ded929 100644
34168 --- a/arch/x86/xen/xen-asm_32.S
34169 +++ b/arch/x86/xen/xen-asm_32.S
34170 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34171 ESP_OFFSET=4 # bytes pushed onto stack
34172
34173 /*
34174 - * Store vcpu_info pointer for easy access. Do it this way to
34175 - * avoid having to reload %fs
34176 + * Store vcpu_info pointer for easy access.
34177 */
34178 #ifdef CONFIG_SMP
34179 - GET_THREAD_INFO(%eax)
34180 - movl %ss:TI_cpu(%eax), %eax
34181 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34182 - mov %ss:xen_vcpu(%eax), %eax
34183 + push %fs
34184 + mov $(__KERNEL_PERCPU), %eax
34185 + mov %eax, %fs
34186 + mov PER_CPU_VAR(xen_vcpu), %eax
34187 + pop %fs
34188 #else
34189 movl %ss:xen_vcpu, %eax
34190 #endif
34191 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34192 index 7faed58..ba4427c 100644
34193 --- a/arch/x86/xen/xen-head.S
34194 +++ b/arch/x86/xen/xen-head.S
34195 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34196 #ifdef CONFIG_X86_32
34197 mov %esi,xen_start_info
34198 mov $init_thread_union+THREAD_SIZE,%esp
34199 +#ifdef CONFIG_SMP
34200 + movl $cpu_gdt_table,%edi
34201 + movl $__per_cpu_load,%eax
34202 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34203 + rorl $16,%eax
34204 + movb %al,__KERNEL_PERCPU + 4(%edi)
34205 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34206 + movl $__per_cpu_end - 1,%eax
34207 + subl $__per_cpu_start,%eax
34208 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34209 +#endif
34210 #else
34211 mov %rsi,xen_start_info
34212 mov $init_thread_union+THREAD_SIZE,%rsp
34213 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34214 index 86782c5..fa272c8 100644
34215 --- a/arch/x86/xen/xen-ops.h
34216 +++ b/arch/x86/xen/xen-ops.h
34217 @@ -10,8 +10,6 @@
34218 extern const char xen_hypervisor_callback[];
34219 extern const char xen_failsafe_callback[];
34220
34221 -extern void *xen_initial_gdt;
34222 -
34223 struct trap_info;
34224 void xen_copy_trap_info(struct trap_info *traps);
34225
34226 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34227 index 525bd3d..ef888b1 100644
34228 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34229 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34230 @@ -119,9 +119,9 @@
34231 ----------------------------------------------------------------------*/
34232
34233 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34234 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34235 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34236 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34237 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34238
34239 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34240 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34241 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34242 index 2f33760..835e50a 100644
34243 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34244 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34245 @@ -11,6 +11,7 @@
34246 #ifndef _XTENSA_CORE_H
34247 #define _XTENSA_CORE_H
34248
34249 +#include <linux/const.h>
34250
34251 /****************************************************************************
34252 Parameters Useful for Any Code, USER or PRIVILEGED
34253 @@ -112,9 +113,9 @@
34254 ----------------------------------------------------------------------*/
34255
34256 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34257 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34258 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34259 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34260 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34261
34262 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34263 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34264 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34265 index af00795..2bb8105 100644
34266 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34267 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34268 @@ -11,6 +11,7 @@
34269 #ifndef _XTENSA_CORE_CONFIGURATION_H
34270 #define _XTENSA_CORE_CONFIGURATION_H
34271
34272 +#include <linux/const.h>
34273
34274 /****************************************************************************
34275 Parameters Useful for Any Code, USER or PRIVILEGED
34276 @@ -118,9 +119,9 @@
34277 ----------------------------------------------------------------------*/
34278
34279 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34280 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34281 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34282 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34283 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34284
34285 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34286 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34287 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34288 index 290792a..416f287 100644
34289 --- a/block/blk-cgroup.c
34290 +++ b/block/blk-cgroup.c
34291 @@ -808,7 +808,7 @@ static void blkcg_css_free(struct cgroup *cgroup)
34292
34293 static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34294 {
34295 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34296 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34297 struct blkcg *blkcg;
34298 struct cgroup *parent = cgroup->parent;
34299
34300 @@ -823,7 +823,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34301
34302 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34303 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34304 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34305 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34306 done:
34307 spin_lock_init(&blkcg->lock);
34308 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34309 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34310 index 4b8d9b54..a7178c0 100644
34311 --- a/block/blk-iopoll.c
34312 +++ b/block/blk-iopoll.c
34313 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34314 }
34315 EXPORT_SYMBOL(blk_iopoll_complete);
34316
34317 -static void blk_iopoll_softirq(struct softirq_action *h)
34318 +static __latent_entropy void blk_iopoll_softirq(void)
34319 {
34320 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34321 int rearm = 0, budget = blk_iopoll_budget;
34322 diff --git a/block/blk-map.c b/block/blk-map.c
34323 index 623e1cd..ca1e109 100644
34324 --- a/block/blk-map.c
34325 +++ b/block/blk-map.c
34326 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34327 if (!len || !kbuf)
34328 return -EINVAL;
34329
34330 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34331 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34332 if (do_copy)
34333 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34334 else
34335 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34336 index ec9e606..3f38839 100644
34337 --- a/block/blk-softirq.c
34338 +++ b/block/blk-softirq.c
34339 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34340 * Softirq action handler - move entries to local list and loop over them
34341 * while passing them to the queue registered handler.
34342 */
34343 -static void blk_done_softirq(struct softirq_action *h)
34344 +static __latent_entropy void blk_done_softirq(void)
34345 {
34346 struct list_head *cpu_list, local_list;
34347
34348 diff --git a/block/bsg.c b/block/bsg.c
34349 index 420a5a9..23834aa 100644
34350 --- a/block/bsg.c
34351 +++ b/block/bsg.c
34352 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34353 struct sg_io_v4 *hdr, struct bsg_device *bd,
34354 fmode_t has_write_perm)
34355 {
34356 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34357 + unsigned char *cmdptr;
34358 +
34359 if (hdr->request_len > BLK_MAX_CDB) {
34360 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34361 if (!rq->cmd)
34362 return -ENOMEM;
34363 - }
34364 + cmdptr = rq->cmd;
34365 + } else
34366 + cmdptr = tmpcmd;
34367
34368 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34369 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34370 hdr->request_len))
34371 return -EFAULT;
34372
34373 + if (cmdptr != rq->cmd)
34374 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34375 +
34376 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34377 if (blk_verify_command(rq->cmd, has_write_perm))
34378 return -EPERM;
34379 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34380 index 7e5d474..0cf0017 100644
34381 --- a/block/compat_ioctl.c
34382 +++ b/block/compat_ioctl.c
34383 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34384 err |= __get_user(f->spec1, &uf->spec1);
34385 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34386 err |= __get_user(name, &uf->name);
34387 - f->name = compat_ptr(name);
34388 + f->name = (void __force_kernel *)compat_ptr(name);
34389 if (err) {
34390 err = -EFAULT;
34391 goto out;
34392 diff --git a/block/genhd.c b/block/genhd.c
34393 index dadf42b..48dc887 100644
34394 --- a/block/genhd.c
34395 +++ b/block/genhd.c
34396 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34397
34398 /*
34399 * Register device numbers dev..(dev+range-1)
34400 - * range must be nonzero
34401 + * Noop if @range is zero.
34402 * The hash chain is sorted on range, so that subranges can override.
34403 */
34404 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34405 struct kobject *(*probe)(dev_t, int *, void *),
34406 int (*lock)(dev_t, void *), void *data)
34407 {
34408 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34409 + if (range)
34410 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34411 }
34412
34413 EXPORT_SYMBOL(blk_register_region);
34414
34415 +/* undo blk_register_region(), noop if @range is zero */
34416 void blk_unregister_region(dev_t devt, unsigned long range)
34417 {
34418 - kobj_unmap(bdev_map, devt, range);
34419 + if (range)
34420 + kobj_unmap(bdev_map, devt, range);
34421 }
34422
34423 EXPORT_SYMBOL(blk_unregister_region);
34424 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34425 index c85fc89..51e690b 100644
34426 --- a/block/partitions/efi.c
34427 +++ b/block/partitions/efi.c
34428 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34429 if (!gpt)
34430 return NULL;
34431
34432 + if (!le32_to_cpu(gpt->num_partition_entries))
34433 + return NULL;
34434 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34435 + if (!pte)
34436 + return NULL;
34437 +
34438 count = le32_to_cpu(gpt->num_partition_entries) *
34439 le32_to_cpu(gpt->sizeof_partition_entry);
34440 - if (!count)
34441 - return NULL;
34442 - pte = kmalloc(count, GFP_KERNEL);
34443 - if (!pte)
34444 - return NULL;
34445 -
34446 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34447 (u8 *) pte,
34448 count) < count) {
34449 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34450 index a5ffcc9..3cedc9c 100644
34451 --- a/block/scsi_ioctl.c
34452 +++ b/block/scsi_ioctl.c
34453 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34454 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34455 struct sg_io_hdr *hdr, fmode_t mode)
34456 {
34457 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34458 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34459 + unsigned char *cmdptr;
34460 +
34461 + if (rq->cmd != rq->__cmd)
34462 + cmdptr = rq->cmd;
34463 + else
34464 + cmdptr = tmpcmd;
34465 +
34466 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34467 return -EFAULT;
34468 +
34469 + if (cmdptr != rq->cmd)
34470 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34471 +
34472 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34473 return -EPERM;
34474
34475 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34476 int err;
34477 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34478 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34479 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34480 + unsigned char *cmdptr;
34481
34482 if (!sic)
34483 return -EINVAL;
34484 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34485 */
34486 err = -EFAULT;
34487 rq->cmd_len = cmdlen;
34488 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34489 +
34490 + if (rq->cmd != rq->__cmd)
34491 + cmdptr = rq->cmd;
34492 + else
34493 + cmdptr = tmpcmd;
34494 +
34495 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34496 goto error;
34497
34498 + if (rq->cmd != cmdptr)
34499 + memcpy(rq->cmd, cmdptr, cmdlen);
34500 +
34501 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34502 goto error;
34503
34504 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34505 index 7bdd61b..afec999 100644
34506 --- a/crypto/cryptd.c
34507 +++ b/crypto/cryptd.c
34508 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34509
34510 struct cryptd_blkcipher_request_ctx {
34511 crypto_completion_t complete;
34512 -};
34513 +} __no_const;
34514
34515 struct cryptd_hash_ctx {
34516 struct crypto_shash *child;
34517 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34518
34519 struct cryptd_aead_request_ctx {
34520 crypto_completion_t complete;
34521 -};
34522 +} __no_const;
34523
34524 static void cryptd_queue_worker(struct work_struct *work);
34525
34526 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34527 index f8c920c..ab2cb5a 100644
34528 --- a/crypto/pcrypt.c
34529 +++ b/crypto/pcrypt.c
34530 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34531 int ret;
34532
34533 pinst->kobj.kset = pcrypt_kset;
34534 - ret = kobject_add(&pinst->kobj, NULL, name);
34535 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34536 if (!ret)
34537 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34538
34539 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34540 index f220d64..d359ad6 100644
34541 --- a/drivers/acpi/apei/apei-internal.h
34542 +++ b/drivers/acpi/apei/apei-internal.h
34543 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34544 struct apei_exec_ins_type {
34545 u32 flags;
34546 apei_exec_ins_func_t run;
34547 -};
34548 +} __do_const;
34549
34550 struct apei_exec_context {
34551 u32 ip;
34552 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34553 index 33dc6a0..4b24b47 100644
34554 --- a/drivers/acpi/apei/cper.c
34555 +++ b/drivers/acpi/apei/cper.c
34556 @@ -39,12 +39,12 @@
34557 */
34558 u64 cper_next_record_id(void)
34559 {
34560 - static atomic64_t seq;
34561 + static atomic64_unchecked_t seq;
34562
34563 - if (!atomic64_read(&seq))
34564 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34565 + if (!atomic64_read_unchecked(&seq))
34566 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34567
34568 - return atomic64_inc_return(&seq);
34569 + return atomic64_inc_return_unchecked(&seq);
34570 }
34571 EXPORT_SYMBOL_GPL(cper_next_record_id);
34572
34573 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34574 index ec9b57d..9682b3a 100644
34575 --- a/drivers/acpi/apei/ghes.c
34576 +++ b/drivers/acpi/apei/ghes.c
34577 @@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
34578 const struct acpi_hest_generic *generic,
34579 const struct acpi_hest_generic_status *estatus)
34580 {
34581 - static atomic_t seqno;
34582 + static atomic_unchecked_t seqno;
34583 unsigned int curr_seqno;
34584 char pfx_seq[64];
34585
34586 @@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
34587 else
34588 pfx = KERN_ERR;
34589 }
34590 - curr_seqno = atomic_inc_return(&seqno);
34591 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34592 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34593 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34594 pfx_seq, generic->header.source_id);
34595 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34596 index be60399..778b33e8 100644
34597 --- a/drivers/acpi/bgrt.c
34598 +++ b/drivers/acpi/bgrt.c
34599 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
34600 return -ENODEV;
34601
34602 sysfs_bin_attr_init(&image_attr);
34603 - image_attr.private = bgrt_image;
34604 - image_attr.size = bgrt_image_size;
34605 + pax_open_kernel();
34606 + *(void **)&image_attr.private = bgrt_image;
34607 + *(size_t *)&image_attr.size = bgrt_image_size;
34608 + pax_close_kernel();
34609
34610 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34611 if (!bgrt_kobj)
34612 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34613 index cb96296..b81293b 100644
34614 --- a/drivers/acpi/blacklist.c
34615 +++ b/drivers/acpi/blacklist.c
34616 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34617 u32 is_critical_error;
34618 };
34619
34620 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34621 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34622
34623 /*
34624 * POLICY: If *anything* doesn't work, put it on the blacklist.
34625 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
34626 return 0;
34627 }
34628
34629 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34630 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34631 {
34632 .callback = dmi_disable_osi_vista,
34633 .ident = "Fujitsu Siemens",
34634 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34635 index f98dd00..7b69865 100644
34636 --- a/drivers/acpi/processor_idle.c
34637 +++ b/drivers/acpi/processor_idle.c
34638 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34639 {
34640 int i, count = CPUIDLE_DRIVER_STATE_START;
34641 struct acpi_processor_cx *cx;
34642 - struct cpuidle_state *state;
34643 + cpuidle_state_no_const *state;
34644 struct cpuidle_driver *drv = &acpi_idle_driver;
34645
34646 if (!pr->flags.power_setup_done)
34647 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34648 index 05306a5..733d1f0 100644
34649 --- a/drivers/acpi/sysfs.c
34650 +++ b/drivers/acpi/sysfs.c
34651 @@ -423,11 +423,11 @@ static u32 num_counters;
34652 static struct attribute **all_attrs;
34653 static u32 acpi_gpe_count;
34654
34655 -static struct attribute_group interrupt_stats_attr_group = {
34656 +static attribute_group_no_const interrupt_stats_attr_group = {
34657 .name = "interrupts",
34658 };
34659
34660 -static struct kobj_attribute *counter_attrs;
34661 +static kobj_attribute_no_const *counter_attrs;
34662
34663 static void delete_gpe_attr_array(void)
34664 {
34665 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34666 index acfd0f7..e5acb08 100644
34667 --- a/drivers/ata/libahci.c
34668 +++ b/drivers/ata/libahci.c
34669 @@ -1231,7 +1231,7 @@ int ahci_kick_engine(struct ata_port *ap)
34670 }
34671 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34672
34673 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34674 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34675 struct ata_taskfile *tf, int is_cmd, u16 flags,
34676 unsigned long timeout_msec)
34677 {
34678 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34679 index c24354d..335c975 100644
34680 --- a/drivers/ata/libata-core.c
34681 +++ b/drivers/ata/libata-core.c
34682 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34683 static void ata_dev_xfermask(struct ata_device *dev);
34684 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34685
34686 -atomic_t ata_print_id = ATOMIC_INIT(0);
34687 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34688
34689 struct ata_force_param {
34690 const char *name;
34691 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34692 struct ata_port *ap;
34693 unsigned int tag;
34694
34695 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34696 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34697 ap = qc->ap;
34698
34699 qc->flags = 0;
34700 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34701 struct ata_port *ap;
34702 struct ata_link *link;
34703
34704 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34705 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34706 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34707 ap = qc->ap;
34708 link = qc->dev->link;
34709 @@ -5927,6 +5927,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34710 return;
34711
34712 spin_lock(&lock);
34713 + pax_open_kernel();
34714
34715 for (cur = ops->inherits; cur; cur = cur->inherits) {
34716 void **inherit = (void **)cur;
34717 @@ -5940,8 +5941,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34718 if (IS_ERR(*pp))
34719 *pp = NULL;
34720
34721 - ops->inherits = NULL;
34722 + *(struct ata_port_operations **)&ops->inherits = NULL;
34723
34724 + pax_close_kernel();
34725 spin_unlock(&lock);
34726 }
34727
34728 @@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34729
34730 /* give ports names and add SCSI hosts */
34731 for (i = 0; i < host->n_ports; i++) {
34732 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34733 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34734 host->ports[i]->local_port_no = i + 1;
34735 }
34736
34737 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34738 index b1e880a..8cf82e1 100644
34739 --- a/drivers/ata/libata-scsi.c
34740 +++ b/drivers/ata/libata-scsi.c
34741 @@ -4104,7 +4104,7 @@ int ata_sas_port_init(struct ata_port *ap)
34742
34743 if (rc)
34744 return rc;
34745 - ap->print_id = atomic_inc_return(&ata_print_id);
34746 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34747 return 0;
34748 }
34749 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34750 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34751 index 577d902b..cb4781e 100644
34752 --- a/drivers/ata/libata.h
34753 +++ b/drivers/ata/libata.h
34754 @@ -53,7 +53,7 @@ enum {
34755 ATA_DNXFER_QUIET = (1 << 31),
34756 };
34757
34758 -extern atomic_t ata_print_id;
34759 +extern atomic_unchecked_t ata_print_id;
34760 extern int atapi_passthru16;
34761 extern int libata_fua;
34762 extern int libata_noacpi;
34763 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34764 index 848ed32..132f39d 100644
34765 --- a/drivers/ata/pata_arasan_cf.c
34766 +++ b/drivers/ata/pata_arasan_cf.c
34767 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34768 /* Handle platform specific quirks */
34769 if (quirk) {
34770 if (quirk & CF_BROKEN_PIO) {
34771 - ap->ops->set_piomode = NULL;
34772 + pax_open_kernel();
34773 + *(void **)&ap->ops->set_piomode = NULL;
34774 + pax_close_kernel();
34775 ap->pio_mask = 0;
34776 }
34777 if (quirk & CF_BROKEN_MWDMA)
34778 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34779 index f9b983a..887b9d8 100644
34780 --- a/drivers/atm/adummy.c
34781 +++ b/drivers/atm/adummy.c
34782 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34783 vcc->pop(vcc, skb);
34784 else
34785 dev_kfree_skb_any(skb);
34786 - atomic_inc(&vcc->stats->tx);
34787 + atomic_inc_unchecked(&vcc->stats->tx);
34788
34789 return 0;
34790 }
34791 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34792 index 62a7607..cc4be104 100644
34793 --- a/drivers/atm/ambassador.c
34794 +++ b/drivers/atm/ambassador.c
34795 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34796 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34797
34798 // VC layer stats
34799 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34800 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34801
34802 // free the descriptor
34803 kfree (tx_descr);
34804 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34805 dump_skb ("<<<", vc, skb);
34806
34807 // VC layer stats
34808 - atomic_inc(&atm_vcc->stats->rx);
34809 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34810 __net_timestamp(skb);
34811 // end of our responsibility
34812 atm_vcc->push (atm_vcc, skb);
34813 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34814 } else {
34815 PRINTK (KERN_INFO, "dropped over-size frame");
34816 // should we count this?
34817 - atomic_inc(&atm_vcc->stats->rx_drop);
34818 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34819 }
34820
34821 } else {
34822 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34823 }
34824
34825 if (check_area (skb->data, skb->len)) {
34826 - atomic_inc(&atm_vcc->stats->tx_err);
34827 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34828 return -ENOMEM; // ?
34829 }
34830
34831 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34832 index 0e3f8f9..765a7a5 100644
34833 --- a/drivers/atm/atmtcp.c
34834 +++ b/drivers/atm/atmtcp.c
34835 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34836 if (vcc->pop) vcc->pop(vcc,skb);
34837 else dev_kfree_skb(skb);
34838 if (dev_data) return 0;
34839 - atomic_inc(&vcc->stats->tx_err);
34840 + atomic_inc_unchecked(&vcc->stats->tx_err);
34841 return -ENOLINK;
34842 }
34843 size = skb->len+sizeof(struct atmtcp_hdr);
34844 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34845 if (!new_skb) {
34846 if (vcc->pop) vcc->pop(vcc,skb);
34847 else dev_kfree_skb(skb);
34848 - atomic_inc(&vcc->stats->tx_err);
34849 + atomic_inc_unchecked(&vcc->stats->tx_err);
34850 return -ENOBUFS;
34851 }
34852 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34853 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34854 if (vcc->pop) vcc->pop(vcc,skb);
34855 else dev_kfree_skb(skb);
34856 out_vcc->push(out_vcc,new_skb);
34857 - atomic_inc(&vcc->stats->tx);
34858 - atomic_inc(&out_vcc->stats->rx);
34859 + atomic_inc_unchecked(&vcc->stats->tx);
34860 + atomic_inc_unchecked(&out_vcc->stats->rx);
34861 return 0;
34862 }
34863
34864 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34865 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34866 read_unlock(&vcc_sklist_lock);
34867 if (!out_vcc) {
34868 - atomic_inc(&vcc->stats->tx_err);
34869 + atomic_inc_unchecked(&vcc->stats->tx_err);
34870 goto done;
34871 }
34872 skb_pull(skb,sizeof(struct atmtcp_hdr));
34873 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34874 __net_timestamp(new_skb);
34875 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34876 out_vcc->push(out_vcc,new_skb);
34877 - atomic_inc(&vcc->stats->tx);
34878 - atomic_inc(&out_vcc->stats->rx);
34879 + atomic_inc_unchecked(&vcc->stats->tx);
34880 + atomic_inc_unchecked(&out_vcc->stats->rx);
34881 done:
34882 if (vcc->pop) vcc->pop(vcc,skb);
34883 else dev_kfree_skb(skb);
34884 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34885 index b1955ba..b179940 100644
34886 --- a/drivers/atm/eni.c
34887 +++ b/drivers/atm/eni.c
34888 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34889 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34890 vcc->dev->number);
34891 length = 0;
34892 - atomic_inc(&vcc->stats->rx_err);
34893 + atomic_inc_unchecked(&vcc->stats->rx_err);
34894 }
34895 else {
34896 length = ATM_CELL_SIZE-1; /* no HEC */
34897 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34898 size);
34899 }
34900 eff = length = 0;
34901 - atomic_inc(&vcc->stats->rx_err);
34902 + atomic_inc_unchecked(&vcc->stats->rx_err);
34903 }
34904 else {
34905 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34906 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34907 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34908 vcc->dev->number,vcc->vci,length,size << 2,descr);
34909 length = eff = 0;
34910 - atomic_inc(&vcc->stats->rx_err);
34911 + atomic_inc_unchecked(&vcc->stats->rx_err);
34912 }
34913 }
34914 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34915 @@ -767,7 +767,7 @@ rx_dequeued++;
34916 vcc->push(vcc,skb);
34917 pushed++;
34918 }
34919 - atomic_inc(&vcc->stats->rx);
34920 + atomic_inc_unchecked(&vcc->stats->rx);
34921 }
34922 wake_up(&eni_dev->rx_wait);
34923 }
34924 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34925 PCI_DMA_TODEVICE);
34926 if (vcc->pop) vcc->pop(vcc,skb);
34927 else dev_kfree_skb_irq(skb);
34928 - atomic_inc(&vcc->stats->tx);
34929 + atomic_inc_unchecked(&vcc->stats->tx);
34930 wake_up(&eni_dev->tx_wait);
34931 dma_complete++;
34932 }
34933 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34934 index b41c948..a002b17 100644
34935 --- a/drivers/atm/firestream.c
34936 +++ b/drivers/atm/firestream.c
34937 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34938 }
34939 }
34940
34941 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34942 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34943
34944 fs_dprintk (FS_DEBUG_TXMEM, "i");
34945 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34946 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34947 #endif
34948 skb_put (skb, qe->p1 & 0xffff);
34949 ATM_SKB(skb)->vcc = atm_vcc;
34950 - atomic_inc(&atm_vcc->stats->rx);
34951 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34952 __net_timestamp(skb);
34953 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34954 atm_vcc->push (atm_vcc, skb);
34955 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34956 kfree (pe);
34957 }
34958 if (atm_vcc)
34959 - atomic_inc(&atm_vcc->stats->rx_drop);
34960 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34961 break;
34962 case 0x1f: /* Reassembly abort: no buffers. */
34963 /* Silently increment error counter. */
34964 if (atm_vcc)
34965 - atomic_inc(&atm_vcc->stats->rx_drop);
34966 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34967 break;
34968 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34969 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34970 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34971 index 204814e..cede831 100644
34972 --- a/drivers/atm/fore200e.c
34973 +++ b/drivers/atm/fore200e.c
34974 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
34975 #endif
34976 /* check error condition */
34977 if (*entry->status & STATUS_ERROR)
34978 - atomic_inc(&vcc->stats->tx_err);
34979 + atomic_inc_unchecked(&vcc->stats->tx_err);
34980 else
34981 - atomic_inc(&vcc->stats->tx);
34982 + atomic_inc_unchecked(&vcc->stats->tx);
34983 }
34984 }
34985
34986 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34987 if (skb == NULL) {
34988 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
34989
34990 - atomic_inc(&vcc->stats->rx_drop);
34991 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34992 return -ENOMEM;
34993 }
34994
34995 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34996
34997 dev_kfree_skb_any(skb);
34998
34999 - atomic_inc(&vcc->stats->rx_drop);
35000 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35001 return -ENOMEM;
35002 }
35003
35004 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35005
35006 vcc->push(vcc, skb);
35007 - atomic_inc(&vcc->stats->rx);
35008 + atomic_inc_unchecked(&vcc->stats->rx);
35009
35010 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35011
35012 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35013 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35014 fore200e->atm_dev->number,
35015 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35016 - atomic_inc(&vcc->stats->rx_err);
35017 + atomic_inc_unchecked(&vcc->stats->rx_err);
35018 }
35019 }
35020
35021 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35022 goto retry_here;
35023 }
35024
35025 - atomic_inc(&vcc->stats->tx_err);
35026 + atomic_inc_unchecked(&vcc->stats->tx_err);
35027
35028 fore200e->tx_sat++;
35029 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35030 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35031 index 507362a..a845e57 100644
35032 --- a/drivers/atm/he.c
35033 +++ b/drivers/atm/he.c
35034 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35035
35036 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35037 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35038 - atomic_inc(&vcc->stats->rx_drop);
35039 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35040 goto return_host_buffers;
35041 }
35042
35043 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35044 RBRQ_LEN_ERR(he_dev->rbrq_head)
35045 ? "LEN_ERR" : "",
35046 vcc->vpi, vcc->vci);
35047 - atomic_inc(&vcc->stats->rx_err);
35048 + atomic_inc_unchecked(&vcc->stats->rx_err);
35049 goto return_host_buffers;
35050 }
35051
35052 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35053 vcc->push(vcc, skb);
35054 spin_lock(&he_dev->global_lock);
35055
35056 - atomic_inc(&vcc->stats->rx);
35057 + atomic_inc_unchecked(&vcc->stats->rx);
35058
35059 return_host_buffers:
35060 ++pdus_assembled;
35061 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35062 tpd->vcc->pop(tpd->vcc, tpd->skb);
35063 else
35064 dev_kfree_skb_any(tpd->skb);
35065 - atomic_inc(&tpd->vcc->stats->tx_err);
35066 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35067 }
35068 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35069 return;
35070 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35071 vcc->pop(vcc, skb);
35072 else
35073 dev_kfree_skb_any(skb);
35074 - atomic_inc(&vcc->stats->tx_err);
35075 + atomic_inc_unchecked(&vcc->stats->tx_err);
35076 return -EINVAL;
35077 }
35078
35079 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35080 vcc->pop(vcc, skb);
35081 else
35082 dev_kfree_skb_any(skb);
35083 - atomic_inc(&vcc->stats->tx_err);
35084 + atomic_inc_unchecked(&vcc->stats->tx_err);
35085 return -EINVAL;
35086 }
35087 #endif
35088 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35089 vcc->pop(vcc, skb);
35090 else
35091 dev_kfree_skb_any(skb);
35092 - atomic_inc(&vcc->stats->tx_err);
35093 + atomic_inc_unchecked(&vcc->stats->tx_err);
35094 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35095 return -ENOMEM;
35096 }
35097 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35098 vcc->pop(vcc, skb);
35099 else
35100 dev_kfree_skb_any(skb);
35101 - atomic_inc(&vcc->stats->tx_err);
35102 + atomic_inc_unchecked(&vcc->stats->tx_err);
35103 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35104 return -ENOMEM;
35105 }
35106 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35107 __enqueue_tpd(he_dev, tpd, cid);
35108 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35109
35110 - atomic_inc(&vcc->stats->tx);
35111 + atomic_inc_unchecked(&vcc->stats->tx);
35112
35113 return 0;
35114 }
35115 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35116 index 1dc0519..1aadaf7 100644
35117 --- a/drivers/atm/horizon.c
35118 +++ b/drivers/atm/horizon.c
35119 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35120 {
35121 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35122 // VC layer stats
35123 - atomic_inc(&vcc->stats->rx);
35124 + atomic_inc_unchecked(&vcc->stats->rx);
35125 __net_timestamp(skb);
35126 // end of our responsibility
35127 vcc->push (vcc, skb);
35128 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35129 dev->tx_iovec = NULL;
35130
35131 // VC layer stats
35132 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35133 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35134
35135 // free the skb
35136 hrz_kfree_skb (skb);
35137 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35138 index 272f009..a18ba55 100644
35139 --- a/drivers/atm/idt77252.c
35140 +++ b/drivers/atm/idt77252.c
35141 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35142 else
35143 dev_kfree_skb(skb);
35144
35145 - atomic_inc(&vcc->stats->tx);
35146 + atomic_inc_unchecked(&vcc->stats->tx);
35147 }
35148
35149 atomic_dec(&scq->used);
35150 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35151 if ((sb = dev_alloc_skb(64)) == NULL) {
35152 printk("%s: Can't allocate buffers for aal0.\n",
35153 card->name);
35154 - atomic_add(i, &vcc->stats->rx_drop);
35155 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35156 break;
35157 }
35158 if (!atm_charge(vcc, sb->truesize)) {
35159 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35160 card->name);
35161 - atomic_add(i - 1, &vcc->stats->rx_drop);
35162 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35163 dev_kfree_skb(sb);
35164 break;
35165 }
35166 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35167 ATM_SKB(sb)->vcc = vcc;
35168 __net_timestamp(sb);
35169 vcc->push(vcc, sb);
35170 - atomic_inc(&vcc->stats->rx);
35171 + atomic_inc_unchecked(&vcc->stats->rx);
35172
35173 cell += ATM_CELL_PAYLOAD;
35174 }
35175 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35176 "(CDC: %08x)\n",
35177 card->name, len, rpp->len, readl(SAR_REG_CDC));
35178 recycle_rx_pool_skb(card, rpp);
35179 - atomic_inc(&vcc->stats->rx_err);
35180 + atomic_inc_unchecked(&vcc->stats->rx_err);
35181 return;
35182 }
35183 if (stat & SAR_RSQE_CRC) {
35184 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35185 recycle_rx_pool_skb(card, rpp);
35186 - atomic_inc(&vcc->stats->rx_err);
35187 + atomic_inc_unchecked(&vcc->stats->rx_err);
35188 return;
35189 }
35190 if (skb_queue_len(&rpp->queue) > 1) {
35191 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35192 RXPRINTK("%s: Can't alloc RX skb.\n",
35193 card->name);
35194 recycle_rx_pool_skb(card, rpp);
35195 - atomic_inc(&vcc->stats->rx_err);
35196 + atomic_inc_unchecked(&vcc->stats->rx_err);
35197 return;
35198 }
35199 if (!atm_charge(vcc, skb->truesize)) {
35200 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35201 __net_timestamp(skb);
35202
35203 vcc->push(vcc, skb);
35204 - atomic_inc(&vcc->stats->rx);
35205 + atomic_inc_unchecked(&vcc->stats->rx);
35206
35207 return;
35208 }
35209 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35210 __net_timestamp(skb);
35211
35212 vcc->push(vcc, skb);
35213 - atomic_inc(&vcc->stats->rx);
35214 + atomic_inc_unchecked(&vcc->stats->rx);
35215
35216 if (skb->truesize > SAR_FB_SIZE_3)
35217 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35218 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35219 if (vcc->qos.aal != ATM_AAL0) {
35220 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35221 card->name, vpi, vci);
35222 - atomic_inc(&vcc->stats->rx_drop);
35223 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35224 goto drop;
35225 }
35226
35227 if ((sb = dev_alloc_skb(64)) == NULL) {
35228 printk("%s: Can't allocate buffers for AAL0.\n",
35229 card->name);
35230 - atomic_inc(&vcc->stats->rx_err);
35231 + atomic_inc_unchecked(&vcc->stats->rx_err);
35232 goto drop;
35233 }
35234
35235 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35236 ATM_SKB(sb)->vcc = vcc;
35237 __net_timestamp(sb);
35238 vcc->push(vcc, sb);
35239 - atomic_inc(&vcc->stats->rx);
35240 + atomic_inc_unchecked(&vcc->stats->rx);
35241
35242 drop:
35243 skb_pull(queue, 64);
35244 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35245
35246 if (vc == NULL) {
35247 printk("%s: NULL connection in send().\n", card->name);
35248 - atomic_inc(&vcc->stats->tx_err);
35249 + atomic_inc_unchecked(&vcc->stats->tx_err);
35250 dev_kfree_skb(skb);
35251 return -EINVAL;
35252 }
35253 if (!test_bit(VCF_TX, &vc->flags)) {
35254 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35255 - atomic_inc(&vcc->stats->tx_err);
35256 + atomic_inc_unchecked(&vcc->stats->tx_err);
35257 dev_kfree_skb(skb);
35258 return -EINVAL;
35259 }
35260 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35261 break;
35262 default:
35263 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35264 - atomic_inc(&vcc->stats->tx_err);
35265 + atomic_inc_unchecked(&vcc->stats->tx_err);
35266 dev_kfree_skb(skb);
35267 return -EINVAL;
35268 }
35269
35270 if (skb_shinfo(skb)->nr_frags != 0) {
35271 printk("%s: No scatter-gather yet.\n", card->name);
35272 - atomic_inc(&vcc->stats->tx_err);
35273 + atomic_inc_unchecked(&vcc->stats->tx_err);
35274 dev_kfree_skb(skb);
35275 return -EINVAL;
35276 }
35277 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35278
35279 err = queue_skb(card, vc, skb, oam);
35280 if (err) {
35281 - atomic_inc(&vcc->stats->tx_err);
35282 + atomic_inc_unchecked(&vcc->stats->tx_err);
35283 dev_kfree_skb(skb);
35284 return err;
35285 }
35286 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35287 skb = dev_alloc_skb(64);
35288 if (!skb) {
35289 printk("%s: Out of memory in send_oam().\n", card->name);
35290 - atomic_inc(&vcc->stats->tx_err);
35291 + atomic_inc_unchecked(&vcc->stats->tx_err);
35292 return -ENOMEM;
35293 }
35294 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35295 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35296 index 4217f29..88f547a 100644
35297 --- a/drivers/atm/iphase.c
35298 +++ b/drivers/atm/iphase.c
35299 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35300 status = (u_short) (buf_desc_ptr->desc_mode);
35301 if (status & (RX_CER | RX_PTE | RX_OFL))
35302 {
35303 - atomic_inc(&vcc->stats->rx_err);
35304 + atomic_inc_unchecked(&vcc->stats->rx_err);
35305 IF_ERR(printk("IA: bad packet, dropping it");)
35306 if (status & RX_CER) {
35307 IF_ERR(printk(" cause: packet CRC error\n");)
35308 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35309 len = dma_addr - buf_addr;
35310 if (len > iadev->rx_buf_sz) {
35311 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35312 - atomic_inc(&vcc->stats->rx_err);
35313 + atomic_inc_unchecked(&vcc->stats->rx_err);
35314 goto out_free_desc;
35315 }
35316
35317 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35318 ia_vcc = INPH_IA_VCC(vcc);
35319 if (ia_vcc == NULL)
35320 {
35321 - atomic_inc(&vcc->stats->rx_err);
35322 + atomic_inc_unchecked(&vcc->stats->rx_err);
35323 atm_return(vcc, skb->truesize);
35324 dev_kfree_skb_any(skb);
35325 goto INCR_DLE;
35326 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35327 if ((length > iadev->rx_buf_sz) || (length >
35328 (skb->len - sizeof(struct cpcs_trailer))))
35329 {
35330 - atomic_inc(&vcc->stats->rx_err);
35331 + atomic_inc_unchecked(&vcc->stats->rx_err);
35332 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35333 length, skb->len);)
35334 atm_return(vcc, skb->truesize);
35335 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35336
35337 IF_RX(printk("rx_dle_intr: skb push");)
35338 vcc->push(vcc,skb);
35339 - atomic_inc(&vcc->stats->rx);
35340 + atomic_inc_unchecked(&vcc->stats->rx);
35341 iadev->rx_pkt_cnt++;
35342 }
35343 INCR_DLE:
35344 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35345 {
35346 struct k_sonet_stats *stats;
35347 stats = &PRIV(_ia_dev[board])->sonet_stats;
35348 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35349 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35350 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35351 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35352 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35353 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35354 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35355 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35356 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35357 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35358 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35359 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35360 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35361 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35362 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35363 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35364 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35365 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35366 }
35367 ia_cmds.status = 0;
35368 break;
35369 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35370 if ((desc == 0) || (desc > iadev->num_tx_desc))
35371 {
35372 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35373 - atomic_inc(&vcc->stats->tx);
35374 + atomic_inc_unchecked(&vcc->stats->tx);
35375 if (vcc->pop)
35376 vcc->pop(vcc, skb);
35377 else
35378 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35379 ATM_DESC(skb) = vcc->vci;
35380 skb_queue_tail(&iadev->tx_dma_q, skb);
35381
35382 - atomic_inc(&vcc->stats->tx);
35383 + atomic_inc_unchecked(&vcc->stats->tx);
35384 iadev->tx_pkt_cnt++;
35385 /* Increment transaction counter */
35386 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35387
35388 #if 0
35389 /* add flow control logic */
35390 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35391 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35392 if (iavcc->vc_desc_cnt > 10) {
35393 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35394 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35395 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35396 index fa7d701..1e404c7 100644
35397 --- a/drivers/atm/lanai.c
35398 +++ b/drivers/atm/lanai.c
35399 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35400 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35401 lanai_endtx(lanai, lvcc);
35402 lanai_free_skb(lvcc->tx.atmvcc, skb);
35403 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35404 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35405 }
35406
35407 /* Try to fill the buffer - don't call unless there is backlog */
35408 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35409 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35410 __net_timestamp(skb);
35411 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35412 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35413 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35414 out:
35415 lvcc->rx.buf.ptr = end;
35416 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35417 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35418 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35419 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35420 lanai->stats.service_rxnotaal5++;
35421 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35422 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35423 return 0;
35424 }
35425 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35426 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35427 int bytes;
35428 read_unlock(&vcc_sklist_lock);
35429 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35430 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35431 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35432 lvcc->stats.x.aal5.service_trash++;
35433 bytes = (SERVICE_GET_END(s) * 16) -
35434 (((unsigned long) lvcc->rx.buf.ptr) -
35435 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35436 }
35437 if (s & SERVICE_STREAM) {
35438 read_unlock(&vcc_sklist_lock);
35439 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35440 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35441 lvcc->stats.x.aal5.service_stream++;
35442 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35443 "PDU on VCI %d!\n", lanai->number, vci);
35444 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35445 return 0;
35446 }
35447 DPRINTK("got rx crc error on vci %d\n", vci);
35448 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35449 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35450 lvcc->stats.x.aal5.service_rxcrc++;
35451 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35452 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35453 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35454 index 6587dc2..149833d 100644
35455 --- a/drivers/atm/nicstar.c
35456 +++ b/drivers/atm/nicstar.c
35457 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35458 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35459 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35460 card->index);
35461 - atomic_inc(&vcc->stats->tx_err);
35462 + atomic_inc_unchecked(&vcc->stats->tx_err);
35463 dev_kfree_skb_any(skb);
35464 return -EINVAL;
35465 }
35466 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35467 if (!vc->tx) {
35468 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35469 card->index);
35470 - atomic_inc(&vcc->stats->tx_err);
35471 + atomic_inc_unchecked(&vcc->stats->tx_err);
35472 dev_kfree_skb_any(skb);
35473 return -EINVAL;
35474 }
35475 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35476 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35477 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35478 card->index);
35479 - atomic_inc(&vcc->stats->tx_err);
35480 + atomic_inc_unchecked(&vcc->stats->tx_err);
35481 dev_kfree_skb_any(skb);
35482 return -EINVAL;
35483 }
35484
35485 if (skb_shinfo(skb)->nr_frags != 0) {
35486 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35487 - atomic_inc(&vcc->stats->tx_err);
35488 + atomic_inc_unchecked(&vcc->stats->tx_err);
35489 dev_kfree_skb_any(skb);
35490 return -EINVAL;
35491 }
35492 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35493 }
35494
35495 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35496 - atomic_inc(&vcc->stats->tx_err);
35497 + atomic_inc_unchecked(&vcc->stats->tx_err);
35498 dev_kfree_skb_any(skb);
35499 return -EIO;
35500 }
35501 - atomic_inc(&vcc->stats->tx);
35502 + atomic_inc_unchecked(&vcc->stats->tx);
35503
35504 return 0;
35505 }
35506 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35507 printk
35508 ("nicstar%d: Can't allocate buffers for aal0.\n",
35509 card->index);
35510 - atomic_add(i, &vcc->stats->rx_drop);
35511 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35512 break;
35513 }
35514 if (!atm_charge(vcc, sb->truesize)) {
35515 RXPRINTK
35516 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35517 card->index);
35518 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35519 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35520 dev_kfree_skb_any(sb);
35521 break;
35522 }
35523 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35524 ATM_SKB(sb)->vcc = vcc;
35525 __net_timestamp(sb);
35526 vcc->push(vcc, sb);
35527 - atomic_inc(&vcc->stats->rx);
35528 + atomic_inc_unchecked(&vcc->stats->rx);
35529 cell += ATM_CELL_PAYLOAD;
35530 }
35531
35532 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35533 if (iovb == NULL) {
35534 printk("nicstar%d: Out of iovec buffers.\n",
35535 card->index);
35536 - atomic_inc(&vcc->stats->rx_drop);
35537 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35538 recycle_rx_buf(card, skb);
35539 return;
35540 }
35541 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35542 small or large buffer itself. */
35543 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35544 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35545 - atomic_inc(&vcc->stats->rx_err);
35546 + atomic_inc_unchecked(&vcc->stats->rx_err);
35547 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35548 NS_MAX_IOVECS);
35549 NS_PRV_IOVCNT(iovb) = 0;
35550 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35551 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35552 card->index);
35553 which_list(card, skb);
35554 - atomic_inc(&vcc->stats->rx_err);
35555 + atomic_inc_unchecked(&vcc->stats->rx_err);
35556 recycle_rx_buf(card, skb);
35557 vc->rx_iov = NULL;
35558 recycle_iov_buf(card, iovb);
35559 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35560 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35561 card->index);
35562 which_list(card, skb);
35563 - atomic_inc(&vcc->stats->rx_err);
35564 + atomic_inc_unchecked(&vcc->stats->rx_err);
35565 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35566 NS_PRV_IOVCNT(iovb));
35567 vc->rx_iov = NULL;
35568 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35569 printk(" - PDU size mismatch.\n");
35570 else
35571 printk(".\n");
35572 - atomic_inc(&vcc->stats->rx_err);
35573 + atomic_inc_unchecked(&vcc->stats->rx_err);
35574 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35575 NS_PRV_IOVCNT(iovb));
35576 vc->rx_iov = NULL;
35577 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35578 /* skb points to a small buffer */
35579 if (!atm_charge(vcc, skb->truesize)) {
35580 push_rxbufs(card, skb);
35581 - atomic_inc(&vcc->stats->rx_drop);
35582 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35583 } else {
35584 skb_put(skb, len);
35585 dequeue_sm_buf(card, skb);
35586 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35587 ATM_SKB(skb)->vcc = vcc;
35588 __net_timestamp(skb);
35589 vcc->push(vcc, skb);
35590 - atomic_inc(&vcc->stats->rx);
35591 + atomic_inc_unchecked(&vcc->stats->rx);
35592 }
35593 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35594 struct sk_buff *sb;
35595 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35596 if (len <= NS_SMBUFSIZE) {
35597 if (!atm_charge(vcc, sb->truesize)) {
35598 push_rxbufs(card, sb);
35599 - atomic_inc(&vcc->stats->rx_drop);
35600 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35601 } else {
35602 skb_put(sb, len);
35603 dequeue_sm_buf(card, sb);
35604 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35605 ATM_SKB(sb)->vcc = vcc;
35606 __net_timestamp(sb);
35607 vcc->push(vcc, sb);
35608 - atomic_inc(&vcc->stats->rx);
35609 + atomic_inc_unchecked(&vcc->stats->rx);
35610 }
35611
35612 push_rxbufs(card, skb);
35613 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35614
35615 if (!atm_charge(vcc, skb->truesize)) {
35616 push_rxbufs(card, skb);
35617 - atomic_inc(&vcc->stats->rx_drop);
35618 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35619 } else {
35620 dequeue_lg_buf(card, skb);
35621 #ifdef NS_USE_DESTRUCTORS
35622 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35623 ATM_SKB(skb)->vcc = vcc;
35624 __net_timestamp(skb);
35625 vcc->push(vcc, skb);
35626 - atomic_inc(&vcc->stats->rx);
35627 + atomic_inc_unchecked(&vcc->stats->rx);
35628 }
35629
35630 push_rxbufs(card, sb);
35631 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35632 printk
35633 ("nicstar%d: Out of huge buffers.\n",
35634 card->index);
35635 - atomic_inc(&vcc->stats->rx_drop);
35636 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35637 recycle_iovec_rx_bufs(card,
35638 (struct iovec *)
35639 iovb->data,
35640 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35641 card->hbpool.count++;
35642 } else
35643 dev_kfree_skb_any(hb);
35644 - atomic_inc(&vcc->stats->rx_drop);
35645 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35646 } else {
35647 /* Copy the small buffer to the huge buffer */
35648 sb = (struct sk_buff *)iov->iov_base;
35649 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35650 #endif /* NS_USE_DESTRUCTORS */
35651 __net_timestamp(hb);
35652 vcc->push(vcc, hb);
35653 - atomic_inc(&vcc->stats->rx);
35654 + atomic_inc_unchecked(&vcc->stats->rx);
35655 }
35656 }
35657
35658 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35659 index 32784d1..4a8434a 100644
35660 --- a/drivers/atm/solos-pci.c
35661 +++ b/drivers/atm/solos-pci.c
35662 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35663 }
35664 atm_charge(vcc, skb->truesize);
35665 vcc->push(vcc, skb);
35666 - atomic_inc(&vcc->stats->rx);
35667 + atomic_inc_unchecked(&vcc->stats->rx);
35668 break;
35669
35670 case PKT_STATUS:
35671 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35672 vcc = SKB_CB(oldskb)->vcc;
35673
35674 if (vcc) {
35675 - atomic_inc(&vcc->stats->tx);
35676 + atomic_inc_unchecked(&vcc->stats->tx);
35677 solos_pop(vcc, oldskb);
35678 } else {
35679 dev_kfree_skb_irq(oldskb);
35680 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35681 index 0215934..ce9f5b1 100644
35682 --- a/drivers/atm/suni.c
35683 +++ b/drivers/atm/suni.c
35684 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35685
35686
35687 #define ADD_LIMITED(s,v) \
35688 - atomic_add((v),&stats->s); \
35689 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35690 + atomic_add_unchecked((v),&stats->s); \
35691 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35692
35693
35694 static void suni_hz(unsigned long from_timer)
35695 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35696 index 5120a96..e2572bd 100644
35697 --- a/drivers/atm/uPD98402.c
35698 +++ b/drivers/atm/uPD98402.c
35699 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35700 struct sonet_stats tmp;
35701 int error = 0;
35702
35703 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35704 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35705 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35706 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35707 if (zero && !error) {
35708 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35709
35710
35711 #define ADD_LIMITED(s,v) \
35712 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35713 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35714 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35715 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35716 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35717 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35718
35719
35720 static void stat_event(struct atm_dev *dev)
35721 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35722 if (reason & uPD98402_INT_PFM) stat_event(dev);
35723 if (reason & uPD98402_INT_PCO) {
35724 (void) GET(PCOCR); /* clear interrupt cause */
35725 - atomic_add(GET(HECCT),
35726 + atomic_add_unchecked(GET(HECCT),
35727 &PRIV(dev)->sonet_stats.uncorr_hcs);
35728 }
35729 if ((reason & uPD98402_INT_RFO) &&
35730 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35731 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35732 uPD98402_INT_LOS),PIMR); /* enable them */
35733 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35734 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35735 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35736 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35737 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35738 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35739 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35740 return 0;
35741 }
35742
35743 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35744 index 969c3c2..9b72956 100644
35745 --- a/drivers/atm/zatm.c
35746 +++ b/drivers/atm/zatm.c
35747 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35748 }
35749 if (!size) {
35750 dev_kfree_skb_irq(skb);
35751 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35752 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35753 continue;
35754 }
35755 if (!atm_charge(vcc,skb->truesize)) {
35756 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35757 skb->len = size;
35758 ATM_SKB(skb)->vcc = vcc;
35759 vcc->push(vcc,skb);
35760 - atomic_inc(&vcc->stats->rx);
35761 + atomic_inc_unchecked(&vcc->stats->rx);
35762 }
35763 zout(pos & 0xffff,MTA(mbx));
35764 #if 0 /* probably a stupid idea */
35765 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35766 skb_queue_head(&zatm_vcc->backlog,skb);
35767 break;
35768 }
35769 - atomic_inc(&vcc->stats->tx);
35770 + atomic_inc_unchecked(&vcc->stats->tx);
35771 wake_up(&zatm_vcc->tx_wait);
35772 }
35773
35774 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35775 index d414331..b4dd4ba 100644
35776 --- a/drivers/base/bus.c
35777 +++ b/drivers/base/bus.c
35778 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35779 return -EINVAL;
35780
35781 mutex_lock(&subsys->p->mutex);
35782 - list_add_tail(&sif->node, &subsys->p->interfaces);
35783 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35784 if (sif->add_dev) {
35785 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35786 while ((dev = subsys_dev_iter_next(&iter)))
35787 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35788 subsys = sif->subsys;
35789
35790 mutex_lock(&subsys->p->mutex);
35791 - list_del_init(&sif->node);
35792 + pax_list_del_init((struct list_head *)&sif->node);
35793 if (sif->remove_dev) {
35794 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35795 while ((dev = subsys_dev_iter_next(&iter)))
35796 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35797 index 7413d06..79155fa 100644
35798 --- a/drivers/base/devtmpfs.c
35799 +++ b/drivers/base/devtmpfs.c
35800 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35801 if (!thread)
35802 return 0;
35803
35804 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35805 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35806 if (err)
35807 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35808 else
35809 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35810 *err = sys_unshare(CLONE_NEWNS);
35811 if (*err)
35812 goto out;
35813 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35814 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35815 if (*err)
35816 goto out;
35817 - sys_chdir("/.."); /* will traverse into overmounted root */
35818 - sys_chroot(".");
35819 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35820 + sys_chroot((char __force_user *)".");
35821 complete(&setup_done);
35822 while (1) {
35823 spin_lock(&req_lock);
35824 diff --git a/drivers/base/node.c b/drivers/base/node.c
35825 index 7616a77c..8f57f51 100644
35826 --- a/drivers/base/node.c
35827 +++ b/drivers/base/node.c
35828 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35829 struct node_attr {
35830 struct device_attribute attr;
35831 enum node_states state;
35832 -};
35833 +} __do_const;
35834
35835 static ssize_t show_node_state(struct device *dev,
35836 struct device_attribute *attr, char *buf)
35837 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35838 index bfb8955..42c9b9a 100644
35839 --- a/drivers/base/power/domain.c
35840 +++ b/drivers/base/power/domain.c
35841 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35842 {
35843 struct cpuidle_driver *cpuidle_drv;
35844 struct gpd_cpu_data *cpu_data;
35845 - struct cpuidle_state *idle_state;
35846 + cpuidle_state_no_const *idle_state;
35847 int ret = 0;
35848
35849 if (IS_ERR_OR_NULL(genpd) || state < 0)
35850 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35851 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35852 {
35853 struct gpd_cpu_data *cpu_data;
35854 - struct cpuidle_state *idle_state;
35855 + cpuidle_state_no_const *idle_state;
35856 int ret = 0;
35857
35858 if (IS_ERR_OR_NULL(genpd))
35859 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35860 index a53ebd2..8f73eeb 100644
35861 --- a/drivers/base/power/sysfs.c
35862 +++ b/drivers/base/power/sysfs.c
35863 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35864 return -EIO;
35865 }
35866 }
35867 - return sprintf(buf, p);
35868 + return sprintf(buf, "%s", p);
35869 }
35870
35871 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35872 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35873 index 2d56f41..8830f19 100644
35874 --- a/drivers/base/power/wakeup.c
35875 +++ b/drivers/base/power/wakeup.c
35876 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35877 * They need to be modified together atomically, so it's better to use one
35878 * atomic variable to hold them both.
35879 */
35880 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35881 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35882
35883 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35884 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35885
35886 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35887 {
35888 - unsigned int comb = atomic_read(&combined_event_count);
35889 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35890
35891 *cnt = (comb >> IN_PROGRESS_BITS);
35892 *inpr = comb & MAX_IN_PROGRESS;
35893 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35894 ws->start_prevent_time = ws->last_time;
35895
35896 /* Increment the counter of events in progress. */
35897 - cec = atomic_inc_return(&combined_event_count);
35898 + cec = atomic_inc_return_unchecked(&combined_event_count);
35899
35900 trace_wakeup_source_activate(ws->name, cec);
35901 }
35902 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35903 * Increment the counter of registered wakeup events and decrement the
35904 * couter of wakeup events in progress simultaneously.
35905 */
35906 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35907 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35908 trace_wakeup_source_deactivate(ws->name, cec);
35909
35910 split_counters(&cnt, &inpr);
35911 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35912 index e8d11b6..7b1b36f 100644
35913 --- a/drivers/base/syscore.c
35914 +++ b/drivers/base/syscore.c
35915 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35916 void register_syscore_ops(struct syscore_ops *ops)
35917 {
35918 mutex_lock(&syscore_ops_lock);
35919 - list_add_tail(&ops->node, &syscore_ops_list);
35920 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35921 mutex_unlock(&syscore_ops_lock);
35922 }
35923 EXPORT_SYMBOL_GPL(register_syscore_ops);
35924 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35925 void unregister_syscore_ops(struct syscore_ops *ops)
35926 {
35927 mutex_lock(&syscore_ops_lock);
35928 - list_del(&ops->node);
35929 + pax_list_del((struct list_head *)&ops->node);
35930 mutex_unlock(&syscore_ops_lock);
35931 }
35932 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35933 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35934 index 90a4e6b..002d10f 100644
35935 --- a/drivers/block/cciss.c
35936 +++ b/drivers/block/cciss.c
35937 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
35938 while (!list_empty(&h->reqQ)) {
35939 c = list_entry(h->reqQ.next, CommandList_struct, list);
35940 /* can't do anything if fifo is full */
35941 - if ((h->access.fifo_full(h))) {
35942 + if ((h->access->fifo_full(h))) {
35943 dev_warn(&h->pdev->dev, "fifo full\n");
35944 break;
35945 }
35946 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
35947 h->Qdepth--;
35948
35949 /* Tell the controller execute command */
35950 - h->access.submit_command(h, c);
35951 + h->access->submit_command(h, c);
35952
35953 /* Put job onto the completed Q */
35954 addQ(&h->cmpQ, c);
35955 @@ -3447,17 +3447,17 @@ startio:
35956
35957 static inline unsigned long get_next_completion(ctlr_info_t *h)
35958 {
35959 - return h->access.command_completed(h);
35960 + return h->access->command_completed(h);
35961 }
35962
35963 static inline int interrupt_pending(ctlr_info_t *h)
35964 {
35965 - return h->access.intr_pending(h);
35966 + return h->access->intr_pending(h);
35967 }
35968
35969 static inline long interrupt_not_for_us(ctlr_info_t *h)
35970 {
35971 - return ((h->access.intr_pending(h) == 0) ||
35972 + return ((h->access->intr_pending(h) == 0) ||
35973 (h->interrupts_enabled == 0));
35974 }
35975
35976 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
35977 u32 a;
35978
35979 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
35980 - return h->access.command_completed(h);
35981 + return h->access->command_completed(h);
35982
35983 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
35984 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
35985 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
35986 trans_support & CFGTBL_Trans_use_short_tags);
35987
35988 /* Change the access methods to the performant access methods */
35989 - h->access = SA5_performant_access;
35990 + h->access = &SA5_performant_access;
35991 h->transMethod = CFGTBL_Trans_Performant;
35992
35993 return;
35994 @@ -4320,7 +4320,7 @@ static int cciss_pci_init(ctlr_info_t *h)
35995 if (prod_index < 0)
35996 return -ENODEV;
35997 h->product_name = products[prod_index].product_name;
35998 - h->access = *(products[prod_index].access);
35999 + h->access = products[prod_index].access;
36000
36001 if (cciss_board_disabled(h)) {
36002 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36003 @@ -5052,7 +5052,7 @@ reinit_after_soft_reset:
36004 }
36005
36006 /* make sure the board interrupts are off */
36007 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36008 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36009 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36010 if (rc)
36011 goto clean2;
36012 @@ -5102,7 +5102,7 @@ reinit_after_soft_reset:
36013 * fake ones to scoop up any residual completions.
36014 */
36015 spin_lock_irqsave(&h->lock, flags);
36016 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36017 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36018 spin_unlock_irqrestore(&h->lock, flags);
36019 free_irq(h->intr[h->intr_mode], h);
36020 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36021 @@ -5122,9 +5122,9 @@ reinit_after_soft_reset:
36022 dev_info(&h->pdev->dev, "Board READY.\n");
36023 dev_info(&h->pdev->dev,
36024 "Waiting for stale completions to drain.\n");
36025 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36026 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36027 msleep(10000);
36028 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36029 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36030
36031 rc = controller_reset_failed(h->cfgtable);
36032 if (rc)
36033 @@ -5147,7 +5147,7 @@ reinit_after_soft_reset:
36034 cciss_scsi_setup(h);
36035
36036 /* Turn the interrupts on so we can service requests */
36037 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36038 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36039
36040 /* Get the firmware version */
36041 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36042 @@ -5219,7 +5219,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36043 kfree(flush_buf);
36044 if (return_code != IO_OK)
36045 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36046 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36047 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36048 free_irq(h->intr[h->intr_mode], h);
36049 }
36050
36051 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36052 index 7fda30e..eb5dfe0 100644
36053 --- a/drivers/block/cciss.h
36054 +++ b/drivers/block/cciss.h
36055 @@ -101,7 +101,7 @@ struct ctlr_info
36056 /* information about each logical volume */
36057 drive_info_struct *drv[CISS_MAX_LUN];
36058
36059 - struct access_method access;
36060 + struct access_method *access;
36061
36062 /* queue and queue Info */
36063 struct list_head reqQ;
36064 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36065 index 2b94403..fd6ad1f 100644
36066 --- a/drivers/block/cpqarray.c
36067 +++ b/drivers/block/cpqarray.c
36068 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36069 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36070 goto Enomem4;
36071 }
36072 - hba[i]->access.set_intr_mask(hba[i], 0);
36073 + hba[i]->access->set_intr_mask(hba[i], 0);
36074 if (request_irq(hba[i]->intr, do_ida_intr,
36075 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36076 {
36077 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36078 add_timer(&hba[i]->timer);
36079
36080 /* Enable IRQ now that spinlock and rate limit timer are set up */
36081 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36082 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36083
36084 for(j=0; j<NWD; j++) {
36085 struct gendisk *disk = ida_gendisk[i][j];
36086 @@ -694,7 +694,7 @@ DBGINFO(
36087 for(i=0; i<NR_PRODUCTS; i++) {
36088 if (board_id == products[i].board_id) {
36089 c->product_name = products[i].product_name;
36090 - c->access = *(products[i].access);
36091 + c->access = products[i].access;
36092 break;
36093 }
36094 }
36095 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36096 hba[ctlr]->intr = intr;
36097 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36098 hba[ctlr]->product_name = products[j].product_name;
36099 - hba[ctlr]->access = *(products[j].access);
36100 + hba[ctlr]->access = products[j].access;
36101 hba[ctlr]->ctlr = ctlr;
36102 hba[ctlr]->board_id = board_id;
36103 hba[ctlr]->pci_dev = NULL; /* not PCI */
36104 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36105
36106 while((c = h->reqQ) != NULL) {
36107 /* Can't do anything if we're busy */
36108 - if (h->access.fifo_full(h) == 0)
36109 + if (h->access->fifo_full(h) == 0)
36110 return;
36111
36112 /* Get the first entry from the request Q */
36113 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36114 h->Qdepth--;
36115
36116 /* Tell the controller to do our bidding */
36117 - h->access.submit_command(h, c);
36118 + h->access->submit_command(h, c);
36119
36120 /* Get onto the completion Q */
36121 addQ(&h->cmpQ, c);
36122 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36123 unsigned long flags;
36124 __u32 a,a1;
36125
36126 - istat = h->access.intr_pending(h);
36127 + istat = h->access->intr_pending(h);
36128 /* Is this interrupt for us? */
36129 if (istat == 0)
36130 return IRQ_NONE;
36131 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36132 */
36133 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36134 if (istat & FIFO_NOT_EMPTY) {
36135 - while((a = h->access.command_completed(h))) {
36136 + while((a = h->access->command_completed(h))) {
36137 a1 = a; a &= ~3;
36138 if ((c = h->cmpQ) == NULL)
36139 {
36140 @@ -1448,11 +1448,11 @@ static int sendcmd(
36141 /*
36142 * Disable interrupt
36143 */
36144 - info_p->access.set_intr_mask(info_p, 0);
36145 + info_p->access->set_intr_mask(info_p, 0);
36146 /* Make sure there is room in the command FIFO */
36147 /* Actually it should be completely empty at this time. */
36148 for (i = 200000; i > 0; i--) {
36149 - temp = info_p->access.fifo_full(info_p);
36150 + temp = info_p->access->fifo_full(info_p);
36151 if (temp != 0) {
36152 break;
36153 }
36154 @@ -1465,7 +1465,7 @@ DBG(
36155 /*
36156 * Send the cmd
36157 */
36158 - info_p->access.submit_command(info_p, c);
36159 + info_p->access->submit_command(info_p, c);
36160 complete = pollcomplete(ctlr);
36161
36162 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36163 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36164 * we check the new geometry. Then turn interrupts back on when
36165 * we're done.
36166 */
36167 - host->access.set_intr_mask(host, 0);
36168 + host->access->set_intr_mask(host, 0);
36169 getgeometry(ctlr);
36170 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36171 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36172
36173 for(i=0; i<NWD; i++) {
36174 struct gendisk *disk = ida_gendisk[ctlr][i];
36175 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36176 /* Wait (up to 2 seconds) for a command to complete */
36177
36178 for (i = 200000; i > 0; i--) {
36179 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36180 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36181 if (done == 0) {
36182 udelay(10); /* a short fixed delay */
36183 } else
36184 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36185 index be73e9d..7fbf140 100644
36186 --- a/drivers/block/cpqarray.h
36187 +++ b/drivers/block/cpqarray.h
36188 @@ -99,7 +99,7 @@ struct ctlr_info {
36189 drv_info_t drv[NWD];
36190 struct proc_dir_entry *proc;
36191
36192 - struct access_method access;
36193 + struct access_method *access;
36194
36195 cmdlist_t *reqQ;
36196 cmdlist_t *cmpQ;
36197 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36198 index 2d7f608..11245fe 100644
36199 --- a/drivers/block/drbd/drbd_int.h
36200 +++ b/drivers/block/drbd/drbd_int.h
36201 @@ -582,7 +582,7 @@ struct drbd_epoch {
36202 struct drbd_tconn *tconn;
36203 struct list_head list;
36204 unsigned int barrier_nr;
36205 - atomic_t epoch_size; /* increased on every request added. */
36206 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36207 atomic_t active; /* increased on every req. added, and dec on every finished. */
36208 unsigned long flags;
36209 };
36210 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36211 unsigned int al_tr_number;
36212 int al_tr_cycle;
36213 wait_queue_head_t seq_wait;
36214 - atomic_t packet_seq;
36215 + atomic_unchecked_t packet_seq;
36216 unsigned int peer_seq;
36217 spinlock_t peer_seq_lock;
36218 unsigned int minor;
36219 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36220 char __user *uoptval;
36221 int err;
36222
36223 - uoptval = (char __user __force *)optval;
36224 + uoptval = (char __force_user *)optval;
36225
36226 set_fs(KERNEL_DS);
36227 if (level == SOL_SOCKET)
36228 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36229 index 55635ed..40e837c 100644
36230 --- a/drivers/block/drbd/drbd_main.c
36231 +++ b/drivers/block/drbd/drbd_main.c
36232 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36233 p->sector = sector;
36234 p->block_id = block_id;
36235 p->blksize = blksize;
36236 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36237 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36238 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36239 }
36240
36241 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36242 return -EIO;
36243 p->sector = cpu_to_be64(req->i.sector);
36244 p->block_id = (unsigned long)req;
36245 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36246 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36247 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36248 if (mdev->state.conn >= C_SYNC_SOURCE &&
36249 mdev->state.conn <= C_PAUSED_SYNC_T)
36250 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36251 {
36252 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36253
36254 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36255 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36256 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36257 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36258 kfree(tconn->current_epoch);
36259
36260 idr_destroy(&tconn->volumes);
36261 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36262 index 8cc1e64..ba7ffa9 100644
36263 --- a/drivers/block/drbd/drbd_nl.c
36264 +++ b/drivers/block/drbd/drbd_nl.c
36265 @@ -3440,7 +3440,7 @@ out:
36266
36267 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36268 {
36269 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36270 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36271 struct sk_buff *msg;
36272 struct drbd_genlmsghdr *d_out;
36273 unsigned seq;
36274 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36275 return;
36276 }
36277
36278 - seq = atomic_inc_return(&drbd_genl_seq);
36279 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36280 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36281 if (!msg)
36282 goto failed;
36283 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36284 index cc29cd3..d4b058b 100644
36285 --- a/drivers/block/drbd/drbd_receiver.c
36286 +++ b/drivers/block/drbd/drbd_receiver.c
36287 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36288 {
36289 int err;
36290
36291 - atomic_set(&mdev->packet_seq, 0);
36292 + atomic_set_unchecked(&mdev->packet_seq, 0);
36293 mdev->peer_seq = 0;
36294
36295 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36296 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36297 do {
36298 next_epoch = NULL;
36299
36300 - epoch_size = atomic_read(&epoch->epoch_size);
36301 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36302
36303 switch (ev & ~EV_CLEANUP) {
36304 case EV_PUT:
36305 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36306 rv = FE_DESTROYED;
36307 } else {
36308 epoch->flags = 0;
36309 - atomic_set(&epoch->epoch_size, 0);
36310 + atomic_set_unchecked(&epoch->epoch_size, 0);
36311 /* atomic_set(&epoch->active, 0); is already zero */
36312 if (rv == FE_STILL_LIVE)
36313 rv = FE_RECYCLED;
36314 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36315 conn_wait_active_ee_empty(tconn);
36316 drbd_flush(tconn);
36317
36318 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36319 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36320 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36321 if (epoch)
36322 break;
36323 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36324 }
36325
36326 epoch->flags = 0;
36327 - atomic_set(&epoch->epoch_size, 0);
36328 + atomic_set_unchecked(&epoch->epoch_size, 0);
36329 atomic_set(&epoch->active, 0);
36330
36331 spin_lock(&tconn->epoch_lock);
36332 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36333 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36334 list_add(&epoch->list, &tconn->current_epoch->list);
36335 tconn->current_epoch = epoch;
36336 tconn->epochs++;
36337 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36338
36339 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36340 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36341 - atomic_inc(&tconn->current_epoch->epoch_size);
36342 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36343 err2 = drbd_drain_block(mdev, pi->size);
36344 if (!err)
36345 err = err2;
36346 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36347
36348 spin_lock(&tconn->epoch_lock);
36349 peer_req->epoch = tconn->current_epoch;
36350 - atomic_inc(&peer_req->epoch->epoch_size);
36351 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36352 atomic_inc(&peer_req->epoch->active);
36353 spin_unlock(&tconn->epoch_lock);
36354
36355 @@ -4347,7 +4347,7 @@ struct data_cmd {
36356 int expect_payload;
36357 size_t pkt_size;
36358 int (*fn)(struct drbd_tconn *, struct packet_info *);
36359 -};
36360 +} __do_const;
36361
36362 static struct data_cmd drbd_cmd_handler[] = {
36363 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36364 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36365 if (!list_empty(&tconn->current_epoch->list))
36366 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36367 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36368 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36369 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36370 tconn->send.seen_any_write_yet = false;
36371
36372 conn_info(tconn, "Connection closed\n");
36373 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36374 struct asender_cmd {
36375 size_t pkt_size;
36376 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36377 -};
36378 +} __do_const;
36379
36380 static struct asender_cmd asender_tbl[] = {
36381 [P_PING] = { 0, got_Ping },
36382 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36383 index 40e7155..df5c79a 100644
36384 --- a/drivers/block/loop.c
36385 +++ b/drivers/block/loop.c
36386 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36387
36388 file_start_write(file);
36389 set_fs(get_ds());
36390 - bw = file->f_op->write(file, buf, len, &pos);
36391 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36392 set_fs(old_fs);
36393 file_end_write(file);
36394 if (likely(bw == len))
36395 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36396 index f5d0ea1..c62380a 100644
36397 --- a/drivers/block/pktcdvd.c
36398 +++ b/drivers/block/pktcdvd.c
36399 @@ -84,7 +84,7 @@
36400 #define MAX_SPEED 0xffff
36401
36402 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
36403 - ~(sector_t)((pd)->settings.size - 1))
36404 + ~(sector_t)((pd)->settings.size - 1UL))
36405
36406 static DEFINE_MUTEX(pktcdvd_mutex);
36407 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
36408 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
36409 index 60abf59..80789e1 100644
36410 --- a/drivers/bluetooth/btwilink.c
36411 +++ b/drivers/bluetooth/btwilink.c
36412 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
36413
36414 static int bt_ti_probe(struct platform_device *pdev)
36415 {
36416 - static struct ti_st *hst;
36417 + struct ti_st *hst;
36418 struct hci_dev *hdev;
36419 int err;
36420
36421 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36422 index 7332889..9ece19e 100644
36423 --- a/drivers/bus/arm-cci.c
36424 +++ b/drivers/bus/arm-cci.c
36425 @@ -419,7 +419,7 @@ static int __init cci_probe(void)
36426
36427 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36428
36429 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36430 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36431 if (!ports)
36432 return -ENOMEM;
36433
36434 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36435 index 8a3aff7..d7538c2 100644
36436 --- a/drivers/cdrom/cdrom.c
36437 +++ b/drivers/cdrom/cdrom.c
36438 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36439 ENSURE(reset, CDC_RESET);
36440 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36441 cdi->mc_flags = 0;
36442 - cdo->n_minors = 0;
36443 cdi->options = CDO_USE_FFLAGS;
36444
36445 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36446 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36447 else
36448 cdi->cdda_method = CDDA_OLD;
36449
36450 - if (!cdo->generic_packet)
36451 - cdo->generic_packet = cdrom_dummy_generic_packet;
36452 + if (!cdo->generic_packet) {
36453 + pax_open_kernel();
36454 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36455 + pax_close_kernel();
36456 + }
36457
36458 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36459 mutex_lock(&cdrom_mutex);
36460 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36461 if (cdi->exit)
36462 cdi->exit(cdi);
36463
36464 - cdi->ops->n_minors--;
36465 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36466 }
36467
36468 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36469 */
36470 nr = nframes;
36471 do {
36472 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36473 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36474 if (cgc.buffer)
36475 break;
36476
36477 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36478 struct cdrom_device_info *cdi;
36479 int ret;
36480
36481 - ret = scnprintf(info + *pos, max_size - *pos, header);
36482 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36483 if (!ret)
36484 return 1;
36485
36486 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36487 index 5980cb9..6d7bd7e 100644
36488 --- a/drivers/cdrom/gdrom.c
36489 +++ b/drivers/cdrom/gdrom.c
36490 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36491 .audio_ioctl = gdrom_audio_ioctl,
36492 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36493 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36494 - .n_minors = 1,
36495 };
36496
36497 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36498 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36499 index 1421997..33f5d6d 100644
36500 --- a/drivers/char/Kconfig
36501 +++ b/drivers/char/Kconfig
36502 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36503
36504 config DEVKMEM
36505 bool "/dev/kmem virtual device support"
36506 - default y
36507 + default n
36508 + depends on !GRKERNSEC_KMEM
36509 help
36510 Say Y here if you want to support the /dev/kmem device. The
36511 /dev/kmem device is rarely used, but can be used for certain
36512 @@ -570,6 +571,7 @@ config DEVPORT
36513 bool
36514 depends on !M68K
36515 depends on ISA || PCI
36516 + depends on !GRKERNSEC_KMEM
36517 default y
36518
36519 source "drivers/s390/char/Kconfig"
36520 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36521 index a48e05b..6bac831 100644
36522 --- a/drivers/char/agp/compat_ioctl.c
36523 +++ b/drivers/char/agp/compat_ioctl.c
36524 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36525 return -ENOMEM;
36526 }
36527
36528 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36529 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36530 sizeof(*usegment) * ureserve.seg_count)) {
36531 kfree(usegment);
36532 kfree(ksegment);
36533 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36534 index 1b19239..b87b143 100644
36535 --- a/drivers/char/agp/frontend.c
36536 +++ b/drivers/char/agp/frontend.c
36537 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36538 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36539 return -EFAULT;
36540
36541 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36542 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36543 return -EFAULT;
36544
36545 client = agp_find_client_by_pid(reserve.pid);
36546 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36547 if (segment == NULL)
36548 return -ENOMEM;
36549
36550 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36551 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36552 sizeof(struct agp_segment) * reserve.seg_count)) {
36553 kfree(segment);
36554 return -EFAULT;
36555 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36556 index 4f94375..413694e 100644
36557 --- a/drivers/char/genrtc.c
36558 +++ b/drivers/char/genrtc.c
36559 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36560 switch (cmd) {
36561
36562 case RTC_PLL_GET:
36563 + memset(&pll, 0, sizeof(pll));
36564 if (get_rtc_pll(&pll))
36565 return -EINVAL;
36566 else
36567 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36568 index 448ce5e..3a76625 100644
36569 --- a/drivers/char/hpet.c
36570 +++ b/drivers/char/hpet.c
36571 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36572 }
36573
36574 static int
36575 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36576 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36577 struct hpet_info *info)
36578 {
36579 struct hpet_timer __iomem *timer;
36580 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36581 index 86fe45c..c0ea948 100644
36582 --- a/drivers/char/hw_random/intel-rng.c
36583 +++ b/drivers/char/hw_random/intel-rng.c
36584 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36585
36586 if (no_fwh_detect)
36587 return -ENODEV;
36588 - printk(warning);
36589 + printk("%s", warning);
36590 return -EBUSY;
36591 }
36592
36593 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36594 index 4445fa1..7c6de37 100644
36595 --- a/drivers/char/ipmi/ipmi_msghandler.c
36596 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36597 @@ -420,7 +420,7 @@ struct ipmi_smi {
36598 struct proc_dir_entry *proc_dir;
36599 char proc_dir_name[10];
36600
36601 - atomic_t stats[IPMI_NUM_STATS];
36602 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36603
36604 /*
36605 * run_to_completion duplicate of smb_info, smi_info
36606 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36607
36608
36609 #define ipmi_inc_stat(intf, stat) \
36610 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36611 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36612 #define ipmi_get_stat(intf, stat) \
36613 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36614 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36615
36616 static int is_lan_addr(struct ipmi_addr *addr)
36617 {
36618 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36619 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36620 init_waitqueue_head(&intf->waitq);
36621 for (i = 0; i < IPMI_NUM_STATS; i++)
36622 - atomic_set(&intf->stats[i], 0);
36623 + atomic_set_unchecked(&intf->stats[i], 0);
36624
36625 intf->proc_dir = NULL;
36626
36627 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36628 index af4b23f..79806fc 100644
36629 --- a/drivers/char/ipmi/ipmi_si_intf.c
36630 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36631 @@ -275,7 +275,7 @@ struct smi_info {
36632 unsigned char slave_addr;
36633
36634 /* Counters and things for the proc filesystem. */
36635 - atomic_t stats[SI_NUM_STATS];
36636 + atomic_unchecked_t stats[SI_NUM_STATS];
36637
36638 struct task_struct *thread;
36639
36640 @@ -284,9 +284,9 @@ struct smi_info {
36641 };
36642
36643 #define smi_inc_stat(smi, stat) \
36644 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36645 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36646 #define smi_get_stat(smi, stat) \
36647 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36648 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36649
36650 #define SI_MAX_PARMS 4
36651
36652 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
36653 atomic_set(&new_smi->req_events, 0);
36654 new_smi->run_to_completion = 0;
36655 for (i = 0; i < SI_NUM_STATS; i++)
36656 - atomic_set(&new_smi->stats[i], 0);
36657 + atomic_set_unchecked(&new_smi->stats[i], 0);
36658
36659 new_smi->interrupt_disabled = 1;
36660 atomic_set(&new_smi->stop_operation, 0);
36661 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36662 index f895a8c..2bc9147 100644
36663 --- a/drivers/char/mem.c
36664 +++ b/drivers/char/mem.c
36665 @@ -18,6 +18,7 @@
36666 #include <linux/raw.h>
36667 #include <linux/tty.h>
36668 #include <linux/capability.h>
36669 +#include <linux/security.h>
36670 #include <linux/ptrace.h>
36671 #include <linux/device.h>
36672 #include <linux/highmem.h>
36673 @@ -37,6 +38,10 @@
36674
36675 #define DEVPORT_MINOR 4
36676
36677 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36678 +extern const struct file_operations grsec_fops;
36679 +#endif
36680 +
36681 static inline unsigned long size_inside_page(unsigned long start,
36682 unsigned long size)
36683 {
36684 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36685
36686 while (cursor < to) {
36687 if (!devmem_is_allowed(pfn)) {
36688 +#ifdef CONFIG_GRKERNSEC_KMEM
36689 + gr_handle_mem_readwrite(from, to);
36690 +#else
36691 printk(KERN_INFO
36692 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36693 current->comm, from, to);
36694 +#endif
36695 return 0;
36696 }
36697 cursor += PAGE_SIZE;
36698 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36699 }
36700 return 1;
36701 }
36702 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36703 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36704 +{
36705 + return 0;
36706 +}
36707 #else
36708 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36709 {
36710 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36711
36712 while (count > 0) {
36713 unsigned long remaining;
36714 + char *temp;
36715
36716 sz = size_inside_page(p, count);
36717
36718 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36719 if (!ptr)
36720 return -EFAULT;
36721
36722 - remaining = copy_to_user(buf, ptr, sz);
36723 +#ifdef CONFIG_PAX_USERCOPY
36724 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36725 + if (!temp) {
36726 + unxlate_dev_mem_ptr(p, ptr);
36727 + return -ENOMEM;
36728 + }
36729 + memcpy(temp, ptr, sz);
36730 +#else
36731 + temp = ptr;
36732 +#endif
36733 +
36734 + remaining = copy_to_user(buf, temp, sz);
36735 +
36736 +#ifdef CONFIG_PAX_USERCOPY
36737 + kfree(temp);
36738 +#endif
36739 +
36740 unxlate_dev_mem_ptr(p, ptr);
36741 if (remaining)
36742 return -EFAULT;
36743 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36744 size_t count, loff_t *ppos)
36745 {
36746 unsigned long p = *ppos;
36747 - ssize_t low_count, read, sz;
36748 + ssize_t low_count, read, sz, err = 0;
36749 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36750 - int err = 0;
36751
36752 read = 0;
36753 if (p < (unsigned long) high_memory) {
36754 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36755 }
36756 #endif
36757 while (low_count > 0) {
36758 + char *temp;
36759 +
36760 sz = size_inside_page(p, low_count);
36761
36762 /*
36763 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36764 */
36765 kbuf = xlate_dev_kmem_ptr((char *)p);
36766
36767 - if (copy_to_user(buf, kbuf, sz))
36768 +#ifdef CONFIG_PAX_USERCOPY
36769 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36770 + if (!temp)
36771 + return -ENOMEM;
36772 + memcpy(temp, kbuf, sz);
36773 +#else
36774 + temp = kbuf;
36775 +#endif
36776 +
36777 + err = copy_to_user(buf, temp, sz);
36778 +
36779 +#ifdef CONFIG_PAX_USERCOPY
36780 + kfree(temp);
36781 +#endif
36782 +
36783 + if (err)
36784 return -EFAULT;
36785 buf += sz;
36786 p += sz;
36787 @@ -822,6 +869,9 @@ static const struct memdev {
36788 #ifdef CONFIG_PRINTK
36789 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36790 #endif
36791 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36792 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36793 +#endif
36794 };
36795
36796 static int memory_open(struct inode *inode, struct file *filp)
36797 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36798 continue;
36799
36800 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36801 - NULL, devlist[minor].name);
36802 + NULL, "%s", devlist[minor].name);
36803 }
36804
36805 return tty_init();
36806 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36807 index 9df78e2..01ba9ae 100644
36808 --- a/drivers/char/nvram.c
36809 +++ b/drivers/char/nvram.c
36810 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36811
36812 spin_unlock_irq(&rtc_lock);
36813
36814 - if (copy_to_user(buf, contents, tmp - contents))
36815 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36816 return -EFAULT;
36817
36818 *ppos = i;
36819 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36820 index 5c5cc00..ac9edb7 100644
36821 --- a/drivers/char/pcmcia/synclink_cs.c
36822 +++ b/drivers/char/pcmcia/synclink_cs.c
36823 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36824
36825 if (debug_level >= DEBUG_LEVEL_INFO)
36826 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36827 - __FILE__, __LINE__, info->device_name, port->count);
36828 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36829
36830 - WARN_ON(!port->count);
36831 + WARN_ON(!atomic_read(&port->count));
36832
36833 if (tty_port_close_start(port, tty, filp) == 0)
36834 goto cleanup;
36835 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36836 cleanup:
36837 if (debug_level >= DEBUG_LEVEL_INFO)
36838 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36839 - tty->driver->name, port->count);
36840 + tty->driver->name, atomic_read(&port->count));
36841 }
36842
36843 /* Wait until the transmitter is empty.
36844 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36845
36846 if (debug_level >= DEBUG_LEVEL_INFO)
36847 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36848 - __FILE__, __LINE__, tty->driver->name, port->count);
36849 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36850
36851 /* If port is closing, signal caller to try again */
36852 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36853 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36854 goto cleanup;
36855 }
36856 spin_lock(&port->lock);
36857 - port->count++;
36858 + atomic_inc(&port->count);
36859 spin_unlock(&port->lock);
36860 spin_unlock_irqrestore(&info->netlock, flags);
36861
36862 - if (port->count == 1) {
36863 + if (atomic_read(&port->count) == 1) {
36864 /* 1st open on this device, init hardware */
36865 retval = startup(info, tty);
36866 if (retval < 0)
36867 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36868 unsigned short new_crctype;
36869
36870 /* return error if TTY interface open */
36871 - if (info->port.count)
36872 + if (atomic_read(&info->port.count))
36873 return -EBUSY;
36874
36875 switch (encoding)
36876 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36877
36878 /* arbitrate between network and tty opens */
36879 spin_lock_irqsave(&info->netlock, flags);
36880 - if (info->port.count != 0 || info->netcount != 0) {
36881 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36882 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36883 spin_unlock_irqrestore(&info->netlock, flags);
36884 return -EBUSY;
36885 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36886 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36887
36888 /* return error if TTY interface open */
36889 - if (info->port.count)
36890 + if (atomic_read(&info->port.count))
36891 return -EBUSY;
36892
36893 if (cmd != SIOCWANDEV)
36894 diff --git a/drivers/char/random.c b/drivers/char/random.c
36895 index 92e6c67..c640ec3 100644
36896 --- a/drivers/char/random.c
36897 +++ b/drivers/char/random.c
36898 @@ -272,8 +272,13 @@
36899 /*
36900 * Configuration information
36901 */
36902 +#ifdef CONFIG_GRKERNSEC_RANDNET
36903 +#define INPUT_POOL_WORDS 512
36904 +#define OUTPUT_POOL_WORDS 128
36905 +#else
36906 #define INPUT_POOL_WORDS 128
36907 #define OUTPUT_POOL_WORDS 32
36908 +#endif
36909 #define SEC_XFER_SIZE 512
36910 #define EXTRACT_SIZE 10
36911
36912 @@ -313,10 +318,17 @@ static struct poolinfo {
36913 int poolwords;
36914 int tap1, tap2, tap3, tap4, tap5;
36915 } poolinfo_table[] = {
36916 +#ifdef CONFIG_GRKERNSEC_RANDNET
36917 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36918 + { 512, 411, 308, 208, 104, 1 },
36919 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36920 + { 128, 103, 76, 51, 25, 1 },
36921 +#else
36922 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36923 { 128, 103, 76, 51, 25, 1 },
36924 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36925 { 32, 26, 20, 14, 7, 1 },
36926 +#endif
36927 #if 0
36928 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36929 { 2048, 1638, 1231, 819, 411, 1 },
36930 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36931 input_rotate += i ? 7 : 14;
36932 }
36933
36934 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36935 - ACCESS_ONCE(r->add_ptr) = i;
36936 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36937 + ACCESS_ONCE_RW(r->add_ptr) = i;
36938 smp_wmb();
36939
36940 if (out)
36941 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36942
36943 extract_buf(r, tmp);
36944 i = min_t(int, nbytes, EXTRACT_SIZE);
36945 - if (copy_to_user(buf, tmp, i)) {
36946 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36947 ret = -EFAULT;
36948 break;
36949 }
36950 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36951 #include <linux/sysctl.h>
36952
36953 static int min_read_thresh = 8, min_write_thresh;
36954 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36955 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36956 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36957 static char sysctl_bootid[16];
36958
36959 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
36960 static int proc_do_uuid(struct ctl_table *table, int write,
36961 void __user *buffer, size_t *lenp, loff_t *ppos)
36962 {
36963 - struct ctl_table fake_table;
36964 + ctl_table_no_const fake_table;
36965 unsigned char buf[64], tmp_uuid[16], *uuid;
36966
36967 uuid = table->data;
36968 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
36969 index bf2349db..5456d53 100644
36970 --- a/drivers/char/sonypi.c
36971 +++ b/drivers/char/sonypi.c
36972 @@ -54,6 +54,7 @@
36973
36974 #include <asm/uaccess.h>
36975 #include <asm/io.h>
36976 +#include <asm/local.h>
36977
36978 #include <linux/sonypi.h>
36979
36980 @@ -490,7 +491,7 @@ static struct sonypi_device {
36981 spinlock_t fifo_lock;
36982 wait_queue_head_t fifo_proc_list;
36983 struct fasync_struct *fifo_async;
36984 - int open_count;
36985 + local_t open_count;
36986 int model;
36987 struct input_dev *input_jog_dev;
36988 struct input_dev *input_key_dev;
36989 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
36990 static int sonypi_misc_release(struct inode *inode, struct file *file)
36991 {
36992 mutex_lock(&sonypi_device.lock);
36993 - sonypi_device.open_count--;
36994 + local_dec(&sonypi_device.open_count);
36995 mutex_unlock(&sonypi_device.lock);
36996 return 0;
36997 }
36998 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
36999 {
37000 mutex_lock(&sonypi_device.lock);
37001 /* Flush input queue on first open */
37002 - if (!sonypi_device.open_count)
37003 + if (!local_read(&sonypi_device.open_count))
37004 kfifo_reset(&sonypi_device.fifo);
37005 - sonypi_device.open_count++;
37006 + local_inc(&sonypi_device.open_count);
37007 mutex_unlock(&sonypi_device.lock);
37008
37009 return 0;
37010 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37011 index 64420b3..5c40b56 100644
37012 --- a/drivers/char/tpm/tpm_acpi.c
37013 +++ b/drivers/char/tpm/tpm_acpi.c
37014 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37015 virt = acpi_os_map_memory(start, len);
37016 if (!virt) {
37017 kfree(log->bios_event_log);
37018 + log->bios_event_log = NULL;
37019 printk("%s: ERROR - Unable to map memory\n", __func__);
37020 return -EIO;
37021 }
37022
37023 - memcpy_fromio(log->bios_event_log, virt, len);
37024 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37025
37026 acpi_os_unmap_memory(virt, len);
37027 return 0;
37028 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37029 index 84ddc55..1d32f1e 100644
37030 --- a/drivers/char/tpm/tpm_eventlog.c
37031 +++ b/drivers/char/tpm/tpm_eventlog.c
37032 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37033 event = addr;
37034
37035 if ((event->event_type == 0 && event->event_size == 0) ||
37036 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37037 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37038 return NULL;
37039
37040 return addr;
37041 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37042 return NULL;
37043
37044 if ((event->event_type == 0 && event->event_size == 0) ||
37045 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37046 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37047 return NULL;
37048
37049 (*pos)++;
37050 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37051 int i;
37052
37053 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37054 - seq_putc(m, data[i]);
37055 + if (!seq_putc(m, data[i]))
37056 + return -EFAULT;
37057
37058 return 0;
37059 }
37060 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37061 index fc45567..fa2a590 100644
37062 --- a/drivers/char/virtio_console.c
37063 +++ b/drivers/char/virtio_console.c
37064 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37065 if (to_user) {
37066 ssize_t ret;
37067
37068 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37069 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37070 if (ret)
37071 return -EFAULT;
37072 } else {
37073 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37074 if (!port_has_data(port) && !port->host_connected)
37075 return 0;
37076
37077 - return fill_readbuf(port, ubuf, count, true);
37078 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37079 }
37080
37081 static int wait_port_writable(struct port *port, bool nonblock)
37082 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37083 index a33f46f..a720eed 100644
37084 --- a/drivers/clk/clk-composite.c
37085 +++ b/drivers/clk/clk-composite.c
37086 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37087 struct clk *clk;
37088 struct clk_init_data init;
37089 struct clk_composite *composite;
37090 - struct clk_ops *clk_composite_ops;
37091 + clk_ops_no_const *clk_composite_ops;
37092
37093 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37094 if (!composite) {
37095 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37096 index 5bb848c..f1d4fc9 100644
37097 --- a/drivers/clk/socfpga/clk.c
37098 +++ b/drivers/clk/socfpga/clk.c
37099 @@ -22,6 +22,7 @@
37100 #include <linux/clk-provider.h>
37101 #include <linux/io.h>
37102 #include <linux/of.h>
37103 +#include <asm/pgtable.h>
37104
37105 /* Clock Manager offsets */
37106 #define CLKMGR_CTRL 0x0
37107 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37108 streq(clk_name, "periph_pll") ||
37109 streq(clk_name, "sdram_pll")) {
37110 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37111 - clk_pll_ops.enable = clk_gate_ops.enable;
37112 - clk_pll_ops.disable = clk_gate_ops.disable;
37113 + pax_open_kernel();
37114 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37115 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37116 + pax_close_kernel();
37117 }
37118
37119 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37120 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37121 return parent_rate / div;
37122 }
37123
37124 -static struct clk_ops gateclk_ops = {
37125 +static clk_ops_no_const gateclk_ops __read_only = {
37126 .recalc_rate = socfpga_clk_recalc_rate,
37127 .get_parent = socfpga_clk_get_parent,
37128 .set_parent = socfpga_clk_set_parent,
37129 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37130 index 3926402..37b580d 100644
37131 --- a/drivers/cpufreq/acpi-cpufreq.c
37132 +++ b/drivers/cpufreq/acpi-cpufreq.c
37133 @@ -173,7 +173,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37134 return sprintf(buf, "%u\n", boost_enabled);
37135 }
37136
37137 -static struct global_attr global_boost = __ATTR(boost, 0644,
37138 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37139 show_global_boost,
37140 store_global_boost);
37141
37142 @@ -722,8 +722,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37143 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37144 per_cpu(acfreq_data, cpu) = data;
37145
37146 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37147 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37148 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37149 + pax_open_kernel();
37150 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37151 + pax_close_kernel();
37152 + }
37153
37154 result = acpi_processor_register_performance(data->acpi_data, cpu);
37155 if (result)
37156 @@ -851,7 +854,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37157 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37158 break;
37159 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37160 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37161 + pax_open_kernel();
37162 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37163 + pax_close_kernel();
37164 policy->cur = get_cur_freq_on_cpu(cpu);
37165 break;
37166 default:
37167 @@ -862,8 +867,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37168 acpi_processor_notify_smm(THIS_MODULE);
37169
37170 /* Check for APERF/MPERF support in hardware */
37171 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
37172 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37173 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
37174 + pax_open_kernel();
37175 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37176 + pax_close_kernel();
37177 + }
37178
37179 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
37180 for (i = 0; i < perf->state_count; i++)
37181 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37182 index f0a5e2b..0a7ee46 100644
37183 --- a/drivers/cpufreq/cpufreq.c
37184 +++ b/drivers/cpufreq/cpufreq.c
37185 @@ -1959,7 +1959,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37186 return NOTIFY_OK;
37187 }
37188
37189 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37190 +static struct notifier_block cpufreq_cpu_notifier = {
37191 .notifier_call = cpufreq_cpu_callback,
37192 };
37193
37194 @@ -1991,8 +1991,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37195
37196 pr_debug("trying to register driver %s\n", driver_data->name);
37197
37198 - if (driver_data->setpolicy)
37199 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37200 + if (driver_data->setpolicy) {
37201 + pax_open_kernel();
37202 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37203 + pax_close_kernel();
37204 + }
37205
37206 write_lock_irqsave(&cpufreq_driver_lock, flags);
37207 if (cpufreq_driver) {
37208 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37209 index e59afaa..a53a3ff 100644
37210 --- a/drivers/cpufreq/cpufreq_governor.c
37211 +++ b/drivers/cpufreq/cpufreq_governor.c
37212 @@ -191,7 +191,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37213 struct dbs_data *dbs_data;
37214 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37215 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37216 - struct od_ops *od_ops = NULL;
37217 + const struct od_ops *od_ops = NULL;
37218 struct od_dbs_tuners *od_tuners = NULL;
37219 struct cs_dbs_tuners *cs_tuners = NULL;
37220 struct cpu_dbs_common_info *cpu_cdbs;
37221 @@ -257,7 +257,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37222
37223 if ((cdata->governor == GOV_CONSERVATIVE) &&
37224 (!policy->governor->initialized)) {
37225 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37226 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37227
37228 cpufreq_register_notifier(cs_ops->notifier_block,
37229 CPUFREQ_TRANSITION_NOTIFIER);
37230 @@ -277,7 +277,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37231
37232 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37233 (policy->governor->initialized == 1)) {
37234 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37235 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37236
37237 cpufreq_unregister_notifier(cs_ops->notifier_block,
37238 CPUFREQ_TRANSITION_NOTIFIER);
37239 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37240 index d5f12b4..eb30af1 100644
37241 --- a/drivers/cpufreq/cpufreq_governor.h
37242 +++ b/drivers/cpufreq/cpufreq_governor.h
37243 @@ -204,7 +204,7 @@ struct common_dbs_data {
37244 void (*exit)(struct dbs_data *dbs_data);
37245
37246 /* Governor specific ops, see below */
37247 - void *gov_ops;
37248 + const void *gov_ops;
37249 };
37250
37251 /* Governer Per policy data */
37252 @@ -224,7 +224,7 @@ struct od_ops {
37253 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37254 unsigned int freq_next, unsigned int relation);
37255 void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq);
37256 -};
37257 +} __no_const;
37258
37259 struct cs_ops {
37260 struct notifier_block *notifier_block;
37261 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37262 index c087347..989aa2e 100644
37263 --- a/drivers/cpufreq/cpufreq_ondemand.c
37264 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37265 @@ -560,7 +560,7 @@ static void od_exit(struct dbs_data *dbs_data)
37266
37267 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37268
37269 -static struct od_ops od_ops = {
37270 +static struct od_ops od_ops __read_only = {
37271 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37272 .powersave_bias_target = generic_powersave_bias_target,
37273 .freq_increase = dbs_freq_increase,
37274 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37275 (struct cpufreq_policy *, unsigned int, unsigned int),
37276 unsigned int powersave_bias)
37277 {
37278 - od_ops.powersave_bias_target = f;
37279 + pax_open_kernel();
37280 + *(void **)&od_ops.powersave_bias_target = f;
37281 + pax_close_kernel();
37282 od_set_powersave_bias(powersave_bias);
37283 }
37284 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37285
37286 void od_unregister_powersave_bias_handler(void)
37287 {
37288 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37289 + pax_open_kernel();
37290 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37291 + pax_close_kernel();
37292 od_set_powersave_bias(0);
37293 }
37294 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37295 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37296 index d37568c..fbb19a1 100644
37297 --- a/drivers/cpufreq/cpufreq_stats.c
37298 +++ b/drivers/cpufreq/cpufreq_stats.c
37299 @@ -365,7 +365,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37300 }
37301
37302 /* priority=1 so this will get called before cpufreq_remove_dev */
37303 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37304 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37305 .notifier_call = cpufreq_stat_cpu_callback,
37306 .priority = 1,
37307 };
37308 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37309 index 9ee7817..17b658e 100644
37310 --- a/drivers/cpufreq/p4-clockmod.c
37311 +++ b/drivers/cpufreq/p4-clockmod.c
37312 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37313 case 0x0F: /* Core Duo */
37314 case 0x16: /* Celeron Core */
37315 case 0x1C: /* Atom */
37316 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37317 + pax_open_kernel();
37318 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37319 + pax_close_kernel();
37320 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37321 case 0x0D: /* Pentium M (Dothan) */
37322 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37323 + pax_open_kernel();
37324 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37325 + pax_close_kernel();
37326 /* fall through */
37327 case 0x09: /* Pentium M (Banias) */
37328 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37329 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37330
37331 /* on P-4s, the TSC runs with constant frequency independent whether
37332 * throttling is active or not. */
37333 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37334 + pax_open_kernel();
37335 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37336 + pax_close_kernel();
37337
37338 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37339 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37340 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37341 index 880ee29..2445bc6 100644
37342 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37343 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37344 @@ -18,14 +18,12 @@
37345 #include <asm/head.h>
37346 #include <asm/timer.h>
37347
37348 -static struct cpufreq_driver *cpufreq_us3_driver;
37349 -
37350 struct us3_freq_percpu_info {
37351 struct cpufreq_frequency_table table[4];
37352 };
37353
37354 /* Indexed by cpu number. */
37355 -static struct us3_freq_percpu_info *us3_freq_table;
37356 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37357
37358 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37359 * in the Safari config register.
37360 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37361
37362 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37363 {
37364 - if (cpufreq_us3_driver)
37365 - us3_set_cpu_divider_index(policy, 0);
37366 + us3_set_cpu_divider_index(policy->cpu, 0);
37367
37368 return 0;
37369 }
37370
37371 +static int __init us3_freq_init(void);
37372 +static void __exit us3_freq_exit(void);
37373 +
37374 +static struct cpufreq_driver cpufreq_us3_driver = {
37375 + .init = us3_freq_cpu_init,
37376 + .verify = us3_freq_verify,
37377 + .target = us3_freq_target,
37378 + .get = us3_freq_get,
37379 + .exit = us3_freq_cpu_exit,
37380 + .owner = THIS_MODULE,
37381 + .name = "UltraSPARC-III",
37382 +
37383 +};
37384 +
37385 static int __init us3_freq_init(void)
37386 {
37387 unsigned long manuf, impl, ver;
37388 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
37389 (impl == CHEETAH_IMPL ||
37390 impl == CHEETAH_PLUS_IMPL ||
37391 impl == JAGUAR_IMPL ||
37392 - impl == PANTHER_IMPL)) {
37393 - struct cpufreq_driver *driver;
37394 -
37395 - ret = -ENOMEM;
37396 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
37397 - if (!driver)
37398 - goto err_out;
37399 -
37400 - us3_freq_table = kzalloc(
37401 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
37402 - GFP_KERNEL);
37403 - if (!us3_freq_table)
37404 - goto err_out;
37405 -
37406 - driver->init = us3_freq_cpu_init;
37407 - driver->verify = us3_freq_verify;
37408 - driver->target = us3_freq_target;
37409 - driver->get = us3_freq_get;
37410 - driver->exit = us3_freq_cpu_exit;
37411 - driver->owner = THIS_MODULE,
37412 - strcpy(driver->name, "UltraSPARC-III");
37413 -
37414 - cpufreq_us3_driver = driver;
37415 - ret = cpufreq_register_driver(driver);
37416 - if (ret)
37417 - goto err_out;
37418 -
37419 - return 0;
37420 -
37421 -err_out:
37422 - if (driver) {
37423 - kfree(driver);
37424 - cpufreq_us3_driver = NULL;
37425 - }
37426 - kfree(us3_freq_table);
37427 - us3_freq_table = NULL;
37428 - return ret;
37429 - }
37430 + impl == PANTHER_IMPL))
37431 + return cpufreq_register_driver(&cpufreq_us3_driver);
37432
37433 return -ENODEV;
37434 }
37435
37436 static void __exit us3_freq_exit(void)
37437 {
37438 - if (cpufreq_us3_driver) {
37439 - cpufreq_unregister_driver(cpufreq_us3_driver);
37440 - kfree(cpufreq_us3_driver);
37441 - cpufreq_us3_driver = NULL;
37442 - kfree(us3_freq_table);
37443 - us3_freq_table = NULL;
37444 - }
37445 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37446 }
37447
37448 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37449 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37450 index 0915e71..53376ed 100644
37451 --- a/drivers/cpufreq/speedstep-centrino.c
37452 +++ b/drivers/cpufreq/speedstep-centrino.c
37453 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37454 !cpu_has(cpu, X86_FEATURE_EST))
37455 return -ENODEV;
37456
37457 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37458 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37459 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37460 + pax_open_kernel();
37461 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37462 + pax_close_kernel();
37463 + }
37464
37465 if (policy->cpu != 0)
37466 return -ENODEV;
37467 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37468 index fdc432f..98e64e2 100644
37469 --- a/drivers/cpuidle/cpuidle.c
37470 +++ b/drivers/cpuidle/cpuidle.c
37471 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
37472
37473 static void poll_idle_init(struct cpuidle_driver *drv)
37474 {
37475 - struct cpuidle_state *state = &drv->states[0];
37476 + cpuidle_state_no_const *state = &drv->states[0];
37477
37478 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37479 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37480 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37481 index ea2f8e7..70ac501 100644
37482 --- a/drivers/cpuidle/governor.c
37483 +++ b/drivers/cpuidle/governor.c
37484 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37485 mutex_lock(&cpuidle_lock);
37486 if (__cpuidle_find_governor(gov->name) == NULL) {
37487 ret = 0;
37488 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37489 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37490 if (!cpuidle_curr_governor ||
37491 cpuidle_curr_governor->rating < gov->rating)
37492 cpuidle_switch_governor(gov);
37493 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37494 new_gov = cpuidle_replace_governor(gov->rating);
37495 cpuidle_switch_governor(new_gov);
37496 }
37497 - list_del(&gov->governor_list);
37498 + pax_list_del((struct list_head *)&gov->governor_list);
37499 mutex_unlock(&cpuidle_lock);
37500 }
37501
37502 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37503 index 428754a..8bdf9cc 100644
37504 --- a/drivers/cpuidle/sysfs.c
37505 +++ b/drivers/cpuidle/sysfs.c
37506 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37507 NULL
37508 };
37509
37510 -static struct attribute_group cpuidle_attr_group = {
37511 +static attribute_group_no_const cpuidle_attr_group = {
37512 .attrs = cpuidle_default_attrs,
37513 .name = "cpuidle",
37514 };
37515 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37516 index 12fea3e..1e28f47 100644
37517 --- a/drivers/crypto/hifn_795x.c
37518 +++ b/drivers/crypto/hifn_795x.c
37519 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37520 MODULE_PARM_DESC(hifn_pll_ref,
37521 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37522
37523 -static atomic_t hifn_dev_number;
37524 +static atomic_unchecked_t hifn_dev_number;
37525
37526 #define ACRYPTO_OP_DECRYPT 0
37527 #define ACRYPTO_OP_ENCRYPT 1
37528 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37529 goto err_out_disable_pci_device;
37530
37531 snprintf(name, sizeof(name), "hifn%d",
37532 - atomic_inc_return(&hifn_dev_number)-1);
37533 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37534
37535 err = pci_request_regions(pdev, name);
37536 if (err)
37537 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37538 index e94e619..f7e249c 100644
37539 --- a/drivers/devfreq/devfreq.c
37540 +++ b/drivers/devfreq/devfreq.c
37541 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37542 goto err_out;
37543 }
37544
37545 - list_add(&governor->node, &devfreq_governor_list);
37546 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37547
37548 list_for_each_entry(devfreq, &devfreq_list, node) {
37549 int ret = 0;
37550 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37551 }
37552 }
37553
37554 - list_del(&governor->node);
37555 + pax_list_del((struct list_head *)&governor->node);
37556 err_out:
37557 mutex_unlock(&devfreq_list_lock);
37558
37559 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
37560 index 5039fbc..841169f 100644
37561 --- a/drivers/dma/sh/shdma.c
37562 +++ b/drivers/dma/sh/shdma.c
37563 @@ -488,7 +488,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37564 return ret;
37565 }
37566
37567 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37568 +static struct notifier_block sh_dmae_nmi_notifier = {
37569 .notifier_call = sh_dmae_nmi_handler,
37570
37571 /* Run before NMI debug handler and KGDB */
37572 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37573 index 211021d..201d47f 100644
37574 --- a/drivers/edac/edac_device.c
37575 +++ b/drivers/edac/edac_device.c
37576 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37577 */
37578 int edac_device_alloc_index(void)
37579 {
37580 - static atomic_t device_indexes = ATOMIC_INIT(0);
37581 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37582
37583 - return atomic_inc_return(&device_indexes) - 1;
37584 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37585 }
37586 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37587
37588 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37589 index e7c32c4..6397af1 100644
37590 --- a/drivers/edac/edac_mc_sysfs.c
37591 +++ b/drivers/edac/edac_mc_sysfs.c
37592 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
37593 struct dev_ch_attribute {
37594 struct device_attribute attr;
37595 int channel;
37596 -};
37597 +} __do_const;
37598
37599 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37600 struct dev_ch_attribute dev_attr_legacy_##_name = \
37601 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37602 }
37603
37604 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37605 + pax_open_kernel();
37606 if (mci->get_sdram_scrub_rate) {
37607 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37608 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37609 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37610 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37611 }
37612 if (mci->set_sdram_scrub_rate) {
37613 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37614 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37615 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37616 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37617 }
37618 + pax_close_kernel();
37619 err = device_create_file(&mci->dev,
37620 &dev_attr_sdram_scrub_rate);
37621 if (err) {
37622 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37623 index dd370f9..0281629 100644
37624 --- a/drivers/edac/edac_pci.c
37625 +++ b/drivers/edac/edac_pci.c
37626 @@ -29,7 +29,7 @@
37627
37628 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37629 static LIST_HEAD(edac_pci_list);
37630 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37631 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37632
37633 /*
37634 * edac_pci_alloc_ctl_info
37635 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37636 */
37637 int edac_pci_alloc_index(void)
37638 {
37639 - return atomic_inc_return(&pci_indexes) - 1;
37640 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37641 }
37642 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37643
37644 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37645 index e8658e4..22746d6 100644
37646 --- a/drivers/edac/edac_pci_sysfs.c
37647 +++ b/drivers/edac/edac_pci_sysfs.c
37648 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37649 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37650 static int edac_pci_poll_msec = 1000; /* one second workq period */
37651
37652 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37653 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37654 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37655 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37656
37657 static struct kobject *edac_pci_top_main_kobj;
37658 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37659 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37660 void *value;
37661 ssize_t(*show) (void *, char *);
37662 ssize_t(*store) (void *, const char *, size_t);
37663 -};
37664 +} __do_const;
37665
37666 /* Set of show/store abstract level functions for PCI Parity object */
37667 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37668 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37669 edac_printk(KERN_CRIT, EDAC_PCI,
37670 "Signaled System Error on %s\n",
37671 pci_name(dev));
37672 - atomic_inc(&pci_nonparity_count);
37673 + atomic_inc_unchecked(&pci_nonparity_count);
37674 }
37675
37676 if (status & (PCI_STATUS_PARITY)) {
37677 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37678 "Master Data Parity Error on %s\n",
37679 pci_name(dev));
37680
37681 - atomic_inc(&pci_parity_count);
37682 + atomic_inc_unchecked(&pci_parity_count);
37683 }
37684
37685 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37686 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37687 "Detected Parity Error on %s\n",
37688 pci_name(dev));
37689
37690 - atomic_inc(&pci_parity_count);
37691 + atomic_inc_unchecked(&pci_parity_count);
37692 }
37693 }
37694
37695 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37696 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37697 "Signaled System Error on %s\n",
37698 pci_name(dev));
37699 - atomic_inc(&pci_nonparity_count);
37700 + atomic_inc_unchecked(&pci_nonparity_count);
37701 }
37702
37703 if (status & (PCI_STATUS_PARITY)) {
37704 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37705 "Master Data Parity Error on "
37706 "%s\n", pci_name(dev));
37707
37708 - atomic_inc(&pci_parity_count);
37709 + atomic_inc_unchecked(&pci_parity_count);
37710 }
37711
37712 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37713 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37714 "Detected Parity Error on %s\n",
37715 pci_name(dev));
37716
37717 - atomic_inc(&pci_parity_count);
37718 + atomic_inc_unchecked(&pci_parity_count);
37719 }
37720 }
37721 }
37722 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37723 if (!check_pci_errors)
37724 return;
37725
37726 - before_count = atomic_read(&pci_parity_count);
37727 + before_count = atomic_read_unchecked(&pci_parity_count);
37728
37729 /* scan all PCI devices looking for a Parity Error on devices and
37730 * bridges.
37731 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37732 /* Only if operator has selected panic on PCI Error */
37733 if (edac_pci_get_panic_on_pe()) {
37734 /* If the count is different 'after' from 'before' */
37735 - if (before_count != atomic_read(&pci_parity_count))
37736 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37737 panic("EDAC: PCI Parity Error");
37738 }
37739 }
37740 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37741 index 51b7e3a..aa8a3e8 100644
37742 --- a/drivers/edac/mce_amd.h
37743 +++ b/drivers/edac/mce_amd.h
37744 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37745 bool (*mc0_mce)(u16, u8);
37746 bool (*mc1_mce)(u16, u8);
37747 bool (*mc2_mce)(u16, u8);
37748 -};
37749 +} __no_const;
37750
37751 void amd_report_gart_errors(bool);
37752 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37753 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37754 index 57ea7f4..af06b76 100644
37755 --- a/drivers/firewire/core-card.c
37756 +++ b/drivers/firewire/core-card.c
37757 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37758 const struct fw_card_driver *driver,
37759 struct device *device)
37760 {
37761 - static atomic_t index = ATOMIC_INIT(-1);
37762 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37763
37764 - card->index = atomic_inc_return(&index);
37765 + card->index = atomic_inc_return_unchecked(&index);
37766 card->driver = driver;
37767 card->device = device;
37768 card->current_tlabel = 0;
37769 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37770
37771 void fw_core_remove_card(struct fw_card *card)
37772 {
37773 - struct fw_card_driver dummy_driver = dummy_driver_template;
37774 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37775
37776 card->driver->update_phy_reg(card, 4,
37777 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37778 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37779 index de4aa40..49ab1f2 100644
37780 --- a/drivers/firewire/core-device.c
37781 +++ b/drivers/firewire/core-device.c
37782 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37783 struct config_rom_attribute {
37784 struct device_attribute attr;
37785 u32 key;
37786 -};
37787 +} __do_const;
37788
37789 static ssize_t show_immediate(struct device *dev,
37790 struct device_attribute *dattr, char *buf)
37791 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37792 index 28a94c7..58da63a 100644
37793 --- a/drivers/firewire/core-transaction.c
37794 +++ b/drivers/firewire/core-transaction.c
37795 @@ -38,6 +38,7 @@
37796 #include <linux/timer.h>
37797 #include <linux/types.h>
37798 #include <linux/workqueue.h>
37799 +#include <linux/sched.h>
37800
37801 #include <asm/byteorder.h>
37802
37803 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37804 index 515a42c..5ecf3ba 100644
37805 --- a/drivers/firewire/core.h
37806 +++ b/drivers/firewire/core.h
37807 @@ -111,6 +111,7 @@ struct fw_card_driver {
37808
37809 int (*stop_iso)(struct fw_iso_context *ctx);
37810 };
37811 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37812
37813 void fw_card_initialize(struct fw_card *card,
37814 const struct fw_card_driver *driver, struct device *device);
37815 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37816 index 94a58a0..f5eba42 100644
37817 --- a/drivers/firmware/dmi-id.c
37818 +++ b/drivers/firmware/dmi-id.c
37819 @@ -16,7 +16,7 @@
37820 struct dmi_device_attribute{
37821 struct device_attribute dev_attr;
37822 int field;
37823 -};
37824 +} __do_const;
37825 #define to_dmi_dev_attr(_dev_attr) \
37826 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37827
37828 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37829 index 232fa8f..386c255 100644
37830 --- a/drivers/firmware/dmi_scan.c
37831 +++ b/drivers/firmware/dmi_scan.c
37832 @@ -504,11 +504,6 @@ void __init dmi_scan_machine(void)
37833 }
37834 }
37835 else {
37836 - /*
37837 - * no iounmap() for that ioremap(); it would be a no-op, but
37838 - * it's so early in setup that sucker gets confused into doing
37839 - * what it shouldn't if we actually call it.
37840 - */
37841 p = dmi_ioremap(0xF0000, 0x10000);
37842 if (p == NULL)
37843 goto error;
37844 @@ -806,7 +801,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37845 if (buf == NULL)
37846 return -1;
37847
37848 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37849 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37850
37851 iounmap(buf);
37852 return 0;
37853 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37854 index 5145fa3..0d3babd 100644
37855 --- a/drivers/firmware/efi/efi.c
37856 +++ b/drivers/firmware/efi/efi.c
37857 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37858 };
37859
37860 static struct efivars generic_efivars;
37861 -static struct efivar_operations generic_ops;
37862 +static efivar_operations_no_const generic_ops __read_only;
37863
37864 static int generic_ops_register(void)
37865 {
37866 - generic_ops.get_variable = efi.get_variable;
37867 - generic_ops.set_variable = efi.set_variable;
37868 - generic_ops.get_next_variable = efi.get_next_variable;
37869 - generic_ops.query_variable_store = efi_query_variable_store;
37870 + pax_open_kernel();
37871 + *(void **)&generic_ops.get_variable = efi.get_variable;
37872 + *(void **)&generic_ops.set_variable = efi.set_variable;
37873 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37874 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37875 + pax_close_kernel();
37876
37877 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37878 }
37879 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37880 index 8a7432a..28fb839 100644
37881 --- a/drivers/firmware/efi/efivars.c
37882 +++ b/drivers/firmware/efi/efivars.c
37883 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37884 static int
37885 create_efivars_bin_attributes(void)
37886 {
37887 - struct bin_attribute *attr;
37888 + bin_attribute_no_const *attr;
37889 int error;
37890
37891 /* new_var */
37892 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37893 index 2a90ba6..07f3733 100644
37894 --- a/drivers/firmware/google/memconsole.c
37895 +++ b/drivers/firmware/google/memconsole.c
37896 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37897 if (!found_memconsole())
37898 return -ENODEV;
37899
37900 - memconsole_bin_attr.size = memconsole_length;
37901 + pax_open_kernel();
37902 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37903 + pax_close_kernel();
37904
37905 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37906
37907 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37908 index 2729e3d..f9deca1 100644
37909 --- a/drivers/gpio/gpio-ich.c
37910 +++ b/drivers/gpio/gpio-ich.c
37911 @@ -71,7 +71,7 @@ struct ichx_desc {
37912 /* Some chipsets have quirks, let these use their own request/get */
37913 int (*request)(struct gpio_chip *chip, unsigned offset);
37914 int (*get)(struct gpio_chip *chip, unsigned offset);
37915 -};
37916 +} __do_const;
37917
37918 static struct {
37919 spinlock_t lock;
37920 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37921 index 9902732..64b62dd 100644
37922 --- a/drivers/gpio/gpio-vr41xx.c
37923 +++ b/drivers/gpio/gpio-vr41xx.c
37924 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37925 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37926 maskl, pendl, maskh, pendh);
37927
37928 - atomic_inc(&irq_err_count);
37929 + atomic_inc_unchecked(&irq_err_count);
37930
37931 return -EINVAL;
37932 }
37933 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37934 index 6a64749..0767a9f 100644
37935 --- a/drivers/gpu/drm/drm_crtc_helper.c
37936 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37937 @@ -322,7 +322,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37938 struct drm_crtc *tmp;
37939 int crtc_mask = 1;
37940
37941 - WARN(!crtc, "checking null crtc?\n");
37942 + BUG_ON(!crtc);
37943
37944 dev = crtc->dev;
37945
37946 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37947 index 6dd7173..32d755c 100644
37948 --- a/drivers/gpu/drm/drm_drv.c
37949 +++ b/drivers/gpu/drm/drm_drv.c
37950 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
37951 /**
37952 * Copy and IOCTL return string to user space
37953 */
37954 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37955 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37956 {
37957 int len;
37958
37959 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
37960 struct drm_file *file_priv = filp->private_data;
37961 struct drm_device *dev;
37962 const struct drm_ioctl_desc *ioctl = NULL;
37963 - drm_ioctl_t *func;
37964 + drm_ioctl_no_const_t func;
37965 unsigned int nr = DRM_IOCTL_NR(cmd);
37966 int retcode = -EINVAL;
37967 char stack_kdata[128];
37968 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
37969 return -ENODEV;
37970
37971 atomic_inc(&dev->ioctl_count);
37972 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37973 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37974 ++file_priv->ioctl_count;
37975
37976 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37977 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37978 index 3a24385..4e426e0 100644
37979 --- a/drivers/gpu/drm/drm_fops.c
37980 +++ b/drivers/gpu/drm/drm_fops.c
37981 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
37982 }
37983
37984 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
37985 - atomic_set(&dev->counts[i], 0);
37986 + atomic_set_unchecked(&dev->counts[i], 0);
37987
37988 dev->sigdata.lock = NULL;
37989
37990 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
37991 if (drm_device_is_unplugged(dev))
37992 return -ENODEV;
37993
37994 - if (!dev->open_count++)
37995 + if (local_inc_return(&dev->open_count) == 1)
37996 need_setup = 1;
37997 mutex_lock(&dev->struct_mutex);
37998 old_imapping = inode->i_mapping;
37999 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
38000 retcode = drm_open_helper(inode, filp, dev);
38001 if (retcode)
38002 goto err_undo;
38003 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38004 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38005 if (need_setup) {
38006 retcode = drm_setup(dev);
38007 if (retcode)
38008 @@ -166,7 +166,7 @@ err_undo:
38009 iput(container_of(dev->dev_mapping, struct inode, i_data));
38010 dev->dev_mapping = old_mapping;
38011 mutex_unlock(&dev->struct_mutex);
38012 - dev->open_count--;
38013 + local_dec(&dev->open_count);
38014 return retcode;
38015 }
38016 EXPORT_SYMBOL(drm_open);
38017 @@ -456,7 +456,7 @@ int drm_release(struct inode *inode, struct file *filp)
38018
38019 mutex_lock(&drm_global_mutex);
38020
38021 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38022 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38023
38024 if (dev->driver->preclose)
38025 dev->driver->preclose(dev, file_priv);
38026 @@ -465,10 +465,10 @@ int drm_release(struct inode *inode, struct file *filp)
38027 * Begin inline drm_release
38028 */
38029
38030 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38031 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38032 task_pid_nr(current),
38033 (long)old_encode_dev(file_priv->minor->device),
38034 - dev->open_count);
38035 + local_read(&dev->open_count));
38036
38037 /* Release any auth tokens that might point to this file_priv,
38038 (do that under the drm_global_mutex) */
38039 @@ -565,8 +565,8 @@ int drm_release(struct inode *inode, struct file *filp)
38040 * End inline drm_release
38041 */
38042
38043 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38044 - if (!--dev->open_count) {
38045 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38046 + if (local_dec_and_test(&dev->open_count)) {
38047 if (atomic_read(&dev->ioctl_count)) {
38048 DRM_ERROR("Device busy: %d\n",
38049 atomic_read(&dev->ioctl_count));
38050 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38051 index f731116..629842c 100644
38052 --- a/drivers/gpu/drm/drm_global.c
38053 +++ b/drivers/gpu/drm/drm_global.c
38054 @@ -36,7 +36,7 @@
38055 struct drm_global_item {
38056 struct mutex mutex;
38057 void *object;
38058 - int refcount;
38059 + atomic_t refcount;
38060 };
38061
38062 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38063 @@ -49,7 +49,7 @@ void drm_global_init(void)
38064 struct drm_global_item *item = &glob[i];
38065 mutex_init(&item->mutex);
38066 item->object = NULL;
38067 - item->refcount = 0;
38068 + atomic_set(&item->refcount, 0);
38069 }
38070 }
38071
38072 @@ -59,7 +59,7 @@ void drm_global_release(void)
38073 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38074 struct drm_global_item *item = &glob[i];
38075 BUG_ON(item->object != NULL);
38076 - BUG_ON(item->refcount != 0);
38077 + BUG_ON(atomic_read(&item->refcount) != 0);
38078 }
38079 }
38080
38081 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38082 void *object;
38083
38084 mutex_lock(&item->mutex);
38085 - if (item->refcount == 0) {
38086 + if (atomic_read(&item->refcount) == 0) {
38087 item->object = kzalloc(ref->size, GFP_KERNEL);
38088 if (unlikely(item->object == NULL)) {
38089 ret = -ENOMEM;
38090 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38091 goto out_err;
38092
38093 }
38094 - ++item->refcount;
38095 + atomic_inc(&item->refcount);
38096 ref->object = item->object;
38097 object = item->object;
38098 mutex_unlock(&item->mutex);
38099 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38100 struct drm_global_item *item = &glob[ref->global_type];
38101
38102 mutex_lock(&item->mutex);
38103 - BUG_ON(item->refcount == 0);
38104 + BUG_ON(atomic_read(&item->refcount) == 0);
38105 BUG_ON(ref->object != item->object);
38106 - if (--item->refcount == 0) {
38107 + if (atomic_dec_and_test(&item->refcount)) {
38108 ref->release(ref);
38109 item->object = NULL;
38110 }
38111 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38112 index d4b20ce..77a8d41 100644
38113 --- a/drivers/gpu/drm/drm_info.c
38114 +++ b/drivers/gpu/drm/drm_info.c
38115 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38116 struct drm_local_map *map;
38117 struct drm_map_list *r_list;
38118
38119 - /* Hardcoded from _DRM_FRAME_BUFFER,
38120 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38121 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38122 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38123 + static const char * const types[] = {
38124 + [_DRM_FRAME_BUFFER] = "FB",
38125 + [_DRM_REGISTERS] = "REG",
38126 + [_DRM_SHM] = "SHM",
38127 + [_DRM_AGP] = "AGP",
38128 + [_DRM_SCATTER_GATHER] = "SG",
38129 + [_DRM_CONSISTENT] = "PCI",
38130 + [_DRM_GEM] = "GEM" };
38131 const char *type;
38132 int i;
38133
38134 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38135 map = r_list->map;
38136 if (!map)
38137 continue;
38138 - if (map->type < 0 || map->type > 5)
38139 + if (map->type >= ARRAY_SIZE(types))
38140 type = "??";
38141 else
38142 type = types[map->type];
38143 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38144 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38145 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38146 vma->vm_flags & VM_IO ? 'i' : '-',
38147 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38148 + 0);
38149 +#else
38150 vma->vm_pgoff);
38151 +#endif
38152
38153 #if defined(__i386__)
38154 pgprot = pgprot_val(vma->vm_page_prot);
38155 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38156 index 2f4c434..dd12cd2 100644
38157 --- a/drivers/gpu/drm/drm_ioc32.c
38158 +++ b/drivers/gpu/drm/drm_ioc32.c
38159 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38160 request = compat_alloc_user_space(nbytes);
38161 if (!access_ok(VERIFY_WRITE, request, nbytes))
38162 return -EFAULT;
38163 - list = (struct drm_buf_desc *) (request + 1);
38164 + list = (struct drm_buf_desc __user *) (request + 1);
38165
38166 if (__put_user(count, &request->count)
38167 || __put_user(list, &request->list))
38168 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38169 request = compat_alloc_user_space(nbytes);
38170 if (!access_ok(VERIFY_WRITE, request, nbytes))
38171 return -EFAULT;
38172 - list = (struct drm_buf_pub *) (request + 1);
38173 + list = (struct drm_buf_pub __user *) (request + 1);
38174
38175 if (__put_user(count, &request->count)
38176 || __put_user(list, &request->list))
38177 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38178 return 0;
38179 }
38180
38181 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38182 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38183 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38184 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38185 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38186 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38187 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38188 {
38189 unsigned int nr = DRM_IOCTL_NR(cmd);
38190 - drm_ioctl_compat_t *fn;
38191 int ret;
38192
38193 /* Assume that ioctls without an explicit compat routine will just
38194 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38195 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38196 return drm_ioctl(filp, cmd, arg);
38197
38198 - fn = drm_compat_ioctls[nr];
38199 -
38200 - if (fn != NULL)
38201 - ret = (*fn) (filp, cmd, arg);
38202 + if (drm_compat_ioctls[nr] != NULL)
38203 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38204 else
38205 ret = drm_ioctl(filp, cmd, arg);
38206
38207 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
38208 index ffd7a7b..a64643e 100644
38209 --- a/drivers/gpu/drm/drm_ioctl.c
38210 +++ b/drivers/gpu/drm/drm_ioctl.c
38211 @@ -265,7 +265,7 @@ int drm_getstats(struct drm_device *dev, void *data,
38212 stats->data[i].value =
38213 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
38214 else
38215 - stats->data[i].value = atomic_read(&dev->counts[i]);
38216 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
38217 stats->data[i].type = dev->types[i];
38218 }
38219
38220 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38221 index d752c96..fe08455 100644
38222 --- a/drivers/gpu/drm/drm_lock.c
38223 +++ b/drivers/gpu/drm/drm_lock.c
38224 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38225 if (drm_lock_take(&master->lock, lock->context)) {
38226 master->lock.file_priv = file_priv;
38227 master->lock.lock_time = jiffies;
38228 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38229 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38230 break; /* Got lock */
38231 }
38232
38233 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38234 return -EINVAL;
38235 }
38236
38237 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38238 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38239
38240 if (drm_lock_free(&master->lock, lock->context)) {
38241 /* FIXME: Should really bail out here. */
38242 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38243 index 327ca19..684d3c0 100644
38244 --- a/drivers/gpu/drm/drm_stub.c
38245 +++ b/drivers/gpu/drm/drm_stub.c
38246 @@ -495,7 +495,7 @@ void drm_unplug_dev(struct drm_device *dev)
38247
38248 drm_device_set_unplugged(dev);
38249
38250 - if (dev->open_count == 0) {
38251 + if (local_read(&dev->open_count) == 0) {
38252 drm_put_dev(dev);
38253 }
38254 mutex_unlock(&drm_global_mutex);
38255 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38256 index 2290b3b..22056a1 100644
38257 --- a/drivers/gpu/drm/drm_sysfs.c
38258 +++ b/drivers/gpu/drm/drm_sysfs.c
38259 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38260 int drm_sysfs_device_add(struct drm_minor *minor)
38261 {
38262 int err;
38263 - char *minor_str;
38264 + const char *minor_str;
38265
38266 minor->kdev.parent = minor->dev->dev;
38267
38268 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38269 index ada49ed..29275a0 100644
38270 --- a/drivers/gpu/drm/i810/i810_dma.c
38271 +++ b/drivers/gpu/drm/i810/i810_dma.c
38272 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38273 dma->buflist[vertex->idx],
38274 vertex->discard, vertex->used);
38275
38276 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38277 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38278 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38279 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38280 sarea_priv->last_enqueue = dev_priv->counter - 1;
38281 sarea_priv->last_dispatch = (int)hw_status[5];
38282
38283 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38284 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38285 mc->last_render);
38286
38287 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38288 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38289 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38290 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38291 sarea_priv->last_enqueue = dev_priv->counter - 1;
38292 sarea_priv->last_dispatch = (int)hw_status[5];
38293
38294 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38295 index 6e0acad..93c8289 100644
38296 --- a/drivers/gpu/drm/i810/i810_drv.h
38297 +++ b/drivers/gpu/drm/i810/i810_drv.h
38298 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38299 int page_flipping;
38300
38301 wait_queue_head_t irq_queue;
38302 - atomic_t irq_received;
38303 - atomic_t irq_emitted;
38304 + atomic_unchecked_t irq_received;
38305 + atomic_unchecked_t irq_emitted;
38306
38307 int front_offset;
38308 } drm_i810_private_t;
38309 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38310 index 47d6c74..279123f 100644
38311 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38312 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38313 @@ -541,7 +541,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38314 I915_READ(GTIMR));
38315 }
38316 seq_printf(m, "Interrupts received: %d\n",
38317 - atomic_read(&dev_priv->irq_received));
38318 + atomic_read_unchecked(&dev_priv->irq_received));
38319 for_each_ring(ring, dev_priv, i) {
38320 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38321 seq_printf(m,
38322 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38323 index f466980..8f2883f 100644
38324 --- a/drivers/gpu/drm/i915/i915_dma.c
38325 +++ b/drivers/gpu/drm/i915/i915_dma.c
38326 @@ -1260,7 +1260,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38327 bool can_switch;
38328
38329 spin_lock(&dev->count_lock);
38330 - can_switch = (dev->open_count == 0);
38331 + can_switch = (local_read(&dev->open_count) == 0);
38332 spin_unlock(&dev->count_lock);
38333 return can_switch;
38334 }
38335 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38336 index 2f09e80..077876d 100644
38337 --- a/drivers/gpu/drm/i915/i915_drv.h
38338 +++ b/drivers/gpu/drm/i915/i915_drv.h
38339 @@ -1028,7 +1028,7 @@ typedef struct drm_i915_private {
38340 drm_dma_handle_t *status_page_dmah;
38341 struct resource mch_res;
38342
38343 - atomic_t irq_received;
38344 + atomic_unchecked_t irq_received;
38345
38346 /* protects the irq masks */
38347 spinlock_t irq_lock;
38348 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38349 index 87a3227..cd13d8f 100644
38350 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38351 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38352 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38353
38354 static int
38355 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38356 - int count)
38357 + unsigned int count)
38358 {
38359 - int i;
38360 + unsigned int i;
38361 int relocs_total = 0;
38362 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38363
38364 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38365 index 3c59584..500f2e9 100644
38366 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38367 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38368 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38369 (unsigned long)request);
38370 }
38371
38372 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38373 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38374 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38375 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38376 [DRM_I915_GETPARAM] = compat_i915_getparam,
38377 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38378 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38379 {
38380 unsigned int nr = DRM_IOCTL_NR(cmd);
38381 - drm_ioctl_compat_t *fn = NULL;
38382 int ret;
38383
38384 if (nr < DRM_COMMAND_BASE)
38385 return drm_compat_ioctl(filp, cmd, arg);
38386
38387 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38388 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38389 -
38390 - if (fn != NULL)
38391 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38392 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38393 ret = (*fn) (filp, cmd, arg);
38394 - else
38395 + } else
38396 ret = drm_ioctl(filp, cmd, arg);
38397
38398 return ret;
38399 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38400 index 46d46ba..6e49848 100644
38401 --- a/drivers/gpu/drm/i915/i915_irq.c
38402 +++ b/drivers/gpu/drm/i915/i915_irq.c
38403 @@ -975,7 +975,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38404 int pipe;
38405 u32 pipe_stats[I915_MAX_PIPES];
38406
38407 - atomic_inc(&dev_priv->irq_received);
38408 + atomic_inc_unchecked(&dev_priv->irq_received);
38409
38410 while (true) {
38411 iir = I915_READ(VLV_IIR);
38412 @@ -1192,7 +1192,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
38413 irqreturn_t ret = IRQ_NONE;
38414 int i;
38415
38416 - atomic_inc(&dev_priv->irq_received);
38417 + atomic_inc_unchecked(&dev_priv->irq_received);
38418
38419 /* We get interrupts on unclaimed registers, so check for this before we
38420 * do any I915_{READ,WRITE}. */
38421 @@ -1312,7 +1312,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38422 int ret = IRQ_NONE;
38423 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
38424
38425 - atomic_inc(&dev_priv->irq_received);
38426 + atomic_inc_unchecked(&dev_priv->irq_received);
38427
38428 /* disable master interrupt before clearing iir */
38429 de_ier = I915_READ(DEIER);
38430 @@ -2617,7 +2617,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38431 {
38432 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38433
38434 - atomic_set(&dev_priv->irq_received, 0);
38435 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38436
38437 I915_WRITE(HWSTAM, 0xeffe);
38438
38439 @@ -2639,7 +2639,7 @@ static void ivybridge_irq_preinstall(struct drm_device *dev)
38440 {
38441 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38442
38443 - atomic_set(&dev_priv->irq_received, 0);
38444 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38445
38446 I915_WRITE(HWSTAM, 0xeffe);
38447
38448 @@ -2667,7 +2667,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38449 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38450 int pipe;
38451
38452 - atomic_set(&dev_priv->irq_received, 0);
38453 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38454
38455 /* VLV magic */
38456 I915_WRITE(VLV_IMR, 0);
38457 @@ -2979,7 +2979,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38458 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38459 int pipe;
38460
38461 - atomic_set(&dev_priv->irq_received, 0);
38462 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38463
38464 for_each_pipe(pipe)
38465 I915_WRITE(PIPESTAT(pipe), 0);
38466 @@ -3058,7 +3058,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38467 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38468 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38469
38470 - atomic_inc(&dev_priv->irq_received);
38471 + atomic_inc_unchecked(&dev_priv->irq_received);
38472
38473 iir = I915_READ16(IIR);
38474 if (iir == 0)
38475 @@ -3133,7 +3133,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38476 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38477 int pipe;
38478
38479 - atomic_set(&dev_priv->irq_received, 0);
38480 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38481
38482 if (I915_HAS_HOTPLUG(dev)) {
38483 I915_WRITE(PORT_HOTPLUG_EN, 0);
38484 @@ -3232,7 +3232,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38485 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38486 int pipe, ret = IRQ_NONE;
38487
38488 - atomic_inc(&dev_priv->irq_received);
38489 + atomic_inc_unchecked(&dev_priv->irq_received);
38490
38491 iir = I915_READ(IIR);
38492 do {
38493 @@ -3356,7 +3356,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38494 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38495 int pipe;
38496
38497 - atomic_set(&dev_priv->irq_received, 0);
38498 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38499
38500 I915_WRITE(PORT_HOTPLUG_EN, 0);
38501 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38502 @@ -3465,7 +3465,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38503 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38504 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38505
38506 - atomic_inc(&dev_priv->irq_received);
38507 + atomic_inc_unchecked(&dev_priv->irq_received);
38508
38509 iir = I915_READ(IIR);
38510
38511 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38512 index ad2a258..684e615 100644
38513 --- a/drivers/gpu/drm/i915/intel_display.c
38514 +++ b/drivers/gpu/drm/i915/intel_display.c
38515 @@ -9461,13 +9461,13 @@ struct intel_quirk {
38516 int subsystem_vendor;
38517 int subsystem_device;
38518 void (*hook)(struct drm_device *dev);
38519 -};
38520 +} __do_const;
38521
38522 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38523 struct intel_dmi_quirk {
38524 void (*hook)(struct drm_device *dev);
38525 const struct dmi_system_id (*dmi_id_list)[];
38526 -};
38527 +} __do_const;
38528
38529 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38530 {
38531 @@ -9475,18 +9475,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38532 return 1;
38533 }
38534
38535 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38536 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38537 {
38538 - .dmi_id_list = &(const struct dmi_system_id[]) {
38539 - {
38540 - .callback = intel_dmi_reverse_brightness,
38541 - .ident = "NCR Corporation",
38542 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38543 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38544 - },
38545 - },
38546 - { } /* terminating entry */
38547 + .callback = intel_dmi_reverse_brightness,
38548 + .ident = "NCR Corporation",
38549 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38550 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38551 },
38552 + },
38553 + { } /* terminating entry */
38554 +};
38555 +
38556 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38557 + {
38558 + .dmi_id_list = &intel_dmi_quirks_table,
38559 .hook = quirk_invert_brightness,
38560 },
38561 };
38562 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38563 index 54558a0..2d97005 100644
38564 --- a/drivers/gpu/drm/mga/mga_drv.h
38565 +++ b/drivers/gpu/drm/mga/mga_drv.h
38566 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38567 u32 clear_cmd;
38568 u32 maccess;
38569
38570 - atomic_t vbl_received; /**< Number of vblanks received. */
38571 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38572 wait_queue_head_t fence_queue;
38573 - atomic_t last_fence_retired;
38574 + atomic_unchecked_t last_fence_retired;
38575 u32 next_fence_to_post;
38576
38577 unsigned int fb_cpp;
38578 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38579 index 709e90d..89a1c0d 100644
38580 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38581 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38582 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38583 return 0;
38584 }
38585
38586 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38587 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38588 [DRM_MGA_INIT] = compat_mga_init,
38589 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38590 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38591 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38592 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38593 {
38594 unsigned int nr = DRM_IOCTL_NR(cmd);
38595 - drm_ioctl_compat_t *fn = NULL;
38596 int ret;
38597
38598 if (nr < DRM_COMMAND_BASE)
38599 return drm_compat_ioctl(filp, cmd, arg);
38600
38601 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38602 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38603 -
38604 - if (fn != NULL)
38605 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38606 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38607 ret = (*fn) (filp, cmd, arg);
38608 - else
38609 + } else
38610 ret = drm_ioctl(filp, cmd, arg);
38611
38612 return ret;
38613 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38614 index 598c281..60d590e 100644
38615 --- a/drivers/gpu/drm/mga/mga_irq.c
38616 +++ b/drivers/gpu/drm/mga/mga_irq.c
38617 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38618 if (crtc != 0)
38619 return 0;
38620
38621 - return atomic_read(&dev_priv->vbl_received);
38622 + return atomic_read_unchecked(&dev_priv->vbl_received);
38623 }
38624
38625
38626 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38627 /* VBLANK interrupt */
38628 if (status & MGA_VLINEPEN) {
38629 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38630 - atomic_inc(&dev_priv->vbl_received);
38631 + atomic_inc_unchecked(&dev_priv->vbl_received);
38632 drm_handle_vblank(dev, 0);
38633 handled = 1;
38634 }
38635 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38636 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38637 MGA_WRITE(MGA_PRIMEND, prim_end);
38638
38639 - atomic_inc(&dev_priv->last_fence_retired);
38640 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38641 DRM_WAKEUP(&dev_priv->fence_queue);
38642 handled = 1;
38643 }
38644 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38645 * using fences.
38646 */
38647 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38648 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38649 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38650 - *sequence) <= (1 << 23)));
38651
38652 *sequence = cur_fence;
38653 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38654 index 3e72876..d1c15ad 100644
38655 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38656 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38657 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38658 struct bit_table {
38659 const char id;
38660 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38661 -};
38662 +} __no_const;
38663
38664 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38665
38666 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38667 index 41ff7e0..fa854ef 100644
38668 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38669 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38670 @@ -92,7 +92,6 @@ struct nouveau_drm {
38671 struct drm_global_reference mem_global_ref;
38672 struct ttm_bo_global_ref bo_global_ref;
38673 struct ttm_bo_device bdev;
38674 - atomic_t validate_sequence;
38675 int (*move)(struct nouveau_channel *,
38676 struct ttm_buffer_object *,
38677 struct ttm_mem_reg *, struct ttm_mem_reg *);
38678 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38679 index 08214bc..9208577 100644
38680 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38681 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38682 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38683 unsigned long arg)
38684 {
38685 unsigned int nr = DRM_IOCTL_NR(cmd);
38686 - drm_ioctl_compat_t *fn = NULL;
38687 + drm_ioctl_compat_t fn = NULL;
38688 int ret;
38689
38690 if (nr < DRM_COMMAND_BASE)
38691 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38692 index 25d3495..d81aaf6 100644
38693 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38694 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38695 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38696 bool can_switch;
38697
38698 spin_lock(&dev->count_lock);
38699 - can_switch = (dev->open_count == 0);
38700 + can_switch = (local_read(&dev->open_count) == 0);
38701 spin_unlock(&dev->count_lock);
38702 return can_switch;
38703 }
38704 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38705 index 1dfd84c..104896c 100644
38706 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38707 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38708 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38709 }
38710 }
38711
38712 -static struct vm_operations_struct qxl_ttm_vm_ops;
38713 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38714 static const struct vm_operations_struct *ttm_vm_ops;
38715
38716 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38717 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38718 return r;
38719 if (unlikely(ttm_vm_ops == NULL)) {
38720 ttm_vm_ops = vma->vm_ops;
38721 + pax_open_kernel();
38722 qxl_ttm_vm_ops = *ttm_vm_ops;
38723 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38724 + pax_close_kernel();
38725 }
38726 vma->vm_ops = &qxl_ttm_vm_ops;
38727 return 0;
38728 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38729 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38730 {
38731 #if defined(CONFIG_DEBUG_FS)
38732 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38733 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38734 - unsigned i;
38735 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38736 + {
38737 + .name = "qxl_mem_mm",
38738 + .show = &qxl_mm_dump_table,
38739 + },
38740 + {
38741 + .name = "qxl_surf_mm",
38742 + .show = &qxl_mm_dump_table,
38743 + }
38744 + };
38745
38746 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38747 - if (i == 0)
38748 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38749 - else
38750 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38751 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38752 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38753 - qxl_mem_types_list[i].driver_features = 0;
38754 - if (i == 0)
38755 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38756 - else
38757 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38758 + pax_open_kernel();
38759 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38760 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38761 + pax_close_kernel();
38762
38763 - }
38764 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38765 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38766 #else
38767 return 0;
38768 #endif
38769 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38770 index d4660cf..70dbe65 100644
38771 --- a/drivers/gpu/drm/r128/r128_cce.c
38772 +++ b/drivers/gpu/drm/r128/r128_cce.c
38773 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38774
38775 /* GH: Simple idle check.
38776 */
38777 - atomic_set(&dev_priv->idle_count, 0);
38778 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38779
38780 /* We don't support anything other than bus-mastering ring mode,
38781 * but the ring can be in either AGP or PCI space for the ring
38782 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38783 index 930c71b..499aded 100644
38784 --- a/drivers/gpu/drm/r128/r128_drv.h
38785 +++ b/drivers/gpu/drm/r128/r128_drv.h
38786 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38787 int is_pci;
38788 unsigned long cce_buffers_offset;
38789
38790 - atomic_t idle_count;
38791 + atomic_unchecked_t idle_count;
38792
38793 int page_flipping;
38794 int current_page;
38795 u32 crtc_offset;
38796 u32 crtc_offset_cntl;
38797
38798 - atomic_t vbl_received;
38799 + atomic_unchecked_t vbl_received;
38800
38801 u32 color_fmt;
38802 unsigned int front_offset;
38803 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38804 index a954c54..9cc595c 100644
38805 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38806 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38807 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38808 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38809 }
38810
38811 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38812 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38813 [DRM_R128_INIT] = compat_r128_init,
38814 [DRM_R128_DEPTH] = compat_r128_depth,
38815 [DRM_R128_STIPPLE] = compat_r128_stipple,
38816 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
38817 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38818 {
38819 unsigned int nr = DRM_IOCTL_NR(cmd);
38820 - drm_ioctl_compat_t *fn = NULL;
38821 int ret;
38822
38823 if (nr < DRM_COMMAND_BASE)
38824 return drm_compat_ioctl(filp, cmd, arg);
38825
38826 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
38827 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38828 -
38829 - if (fn != NULL)
38830 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
38831 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38832 ret = (*fn) (filp, cmd, arg);
38833 - else
38834 + } else
38835 ret = drm_ioctl(filp, cmd, arg);
38836
38837 return ret;
38838 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
38839 index 2ea4f09..d391371 100644
38840 --- a/drivers/gpu/drm/r128/r128_irq.c
38841 +++ b/drivers/gpu/drm/r128/r128_irq.c
38842 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
38843 if (crtc != 0)
38844 return 0;
38845
38846 - return atomic_read(&dev_priv->vbl_received);
38847 + return atomic_read_unchecked(&dev_priv->vbl_received);
38848 }
38849
38850 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38851 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38852 /* VBLANK interrupt */
38853 if (status & R128_CRTC_VBLANK_INT) {
38854 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
38855 - atomic_inc(&dev_priv->vbl_received);
38856 + atomic_inc_unchecked(&dev_priv->vbl_received);
38857 drm_handle_vblank(dev, 0);
38858 return IRQ_HANDLED;
38859 }
38860 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
38861 index 19bb7e6..de7e2a2 100644
38862 --- a/drivers/gpu/drm/r128/r128_state.c
38863 +++ b/drivers/gpu/drm/r128/r128_state.c
38864 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38865
38866 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38867 {
38868 - if (atomic_read(&dev_priv->idle_count) == 0)
38869 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38870 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38871 else
38872 - atomic_set(&dev_priv->idle_count, 0);
38873 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38874 }
38875
38876 #endif
38877 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38878 index af85299..ed9ac8d 100644
38879 --- a/drivers/gpu/drm/radeon/mkregtable.c
38880 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38881 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
38882 regex_t mask_rex;
38883 regmatch_t match[4];
38884 char buf[1024];
38885 - size_t end;
38886 + long end;
38887 int len;
38888 int done = 0;
38889 int r;
38890 unsigned o;
38891 struct offset *offset;
38892 char last_reg_s[10];
38893 - int last_reg;
38894 + unsigned long last_reg;
38895
38896 if (regcomp
38897 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38898 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38899 index d15f27e..ef11ffc 100644
38900 --- a/drivers/gpu/drm/radeon/radeon_device.c
38901 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38902 @@ -1105,7 +1105,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38903 bool can_switch;
38904
38905 spin_lock(&dev->count_lock);
38906 - can_switch = (dev->open_count == 0);
38907 + can_switch = (local_read(&dev->open_count) == 0);
38908 spin_unlock(&dev->count_lock);
38909 return can_switch;
38910 }
38911 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
38912 index b369d42..8dd04eb 100644
38913 --- a/drivers/gpu/drm/radeon/radeon_drv.h
38914 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
38915 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
38916
38917 /* SW interrupt */
38918 wait_queue_head_t swi_queue;
38919 - atomic_t swi_emitted;
38920 + atomic_unchecked_t swi_emitted;
38921 int vblank_crtc;
38922 uint32_t irq_enable_reg;
38923 uint32_t r500_disp_irq_reg;
38924 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
38925 index c180df8..5fd8186 100644
38926 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
38927 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
38928 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38929 request = compat_alloc_user_space(sizeof(*request));
38930 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
38931 || __put_user(req32.param, &request->param)
38932 - || __put_user((void __user *)(unsigned long)req32.value,
38933 + || __put_user((unsigned long)req32.value,
38934 &request->value))
38935 return -EFAULT;
38936
38937 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38938 #define compat_radeon_cp_setparam NULL
38939 #endif /* X86_64 || IA64 */
38940
38941 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38942 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
38943 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
38944 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
38945 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
38946 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38947 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38948 {
38949 unsigned int nr = DRM_IOCTL_NR(cmd);
38950 - drm_ioctl_compat_t *fn = NULL;
38951 int ret;
38952
38953 if (nr < DRM_COMMAND_BASE)
38954 return drm_compat_ioctl(filp, cmd, arg);
38955
38956 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
38957 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38958 -
38959 - if (fn != NULL)
38960 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
38961 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38962 ret = (*fn) (filp, cmd, arg);
38963 - else
38964 + } else
38965 ret = drm_ioctl(filp, cmd, arg);
38966
38967 return ret;
38968 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
38969 index 8d68e97..9dcfed8 100644
38970 --- a/drivers/gpu/drm/radeon/radeon_irq.c
38971 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
38972 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
38973 unsigned int ret;
38974 RING_LOCALS;
38975
38976 - atomic_inc(&dev_priv->swi_emitted);
38977 - ret = atomic_read(&dev_priv->swi_emitted);
38978 + atomic_inc_unchecked(&dev_priv->swi_emitted);
38979 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
38980
38981 BEGIN_RING(4);
38982 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
38983 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
38984 drm_radeon_private_t *dev_priv =
38985 (drm_radeon_private_t *) dev->dev_private;
38986
38987 - atomic_set(&dev_priv->swi_emitted, 0);
38988 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
38989 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
38990
38991 dev->max_vblank_count = 0x001fffff;
38992 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
38993 index 4d20910..6726b6d 100644
38994 --- a/drivers/gpu/drm/radeon/radeon_state.c
38995 +++ b/drivers/gpu/drm/radeon/radeon_state.c
38996 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
38997 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
38998 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
38999
39000 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39001 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39002 sarea_priv->nbox * sizeof(depth_boxes[0])))
39003 return -EFAULT;
39004
39005 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39006 {
39007 drm_radeon_private_t *dev_priv = dev->dev_private;
39008 drm_radeon_getparam_t *param = data;
39009 - int value;
39010 + int value = 0;
39011
39012 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39013
39014 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39015 index 6c0ce89..57a2529 100644
39016 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39017 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39018 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39019 man->size = size >> PAGE_SHIFT;
39020 }
39021
39022 -static struct vm_operations_struct radeon_ttm_vm_ops;
39023 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39024 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39025
39026 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39027 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39028 }
39029 if (unlikely(ttm_vm_ops == NULL)) {
39030 ttm_vm_ops = vma->vm_ops;
39031 + pax_open_kernel();
39032 radeon_ttm_vm_ops = *ttm_vm_ops;
39033 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39034 + pax_close_kernel();
39035 }
39036 vma->vm_ops = &radeon_ttm_vm_ops;
39037 return 0;
39038 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39039 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39040 {
39041 #if defined(CONFIG_DEBUG_FS)
39042 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39043 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39044 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39045 + {
39046 + .name = "radeon_vram_mm",
39047 + .show = &radeon_mm_dump_table,
39048 + },
39049 + {
39050 + .name = "radeon_gtt_mm",
39051 + .show = &radeon_mm_dump_table,
39052 + },
39053 + {
39054 + .name = "ttm_page_pool",
39055 + .show = &ttm_page_alloc_debugfs,
39056 + },
39057 + {
39058 + .name = "ttm_dma_page_pool",
39059 + .show = &ttm_dma_page_alloc_debugfs,
39060 + },
39061 + };
39062 unsigned i;
39063
39064 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39065 - if (i == 0)
39066 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39067 - else
39068 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39069 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39070 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39071 - radeon_mem_types_list[i].driver_features = 0;
39072 - if (i == 0)
39073 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39074 - else
39075 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39076 -
39077 - }
39078 - /* Add ttm page pool to debugfs */
39079 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39080 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39081 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39082 - radeon_mem_types_list[i].driver_features = 0;
39083 - radeon_mem_types_list[i++].data = NULL;
39084 + pax_open_kernel();
39085 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39086 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39087 + pax_close_kernel();
39088 #ifdef CONFIG_SWIOTLB
39089 - if (swiotlb_nr_tbl()) {
39090 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39091 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39092 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39093 - radeon_mem_types_list[i].driver_features = 0;
39094 - radeon_mem_types_list[i++].data = NULL;
39095 - }
39096 + if (swiotlb_nr_tbl())
39097 + i++;
39098 #endif
39099 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39100
39101 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39102 index d8ddfb3..609de1d 100644
39103 --- a/drivers/gpu/drm/radeon/rs690.c
39104 +++ b/drivers/gpu/drm/radeon/rs690.c
39105 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39106 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39107 rdev->pm.sideport_bandwidth.full)
39108 max_bandwidth = rdev->pm.sideport_bandwidth;
39109 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39110 + read_delay_latency.full = dfixed_const(800 * 1000);
39111 read_delay_latency.full = dfixed_div(read_delay_latency,
39112 rdev->pm.igp_sideport_mclk);
39113 + a.full = dfixed_const(370);
39114 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39115 } else {
39116 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39117 rdev->pm.k8_bandwidth.full)
39118 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39119 index dbc2def..0a9f710 100644
39120 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39121 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39122 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39123 zone->glob = glob;
39124 glob->zone_kernel = zone;
39125 ret = kobject_init_and_add(
39126 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39127 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39128 if (unlikely(ret != 0)) {
39129 kobject_put(&zone->kobj);
39130 return ret;
39131 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39132 zone->glob = glob;
39133 glob->zone_dma32 = zone;
39134 ret = kobject_init_and_add(
39135 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39136 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39137 if (unlikely(ret != 0)) {
39138 kobject_put(&zone->kobj);
39139 return ret;
39140 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39141 index bd2a3b4..122d9ad 100644
39142 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39143 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39144 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
39145 static int ttm_pool_mm_shrink(struct shrinker *shrink,
39146 struct shrink_control *sc)
39147 {
39148 - static atomic_t start_pool = ATOMIC_INIT(0);
39149 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39150 unsigned i;
39151 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39152 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39153 struct ttm_page_pool *pool;
39154 int shrink_pages = sc->nr_to_scan;
39155
39156 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39157 index 97e9d61..bf23c461 100644
39158 --- a/drivers/gpu/drm/udl/udl_fb.c
39159 +++ b/drivers/gpu/drm/udl/udl_fb.c
39160 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39161 fb_deferred_io_cleanup(info);
39162 kfree(info->fbdefio);
39163 info->fbdefio = NULL;
39164 - info->fbops->fb_mmap = udl_fb_mmap;
39165 }
39166
39167 pr_warn("released /dev/fb%d user=%d count=%d\n",
39168 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39169 index 893a650..6190d3b 100644
39170 --- a/drivers/gpu/drm/via/via_drv.h
39171 +++ b/drivers/gpu/drm/via/via_drv.h
39172 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39173 typedef uint32_t maskarray_t[5];
39174
39175 typedef struct drm_via_irq {
39176 - atomic_t irq_received;
39177 + atomic_unchecked_t irq_received;
39178 uint32_t pending_mask;
39179 uint32_t enable_mask;
39180 wait_queue_head_t irq_queue;
39181 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39182 struct timeval last_vblank;
39183 int last_vblank_valid;
39184 unsigned usec_per_vblank;
39185 - atomic_t vbl_received;
39186 + atomic_unchecked_t vbl_received;
39187 drm_via_state_t hc_state;
39188 char pci_buf[VIA_PCI_BUF_SIZE];
39189 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39190 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39191 index ac98964..5dbf512 100644
39192 --- a/drivers/gpu/drm/via/via_irq.c
39193 +++ b/drivers/gpu/drm/via/via_irq.c
39194 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39195 if (crtc != 0)
39196 return 0;
39197
39198 - return atomic_read(&dev_priv->vbl_received);
39199 + return atomic_read_unchecked(&dev_priv->vbl_received);
39200 }
39201
39202 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39203 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39204
39205 status = VIA_READ(VIA_REG_INTERRUPT);
39206 if (status & VIA_IRQ_VBLANK_PENDING) {
39207 - atomic_inc(&dev_priv->vbl_received);
39208 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39209 + atomic_inc_unchecked(&dev_priv->vbl_received);
39210 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39211 do_gettimeofday(&cur_vblank);
39212 if (dev_priv->last_vblank_valid) {
39213 dev_priv->usec_per_vblank =
39214 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39215 dev_priv->last_vblank = cur_vblank;
39216 dev_priv->last_vblank_valid = 1;
39217 }
39218 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39219 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39220 DRM_DEBUG("US per vblank is: %u\n",
39221 dev_priv->usec_per_vblank);
39222 }
39223 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39224
39225 for (i = 0; i < dev_priv->num_irqs; ++i) {
39226 if (status & cur_irq->pending_mask) {
39227 - atomic_inc(&cur_irq->irq_received);
39228 + atomic_inc_unchecked(&cur_irq->irq_received);
39229 DRM_WAKEUP(&cur_irq->irq_queue);
39230 handled = 1;
39231 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39232 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39233 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39234 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39235 masks[irq][4]));
39236 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39237 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39238 } else {
39239 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39240 (((cur_irq_sequence =
39241 - atomic_read(&cur_irq->irq_received)) -
39242 + atomic_read_unchecked(&cur_irq->irq_received)) -
39243 *sequence) <= (1 << 23)));
39244 }
39245 *sequence = cur_irq_sequence;
39246 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39247 }
39248
39249 for (i = 0; i < dev_priv->num_irqs; ++i) {
39250 - atomic_set(&cur_irq->irq_received, 0);
39251 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39252 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39253 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39254 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39255 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39256 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39257 case VIA_IRQ_RELATIVE:
39258 irqwait->request.sequence +=
39259 - atomic_read(&cur_irq->irq_received);
39260 + atomic_read_unchecked(&cur_irq->irq_received);
39261 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39262 case VIA_IRQ_ABSOLUTE:
39263 break;
39264 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39265 index 13aeda7..4a952d1 100644
39266 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39267 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39268 @@ -290,7 +290,7 @@ struct vmw_private {
39269 * Fencing and IRQs.
39270 */
39271
39272 - atomic_t marker_seq;
39273 + atomic_unchecked_t marker_seq;
39274 wait_queue_head_t fence_queue;
39275 wait_queue_head_t fifo_queue;
39276 int fence_queue_waiters; /* Protected by hw_mutex */
39277 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39278 index 3eb1486..0a47ee9 100644
39279 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39280 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39281 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39282 (unsigned int) min,
39283 (unsigned int) fifo->capabilities);
39284
39285 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39286 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39287 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39288 vmw_marker_queue_init(&fifo->marker_queue);
39289 return vmw_fifo_send_fence(dev_priv, &dummy);
39290 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39291 if (reserveable)
39292 iowrite32(bytes, fifo_mem +
39293 SVGA_FIFO_RESERVED);
39294 - return fifo_mem + (next_cmd >> 2);
39295 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39296 } else {
39297 need_bounce = true;
39298 }
39299 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39300
39301 fm = vmw_fifo_reserve(dev_priv, bytes);
39302 if (unlikely(fm == NULL)) {
39303 - *seqno = atomic_read(&dev_priv->marker_seq);
39304 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39305 ret = -ENOMEM;
39306 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39307 false, 3*HZ);
39308 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39309 }
39310
39311 do {
39312 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39313 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39314 } while (*seqno == 0);
39315
39316 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39317 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39318 index c509d40..3b640c3 100644
39319 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39320 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39321 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39322 int ret;
39323
39324 num_clips = arg->num_clips;
39325 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39326 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39327
39328 if (unlikely(num_clips == 0))
39329 return 0;
39330 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39331 int ret;
39332
39333 num_clips = arg->num_clips;
39334 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39335 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39336
39337 if (unlikely(num_clips == 0))
39338 return 0;
39339 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39340 index 4640adb..e1384ed 100644
39341 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39342 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39343 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39344 * emitted. Then the fence is stale and signaled.
39345 */
39346
39347 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39348 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39349 > VMW_FENCE_WRAP);
39350
39351 return ret;
39352 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39353
39354 if (fifo_idle)
39355 down_read(&fifo_state->rwsem);
39356 - signal_seq = atomic_read(&dev_priv->marker_seq);
39357 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39358 ret = 0;
39359
39360 for (;;) {
39361 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39362 index 8a8725c2..afed796 100644
39363 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39364 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39365 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39366 while (!vmw_lag_lt(queue, us)) {
39367 spin_lock(&queue->lock);
39368 if (list_empty(&queue->head))
39369 - seqno = atomic_read(&dev_priv->marker_seq);
39370 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39371 else {
39372 marker = list_first_entry(&queue->head,
39373 struct vmw_marker, head);
39374 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39375 index 5360e5a..c2c0d26 100644
39376 --- a/drivers/gpu/host1x/drm/dc.c
39377 +++ b/drivers/gpu/host1x/drm/dc.c
39378 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39379 }
39380
39381 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39382 - dc->debugfs_files[i].data = dc;
39383 + *(void **)&dc->debugfs_files[i].data = dc;
39384
39385 err = drm_debugfs_create_files(dc->debugfs_files,
39386 ARRAY_SIZE(debugfs_files),
39387 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39388 index 15323da..8431ce9 100644
39389 --- a/drivers/hid/hid-core.c
39390 +++ b/drivers/hid/hid-core.c
39391 @@ -2371,7 +2371,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39392
39393 int hid_add_device(struct hid_device *hdev)
39394 {
39395 - static atomic_t id = ATOMIC_INIT(0);
39396 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39397 int ret;
39398
39399 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39400 @@ -2405,7 +2405,7 @@ int hid_add_device(struct hid_device *hdev)
39401 /* XXX hack, any other cleaner solution after the driver core
39402 * is converted to allow more than 20 bytes as the device name? */
39403 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39404 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39405 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39406
39407 hid_debug_register(hdev, dev_name(&hdev->dev));
39408 ret = device_add(&hdev->dev);
39409 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39410 index c13fb5b..55a3802 100644
39411 --- a/drivers/hid/hid-wiimote-debug.c
39412 +++ b/drivers/hid/hid-wiimote-debug.c
39413 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39414 else if (size == 0)
39415 return -EIO;
39416
39417 - if (copy_to_user(u, buf, size))
39418 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39419 return -EFAULT;
39420
39421 *off += size;
39422 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39423 index 145a4cb..2353a3e 100644
39424 --- a/drivers/hid/uhid.c
39425 +++ b/drivers/hid/uhid.c
39426 @@ -47,7 +47,7 @@ struct uhid_device {
39427 struct mutex report_lock;
39428 wait_queue_head_t report_wait;
39429 atomic_t report_done;
39430 - atomic_t report_id;
39431 + atomic_unchecked_t report_id;
39432 struct uhid_event report_buf;
39433 };
39434
39435 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39436
39437 spin_lock_irqsave(&uhid->qlock, flags);
39438 ev->type = UHID_FEATURE;
39439 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39440 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39441 ev->u.feature.rnum = rnum;
39442 ev->u.feature.rtype = report_type;
39443
39444 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39445 spin_lock_irqsave(&uhid->qlock, flags);
39446
39447 /* id for old report; drop it silently */
39448 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39449 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39450 goto unlock;
39451 if (atomic_read(&uhid->report_done))
39452 goto unlock;
39453 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39454 index 6de6c98..18319e9 100644
39455 --- a/drivers/hv/channel.c
39456 +++ b/drivers/hv/channel.c
39457 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39458 int ret = 0;
39459 int t;
39460
39461 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39462 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39463 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39464 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39465
39466 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39467 if (ret)
39468 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39469 index 88f4096..e50452e 100644
39470 --- a/drivers/hv/hv.c
39471 +++ b/drivers/hv/hv.c
39472 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39473 u64 output_address = (output) ? virt_to_phys(output) : 0;
39474 u32 output_address_hi = output_address >> 32;
39475 u32 output_address_lo = output_address & 0xFFFFFFFF;
39476 - void *hypercall_page = hv_context.hypercall_page;
39477 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39478
39479 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39480 "=a"(hv_status_lo) : "d" (control_hi),
39481 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39482 index deb5c25..ed2d4fd 100644
39483 --- a/drivers/hv/hv_balloon.c
39484 +++ b/drivers/hv/hv_balloon.c
39485 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39486
39487 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39488 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39489 -static atomic_t trans_id = ATOMIC_INIT(0);
39490 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39491
39492 static int dm_ring_size = (5 * PAGE_SIZE);
39493
39494 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
39495 memset(&resp, 0, sizeof(struct dm_hot_add_response));
39496 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
39497 resp.hdr.size = sizeof(struct dm_hot_add_response);
39498 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39499 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39500
39501 #ifdef CONFIG_MEMORY_HOTPLUG
39502 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
39503 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39504 memset(&status, 0, sizeof(struct dm_status));
39505 status.hdr.type = DM_STATUS_REPORT;
39506 status.hdr.size = sizeof(struct dm_status);
39507 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39508 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39509
39510 /*
39511 * The host expects the guest to report free memory.
39512 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39513 * send the status. This can happen if we were interrupted
39514 * after we picked our transaction ID.
39515 */
39516 - if (status.hdr.trans_id != atomic_read(&trans_id))
39517 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39518 return;
39519
39520 vmbus_sendpacket(dm->dev->channel, &status,
39521 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
39522 bl_resp = (struct dm_balloon_response *)send_buffer;
39523 memset(send_buffer, 0, PAGE_SIZE);
39524 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
39525 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39526 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39527 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
39528 bl_resp->more_pages = 1;
39529
39530 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39531
39532 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39533 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39534 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39535 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39536 resp.hdr.size = sizeof(struct dm_unballoon_response);
39537
39538 vmbus_sendpacket(dm_device.dev->channel, &resp,
39539 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39540 memset(&version_req, 0, sizeof(struct dm_version_request));
39541 version_req.hdr.type = DM_VERSION_REQUEST;
39542 version_req.hdr.size = sizeof(struct dm_version_request);
39543 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39544 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39545 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39546 version_req.is_last_attempt = 1;
39547
39548 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39549 memset(&version_req, 0, sizeof(struct dm_version_request));
39550 version_req.hdr.type = DM_VERSION_REQUEST;
39551 version_req.hdr.size = sizeof(struct dm_version_request);
39552 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39553 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39554 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39555 version_req.is_last_attempt = 0;
39556
39557 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39558 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39559 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39560 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39561 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39562 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39563
39564 cap_msg.caps.cap_bits.balloon = 1;
39565 cap_msg.caps.cap_bits.hot_add = 1;
39566 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39567 index d84918f..7f38f9f 100644
39568 --- a/drivers/hv/hyperv_vmbus.h
39569 +++ b/drivers/hv/hyperv_vmbus.h
39570 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39571 struct vmbus_connection {
39572 enum vmbus_connect_state conn_state;
39573
39574 - atomic_t next_gpadl_handle;
39575 + atomic_unchecked_t next_gpadl_handle;
39576
39577 /*
39578 * Represents channel interrupts. Each bit position represents a
39579 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39580 index e8e071fc1..5b4b245 100644
39581 --- a/drivers/hv/vmbus_drv.c
39582 +++ b/drivers/hv/vmbus_drv.c
39583 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39584 {
39585 int ret = 0;
39586
39587 - static atomic_t device_num = ATOMIC_INIT(0);
39588 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39589
39590 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39591 - atomic_inc_return(&device_num));
39592 + atomic_inc_return_unchecked(&device_num));
39593
39594 child_device_obj->device.bus = &hv_bus;
39595 child_device_obj->device.parent = &hv_acpi_dev->dev;
39596 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39597 index 6351aba..dc4aaf4 100644
39598 --- a/drivers/hwmon/acpi_power_meter.c
39599 +++ b/drivers/hwmon/acpi_power_meter.c
39600 @@ -117,7 +117,7 @@ struct sensor_template {
39601 struct device_attribute *devattr,
39602 const char *buf, size_t count);
39603 int index;
39604 -};
39605 +} __do_const;
39606
39607 /* Averaging interval */
39608 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39609 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39610 struct sensor_template *attrs)
39611 {
39612 struct device *dev = &resource->acpi_dev->dev;
39613 - struct sensor_device_attribute *sensors =
39614 + sensor_device_attribute_no_const *sensors =
39615 &resource->sensors[resource->num_sensors];
39616 int res = 0;
39617
39618 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39619 index 3288f13..71cfb4e 100644
39620 --- a/drivers/hwmon/applesmc.c
39621 +++ b/drivers/hwmon/applesmc.c
39622 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39623 {
39624 struct applesmc_node_group *grp;
39625 struct applesmc_dev_attr *node;
39626 - struct attribute *attr;
39627 + attribute_no_const *attr;
39628 int ret, i;
39629
39630 for (grp = groups; grp->format; grp++) {
39631 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39632 index b25c643..a13460d 100644
39633 --- a/drivers/hwmon/asus_atk0110.c
39634 +++ b/drivers/hwmon/asus_atk0110.c
39635 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39636 struct atk_sensor_data {
39637 struct list_head list;
39638 struct atk_data *data;
39639 - struct device_attribute label_attr;
39640 - struct device_attribute input_attr;
39641 - struct device_attribute limit1_attr;
39642 - struct device_attribute limit2_attr;
39643 + device_attribute_no_const label_attr;
39644 + device_attribute_no_const input_attr;
39645 + device_attribute_no_const limit1_attr;
39646 + device_attribute_no_const limit2_attr;
39647 char label_attr_name[ATTR_NAME_SIZE];
39648 char input_attr_name[ATTR_NAME_SIZE];
39649 char limit1_attr_name[ATTR_NAME_SIZE];
39650 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39651 static struct device_attribute atk_name_attr =
39652 __ATTR(name, 0444, atk_name_show, NULL);
39653
39654 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39655 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39656 sysfs_show_func show)
39657 {
39658 sysfs_attr_init(&attr->attr);
39659 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39660 index 2e5e2dc..5208b31 100644
39661 --- a/drivers/hwmon/coretemp.c
39662 +++ b/drivers/hwmon/coretemp.c
39663 @@ -785,7 +785,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39664 return NOTIFY_OK;
39665 }
39666
39667 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39668 +static struct notifier_block coretemp_cpu_notifier = {
39669 .notifier_call = coretemp_cpu_callback,
39670 };
39671
39672 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39673 index 1429f6e..ee03d59 100644
39674 --- a/drivers/hwmon/ibmaem.c
39675 +++ b/drivers/hwmon/ibmaem.c
39676 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39677 struct aem_rw_sensor_template *rw)
39678 {
39679 struct device *dev = &data->pdev->dev;
39680 - struct sensor_device_attribute *sensors = data->sensors;
39681 + sensor_device_attribute_no_const *sensors = data->sensors;
39682 int err;
39683
39684 /* Set up read-only sensors */
39685 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39686 index 708081b..fe2d4ab 100644
39687 --- a/drivers/hwmon/iio_hwmon.c
39688 +++ b/drivers/hwmon/iio_hwmon.c
39689 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39690 {
39691 struct device *dev = &pdev->dev;
39692 struct iio_hwmon_state *st;
39693 - struct sensor_device_attribute *a;
39694 + sensor_device_attribute_no_const *a;
39695 int ret, i;
39696 int in_i = 1, temp_i = 1, curr_i = 1;
39697 enum iio_chan_type type;
39698 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39699 index 9add6092..ee7ba3f 100644
39700 --- a/drivers/hwmon/pmbus/pmbus_core.c
39701 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39702 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39703 return 0;
39704 }
39705
39706 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39707 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39708 const char *name,
39709 umode_t mode,
39710 ssize_t (*show)(struct device *dev,
39711 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39712 dev_attr->store = store;
39713 }
39714
39715 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39716 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39717 const char *name,
39718 umode_t mode,
39719 ssize_t (*show)(struct device *dev,
39720 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39721 u16 reg, u8 mask)
39722 {
39723 struct pmbus_boolean *boolean;
39724 - struct sensor_device_attribute *a;
39725 + sensor_device_attribute_no_const *a;
39726
39727 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39728 if (!boolean)
39729 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39730 bool update, bool readonly)
39731 {
39732 struct pmbus_sensor *sensor;
39733 - struct device_attribute *a;
39734 + device_attribute_no_const *a;
39735
39736 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39737 if (!sensor)
39738 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39739 const char *lstring, int index)
39740 {
39741 struct pmbus_label *label;
39742 - struct device_attribute *a;
39743 + device_attribute_no_const *a;
39744
39745 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39746 if (!label)
39747 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39748 index 2507f90..1645765 100644
39749 --- a/drivers/hwmon/sht15.c
39750 +++ b/drivers/hwmon/sht15.c
39751 @@ -169,7 +169,7 @@ struct sht15_data {
39752 int supply_uv;
39753 bool supply_uv_valid;
39754 struct work_struct update_supply_work;
39755 - atomic_t interrupt_handled;
39756 + atomic_unchecked_t interrupt_handled;
39757 };
39758
39759 /**
39760 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39761 ret = gpio_direction_input(data->pdata->gpio_data);
39762 if (ret)
39763 return ret;
39764 - atomic_set(&data->interrupt_handled, 0);
39765 + atomic_set_unchecked(&data->interrupt_handled, 0);
39766
39767 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39768 if (gpio_get_value(data->pdata->gpio_data) == 0) {
39769 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
39770 /* Only relevant if the interrupt hasn't occurred. */
39771 - if (!atomic_read(&data->interrupt_handled))
39772 + if (!atomic_read_unchecked(&data->interrupt_handled))
39773 schedule_work(&data->read_work);
39774 }
39775 ret = wait_event_timeout(data->wait_queue,
39776 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
39777
39778 /* First disable the interrupt */
39779 disable_irq_nosync(irq);
39780 - atomic_inc(&data->interrupt_handled);
39781 + atomic_inc_unchecked(&data->interrupt_handled);
39782 /* Then schedule a reading work struct */
39783 if (data->state != SHT15_READING_NOTHING)
39784 schedule_work(&data->read_work);
39785 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
39786 * If not, then start the interrupt again - care here as could
39787 * have gone low in meantime so verify it hasn't!
39788 */
39789 - atomic_set(&data->interrupt_handled, 0);
39790 + atomic_set_unchecked(&data->interrupt_handled, 0);
39791 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39792 /* If still not occurred or another handler was scheduled */
39793 if (gpio_get_value(data->pdata->gpio_data)
39794 - || atomic_read(&data->interrupt_handled))
39795 + || atomic_read_unchecked(&data->interrupt_handled))
39796 return;
39797 }
39798
39799 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
39800 index 38944e9..ae9e5ed 100644
39801 --- a/drivers/hwmon/via-cputemp.c
39802 +++ b/drivers/hwmon/via-cputemp.c
39803 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
39804 return NOTIFY_OK;
39805 }
39806
39807 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
39808 +static struct notifier_block via_cputemp_cpu_notifier = {
39809 .notifier_call = via_cputemp_cpu_callback,
39810 };
39811
39812 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
39813 index 07f01ac..d79ad3d 100644
39814 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
39815 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
39816 @@ -43,7 +43,7 @@
39817 extern struct i2c_adapter amd756_smbus;
39818
39819 static struct i2c_adapter *s4882_adapter;
39820 -static struct i2c_algorithm *s4882_algo;
39821 +static i2c_algorithm_no_const *s4882_algo;
39822
39823 /* Wrapper access functions for multiplexed SMBus */
39824 static DEFINE_MUTEX(amd756_lock);
39825 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
39826 index 2ca268d..c6acbdf 100644
39827 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
39828 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
39829 @@ -41,7 +41,7 @@
39830 extern struct i2c_adapter *nforce2_smbus;
39831
39832 static struct i2c_adapter *s4985_adapter;
39833 -static struct i2c_algorithm *s4985_algo;
39834 +static i2c_algorithm_no_const *s4985_algo;
39835
39836 /* Wrapper access functions for multiplexed SMBus */
39837 static DEFINE_MUTEX(nforce2_lock);
39838 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
39839 index c3ccdea..5b3dc1a 100644
39840 --- a/drivers/i2c/i2c-dev.c
39841 +++ b/drivers/i2c/i2c-dev.c
39842 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
39843 break;
39844 }
39845
39846 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
39847 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
39848 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
39849 if (IS_ERR(rdwr_pa[i].buf)) {
39850 res = PTR_ERR(rdwr_pa[i].buf);
39851 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
39852 index 0b510ba..4fbb5085 100644
39853 --- a/drivers/ide/ide-cd.c
39854 +++ b/drivers/ide/ide-cd.c
39855 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
39856 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
39857 if ((unsigned long)buf & alignment
39858 || blk_rq_bytes(rq) & q->dma_pad_mask
39859 - || object_is_on_stack(buf))
39860 + || object_starts_on_stack(buf))
39861 drive->dma = 0;
39862 }
39863 }
39864 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
39865 index e145931..08bfc59 100644
39866 --- a/drivers/iio/industrialio-core.c
39867 +++ b/drivers/iio/industrialio-core.c
39868 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
39869 }
39870
39871 static
39872 -int __iio_device_attr_init(struct device_attribute *dev_attr,
39873 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
39874 const char *postfix,
39875 struct iio_chan_spec const *chan,
39876 ssize_t (*readfunc)(struct device *dev,
39877 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
39878 index 784b97c..c9ceadf 100644
39879 --- a/drivers/infiniband/core/cm.c
39880 +++ b/drivers/infiniband/core/cm.c
39881 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
39882
39883 struct cm_counter_group {
39884 struct kobject obj;
39885 - atomic_long_t counter[CM_ATTR_COUNT];
39886 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
39887 };
39888
39889 struct cm_counter_attribute {
39890 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
39891 struct ib_mad_send_buf *msg = NULL;
39892 int ret;
39893
39894 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39895 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39896 counter[CM_REQ_COUNTER]);
39897
39898 /* Quick state check to discard duplicate REQs. */
39899 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
39900 if (!cm_id_priv)
39901 return;
39902
39903 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39904 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39905 counter[CM_REP_COUNTER]);
39906 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
39907 if (ret)
39908 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
39909 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
39910 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
39911 spin_unlock_irq(&cm_id_priv->lock);
39912 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39913 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39914 counter[CM_RTU_COUNTER]);
39915 goto out;
39916 }
39917 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
39918 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
39919 dreq_msg->local_comm_id);
39920 if (!cm_id_priv) {
39921 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39922 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39923 counter[CM_DREQ_COUNTER]);
39924 cm_issue_drep(work->port, work->mad_recv_wc);
39925 return -EINVAL;
39926 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
39927 case IB_CM_MRA_REP_RCVD:
39928 break;
39929 case IB_CM_TIMEWAIT:
39930 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39931 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39932 counter[CM_DREQ_COUNTER]);
39933 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39934 goto unlock;
39935 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
39936 cm_free_msg(msg);
39937 goto deref;
39938 case IB_CM_DREQ_RCVD:
39939 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39940 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39941 counter[CM_DREQ_COUNTER]);
39942 goto unlock;
39943 default:
39944 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
39945 ib_modify_mad(cm_id_priv->av.port->mad_agent,
39946 cm_id_priv->msg, timeout)) {
39947 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
39948 - atomic_long_inc(&work->port->
39949 + atomic_long_inc_unchecked(&work->port->
39950 counter_group[CM_RECV_DUPLICATES].
39951 counter[CM_MRA_COUNTER]);
39952 goto out;
39953 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
39954 break;
39955 case IB_CM_MRA_REQ_RCVD:
39956 case IB_CM_MRA_REP_RCVD:
39957 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39958 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39959 counter[CM_MRA_COUNTER]);
39960 /* fall through */
39961 default:
39962 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
39963 case IB_CM_LAP_IDLE:
39964 break;
39965 case IB_CM_MRA_LAP_SENT:
39966 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39967 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39968 counter[CM_LAP_COUNTER]);
39969 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39970 goto unlock;
39971 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
39972 cm_free_msg(msg);
39973 goto deref;
39974 case IB_CM_LAP_RCVD:
39975 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39976 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39977 counter[CM_LAP_COUNTER]);
39978 goto unlock;
39979 default:
39980 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
39981 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
39982 if (cur_cm_id_priv) {
39983 spin_unlock_irq(&cm.lock);
39984 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39985 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39986 counter[CM_SIDR_REQ_COUNTER]);
39987 goto out; /* Duplicate message. */
39988 }
39989 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
39990 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
39991 msg->retries = 1;
39992
39993 - atomic_long_add(1 + msg->retries,
39994 + atomic_long_add_unchecked(1 + msg->retries,
39995 &port->counter_group[CM_XMIT].counter[attr_index]);
39996 if (msg->retries)
39997 - atomic_long_add(msg->retries,
39998 + atomic_long_add_unchecked(msg->retries,
39999 &port->counter_group[CM_XMIT_RETRIES].
40000 counter[attr_index]);
40001
40002 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40003 }
40004
40005 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40006 - atomic_long_inc(&port->counter_group[CM_RECV].
40007 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40008 counter[attr_id - CM_ATTR_ID_OFFSET]);
40009
40010 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40011 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40012 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40013
40014 return sprintf(buf, "%ld\n",
40015 - atomic_long_read(&group->counter[cm_attr->index]));
40016 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40017 }
40018
40019 static const struct sysfs_ops cm_counter_ops = {
40020 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40021 index 9f5ad7c..588cd84 100644
40022 --- a/drivers/infiniband/core/fmr_pool.c
40023 +++ b/drivers/infiniband/core/fmr_pool.c
40024 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40025
40026 struct task_struct *thread;
40027
40028 - atomic_t req_ser;
40029 - atomic_t flush_ser;
40030 + atomic_unchecked_t req_ser;
40031 + atomic_unchecked_t flush_ser;
40032
40033 wait_queue_head_t force_wait;
40034 };
40035 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40036 struct ib_fmr_pool *pool = pool_ptr;
40037
40038 do {
40039 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40040 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40041 ib_fmr_batch_release(pool);
40042
40043 - atomic_inc(&pool->flush_ser);
40044 + atomic_inc_unchecked(&pool->flush_ser);
40045 wake_up_interruptible(&pool->force_wait);
40046
40047 if (pool->flush_function)
40048 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40049 }
40050
40051 set_current_state(TASK_INTERRUPTIBLE);
40052 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40053 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40054 !kthread_should_stop())
40055 schedule();
40056 __set_current_state(TASK_RUNNING);
40057 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40058 pool->dirty_watermark = params->dirty_watermark;
40059 pool->dirty_len = 0;
40060 spin_lock_init(&pool->pool_lock);
40061 - atomic_set(&pool->req_ser, 0);
40062 - atomic_set(&pool->flush_ser, 0);
40063 + atomic_set_unchecked(&pool->req_ser, 0);
40064 + atomic_set_unchecked(&pool->flush_ser, 0);
40065 init_waitqueue_head(&pool->force_wait);
40066
40067 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40068 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40069 }
40070 spin_unlock_irq(&pool->pool_lock);
40071
40072 - serial = atomic_inc_return(&pool->req_ser);
40073 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40074 wake_up_process(pool->thread);
40075
40076 if (wait_event_interruptible(pool->force_wait,
40077 - atomic_read(&pool->flush_ser) - serial >= 0))
40078 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40079 return -EINTR;
40080
40081 return 0;
40082 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40083 } else {
40084 list_add_tail(&fmr->list, &pool->dirty_list);
40085 if (++pool->dirty_len >= pool->dirty_watermark) {
40086 - atomic_inc(&pool->req_ser);
40087 + atomic_inc_unchecked(&pool->req_ser);
40088 wake_up_process(pool->thread);
40089 }
40090 }
40091 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40092 index 4cb8eb2..146bf60 100644
40093 --- a/drivers/infiniband/hw/cxgb4/mem.c
40094 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40095 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40096 int err;
40097 struct fw_ri_tpte tpt;
40098 u32 stag_idx;
40099 - static atomic_t key;
40100 + static atomic_unchecked_t key;
40101
40102 if (c4iw_fatal_error(rdev))
40103 return -EIO;
40104 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40105 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40106 rdev->stats.stag.max = rdev->stats.stag.cur;
40107 mutex_unlock(&rdev->stats.lock);
40108 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40109 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40110 }
40111 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40112 __func__, stag_state, type, pdid, stag_idx);
40113 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40114 index 79b3dbc..96e5fcc 100644
40115 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40116 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40117 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40118 struct ib_atomic_eth *ateth;
40119 struct ipath_ack_entry *e;
40120 u64 vaddr;
40121 - atomic64_t *maddr;
40122 + atomic64_unchecked_t *maddr;
40123 u64 sdata;
40124 u32 rkey;
40125 u8 next;
40126 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40127 IB_ACCESS_REMOTE_ATOMIC)))
40128 goto nack_acc_unlck;
40129 /* Perform atomic OP and save result. */
40130 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40131 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40132 sdata = be64_to_cpu(ateth->swap_data);
40133 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40134 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40135 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40136 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40137 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40138 be64_to_cpu(ateth->compare_data),
40139 sdata);
40140 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40141 index 1f95bba..9530f87 100644
40142 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40143 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40144 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40145 unsigned long flags;
40146 struct ib_wc wc;
40147 u64 sdata;
40148 - atomic64_t *maddr;
40149 + atomic64_unchecked_t *maddr;
40150 enum ib_wc_status send_status;
40151
40152 /*
40153 @@ -382,11 +382,11 @@ again:
40154 IB_ACCESS_REMOTE_ATOMIC)))
40155 goto acc_err;
40156 /* Perform atomic OP and save result. */
40157 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40158 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40159 sdata = wqe->wr.wr.atomic.compare_add;
40160 *(u64 *) sqp->s_sge.sge.vaddr =
40161 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40162 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40163 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40164 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40165 sdata, wqe->wr.wr.atomic.swap);
40166 goto send_comp;
40167 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40168 index f2a3f48..673ec79 100644
40169 --- a/drivers/infiniband/hw/mlx4/mad.c
40170 +++ b/drivers/infiniband/hw/mlx4/mad.c
40171 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40172
40173 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40174 {
40175 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40176 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40177 cpu_to_be64(0xff00000000000000LL);
40178 }
40179
40180 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40181 index 25b2cdf..099ff97 100644
40182 --- a/drivers/infiniband/hw/mlx4/mcg.c
40183 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40184 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40185 {
40186 char name[20];
40187
40188 - atomic_set(&ctx->tid, 0);
40189 + atomic_set_unchecked(&ctx->tid, 0);
40190 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40191 ctx->mcg_wq = create_singlethread_workqueue(name);
40192 if (!ctx->mcg_wq)
40193 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40194 index f61ec26..ebf72cf 100644
40195 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40196 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40197 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
40198 struct list_head mcg_mgid0_list;
40199 struct workqueue_struct *mcg_wq;
40200 struct mlx4_ib_demux_pv_ctx **tun;
40201 - atomic_t tid;
40202 + atomic_unchecked_t tid;
40203 int flushing; /* flushing the work queue */
40204 };
40205
40206 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40207 index 9d3e5c1..d9afe4a 100644
40208 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40209 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40210 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40211 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40212 }
40213
40214 -int mthca_QUERY_FW(struct mthca_dev *dev)
40215 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40216 {
40217 struct mthca_mailbox *mailbox;
40218 u32 *outbox;
40219 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40220 index ed9a989..e0c5871 100644
40221 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40222 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40223 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40224 return key;
40225 }
40226
40227 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40228 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40229 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40230 {
40231 struct mthca_mailbox *mailbox;
40232 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40233 index 4291410..d2ab1fb 100644
40234 --- a/drivers/infiniband/hw/nes/nes.c
40235 +++ b/drivers/infiniband/hw/nes/nes.c
40236 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40237 LIST_HEAD(nes_adapter_list);
40238 static LIST_HEAD(nes_dev_list);
40239
40240 -atomic_t qps_destroyed;
40241 +atomic_unchecked_t qps_destroyed;
40242
40243 static unsigned int ee_flsh_adapter;
40244 static unsigned int sysfs_nonidx_addr;
40245 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40246 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40247 struct nes_adapter *nesadapter = nesdev->nesadapter;
40248
40249 - atomic_inc(&qps_destroyed);
40250 + atomic_inc_unchecked(&qps_destroyed);
40251
40252 /* Free the control structures */
40253
40254 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40255 index 33cc589..3bd6538 100644
40256 --- a/drivers/infiniband/hw/nes/nes.h
40257 +++ b/drivers/infiniband/hw/nes/nes.h
40258 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40259 extern unsigned int wqm_quanta;
40260 extern struct list_head nes_adapter_list;
40261
40262 -extern atomic_t cm_connects;
40263 -extern atomic_t cm_accepts;
40264 -extern atomic_t cm_disconnects;
40265 -extern atomic_t cm_closes;
40266 -extern atomic_t cm_connecteds;
40267 -extern atomic_t cm_connect_reqs;
40268 -extern atomic_t cm_rejects;
40269 -extern atomic_t mod_qp_timouts;
40270 -extern atomic_t qps_created;
40271 -extern atomic_t qps_destroyed;
40272 -extern atomic_t sw_qps_destroyed;
40273 +extern atomic_unchecked_t cm_connects;
40274 +extern atomic_unchecked_t cm_accepts;
40275 +extern atomic_unchecked_t cm_disconnects;
40276 +extern atomic_unchecked_t cm_closes;
40277 +extern atomic_unchecked_t cm_connecteds;
40278 +extern atomic_unchecked_t cm_connect_reqs;
40279 +extern atomic_unchecked_t cm_rejects;
40280 +extern atomic_unchecked_t mod_qp_timouts;
40281 +extern atomic_unchecked_t qps_created;
40282 +extern atomic_unchecked_t qps_destroyed;
40283 +extern atomic_unchecked_t sw_qps_destroyed;
40284 extern u32 mh_detected;
40285 extern u32 mh_pauses_sent;
40286 extern u32 cm_packets_sent;
40287 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40288 extern u32 cm_packets_received;
40289 extern u32 cm_packets_dropped;
40290 extern u32 cm_packets_retrans;
40291 -extern atomic_t cm_listens_created;
40292 -extern atomic_t cm_listens_destroyed;
40293 +extern atomic_unchecked_t cm_listens_created;
40294 +extern atomic_unchecked_t cm_listens_destroyed;
40295 extern u32 cm_backlog_drops;
40296 -extern atomic_t cm_loopbacks;
40297 -extern atomic_t cm_nodes_created;
40298 -extern atomic_t cm_nodes_destroyed;
40299 -extern atomic_t cm_accel_dropped_pkts;
40300 -extern atomic_t cm_resets_recvd;
40301 -extern atomic_t pau_qps_created;
40302 -extern atomic_t pau_qps_destroyed;
40303 +extern atomic_unchecked_t cm_loopbacks;
40304 +extern atomic_unchecked_t cm_nodes_created;
40305 +extern atomic_unchecked_t cm_nodes_destroyed;
40306 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40307 +extern atomic_unchecked_t cm_resets_recvd;
40308 +extern atomic_unchecked_t pau_qps_created;
40309 +extern atomic_unchecked_t pau_qps_destroyed;
40310
40311 extern u32 int_mod_timer_init;
40312 extern u32 int_mod_cq_depth_256;
40313 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40314 index 24b9f1a..00fd004 100644
40315 --- a/drivers/infiniband/hw/nes/nes_cm.c
40316 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40317 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40318 u32 cm_packets_retrans;
40319 u32 cm_packets_created;
40320 u32 cm_packets_received;
40321 -atomic_t cm_listens_created;
40322 -atomic_t cm_listens_destroyed;
40323 +atomic_unchecked_t cm_listens_created;
40324 +atomic_unchecked_t cm_listens_destroyed;
40325 u32 cm_backlog_drops;
40326 -atomic_t cm_loopbacks;
40327 -atomic_t cm_nodes_created;
40328 -atomic_t cm_nodes_destroyed;
40329 -atomic_t cm_accel_dropped_pkts;
40330 -atomic_t cm_resets_recvd;
40331 +atomic_unchecked_t cm_loopbacks;
40332 +atomic_unchecked_t cm_nodes_created;
40333 +atomic_unchecked_t cm_nodes_destroyed;
40334 +atomic_unchecked_t cm_accel_dropped_pkts;
40335 +atomic_unchecked_t cm_resets_recvd;
40336
40337 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40338 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40339 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40340
40341 static struct nes_cm_core *g_cm_core;
40342
40343 -atomic_t cm_connects;
40344 -atomic_t cm_accepts;
40345 -atomic_t cm_disconnects;
40346 -atomic_t cm_closes;
40347 -atomic_t cm_connecteds;
40348 -atomic_t cm_connect_reqs;
40349 -atomic_t cm_rejects;
40350 +atomic_unchecked_t cm_connects;
40351 +atomic_unchecked_t cm_accepts;
40352 +atomic_unchecked_t cm_disconnects;
40353 +atomic_unchecked_t cm_closes;
40354 +atomic_unchecked_t cm_connecteds;
40355 +atomic_unchecked_t cm_connect_reqs;
40356 +atomic_unchecked_t cm_rejects;
40357
40358 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40359 {
40360 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40361 kfree(listener);
40362 listener = NULL;
40363 ret = 0;
40364 - atomic_inc(&cm_listens_destroyed);
40365 + atomic_inc_unchecked(&cm_listens_destroyed);
40366 } else {
40367 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40368 }
40369 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40370 cm_node->rem_mac);
40371
40372 add_hte_node(cm_core, cm_node);
40373 - atomic_inc(&cm_nodes_created);
40374 + atomic_inc_unchecked(&cm_nodes_created);
40375
40376 return cm_node;
40377 }
40378 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40379 }
40380
40381 atomic_dec(&cm_core->node_cnt);
40382 - atomic_inc(&cm_nodes_destroyed);
40383 + atomic_inc_unchecked(&cm_nodes_destroyed);
40384 nesqp = cm_node->nesqp;
40385 if (nesqp) {
40386 nesqp->cm_node = NULL;
40387 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40388
40389 static void drop_packet(struct sk_buff *skb)
40390 {
40391 - atomic_inc(&cm_accel_dropped_pkts);
40392 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40393 dev_kfree_skb_any(skb);
40394 }
40395
40396 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40397 {
40398
40399 int reset = 0; /* whether to send reset in case of err.. */
40400 - atomic_inc(&cm_resets_recvd);
40401 + atomic_inc_unchecked(&cm_resets_recvd);
40402 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40403 " refcnt=%d\n", cm_node, cm_node->state,
40404 atomic_read(&cm_node->ref_count));
40405 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40406 rem_ref_cm_node(cm_node->cm_core, cm_node);
40407 return NULL;
40408 }
40409 - atomic_inc(&cm_loopbacks);
40410 + atomic_inc_unchecked(&cm_loopbacks);
40411 loopbackremotenode->loopbackpartner = cm_node;
40412 loopbackremotenode->tcp_cntxt.rcv_wscale =
40413 NES_CM_DEFAULT_RCV_WND_SCALE;
40414 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40415 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40416 else {
40417 rem_ref_cm_node(cm_core, cm_node);
40418 - atomic_inc(&cm_accel_dropped_pkts);
40419 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40420 dev_kfree_skb_any(skb);
40421 }
40422 break;
40423 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40424
40425 if ((cm_id) && (cm_id->event_handler)) {
40426 if (issue_disconn) {
40427 - atomic_inc(&cm_disconnects);
40428 + atomic_inc_unchecked(&cm_disconnects);
40429 cm_event.event = IW_CM_EVENT_DISCONNECT;
40430 cm_event.status = disconn_status;
40431 cm_event.local_addr = cm_id->local_addr;
40432 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40433 }
40434
40435 if (issue_close) {
40436 - atomic_inc(&cm_closes);
40437 + atomic_inc_unchecked(&cm_closes);
40438 nes_disconnect(nesqp, 1);
40439
40440 cm_id->provider_data = nesqp;
40441 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40442
40443 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40444 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40445 - atomic_inc(&cm_accepts);
40446 + atomic_inc_unchecked(&cm_accepts);
40447
40448 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40449 netdev_refcnt_read(nesvnic->netdev));
40450 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40451 struct nes_cm_core *cm_core;
40452 u8 *start_buff;
40453
40454 - atomic_inc(&cm_rejects);
40455 + atomic_inc_unchecked(&cm_rejects);
40456 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40457 loopback = cm_node->loopbackpartner;
40458 cm_core = cm_node->cm_core;
40459 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40460 ntohl(cm_id->local_addr.sin_addr.s_addr),
40461 ntohs(cm_id->local_addr.sin_port));
40462
40463 - atomic_inc(&cm_connects);
40464 + atomic_inc_unchecked(&cm_connects);
40465 nesqp->active_conn = 1;
40466
40467 /* cache the cm_id in the qp */
40468 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40469 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40470 return err;
40471 }
40472 - atomic_inc(&cm_listens_created);
40473 + atomic_inc_unchecked(&cm_listens_created);
40474 }
40475
40476 cm_id->add_ref(cm_id);
40477 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40478
40479 if (nesqp->destroyed)
40480 return;
40481 - atomic_inc(&cm_connecteds);
40482 + atomic_inc_unchecked(&cm_connecteds);
40483 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40484 " local port 0x%04X. jiffies = %lu.\n",
40485 nesqp->hwqp.qp_id,
40486 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40487
40488 cm_id->add_ref(cm_id);
40489 ret = cm_id->event_handler(cm_id, &cm_event);
40490 - atomic_inc(&cm_closes);
40491 + atomic_inc_unchecked(&cm_closes);
40492 cm_event.event = IW_CM_EVENT_CLOSE;
40493 cm_event.status = 0;
40494 cm_event.provider_data = cm_id->provider_data;
40495 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40496 return;
40497 cm_id = cm_node->cm_id;
40498
40499 - atomic_inc(&cm_connect_reqs);
40500 + atomic_inc_unchecked(&cm_connect_reqs);
40501 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40502 cm_node, cm_id, jiffies);
40503
40504 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40505 return;
40506 cm_id = cm_node->cm_id;
40507
40508 - atomic_inc(&cm_connect_reqs);
40509 + atomic_inc_unchecked(&cm_connect_reqs);
40510 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40511 cm_node, cm_id, jiffies);
40512
40513 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40514 index 4166452..fc952c3 100644
40515 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40516 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40517 @@ -40,8 +40,8 @@
40518 #include "nes.h"
40519 #include "nes_mgt.h"
40520
40521 -atomic_t pau_qps_created;
40522 -atomic_t pau_qps_destroyed;
40523 +atomic_unchecked_t pau_qps_created;
40524 +atomic_unchecked_t pau_qps_destroyed;
40525
40526 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40527 {
40528 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40529 {
40530 struct sk_buff *skb;
40531 unsigned long flags;
40532 - atomic_inc(&pau_qps_destroyed);
40533 + atomic_inc_unchecked(&pau_qps_destroyed);
40534
40535 /* Free packets that have not yet been forwarded */
40536 /* Lock is acquired by skb_dequeue when removing the skb */
40537 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40538 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40539 skb_queue_head_init(&nesqp->pau_list);
40540 spin_lock_init(&nesqp->pau_lock);
40541 - atomic_inc(&pau_qps_created);
40542 + atomic_inc_unchecked(&pau_qps_created);
40543 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40544 }
40545
40546 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40547 index 49eb511..a774366 100644
40548 --- a/drivers/infiniband/hw/nes/nes_nic.c
40549 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40550 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40551 target_stat_values[++index] = mh_detected;
40552 target_stat_values[++index] = mh_pauses_sent;
40553 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40554 - target_stat_values[++index] = atomic_read(&cm_connects);
40555 - target_stat_values[++index] = atomic_read(&cm_accepts);
40556 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40557 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40558 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40559 - target_stat_values[++index] = atomic_read(&cm_rejects);
40560 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40561 - target_stat_values[++index] = atomic_read(&qps_created);
40562 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40563 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40564 - target_stat_values[++index] = atomic_read(&cm_closes);
40565 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40566 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40567 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40568 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40569 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40570 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40571 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40572 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40573 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40574 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40575 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40576 target_stat_values[++index] = cm_packets_sent;
40577 target_stat_values[++index] = cm_packets_bounced;
40578 target_stat_values[++index] = cm_packets_created;
40579 target_stat_values[++index] = cm_packets_received;
40580 target_stat_values[++index] = cm_packets_dropped;
40581 target_stat_values[++index] = cm_packets_retrans;
40582 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40583 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40584 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40585 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40586 target_stat_values[++index] = cm_backlog_drops;
40587 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40588 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40589 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40590 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40591 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40592 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40593 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40594 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40595 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40596 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40597 target_stat_values[++index] = nesadapter->free_4kpbl;
40598 target_stat_values[++index] = nesadapter->free_256pbl;
40599 target_stat_values[++index] = int_mod_timer_init;
40600 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40601 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40602 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40603 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40604 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40605 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40606 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40607 }
40608
40609 /**
40610 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40611 index 5b53ca5..443da3c 100644
40612 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40613 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40614 @@ -46,9 +46,9 @@
40615
40616 #include <rdma/ib_umem.h>
40617
40618 -atomic_t mod_qp_timouts;
40619 -atomic_t qps_created;
40620 -atomic_t sw_qps_destroyed;
40621 +atomic_unchecked_t mod_qp_timouts;
40622 +atomic_unchecked_t qps_created;
40623 +atomic_unchecked_t sw_qps_destroyed;
40624
40625 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40626
40627 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40628 if (init_attr->create_flags)
40629 return ERR_PTR(-EINVAL);
40630
40631 - atomic_inc(&qps_created);
40632 + atomic_inc_unchecked(&qps_created);
40633 switch (init_attr->qp_type) {
40634 case IB_QPT_RC:
40635 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40636 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40637 struct iw_cm_event cm_event;
40638 int ret = 0;
40639
40640 - atomic_inc(&sw_qps_destroyed);
40641 + atomic_inc_unchecked(&sw_qps_destroyed);
40642 nesqp->destroyed = 1;
40643
40644 /* Blow away the connection if it exists. */
40645 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40646 index 4a9af79..b993f75 100644
40647 --- a/drivers/infiniband/hw/qib/qib.h
40648 +++ b/drivers/infiniband/hw/qib/qib.h
40649 @@ -52,6 +52,7 @@
40650 #include <linux/kref.h>
40651 #include <linux/sched.h>
40652 #include <linux/kthread.h>
40653 +#include <linux/slab.h>
40654
40655 #include "qib_common.h"
40656 #include "qib_verbs.h"
40657 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40658 index da739d9..da1c7f4 100644
40659 --- a/drivers/input/gameport/gameport.c
40660 +++ b/drivers/input/gameport/gameport.c
40661 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40662 */
40663 static void gameport_init_port(struct gameport *gameport)
40664 {
40665 - static atomic_t gameport_no = ATOMIC_INIT(0);
40666 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40667
40668 __module_get(THIS_MODULE);
40669
40670 mutex_init(&gameport->drv_mutex);
40671 device_initialize(&gameport->dev);
40672 dev_set_name(&gameport->dev, "gameport%lu",
40673 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40674 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40675 gameport->dev.bus = &gameport_bus;
40676 gameport->dev.release = gameport_release_port;
40677 if (gameport->parent)
40678 diff --git a/drivers/input/input.c b/drivers/input/input.c
40679 index c044699..174d71a 100644
40680 --- a/drivers/input/input.c
40681 +++ b/drivers/input/input.c
40682 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
40683 */
40684 int input_register_device(struct input_dev *dev)
40685 {
40686 - static atomic_t input_no = ATOMIC_INIT(0);
40687 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
40688 struct input_devres *devres = NULL;
40689 struct input_handler *handler;
40690 unsigned int packet_size;
40691 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
40692 dev->setkeycode = input_default_setkeycode;
40693
40694 dev_set_name(&dev->dev, "input%ld",
40695 - (unsigned long) atomic_inc_return(&input_no) - 1);
40696 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
40697
40698 error = device_add(&dev->dev);
40699 if (error)
40700 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
40701 index 04c69af..5f92d00 100644
40702 --- a/drivers/input/joystick/sidewinder.c
40703 +++ b/drivers/input/joystick/sidewinder.c
40704 @@ -30,6 +30,7 @@
40705 #include <linux/kernel.h>
40706 #include <linux/module.h>
40707 #include <linux/slab.h>
40708 +#include <linux/sched.h>
40709 #include <linux/init.h>
40710 #include <linux/input.h>
40711 #include <linux/gameport.h>
40712 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
40713 index 75e3b10..fb390fd 100644
40714 --- a/drivers/input/joystick/xpad.c
40715 +++ b/drivers/input/joystick/xpad.c
40716 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
40717
40718 static int xpad_led_probe(struct usb_xpad *xpad)
40719 {
40720 - static atomic_t led_seq = ATOMIC_INIT(0);
40721 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
40722 long led_no;
40723 struct xpad_led *led;
40724 struct led_classdev *led_cdev;
40725 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
40726 if (!led)
40727 return -ENOMEM;
40728
40729 - led_no = (long)atomic_inc_return(&led_seq) - 1;
40730 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
40731
40732 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
40733 led->xpad = xpad;
40734 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
40735 index e204f26..8459f15 100644
40736 --- a/drivers/input/misc/ims-pcu.c
40737 +++ b/drivers/input/misc/ims-pcu.c
40738 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
40739
40740 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40741 {
40742 - static atomic_t device_no = ATOMIC_INIT(0);
40743 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
40744
40745 const struct ims_pcu_device_info *info;
40746 u8 device_id;
40747 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40748 }
40749
40750 /* Device appears to be operable, complete initialization */
40751 - pcu->device_no = atomic_inc_return(&device_no) - 1;
40752 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
40753
40754 error = ims_pcu_setup_backlight(pcu);
40755 if (error)
40756 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
40757 index 2f0b39d..7370f13 100644
40758 --- a/drivers/input/mouse/psmouse.h
40759 +++ b/drivers/input/mouse/psmouse.h
40760 @@ -116,7 +116,7 @@ struct psmouse_attribute {
40761 ssize_t (*set)(struct psmouse *psmouse, void *data,
40762 const char *buf, size_t count);
40763 bool protect;
40764 -};
40765 +} __do_const;
40766 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
40767
40768 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
40769 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
40770 index 4c842c3..590b0bf 100644
40771 --- a/drivers/input/mousedev.c
40772 +++ b/drivers/input/mousedev.c
40773 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
40774
40775 spin_unlock_irq(&client->packet_lock);
40776
40777 - if (copy_to_user(buffer, data, count))
40778 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
40779 return -EFAULT;
40780
40781 return count;
40782 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
40783 index 25fc597..558bf3b3 100644
40784 --- a/drivers/input/serio/serio.c
40785 +++ b/drivers/input/serio/serio.c
40786 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
40787 */
40788 static void serio_init_port(struct serio *serio)
40789 {
40790 - static atomic_t serio_no = ATOMIC_INIT(0);
40791 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
40792
40793 __module_get(THIS_MODULE);
40794
40795 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
40796 mutex_init(&serio->drv_mutex);
40797 device_initialize(&serio->dev);
40798 dev_set_name(&serio->dev, "serio%ld",
40799 - (long)atomic_inc_return(&serio_no) - 1);
40800 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
40801 serio->dev.bus = &serio_bus;
40802 serio->dev.release = serio_release_port;
40803 serio->dev.groups = serio_device_attr_groups;
40804 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
40805 index 59df2e7..8f1cafb 100644
40806 --- a/drivers/input/serio/serio_raw.c
40807 +++ b/drivers/input/serio/serio_raw.c
40808 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
40809
40810 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40811 {
40812 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
40813 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
40814 struct serio_raw *serio_raw;
40815 int err;
40816
40817 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40818 }
40819
40820 snprintf(serio_raw->name, sizeof(serio_raw->name),
40821 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
40822 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
40823 kref_init(&serio_raw->kref);
40824 INIT_LIST_HEAD(&serio_raw->client_list);
40825 init_waitqueue_head(&serio_raw->wait);
40826 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
40827 index fbe9ca7..dbee61d 100644
40828 --- a/drivers/iommu/iommu.c
40829 +++ b/drivers/iommu/iommu.c
40830 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
40831 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
40832 {
40833 bus_register_notifier(bus, &iommu_bus_nb);
40834 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
40835 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
40836 }
40837
40838 /**
40839 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
40840 index 39f81ae..2660096 100644
40841 --- a/drivers/iommu/irq_remapping.c
40842 +++ b/drivers/iommu/irq_remapping.c
40843 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
40844 void panic_if_irq_remap(const char *msg)
40845 {
40846 if (irq_remapping_enabled)
40847 - panic(msg);
40848 + panic("%s", msg);
40849 }
40850
40851 static void ir_ack_apic_edge(struct irq_data *data)
40852 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
40853
40854 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
40855 {
40856 - chip->irq_print_chip = ir_print_prefix;
40857 - chip->irq_ack = ir_ack_apic_edge;
40858 - chip->irq_eoi = ir_ack_apic_level;
40859 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
40860 + pax_open_kernel();
40861 + *(void **)&chip->irq_print_chip = ir_print_prefix;
40862 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
40863 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
40864 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
40865 + pax_close_kernel();
40866 }
40867
40868 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
40869 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
40870 index ee7c503..5d4ce08 100644
40871 --- a/drivers/irqchip/irq-gic.c
40872 +++ b/drivers/irqchip/irq-gic.c
40873 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
40874 * Supported arch specific GIC irq extension.
40875 * Default make them NULL.
40876 */
40877 -struct irq_chip gic_arch_extn = {
40878 +irq_chip_no_const gic_arch_extn = {
40879 .irq_eoi = NULL,
40880 .irq_mask = NULL,
40881 .irq_unmask = NULL,
40882 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
40883 chained_irq_exit(chip, desc);
40884 }
40885
40886 -static struct irq_chip gic_chip = {
40887 +static irq_chip_no_const gic_chip __read_only = {
40888 .name = "GIC",
40889 .irq_mask = gic_mask_irq,
40890 .irq_unmask = gic_unmask_irq,
40891 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
40892 index ac6f72b..81150f2 100644
40893 --- a/drivers/isdn/capi/capi.c
40894 +++ b/drivers/isdn/capi/capi.c
40895 @@ -81,8 +81,8 @@ struct capiminor {
40896
40897 struct capi20_appl *ap;
40898 u32 ncci;
40899 - atomic_t datahandle;
40900 - atomic_t msgid;
40901 + atomic_unchecked_t datahandle;
40902 + atomic_unchecked_t msgid;
40903
40904 struct tty_port port;
40905 int ttyinstop;
40906 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
40907 capimsg_setu16(s, 2, mp->ap->applid);
40908 capimsg_setu8 (s, 4, CAPI_DATA_B3);
40909 capimsg_setu8 (s, 5, CAPI_RESP);
40910 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
40911 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
40912 capimsg_setu32(s, 8, mp->ncci);
40913 capimsg_setu16(s, 12, datahandle);
40914 }
40915 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
40916 mp->outbytes -= len;
40917 spin_unlock_bh(&mp->outlock);
40918
40919 - datahandle = atomic_inc_return(&mp->datahandle);
40920 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
40921 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
40922 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
40923 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
40924 capimsg_setu16(skb->data, 2, mp->ap->applid);
40925 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
40926 capimsg_setu8 (skb->data, 5, CAPI_REQ);
40927 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
40928 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
40929 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
40930 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
40931 capimsg_setu16(skb->data, 16, len); /* Data length */
40932 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
40933 index 600c79b..3752bab 100644
40934 --- a/drivers/isdn/gigaset/interface.c
40935 +++ b/drivers/isdn/gigaset/interface.c
40936 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
40937 }
40938 tty->driver_data = cs;
40939
40940 - ++cs->port.count;
40941 + atomic_inc(&cs->port.count);
40942
40943 - if (cs->port.count == 1) {
40944 + if (atomic_read(&cs->port.count) == 1) {
40945 tty_port_tty_set(&cs->port, tty);
40946 cs->port.low_latency = 1;
40947 }
40948 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
40949
40950 if (!cs->connected)
40951 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
40952 - else if (!cs->port.count)
40953 + else if (!atomic_read(&cs->port.count))
40954 dev_warn(cs->dev, "%s: device not opened\n", __func__);
40955 - else if (!--cs->port.count)
40956 + else if (!atomic_dec_return(&cs->port.count))
40957 tty_port_tty_set(&cs->port, NULL);
40958
40959 mutex_unlock(&cs->mutex);
40960 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
40961 index d0a41cb..f0cdb8c 100644
40962 --- a/drivers/isdn/gigaset/usb-gigaset.c
40963 +++ b/drivers/isdn/gigaset/usb-gigaset.c
40964 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
40965 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
40966 memcpy(cs->hw.usb->bchars, buf, 6);
40967 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
40968 - 0, 0, &buf, 6, 2000);
40969 + 0, 0, buf, 6, 2000);
40970 }
40971
40972 static void gigaset_freebcshw(struct bc_state *bcs)
40973 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
40974 index 4d9b195..455075c 100644
40975 --- a/drivers/isdn/hardware/avm/b1.c
40976 +++ b/drivers/isdn/hardware/avm/b1.c
40977 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
40978 }
40979 if (left) {
40980 if (t4file->user) {
40981 - if (copy_from_user(buf, dp, left))
40982 + if (left > sizeof buf || copy_from_user(buf, dp, left))
40983 return -EFAULT;
40984 } else {
40985 memcpy(buf, dp, left);
40986 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
40987 }
40988 if (left) {
40989 if (config->user) {
40990 - if (copy_from_user(buf, dp, left))
40991 + if (left > sizeof buf || copy_from_user(buf, dp, left))
40992 return -EFAULT;
40993 } else {
40994 memcpy(buf, dp, left);
40995 diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
40996 index 1063bab..36817e0 100644
40997 --- a/drivers/isdn/hisax/amd7930_fn.c
40998 +++ b/drivers/isdn/hisax/amd7930_fn.c
40999 @@ -314,7 +314,7 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag)
41000
41001 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx);
41002 QuickHex(t, cs->rcvbuf, cs->rcvidx);
41003 - debugl1(cs, cs->dlog);
41004 + debugl1(cs, "%s", cs->dlog);
41005 }
41006 /* moves received data in sk-buffer */
41007 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
41008 @@ -406,7 +406,7 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs)
41009
41010 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count);
41011 QuickHex(t, deb_ptr, count);
41012 - debugl1(cs, cs->dlog);
41013 + debugl1(cs, "%s", cs->dlog);
41014 }
41015 /* AMD interrupts on */
41016 AmdIrqOn(cs);
41017 diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
41018 index ee9b9a0..d1427bd 100644
41019 --- a/drivers/isdn/hisax/avm_pci.c
41020 +++ b/drivers/isdn/hisax/avm_pci.c
41021 @@ -285,7 +285,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count)
41022 t += sprintf(t, "hdlc_empty_fifo %c cnt %d",
41023 bcs->channel ? 'B' : 'A', count);
41024 QuickHex(t, p, count);
41025 - debugl1(cs, bcs->blog);
41026 + debugl1(cs, "%s", bcs->blog);
41027 }
41028 }
41029
41030 @@ -345,7 +345,7 @@ hdlc_fill_fifo(struct BCState *bcs)
41031 t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
41032 bcs->channel ? 'B' : 'A', count);
41033 QuickHex(t, p, count);
41034 - debugl1(cs, bcs->blog);
41035 + debugl1(cs, "%s", bcs->blog);
41036 }
41037 }
41038
41039 diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
41040 index bf04d2a..b33f53b 100644
41041 --- a/drivers/isdn/hisax/config.c
41042 +++ b/drivers/isdn/hisax/config.c
41043 @@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
41044 ptr--;
41045 *ptr++ = '\n';
41046 *ptr = 0;
41047 - HiSax_putstatus(cs, NULL, cs->dlog);
41048 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41049 } else
41050 HiSax_putstatus(cs, "LogEcho: ",
41051 "warning Frame too big (%d)",
41052 diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
41053 index 8d0cf6e..4fc90de 100644
41054 --- a/drivers/isdn/hisax/diva.c
41055 +++ b/drivers/isdn/hisax/diva.c
41056 @@ -427,7 +427,7 @@ Memhscx_empty_fifo(struct BCState *bcs, int count)
41057 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41058 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41059 QuickHex(t, ptr, count);
41060 - debugl1(cs, bcs->blog);
41061 + debugl1(cs, "%s", bcs->blog);
41062 }
41063 }
41064
41065 @@ -469,7 +469,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
41066 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41067 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41068 QuickHex(t, ptr, count);
41069 - debugl1(cs, bcs->blog);
41070 + debugl1(cs, "%s", bcs->blog);
41071 }
41072 }
41073
41074 diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
41075 index 1df6f9a..2be1c8a 100644
41076 --- a/drivers/isdn/hisax/elsa.c
41077 +++ b/drivers/isdn/hisax/elsa.c
41078 @@ -535,7 +535,7 @@ check_arcofi(struct IsdnCardState *cs)
41079 t = tmp;
41080 t += sprintf(tmp, "Arcofi data");
41081 QuickHex(t, p, cs->dc.isac.mon_rxp);
41082 - debugl1(cs, tmp);
41083 + debugl1(cs, "%s", tmp);
41084 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
41085 switch (cs->dc.isac.mon_rx[1]) {
41086 case 0x80:
41087 diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
41088 index d4c98d3..3f84dd8 100644
41089 --- a/drivers/isdn/hisax/elsa_ser.c
41090 +++ b/drivers/isdn/hisax/elsa_ser.c
41091 @@ -344,7 +344,7 @@ static inline void receive_chars(struct IsdnCardState *cs,
41092
41093 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt);
41094 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt);
41095 - debugl1(cs, tmp);
41096 + debugl1(cs, "%s", tmp);
41097 }
41098 cs->hw.elsa.rcvcnt = 0;
41099 }
41100 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
41101 index 3ccd724..497bd02 100644
41102 --- a/drivers/isdn/hisax/hfc_pci.c
41103 +++ b/drivers/isdn/hisax/hfc_pci.c
41104 @@ -901,7 +901,7 @@ Begin:
41105 ptr--;
41106 *ptr++ = '\n';
41107 *ptr = 0;
41108 - HiSax_putstatus(cs, NULL, cs->dlog);
41109 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41110 } else
41111 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
41112 }
41113 diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
41114 index dc4574f..fa1fefd 100644
41115 --- a/drivers/isdn/hisax/hfc_sx.c
41116 +++ b/drivers/isdn/hisax/hfc_sx.c
41117 @@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs)
41118 ptr--;
41119 *ptr++ = '\n';
41120 *ptr = 0;
41121 - HiSax_putstatus(cs, NULL, cs->dlog);
41122 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41123 } else
41124 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
41125 }
41126 diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
41127 index f398d48..a8d6188 100644
41128 --- a/drivers/isdn/hisax/hscx_irq.c
41129 +++ b/drivers/isdn/hisax/hscx_irq.c
41130 @@ -75,7 +75,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
41131 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41132 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41133 QuickHex(t, ptr, count);
41134 - debugl1(cs, bcs->blog);
41135 + debugl1(cs, "%s", bcs->blog);
41136 }
41137 }
41138
41139 @@ -115,7 +115,7 @@ hscx_fill_fifo(struct BCState *bcs)
41140 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41141 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41142 QuickHex(t, ptr, count);
41143 - debugl1(cs, bcs->blog);
41144 + debugl1(cs, "%s", bcs->blog);
41145 }
41146 }
41147
41148 diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
41149 index db5321f..51dae91 100644
41150 --- a/drivers/isdn/hisax/icc.c
41151 +++ b/drivers/isdn/hisax/icc.c
41152 @@ -134,7 +134,7 @@ icc_empty_fifo(struct IsdnCardState *cs, int count)
41153
41154 t += sprintf(t, "icc_empty_fifo cnt %d", count);
41155 QuickHex(t, ptr, count);
41156 - debugl1(cs, cs->dlog);
41157 + debugl1(cs, "%s", cs->dlog);
41158 }
41159 }
41160
41161 @@ -176,7 +176,7 @@ icc_fill_fifo(struct IsdnCardState *cs)
41162
41163 t += sprintf(t, "icc_fill_fifo cnt %d", count);
41164 QuickHex(t, ptr, count);
41165 - debugl1(cs, cs->dlog);
41166 + debugl1(cs, "%s", cs->dlog);
41167 }
41168 }
41169
41170 diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
41171 index 74feb5c..5faa5de 100644
41172 --- a/drivers/isdn/hisax/ipacx.c
41173 +++ b/drivers/isdn/hisax/ipacx.c
41174 @@ -260,7 +260,7 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
41175
41176 t += sprintf(t, "dch_empty_fifo() cnt %d", count);
41177 QuickHex(t, ptr, count);
41178 - debugl1(cs, cs->dlog);
41179 + debugl1(cs, "%s", cs->dlog);
41180 }
41181 }
41182
41183 @@ -307,7 +307,7 @@ dch_fill_fifo(struct IsdnCardState *cs)
41184
41185 t += sprintf(t, "dch_fill_fifo() cnt %d", count);
41186 QuickHex(t, ptr, count);
41187 - debugl1(cs, cs->dlog);
41188 + debugl1(cs, "%s", cs->dlog);
41189 }
41190 }
41191
41192 @@ -539,7 +539,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
41193
41194 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count);
41195 QuickHex(t, ptr, count);
41196 - debugl1(cs, bcs->blog);
41197 + debugl1(cs, "%s", bcs->blog);
41198 }
41199 }
41200
41201 @@ -582,7 +582,7 @@ bch_fill_fifo(struct BCState *bcs)
41202
41203 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
41204 QuickHex(t, ptr, count);
41205 - debugl1(cs, bcs->blog);
41206 + debugl1(cs, "%s", bcs->blog);
41207 }
41208 }
41209
41210 diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
41211 index a365ccc..7fdf78f 100644
41212 --- a/drivers/isdn/hisax/isac.c
41213 +++ b/drivers/isdn/hisax/isac.c
41214 @@ -137,7 +137,7 @@ isac_empty_fifo(struct IsdnCardState *cs, int count)
41215
41216 t += sprintf(t, "isac_empty_fifo cnt %d", count);
41217 QuickHex(t, ptr, count);
41218 - debugl1(cs, cs->dlog);
41219 + debugl1(cs, "%s", cs->dlog);
41220 }
41221 }
41222
41223 @@ -179,7 +179,7 @@ isac_fill_fifo(struct IsdnCardState *cs)
41224
41225 t += sprintf(t, "isac_fill_fifo cnt %d", count);
41226 QuickHex(t, ptr, count);
41227 - debugl1(cs, cs->dlog);
41228 + debugl1(cs, "%s", cs->dlog);
41229 }
41230 }
41231
41232 diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
41233 index 7fdf347..f4956c7 100644
41234 --- a/drivers/isdn/hisax/isar.c
41235 +++ b/drivers/isdn/hisax/isar.c
41236 @@ -74,7 +74,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
41237 t = tmp;
41238 t += sprintf(t, "sendmbox cnt %d", len);
41239 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
41240 - debugl1(cs, tmp);
41241 + debugl1(cs, "%s", tmp);
41242 i -= 64;
41243 }
41244 }
41245 @@ -105,7 +105,7 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
41246 t = tmp;
41247 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb);
41248 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
41249 - debugl1(cs, tmp);
41250 + debugl1(cs, "%s", tmp);
41251 i -= 64;
41252 }
41253 }
41254 @@ -1248,7 +1248,7 @@ isar_int_main(struct IsdnCardState *cs)
41255 tp += sprintf(debbuf, "msg iis(%x) msb(%x)",
41256 ireg->iis, ireg->cmsb);
41257 QuickHex(tp, (u_char *)ireg->par, ireg->clsb);
41258 - debugl1(cs, debbuf);
41259 + debugl1(cs, "%s", debbuf);
41260 }
41261 break;
41262 case ISAR_IIS_INVMSG:
41263 diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
41264 index f946c58..e2ae787 100644
41265 --- a/drivers/isdn/hisax/jade.c
41266 +++ b/drivers/isdn/hisax/jade.c
41267 @@ -81,10 +81,7 @@ modejade(struct BCState *bcs, int mode, int bc)
41268 int jade = bcs->hw.hscx.hscx;
41269
41270 if (cs->debug & L1_DEB_HSCX) {
41271 - char tmp[40];
41272 - sprintf(tmp, "jade %c mode %d ichan %d",
41273 - 'A' + jade, mode, bc);
41274 - debugl1(cs, tmp);
41275 + debugl1(cs, "jade %c mode %d ichan %d", 'A' + jade, mode, bc);
41276 }
41277 bcs->mode = mode;
41278 bcs->channel = bc;
41279 @@ -257,23 +254,18 @@ void
41280 clear_pending_jade_ints(struct IsdnCardState *cs)
41281 {
41282 int val;
41283 - char tmp[64];
41284
41285 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
41286 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
41287
41288 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
41289 - sprintf(tmp, "jade B ISTA %x", val);
41290 - debugl1(cs, tmp);
41291 + debugl1(cs, "jade B ISTA %x", val);
41292 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
41293 - sprintf(tmp, "jade A ISTA %x", val);
41294 - debugl1(cs, tmp);
41295 + debugl1(cs, "jade A ISTA %x", val);
41296 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
41297 - sprintf(tmp, "jade B STAR %x", val);
41298 - debugl1(cs, tmp);
41299 + debugl1(cs, "jade B STAR %x", val);
41300 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
41301 - sprintf(tmp, "jade A STAR %x", val);
41302 - debugl1(cs, tmp);
41303 + debugl1(cs, "jade A STAR %x", val);
41304 /* Unmask ints */
41305 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
41306 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
41307 diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c
41308 index f521fc8..b930da9 100644
41309 --- a/drivers/isdn/hisax/jade_irq.c
41310 +++ b/drivers/isdn/hisax/jade_irq.c
41311 @@ -65,7 +65,7 @@ jade_empty_fifo(struct BCState *bcs, int count)
41312 t += sprintf(t, "jade_empty_fifo %c cnt %d",
41313 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41314 QuickHex(t, ptr, count);
41315 - debugl1(cs, bcs->blog);
41316 + debugl1(cs, "%s", bcs->blog);
41317 }
41318 }
41319
41320 @@ -105,7 +105,7 @@ jade_fill_fifo(struct BCState *bcs)
41321 t += sprintf(t, "jade_fill_fifo %c cnt %d",
41322 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41323 QuickHex(t, ptr, count);
41324 - debugl1(cs, bcs->blog);
41325 + debugl1(cs, "%s", bcs->blog);
41326 }
41327 }
41328
41329 diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
41330 index 4c1bca5..875402e 100644
41331 --- a/drivers/isdn/hisax/l3_1tr6.c
41332 +++ b/drivers/isdn/hisax/l3_1tr6.c
41333 @@ -63,7 +63,7 @@ l3_1tr6_error(struct l3_process *pc, u_char *msg, struct sk_buff *skb)
41334 {
41335 dev_kfree_skb(skb);
41336 if (pc->st->l3.debug & L3_DEB_WARN)
41337 - l3_debug(pc->st, msg);
41338 + l3_debug(pc->st, "%s", msg);
41339 l3_1tr6_release_req(pc, 0, NULL);
41340 }
41341
41342 @@ -161,7 +161,6 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41343 {
41344 u_char *p;
41345 int bcfound = 0;
41346 - char tmp[80];
41347 struct sk_buff *skb = arg;
41348
41349 /* Channel Identification */
41350 @@ -214,10 +213,9 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41351 /* Signal all services, linklevel takes care of Service-Indicator */
41352 if (bcfound) {
41353 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
41354 - sprintf(tmp, "non-digital call: %s -> %s",
41355 + l3_debug(pc->st, "non-digital call: %s -> %s",
41356 pc->para.setup.phone,
41357 pc->para.setup.eazmsn);
41358 - l3_debug(pc->st, tmp);
41359 }
41360 newl3state(pc, 6);
41361 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
41362 @@ -301,7 +299,7 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41363 {
41364 u_char *p;
41365 int i, tmpcharge = 0;
41366 - char a_charge[8], tmp[32];
41367 + char a_charge[8];
41368 struct sk_buff *skb = arg;
41369
41370 p = skb->data;
41371 @@ -316,8 +314,8 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41372 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41373 }
41374 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41375 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41376 - l3_debug(pc->st, tmp);
41377 + l3_debug(pc->st, "charging info %d",
41378 + pc->para.chargeinfo);
41379 }
41380 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41381 l3_debug(pc->st, "charging info not found");
41382 @@ -399,7 +397,7 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41383 struct sk_buff *skb = arg;
41384 u_char *p;
41385 int i, tmpcharge = 0;
41386 - char a_charge[8], tmp[32];
41387 + char a_charge[8];
41388
41389 StopAllL3Timer(pc);
41390 p = skb->data;
41391 @@ -414,8 +412,8 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41392 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41393 }
41394 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41395 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41396 - l3_debug(pc->st, tmp);
41397 + l3_debug(pc->st, "charging info %d",
41398 + pc->para.chargeinfo);
41399 }
41400 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41401 l3_debug(pc->st, "charging info not found");
41402 @@ -746,7 +744,6 @@ up1tr6(struct PStack *st, int pr, void *arg)
41403 int i, mt, cr;
41404 struct l3_process *proc;
41405 struct sk_buff *skb = arg;
41406 - char tmp[80];
41407
41408 switch (pr) {
41409 case (DL_DATA | INDICATION):
41410 @@ -762,26 +759,23 @@ up1tr6(struct PStack *st, int pr, void *arg)
41411 }
41412 if (skb->len < 4) {
41413 if (st->l3.debug & L3_DEB_PROTERR) {
41414 - sprintf(tmp, "up1tr6 len only %d", skb->len);
41415 - l3_debug(st, tmp);
41416 + l3_debug(st, "up1tr6 len only %d", skb->len);
41417 }
41418 dev_kfree_skb(skb);
41419 return;
41420 }
41421 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
41422 if (st->l3.debug & L3_DEB_PROTERR) {
41423 - sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d",
41424 + l3_debug(st, "up1tr6%sunexpected discriminator %x message len %d",
41425 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41426 skb->data[0], skb->len);
41427 - l3_debug(st, tmp);
41428 }
41429 dev_kfree_skb(skb);
41430 return;
41431 }
41432 if (skb->data[1] != 1) {
41433 if (st->l3.debug & L3_DEB_PROTERR) {
41434 - sprintf(tmp, "up1tr6 CR len not 1");
41435 - l3_debug(st, tmp);
41436 + l3_debug(st, "up1tr6 CR len not 1");
41437 }
41438 dev_kfree_skb(skb);
41439 return;
41440 @@ -791,9 +785,8 @@ up1tr6(struct PStack *st, int pr, void *arg)
41441 if (skb->data[0] == PROTO_DIS_N0) {
41442 dev_kfree_skb(skb);
41443 if (st->l3.debug & L3_DEB_STATE) {
41444 - sprintf(tmp, "up1tr6%s N0 mt %x unhandled",
41445 + l3_debug(st, "up1tr6%s N0 mt %x unhandled",
41446 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt);
41447 - l3_debug(st, tmp);
41448 }
41449 } else if (skb->data[0] == PROTO_DIS_N1) {
41450 if (!(proc = getl3proc(st, cr))) {
41451 @@ -801,8 +794,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41452 if (cr < 128) {
41453 if (!(proc = new_l3_process(st, cr))) {
41454 if (st->l3.debug & L3_DEB_PROTERR) {
41455 - sprintf(tmp, "up1tr6 no roc mem");
41456 - l3_debug(st, tmp);
41457 + l3_debug(st, "up1tr6 no roc mem");
41458 }
41459 dev_kfree_skb(skb);
41460 return;
41461 @@ -821,8 +813,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41462 } else {
41463 if (!(proc = new_l3_process(st, cr))) {
41464 if (st->l3.debug & L3_DEB_PROTERR) {
41465 - sprintf(tmp, "up1tr6 no roc mem");
41466 - l3_debug(st, tmp);
41467 + l3_debug(st, "up1tr6 no roc mem");
41468 }
41469 dev_kfree_skb(skb);
41470 return;
41471 @@ -837,18 +828,16 @@ up1tr6(struct PStack *st, int pr, void *arg)
41472 if (i == ARRAY_SIZE(datastln1)) {
41473 dev_kfree_skb(skb);
41474 if (st->l3.debug & L3_DEB_STATE) {
41475 - sprintf(tmp, "up1tr6%sstate %d mt %x unhandled",
41476 + l3_debug(st, "up1tr6%sstate %d mt %x unhandled",
41477 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41478 proc->state, mt);
41479 - l3_debug(st, tmp);
41480 }
41481 return;
41482 } else {
41483 if (st->l3.debug & L3_DEB_STATE) {
41484 - sprintf(tmp, "up1tr6%sstate %d mt %x",
41485 + l3_debug(st, "up1tr6%sstate %d mt %x",
41486 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41487 proc->state, mt);
41488 - l3_debug(st, tmp);
41489 }
41490 datastln1[i].rout(proc, pr, skb);
41491 }
41492 @@ -861,7 +850,6 @@ down1tr6(struct PStack *st, int pr, void *arg)
41493 int i, cr;
41494 struct l3_process *proc;
41495 struct Channel *chan;
41496 - char tmp[80];
41497
41498 if ((DL_ESTABLISH | REQUEST) == pr) {
41499 l3_msg(st, pr, NULL);
41500 @@ -888,15 +876,13 @@ down1tr6(struct PStack *st, int pr, void *arg)
41501 break;
41502 if (i == ARRAY_SIZE(downstl)) {
41503 if (st->l3.debug & L3_DEB_STATE) {
41504 - sprintf(tmp, "down1tr6 state %d prim %d unhandled",
41505 + l3_debug(st, "down1tr6 state %d prim %d unhandled",
41506 proc->state, pr);
41507 - l3_debug(st, tmp);
41508 }
41509 } else {
41510 if (st->l3.debug & L3_DEB_STATE) {
41511 - sprintf(tmp, "down1tr6 state %d prim %d",
41512 + l3_debug(st, "down1tr6 state %d prim %d",
41513 proc->state, pr);
41514 - l3_debug(st, tmp);
41515 }
41516 downstl[i].rout(proc, pr, arg);
41517 }
41518 diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
41519 index b646eed..233e432 100644
41520 --- a/drivers/isdn/hisax/netjet.c
41521 +++ b/drivers/isdn/hisax/netjet.c
41522 @@ -176,7 +176,7 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s
41523 else
41524 j = i;
41525 QuickHex(t, p, j);
41526 - debugl1(cs, tmp);
41527 + debugl1(cs, "%s", tmp);
41528 p += j;
41529 i -= j;
41530 t = tmp;
41531 diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
41532 index 041bf52..af1b020 100644
41533 --- a/drivers/isdn/hisax/q931.c
41534 +++ b/drivers/isdn/hisax/q931.c
41535 @@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size)
41536 dp--;
41537 *dp++ = '\n';
41538 *dp = 0;
41539 - HiSax_putstatus(cs, NULL, cs->dlog);
41540 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41541 } else
41542 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
41543 }
41544 @@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41545 }
41546 if (finish) {
41547 *dp = 0;
41548 - HiSax_putstatus(cs, NULL, cs->dlog);
41549 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41550 return;
41551 }
41552 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
41553 @@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41554 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
41555 }
41556 *dp = 0;
41557 - HiSax_putstatus(cs, NULL, cs->dlog);
41558 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41559 }
41560 diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
41561 index d8cac69..a858955 100644
41562 --- a/drivers/isdn/hisax/w6692.c
41563 +++ b/drivers/isdn/hisax/w6692.c
41564 @@ -154,7 +154,7 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
41565
41566 t += sprintf(t, "W6692_empty_fifo cnt %d", count);
41567 QuickHex(t, ptr, count);
41568 - debugl1(cs, cs->dlog);
41569 + debugl1(cs, "%s", cs->dlog);
41570 }
41571 }
41572
41573 @@ -196,7 +196,7 @@ W6692_fill_fifo(struct IsdnCardState *cs)
41574
41575 t += sprintf(t, "W6692_fill_fifo cnt %d", count);
41576 QuickHex(t, ptr, count);
41577 - debugl1(cs, cs->dlog);
41578 + debugl1(cs, "%s", cs->dlog);
41579 }
41580 }
41581
41582 @@ -226,7 +226,7 @@ W6692B_empty_fifo(struct BCState *bcs, int count)
41583 t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
41584 bcs->channel + '1', count);
41585 QuickHex(t, ptr, count);
41586 - debugl1(cs, bcs->blog);
41587 + debugl1(cs, "%s", bcs->blog);
41588 }
41589 }
41590
41591 @@ -264,7 +264,7 @@ W6692B_fill_fifo(struct BCState *bcs)
41592 t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
41593 bcs->channel + '1', count);
41594 QuickHex(t, ptr, count);
41595 - debugl1(cs, bcs->blog);
41596 + debugl1(cs, "%s", bcs->blog);
41597 }
41598 }
41599
41600 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41601 index 9bb12ba..d4262f7 100644
41602 --- a/drivers/isdn/i4l/isdn_common.c
41603 +++ b/drivers/isdn/i4l/isdn_common.c
41604 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41605 } else
41606 return -EINVAL;
41607 case IIOCDBGVAR:
41608 + if (!capable(CAP_SYS_RAWIO))
41609 + return -EPERM;
41610 if (arg) {
41611 if (copy_to_user(argp, &dev, sizeof(ulong)))
41612 return -EFAULT;
41613 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41614 index 3c5f249..5fac4d0 100644
41615 --- a/drivers/isdn/i4l/isdn_tty.c
41616 +++ b/drivers/isdn/i4l/isdn_tty.c
41617 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41618
41619 #ifdef ISDN_DEBUG_MODEM_OPEN
41620 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41621 - port->count);
41622 + atomic_read(&port->count));
41623 #endif
41624 - port->count++;
41625 + atomic_inc(&port->count);
41626 port->tty = tty;
41627 /*
41628 * Start up serial port
41629 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41630 #endif
41631 return;
41632 }
41633 - if ((tty->count == 1) && (port->count != 1)) {
41634 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41635 /*
41636 * Uh, oh. tty->count is 1, which means that the tty
41637 * structure will be freed. Info->count should always
41638 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41639 * serial port won't be shutdown.
41640 */
41641 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41642 - "info->count is %d\n", port->count);
41643 - port->count = 1;
41644 + "info->count is %d\n", atomic_read(&port->count));
41645 + atomic_set(&port->count, 1);
41646 }
41647 - if (--port->count < 0) {
41648 + if (atomic_dec_return(&port->count) < 0) {
41649 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41650 - info->line, port->count);
41651 - port->count = 0;
41652 + info->line, atomic_read(&port->count));
41653 + atomic_set(&port->count, 0);
41654 }
41655 - if (port->count) {
41656 + if (atomic_read(&port->count)) {
41657 #ifdef ISDN_DEBUG_MODEM_OPEN
41658 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41659 #endif
41660 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41661 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41662 return;
41663 isdn_tty_shutdown(info);
41664 - port->count = 0;
41665 + atomic_set(&port->count, 0);
41666 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41667 port->tty = NULL;
41668 wake_up_interruptible(&port->open_wait);
41669 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41670 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41671 modem_info *info = &dev->mdm.info[i];
41672
41673 - if (info->port.count == 0)
41674 + if (atomic_read(&info->port.count) == 0)
41675 continue;
41676 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41677 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41678 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41679 index e74df7c..03a03ba 100644
41680 --- a/drivers/isdn/icn/icn.c
41681 +++ b/drivers/isdn/icn/icn.c
41682 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41683 if (count > len)
41684 count = len;
41685 if (user) {
41686 - if (copy_from_user(msg, buf, count))
41687 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41688 return -EFAULT;
41689 } else
41690 memcpy(msg, buf, count);
41691 diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
41692 index baf2686..02125e6 100644
41693 --- a/drivers/isdn/isdnloop/isdnloop.c
41694 +++ b/drivers/isdn/isdnloop/isdnloop.c
41695 @@ -1083,8 +1083,10 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41696 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41697 return -ENOMEM;
41698 }
41699 - for (i = 0; i < 3; i++)
41700 - strcpy(card->s0num[i], sdef.num[i]);
41701 + for (i = 0; i < 3; i++) {
41702 + strlcpy(card->s0num[i], sdef.num[i],
41703 + sizeof(card->s0num[0]));
41704 + }
41705 break;
41706 case ISDN_PTYPE_1TR6:
41707 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
41708 @@ -1097,7 +1099,7 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41709 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41710 return -ENOMEM;
41711 }
41712 - strcpy(card->s0num[0], sdef.num[0]);
41713 + strlcpy(card->s0num[0], sdef.num[0], sizeof(card->s0num[0]));
41714 card->s0num[1][0] = '\0';
41715 card->s0num[2][0] = '\0';
41716 break;
41717 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41718 index 6a8405d..0bd1c7e 100644
41719 --- a/drivers/leds/leds-clevo-mail.c
41720 +++ b/drivers/leds/leds-clevo-mail.c
41721 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41722 * detected as working, but in reality it is not) as low as
41723 * possible.
41724 */
41725 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
41726 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
41727 {
41728 .callback = clevo_mail_led_dmi_callback,
41729 .ident = "Clevo D410J",
41730 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41731 index 64e204e..c6bf189 100644
41732 --- a/drivers/leds/leds-ss4200.c
41733 +++ b/drivers/leds/leds-ss4200.c
41734 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41735 * detected as working, but in reality it is not) as low as
41736 * possible.
41737 */
41738 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
41739 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
41740 {
41741 .callback = ss4200_led_dmi_callback,
41742 .ident = "Intel SS4200-E",
41743 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41744 index 0bf1e4e..b4bf44e 100644
41745 --- a/drivers/lguest/core.c
41746 +++ b/drivers/lguest/core.c
41747 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41748 * The end address needs +1 because __get_vm_area allocates an
41749 * extra guard page, so we need space for that.
41750 */
41751 +
41752 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41753 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41754 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41755 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41756 +#else
41757 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41758 VM_ALLOC, switcher_addr, switcher_addr
41759 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41760 +#endif
41761 +
41762 if (!switcher_vma) {
41763 err = -ENOMEM;
41764 printk("lguest: could not map switcher pages high\n");
41765 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41766 * Now the Switcher is mapped at the right address, we can't fail!
41767 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41768 */
41769 - memcpy(switcher_vma->addr, start_switcher_text,
41770 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41771 end_switcher_text - start_switcher_text);
41772
41773 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41774 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41775 index a35d8d1..59fb772 100644
41776 --- a/drivers/lguest/page_tables.c
41777 +++ b/drivers/lguest/page_tables.c
41778 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41779 /*:*/
41780
41781 #ifdef CONFIG_X86_PAE
41782 -static void release_pmd(pmd_t *spmd)
41783 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41784 {
41785 /* If the entry's not present, there's nothing to release. */
41786 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41787 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41788 index 5169239..47cb4db 100644
41789 --- a/drivers/lguest/x86/core.c
41790 +++ b/drivers/lguest/x86/core.c
41791 @@ -59,7 +59,7 @@ static struct {
41792 /* Offset from where switcher.S was compiled to where we've copied it */
41793 static unsigned long switcher_offset(void)
41794 {
41795 - return switcher_addr - (unsigned long)start_switcher_text;
41796 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41797 }
41798
41799 /* This cpu's struct lguest_pages (after the Switcher text page) */
41800 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
41801 * These copies are pretty cheap, so we do them unconditionally: */
41802 /* Save the current Host top-level page directory.
41803 */
41804 +
41805 +#ifdef CONFIG_PAX_PER_CPU_PGD
41806 + pages->state.host_cr3 = read_cr3();
41807 +#else
41808 pages->state.host_cr3 = __pa(current->mm->pgd);
41809 +#endif
41810 +
41811 /*
41812 * Set up the Guest's page tables to see this CPU's pages (and no
41813 * other CPU's pages).
41814 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
41815 * compiled-in switcher code and the high-mapped copy we just made.
41816 */
41817 for (i = 0; i < IDT_ENTRIES; i++)
41818 - default_idt_entries[i] += switcher_offset();
41819 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
41820
41821 /*
41822 * Set up the Switcher's per-cpu areas.
41823 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
41824 * it will be undisturbed when we switch. To change %cs and jump we
41825 * need this structure to feed to Intel's "lcall" instruction.
41826 */
41827 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
41828 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
41829 lguest_entry.segment = LGUEST_CS;
41830
41831 /*
41832 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
41833 index 40634b0..4f5855e 100644
41834 --- a/drivers/lguest/x86/switcher_32.S
41835 +++ b/drivers/lguest/x86/switcher_32.S
41836 @@ -87,6 +87,7 @@
41837 #include <asm/page.h>
41838 #include <asm/segment.h>
41839 #include <asm/lguest.h>
41840 +#include <asm/processor-flags.h>
41841
41842 // We mark the start of the code to copy
41843 // It's placed in .text tho it's never run here
41844 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
41845 // Changes type when we load it: damn Intel!
41846 // For after we switch over our page tables
41847 // That entry will be read-only: we'd crash.
41848 +
41849 +#ifdef CONFIG_PAX_KERNEXEC
41850 + mov %cr0, %edx
41851 + xor $X86_CR0_WP, %edx
41852 + mov %edx, %cr0
41853 +#endif
41854 +
41855 movl $(GDT_ENTRY_TSS*8), %edx
41856 ltr %dx
41857
41858 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
41859 // Let's clear it again for our return.
41860 // The GDT descriptor of the Host
41861 // Points to the table after two "size" bytes
41862 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
41863 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
41864 // Clear "used" from type field (byte 5, bit 2)
41865 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
41866 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
41867 +
41868 +#ifdef CONFIG_PAX_KERNEXEC
41869 + mov %cr0, %eax
41870 + xor $X86_CR0_WP, %eax
41871 + mov %eax, %cr0
41872 +#endif
41873
41874 // Once our page table's switched, the Guest is live!
41875 // The Host fades as we run this final step.
41876 @@ -295,13 +309,12 @@ deliver_to_host:
41877 // I consulted gcc, and it gave
41878 // These instructions, which I gladly credit:
41879 leal (%edx,%ebx,8), %eax
41880 - movzwl (%eax),%edx
41881 - movl 4(%eax), %eax
41882 - xorw %ax, %ax
41883 - orl %eax, %edx
41884 + movl 4(%eax), %edx
41885 + movw (%eax), %dx
41886 // Now the address of the handler's in %edx
41887 // We call it now: its "iret" drops us home.
41888 - jmp *%edx
41889 + ljmp $__KERNEL_CS, $1f
41890 +1: jmp *%edx
41891
41892 // Every interrupt can come to us here
41893 // But we must truly tell each apart.
41894 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
41895 index 0003992..854bbce 100644
41896 --- a/drivers/md/bcache/closure.h
41897 +++ b/drivers/md/bcache/closure.h
41898 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
41899 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
41900 struct workqueue_struct *wq)
41901 {
41902 - BUG_ON(object_is_on_stack(cl));
41903 + BUG_ON(object_starts_on_stack(cl));
41904 closure_set_ip(cl);
41905 cl->fn = fn;
41906 cl->wq = wq;
41907 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
41908 index 547c4c5..5be1de4 100644
41909 --- a/drivers/md/bcache/super.c
41910 +++ b/drivers/md/bcache/super.c
41911 @@ -1644,7 +1644,7 @@ err_unlock_gc:
41912 err:
41913 closure_sync(&op.cl);
41914 /* XXX: test this, it's broken */
41915 - bch_cache_set_error(c, err);
41916 + bch_cache_set_error(c, "%s", err);
41917 }
41918
41919 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
41920 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
41921 index a7fd821..9dcf6c3 100644
41922 --- a/drivers/md/bitmap.c
41923 +++ b/drivers/md/bitmap.c
41924 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
41925 chunk_kb ? "KB" : "B");
41926 if (bitmap->storage.file) {
41927 seq_printf(seq, ", file: ");
41928 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
41929 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
41930 }
41931
41932 seq_printf(seq, "\n");
41933 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
41934 index f1b7586..a49c4bd 100644
41935 --- a/drivers/md/dm-ioctl.c
41936 +++ b/drivers/md/dm-ioctl.c
41937 @@ -1739,7 +1739,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
41938 cmd == DM_LIST_VERSIONS_CMD)
41939 return 0;
41940
41941 - if ((cmd == DM_DEV_CREATE_CMD)) {
41942 + if (cmd == DM_DEV_CREATE_CMD) {
41943 if (!*param->name) {
41944 DMWARN("name not supplied when creating device");
41945 return -EINVAL;
41946 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
41947 index 699b5be..eac0a15 100644
41948 --- a/drivers/md/dm-raid1.c
41949 +++ b/drivers/md/dm-raid1.c
41950 @@ -40,7 +40,7 @@ enum dm_raid1_error {
41951
41952 struct mirror {
41953 struct mirror_set *ms;
41954 - atomic_t error_count;
41955 + atomic_unchecked_t error_count;
41956 unsigned long error_type;
41957 struct dm_dev *dev;
41958 sector_t offset;
41959 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
41960 struct mirror *m;
41961
41962 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
41963 - if (!atomic_read(&m->error_count))
41964 + if (!atomic_read_unchecked(&m->error_count))
41965 return m;
41966
41967 return NULL;
41968 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
41969 * simple way to tell if a device has encountered
41970 * errors.
41971 */
41972 - atomic_inc(&m->error_count);
41973 + atomic_inc_unchecked(&m->error_count);
41974
41975 if (test_and_set_bit(error_type, &m->error_type))
41976 return;
41977 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
41978 struct mirror *m = get_default_mirror(ms);
41979
41980 do {
41981 - if (likely(!atomic_read(&m->error_count)))
41982 + if (likely(!atomic_read_unchecked(&m->error_count)))
41983 return m;
41984
41985 if (m-- == ms->mirror)
41986 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
41987 {
41988 struct mirror *default_mirror = get_default_mirror(m->ms);
41989
41990 - return !atomic_read(&default_mirror->error_count);
41991 + return !atomic_read_unchecked(&default_mirror->error_count);
41992 }
41993
41994 static int mirror_available(struct mirror_set *ms, struct bio *bio)
41995 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
41996 */
41997 if (likely(region_in_sync(ms, region, 1)))
41998 m = choose_mirror(ms, bio->bi_sector);
41999 - else if (m && atomic_read(&m->error_count))
42000 + else if (m && atomic_read_unchecked(&m->error_count))
42001 m = NULL;
42002
42003 if (likely(m))
42004 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42005 }
42006
42007 ms->mirror[mirror].ms = ms;
42008 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42009 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42010 ms->mirror[mirror].error_type = 0;
42011 ms->mirror[mirror].offset = offset;
42012
42013 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42014 */
42015 static char device_status_char(struct mirror *m)
42016 {
42017 - if (!atomic_read(&(m->error_count)))
42018 + if (!atomic_read_unchecked(&(m->error_count)))
42019 return 'A';
42020
42021 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42022 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42023 index d907ca6..cfb8384 100644
42024 --- a/drivers/md/dm-stripe.c
42025 +++ b/drivers/md/dm-stripe.c
42026 @@ -20,7 +20,7 @@ struct stripe {
42027 struct dm_dev *dev;
42028 sector_t physical_start;
42029
42030 - atomic_t error_count;
42031 + atomic_unchecked_t error_count;
42032 };
42033
42034 struct stripe_c {
42035 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42036 kfree(sc);
42037 return r;
42038 }
42039 - atomic_set(&(sc->stripe[i].error_count), 0);
42040 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42041 }
42042
42043 ti->private = sc;
42044 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42045 DMEMIT("%d ", sc->stripes);
42046 for (i = 0; i < sc->stripes; i++) {
42047 DMEMIT("%s ", sc->stripe[i].dev->name);
42048 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42049 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42050 'D' : 'A';
42051 }
42052 buffer[i] = '\0';
42053 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42054 */
42055 for (i = 0; i < sc->stripes; i++)
42056 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42057 - atomic_inc(&(sc->stripe[i].error_count));
42058 - if (atomic_read(&(sc->stripe[i].error_count)) <
42059 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42060 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42061 DM_IO_ERROR_THRESHOLD)
42062 schedule_work(&sc->trigger_event);
42063 }
42064 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42065 index f221812..6cfda2f 100644
42066 --- a/drivers/md/dm-table.c
42067 +++ b/drivers/md/dm-table.c
42068 @@ -286,7 +286,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
42069 static int open_dev(struct dm_dev_internal *d, dev_t dev,
42070 struct mapped_device *md)
42071 {
42072 - static char *_claim_ptr = "I belong to device-mapper";
42073 + static char _claim_ptr[] = "I belong to device-mapper";
42074 struct block_device *bdev;
42075
42076 int r;
42077 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42078 if (!dev_size)
42079 return 0;
42080
42081 - if ((start >= dev_size) || (start + len > dev_size)) {
42082 + if ((start >= dev_size) || (len > dev_size - start)) {
42083 DMWARN("%s: %s too small for target: "
42084 "start=%llu, len=%llu, dev_size=%llu",
42085 dm_device_name(ti->table->md), bdevname(bdev, b),
42086 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42087 index 60bce43..9b997d0 100644
42088 --- a/drivers/md/dm-thin-metadata.c
42089 +++ b/drivers/md/dm-thin-metadata.c
42090 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42091 {
42092 pmd->info.tm = pmd->tm;
42093 pmd->info.levels = 2;
42094 - pmd->info.value_type.context = pmd->data_sm;
42095 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42096 pmd->info.value_type.size = sizeof(__le64);
42097 pmd->info.value_type.inc = data_block_inc;
42098 pmd->info.value_type.dec = data_block_dec;
42099 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42100
42101 pmd->bl_info.tm = pmd->tm;
42102 pmd->bl_info.levels = 1;
42103 - pmd->bl_info.value_type.context = pmd->data_sm;
42104 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42105 pmd->bl_info.value_type.size = sizeof(__le64);
42106 pmd->bl_info.value_type.inc = data_block_inc;
42107 pmd->bl_info.value_type.dec = data_block_dec;
42108 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42109 index 995e1fc..2468cec 100644
42110 --- a/drivers/md/dm.c
42111 +++ b/drivers/md/dm.c
42112 @@ -178,9 +178,9 @@ struct mapped_device {
42113 /*
42114 * Event handling.
42115 */
42116 - atomic_t event_nr;
42117 + atomic_unchecked_t event_nr;
42118 wait_queue_head_t eventq;
42119 - atomic_t uevent_seq;
42120 + atomic_unchecked_t uevent_seq;
42121 struct list_head uevent_list;
42122 spinlock_t uevent_lock; /* Protect access to uevent_list */
42123
42124 @@ -1916,8 +1916,8 @@ static struct mapped_device *alloc_dev(int minor)
42125 spin_lock_init(&md->deferred_lock);
42126 atomic_set(&md->holders, 1);
42127 atomic_set(&md->open_count, 0);
42128 - atomic_set(&md->event_nr, 0);
42129 - atomic_set(&md->uevent_seq, 0);
42130 + atomic_set_unchecked(&md->event_nr, 0);
42131 + atomic_set_unchecked(&md->uevent_seq, 0);
42132 INIT_LIST_HEAD(&md->uevent_list);
42133 spin_lock_init(&md->uevent_lock);
42134
42135 @@ -2068,7 +2068,7 @@ static void event_callback(void *context)
42136
42137 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42138
42139 - atomic_inc(&md->event_nr);
42140 + atomic_inc_unchecked(&md->event_nr);
42141 wake_up(&md->eventq);
42142 }
42143
42144 @@ -2727,18 +2727,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42145
42146 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42147 {
42148 - return atomic_add_return(1, &md->uevent_seq);
42149 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42150 }
42151
42152 uint32_t dm_get_event_nr(struct mapped_device *md)
42153 {
42154 - return atomic_read(&md->event_nr);
42155 + return atomic_read_unchecked(&md->event_nr);
42156 }
42157
42158 int dm_wait_event(struct mapped_device *md, int event_nr)
42159 {
42160 return wait_event_interruptible(md->eventq,
42161 - (event_nr != atomic_read(&md->event_nr)));
42162 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42163 }
42164
42165 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42166 diff --git a/drivers/md/md.c b/drivers/md/md.c
42167 index 866f489..9bf9ba3 100644
42168 --- a/drivers/md/md.c
42169 +++ b/drivers/md/md.c
42170 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42171 * start build, activate spare
42172 */
42173 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42174 -static atomic_t md_event_count;
42175 +static atomic_unchecked_t md_event_count;
42176 void md_new_event(struct mddev *mddev)
42177 {
42178 - atomic_inc(&md_event_count);
42179 + atomic_inc_unchecked(&md_event_count);
42180 wake_up(&md_event_waiters);
42181 }
42182 EXPORT_SYMBOL_GPL(md_new_event);
42183 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42184 */
42185 static void md_new_event_inintr(struct mddev *mddev)
42186 {
42187 - atomic_inc(&md_event_count);
42188 + atomic_inc_unchecked(&md_event_count);
42189 wake_up(&md_event_waiters);
42190 }
42191
42192 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42193 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42194 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42195 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42196 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42197 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42198
42199 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42200 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42201 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42202 else
42203 sb->resync_offset = cpu_to_le64(0);
42204
42205 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42206 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42207
42208 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42209 sb->size = cpu_to_le64(mddev->dev_sectors);
42210 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42211 static ssize_t
42212 errors_show(struct md_rdev *rdev, char *page)
42213 {
42214 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42215 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42216 }
42217
42218 static ssize_t
42219 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42220 char *e;
42221 unsigned long n = simple_strtoul(buf, &e, 10);
42222 if (*buf && (*e == 0 || *e == '\n')) {
42223 - atomic_set(&rdev->corrected_errors, n);
42224 + atomic_set_unchecked(&rdev->corrected_errors, n);
42225 return len;
42226 }
42227 return -EINVAL;
42228 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42229 rdev->sb_loaded = 0;
42230 rdev->bb_page = NULL;
42231 atomic_set(&rdev->nr_pending, 0);
42232 - atomic_set(&rdev->read_errors, 0);
42233 - atomic_set(&rdev->corrected_errors, 0);
42234 + atomic_set_unchecked(&rdev->read_errors, 0);
42235 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42236
42237 INIT_LIST_HEAD(&rdev->same_set);
42238 init_waitqueue_head(&rdev->blocked_wait);
42239 @@ -7024,7 +7024,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42240
42241 spin_unlock(&pers_lock);
42242 seq_printf(seq, "\n");
42243 - seq->poll_event = atomic_read(&md_event_count);
42244 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42245 return 0;
42246 }
42247 if (v == (void*)2) {
42248 @@ -7127,7 +7127,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42249 return error;
42250
42251 seq = file->private_data;
42252 - seq->poll_event = atomic_read(&md_event_count);
42253 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42254 return error;
42255 }
42256
42257 @@ -7141,7 +7141,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42258 /* always allow read */
42259 mask = POLLIN | POLLRDNORM;
42260
42261 - if (seq->poll_event != atomic_read(&md_event_count))
42262 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42263 mask |= POLLERR | POLLPRI;
42264 return mask;
42265 }
42266 @@ -7185,7 +7185,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42267 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42268 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42269 (int)part_stat_read(&disk->part0, sectors[1]) -
42270 - atomic_read(&disk->sync_io);
42271 + atomic_read_unchecked(&disk->sync_io);
42272 /* sync IO will cause sync_io to increase before the disk_stats
42273 * as sync_io is counted when a request starts, and
42274 * disk_stats is counted when it completes.
42275 diff --git a/drivers/md/md.h b/drivers/md/md.h
42276 index 20f02c0..fd8c821 100644
42277 --- a/drivers/md/md.h
42278 +++ b/drivers/md/md.h
42279 @@ -94,13 +94,13 @@ struct md_rdev {
42280 * only maintained for arrays that
42281 * support hot removal
42282 */
42283 - atomic_t read_errors; /* number of consecutive read errors that
42284 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42285 * we have tried to ignore.
42286 */
42287 struct timespec last_read_error; /* monotonic time since our
42288 * last read error
42289 */
42290 - atomic_t corrected_errors; /* number of corrected read errors,
42291 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42292 * for reporting to userspace and storing
42293 * in superblock.
42294 */
42295 @@ -442,7 +442,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42296
42297 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42298 {
42299 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42300 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42301 }
42302
42303 struct md_personality
42304 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42305 index 3e6d115..ffecdeb 100644
42306 --- a/drivers/md/persistent-data/dm-space-map.h
42307 +++ b/drivers/md/persistent-data/dm-space-map.h
42308 @@ -71,6 +71,7 @@ struct dm_space_map {
42309 dm_sm_threshold_fn fn,
42310 void *context);
42311 };
42312 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42313
42314 /*----------------------------------------------------------------*/
42315
42316 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42317 index aacf6bf..67d63f2 100644
42318 --- a/drivers/md/raid1.c
42319 +++ b/drivers/md/raid1.c
42320 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42321 if (r1_sync_page_io(rdev, sect, s,
42322 bio->bi_io_vec[idx].bv_page,
42323 READ) != 0)
42324 - atomic_add(s, &rdev->corrected_errors);
42325 + atomic_add_unchecked(s, &rdev->corrected_errors);
42326 }
42327 sectors -= s;
42328 sect += s;
42329 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42330 test_bit(In_sync, &rdev->flags)) {
42331 if (r1_sync_page_io(rdev, sect, s,
42332 conf->tmppage, READ)) {
42333 - atomic_add(s, &rdev->corrected_errors);
42334 + atomic_add_unchecked(s, &rdev->corrected_errors);
42335 printk(KERN_INFO
42336 "md/raid1:%s: read error corrected "
42337 "(%d sectors at %llu on %s)\n",
42338 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42339 index 73dc8a3..bdd515a 100644
42340 --- a/drivers/md/raid10.c
42341 +++ b/drivers/md/raid10.c
42342 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
42343 /* The write handler will notice the lack of
42344 * R10BIO_Uptodate and record any errors etc
42345 */
42346 - atomic_add(r10_bio->sectors,
42347 + atomic_add_unchecked(r10_bio->sectors,
42348 &conf->mirrors[d].rdev->corrected_errors);
42349
42350 /* for reconstruct, we always reschedule after a read.
42351 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42352 {
42353 struct timespec cur_time_mon;
42354 unsigned long hours_since_last;
42355 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42356 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42357
42358 ktime_get_ts(&cur_time_mon);
42359
42360 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42361 * overflowing the shift of read_errors by hours_since_last.
42362 */
42363 if (hours_since_last >= 8 * sizeof(read_errors))
42364 - atomic_set(&rdev->read_errors, 0);
42365 + atomic_set_unchecked(&rdev->read_errors, 0);
42366 else
42367 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42368 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42369 }
42370
42371 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42372 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42373 return;
42374
42375 check_decay_read_errors(mddev, rdev);
42376 - atomic_inc(&rdev->read_errors);
42377 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42378 + atomic_inc_unchecked(&rdev->read_errors);
42379 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42380 char b[BDEVNAME_SIZE];
42381 bdevname(rdev->bdev, b);
42382
42383 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42384 "md/raid10:%s: %s: Raid device exceeded "
42385 "read_error threshold [cur %d:max %d]\n",
42386 mdname(mddev), b,
42387 - atomic_read(&rdev->read_errors), max_read_errors);
42388 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42389 printk(KERN_NOTICE
42390 "md/raid10:%s: %s: Failing raid device\n",
42391 mdname(mddev), b);
42392 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42393 sect +
42394 choose_data_offset(r10_bio, rdev)),
42395 bdevname(rdev->bdev, b));
42396 - atomic_add(s, &rdev->corrected_errors);
42397 + atomic_add_unchecked(s, &rdev->corrected_errors);
42398 }
42399
42400 rdev_dec_pending(rdev, mddev);
42401 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42402 index d825059..d5e4ec7 100644
42403 --- a/drivers/md/raid5.c
42404 +++ b/drivers/md/raid5.c
42405 @@ -1776,21 +1776,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42406 mdname(conf->mddev), STRIPE_SECTORS,
42407 (unsigned long long)s,
42408 bdevname(rdev->bdev, b));
42409 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42410 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42411 clear_bit(R5_ReadError, &sh->dev[i].flags);
42412 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42413 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42414 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42415
42416 - if (atomic_read(&rdev->read_errors))
42417 - atomic_set(&rdev->read_errors, 0);
42418 + if (atomic_read_unchecked(&rdev->read_errors))
42419 + atomic_set_unchecked(&rdev->read_errors, 0);
42420 } else {
42421 const char *bdn = bdevname(rdev->bdev, b);
42422 int retry = 0;
42423 int set_bad = 0;
42424
42425 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42426 - atomic_inc(&rdev->read_errors);
42427 + atomic_inc_unchecked(&rdev->read_errors);
42428 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42429 printk_ratelimited(
42430 KERN_WARNING
42431 @@ -1818,7 +1818,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42432 mdname(conf->mddev),
42433 (unsigned long long)s,
42434 bdn);
42435 - } else if (atomic_read(&rdev->read_errors)
42436 + } else if (atomic_read_unchecked(&rdev->read_errors)
42437 > conf->max_nr_stripes)
42438 printk(KERN_WARNING
42439 "md/raid:%s: Too many read errors, failing device %s.\n",
42440 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42441 index 401ef64..836e563 100644
42442 --- a/drivers/media/dvb-core/dvbdev.c
42443 +++ b/drivers/media/dvb-core/dvbdev.c
42444 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42445 const struct dvb_device *template, void *priv, int type)
42446 {
42447 struct dvb_device *dvbdev;
42448 - struct file_operations *dvbdevfops;
42449 + file_operations_no_const *dvbdevfops;
42450 struct device *clsdev;
42451 int minor;
42452 int id;
42453 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42454 index 9b6c3bb..baeb5c7 100644
42455 --- a/drivers/media/dvb-frontends/dib3000.h
42456 +++ b/drivers/media/dvb-frontends/dib3000.h
42457 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42458 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42459 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42460 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42461 -};
42462 +} __no_const;
42463
42464 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42465 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42466 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42467 index ecf21d9..b992428d 100644
42468 --- a/drivers/media/pci/cx88/cx88-video.c
42469 +++ b/drivers/media/pci/cx88/cx88-video.c
42470 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42471
42472 /* ------------------------------------------------------------------ */
42473
42474 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42475 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42476 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42477 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42478 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42479 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42480
42481 module_param_array(video_nr, int, NULL, 0444);
42482 module_param_array(vbi_nr, int, NULL, 0444);
42483 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42484 index c08ae3e..eb59af1 100644
42485 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42486 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42487 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42488 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42489
42490 /* ivtv instance counter */
42491 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42492 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42493
42494 /* Parameter declarations */
42495 static int cardtype[IVTV_MAX_CARDS];
42496 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42497 index dfd0a21..6bbb465 100644
42498 --- a/drivers/media/platform/omap/omap_vout.c
42499 +++ b/drivers/media/platform/omap/omap_vout.c
42500 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42501 OMAP_VIDEO2,
42502 };
42503
42504 -static struct videobuf_queue_ops video_vbq_ops;
42505 /* Variables configurable through module params*/
42506 static u32 video1_numbuffers = 3;
42507 static u32 video2_numbuffers = 3;
42508 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42509 {
42510 struct videobuf_queue *q;
42511 struct omap_vout_device *vout = NULL;
42512 + static struct videobuf_queue_ops video_vbq_ops = {
42513 + .buf_setup = omap_vout_buffer_setup,
42514 + .buf_prepare = omap_vout_buffer_prepare,
42515 + .buf_release = omap_vout_buffer_release,
42516 + .buf_queue = omap_vout_buffer_queue,
42517 + };
42518
42519 vout = video_drvdata(file);
42520 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42521 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42522 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42523
42524 q = &vout->vbq;
42525 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42526 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42527 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42528 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42529 spin_lock_init(&vout->vbq_lock);
42530
42531 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42532 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42533 index 04e6490..2df65bf 100644
42534 --- a/drivers/media/platform/s5p-tv/mixer.h
42535 +++ b/drivers/media/platform/s5p-tv/mixer.h
42536 @@ -156,7 +156,7 @@ struct mxr_layer {
42537 /** layer index (unique identifier) */
42538 int idx;
42539 /** callbacks for layer methods */
42540 - struct mxr_layer_ops ops;
42541 + struct mxr_layer_ops *ops;
42542 /** format array */
42543 const struct mxr_format **fmt_array;
42544 /** size of format array */
42545 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42546 index b93a21f..2535195 100644
42547 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42548 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42549 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42550 {
42551 struct mxr_layer *layer;
42552 int ret;
42553 - struct mxr_layer_ops ops = {
42554 + static struct mxr_layer_ops ops = {
42555 .release = mxr_graph_layer_release,
42556 .buffer_set = mxr_graph_buffer_set,
42557 .stream_set = mxr_graph_stream_set,
42558 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42559 index b713403..53cb5ad 100644
42560 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42561 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42562 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42563 layer->update_buf = next;
42564 }
42565
42566 - layer->ops.buffer_set(layer, layer->update_buf);
42567 + layer->ops->buffer_set(layer, layer->update_buf);
42568
42569 if (done && done != layer->shadow_buf)
42570 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42571 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42572 index 641b1f0..49cff30 100644
42573 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42574 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42575 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42576 layer->geo.src.height = layer->geo.src.full_height;
42577
42578 mxr_geometry_dump(mdev, &layer->geo);
42579 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42580 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42581 mxr_geometry_dump(mdev, &layer->geo);
42582 }
42583
42584 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42585 layer->geo.dst.full_width = mbus_fmt.width;
42586 layer->geo.dst.full_height = mbus_fmt.height;
42587 layer->geo.dst.field = mbus_fmt.field;
42588 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42589 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42590
42591 mxr_geometry_dump(mdev, &layer->geo);
42592 }
42593 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42594 /* set source size to highest accepted value */
42595 geo->src.full_width = max(geo->dst.full_width, pix->width);
42596 geo->src.full_height = max(geo->dst.full_height, pix->height);
42597 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42598 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42599 mxr_geometry_dump(mdev, &layer->geo);
42600 /* set cropping to total visible screen */
42601 geo->src.width = pix->width;
42602 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42603 geo->src.x_offset = 0;
42604 geo->src.y_offset = 0;
42605 /* assure consistency of geometry */
42606 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42607 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42608 mxr_geometry_dump(mdev, &layer->geo);
42609 /* set full size to lowest possible value */
42610 geo->src.full_width = 0;
42611 geo->src.full_height = 0;
42612 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42613 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42614 mxr_geometry_dump(mdev, &layer->geo);
42615
42616 /* returning results */
42617 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42618 target->width = s->r.width;
42619 target->height = s->r.height;
42620
42621 - layer->ops.fix_geometry(layer, stage, s->flags);
42622 + layer->ops->fix_geometry(layer, stage, s->flags);
42623
42624 /* retrieve update selection rectangle */
42625 res.left = target->x_offset;
42626 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42627 mxr_output_get(mdev);
42628
42629 mxr_layer_update_output(layer);
42630 - layer->ops.format_set(layer);
42631 + layer->ops->format_set(layer);
42632 /* enabling layer in hardware */
42633 spin_lock_irqsave(&layer->enq_slock, flags);
42634 layer->state = MXR_LAYER_STREAMING;
42635 spin_unlock_irqrestore(&layer->enq_slock, flags);
42636
42637 - layer->ops.stream_set(layer, MXR_ENABLE);
42638 + layer->ops->stream_set(layer, MXR_ENABLE);
42639 mxr_streamer_get(mdev);
42640
42641 return 0;
42642 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42643 spin_unlock_irqrestore(&layer->enq_slock, flags);
42644
42645 /* disabling layer in hardware */
42646 - layer->ops.stream_set(layer, MXR_DISABLE);
42647 + layer->ops->stream_set(layer, MXR_DISABLE);
42648 /* remove one streamer */
42649 mxr_streamer_put(mdev);
42650 /* allow changes in output configuration */
42651 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42652
42653 void mxr_layer_release(struct mxr_layer *layer)
42654 {
42655 - if (layer->ops.release)
42656 - layer->ops.release(layer);
42657 + if (layer->ops->release)
42658 + layer->ops->release(layer);
42659 }
42660
42661 void mxr_base_layer_release(struct mxr_layer *layer)
42662 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42663
42664 layer->mdev = mdev;
42665 layer->idx = idx;
42666 - layer->ops = *ops;
42667 + layer->ops = ops;
42668
42669 spin_lock_init(&layer->enq_slock);
42670 INIT_LIST_HEAD(&layer->enq_list);
42671 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42672 index 3d13a63..da31bf1 100644
42673 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42674 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42675 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42676 {
42677 struct mxr_layer *layer;
42678 int ret;
42679 - struct mxr_layer_ops ops = {
42680 + static struct mxr_layer_ops ops = {
42681 .release = mxr_vp_layer_release,
42682 .buffer_set = mxr_vp_buffer_set,
42683 .stream_set = mxr_vp_stream_set,
42684 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42685 index 545c04c..a14bded 100644
42686 --- a/drivers/media/radio/radio-cadet.c
42687 +++ b/drivers/media/radio/radio-cadet.c
42688 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42689 unsigned char readbuf[RDS_BUFFER];
42690 int i = 0;
42691
42692 + if (count > RDS_BUFFER)
42693 + return -EFAULT;
42694 mutex_lock(&dev->lock);
42695 if (dev->rdsstat == 0)
42696 cadet_start_rds(dev);
42697 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42698 while (i < count && dev->rdsin != dev->rdsout)
42699 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42700
42701 - if (i && copy_to_user(data, readbuf, i))
42702 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42703 i = -EFAULT;
42704 unlock:
42705 mutex_unlock(&dev->lock);
42706 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42707 index bd4d3a7..ffc0b9d 100644
42708 --- a/drivers/media/radio/radio-maxiradio.c
42709 +++ b/drivers/media/radio/radio-maxiradio.c
42710 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42711 /* TEA5757 pin mappings */
42712 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42713
42714 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42715 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42716
42717 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42718 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42719 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42720 index 8fa18ab..caee70f 100644
42721 --- a/drivers/media/radio/radio-shark.c
42722 +++ b/drivers/media/radio/radio-shark.c
42723 @@ -79,7 +79,7 @@ struct shark_device {
42724 u32 last_val;
42725 };
42726
42727 -static atomic_t shark_instance = ATOMIC_INIT(0);
42728 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42729
42730 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42731 {
42732 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42733 index 9fb6697..f167415 100644
42734 --- a/drivers/media/radio/radio-shark2.c
42735 +++ b/drivers/media/radio/radio-shark2.c
42736 @@ -74,7 +74,7 @@ struct shark_device {
42737 u8 *transfer_buffer;
42738 };
42739
42740 -static atomic_t shark_instance = ATOMIC_INIT(0);
42741 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42742
42743 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42744 {
42745 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42746 index 9c9084c..a9e8dfb 100644
42747 --- a/drivers/media/radio/radio-si476x.c
42748 +++ b/drivers/media/radio/radio-si476x.c
42749 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42750 struct si476x_radio *radio;
42751 struct v4l2_ctrl *ctrl;
42752
42753 - static atomic_t instance = ATOMIC_INIT(0);
42754 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42755
42756 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42757 if (!radio)
42758 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42759 index 1cf382a..c22998c 100644
42760 --- a/drivers/media/rc/rc-main.c
42761 +++ b/drivers/media/rc/rc-main.c
42762 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42763 int rc_register_device(struct rc_dev *dev)
42764 {
42765 static bool raw_init = false; /* raw decoders loaded? */
42766 - static atomic_t devno = ATOMIC_INIT(0);
42767 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42768 struct rc_map *rc_map;
42769 const char *path;
42770 int rc;
42771 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
42772 */
42773 mutex_lock(&dev->lock);
42774
42775 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42776 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42777 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42778 dev_set_drvdata(&dev->dev, dev);
42779 rc = device_add(&dev->dev);
42780 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42781 index 3940bb0..fb3952a 100644
42782 --- a/drivers/media/usb/dvb-usb/cxusb.c
42783 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42784 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42785
42786 struct dib0700_adapter_state {
42787 int (*set_param_save) (struct dvb_frontend *);
42788 -};
42789 +} __no_const;
42790
42791 static int dib7070_set_param_override(struct dvb_frontend *fe)
42792 {
42793 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42794 index 6e237b6..dc25556 100644
42795 --- a/drivers/media/usb/dvb-usb/dw2102.c
42796 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42797 @@ -118,7 +118,7 @@ struct su3000_state {
42798
42799 struct s6x0_state {
42800 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42801 -};
42802 +} __no_const;
42803
42804 /* debug */
42805 static int dvb_usb_dw2102_debug;
42806 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42807 index 8f7a6a4..59502dd 100644
42808 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42809 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42810 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
42811 __u32 reserved;
42812 };
42813
42814 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42815 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42816 enum v4l2_memory memory)
42817 {
42818 void __user *up_pln;
42819 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42820 return 0;
42821 }
42822
42823 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42824 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42825 enum v4l2_memory memory)
42826 {
42827 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
42828 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
42829 put_user(kp->start_block, &up->start_block) ||
42830 put_user(kp->blocks, &up->blocks) ||
42831 put_user(tmp, &up->edid) ||
42832 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
42833 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
42834 return -EFAULT;
42835 return 0;
42836 }
42837 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
42838 index 02d1b63..5fd6b16 100644
42839 --- a/drivers/media/v4l2-core/v4l2-device.c
42840 +++ b/drivers/media/v4l2-core/v4l2-device.c
42841 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
42842 EXPORT_SYMBOL_GPL(v4l2_device_put);
42843
42844 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
42845 - atomic_t *instance)
42846 + atomic_unchecked_t *instance)
42847 {
42848 - int num = atomic_inc_return(instance) - 1;
42849 + int num = atomic_inc_return_unchecked(instance) - 1;
42850 int len = strlen(basename);
42851
42852 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
42853 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
42854 index 68e6b5e..d8b923e 100644
42855 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
42856 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
42857 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
42858 struct file *file, void *fh, void *p);
42859 } u;
42860 void (*debug)(const void *arg, bool write_only);
42861 -};
42862 +} __do_const;
42863 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
42864
42865 /* This control needs a priority check */
42866 #define INFO_FL_PRIO (1 << 0)
42867 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
42868 struct video_device *vfd = video_devdata(file);
42869 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
42870 bool write_only = false;
42871 - struct v4l2_ioctl_info default_info;
42872 + v4l2_ioctl_info_no_const default_info;
42873 const struct v4l2_ioctl_info *info;
42874 void *fh = file->private_data;
42875 struct v4l2_fh *vfh = NULL;
42876 @@ -2194,7 +2195,7 @@ done:
42877 }
42878
42879 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42880 - void * __user *user_ptr, void ***kernel_ptr)
42881 + void __user **user_ptr, void ***kernel_ptr)
42882 {
42883 int ret = 0;
42884
42885 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42886 ret = -EINVAL;
42887 break;
42888 }
42889 - *user_ptr = (void __user *)buf->m.planes;
42890 + *user_ptr = (void __force_user *)buf->m.planes;
42891 *kernel_ptr = (void *)&buf->m.planes;
42892 *array_size = sizeof(struct v4l2_plane) * buf->length;
42893 ret = 1;
42894 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42895 ret = -EINVAL;
42896 break;
42897 }
42898 - *user_ptr = (void __user *)ctrls->controls;
42899 + *user_ptr = (void __force_user *)ctrls->controls;
42900 *kernel_ptr = (void *)&ctrls->controls;
42901 *array_size = sizeof(struct v4l2_ext_control)
42902 * ctrls->count;
42903 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
42904 index 767ff4d..c69d259 100644
42905 --- a/drivers/message/fusion/mptbase.c
42906 +++ b/drivers/message/fusion/mptbase.c
42907 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42908 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
42909 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
42910
42911 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42912 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
42913 +#else
42914 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
42915 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
42916 +#endif
42917 +
42918 /*
42919 * Rounding UP to nearest 4-kB boundary here...
42920 */
42921 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42922 ioc->facts.GlobalCredits);
42923
42924 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
42925 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42926 + NULL, NULL);
42927 +#else
42928 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
42929 +#endif
42930 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
42931 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
42932 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
42933 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
42934 index dd239bd..689c4f7 100644
42935 --- a/drivers/message/fusion/mptsas.c
42936 +++ b/drivers/message/fusion/mptsas.c
42937 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
42938 return 0;
42939 }
42940
42941 +static inline void
42942 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42943 +{
42944 + if (phy_info->port_details) {
42945 + phy_info->port_details->rphy = rphy;
42946 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42947 + ioc->name, rphy));
42948 + }
42949 +
42950 + if (rphy) {
42951 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42952 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42953 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42954 + ioc->name, rphy, rphy->dev.release));
42955 + }
42956 +}
42957 +
42958 /* no mutex */
42959 static void
42960 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
42961 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
42962 return NULL;
42963 }
42964
42965 -static inline void
42966 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42967 -{
42968 - if (phy_info->port_details) {
42969 - phy_info->port_details->rphy = rphy;
42970 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42971 - ioc->name, rphy));
42972 - }
42973 -
42974 - if (rphy) {
42975 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42976 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42977 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42978 - ioc->name, rphy, rphy->dev.release));
42979 - }
42980 -}
42981 -
42982 static inline struct sas_port *
42983 mptsas_get_port(struct mptsas_phyinfo *phy_info)
42984 {
42985 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
42986 index 727819c..ad74694 100644
42987 --- a/drivers/message/fusion/mptscsih.c
42988 +++ b/drivers/message/fusion/mptscsih.c
42989 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
42990
42991 h = shost_priv(SChost);
42992
42993 - if (h) {
42994 - if (h->info_kbuf == NULL)
42995 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42996 - return h->info_kbuf;
42997 - h->info_kbuf[0] = '\0';
42998 + if (!h)
42999 + return NULL;
43000
43001 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43002 - h->info_kbuf[size-1] = '\0';
43003 - }
43004 + if (h->info_kbuf == NULL)
43005 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43006 + return h->info_kbuf;
43007 + h->info_kbuf[0] = '\0';
43008 +
43009 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43010 + h->info_kbuf[size-1] = '\0';
43011
43012 return h->info_kbuf;
43013 }
43014 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43015 index b7d87cd..3fb36da 100644
43016 --- a/drivers/message/i2o/i2o_proc.c
43017 +++ b/drivers/message/i2o/i2o_proc.c
43018 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43019 "Array Controller Device"
43020 };
43021
43022 -static char *chtostr(char *tmp, u8 *chars, int n)
43023 -{
43024 - tmp[0] = 0;
43025 - return strncat(tmp, (char *)chars, n);
43026 -}
43027 -
43028 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43029 char *group)
43030 {
43031 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
43032 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
43033 {
43034 struct i2o_controller *c = (struct i2o_controller *)seq->private;
43035 - static u32 work32[5];
43036 - static u8 *work8 = (u8 *) work32;
43037 - static u16 *work16 = (u16 *) work32;
43038 + u32 work32[5];
43039 + u8 *work8 = (u8 *) work32;
43040 + u16 *work16 = (u16 *) work32;
43041 int token;
43042 u32 hwcap;
43043
43044 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43045 } *result;
43046
43047 i2o_exec_execute_ddm_table ddm_table;
43048 - char tmp[28 + 1];
43049
43050 result = kmalloc(sizeof(*result), GFP_KERNEL);
43051 if (!result)
43052 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43053
43054 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43055 seq_printf(seq, "%-#8x", ddm_table.module_id);
43056 - seq_printf(seq, "%-29s",
43057 - chtostr(tmp, ddm_table.module_name_version, 28));
43058 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43059 seq_printf(seq, "%9d ", ddm_table.data_size);
43060 seq_printf(seq, "%8d", ddm_table.code_size);
43061
43062 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43063
43064 i2o_driver_result_table *result;
43065 i2o_driver_store_table *dst;
43066 - char tmp[28 + 1];
43067
43068 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43069 if (result == NULL)
43070 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43071
43072 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43073 seq_printf(seq, "%-#8x", dst->module_id);
43074 - seq_printf(seq, "%-29s",
43075 - chtostr(tmp, dst->module_name_version, 28));
43076 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43077 + seq_printf(seq, "%-.28s", dst->module_name_version);
43078 + seq_printf(seq, "%-.8s", dst->date);
43079 seq_printf(seq, "%8d ", dst->module_size);
43080 seq_printf(seq, "%8d ", dst->mpb_size);
43081 seq_printf(seq, "0x%04x", dst->module_flags);
43082 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
43083 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43084 {
43085 struct i2o_device *d = (struct i2o_device *)seq->private;
43086 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43087 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43088 // == (allow) 512d bytes (max)
43089 - static u16 *work16 = (u16 *) work32;
43090 + u16 *work16 = (u16 *) work32;
43091 int token;
43092 - char tmp[16 + 1];
43093
43094 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43095
43096 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43097 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43098 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43099 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43100 - seq_printf(seq, "Vendor info : %s\n",
43101 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43102 - seq_printf(seq, "Product info : %s\n",
43103 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43104 - seq_printf(seq, "Description : %s\n",
43105 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43106 - seq_printf(seq, "Product rev. : %s\n",
43107 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43108 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43109 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43110 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43111 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43112
43113 seq_printf(seq, "Serial number : ");
43114 print_serial_number(seq, (u8 *) (work32 + 16),
43115 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43116 u8 pad[256]; // allow up to 256 byte (max) serial number
43117 } result;
43118
43119 - char tmp[24 + 1];
43120 -
43121 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43122
43123 if (token < 0) {
43124 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43125 }
43126
43127 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43128 - seq_printf(seq, "Module name : %s\n",
43129 - chtostr(tmp, result.module_name, 24));
43130 - seq_printf(seq, "Module revision : %s\n",
43131 - chtostr(tmp, result.module_rev, 8));
43132 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43133 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43134
43135 seq_printf(seq, "Serial number : ");
43136 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43137 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43138 u8 instance_number[4];
43139 } result;
43140
43141 - char tmp[64 + 1];
43142 -
43143 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43144
43145 if (token < 0) {
43146 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43147 return 0;
43148 }
43149
43150 - seq_printf(seq, "Device name : %s\n",
43151 - chtostr(tmp, result.device_name, 64));
43152 - seq_printf(seq, "Service name : %s\n",
43153 - chtostr(tmp, result.service_name, 64));
43154 - seq_printf(seq, "Physical name : %s\n",
43155 - chtostr(tmp, result.physical_location, 64));
43156 - seq_printf(seq, "Instance number : %s\n",
43157 - chtostr(tmp, result.instance_number, 4));
43158 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43159 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43160 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43161 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43162
43163 return 0;
43164 }
43165 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43166 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
43167 {
43168 struct i2o_device *d = (struct i2o_device *)seq->private;
43169 - static u32 work32[12];
43170 - static u16 *work16 = (u16 *) work32;
43171 - static u8 *work8 = (u8 *) work32;
43172 + u32 work32[12];
43173 + u16 *work16 = (u16 *) work32;
43174 + u8 *work8 = (u8 *) work32;
43175 int token;
43176
43177 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
43178 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43179 index a8c08f3..155fe3d 100644
43180 --- a/drivers/message/i2o/iop.c
43181 +++ b/drivers/message/i2o/iop.c
43182 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43183
43184 spin_lock_irqsave(&c->context_list_lock, flags);
43185
43186 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43187 - atomic_inc(&c->context_list_counter);
43188 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43189 + atomic_inc_unchecked(&c->context_list_counter);
43190
43191 - entry->context = atomic_read(&c->context_list_counter);
43192 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43193
43194 list_add(&entry->list, &c->context_list);
43195
43196 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43197
43198 #if BITS_PER_LONG == 64
43199 spin_lock_init(&c->context_list_lock);
43200 - atomic_set(&c->context_list_counter, 0);
43201 + atomic_set_unchecked(&c->context_list_counter, 0);
43202 INIT_LIST_HEAD(&c->context_list);
43203 #endif
43204
43205 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43206 index fcbb2e9..2635e11 100644
43207 --- a/drivers/mfd/janz-cmodio.c
43208 +++ b/drivers/mfd/janz-cmodio.c
43209 @@ -13,6 +13,7 @@
43210
43211 #include <linux/kernel.h>
43212 #include <linux/module.h>
43213 +#include <linux/slab.h>
43214 #include <linux/init.h>
43215 #include <linux/pci.h>
43216 #include <linux/interrupt.h>
43217 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
43218 index 8042b32..cba3166 100644
43219 --- a/drivers/mfd/max8925-i2c.c
43220 +++ b/drivers/mfd/max8925-i2c.c
43221 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
43222 const struct i2c_device_id *id)
43223 {
43224 struct max8925_platform_data *pdata = client->dev.platform_data;
43225 - static struct max8925_chip *chip;
43226 + struct max8925_chip *chip;
43227 struct device_node *node = client->dev.of_node;
43228
43229 if (node && !pdata) {
43230 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
43231 index d792772..cd73ba3 100644
43232 --- a/drivers/mfd/tps65910.c
43233 +++ b/drivers/mfd/tps65910.c
43234 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
43235 struct tps65910_platform_data *pdata)
43236 {
43237 int ret = 0;
43238 - static struct regmap_irq_chip *tps6591x_irqs_chip;
43239 + struct regmap_irq_chip *tps6591x_irqs_chip;
43240
43241 if (!irq) {
43242 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
43243 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43244 index 9aa6d1e..1631bfc 100644
43245 --- a/drivers/mfd/twl4030-irq.c
43246 +++ b/drivers/mfd/twl4030-irq.c
43247 @@ -35,6 +35,7 @@
43248 #include <linux/of.h>
43249 #include <linux/irqdomain.h>
43250 #include <linux/i2c/twl.h>
43251 +#include <asm/pgtable.h>
43252
43253 #include "twl-core.h"
43254
43255 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43256 * Install an irq handler for each of the SIH modules;
43257 * clone dummy irq_chip since PIH can't *do* anything
43258 */
43259 - twl4030_irq_chip = dummy_irq_chip;
43260 - twl4030_irq_chip.name = "twl4030";
43261 + pax_open_kernel();
43262 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43263 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43264
43265 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43266 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43267 + pax_close_kernel();
43268
43269 for (i = irq_base; i < irq_end; i++) {
43270 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43271 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43272 index 277a8db..0e0b754 100644
43273 --- a/drivers/mfd/twl6030-irq.c
43274 +++ b/drivers/mfd/twl6030-irq.c
43275 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43276 * install an irq handler for each of the modules;
43277 * clone dummy irq_chip since PIH can't *do* anything
43278 */
43279 - twl6030_irq_chip = dummy_irq_chip;
43280 - twl6030_irq_chip.name = "twl6030";
43281 - twl6030_irq_chip.irq_set_type = NULL;
43282 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43283 + pax_open_kernel();
43284 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43285 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43286 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43287 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43288 + pax_close_kernel();
43289
43290 for (i = irq_base; i < irq_end; i++) {
43291 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43292 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43293 index f32550a..e3e52a2 100644
43294 --- a/drivers/misc/c2port/core.c
43295 +++ b/drivers/misc/c2port/core.c
43296 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43297 mutex_init(&c2dev->mutex);
43298
43299 /* Create binary file */
43300 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43301 + pax_open_kernel();
43302 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43303 + pax_close_kernel();
43304 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43305 if (unlikely(ret))
43306 goto error_device_create_bin_file;
43307 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43308 index 36f5d52..32311c3 100644
43309 --- a/drivers/misc/kgdbts.c
43310 +++ b/drivers/misc/kgdbts.c
43311 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43312 char before[BREAK_INSTR_SIZE];
43313 char after[BREAK_INSTR_SIZE];
43314
43315 - probe_kernel_read(before, (char *)kgdbts_break_test,
43316 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43317 BREAK_INSTR_SIZE);
43318 init_simple_test();
43319 ts.tst = plant_and_detach_test;
43320 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43321 /* Activate test with initial breakpoint */
43322 if (!is_early)
43323 kgdb_breakpoint();
43324 - probe_kernel_read(after, (char *)kgdbts_break_test,
43325 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43326 BREAK_INSTR_SIZE);
43327 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43328 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43329 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43330 index 036effe..b3a6336 100644
43331 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43332 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43333 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43334 * the lid is closed. This leads to interrupts as soon as a little move
43335 * is done.
43336 */
43337 - atomic_inc(&lis3->count);
43338 + atomic_inc_unchecked(&lis3->count);
43339
43340 wake_up_interruptible(&lis3->misc_wait);
43341 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43342 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43343 if (lis3->pm_dev)
43344 pm_runtime_get_sync(lis3->pm_dev);
43345
43346 - atomic_set(&lis3->count, 0);
43347 + atomic_set_unchecked(&lis3->count, 0);
43348 return 0;
43349 }
43350
43351 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43352 add_wait_queue(&lis3->misc_wait, &wait);
43353 while (true) {
43354 set_current_state(TASK_INTERRUPTIBLE);
43355 - data = atomic_xchg(&lis3->count, 0);
43356 + data = atomic_xchg_unchecked(&lis3->count, 0);
43357 if (data)
43358 break;
43359
43360 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43361 struct lis3lv02d, miscdev);
43362
43363 poll_wait(file, &lis3->misc_wait, wait);
43364 - if (atomic_read(&lis3->count))
43365 + if (atomic_read_unchecked(&lis3->count))
43366 return POLLIN | POLLRDNORM;
43367 return 0;
43368 }
43369 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43370 index c439c82..1f20f57 100644
43371 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43372 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43373 @@ -297,7 +297,7 @@ struct lis3lv02d {
43374 struct input_polled_dev *idev; /* input device */
43375 struct platform_device *pdev; /* platform device */
43376 struct regulator_bulk_data regulators[2];
43377 - atomic_t count; /* interrupt count after last read */
43378 + atomic_unchecked_t count; /* interrupt count after last read */
43379 union axis_conversion ac; /* hw -> logical axis */
43380 int mapped_btns[3];
43381
43382 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43383 index 2f30bad..c4c13d0 100644
43384 --- a/drivers/misc/sgi-gru/gruhandles.c
43385 +++ b/drivers/misc/sgi-gru/gruhandles.c
43386 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43387 unsigned long nsec;
43388
43389 nsec = CLKS2NSEC(clks);
43390 - atomic_long_inc(&mcs_op_statistics[op].count);
43391 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43392 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43393 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43394 if (mcs_op_statistics[op].max < nsec)
43395 mcs_op_statistics[op].max = nsec;
43396 }
43397 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43398 index 4f76359..cdfcb2e 100644
43399 --- a/drivers/misc/sgi-gru/gruprocfs.c
43400 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43401 @@ -32,9 +32,9 @@
43402
43403 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43404
43405 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43406 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43407 {
43408 - unsigned long val = atomic_long_read(v);
43409 + unsigned long val = atomic_long_read_unchecked(v);
43410
43411 seq_printf(s, "%16lu %s\n", val, id);
43412 }
43413 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43414
43415 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43416 for (op = 0; op < mcsop_last; op++) {
43417 - count = atomic_long_read(&mcs_op_statistics[op].count);
43418 - total = atomic_long_read(&mcs_op_statistics[op].total);
43419 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43420 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43421 max = mcs_op_statistics[op].max;
43422 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43423 count ? total / count : 0, max);
43424 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43425 index 5c3ce24..4915ccb 100644
43426 --- a/drivers/misc/sgi-gru/grutables.h
43427 +++ b/drivers/misc/sgi-gru/grutables.h
43428 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43429 * GRU statistics.
43430 */
43431 struct gru_stats_s {
43432 - atomic_long_t vdata_alloc;
43433 - atomic_long_t vdata_free;
43434 - atomic_long_t gts_alloc;
43435 - atomic_long_t gts_free;
43436 - atomic_long_t gms_alloc;
43437 - atomic_long_t gms_free;
43438 - atomic_long_t gts_double_allocate;
43439 - atomic_long_t assign_context;
43440 - atomic_long_t assign_context_failed;
43441 - atomic_long_t free_context;
43442 - atomic_long_t load_user_context;
43443 - atomic_long_t load_kernel_context;
43444 - atomic_long_t lock_kernel_context;
43445 - atomic_long_t unlock_kernel_context;
43446 - atomic_long_t steal_user_context;
43447 - atomic_long_t steal_kernel_context;
43448 - atomic_long_t steal_context_failed;
43449 - atomic_long_t nopfn;
43450 - atomic_long_t asid_new;
43451 - atomic_long_t asid_next;
43452 - atomic_long_t asid_wrap;
43453 - atomic_long_t asid_reuse;
43454 - atomic_long_t intr;
43455 - atomic_long_t intr_cbr;
43456 - atomic_long_t intr_tfh;
43457 - atomic_long_t intr_spurious;
43458 - atomic_long_t intr_mm_lock_failed;
43459 - atomic_long_t call_os;
43460 - atomic_long_t call_os_wait_queue;
43461 - atomic_long_t user_flush_tlb;
43462 - atomic_long_t user_unload_context;
43463 - atomic_long_t user_exception;
43464 - atomic_long_t set_context_option;
43465 - atomic_long_t check_context_retarget_intr;
43466 - atomic_long_t check_context_unload;
43467 - atomic_long_t tlb_dropin;
43468 - atomic_long_t tlb_preload_page;
43469 - atomic_long_t tlb_dropin_fail_no_asid;
43470 - atomic_long_t tlb_dropin_fail_upm;
43471 - atomic_long_t tlb_dropin_fail_invalid;
43472 - atomic_long_t tlb_dropin_fail_range_active;
43473 - atomic_long_t tlb_dropin_fail_idle;
43474 - atomic_long_t tlb_dropin_fail_fmm;
43475 - atomic_long_t tlb_dropin_fail_no_exception;
43476 - atomic_long_t tfh_stale_on_fault;
43477 - atomic_long_t mmu_invalidate_range;
43478 - atomic_long_t mmu_invalidate_page;
43479 - atomic_long_t flush_tlb;
43480 - atomic_long_t flush_tlb_gru;
43481 - atomic_long_t flush_tlb_gru_tgh;
43482 - atomic_long_t flush_tlb_gru_zero_asid;
43483 + atomic_long_unchecked_t vdata_alloc;
43484 + atomic_long_unchecked_t vdata_free;
43485 + atomic_long_unchecked_t gts_alloc;
43486 + atomic_long_unchecked_t gts_free;
43487 + atomic_long_unchecked_t gms_alloc;
43488 + atomic_long_unchecked_t gms_free;
43489 + atomic_long_unchecked_t gts_double_allocate;
43490 + atomic_long_unchecked_t assign_context;
43491 + atomic_long_unchecked_t assign_context_failed;
43492 + atomic_long_unchecked_t free_context;
43493 + atomic_long_unchecked_t load_user_context;
43494 + atomic_long_unchecked_t load_kernel_context;
43495 + atomic_long_unchecked_t lock_kernel_context;
43496 + atomic_long_unchecked_t unlock_kernel_context;
43497 + atomic_long_unchecked_t steal_user_context;
43498 + atomic_long_unchecked_t steal_kernel_context;
43499 + atomic_long_unchecked_t steal_context_failed;
43500 + atomic_long_unchecked_t nopfn;
43501 + atomic_long_unchecked_t asid_new;
43502 + atomic_long_unchecked_t asid_next;
43503 + atomic_long_unchecked_t asid_wrap;
43504 + atomic_long_unchecked_t asid_reuse;
43505 + atomic_long_unchecked_t intr;
43506 + atomic_long_unchecked_t intr_cbr;
43507 + atomic_long_unchecked_t intr_tfh;
43508 + atomic_long_unchecked_t intr_spurious;
43509 + atomic_long_unchecked_t intr_mm_lock_failed;
43510 + atomic_long_unchecked_t call_os;
43511 + atomic_long_unchecked_t call_os_wait_queue;
43512 + atomic_long_unchecked_t user_flush_tlb;
43513 + atomic_long_unchecked_t user_unload_context;
43514 + atomic_long_unchecked_t user_exception;
43515 + atomic_long_unchecked_t set_context_option;
43516 + atomic_long_unchecked_t check_context_retarget_intr;
43517 + atomic_long_unchecked_t check_context_unload;
43518 + atomic_long_unchecked_t tlb_dropin;
43519 + atomic_long_unchecked_t tlb_preload_page;
43520 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43521 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43522 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43523 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43524 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43525 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43526 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43527 + atomic_long_unchecked_t tfh_stale_on_fault;
43528 + atomic_long_unchecked_t mmu_invalidate_range;
43529 + atomic_long_unchecked_t mmu_invalidate_page;
43530 + atomic_long_unchecked_t flush_tlb;
43531 + atomic_long_unchecked_t flush_tlb_gru;
43532 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43533 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43534
43535 - atomic_long_t copy_gpa;
43536 - atomic_long_t read_gpa;
43537 + atomic_long_unchecked_t copy_gpa;
43538 + atomic_long_unchecked_t read_gpa;
43539
43540 - atomic_long_t mesq_receive;
43541 - atomic_long_t mesq_receive_none;
43542 - atomic_long_t mesq_send;
43543 - atomic_long_t mesq_send_failed;
43544 - atomic_long_t mesq_noop;
43545 - atomic_long_t mesq_send_unexpected_error;
43546 - atomic_long_t mesq_send_lb_overflow;
43547 - atomic_long_t mesq_send_qlimit_reached;
43548 - atomic_long_t mesq_send_amo_nacked;
43549 - atomic_long_t mesq_send_put_nacked;
43550 - atomic_long_t mesq_page_overflow;
43551 - atomic_long_t mesq_qf_locked;
43552 - atomic_long_t mesq_qf_noop_not_full;
43553 - atomic_long_t mesq_qf_switch_head_failed;
43554 - atomic_long_t mesq_qf_unexpected_error;
43555 - atomic_long_t mesq_noop_unexpected_error;
43556 - atomic_long_t mesq_noop_lb_overflow;
43557 - atomic_long_t mesq_noop_qlimit_reached;
43558 - atomic_long_t mesq_noop_amo_nacked;
43559 - atomic_long_t mesq_noop_put_nacked;
43560 - atomic_long_t mesq_noop_page_overflow;
43561 + atomic_long_unchecked_t mesq_receive;
43562 + atomic_long_unchecked_t mesq_receive_none;
43563 + atomic_long_unchecked_t mesq_send;
43564 + atomic_long_unchecked_t mesq_send_failed;
43565 + atomic_long_unchecked_t mesq_noop;
43566 + atomic_long_unchecked_t mesq_send_unexpected_error;
43567 + atomic_long_unchecked_t mesq_send_lb_overflow;
43568 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43569 + atomic_long_unchecked_t mesq_send_amo_nacked;
43570 + atomic_long_unchecked_t mesq_send_put_nacked;
43571 + atomic_long_unchecked_t mesq_page_overflow;
43572 + atomic_long_unchecked_t mesq_qf_locked;
43573 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43574 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43575 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43576 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43577 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43578 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43579 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43580 + atomic_long_unchecked_t mesq_noop_put_nacked;
43581 + atomic_long_unchecked_t mesq_noop_page_overflow;
43582
43583 };
43584
43585 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43586 tghop_invalidate, mcsop_last};
43587
43588 struct mcs_op_statistic {
43589 - atomic_long_t count;
43590 - atomic_long_t total;
43591 + atomic_long_unchecked_t count;
43592 + atomic_long_unchecked_t total;
43593 unsigned long max;
43594 };
43595
43596 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43597
43598 #define STAT(id) do { \
43599 if (gru_options & OPT_STATS) \
43600 - atomic_long_inc(&gru_stats.id); \
43601 + atomic_long_inc_unchecked(&gru_stats.id); \
43602 } while (0)
43603
43604 #ifdef CONFIG_SGI_GRU_DEBUG
43605 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43606 index c862cd4..0d176fe 100644
43607 --- a/drivers/misc/sgi-xp/xp.h
43608 +++ b/drivers/misc/sgi-xp/xp.h
43609 @@ -288,7 +288,7 @@ struct xpc_interface {
43610 xpc_notify_func, void *);
43611 void (*received) (short, int, void *);
43612 enum xp_retval (*partid_to_nasids) (short, void *);
43613 -};
43614 +} __no_const;
43615
43616 extern struct xpc_interface xpc_interface;
43617
43618 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43619 index b94d5f7..7f494c5 100644
43620 --- a/drivers/misc/sgi-xp/xpc.h
43621 +++ b/drivers/misc/sgi-xp/xpc.h
43622 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43623 void (*received_payload) (struct xpc_channel *, void *);
43624 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43625 };
43626 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43627
43628 /* struct xpc_partition act_state values (for XPC HB) */
43629
43630 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43631 /* found in xpc_main.c */
43632 extern struct device *xpc_part;
43633 extern struct device *xpc_chan;
43634 -extern struct xpc_arch_operations xpc_arch_ops;
43635 +extern xpc_arch_operations_no_const xpc_arch_ops;
43636 extern int xpc_disengage_timelimit;
43637 extern int xpc_disengage_timedout;
43638 extern int xpc_activate_IRQ_rcvd;
43639 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43640 index 82dc574..8539ab2 100644
43641 --- a/drivers/misc/sgi-xp/xpc_main.c
43642 +++ b/drivers/misc/sgi-xp/xpc_main.c
43643 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43644 .notifier_call = xpc_system_die,
43645 };
43646
43647 -struct xpc_arch_operations xpc_arch_ops;
43648 +xpc_arch_operations_no_const xpc_arch_ops;
43649
43650 /*
43651 * Timer function to enforce the timelimit on the partition disengage.
43652 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43653
43654 if (((die_args->trapnr == X86_TRAP_MF) ||
43655 (die_args->trapnr == X86_TRAP_XF)) &&
43656 - !user_mode_vm(die_args->regs))
43657 + !user_mode(die_args->regs))
43658 xpc_die_deactivate();
43659
43660 break;
43661 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43662 index 837fc73..acb5862 100644
43663 --- a/drivers/mmc/core/mmc_ops.c
43664 +++ b/drivers/mmc/core/mmc_ops.c
43665 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43666 void *data_buf;
43667 int is_on_stack;
43668
43669 - is_on_stack = object_is_on_stack(buf);
43670 + is_on_stack = object_starts_on_stack(buf);
43671 if (is_on_stack) {
43672 /*
43673 * dma onto stack is unsafe/nonportable, but callers to this
43674 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43675 index 81b2994..dce857e 100644
43676 --- a/drivers/mmc/host/dw_mmc.h
43677 +++ b/drivers/mmc/host/dw_mmc.h
43678 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43679 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43680 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43681 int (*parse_dt)(struct dw_mci *host);
43682 -};
43683 +} __do_const;
43684 #endif /* _DW_MMC_H_ */
43685 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43686 index c3785ed..1984c44 100644
43687 --- a/drivers/mmc/host/mmci.c
43688 +++ b/drivers/mmc/host/mmci.c
43689 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43690 }
43691
43692 if (variant->busy_detect) {
43693 - mmci_ops.card_busy = mmci_card_busy;
43694 + pax_open_kernel();
43695 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43696 + pax_close_kernel();
43697 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43698 }
43699
43700 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43701 index 926aaf6..8e153e2 100644
43702 --- a/drivers/mmc/host/sdhci-s3c.c
43703 +++ b/drivers/mmc/host/sdhci-s3c.c
43704 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43705 * we can use overriding functions instead of default.
43706 */
43707 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43708 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43709 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43710 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43711 + pax_open_kernel();
43712 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43713 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43714 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43715 + pax_close_kernel();
43716 }
43717
43718 /* It supports additional host capabilities if needed */
43719 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
43720 index 096993f..f02c23b 100644
43721 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
43722 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
43723 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43724 size_t totlen = 0, thislen;
43725 int ret = 0;
43726 size_t buflen = 0;
43727 - static char *buffer;
43728 + char *buffer;
43729
43730 if (!ECCBUF_SIZE) {
43731 /* We should fall back to a general writev implementation.
43732 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43733 index 0c8bb6b..6f35deb 100644
43734 --- a/drivers/mtd/nand/denali.c
43735 +++ b/drivers/mtd/nand/denali.c
43736 @@ -24,6 +24,7 @@
43737 #include <linux/slab.h>
43738 #include <linux/mtd/mtd.h>
43739 #include <linux/module.h>
43740 +#include <linux/slab.h>
43741
43742 #include "denali.h"
43743
43744 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43745 index 51b9d6a..52af9a7 100644
43746 --- a/drivers/mtd/nftlmount.c
43747 +++ b/drivers/mtd/nftlmount.c
43748 @@ -24,6 +24,7 @@
43749 #include <asm/errno.h>
43750 #include <linux/delay.h>
43751 #include <linux/slab.h>
43752 +#include <linux/sched.h>
43753 #include <linux/mtd/mtd.h>
43754 #include <linux/mtd/nand.h>
43755 #include <linux/mtd/nftl.h>
43756 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43757 index f9d5615..99dd95f 100644
43758 --- a/drivers/mtd/sm_ftl.c
43759 +++ b/drivers/mtd/sm_ftl.c
43760 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43761 #define SM_CIS_VENDOR_OFFSET 0x59
43762 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43763 {
43764 - struct attribute_group *attr_group;
43765 + attribute_group_no_const *attr_group;
43766 struct attribute **attributes;
43767 struct sm_sysfs_attribute *vendor_attribute;
43768
43769 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43770 index 5e31046..82f8ddc 100644
43771 --- a/drivers/net/bonding/bond_main.c
43772 +++ b/drivers/net/bonding/bond_main.c
43773 @@ -4839,7 +4839,7 @@ static unsigned int bond_get_num_tx_queues(void)
43774 return tx_queues;
43775 }
43776
43777 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43778 +static struct rtnl_link_ops bond_link_ops = {
43779 .kind = "bond",
43780 .priv_size = sizeof(struct bonding),
43781 .setup = bond_setup,
43782 @@ -4964,8 +4964,8 @@ static void __exit bonding_exit(void)
43783
43784 bond_destroy_debugfs();
43785
43786 - rtnl_link_unregister(&bond_link_ops);
43787 unregister_pernet_subsys(&bond_net_ops);
43788 + rtnl_link_unregister(&bond_link_ops);
43789
43790 #ifdef CONFIG_NET_POLL_CONTROLLER
43791 /*
43792 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43793 index e1d2643..7f4133b 100644
43794 --- a/drivers/net/ethernet/8390/ax88796.c
43795 +++ b/drivers/net/ethernet/8390/ax88796.c
43796 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43797 if (ax->plat->reg_offsets)
43798 ei_local->reg_offset = ax->plat->reg_offsets;
43799 else {
43800 + resource_size_t _mem_size = mem_size;
43801 + do_div(_mem_size, 0x18);
43802 ei_local->reg_offset = ax->reg_offsets;
43803 for (ret = 0; ret < 0x18; ret++)
43804 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43805 + ax->reg_offsets[ret] = _mem_size * ret;
43806 }
43807
43808 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43809 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43810 index c07a6d0..ca88c45 100644
43811 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43812 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43813 @@ -1137,7 +1137,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43814 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43815 {
43816 /* RX_MODE controlling object */
43817 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43818 + bnx2x_init_rx_mode_obj(bp);
43819
43820 /* multicast configuration controlling object */
43821 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43822 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43823 index 8f03c98..dd0ef10 100644
43824 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43825 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43826 @@ -2345,15 +2345,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43827 return rc;
43828 }
43829
43830 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43831 - struct bnx2x_rx_mode_obj *o)
43832 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43833 {
43834 if (CHIP_IS_E1x(bp)) {
43835 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43836 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43837 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43838 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43839 } else {
43840 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43841 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43842 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43843 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43844 }
43845 }
43846
43847 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43848 index 798dfe9..05d0a44 100644
43849 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43850 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43851 @@ -1311,8 +1311,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43852
43853 /********************* RX MODE ****************/
43854
43855 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43856 - struct bnx2x_rx_mode_obj *o);
43857 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43858
43859 /**
43860 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43861 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43862 index cd63d11..b67dd78 100644
43863 --- a/drivers/net/ethernet/broadcom/tg3.h
43864 +++ b/drivers/net/ethernet/broadcom/tg3.h
43865 @@ -147,6 +147,7 @@
43866 #define CHIPREV_ID_5750_A0 0x4000
43867 #define CHIPREV_ID_5750_A1 0x4001
43868 #define CHIPREV_ID_5750_A3 0x4003
43869 +#define CHIPREV_ID_5750_C1 0x4201
43870 #define CHIPREV_ID_5750_C2 0x4202
43871 #define CHIPREV_ID_5752_A0_HW 0x5000
43872 #define CHIPREV_ID_5752_A0 0x6000
43873 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43874 index 8cffcdf..aadf043 100644
43875 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43876 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43877 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
43878 */
43879 struct l2t_skb_cb {
43880 arp_failure_handler_func arp_failure_handler;
43881 -};
43882 +} __no_const;
43883
43884 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
43885
43886 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43887 index 5a3256b..60f16d8 100644
43888 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43889 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43890 @@ -2177,7 +2177,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
43891
43892 int i;
43893 struct adapter *ap = netdev2adap(dev);
43894 - static const unsigned int *reg_ranges;
43895 + const unsigned int *reg_ranges;
43896 int arr_size = 0, buf_size = 0;
43897
43898 if (is_t4(ap->chip)) {
43899 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
43900 index 4c83003..2a2a5b9 100644
43901 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
43902 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
43903 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43904 for (i=0; i<ETH_ALEN; i++) {
43905 tmp.addr[i] = dev->dev_addr[i];
43906 }
43907 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43908 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43909 break;
43910
43911 case DE4X5_SET_HWADDR: /* Set the hardware address */
43912 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43913 spin_lock_irqsave(&lp->lock, flags);
43914 memcpy(&statbuf, &lp->pktStats, ioc->len);
43915 spin_unlock_irqrestore(&lp->lock, flags);
43916 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
43917 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
43918 return -EFAULT;
43919 break;
43920 }
43921 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
43922 index 3d91a5e..1014702 100644
43923 --- a/drivers/net/ethernet/emulex/benet/be_main.c
43924 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
43925 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
43926
43927 if (wrapped)
43928 newacc += 65536;
43929 - ACCESS_ONCE(*acc) = newacc;
43930 + ACCESS_ONCE_RW(*acc) = newacc;
43931 }
43932
43933 void populate_erx_stats(struct be_adapter *adapter,
43934 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
43935 index 934e1ae..b262e6b 100644
43936 --- a/drivers/net/ethernet/faraday/ftgmac100.c
43937 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
43938 @@ -31,6 +31,8 @@
43939 #include <linux/netdevice.h>
43940 #include <linux/phy.h>
43941 #include <linux/platform_device.h>
43942 +#include <linux/interrupt.h>
43943 +#include <linux/irqreturn.h>
43944 #include <net/ip.h>
43945
43946 #include "ftgmac100.h"
43947 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
43948 index 4658f4c..407d155 100644
43949 --- a/drivers/net/ethernet/faraday/ftmac100.c
43950 +++ b/drivers/net/ethernet/faraday/ftmac100.c
43951 @@ -31,6 +31,8 @@
43952 #include <linux/module.h>
43953 #include <linux/netdevice.h>
43954 #include <linux/platform_device.h>
43955 +#include <linux/interrupt.h>
43956 +#include <linux/irqreturn.h>
43957
43958 #include "ftmac100.h"
43959
43960 diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
43961 index 85fe7b5..e2da180 100644
43962 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
43963 +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
43964 @@ -2637,6 +2637,8 @@ static int igb_set_eee(struct net_device *netdev,
43965 (hw->phy.media_type != e1000_media_type_copper))
43966 return -EOPNOTSUPP;
43967
43968 + memset(&eee_curr, 0, sizeof(struct ethtool_eee));
43969 +
43970 ret_val = igb_get_eee(netdev, &eee_curr);
43971 if (ret_val)
43972 return ret_val;
43973 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43974 index 331987d..3be1135 100644
43975 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43976 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43977 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
43978 }
43979
43980 /* update the base incval used to calculate frequency adjustment */
43981 - ACCESS_ONCE(adapter->base_incval) = incval;
43982 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
43983 smp_mb();
43984
43985 /* need lock to prevent incorrect read while modifying cyclecounter */
43986 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43987 index fbe5363..266b4e3 100644
43988 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
43989 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43990 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
43991 struct __vxge_hw_fifo *fifo;
43992 struct vxge_hw_fifo_config *config;
43993 u32 txdl_size, txdl_per_memblock;
43994 - struct vxge_hw_mempool_cbs fifo_mp_callback;
43995 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
43996 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
43997 + };
43998 +
43999 struct __vxge_hw_virtualpath *vpath;
44000
44001 if ((vp == NULL) || (attr == NULL)) {
44002 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44003 goto exit;
44004 }
44005
44006 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44007 -
44008 fifo->mempool =
44009 __vxge_hw_mempool_create(vpath->hldev,
44010 fifo->config->memblock_size,
44011 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44012 index 345d987..af69721 100644
44013 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44014 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44015 @@ -2011,7 +2011,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
44016 op_mode = QLC_83XX_DEFAULT_OPMODE;
44017
44018 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
44019 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44020 + pax_open_kernel();
44021 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44022 + pax_close_kernel();
44023 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44024 } else {
44025 return -EIO;
44026 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44027 index 599d1fd..59868fe 100644
44028 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44029 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44030 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44031 case QLCNIC_NON_PRIV_FUNC:
44032 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44033 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44034 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44035 + pax_open_kernel();
44036 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44037 + pax_close_kernel();
44038 break;
44039 case QLCNIC_PRIV_FUNC:
44040 ahw->op_mode = QLCNIC_PRIV_FUNC;
44041 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44042 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44043 + pax_open_kernel();
44044 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44045 + pax_close_kernel();
44046 break;
44047 case QLCNIC_MGMT_FUNC:
44048 ahw->op_mode = QLCNIC_MGMT_FUNC;
44049 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44050 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44051 + pax_open_kernel();
44052 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44053 + pax_close_kernel();
44054 break;
44055 default:
44056 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44057 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44058 index 79e54ef..dec4019 100644
44059 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44060 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44061 @@ -1105,7 +1105,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
44062 struct qlcnic_dump_entry *entry;
44063 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
44064 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
44065 - static const struct qlcnic_dump_operations *fw_dump_ops;
44066 + const struct qlcnic_dump_operations *fw_dump_ops;
44067 struct device *dev = &adapter->pdev->dev;
44068 struct qlcnic_hardware_context *ahw;
44069 void *temp_buffer;
44070 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44071 index 7ba68e0..618c73d 100644
44072 --- a/drivers/net/ethernet/realtek/r8169.c
44073 +++ b/drivers/net/ethernet/realtek/r8169.c
44074 @@ -759,22 +759,22 @@ struct rtl8169_private {
44075 struct mdio_ops {
44076 void (*write)(struct rtl8169_private *, int, int);
44077 int (*read)(struct rtl8169_private *, int);
44078 - } mdio_ops;
44079 + } __no_const mdio_ops;
44080
44081 struct pll_power_ops {
44082 void (*down)(struct rtl8169_private *);
44083 void (*up)(struct rtl8169_private *);
44084 - } pll_power_ops;
44085 + } __no_const pll_power_ops;
44086
44087 struct jumbo_ops {
44088 void (*enable)(struct rtl8169_private *);
44089 void (*disable)(struct rtl8169_private *);
44090 - } jumbo_ops;
44091 + } __no_const jumbo_ops;
44092
44093 struct csi_ops {
44094 void (*write)(struct rtl8169_private *, int, int);
44095 u32 (*read)(struct rtl8169_private *, int);
44096 - } csi_ops;
44097 + } __no_const csi_ops;
44098
44099 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44100 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44101 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44102 index b495394..0748c54 100644
44103 --- a/drivers/net/ethernet/sfc/ptp.c
44104 +++ b/drivers/net/ethernet/sfc/ptp.c
44105 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44106 (u32)((u64)ptp->start.dma_addr >> 32));
44107
44108 /* Clear flag that signals MC ready */
44109 - ACCESS_ONCE(*start) = 0;
44110 + ACCESS_ONCE_RW(*start) = 0;
44111 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44112 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44113
44114 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44115 index 50617c5..b13724c 100644
44116 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44117 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44118 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44119
44120 writel(value, ioaddr + MMC_CNTRL);
44121
44122 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44123 - MMC_CNTRL, value);
44124 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44125 +// MMC_CNTRL, value);
44126 }
44127
44128 /* To mask all all interrupts.*/
44129 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44130 index e6fe0d8..2b7d752 100644
44131 --- a/drivers/net/hyperv/hyperv_net.h
44132 +++ b/drivers/net/hyperv/hyperv_net.h
44133 @@ -101,7 +101,7 @@ struct rndis_device {
44134
44135 enum rndis_device_state state;
44136 bool link_state;
44137 - atomic_t new_req_id;
44138 + atomic_unchecked_t new_req_id;
44139
44140 spinlock_t request_lock;
44141 struct list_head req_list;
44142 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44143 index 0775f0a..d4fb316 100644
44144 --- a/drivers/net/hyperv/rndis_filter.c
44145 +++ b/drivers/net/hyperv/rndis_filter.c
44146 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44147 * template
44148 */
44149 set = &rndis_msg->msg.set_req;
44150 - set->req_id = atomic_inc_return(&dev->new_req_id);
44151 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44152
44153 /* Add to the request list */
44154 spin_lock_irqsave(&dev->request_lock, flags);
44155 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44156
44157 /* Setup the rndis set */
44158 halt = &request->request_msg.msg.halt_req;
44159 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44160 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44161
44162 /* Ignore return since this msg is optional. */
44163 rndis_filter_send_request(dev, request);
44164 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44165 index bf0d55e..82bcfbd1 100644
44166 --- a/drivers/net/ieee802154/fakehard.c
44167 +++ b/drivers/net/ieee802154/fakehard.c
44168 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44169 phy->transmit_power = 0xbf;
44170
44171 dev->netdev_ops = &fake_ops;
44172 - dev->ml_priv = &fake_mlme;
44173 + dev->ml_priv = (void *)&fake_mlme;
44174
44175 priv = netdev_priv(dev);
44176 priv->phy = phy;
44177 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44178 index 16b43bf..ead0c35 100644
44179 --- a/drivers/net/macvlan.c
44180 +++ b/drivers/net/macvlan.c
44181 @@ -934,13 +934,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44182 int macvlan_link_register(struct rtnl_link_ops *ops)
44183 {
44184 /* common fields */
44185 - ops->priv_size = sizeof(struct macvlan_dev);
44186 - ops->validate = macvlan_validate;
44187 - ops->maxtype = IFLA_MACVLAN_MAX;
44188 - ops->policy = macvlan_policy;
44189 - ops->changelink = macvlan_changelink;
44190 - ops->get_size = macvlan_get_size;
44191 - ops->fill_info = macvlan_fill_info;
44192 + pax_open_kernel();
44193 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44194 + *(void **)&ops->validate = macvlan_validate;
44195 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44196 + *(const void **)&ops->policy = macvlan_policy;
44197 + *(void **)&ops->changelink = macvlan_changelink;
44198 + *(void **)&ops->get_size = macvlan_get_size;
44199 + *(void **)&ops->fill_info = macvlan_fill_info;
44200 + pax_close_kernel();
44201
44202 return rtnl_link_register(ops);
44203 };
44204 @@ -996,7 +998,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44205 return NOTIFY_DONE;
44206 }
44207
44208 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44209 +static struct notifier_block macvlan_notifier_block = {
44210 .notifier_call = macvlan_device_event,
44211 };
44212
44213 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44214 index ea53abb..2e4d087 100644
44215 --- a/drivers/net/macvtap.c
44216 +++ b/drivers/net/macvtap.c
44217 @@ -1286,7 +1286,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44218 return NOTIFY_DONE;
44219 }
44220
44221 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44222 +static struct notifier_block macvtap_notifier_block = {
44223 .notifier_call = macvtap_device_event,
44224 };
44225
44226 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44227 index daec9b0..6428fcb 100644
44228 --- a/drivers/net/phy/mdio-bitbang.c
44229 +++ b/drivers/net/phy/mdio-bitbang.c
44230 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44231 struct mdiobb_ctrl *ctrl = bus->priv;
44232
44233 module_put(ctrl->ops->owner);
44234 + mdiobus_unregister(bus);
44235 mdiobus_free(bus);
44236 }
44237 EXPORT_SYMBOL(free_mdio_bitbang);
44238 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44239 index 72ff14b..11d442d 100644
44240 --- a/drivers/net/ppp/ppp_generic.c
44241 +++ b/drivers/net/ppp/ppp_generic.c
44242 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44243 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44244 struct ppp_stats stats;
44245 struct ppp_comp_stats cstats;
44246 - char *vers;
44247
44248 switch (cmd) {
44249 case SIOCGPPPSTATS:
44250 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44251 break;
44252
44253 case SIOCGPPPVER:
44254 - vers = PPP_VERSION;
44255 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44256 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44257 break;
44258 err = 0;
44259 break;
44260 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44261 index 1252d9c..80e660b 100644
44262 --- a/drivers/net/slip/slhc.c
44263 +++ b/drivers/net/slip/slhc.c
44264 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44265 register struct tcphdr *thp;
44266 register struct iphdr *ip;
44267 register struct cstate *cs;
44268 - int len, hdrlen;
44269 + long len, hdrlen;
44270 unsigned char *cp = icp;
44271
44272 /* We've got a compressed packet; read the change byte */
44273 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44274 index bff7e0b..7315137 100644
44275 --- a/drivers/net/team/team.c
44276 +++ b/drivers/net/team/team.c
44277 @@ -2702,7 +2702,7 @@ static int team_device_event(struct notifier_block *unused,
44278 return NOTIFY_DONE;
44279 }
44280
44281 -static struct notifier_block team_notifier_block __read_mostly = {
44282 +static struct notifier_block team_notifier_block = {
44283 .notifier_call = team_device_event,
44284 };
44285
44286 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44287 index 68b9aa3..b3c20f3 100644
44288 --- a/drivers/net/tun.c
44289 +++ b/drivers/net/tun.c
44290 @@ -1874,7 +1874,7 @@ unlock:
44291 }
44292
44293 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44294 - unsigned long arg, int ifreq_len)
44295 + unsigned long arg, size_t ifreq_len)
44296 {
44297 struct tun_file *tfile = file->private_data;
44298 struct tun_struct *tun;
44299 @@ -1886,6 +1886,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44300 int vnet_hdr_sz;
44301 int ret;
44302
44303 + if (ifreq_len > sizeof ifr)
44304 + return -EFAULT;
44305 +
44306 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44307 if (copy_from_user(&ifr, argp, ifreq_len))
44308 return -EFAULT;
44309 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44310 index 86292e6..8d34433 100644
44311 --- a/drivers/net/usb/hso.c
44312 +++ b/drivers/net/usb/hso.c
44313 @@ -71,7 +71,7 @@
44314 #include <asm/byteorder.h>
44315 #include <linux/serial_core.h>
44316 #include <linux/serial.h>
44317 -
44318 +#include <asm/local.h>
44319
44320 #define MOD_AUTHOR "Option Wireless"
44321 #define MOD_DESCRIPTION "USB High Speed Option driver"
44322 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44323 struct urb *urb;
44324
44325 urb = serial->rx_urb[0];
44326 - if (serial->port.count > 0) {
44327 + if (atomic_read(&serial->port.count) > 0) {
44328 count = put_rxbuf_data(urb, serial);
44329 if (count == -1)
44330 return;
44331 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44332 DUMP1(urb->transfer_buffer, urb->actual_length);
44333
44334 /* Anyone listening? */
44335 - if (serial->port.count == 0)
44336 + if (atomic_read(&serial->port.count) == 0)
44337 return;
44338
44339 if (status == 0) {
44340 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44341 tty_port_tty_set(&serial->port, tty);
44342
44343 /* check for port already opened, if not set the termios */
44344 - serial->port.count++;
44345 - if (serial->port.count == 1) {
44346 + if (atomic_inc_return(&serial->port.count) == 1) {
44347 serial->rx_state = RX_IDLE;
44348 /* Force default termio settings */
44349 _hso_serial_set_termios(tty, NULL);
44350 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44351 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44352 if (result) {
44353 hso_stop_serial_device(serial->parent);
44354 - serial->port.count--;
44355 + atomic_dec(&serial->port.count);
44356 kref_put(&serial->parent->ref, hso_serial_ref_free);
44357 }
44358 } else {
44359 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44360
44361 /* reset the rts and dtr */
44362 /* do the actual close */
44363 - serial->port.count--;
44364 + atomic_dec(&serial->port.count);
44365
44366 - if (serial->port.count <= 0) {
44367 - serial->port.count = 0;
44368 + if (atomic_read(&serial->port.count) <= 0) {
44369 + atomic_set(&serial->port.count, 0);
44370 tty_port_tty_set(&serial->port, NULL);
44371 if (!usb_gone)
44372 hso_stop_serial_device(serial->parent);
44373 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44374
44375 /* the actual setup */
44376 spin_lock_irqsave(&serial->serial_lock, flags);
44377 - if (serial->port.count)
44378 + if (atomic_read(&serial->port.count))
44379 _hso_serial_set_termios(tty, old);
44380 else
44381 tty->termios = *old;
44382 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44383 D1("Pending read interrupt on port %d\n", i);
44384 spin_lock(&serial->serial_lock);
44385 if (serial->rx_state == RX_IDLE &&
44386 - serial->port.count > 0) {
44387 + atomic_read(&serial->port.count) > 0) {
44388 /* Setup and send a ctrl req read on
44389 * port i */
44390 if (!serial->rx_urb_filled[0]) {
44391 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44392 /* Start all serial ports */
44393 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44394 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44395 - if (dev2ser(serial_table[i])->port.count) {
44396 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44397 result =
44398 hso_start_serial_device(serial_table[i], GFP_NOIO);
44399 hso_kick_transmit(dev2ser(serial_table[i]));
44400 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44401 index a79e9d3..78cd4fa 100644
44402 --- a/drivers/net/usb/sierra_net.c
44403 +++ b/drivers/net/usb/sierra_net.c
44404 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44405 /* atomic counter partially included in MAC address to make sure 2 devices
44406 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44407 */
44408 -static atomic_t iface_counter = ATOMIC_INIT(0);
44409 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44410
44411 /*
44412 * SYNC Timer Delay definition used to set the expiry time
44413 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44414 dev->net->netdev_ops = &sierra_net_device_ops;
44415
44416 /* change MAC addr to include, ifacenum, and to be unique */
44417 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44418 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44419 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44420
44421 /* we will have to manufacture ethernet headers, prepare template */
44422 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44423 index 8a05d77..ba8b9c5 100644
44424 --- a/drivers/net/vxlan.c
44425 +++ b/drivers/net/vxlan.c
44426 @@ -1870,7 +1870,7 @@ nla_put_failure:
44427 return -EMSGSIZE;
44428 }
44429
44430 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44431 +static struct rtnl_link_ops vxlan_link_ops = {
44432 .kind = "vxlan",
44433 .maxtype = IFLA_VXLAN_MAX,
44434 .policy = vxlan_policy,
44435 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44436 index 0b60295..b8bfa5b 100644
44437 --- a/drivers/net/wimax/i2400m/rx.c
44438 +++ b/drivers/net/wimax/i2400m/rx.c
44439 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44440 if (i2400m->rx_roq == NULL)
44441 goto error_roq_alloc;
44442
44443 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44444 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44445 GFP_KERNEL);
44446 if (rd == NULL) {
44447 result = -ENOMEM;
44448 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44449 index d0adbaf..6cedbf0 100644
44450 --- a/drivers/net/wireless/airo.c
44451 +++ b/drivers/net/wireless/airo.c
44452 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44453 struct airo_info *ai = dev->ml_priv;
44454 int ridcode;
44455 int enabled;
44456 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44457 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44458 unsigned char *iobuf;
44459
44460 /* Only super-user can write RIDs */
44461 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44462 index 34c8a33..3261fdc 100644
44463 --- a/drivers/net/wireless/at76c50x-usb.c
44464 +++ b/drivers/net/wireless/at76c50x-usb.c
44465 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44466 }
44467
44468 /* Convert timeout from the DFU status to jiffies */
44469 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44470 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44471 {
44472 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44473 | (s->poll_timeout[1] << 8)
44474 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
44475 index 2b3426b..1f564be 100644
44476 --- a/drivers/net/wireless/ath/ath10k/core.c
44477 +++ b/drivers/net/wireless/ath/ath10k/core.c
44478 @@ -507,7 +507,9 @@ EXPORT_SYMBOL(ath10k_core_destroy);
44479
44480 int ath10k_core_register(struct ath10k *ar)
44481 {
44482 - struct ath10k_htc_ops htc_ops;
44483 + static struct ath10k_htc_ops htc_ops = {
44484 + .target_send_suspend_complete = ath10k_send_suspend_complete,
44485 + };
44486 struct bmi_target_info target_info;
44487 int status;
44488
44489 @@ -536,8 +538,6 @@ int ath10k_core_register(struct ath10k *ar)
44490 if (status)
44491 goto err;
44492
44493 - htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete;
44494 -
44495 ar->htc = ath10k_htc_create(ar, &htc_ops);
44496 if (IS_ERR(ar->htc)) {
44497 status = PTR_ERR(ar->htc);
44498 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44499 index 74363c9..237b926 100644
44500 --- a/drivers/net/wireless/ath/ath10k/htc.c
44501 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44502 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44503 struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44504 struct ath10k_htc_ops *htc_ops)
44505 {
44506 - struct ath10k_hif_cb htc_callbacks;
44507 + static struct ath10k_hif_cb htc_callbacks = {
44508 + .rx_completion = ath10k_htc_rx_completion_handler,
44509 + .tx_completion = ath10k_htc_tx_completion_handler,
44510 + };
44511 struct ath10k_htc_ep *ep = NULL;
44512 struct ath10k_htc *htc = NULL;
44513
44514 @@ -979,8 +982,6 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44515 ath10k_htc_reset_endpoint_states(htc);
44516
44517 /* setup HIF layer callbacks */
44518 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44519 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44520 htc->ar = ar;
44521
44522 /* Get HIF default pipe for HTC message exchange */
44523 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44524 index 8d78253..bebbb68 100644
44525 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44526 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44527 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44528 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44529 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44530
44531 - ACCESS_ONCE(ads->ds_link) = i->link;
44532 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44533 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44534 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44535
44536 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44537 ctl6 = SM(i->keytype, AR_EncrType);
44538 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44539
44540 if ((i->is_first || i->is_last) &&
44541 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44542 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44543 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44544 | set11nTries(i->rates, 1)
44545 | set11nTries(i->rates, 2)
44546 | set11nTries(i->rates, 3)
44547 | (i->dur_update ? AR_DurUpdateEna : 0)
44548 | SM(0, AR_BurstDur);
44549
44550 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44551 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44552 | set11nRate(i->rates, 1)
44553 | set11nRate(i->rates, 2)
44554 | set11nRate(i->rates, 3);
44555 } else {
44556 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44557 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44558 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44559 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44560 }
44561
44562 if (!i->is_first) {
44563 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44564 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44565 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44566 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44567 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44568 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44569 return;
44570 }
44571
44572 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44573 break;
44574 }
44575
44576 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44577 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44578 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44579 | SM(i->txpower, AR_XmitPower)
44580 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44581 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44582 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44583 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44584
44585 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44586 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44587 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44588 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44589
44590 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44591 return;
44592
44593 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44594 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44595 | set11nPktDurRTSCTS(i->rates, 1);
44596
44597 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44598 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44599 | set11nPktDurRTSCTS(i->rates, 3);
44600
44601 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44602 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44603 | set11nRateFlags(i->rates, 1)
44604 | set11nRateFlags(i->rates, 2)
44605 | set11nRateFlags(i->rates, 3)
44606 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44607 index 5163abd..3ada4c2 100644
44608 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44609 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44610 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44611 (i->qcu << AR_TxQcuNum_S) | desc_len;
44612
44613 checksum += val;
44614 - ACCESS_ONCE(ads->info) = val;
44615 + ACCESS_ONCE_RW(ads->info) = val;
44616
44617 checksum += i->link;
44618 - ACCESS_ONCE(ads->link) = i->link;
44619 + ACCESS_ONCE_RW(ads->link) = i->link;
44620
44621 checksum += i->buf_addr[0];
44622 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44623 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44624 checksum += i->buf_addr[1];
44625 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44626 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44627 checksum += i->buf_addr[2];
44628 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44629 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44630 checksum += i->buf_addr[3];
44631 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44632 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44633
44634 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44635 - ACCESS_ONCE(ads->ctl3) = val;
44636 + ACCESS_ONCE_RW(ads->ctl3) = val;
44637 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44638 - ACCESS_ONCE(ads->ctl5) = val;
44639 + ACCESS_ONCE_RW(ads->ctl5) = val;
44640 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44641 - ACCESS_ONCE(ads->ctl7) = val;
44642 + ACCESS_ONCE_RW(ads->ctl7) = val;
44643 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44644 - ACCESS_ONCE(ads->ctl9) = val;
44645 + ACCESS_ONCE_RW(ads->ctl9) = val;
44646
44647 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44648 - ACCESS_ONCE(ads->ctl10) = checksum;
44649 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44650
44651 if (i->is_first || i->is_last) {
44652 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44653 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44654 | set11nTries(i->rates, 1)
44655 | set11nTries(i->rates, 2)
44656 | set11nTries(i->rates, 3)
44657 | (i->dur_update ? AR_DurUpdateEna : 0)
44658 | SM(0, AR_BurstDur);
44659
44660 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44661 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44662 | set11nRate(i->rates, 1)
44663 | set11nRate(i->rates, 2)
44664 | set11nRate(i->rates, 3);
44665 } else {
44666 - ACCESS_ONCE(ads->ctl13) = 0;
44667 - ACCESS_ONCE(ads->ctl14) = 0;
44668 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44669 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44670 }
44671
44672 ads->ctl20 = 0;
44673 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44674
44675 ctl17 = SM(i->keytype, AR_EncrType);
44676 if (!i->is_first) {
44677 - ACCESS_ONCE(ads->ctl11) = 0;
44678 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44679 - ACCESS_ONCE(ads->ctl15) = 0;
44680 - ACCESS_ONCE(ads->ctl16) = 0;
44681 - ACCESS_ONCE(ads->ctl17) = ctl17;
44682 - ACCESS_ONCE(ads->ctl18) = 0;
44683 - ACCESS_ONCE(ads->ctl19) = 0;
44684 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44685 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44686 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44687 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44688 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44689 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44690 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44691 return;
44692 }
44693
44694 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44695 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44696 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44697 | SM(i->txpower, AR_XmitPower)
44698 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44699 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44700 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44701 ctl12 |= SM(val, AR_PAPRDChainMask);
44702
44703 - ACCESS_ONCE(ads->ctl12) = ctl12;
44704 - ACCESS_ONCE(ads->ctl17) = ctl17;
44705 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44706 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44707
44708 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44709 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44710 | set11nPktDurRTSCTS(i->rates, 1);
44711
44712 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44713 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44714 | set11nPktDurRTSCTS(i->rates, 3);
44715
44716 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44717 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44718 | set11nRateFlags(i->rates, 1)
44719 | set11nRateFlags(i->rates, 2)
44720 | set11nRateFlags(i->rates, 3)
44721 | SM(i->rtscts_rate, AR_RTSCTSRate);
44722
44723 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44724 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44725 }
44726
44727 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44728 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44729 index cd74b3a..6a28d24 100644
44730 --- a/drivers/net/wireless/ath/ath9k/hw.h
44731 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44732 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
44733
44734 /* ANI */
44735 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44736 -};
44737 +} __no_const;
44738
44739 /**
44740 * struct ath_spec_scan - parameters for Atheros spectral scan
44741 @@ -721,7 +721,7 @@ struct ath_hw_ops {
44742 struct ath_spec_scan *param);
44743 void (*spectral_scan_trigger)(struct ath_hw *ah);
44744 void (*spectral_scan_wait)(struct ath_hw *ah);
44745 -};
44746 +} __no_const;
44747
44748 struct ath_nf_limits {
44749 s16 max;
44750 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
44751 index 92190da..f3a4c4c 100644
44752 --- a/drivers/net/wireless/b43/phy_lp.c
44753 +++ b/drivers/net/wireless/b43/phy_lp.c
44754 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
44755 {
44756 struct ssb_bus *bus = dev->dev->sdev->bus;
44757
44758 - static const struct b206x_channel *chandata = NULL;
44759 + const struct b206x_channel *chandata = NULL;
44760 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
44761 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
44762 u16 old_comm15, scale;
44763 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44764 index 9581d07..84f6a76 100644
44765 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44766 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44767 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44768 */
44769 if (il3945_mod_params.disable_hw_scan) {
44770 D_INFO("Disabling hw_scan\n");
44771 - il3945_mac_ops.hw_scan = NULL;
44772 + pax_open_kernel();
44773 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44774 + pax_close_kernel();
44775 }
44776
44777 D_INFO("*** LOAD DRIVER ***\n");
44778 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44779 index d532948..e0d8bb1 100644
44780 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44781 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44782 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44783 {
44784 struct iwl_priv *priv = file->private_data;
44785 char buf[64];
44786 - int buf_size;
44787 + size_t buf_size;
44788 u32 offset, len;
44789
44790 memset(buf, 0, sizeof(buf));
44791 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44792 struct iwl_priv *priv = file->private_data;
44793
44794 char buf[8];
44795 - int buf_size;
44796 + size_t buf_size;
44797 u32 reset_flag;
44798
44799 memset(buf, 0, sizeof(buf));
44800 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44801 {
44802 struct iwl_priv *priv = file->private_data;
44803 char buf[8];
44804 - int buf_size;
44805 + size_t buf_size;
44806 int ht40;
44807
44808 memset(buf, 0, sizeof(buf));
44809 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44810 {
44811 struct iwl_priv *priv = file->private_data;
44812 char buf[8];
44813 - int buf_size;
44814 + size_t buf_size;
44815 int value;
44816
44817 memset(buf, 0, sizeof(buf));
44818 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44819 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44820 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44821
44822 -static const char *fmt_value = " %-30s %10u\n";
44823 -static const char *fmt_hex = " %-30s 0x%02X\n";
44824 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44825 -static const char *fmt_header =
44826 +static const char fmt_value[] = " %-30s %10u\n";
44827 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44828 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44829 +static const char fmt_header[] =
44830 "%-32s current cumulative delta max\n";
44831
44832 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44833 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44834 {
44835 struct iwl_priv *priv = file->private_data;
44836 char buf[8];
44837 - int buf_size;
44838 + size_t buf_size;
44839 int clear;
44840
44841 memset(buf, 0, sizeof(buf));
44842 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44843 {
44844 struct iwl_priv *priv = file->private_data;
44845 char buf[8];
44846 - int buf_size;
44847 + size_t buf_size;
44848 int trace;
44849
44850 memset(buf, 0, sizeof(buf));
44851 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44852 {
44853 struct iwl_priv *priv = file->private_data;
44854 char buf[8];
44855 - int buf_size;
44856 + size_t buf_size;
44857 int missed;
44858
44859 memset(buf, 0, sizeof(buf));
44860 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44861
44862 struct iwl_priv *priv = file->private_data;
44863 char buf[8];
44864 - int buf_size;
44865 + size_t buf_size;
44866 int plcp;
44867
44868 memset(buf, 0, sizeof(buf));
44869 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44870
44871 struct iwl_priv *priv = file->private_data;
44872 char buf[8];
44873 - int buf_size;
44874 + size_t buf_size;
44875 int flush;
44876
44877 memset(buf, 0, sizeof(buf));
44878 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44879
44880 struct iwl_priv *priv = file->private_data;
44881 char buf[8];
44882 - int buf_size;
44883 + size_t buf_size;
44884 int rts;
44885
44886 if (!priv->cfg->ht_params)
44887 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44888 {
44889 struct iwl_priv *priv = file->private_data;
44890 char buf[8];
44891 - int buf_size;
44892 + size_t buf_size;
44893
44894 memset(buf, 0, sizeof(buf));
44895 buf_size = min(count, sizeof(buf) - 1);
44896 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44897 struct iwl_priv *priv = file->private_data;
44898 u32 event_log_flag;
44899 char buf[8];
44900 - int buf_size;
44901 + size_t buf_size;
44902
44903 /* check that the interface is up */
44904 if (!iwl_is_ready(priv))
44905 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44906 struct iwl_priv *priv = file->private_data;
44907 char buf[8];
44908 u32 calib_disabled;
44909 - int buf_size;
44910 + size_t buf_size;
44911
44912 memset(buf, 0, sizeof(buf));
44913 buf_size = min(count, sizeof(buf) - 1);
44914 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44915 index 1531a4f..21d2641 100644
44916 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44917 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
44918 @@ -1180,7 +1180,7 @@ static void iwl_option_config(struct iwl_priv *priv)
44919 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44920 {
44921 struct iwl_nvm_data *data = priv->nvm_data;
44922 - char *debug_msg;
44923 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44924
44925 if (data->sku_cap_11n_enable &&
44926 !priv->cfg->ht_params) {
44927 @@ -1194,7 +1194,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44928 return -EINVAL;
44929 }
44930
44931 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44932 IWL_DEBUG_INFO(priv, debug_msg,
44933 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
44934 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
44935 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
44936 index 390e2f0..75cfbaf 100644
44937 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
44938 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
44939 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
44940 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
44941
44942 char buf[8];
44943 - int buf_size;
44944 + size_t buf_size;
44945 u32 reset_flag;
44946
44947 memset(buf, 0, sizeof(buf));
44948 @@ -1371,7 +1371,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
44949 {
44950 struct iwl_trans *trans = file->private_data;
44951 char buf[8];
44952 - int buf_size;
44953 + size_t buf_size;
44954 int csr;
44955
44956 memset(buf, 0, sizeof(buf));
44957 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
44958 index cb34c78..9fec0dc 100644
44959 --- a/drivers/net/wireless/mac80211_hwsim.c
44960 +++ b/drivers/net/wireless/mac80211_hwsim.c
44961 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
44962
44963 if (channels > 1) {
44964 hwsim_if_comb.num_different_channels = channels;
44965 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44966 - mac80211_hwsim_ops.cancel_hw_scan =
44967 - mac80211_hwsim_cancel_hw_scan;
44968 - mac80211_hwsim_ops.sw_scan_start = NULL;
44969 - mac80211_hwsim_ops.sw_scan_complete = NULL;
44970 - mac80211_hwsim_ops.remain_on_channel =
44971 - mac80211_hwsim_roc;
44972 - mac80211_hwsim_ops.cancel_remain_on_channel =
44973 - mac80211_hwsim_croc;
44974 - mac80211_hwsim_ops.add_chanctx =
44975 - mac80211_hwsim_add_chanctx;
44976 - mac80211_hwsim_ops.remove_chanctx =
44977 - mac80211_hwsim_remove_chanctx;
44978 - mac80211_hwsim_ops.change_chanctx =
44979 - mac80211_hwsim_change_chanctx;
44980 - mac80211_hwsim_ops.assign_vif_chanctx =
44981 - mac80211_hwsim_assign_vif_chanctx;
44982 - mac80211_hwsim_ops.unassign_vif_chanctx =
44983 - mac80211_hwsim_unassign_vif_chanctx;
44984 + pax_open_kernel();
44985 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44986 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
44987 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
44988 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
44989 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
44990 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
44991 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
44992 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
44993 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
44994 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
44995 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
44996 + pax_close_kernel();
44997 }
44998
44999 spin_lock_init(&hwsim_radio_lock);
45000 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45001 index 8169a85..7fa3b47 100644
45002 --- a/drivers/net/wireless/rndis_wlan.c
45003 +++ b/drivers/net/wireless/rndis_wlan.c
45004 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45005
45006 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45007
45008 - if (rts_threshold < 0 || rts_threshold > 2347)
45009 + if (rts_threshold > 2347)
45010 rts_threshold = 2347;
45011
45012 tmp = cpu_to_le32(rts_threshold);
45013 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45014 index ee3fc57..ed5ddc9 100644
45015 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45016 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45017 @@ -386,7 +386,7 @@ struct rt2x00_intf {
45018 * for hardware which doesn't support hardware
45019 * sequence counting.
45020 */
45021 - atomic_t seqno;
45022 + atomic_unchecked_t seqno;
45023 };
45024
45025 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45026 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45027 index aa95c6c..a59dd67 100644
45028 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45029 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45030 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45031 * sequence counter given by mac80211.
45032 */
45033 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45034 - seqno = atomic_add_return(0x10, &intf->seqno);
45035 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45036 else
45037 - seqno = atomic_read(&intf->seqno);
45038 + seqno = atomic_read_unchecked(&intf->seqno);
45039
45040 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45041 hdr->seq_ctrl |= cpu_to_le16(seqno);
45042 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45043 index e2b3d9c..67a5184 100644
45044 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45045 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45046 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45047
45048 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45049
45050 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45051 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45052 + pax_open_kernel();
45053 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45054 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45055 + pax_close_kernel();
45056
45057 wl1251_info("using dedicated interrupt line");
45058 } else {
45059 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45060 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45061 + pax_open_kernel();
45062 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45063 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45064 + pax_close_kernel();
45065
45066 wl1251_info("using SDIO interrupt");
45067 }
45068 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45069 index 1c627da..69f7d17 100644
45070 --- a/drivers/net/wireless/ti/wl12xx/main.c
45071 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45072 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45073 sizeof(wl->conf.mem));
45074
45075 /* read data preparation is only needed by wl127x */
45076 - wl->ops->prepare_read = wl127x_prepare_read;
45077 + pax_open_kernel();
45078 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45079 + pax_close_kernel();
45080
45081 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45082 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45083 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45084 sizeof(wl->conf.mem));
45085
45086 /* read data preparation is only needed by wl127x */
45087 - wl->ops->prepare_read = wl127x_prepare_read;
45088 + pax_open_kernel();
45089 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45090 + pax_close_kernel();
45091
45092 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45093 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45094 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45095 index 7aa0eb8..5a9ef38 100644
45096 --- a/drivers/net/wireless/ti/wl18xx/main.c
45097 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45098 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45099 }
45100
45101 if (!checksum_param) {
45102 - wl18xx_ops.set_rx_csum = NULL;
45103 - wl18xx_ops.init_vif = NULL;
45104 + pax_open_kernel();
45105 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45106 + *(void **)&wl18xx_ops.init_vif = NULL;
45107 + pax_close_kernel();
45108 }
45109
45110 /* Enable 11a Band only if we have 5G antennas */
45111 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45112 index 7ef0b4a..ff65c28 100644
45113 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45114 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45115 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45116 {
45117 struct zd_usb *usb = urb->context;
45118 struct zd_usb_interrupt *intr = &usb->intr;
45119 - int len;
45120 + unsigned int len;
45121 u16 int_num;
45122
45123 ZD_ASSERT(in_interrupt());
45124 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
45125 index 59f95d8..53e0e7f 100644
45126 --- a/drivers/nfc/nfcwilink.c
45127 +++ b/drivers/nfc/nfcwilink.c
45128 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
45129
45130 static int nfcwilink_probe(struct platform_device *pdev)
45131 {
45132 - static struct nfcwilink *drv;
45133 + struct nfcwilink *drv;
45134 int rc;
45135 __u32 protocols;
45136
45137 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45138 index d93b2b6..ae50401 100644
45139 --- a/drivers/oprofile/buffer_sync.c
45140 +++ b/drivers/oprofile/buffer_sync.c
45141 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45142 if (cookie == NO_COOKIE)
45143 offset = pc;
45144 if (cookie == INVALID_COOKIE) {
45145 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45146 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45147 offset = pc;
45148 }
45149 if (cookie != last_cookie) {
45150 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45151 /* add userspace sample */
45152
45153 if (!mm) {
45154 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45155 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45156 return 0;
45157 }
45158
45159 cookie = lookup_dcookie(mm, s->eip, &offset);
45160
45161 if (cookie == INVALID_COOKIE) {
45162 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45163 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45164 return 0;
45165 }
45166
45167 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45168 /* ignore backtraces if failed to add a sample */
45169 if (state == sb_bt_start) {
45170 state = sb_bt_ignore;
45171 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45172 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45173 }
45174 }
45175 release_mm(mm);
45176 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45177 index c0cc4e7..44d4e54 100644
45178 --- a/drivers/oprofile/event_buffer.c
45179 +++ b/drivers/oprofile/event_buffer.c
45180 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45181 }
45182
45183 if (buffer_pos == buffer_size) {
45184 - atomic_inc(&oprofile_stats.event_lost_overflow);
45185 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45186 return;
45187 }
45188
45189 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45190 index ed2c3ec..deda85a 100644
45191 --- a/drivers/oprofile/oprof.c
45192 +++ b/drivers/oprofile/oprof.c
45193 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45194 if (oprofile_ops.switch_events())
45195 return;
45196
45197 - atomic_inc(&oprofile_stats.multiplex_counter);
45198 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45199 start_switch_worker();
45200 }
45201
45202 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45203 index 84a208d..d61b0a1 100644
45204 --- a/drivers/oprofile/oprofile_files.c
45205 +++ b/drivers/oprofile/oprofile_files.c
45206 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45207
45208 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45209
45210 -static ssize_t timeout_read(struct file *file, char __user *buf,
45211 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45212 size_t count, loff_t *offset)
45213 {
45214 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45215 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45216 index 917d28e..d62d981 100644
45217 --- a/drivers/oprofile/oprofile_stats.c
45218 +++ b/drivers/oprofile/oprofile_stats.c
45219 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45220 cpu_buf->sample_invalid_eip = 0;
45221 }
45222
45223 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45224 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45225 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45226 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45227 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45228 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45229 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45230 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45231 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45232 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45233 }
45234
45235
45236 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45237 index 38b6fc0..b5cbfce 100644
45238 --- a/drivers/oprofile/oprofile_stats.h
45239 +++ b/drivers/oprofile/oprofile_stats.h
45240 @@ -13,11 +13,11 @@
45241 #include <linux/atomic.h>
45242
45243 struct oprofile_stat_struct {
45244 - atomic_t sample_lost_no_mm;
45245 - atomic_t sample_lost_no_mapping;
45246 - atomic_t bt_lost_no_mapping;
45247 - atomic_t event_lost_overflow;
45248 - atomic_t multiplex_counter;
45249 + atomic_unchecked_t sample_lost_no_mm;
45250 + atomic_unchecked_t sample_lost_no_mapping;
45251 + atomic_unchecked_t bt_lost_no_mapping;
45252 + atomic_unchecked_t event_lost_overflow;
45253 + atomic_unchecked_t multiplex_counter;
45254 };
45255
45256 extern struct oprofile_stat_struct oprofile_stats;
45257 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45258 index 7c12d9c..9f5e825 100644
45259 --- a/drivers/oprofile/oprofilefs.c
45260 +++ b/drivers/oprofile/oprofilefs.c
45261 @@ -177,8 +177,8 @@ int oprofilefs_create_ro_ulong(struct super_block *sb, struct dentry *root,
45262
45263 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
45264 {
45265 - atomic_t *val = file->private_data;
45266 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
45267 + atomic_unchecked_t *val = file->private_data;
45268 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
45269 }
45270
45271
45272 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45273
45274
45275 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45276 - char const *name, atomic_t *val)
45277 + char const *name, atomic_unchecked_t *val)
45278 {
45279 return __oprofilefs_create_file(sb, root, name,
45280 &atomic_ro_fops, 0444, val);
45281 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45282 index 61be1d9..dec05d7 100644
45283 --- a/drivers/oprofile/timer_int.c
45284 +++ b/drivers/oprofile/timer_int.c
45285 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45286 return NOTIFY_OK;
45287 }
45288
45289 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45290 +static struct notifier_block oprofile_cpu_notifier = {
45291 .notifier_call = oprofile_cpu_notify,
45292 };
45293
45294 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45295 index 92ed045..62d39bd7 100644
45296 --- a/drivers/parport/procfs.c
45297 +++ b/drivers/parport/procfs.c
45298 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45299
45300 *ppos += len;
45301
45302 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45303 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45304 }
45305
45306 #ifdef CONFIG_PARPORT_1284
45307 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45308
45309 *ppos += len;
45310
45311 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45312 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45313 }
45314 #endif /* IEEE1284.3 support. */
45315
45316 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45317 index c35e8ad..fc33beb 100644
45318 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45319 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45320 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45321 goto init_cleanup;
45322 }
45323
45324 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45325 + pax_open_kernel();
45326 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45327 + pax_close_kernel();
45328 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45329
45330 return retval;
45331 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45332 index a6a71c4..c91097b 100644
45333 --- a/drivers/pci/hotplug/cpcihp_generic.c
45334 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45335 @@ -73,7 +73,6 @@ static u16 port;
45336 static unsigned int enum_bit;
45337 static u8 enum_mask;
45338
45339 -static struct cpci_hp_controller_ops generic_hpc_ops;
45340 static struct cpci_hp_controller generic_hpc;
45341
45342 static int __init validate_parameters(void)
45343 @@ -139,6 +138,10 @@ static int query_enum(void)
45344 return ((value & enum_mask) == enum_mask);
45345 }
45346
45347 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45348 + .query_enum = query_enum,
45349 +};
45350 +
45351 static int __init cpcihp_generic_init(void)
45352 {
45353 int status;
45354 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45355 pci_dev_put(dev);
45356
45357 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45358 - generic_hpc_ops.query_enum = query_enum;
45359 generic_hpc.ops = &generic_hpc_ops;
45360
45361 status = cpci_hp_register_controller(&generic_hpc);
45362 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45363 index 449b4bb..257e2e8 100644
45364 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45365 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45366 @@ -59,7 +59,6 @@
45367 /* local variables */
45368 static bool debug;
45369 static bool poll;
45370 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45371 static struct cpci_hp_controller zt5550_hpc;
45372
45373 /* Primary cPCI bus bridge device */
45374 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45375 return 0;
45376 }
45377
45378 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45379 + .query_enum = zt5550_hc_query_enum,
45380 +};
45381 +
45382 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45383 {
45384 int status;
45385 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45386 dbg("returned from zt5550_hc_config");
45387
45388 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45389 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45390 zt5550_hpc.ops = &zt5550_hpc_ops;
45391 if(!poll) {
45392 zt5550_hpc.irq = hc_dev->irq;
45393 zt5550_hpc.irq_flags = IRQF_SHARED;
45394 zt5550_hpc.dev_id = hc_dev;
45395
45396 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45397 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45398 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45399 + pax_open_kernel();
45400 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45401 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45402 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45403 + pax_open_kernel();
45404 } else {
45405 info("using ENUM# polling mode");
45406 }
45407 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45408 index 76ba8a1..20ca857 100644
45409 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45410 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45411 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45412
45413 void compaq_nvram_init (void __iomem *rom_start)
45414 {
45415 +
45416 +#ifndef CONFIG_PAX_KERNEXEC
45417 if (rom_start) {
45418 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45419 }
45420 +#endif
45421 +
45422 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45423
45424 /* initialize our int15 lock */
45425 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45426 index ec20f74..c1d961e 100644
45427 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45428 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45429 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45430 return -EINVAL;
45431 }
45432
45433 - slot->ops->owner = owner;
45434 - slot->ops->mod_name = mod_name;
45435 + pax_open_kernel();
45436 + *(struct module **)&slot->ops->owner = owner;
45437 + *(const char **)&slot->ops->mod_name = mod_name;
45438 + pax_close_kernel();
45439
45440 mutex_lock(&pci_hp_mutex);
45441 /*
45442 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45443 index 7d72c5e..edce02c 100644
45444 --- a/drivers/pci/hotplug/pciehp_core.c
45445 +++ b/drivers/pci/hotplug/pciehp_core.c
45446 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45447 struct slot *slot = ctrl->slot;
45448 struct hotplug_slot *hotplug = NULL;
45449 struct hotplug_slot_info *info = NULL;
45450 - struct hotplug_slot_ops *ops = NULL;
45451 + hotplug_slot_ops_no_const *ops = NULL;
45452 char name[SLOT_NAME_SIZE];
45453 int retval = -ENOMEM;
45454
45455 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45456 index c0dbe1f..94cf3d8 100644
45457 --- a/drivers/pci/pci-sysfs.c
45458 +++ b/drivers/pci/pci-sysfs.c
45459 @@ -1073,7 +1073,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45460 {
45461 /* allocate attribute structure, piggyback attribute name */
45462 int name_len = write_combine ? 13 : 10;
45463 - struct bin_attribute *res_attr;
45464 + bin_attribute_no_const *res_attr;
45465 int retval;
45466
45467 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45468 @@ -1258,7 +1258,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45469 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45470 {
45471 int retval;
45472 - struct bin_attribute *attr;
45473 + bin_attribute_no_const *attr;
45474
45475 /* If the device has VPD, try to expose it in sysfs. */
45476 if (dev->vpd) {
45477 @@ -1305,7 +1305,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45478 {
45479 int retval;
45480 int rom_size = 0;
45481 - struct bin_attribute *attr;
45482 + bin_attribute_no_const *attr;
45483
45484 if (!sysfs_initialized)
45485 return -EACCES;
45486 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45487 index d1182c4..2a138ec 100644
45488 --- a/drivers/pci/pci.h
45489 +++ b/drivers/pci/pci.h
45490 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45491 struct pci_vpd {
45492 unsigned int len;
45493 const struct pci_vpd_ops *ops;
45494 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45495 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45496 };
45497
45498 int pci_vpd_pci22_init(struct pci_dev *dev);
45499 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45500 index 403a443..034e050 100644
45501 --- a/drivers/pci/pcie/aspm.c
45502 +++ b/drivers/pci/pcie/aspm.c
45503 @@ -27,9 +27,9 @@
45504 #define MODULE_PARAM_PREFIX "pcie_aspm."
45505
45506 /* Note: those are not register definitions */
45507 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45508 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45509 -#define ASPM_STATE_L1 (4) /* L1 state */
45510 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45511 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45512 +#define ASPM_STATE_L1 (4U) /* L1 state */
45513 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45514 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45515
45516 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45517 index 46ada5c..20da716 100644
45518 --- a/drivers/pci/probe.c
45519 +++ b/drivers/pci/probe.c
45520 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45521 struct pci_bus_region region, inverted_region;
45522 bool bar_too_big = false, bar_disabled = false;
45523
45524 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45525 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45526
45527 /* No printks while decoding is disabled! */
45528 if (!dev->mmio_always_on) {
45529 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45530 index cdc7836..528635c 100644
45531 --- a/drivers/pci/proc.c
45532 +++ b/drivers/pci/proc.c
45533 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45534 static int __init pci_proc_init(void)
45535 {
45536 struct pci_dev *dev = NULL;
45537 +
45538 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45539 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45540 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45541 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45542 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45543 +#endif
45544 +#else
45545 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45546 +#endif
45547 proc_create("devices", 0, proc_bus_pci_dir,
45548 &proc_bus_pci_dev_operations);
45549 proc_initialized = 1;
45550 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45551 index 3e5b4497..dcdfb70 100644
45552 --- a/drivers/platform/x86/chromeos_laptop.c
45553 +++ b/drivers/platform/x86/chromeos_laptop.c
45554 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45555 return 0;
45556 }
45557
45558 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45559 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45560 {
45561 .ident = "Samsung Series 5 550 - Touchpad",
45562 .matches = {
45563 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45564 index 62f8030..c7f2a45 100644
45565 --- a/drivers/platform/x86/msi-laptop.c
45566 +++ b/drivers/platform/x86/msi-laptop.c
45567 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45568
45569 if (!quirks->ec_read_only) {
45570 /* allow userland write sysfs file */
45571 - dev_attr_bluetooth.store = store_bluetooth;
45572 - dev_attr_wlan.store = store_wlan;
45573 - dev_attr_threeg.store = store_threeg;
45574 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45575 - dev_attr_wlan.attr.mode |= S_IWUSR;
45576 - dev_attr_threeg.attr.mode |= S_IWUSR;
45577 + pax_open_kernel();
45578 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45579 + *(void **)&dev_attr_wlan.store = store_wlan;
45580 + *(void **)&dev_attr_threeg.store = store_threeg;
45581 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45582 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45583 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45584 + pax_close_kernel();
45585 }
45586
45587 /* disable hardware control by fn key */
45588 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
45589 index 70222f2..8c8ce66 100644
45590 --- a/drivers/platform/x86/msi-wmi.c
45591 +++ b/drivers/platform/x86/msi-wmi.c
45592 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
45593 static void msi_wmi_notify(u32 value, void *context)
45594 {
45595 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
45596 - static struct key_entry *key;
45597 + struct key_entry *key;
45598 union acpi_object *obj;
45599 acpi_status status;
45600
45601 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45602 index 3a1b6bf..b453930 100644
45603 --- a/drivers/platform/x86/sony-laptop.c
45604 +++ b/drivers/platform/x86/sony-laptop.c
45605 @@ -2486,7 +2486,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45606 }
45607
45608 /* High speed charging function */
45609 -static struct device_attribute *hsc_handle;
45610 +static device_attribute_no_const *hsc_handle;
45611
45612 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45613 struct device_attribute *attr,
45614 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45615 index 54d31c0..3f896d3 100644
45616 --- a/drivers/platform/x86/thinkpad_acpi.c
45617 +++ b/drivers/platform/x86/thinkpad_acpi.c
45618 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
45619 return 0;
45620 }
45621
45622 -void static hotkey_mask_warn_incomplete_mask(void)
45623 +static void hotkey_mask_warn_incomplete_mask(void)
45624 {
45625 /* log only what the user can fix... */
45626 const u32 wantedmask = hotkey_driver_mask &
45627 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45628 }
45629 }
45630
45631 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45632 - struct tp_nvram_state *newn,
45633 - const u32 event_mask)
45634 -{
45635 -
45636 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45637 do { \
45638 if ((event_mask & (1 << __scancode)) && \
45639 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45640 tpacpi_hotkey_send_key(__scancode); \
45641 } while (0)
45642
45643 - void issue_volchange(const unsigned int oldvol,
45644 - const unsigned int newvol)
45645 - {
45646 - unsigned int i = oldvol;
45647 +static void issue_volchange(const unsigned int oldvol,
45648 + const unsigned int newvol,
45649 + const u32 event_mask)
45650 +{
45651 + unsigned int i = oldvol;
45652
45653 - while (i > newvol) {
45654 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45655 - i--;
45656 - }
45657 - while (i < newvol) {
45658 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45659 - i++;
45660 - }
45661 + while (i > newvol) {
45662 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45663 + i--;
45664 }
45665 + while (i < newvol) {
45666 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45667 + i++;
45668 + }
45669 +}
45670
45671 - void issue_brightnesschange(const unsigned int oldbrt,
45672 - const unsigned int newbrt)
45673 - {
45674 - unsigned int i = oldbrt;
45675 +static void issue_brightnesschange(const unsigned int oldbrt,
45676 + const unsigned int newbrt,
45677 + const u32 event_mask)
45678 +{
45679 + unsigned int i = oldbrt;
45680
45681 - while (i > newbrt) {
45682 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45683 - i--;
45684 - }
45685 - while (i < newbrt) {
45686 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45687 - i++;
45688 - }
45689 + while (i > newbrt) {
45690 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45691 + i--;
45692 + }
45693 + while (i < newbrt) {
45694 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45695 + i++;
45696 }
45697 +}
45698
45699 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45700 + struct tp_nvram_state *newn,
45701 + const u32 event_mask)
45702 +{
45703 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45704 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45705 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45706 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45707 oldn->volume_level != newn->volume_level) {
45708 /* recently muted, or repeated mute keypress, or
45709 * multiple presses ending in mute */
45710 - issue_volchange(oldn->volume_level, newn->volume_level);
45711 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45712 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45713 }
45714 } else {
45715 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45716 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45717 }
45718 if (oldn->volume_level != newn->volume_level) {
45719 - issue_volchange(oldn->volume_level, newn->volume_level);
45720 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45721 } else if (oldn->volume_toggle != newn->volume_toggle) {
45722 /* repeated vol up/down keypress at end of scale ? */
45723 if (newn->volume_level == 0)
45724 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45725 /* handle brightness */
45726 if (oldn->brightness_level != newn->brightness_level) {
45727 issue_brightnesschange(oldn->brightness_level,
45728 - newn->brightness_level);
45729 + newn->brightness_level,
45730 + event_mask);
45731 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45732 /* repeated key presses that didn't change state */
45733 if (newn->brightness_level == 0)
45734 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45735 && !tp_features.bright_unkfw)
45736 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45737 }
45738 +}
45739
45740 #undef TPACPI_COMPARE_KEY
45741 #undef TPACPI_MAY_SEND_KEY
45742 -}
45743
45744 /*
45745 * Polling driver
45746 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45747 index 769d265..a3a05ca 100644
45748 --- a/drivers/pnp/pnpbios/bioscalls.c
45749 +++ b/drivers/pnp/pnpbios/bioscalls.c
45750 @@ -58,7 +58,7 @@ do { \
45751 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45752 } while(0)
45753
45754 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45755 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45756 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45757
45758 /*
45759 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45760
45761 cpu = get_cpu();
45762 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45763 +
45764 + pax_open_kernel();
45765 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45766 + pax_close_kernel();
45767
45768 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45769 spin_lock_irqsave(&pnp_bios_lock, flags);
45770 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45771 :"memory");
45772 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45773
45774 + pax_open_kernel();
45775 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45776 + pax_close_kernel();
45777 +
45778 put_cpu();
45779
45780 /* If we get here and this is set then the PnP BIOS faulted on us. */
45781 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45782 return status;
45783 }
45784
45785 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45786 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45787 {
45788 int i;
45789
45790 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45791 pnp_bios_callpoint.offset = header->fields.pm16offset;
45792 pnp_bios_callpoint.segment = PNP_CS16;
45793
45794 + pax_open_kernel();
45795 +
45796 for_each_possible_cpu(i) {
45797 struct desc_struct *gdt = get_cpu_gdt_table(i);
45798 if (!gdt)
45799 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45800 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45801 (unsigned long)__va(header->fields.pm16dseg));
45802 }
45803 +
45804 + pax_close_kernel();
45805 }
45806 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45807 index d95e101..67f0c3f 100644
45808 --- a/drivers/pnp/resource.c
45809 +++ b/drivers/pnp/resource.c
45810 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45811 return 1;
45812
45813 /* check if the resource is valid */
45814 - if (*irq < 0 || *irq > 15)
45815 + if (*irq > 15)
45816 return 0;
45817
45818 /* check if the resource is reserved */
45819 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45820 return 1;
45821
45822 /* check if the resource is valid */
45823 - if (*dma < 0 || *dma == 4 || *dma > 7)
45824 + if (*dma == 4 || *dma > 7)
45825 return 0;
45826
45827 /* check if the resource is reserved */
45828 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45829 index 0c52e2a..3421ab7 100644
45830 --- a/drivers/power/pda_power.c
45831 +++ b/drivers/power/pda_power.c
45832 @@ -37,7 +37,11 @@ static int polling;
45833
45834 #if IS_ENABLED(CONFIG_USB_PHY)
45835 static struct usb_phy *transceiver;
45836 -static struct notifier_block otg_nb;
45837 +static int otg_handle_notification(struct notifier_block *nb,
45838 + unsigned long event, void *unused);
45839 +static struct notifier_block otg_nb = {
45840 + .notifier_call = otg_handle_notification
45841 +};
45842 #endif
45843
45844 static struct regulator *ac_draw;
45845 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45846
45847 #if IS_ENABLED(CONFIG_USB_PHY)
45848 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45849 - otg_nb.notifier_call = otg_handle_notification;
45850 ret = usb_register_notifier(transceiver, &otg_nb);
45851 if (ret) {
45852 dev_err(dev, "failure to register otg notifier\n");
45853 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45854 index cc439fd..8fa30df 100644
45855 --- a/drivers/power/power_supply.h
45856 +++ b/drivers/power/power_supply.h
45857 @@ -16,12 +16,12 @@ struct power_supply;
45858
45859 #ifdef CONFIG_SYSFS
45860
45861 -extern void power_supply_init_attrs(struct device_type *dev_type);
45862 +extern void power_supply_init_attrs(void);
45863 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45864
45865 #else
45866
45867 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45868 +static inline void power_supply_init_attrs(void) {}
45869 #define power_supply_uevent NULL
45870
45871 #endif /* CONFIG_SYSFS */
45872 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45873 index 3b2d5df..3207114 100644
45874 --- a/drivers/power/power_supply_core.c
45875 +++ b/drivers/power/power_supply_core.c
45876 @@ -24,7 +24,10 @@
45877 struct class *power_supply_class;
45878 EXPORT_SYMBOL_GPL(power_supply_class);
45879
45880 -static struct device_type power_supply_dev_type;
45881 +extern const struct attribute_group *power_supply_attr_groups[];
45882 +static struct device_type power_supply_dev_type = {
45883 + .groups = power_supply_attr_groups,
45884 +};
45885
45886 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45887 struct power_supply *supply)
45888 @@ -558,7 +561,7 @@ static int __init power_supply_class_init(void)
45889 return PTR_ERR(power_supply_class);
45890
45891 power_supply_class->dev_uevent = power_supply_uevent;
45892 - power_supply_init_attrs(&power_supply_dev_type);
45893 + power_supply_init_attrs();
45894
45895 return 0;
45896 }
45897 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45898 index 29178f7..c65f324 100644
45899 --- a/drivers/power/power_supply_sysfs.c
45900 +++ b/drivers/power/power_supply_sysfs.c
45901 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45902 .is_visible = power_supply_attr_is_visible,
45903 };
45904
45905 -static const struct attribute_group *power_supply_attr_groups[] = {
45906 +const struct attribute_group *power_supply_attr_groups[] = {
45907 &power_supply_attr_group,
45908 NULL,
45909 };
45910
45911 -void power_supply_init_attrs(struct device_type *dev_type)
45912 +void power_supply_init_attrs(void)
45913 {
45914 int i;
45915
45916 - dev_type->groups = power_supply_attr_groups;
45917 -
45918 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45919 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45920 }
45921 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45922 index 288c75a..065bc84 100644
45923 --- a/drivers/regulator/core.c
45924 +++ b/drivers/regulator/core.c
45925 @@ -3544,7 +3544,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45926 {
45927 const struct regulation_constraints *constraints = NULL;
45928 const struct regulator_init_data *init_data;
45929 - static atomic_t regulator_no = ATOMIC_INIT(0);
45930 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45931 struct regulator_dev *rdev;
45932 struct device *dev;
45933 int ret, i;
45934 @@ -3614,7 +3614,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45935 rdev->dev.of_node = config->of_node;
45936 rdev->dev.parent = dev;
45937 dev_set_name(&rdev->dev, "regulator.%d",
45938 - atomic_inc_return(&regulator_no) - 1);
45939 + atomic_inc_return_unchecked(&regulator_no) - 1);
45940 ret = device_register(&rdev->dev);
45941 if (ret != 0) {
45942 put_device(&rdev->dev);
45943 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45944 index d428ef9..fdc0357 100644
45945 --- a/drivers/regulator/max8660.c
45946 +++ b/drivers/regulator/max8660.c
45947 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
45948 max8660->shadow_regs[MAX8660_OVER1] = 5;
45949 } else {
45950 /* Otherwise devices can be toggled via software */
45951 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45952 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45953 + pax_open_kernel();
45954 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
45955 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
45956 + pax_close_kernel();
45957 }
45958
45959 /*
45960 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
45961 index 0c5195a..637a453d 100644
45962 --- a/drivers/regulator/max8973-regulator.c
45963 +++ b/drivers/regulator/max8973-regulator.c
45964 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
45965 if (!pdata || !pdata->enable_ext_control) {
45966 max->desc.enable_reg = MAX8973_VOUT;
45967 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
45968 - max->ops.enable = regulator_enable_regmap;
45969 - max->ops.disable = regulator_disable_regmap;
45970 - max->ops.is_enabled = regulator_is_enabled_regmap;
45971 + pax_open_kernel();
45972 + *(void **)&max->ops.enable = regulator_enable_regmap;
45973 + *(void **)&max->ops.disable = regulator_disable_regmap;
45974 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
45975 + pax_close_kernel();
45976 }
45977
45978 if (pdata) {
45979 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
45980 index 1037e07..e64dea1 100644
45981 --- a/drivers/regulator/mc13892-regulator.c
45982 +++ b/drivers/regulator/mc13892-regulator.c
45983 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
45984 }
45985 mc13xxx_unlock(mc13892);
45986
45987 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45988 + pax_open_kernel();
45989 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45990 = mc13892_vcam_set_mode;
45991 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45992 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45993 = mc13892_vcam_get_mode;
45994 + pax_close_kernel();
45995
45996 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
45997 ARRAY_SIZE(mc13892_regulators));
45998 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
45999 index be06d71..264aee9 100644
46000 --- a/drivers/rtc/rtc-cmos.c
46001 +++ b/drivers/rtc/rtc-cmos.c
46002 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46003 hpet_rtc_timer_init();
46004
46005 /* export at least the first block of NVRAM */
46006 - nvram.size = address_space - NVRAM_OFFSET;
46007 + pax_open_kernel();
46008 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46009 + pax_close_kernel();
46010 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46011 if (retval < 0) {
46012 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46013 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46014 index d049393..bb20be0 100644
46015 --- a/drivers/rtc/rtc-dev.c
46016 +++ b/drivers/rtc/rtc-dev.c
46017 @@ -16,6 +16,7 @@
46018 #include <linux/module.h>
46019 #include <linux/rtc.h>
46020 #include <linux/sched.h>
46021 +#include <linux/grsecurity.h>
46022 #include "rtc-core.h"
46023
46024 static dev_t rtc_devt;
46025 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46026 if (copy_from_user(&tm, uarg, sizeof(tm)))
46027 return -EFAULT;
46028
46029 + gr_log_timechange();
46030 +
46031 return rtc_set_time(rtc, &tm);
46032
46033 case RTC_PIE_ON:
46034 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46035 index ca18fd1..055e42d 100644
46036 --- a/drivers/rtc/rtc-ds1307.c
46037 +++ b/drivers/rtc/rtc-ds1307.c
46038 @@ -107,7 +107,7 @@ struct ds1307 {
46039 u8 offset; /* register's offset */
46040 u8 regs[11];
46041 u16 nvram_offset;
46042 - struct bin_attribute *nvram;
46043 + bin_attribute_no_const *nvram;
46044 enum ds_type type;
46045 unsigned long flags;
46046 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46047 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46048 index fcb0329..d77b7f2 100644
46049 --- a/drivers/rtc/rtc-m48t59.c
46050 +++ b/drivers/rtc/rtc-m48t59.c
46051 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46052 if (IS_ERR(m48t59->rtc))
46053 return PTR_ERR(m48t59->rtc);
46054
46055 - m48t59_nvram_attr.size = pdata->offset;
46056 + pax_open_kernel();
46057 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46058 + pax_close_kernel();
46059
46060 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46061 if (ret)
46062 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
46063 index 14b5f8d..cc9bd26 100644
46064 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
46065 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
46066 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
46067 for (bit = 0; bit < 8; bit++) {
46068
46069 if ((pci_status[i] & (0x1 << bit)) != 0) {
46070 - static const char *s;
46071 + const char *s;
46072
46073 s = pci_status_strings[bit];
46074 if (i == 7/*TARG*/ && bit == 3)
46075 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
46076
46077 for (bit = 0; bit < 8; bit++) {
46078
46079 - if ((split_status[i] & (0x1 << bit)) != 0) {
46080 - static const char *s;
46081 -
46082 - s = split_status_strings[bit];
46083 - printk(s, ahd_name(ahd),
46084 + if ((split_status[i] & (0x1 << bit)) != 0)
46085 + printk(split_status_strings[bit], ahd_name(ahd),
46086 split_status_source[i]);
46087 - }
46088
46089 if (i > 1)
46090 continue;
46091
46092 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
46093 - static const char *s;
46094 -
46095 - s = split_status_strings[bit];
46096 - printk(s, ahd_name(ahd), "SG");
46097 - }
46098 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
46099 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
46100 }
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/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46691 index 5100476..3d89a9e 100644
46692 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46693 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46694 @@ -1542,7 +1542,7 @@ _scsih_get_resync(struct device *dev)
46695 {
46696 struct scsi_device *sdev = to_scsi_device(dev);
46697 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46698 - static struct _raid_device *raid_device;
46699 + struct _raid_device *raid_device;
46700 unsigned long flags;
46701 Mpi2RaidVolPage0_t vol_pg0;
46702 Mpi2ConfigReply_t mpi_reply;
46703 @@ -1594,7 +1594,7 @@ _scsih_get_state(struct device *dev)
46704 {
46705 struct scsi_device *sdev = to_scsi_device(dev);
46706 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46707 - static struct _raid_device *raid_device;
46708 + struct _raid_device *raid_device;
46709 unsigned long flags;
46710 Mpi2RaidVolPage0_t vol_pg0;
46711 Mpi2ConfigReply_t mpi_reply;
46712 @@ -6622,7 +6622,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
46713 struct fw_event_work *fw_event)
46714 {
46715 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
46716 - static struct _raid_device *raid_device;
46717 + struct _raid_device *raid_device;
46718 unsigned long flags;
46719 u16 handle;
46720
46721 @@ -7093,7 +7093,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
46722 u64 sas_address;
46723 struct _sas_device *sas_device;
46724 struct _sas_node *expander_device;
46725 - static struct _raid_device *raid_device;
46726 + struct _raid_device *raid_device;
46727 u8 retry_count;
46728 unsigned long flags;
46729
46730 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46731 index 1eb7b028..b2a6080 100644
46732 --- a/drivers/scsi/pmcraid.c
46733 +++ b/drivers/scsi/pmcraid.c
46734 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46735 res->scsi_dev = scsi_dev;
46736 scsi_dev->hostdata = res;
46737 res->change_detected = 0;
46738 - atomic_set(&res->read_failures, 0);
46739 - atomic_set(&res->write_failures, 0);
46740 + atomic_set_unchecked(&res->read_failures, 0);
46741 + atomic_set_unchecked(&res->write_failures, 0);
46742 rc = 0;
46743 }
46744 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46745 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46746
46747 /* If this was a SCSI read/write command keep count of errors */
46748 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46749 - atomic_inc(&res->read_failures);
46750 + atomic_inc_unchecked(&res->read_failures);
46751 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46752 - atomic_inc(&res->write_failures);
46753 + atomic_inc_unchecked(&res->write_failures);
46754
46755 if (!RES_IS_GSCSI(res->cfg_entry) &&
46756 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46757 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46758 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46759 * hrrq_id assigned here in queuecommand
46760 */
46761 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46762 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46763 pinstance->num_hrrq;
46764 cmd->cmd_done = pmcraid_io_done;
46765
46766 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46767 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46768 * hrrq_id assigned here in queuecommand
46769 */
46770 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46771 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46772 pinstance->num_hrrq;
46773
46774 if (request_size) {
46775 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46776
46777 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46778 /* add resources only after host is added into system */
46779 - if (!atomic_read(&pinstance->expose_resources))
46780 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46781 return;
46782
46783 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46784 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46785 init_waitqueue_head(&pinstance->reset_wait_q);
46786
46787 atomic_set(&pinstance->outstanding_cmds, 0);
46788 - atomic_set(&pinstance->last_message_id, 0);
46789 - atomic_set(&pinstance->expose_resources, 0);
46790 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46791 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46792
46793 INIT_LIST_HEAD(&pinstance->free_res_q);
46794 INIT_LIST_HEAD(&pinstance->used_res_q);
46795 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46796 /* Schedule worker thread to handle CCN and take care of adding and
46797 * removing devices to OS
46798 */
46799 - atomic_set(&pinstance->expose_resources, 1);
46800 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46801 schedule_work(&pinstance->worker_q);
46802 return rc;
46803
46804 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46805 index e1d150f..6c6df44 100644
46806 --- a/drivers/scsi/pmcraid.h
46807 +++ b/drivers/scsi/pmcraid.h
46808 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46809 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46810
46811 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46812 - atomic_t last_message_id;
46813 + atomic_unchecked_t last_message_id;
46814
46815 /* configuration table */
46816 struct pmcraid_config_table *cfg_table;
46817 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46818 atomic_t outstanding_cmds;
46819
46820 /* should add/delete resources to mid-layer now ?*/
46821 - atomic_t expose_resources;
46822 + atomic_unchecked_t expose_resources;
46823
46824
46825
46826 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46827 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46828 };
46829 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46830 - atomic_t read_failures; /* count of failed READ commands */
46831 - atomic_t write_failures; /* count of failed WRITE commands */
46832 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46833 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46834
46835 /* To indicate add/delete/modify during CCN */
46836 u8 change_detected;
46837 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46838 index d7a99ae..801df70 100644
46839 --- a/drivers/scsi/qla2xxx/qla_attr.c
46840 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46841 @@ -2004,7 +2004,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46842 return 0;
46843 }
46844
46845 -struct fc_function_template qla2xxx_transport_functions = {
46846 +fc_function_template_no_const qla2xxx_transport_functions = {
46847
46848 .show_host_node_name = 1,
46849 .show_host_port_name = 1,
46850 @@ -2051,7 +2051,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46851 .bsg_timeout = qla24xx_bsg_timeout,
46852 };
46853
46854 -struct fc_function_template qla2xxx_transport_vport_functions = {
46855 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46856
46857 .show_host_node_name = 1,
46858 .show_host_port_name = 1,
46859 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46860 index 2d98232..a84298e 100644
46861 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46862 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46863 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46864 struct device_attribute;
46865 extern struct device_attribute *qla2x00_host_attrs[];
46866 struct fc_function_template;
46867 -extern struct fc_function_template qla2xxx_transport_functions;
46868 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46869 +extern fc_function_template_no_const qla2xxx_transport_functions;
46870 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46871 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46872 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46873 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46874 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46875 index 3e21e9f..426ba79 100644
46876 --- a/drivers/scsi/qla2xxx/qla_os.c
46877 +++ b/drivers/scsi/qla2xxx/qla_os.c
46878 @@ -1570,8 +1570,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46879 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46880 /* Ok, a 64bit DMA mask is applicable. */
46881 ha->flags.enable_64bit_addressing = 1;
46882 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46883 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46884 + pax_open_kernel();
46885 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46886 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46887 + pax_close_kernel();
46888 return;
46889 }
46890 }
46891 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46892 index ddf16a8..80f4dd0 100644
46893 --- a/drivers/scsi/qla4xxx/ql4_def.h
46894 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46895 @@ -291,7 +291,7 @@ struct ddb_entry {
46896 * (4000 only) */
46897 atomic_t relogin_timer; /* Max Time to wait for
46898 * relogin to complete */
46899 - atomic_t relogin_retry_count; /* Num of times relogin has been
46900 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46901 * retried */
46902 uint32_t default_time2wait; /* Default Min time between
46903 * relogins (+aens) */
46904 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46905 index b246b3c..897004d 100644
46906 --- a/drivers/scsi/qla4xxx/ql4_os.c
46907 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46908 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46909 */
46910 if (!iscsi_is_session_online(cls_sess)) {
46911 /* Reset retry relogin timer */
46912 - atomic_inc(&ddb_entry->relogin_retry_count);
46913 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46914 DEBUG2(ql4_printk(KERN_INFO, ha,
46915 "%s: index[%d] relogin timed out-retrying"
46916 " relogin (%d), retry (%d)\n", __func__,
46917 ddb_entry->fw_ddb_index,
46918 - atomic_read(&ddb_entry->relogin_retry_count),
46919 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46920 ddb_entry->default_time2wait + 4));
46921 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46922 atomic_set(&ddb_entry->retry_relogin_timer,
46923 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46924
46925 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46926 atomic_set(&ddb_entry->relogin_timer, 0);
46927 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46928 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46929 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46930 ddb_entry->default_relogin_timeout =
46931 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46932 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46933 index eaa808e..95f8841 100644
46934 --- a/drivers/scsi/scsi.c
46935 +++ b/drivers/scsi/scsi.c
46936 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46937 unsigned long timeout;
46938 int rtn = 0;
46939
46940 - atomic_inc(&cmd->device->iorequest_cnt);
46941 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46942
46943 /* check if the device is still usable */
46944 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46945 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46946 index 124392f..75eb43e 100644
46947 --- a/drivers/scsi/scsi_lib.c
46948 +++ b/drivers/scsi/scsi_lib.c
46949 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46950 shost = sdev->host;
46951 scsi_init_cmd_errh(cmd);
46952 cmd->result = DID_NO_CONNECT << 16;
46953 - atomic_inc(&cmd->device->iorequest_cnt);
46954 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46955
46956 /*
46957 * SCSI request completion path will do scsi_device_unbusy(),
46958 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46959
46960 INIT_LIST_HEAD(&cmd->eh_entry);
46961
46962 - atomic_inc(&cmd->device->iodone_cnt);
46963 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46964 if (cmd->result)
46965 - atomic_inc(&cmd->device->ioerr_cnt);
46966 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46967
46968 disposition = scsi_decide_disposition(cmd);
46969 if (disposition != SUCCESS &&
46970 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46971 index 7e50061..71db7a6 100644
46972 --- a/drivers/scsi/scsi_sysfs.c
46973 +++ b/drivers/scsi/scsi_sysfs.c
46974 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46975 char *buf) \
46976 { \
46977 struct scsi_device *sdev = to_scsi_device(dev); \
46978 - unsigned long long count = atomic_read(&sdev->field); \
46979 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46980 return snprintf(buf, 20, "0x%llx\n", count); \
46981 } \
46982 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46983 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46984 index 84a1fdf..693b0d6 100644
46985 --- a/drivers/scsi/scsi_tgt_lib.c
46986 +++ b/drivers/scsi/scsi_tgt_lib.c
46987 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
46988 int err;
46989
46990 dprintk("%lx %u\n", uaddr, len);
46991 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
46992 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
46993 if (err) {
46994 /*
46995 * TODO: need to fixup sg_tablesize, max_segment_size,
46996 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
46997 index 4628fd5..a94a1c2 100644
46998 --- a/drivers/scsi/scsi_transport_fc.c
46999 +++ b/drivers/scsi/scsi_transport_fc.c
47000 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47001 * Netlink Infrastructure
47002 */
47003
47004 -static atomic_t fc_event_seq;
47005 +static atomic_unchecked_t fc_event_seq;
47006
47007 /**
47008 * fc_get_event_number - Obtain the next sequential FC event number
47009 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47010 u32
47011 fc_get_event_number(void)
47012 {
47013 - return atomic_add_return(1, &fc_event_seq);
47014 + return atomic_add_return_unchecked(1, &fc_event_seq);
47015 }
47016 EXPORT_SYMBOL(fc_get_event_number);
47017
47018 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47019 {
47020 int error;
47021
47022 - atomic_set(&fc_event_seq, 0);
47023 + atomic_set_unchecked(&fc_event_seq, 0);
47024
47025 error = transport_class_register(&fc_host_class);
47026 if (error)
47027 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47028 char *cp;
47029
47030 *val = simple_strtoul(buf, &cp, 0);
47031 - if ((*cp && (*cp != '\n')) || (*val < 0))
47032 + if (*cp && (*cp != '\n'))
47033 return -EINVAL;
47034 /*
47035 * Check for overflow; dev_loss_tmo is u32
47036 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47037 index abf7c40..c3240ed 100644
47038 --- a/drivers/scsi/scsi_transport_iscsi.c
47039 +++ b/drivers/scsi/scsi_transport_iscsi.c
47040 @@ -80,7 +80,7 @@ struct iscsi_internal {
47041 struct transport_container session_cont;
47042 };
47043
47044 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47045 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47046 static struct workqueue_struct *iscsi_eh_timer_workq;
47047
47048 static DEFINE_IDA(iscsi_sess_ida);
47049 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47050 int err;
47051
47052 ihost = shost->shost_data;
47053 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47054 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47055
47056 if (target_id == ISCSI_MAX_TARGET) {
47057 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47058 @@ -3956,7 +3956,7 @@ static __init int iscsi_transport_init(void)
47059 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47060 ISCSI_TRANSPORT_VERSION);
47061
47062 - atomic_set(&iscsi_session_nr, 0);
47063 + atomic_set_unchecked(&iscsi_session_nr, 0);
47064
47065 err = class_register(&iscsi_transport_class);
47066 if (err)
47067 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47068 index f379c7f..e8fc69c 100644
47069 --- a/drivers/scsi/scsi_transport_srp.c
47070 +++ b/drivers/scsi/scsi_transport_srp.c
47071 @@ -33,7 +33,7 @@
47072 #include "scsi_transport_srp_internal.h"
47073
47074 struct srp_host_attrs {
47075 - atomic_t next_port_id;
47076 + atomic_unchecked_t next_port_id;
47077 };
47078 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47079
47080 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47081 struct Scsi_Host *shost = dev_to_shost(dev);
47082 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47083
47084 - atomic_set(&srp_host->next_port_id, 0);
47085 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47086 return 0;
47087 }
47088
47089 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47090 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47091 rport->roles = ids->roles;
47092
47093 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47094 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47095 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47096
47097 transport_setup_device(&rport->dev);
47098 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47099 index 83e9070..9cb646f 100644
47100 --- a/drivers/scsi/sd.c
47101 +++ b/drivers/scsi/sd.c
47102 @@ -2933,7 +2933,7 @@ static int sd_probe(struct device *dev)
47103 sdkp->disk = gd;
47104 sdkp->index = index;
47105 atomic_set(&sdkp->openers, 0);
47106 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47107 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47108
47109 if (!sdp->request_queue->rq_timeout) {
47110 if (sdp->type != TYPE_MOD)
47111 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47112 index df5e961..df6b97f 100644
47113 --- a/drivers/scsi/sg.c
47114 +++ b/drivers/scsi/sg.c
47115 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47116 sdp->disk->disk_name,
47117 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47118 NULL,
47119 - (char *)arg);
47120 + (char __user *)arg);
47121 case BLKTRACESTART:
47122 return blk_trace_startstop(sdp->device->request_queue, 1);
47123 case BLKTRACESTOP:
47124 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47125 index 978dda2..cb19aa0 100644
47126 --- a/drivers/spi/spi.c
47127 +++ b/drivers/spi/spi.c
47128 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
47129 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47130
47131 /* portable code must never pass more than 32 bytes */
47132 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47133 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47134
47135 static u8 *buf;
47136
47137 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47138 index ee3a57f..18368c1 100644
47139 --- a/drivers/staging/android/timed_output.c
47140 +++ b/drivers/staging/android/timed_output.c
47141 @@ -25,7 +25,7 @@
47142 #include "timed_output.h"
47143
47144 static struct class *timed_output_class;
47145 -static atomic_t device_count;
47146 +static atomic_unchecked_t device_count;
47147
47148 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47149 char *buf)
47150 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
47151 timed_output_class = class_create(THIS_MODULE, "timed_output");
47152 if (IS_ERR(timed_output_class))
47153 return PTR_ERR(timed_output_class);
47154 - atomic_set(&device_count, 0);
47155 + atomic_set_unchecked(&device_count, 0);
47156 }
47157
47158 return 0;
47159 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47160 if (ret < 0)
47161 return ret;
47162
47163 - tdev->index = atomic_inc_return(&device_count);
47164 + tdev->index = atomic_inc_return_unchecked(&device_count);
47165 tdev->dev = device_create(timed_output_class, NULL,
47166 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47167 if (IS_ERR(tdev->dev))
47168 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47169 index 3675020..e80d92c 100644
47170 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47171 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47172 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47173
47174 static int solo_sysfs_init(struct solo_dev *solo_dev)
47175 {
47176 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47177 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47178 struct device *dev = &solo_dev->dev;
47179 const char *driver;
47180 int i;
47181 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47182 index 3335941..2b26186 100644
47183 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47184 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47185 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47186
47187 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47188 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47189 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47190 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47191 if (p2m_id < 0)
47192 p2m_id = -p2m_id;
47193 }
47194 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47195 index 6f91d2e..3f011d2 100644
47196 --- a/drivers/staging/media/solo6x10/solo6x10.h
47197 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47198 @@ -238,7 +238,7 @@ struct solo_dev {
47199
47200 /* P2M DMA Engine */
47201 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47202 - atomic_t p2m_count;
47203 + atomic_unchecked_t p2m_count;
47204 int p2m_jiffies;
47205 unsigned int p2m_timeouts;
47206
47207 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47208 index 34afc16..ffe44dd 100644
47209 --- a/drivers/staging/octeon/ethernet-rx.c
47210 +++ b/drivers/staging/octeon/ethernet-rx.c
47211 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47212 /* Increment RX stats for virtual ports */
47213 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47214 #ifdef CONFIG_64BIT
47215 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47216 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47217 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47218 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47219 #else
47220 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47221 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47222 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47223 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47224 #endif
47225 }
47226 netif_receive_skb(skb);
47227 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47228 dev->name);
47229 */
47230 #ifdef CONFIG_64BIT
47231 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47232 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47233 #else
47234 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47235 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47236 #endif
47237 dev_kfree_skb_irq(skb);
47238 }
47239 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47240 index c3a90e7..023619a 100644
47241 --- a/drivers/staging/octeon/ethernet.c
47242 +++ b/drivers/staging/octeon/ethernet.c
47243 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47244 * since the RX tasklet also increments it.
47245 */
47246 #ifdef CONFIG_64BIT
47247 - atomic64_add(rx_status.dropped_packets,
47248 - (atomic64_t *)&priv->stats.rx_dropped);
47249 + atomic64_add_unchecked(rx_status.dropped_packets,
47250 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47251 #else
47252 - atomic_add(rx_status.dropped_packets,
47253 - (atomic_t *)&priv->stats.rx_dropped);
47254 + atomic_add_unchecked(rx_status.dropped_packets,
47255 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47256 #endif
47257 }
47258
47259 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47260 index dc23395..cf7e9b1 100644
47261 --- a/drivers/staging/rtl8712/rtl871x_io.h
47262 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47263 @@ -108,7 +108,7 @@ struct _io_ops {
47264 u8 *pmem);
47265 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47266 u8 *pmem);
47267 -};
47268 +} __no_const;
47269
47270 struct io_req {
47271 struct list_head list;
47272 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47273 index 1f5088b..0e59820 100644
47274 --- a/drivers/staging/sbe-2t3e3/netdev.c
47275 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47276 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47277 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47278
47279 if (rlen)
47280 - if (copy_to_user(data, &resp, rlen))
47281 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47282 return -EFAULT;
47283
47284 return 0;
47285 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47286 index a863a98..d272795 100644
47287 --- a/drivers/staging/usbip/vhci.h
47288 +++ b/drivers/staging/usbip/vhci.h
47289 @@ -83,7 +83,7 @@ struct vhci_hcd {
47290 unsigned resuming:1;
47291 unsigned long re_timeout;
47292
47293 - atomic_t seqnum;
47294 + atomic_unchecked_t seqnum;
47295
47296 /*
47297 * NOTE:
47298 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47299 index d7974cb..d78076b 100644
47300 --- a/drivers/staging/usbip/vhci_hcd.c
47301 +++ b/drivers/staging/usbip/vhci_hcd.c
47302 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47303
47304 spin_lock(&vdev->priv_lock);
47305
47306 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47307 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47308 if (priv->seqnum == 0xffff)
47309 dev_info(&urb->dev->dev, "seqnum max\n");
47310
47311 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47312 return -ENOMEM;
47313 }
47314
47315 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47316 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47317 if (unlink->seqnum == 0xffff)
47318 pr_info("seqnum max\n");
47319
47320 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47321 vdev->rhport = rhport;
47322 }
47323
47324 - atomic_set(&vhci->seqnum, 0);
47325 + atomic_set_unchecked(&vhci->seqnum, 0);
47326 spin_lock_init(&vhci->lock);
47327
47328 hcd->power_budget = 0; /* no limit */
47329 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47330 index d07fcb5..358e1e1 100644
47331 --- a/drivers/staging/usbip/vhci_rx.c
47332 +++ b/drivers/staging/usbip/vhci_rx.c
47333 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47334 if (!urb) {
47335 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47336 pr_info("max seqnum %d\n",
47337 - atomic_read(&the_controller->seqnum));
47338 + atomic_read_unchecked(&the_controller->seqnum));
47339 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47340 return;
47341 }
47342 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47343 index 57a08c5..5b4bb7c 100644
47344 --- a/drivers/staging/vt6655/hostap.c
47345 +++ b/drivers/staging/vt6655/hostap.c
47346 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47347 *
47348 */
47349
47350 +static net_device_ops_no_const apdev_netdev_ops;
47351 +
47352 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47353 {
47354 PSDevice apdev_priv;
47355 struct net_device *dev = pDevice->dev;
47356 int ret;
47357 - const struct net_device_ops apdev_netdev_ops = {
47358 - .ndo_start_xmit = pDevice->tx_80211,
47359 - };
47360
47361 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47362
47363 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47364 *apdev_priv = *pDevice;
47365 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47366
47367 + /* only half broken now */
47368 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47369 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47370
47371 pDevice->apdev->type = ARPHRD_IEEE80211;
47372 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47373 index c699a30..b90a5fd 100644
47374 --- a/drivers/staging/vt6656/hostap.c
47375 +++ b/drivers/staging/vt6656/hostap.c
47376 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47377 *
47378 */
47379
47380 +static net_device_ops_no_const apdev_netdev_ops;
47381 +
47382 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47383 {
47384 struct vnt_private *apdev_priv;
47385 struct net_device *dev = pDevice->dev;
47386 int ret;
47387 - const struct net_device_ops apdev_netdev_ops = {
47388 - .ndo_start_xmit = pDevice->tx_80211,
47389 - };
47390
47391 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47392
47393 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47394 *apdev_priv = *pDevice;
47395 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47396
47397 + /* only half broken now */
47398 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47399 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47400
47401 pDevice->apdev->type = ARPHRD_IEEE80211;
47402 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47403 index d128ce2..fc1f9a1 100644
47404 --- a/drivers/staging/zcache/tmem.h
47405 +++ b/drivers/staging/zcache/tmem.h
47406 @@ -225,7 +225,7 @@ struct tmem_pamops {
47407 bool (*is_remote)(void *);
47408 int (*replace_in_obj)(void *, struct tmem_obj *);
47409 #endif
47410 -};
47411 +} __no_const;
47412 extern void tmem_register_pamops(struct tmem_pamops *m);
47413
47414 /* memory allocation methods provided by the host implementation */
47415 @@ -234,7 +234,7 @@ struct tmem_hostops {
47416 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47417 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47418 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47419 -};
47420 +} __no_const;
47421 extern void tmem_register_hostops(struct tmem_hostops *m);
47422
47423 /* core tmem accessor functions */
47424 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47425 index e51b09a..5ebac31 100644
47426 --- a/drivers/target/sbp/sbp_target.c
47427 +++ b/drivers/target/sbp/sbp_target.c
47428 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47429
47430 #define SESSION_MAINTENANCE_INTERVAL HZ
47431
47432 -static atomic_t login_id = ATOMIC_INIT(0);
47433 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47434
47435 static void session_maintenance_work(struct work_struct *);
47436 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47437 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47438 login->lun = se_lun;
47439 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47440 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47441 - login->login_id = atomic_inc_return(&login_id);
47442 + login->login_id = atomic_inc_return_unchecked(&login_id);
47443
47444 login->tgt_agt = sbp_target_agent_register(login);
47445 if (IS_ERR(login->tgt_agt)) {
47446 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47447 index 8f4142f..b127f7d 100644
47448 --- a/drivers/target/target_core_device.c
47449 +++ b/drivers/target/target_core_device.c
47450 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47451 spin_lock_init(&dev->se_port_lock);
47452 spin_lock_init(&dev->se_tmr_lock);
47453 spin_lock_init(&dev->qf_cmd_lock);
47454 - atomic_set(&dev->dev_ordered_id, 0);
47455 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47456 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47457 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47458 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47459 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47460 index d8e49d7..6fcfdec 100644
47461 --- a/drivers/target/target_core_transport.c
47462 +++ b/drivers/target/target_core_transport.c
47463 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47464 * Used to determine when ORDERED commands should go from
47465 * Dormant to Active status.
47466 */
47467 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47468 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47469 smp_mb__after_atomic_inc();
47470 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47471 cmd->se_ordered_id, cmd->sam_task_attr,
47472 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47473 index 33f83fe..d80f8e1 100644
47474 --- a/drivers/tty/cyclades.c
47475 +++ b/drivers/tty/cyclades.c
47476 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47477 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47478 info->port.count);
47479 #endif
47480 - info->port.count++;
47481 + atomic_inc(&info->port.count);
47482 #ifdef CY_DEBUG_COUNT
47483 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47484 - current->pid, info->port.count);
47485 + current->pid, atomic_read(&info->port.count));
47486 #endif
47487
47488 /*
47489 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47490 for (j = 0; j < cy_card[i].nports; j++) {
47491 info = &cy_card[i].ports[j];
47492
47493 - if (info->port.count) {
47494 + if (atomic_read(&info->port.count)) {
47495 /* XXX is the ldisc num worth this? */
47496 struct tty_struct *tty;
47497 struct tty_ldisc *ld;
47498 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47499 index eb255e8..f637a57 100644
47500 --- a/drivers/tty/hvc/hvc_console.c
47501 +++ b/drivers/tty/hvc/hvc_console.c
47502 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47503
47504 spin_lock_irqsave(&hp->port.lock, flags);
47505 /* Check and then increment for fast path open. */
47506 - if (hp->port.count++ > 0) {
47507 + if (atomic_inc_return(&hp->port.count) > 1) {
47508 spin_unlock_irqrestore(&hp->port.lock, flags);
47509 hvc_kick();
47510 return 0;
47511 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47512
47513 spin_lock_irqsave(&hp->port.lock, flags);
47514
47515 - if (--hp->port.count == 0) {
47516 + if (atomic_dec_return(&hp->port.count) == 0) {
47517 spin_unlock_irqrestore(&hp->port.lock, flags);
47518 /* We are done with the tty pointer now. */
47519 tty_port_tty_set(&hp->port, NULL);
47520 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47521 */
47522 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47523 } else {
47524 - if (hp->port.count < 0)
47525 + if (atomic_read(&hp->port.count) < 0)
47526 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47527 - hp->vtermno, hp->port.count);
47528 + hp->vtermno, atomic_read(&hp->port.count));
47529 spin_unlock_irqrestore(&hp->port.lock, flags);
47530 }
47531 }
47532 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47533 * open->hangup case this can be called after the final close so prevent
47534 * that from happening for now.
47535 */
47536 - if (hp->port.count <= 0) {
47537 + if (atomic_read(&hp->port.count) <= 0) {
47538 spin_unlock_irqrestore(&hp->port.lock, flags);
47539 return;
47540 }
47541
47542 - hp->port.count = 0;
47543 + atomic_set(&hp->port.count, 0);
47544 spin_unlock_irqrestore(&hp->port.lock, flags);
47545 tty_port_tty_set(&hp->port, NULL);
47546
47547 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47548 return -EPIPE;
47549
47550 /* FIXME what's this (unprotected) check for? */
47551 - if (hp->port.count <= 0)
47552 + if (atomic_read(&hp->port.count) <= 0)
47553 return -EIO;
47554
47555 spin_lock_irqsave(&hp->lock, flags);
47556 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47557 index 81e939e..95ead10 100644
47558 --- a/drivers/tty/hvc/hvcs.c
47559 +++ b/drivers/tty/hvc/hvcs.c
47560 @@ -83,6 +83,7 @@
47561 #include <asm/hvcserver.h>
47562 #include <asm/uaccess.h>
47563 #include <asm/vio.h>
47564 +#include <asm/local.h>
47565
47566 /*
47567 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47568 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47569
47570 spin_lock_irqsave(&hvcsd->lock, flags);
47571
47572 - if (hvcsd->port.count > 0) {
47573 + if (atomic_read(&hvcsd->port.count) > 0) {
47574 spin_unlock_irqrestore(&hvcsd->lock, flags);
47575 printk(KERN_INFO "HVCS: vterm state unchanged. "
47576 "The hvcs device node is still in use.\n");
47577 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47578 }
47579 }
47580
47581 - hvcsd->port.count = 0;
47582 + atomic_set(&hvcsd->port.count, 0);
47583 hvcsd->port.tty = tty;
47584 tty->driver_data = hvcsd;
47585
47586 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47587 unsigned long flags;
47588
47589 spin_lock_irqsave(&hvcsd->lock, flags);
47590 - hvcsd->port.count++;
47591 + atomic_inc(&hvcsd->port.count);
47592 hvcsd->todo_mask |= HVCS_SCHED_READ;
47593 spin_unlock_irqrestore(&hvcsd->lock, flags);
47594
47595 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47596 hvcsd = tty->driver_data;
47597
47598 spin_lock_irqsave(&hvcsd->lock, flags);
47599 - if (--hvcsd->port.count == 0) {
47600 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47601
47602 vio_disable_interrupts(hvcsd->vdev);
47603
47604 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47605
47606 free_irq(irq, hvcsd);
47607 return;
47608 - } else if (hvcsd->port.count < 0) {
47609 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47610 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47611 " is missmanaged.\n",
47612 - hvcsd->vdev->unit_address, hvcsd->port.count);
47613 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47614 }
47615
47616 spin_unlock_irqrestore(&hvcsd->lock, flags);
47617 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47618
47619 spin_lock_irqsave(&hvcsd->lock, flags);
47620 /* Preserve this so that we know how many kref refs to put */
47621 - temp_open_count = hvcsd->port.count;
47622 + temp_open_count = atomic_read(&hvcsd->port.count);
47623
47624 /*
47625 * Don't kref put inside the spinlock because the destruction
47626 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47627 tty->driver_data = NULL;
47628 hvcsd->port.tty = NULL;
47629
47630 - hvcsd->port.count = 0;
47631 + atomic_set(&hvcsd->port.count, 0);
47632
47633 /* This will drop any buffered data on the floor which is OK in a hangup
47634 * scenario. */
47635 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47636 * the middle of a write operation? This is a crummy place to do this
47637 * but we want to keep it all in the spinlock.
47638 */
47639 - if (hvcsd->port.count <= 0) {
47640 + if (atomic_read(&hvcsd->port.count) <= 0) {
47641 spin_unlock_irqrestore(&hvcsd->lock, flags);
47642 return -ENODEV;
47643 }
47644 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47645 {
47646 struct hvcs_struct *hvcsd = tty->driver_data;
47647
47648 - if (!hvcsd || hvcsd->port.count <= 0)
47649 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47650 return 0;
47651
47652 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47653 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47654 index 4190199..48f2920 100644
47655 --- a/drivers/tty/hvc/hvsi.c
47656 +++ b/drivers/tty/hvc/hvsi.c
47657 @@ -85,7 +85,7 @@ struct hvsi_struct {
47658 int n_outbuf;
47659 uint32_t vtermno;
47660 uint32_t virq;
47661 - atomic_t seqno; /* HVSI packet sequence number */
47662 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47663 uint16_t mctrl;
47664 uint8_t state; /* HVSI protocol state */
47665 uint8_t flags;
47666 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47667
47668 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47669 packet.hdr.len = sizeof(struct hvsi_query_response);
47670 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47671 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47672 packet.verb = VSV_SEND_VERSION_NUMBER;
47673 packet.u.version = HVSI_VERSION;
47674 packet.query_seqno = query_seqno+1;
47675 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47676
47677 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47678 packet.hdr.len = sizeof(struct hvsi_query);
47679 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47680 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47681 packet.verb = verb;
47682
47683 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47684 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47685 int wrote;
47686
47687 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47688 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47689 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47690 packet.hdr.len = sizeof(struct hvsi_control);
47691 packet.verb = VSV_SET_MODEM_CTL;
47692 packet.mask = HVSI_TSDTR;
47693 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47694 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47695
47696 packet.hdr.type = VS_DATA_PACKET_HEADER;
47697 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47698 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47699 packet.hdr.len = count + sizeof(struct hvsi_header);
47700 memcpy(&packet.data, buf, count);
47701
47702 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47703 struct hvsi_control packet __ALIGNED__;
47704
47705 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47706 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47707 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47708 packet.hdr.len = 6;
47709 packet.verb = VSV_CLOSE_PROTOCOL;
47710
47711 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47712 index ac27671..0f627ee 100644
47713 --- a/drivers/tty/hvc/hvsi_lib.c
47714 +++ b/drivers/tty/hvc/hvsi_lib.c
47715 @@ -9,7 +9,7 @@
47716
47717 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47718 {
47719 - packet->seqno = atomic_inc_return(&pv->seqno);
47720 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47721
47722 /* Assumes that always succeeds, works in practice */
47723 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47724 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47725
47726 /* Reset state */
47727 pv->established = 0;
47728 - atomic_set(&pv->seqno, 0);
47729 + atomic_set_unchecked(&pv->seqno, 0);
47730
47731 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47732
47733 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47734 pv->mctrl_update = 0;
47735 q.hdr.type = VS_QUERY_PACKET_HEADER;
47736 q.hdr.len = sizeof(struct hvsi_query);
47737 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47738 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47739 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47740 rc = hvsi_send_packet(pv, &q.hdr);
47741 if (rc <= 0) {
47742 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47743 index 8fd72ff..34a0bed 100644
47744 --- a/drivers/tty/ipwireless/tty.c
47745 +++ b/drivers/tty/ipwireless/tty.c
47746 @@ -29,6 +29,7 @@
47747 #include <linux/tty_driver.h>
47748 #include <linux/tty_flip.h>
47749 #include <linux/uaccess.h>
47750 +#include <asm/local.h>
47751
47752 #include "tty.h"
47753 #include "network.h"
47754 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47755 mutex_unlock(&tty->ipw_tty_mutex);
47756 return -ENODEV;
47757 }
47758 - if (tty->port.count == 0)
47759 + if (atomic_read(&tty->port.count) == 0)
47760 tty->tx_bytes_queued = 0;
47761
47762 - tty->port.count++;
47763 + atomic_inc(&tty->port.count);
47764
47765 tty->port.tty = linux_tty;
47766 linux_tty->driver_data = tty;
47767 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47768
47769 static void do_ipw_close(struct ipw_tty *tty)
47770 {
47771 - tty->port.count--;
47772 -
47773 - if (tty->port.count == 0) {
47774 + if (atomic_dec_return(&tty->port.count) == 0) {
47775 struct tty_struct *linux_tty = tty->port.tty;
47776
47777 if (linux_tty != NULL) {
47778 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47779 return;
47780
47781 mutex_lock(&tty->ipw_tty_mutex);
47782 - if (tty->port.count == 0) {
47783 + if (atomic_read(&tty->port.count) == 0) {
47784 mutex_unlock(&tty->ipw_tty_mutex);
47785 return;
47786 }
47787 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47788
47789 mutex_lock(&tty->ipw_tty_mutex);
47790
47791 - if (!tty->port.count) {
47792 + if (!atomic_read(&tty->port.count)) {
47793 mutex_unlock(&tty->ipw_tty_mutex);
47794 return;
47795 }
47796 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47797 return -ENODEV;
47798
47799 mutex_lock(&tty->ipw_tty_mutex);
47800 - if (!tty->port.count) {
47801 + if (!atomic_read(&tty->port.count)) {
47802 mutex_unlock(&tty->ipw_tty_mutex);
47803 return -EINVAL;
47804 }
47805 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47806 if (!tty)
47807 return -ENODEV;
47808
47809 - if (!tty->port.count)
47810 + if (!atomic_read(&tty->port.count))
47811 return -EINVAL;
47812
47813 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47814 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47815 if (!tty)
47816 return 0;
47817
47818 - if (!tty->port.count)
47819 + if (!atomic_read(&tty->port.count))
47820 return 0;
47821
47822 return tty->tx_bytes_queued;
47823 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47824 if (!tty)
47825 return -ENODEV;
47826
47827 - if (!tty->port.count)
47828 + if (!atomic_read(&tty->port.count))
47829 return -EINVAL;
47830
47831 return get_control_lines(tty);
47832 @@ -385,7 +384,7 @@ ipw_tiocmset(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 return set_control_lines(tty, set, clear);
47841 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47842 if (!tty)
47843 return -ENODEV;
47844
47845 - if (!tty->port.count)
47846 + if (!atomic_read(&tty->port.count))
47847 return -EINVAL;
47848
47849 /* FIXME: Exactly how is the tty object locked here .. */
47850 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47851 * are gone */
47852 mutex_lock(&ttyj->ipw_tty_mutex);
47853 }
47854 - while (ttyj->port.count)
47855 + while (atomic_read(&ttyj->port.count))
47856 do_ipw_close(ttyj);
47857 ipwireless_disassociate_network_ttys(network,
47858 ttyj->channel_idx);
47859 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47860 index 1deaca4..c8582d4 100644
47861 --- a/drivers/tty/moxa.c
47862 +++ b/drivers/tty/moxa.c
47863 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47864 }
47865
47866 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47867 - ch->port.count++;
47868 + atomic_inc(&ch->port.count);
47869 tty->driver_data = ch;
47870 tty_port_tty_set(&ch->port, tty);
47871 mutex_lock(&ch->port.mutex);
47872 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47873 index 6422390..49003ac8 100644
47874 --- a/drivers/tty/n_gsm.c
47875 +++ b/drivers/tty/n_gsm.c
47876 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47877 spin_lock_init(&dlci->lock);
47878 mutex_init(&dlci->mutex);
47879 dlci->fifo = &dlci->_fifo;
47880 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47881 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47882 kfree(dlci);
47883 return NULL;
47884 }
47885 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47886 struct gsm_dlci *dlci = tty->driver_data;
47887 struct tty_port *port = &dlci->port;
47888
47889 - port->count++;
47890 + atomic_inc(&port->count);
47891 dlci_get(dlci);
47892 dlci_get(dlci->gsm->dlci[0]);
47893 mux_get(dlci->gsm);
47894 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47895 index 4bf0fc0..433bd58 100644
47896 --- a/drivers/tty/n_tty.c
47897 +++ b/drivers/tty/n_tty.c
47898 @@ -2217,6 +2217,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47899 {
47900 *ops = tty_ldisc_N_TTY;
47901 ops->owner = NULL;
47902 - ops->refcount = ops->flags = 0;
47903 + atomic_set(&ops->refcount, 0);
47904 + ops->flags = 0;
47905 }
47906 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47907 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47908 index abfd990..5ab5da9 100644
47909 --- a/drivers/tty/pty.c
47910 +++ b/drivers/tty/pty.c
47911 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
47912 panic("Couldn't register Unix98 pts driver");
47913
47914 /* Now create the /dev/ptmx special device */
47915 + pax_open_kernel();
47916 tty_default_fops(&ptmx_fops);
47917 - ptmx_fops.open = ptmx_open;
47918 + *(void **)&ptmx_fops.open = ptmx_open;
47919 + pax_close_kernel();
47920
47921 cdev_init(&ptmx_cdev, &ptmx_fops);
47922 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47923 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47924 index 354564e..fe50d9a 100644
47925 --- a/drivers/tty/rocket.c
47926 +++ b/drivers/tty/rocket.c
47927 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47928 tty->driver_data = info;
47929 tty_port_tty_set(port, tty);
47930
47931 - if (port->count++ == 0) {
47932 + if (atomic_inc_return(&port->count) == 1) {
47933 atomic_inc(&rp_num_ports_open);
47934
47935 #ifdef ROCKET_DEBUG_OPEN
47936 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47937 #endif
47938 }
47939 #ifdef ROCKET_DEBUG_OPEN
47940 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47941 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47942 #endif
47943
47944 /*
47945 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47946 spin_unlock_irqrestore(&info->port.lock, flags);
47947 return;
47948 }
47949 - if (info->port.count)
47950 + if (atomic_read(&info->port.count))
47951 atomic_dec(&rp_num_ports_open);
47952 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47953 spin_unlock_irqrestore(&info->port.lock, flags);
47954 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47955 index e2520ab..034e20b 100644
47956 --- a/drivers/tty/serial/ioc4_serial.c
47957 +++ b/drivers/tty/serial/ioc4_serial.c
47958 @@ -437,7 +437,7 @@ struct ioc4_soft {
47959 } is_intr_info[MAX_IOC4_INTR_ENTS];
47960
47961 /* Number of entries active in the above array */
47962 - atomic_t is_num_intrs;
47963 + atomic_unchecked_t is_num_intrs;
47964 } is_intr_type[IOC4_NUM_INTR_TYPES];
47965
47966 /* is_ir_lock must be held while
47967 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47968 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47969 || (type == IOC4_OTHER_INTR_TYPE)));
47970
47971 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47972 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
47973 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
47974
47975 /* Save off the lower level interrupt handler */
47976 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
47977
47978 soft = arg;
47979 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
47980 - num_intrs = (int)atomic_read(
47981 + num_intrs = (int)atomic_read_unchecked(
47982 &soft->is_intr_type[intr_type].is_num_intrs);
47983
47984 this_mir = this_ir = pending_intrs(soft, intr_type);
47985 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
47986 index 1002054..dd644a8 100644
47987 --- a/drivers/tty/serial/kgdboc.c
47988 +++ b/drivers/tty/serial/kgdboc.c
47989 @@ -24,8 +24,9 @@
47990 #define MAX_CONFIG_LEN 40
47991
47992 static struct kgdb_io kgdboc_io_ops;
47993 +static struct kgdb_io kgdboc_io_ops_console;
47994
47995 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
47996 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
47997 static int configured = -1;
47998
47999 static char config[MAX_CONFIG_LEN];
48000 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48001 kgdboc_unregister_kbd();
48002 if (configured == 1)
48003 kgdb_unregister_io_module(&kgdboc_io_ops);
48004 + else if (configured == 2)
48005 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48006 }
48007
48008 static int configure_kgdboc(void)
48009 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48010 int err;
48011 char *cptr = config;
48012 struct console *cons;
48013 + int is_console = 0;
48014
48015 err = kgdboc_option_setup(config);
48016 if (err || !strlen(config) || isspace(config[0]))
48017 goto noconfig;
48018
48019 err = -ENODEV;
48020 - kgdboc_io_ops.is_console = 0;
48021 kgdb_tty_driver = NULL;
48022
48023 kgdboc_use_kms = 0;
48024 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48025 int idx;
48026 if (cons->device && cons->device(cons, &idx) == p &&
48027 idx == tty_line) {
48028 - kgdboc_io_ops.is_console = 1;
48029 + is_console = 1;
48030 break;
48031 }
48032 cons = cons->next;
48033 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48034 kgdb_tty_line = tty_line;
48035
48036 do_register:
48037 - err = kgdb_register_io_module(&kgdboc_io_ops);
48038 + if (is_console) {
48039 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48040 + configured = 2;
48041 + } else {
48042 + err = kgdb_register_io_module(&kgdboc_io_ops);
48043 + configured = 1;
48044 + }
48045 if (err)
48046 goto noconfig;
48047
48048 @@ -205,8 +214,6 @@ do_register:
48049 if (err)
48050 goto nmi_con_failed;
48051
48052 - configured = 1;
48053 -
48054 return 0;
48055
48056 nmi_con_failed:
48057 @@ -223,7 +230,7 @@ noconfig:
48058 static int __init init_kgdboc(void)
48059 {
48060 /* Already configured? */
48061 - if (configured == 1)
48062 + if (configured >= 1)
48063 return 0;
48064
48065 return configure_kgdboc();
48066 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48067 if (config[len - 1] == '\n')
48068 config[len - 1] = '\0';
48069
48070 - if (configured == 1)
48071 + if (configured >= 1)
48072 cleanup_kgdboc();
48073
48074 /* Go and configure with the new params. */
48075 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48076 .post_exception = kgdboc_post_exp_handler,
48077 };
48078
48079 +static struct kgdb_io kgdboc_io_ops_console = {
48080 + .name = "kgdboc",
48081 + .read_char = kgdboc_get_char,
48082 + .write_char = kgdboc_put_char,
48083 + .pre_exception = kgdboc_pre_exp_handler,
48084 + .post_exception = kgdboc_post_exp_handler,
48085 + .is_console = 1
48086 +};
48087 +
48088 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48089 /* This is only available if kgdboc is a built in for early debugging */
48090 static int __init kgdboc_early_init(char *opt)
48091 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48092 index 2c6cfb3..048274e 100644
48093 --- a/drivers/tty/serial/msm_serial.c
48094 +++ b/drivers/tty/serial/msm_serial.c
48095 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
48096 .cons = MSM_CONSOLE,
48097 };
48098
48099 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48100 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48101
48102 static int __init msm_serial_probe(struct platform_device *pdev)
48103 {
48104 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48105 int irq;
48106
48107 if (pdev->id == -1)
48108 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48109 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48110
48111 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48112 return -ENXIO;
48113 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48114 index 376079b..d8de7aa 100644
48115 --- a/drivers/tty/serial/samsung.c
48116 +++ b/drivers/tty/serial/samsung.c
48117 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48118 }
48119 }
48120
48121 +static int s3c64xx_serial_startup(struct uart_port *port);
48122 static int s3c24xx_serial_startup(struct uart_port *port)
48123 {
48124 struct s3c24xx_uart_port *ourport = to_ourport(port);
48125 int ret;
48126
48127 + /* Startup sequence is different for s3c64xx and higher SoC's */
48128 + if (s3c24xx_serial_has_interrupt_mask(port))
48129 + return s3c64xx_serial_startup(port);
48130 +
48131 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48132 port->mapbase, port->membase);
48133
48134 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48135 /* setup info for port */
48136 port->dev = &platdev->dev;
48137
48138 - /* Startup sequence is different for s3c64xx and higher SoC's */
48139 - if (s3c24xx_serial_has_interrupt_mask(port))
48140 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48141 -
48142 port->uartclk = 1;
48143
48144 if (cfg->uart_flags & UPF_CONS_FLOW) {
48145 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48146 index 28cdd28..56f1d60 100644
48147 --- a/drivers/tty/serial/serial_core.c
48148 +++ b/drivers/tty/serial/serial_core.c
48149 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48150 uart_flush_buffer(tty);
48151 uart_shutdown(tty, state);
48152 spin_lock_irqsave(&port->lock, flags);
48153 - port->count = 0;
48154 + atomic_set(&port->count, 0);
48155 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48156 spin_unlock_irqrestore(&port->lock, flags);
48157 tty_port_tty_set(port, NULL);
48158 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48159 goto end;
48160 }
48161
48162 - port->count++;
48163 + atomic_inc(&port->count);
48164 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48165 retval = -ENXIO;
48166 goto err_dec_count;
48167 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48168 /*
48169 * Make sure the device is in D0 state.
48170 */
48171 - if (port->count == 1)
48172 + if (atomic_read(&port->count) == 1)
48173 uart_change_pm(state, UART_PM_STATE_ON);
48174
48175 /*
48176 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48177 end:
48178 return retval;
48179 err_dec_count:
48180 - port->count--;
48181 + atomic_inc(&port->count);
48182 mutex_unlock(&port->mutex);
48183 goto end;
48184 }
48185 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48186 index 8eaf1ab..85c030d 100644
48187 --- a/drivers/tty/synclink.c
48188 +++ b/drivers/tty/synclink.c
48189 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48190
48191 if (debug_level >= DEBUG_LEVEL_INFO)
48192 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48193 - __FILE__,__LINE__, info->device_name, info->port.count);
48194 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48195
48196 if (tty_port_close_start(&info->port, tty, filp) == 0)
48197 goto cleanup;
48198 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48199 cleanup:
48200 if (debug_level >= DEBUG_LEVEL_INFO)
48201 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48202 - tty->driver->name, info->port.count);
48203 + tty->driver->name, atomic_read(&info->port.count));
48204
48205 } /* end of mgsl_close() */
48206
48207 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48208
48209 mgsl_flush_buffer(tty);
48210 shutdown(info);
48211 -
48212 - info->port.count = 0;
48213 +
48214 + atomic_set(&info->port.count, 0);
48215 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48216 info->port.tty = NULL;
48217
48218 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48219
48220 if (debug_level >= DEBUG_LEVEL_INFO)
48221 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48222 - __FILE__,__LINE__, tty->driver->name, port->count );
48223 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48224
48225 spin_lock_irqsave(&info->irq_spinlock, flags);
48226 if (!tty_hung_up_p(filp)) {
48227 extra_count = true;
48228 - port->count--;
48229 + atomic_dec(&port->count);
48230 }
48231 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48232 port->blocked_open++;
48233 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48234
48235 if (debug_level >= DEBUG_LEVEL_INFO)
48236 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48237 - __FILE__,__LINE__, tty->driver->name, port->count );
48238 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48239
48240 tty_unlock(tty);
48241 schedule();
48242 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48243
48244 /* FIXME: Racy on hangup during close wait */
48245 if (extra_count)
48246 - port->count++;
48247 + atomic_inc(&port->count);
48248 port->blocked_open--;
48249
48250 if (debug_level >= DEBUG_LEVEL_INFO)
48251 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48252 - __FILE__,__LINE__, tty->driver->name, port->count );
48253 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48254
48255 if (!retval)
48256 port->flags |= ASYNC_NORMAL_ACTIVE;
48257 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48258
48259 if (debug_level >= DEBUG_LEVEL_INFO)
48260 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48261 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48262 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48263
48264 /* If port is closing, signal caller to try again */
48265 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48266 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48267 spin_unlock_irqrestore(&info->netlock, flags);
48268 goto cleanup;
48269 }
48270 - info->port.count++;
48271 + atomic_inc(&info->port.count);
48272 spin_unlock_irqrestore(&info->netlock, flags);
48273
48274 - if (info->port.count == 1) {
48275 + if (atomic_read(&info->port.count) == 1) {
48276 /* 1st open on this device, init hardware */
48277 retval = startup(info);
48278 if (retval < 0)
48279 @@ -3446,8 +3446,8 @@ cleanup:
48280 if (retval) {
48281 if (tty->count == 1)
48282 info->port.tty = NULL; /* tty layer will release tty struct */
48283 - if(info->port.count)
48284 - info->port.count--;
48285 + if (atomic_read(&info->port.count))
48286 + atomic_dec(&info->port.count);
48287 }
48288
48289 return retval;
48290 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48291 unsigned short new_crctype;
48292
48293 /* return error if TTY interface open */
48294 - if (info->port.count)
48295 + if (atomic_read(&info->port.count))
48296 return -EBUSY;
48297
48298 switch (encoding)
48299 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48300
48301 /* arbitrate between network and tty opens */
48302 spin_lock_irqsave(&info->netlock, flags);
48303 - if (info->port.count != 0 || info->netcount != 0) {
48304 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48305 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48306 spin_unlock_irqrestore(&info->netlock, flags);
48307 return -EBUSY;
48308 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48309 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48310
48311 /* return error if TTY interface open */
48312 - if (info->port.count)
48313 + if (atomic_read(&info->port.count))
48314 return -EBUSY;
48315
48316 if (cmd != SIOCWANDEV)
48317 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48318 index 1abf946..1ee34fc 100644
48319 --- a/drivers/tty/synclink_gt.c
48320 +++ b/drivers/tty/synclink_gt.c
48321 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48322 tty->driver_data = info;
48323 info->port.tty = tty;
48324
48325 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48326 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48327
48328 /* If port is closing, signal caller to try again */
48329 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48330 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48331 mutex_unlock(&info->port.mutex);
48332 goto cleanup;
48333 }
48334 - info->port.count++;
48335 + atomic_inc(&info->port.count);
48336 spin_unlock_irqrestore(&info->netlock, flags);
48337
48338 - if (info->port.count == 1) {
48339 + if (atomic_read(&info->port.count) == 1) {
48340 /* 1st open on this device, init hardware */
48341 retval = startup(info);
48342 if (retval < 0) {
48343 @@ -715,8 +715,8 @@ cleanup:
48344 if (retval) {
48345 if (tty->count == 1)
48346 info->port.tty = NULL; /* tty layer will release tty struct */
48347 - if(info->port.count)
48348 - info->port.count--;
48349 + if(atomic_read(&info->port.count))
48350 + atomic_dec(&info->port.count);
48351 }
48352
48353 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48354 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48355
48356 if (sanity_check(info, tty->name, "close"))
48357 return;
48358 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48359 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48360
48361 if (tty_port_close_start(&info->port, tty, filp) == 0)
48362 goto cleanup;
48363 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48364 tty_port_close_end(&info->port, tty);
48365 info->port.tty = NULL;
48366 cleanup:
48367 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48368 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48369 }
48370
48371 static void hangup(struct tty_struct *tty)
48372 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48373 shutdown(info);
48374
48375 spin_lock_irqsave(&info->port.lock, flags);
48376 - info->port.count = 0;
48377 + atomic_set(&info->port.count, 0);
48378 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48379 info->port.tty = NULL;
48380 spin_unlock_irqrestore(&info->port.lock, flags);
48381 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48382 unsigned short new_crctype;
48383
48384 /* return error if TTY interface open */
48385 - if (info->port.count)
48386 + if (atomic_read(&info->port.count))
48387 return -EBUSY;
48388
48389 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48390 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48391
48392 /* arbitrate between network and tty opens */
48393 spin_lock_irqsave(&info->netlock, flags);
48394 - if (info->port.count != 0 || info->netcount != 0) {
48395 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48396 DBGINFO(("%s hdlc_open busy\n", dev->name));
48397 spin_unlock_irqrestore(&info->netlock, flags);
48398 return -EBUSY;
48399 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48400 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48401
48402 /* return error if TTY interface open */
48403 - if (info->port.count)
48404 + if (atomic_read(&info->port.count))
48405 return -EBUSY;
48406
48407 if (cmd != SIOCWANDEV)
48408 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48409 if (port == NULL)
48410 continue;
48411 spin_lock(&port->lock);
48412 - if ((port->port.count || port->netcount) &&
48413 + if ((atomic_read(&port->port.count) || port->netcount) &&
48414 port->pending_bh && !port->bh_running &&
48415 !port->bh_requested) {
48416 DBGISR(("%s bh queued\n", port->device_name));
48417 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48418 spin_lock_irqsave(&info->lock, flags);
48419 if (!tty_hung_up_p(filp)) {
48420 extra_count = true;
48421 - port->count--;
48422 + atomic_dec(&port->count);
48423 }
48424 spin_unlock_irqrestore(&info->lock, flags);
48425 port->blocked_open++;
48426 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48427 remove_wait_queue(&port->open_wait, &wait);
48428
48429 if (extra_count)
48430 - port->count++;
48431 + atomic_inc(&port->count);
48432 port->blocked_open--;
48433
48434 if (!retval)
48435 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48436 index dc6e969..5dc8786 100644
48437 --- a/drivers/tty/synclinkmp.c
48438 +++ b/drivers/tty/synclinkmp.c
48439 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48440
48441 if (debug_level >= DEBUG_LEVEL_INFO)
48442 printk("%s(%d):%s open(), old ref count = %d\n",
48443 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48444 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48445
48446 /* If port is closing, signal caller to try again */
48447 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48448 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48449 spin_unlock_irqrestore(&info->netlock, flags);
48450 goto cleanup;
48451 }
48452 - info->port.count++;
48453 + atomic_inc(&info->port.count);
48454 spin_unlock_irqrestore(&info->netlock, flags);
48455
48456 - if (info->port.count == 1) {
48457 + if (atomic_read(&info->port.count) == 1) {
48458 /* 1st open on this device, init hardware */
48459 retval = startup(info);
48460 if (retval < 0)
48461 @@ -796,8 +796,8 @@ cleanup:
48462 if (retval) {
48463 if (tty->count == 1)
48464 info->port.tty = NULL; /* tty layer will release tty struct */
48465 - if(info->port.count)
48466 - info->port.count--;
48467 + if(atomic_read(&info->port.count))
48468 + atomic_dec(&info->port.count);
48469 }
48470
48471 return retval;
48472 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48473
48474 if (debug_level >= DEBUG_LEVEL_INFO)
48475 printk("%s(%d):%s close() entry, count=%d\n",
48476 - __FILE__,__LINE__, info->device_name, info->port.count);
48477 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48478
48479 if (tty_port_close_start(&info->port, tty, filp) == 0)
48480 goto cleanup;
48481 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48482 cleanup:
48483 if (debug_level >= DEBUG_LEVEL_INFO)
48484 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48485 - tty->driver->name, info->port.count);
48486 + tty->driver->name, atomic_read(&info->port.count));
48487 }
48488
48489 /* Called by tty_hangup() when a hangup is signaled.
48490 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48491 shutdown(info);
48492
48493 spin_lock_irqsave(&info->port.lock, flags);
48494 - info->port.count = 0;
48495 + atomic_set(&info->port.count, 0);
48496 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48497 info->port.tty = NULL;
48498 spin_unlock_irqrestore(&info->port.lock, flags);
48499 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48500 unsigned short new_crctype;
48501
48502 /* return error if TTY interface open */
48503 - if (info->port.count)
48504 + if (atomic_read(&info->port.count))
48505 return -EBUSY;
48506
48507 switch (encoding)
48508 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48509
48510 /* arbitrate between network and tty opens */
48511 spin_lock_irqsave(&info->netlock, flags);
48512 - if (info->port.count != 0 || info->netcount != 0) {
48513 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48514 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48515 spin_unlock_irqrestore(&info->netlock, flags);
48516 return -EBUSY;
48517 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48518 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48519
48520 /* return error if TTY interface open */
48521 - if (info->port.count)
48522 + if (atomic_read(&info->port.count))
48523 return -EBUSY;
48524
48525 if (cmd != SIOCWANDEV)
48526 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48527 * do not request bottom half processing if the
48528 * device is not open in a normal mode.
48529 */
48530 - if ( port && (port->port.count || port->netcount) &&
48531 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48532 port->pending_bh && !port->bh_running &&
48533 !port->bh_requested ) {
48534 if ( debug_level >= DEBUG_LEVEL_ISR )
48535 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48536
48537 if (debug_level >= DEBUG_LEVEL_INFO)
48538 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48539 - __FILE__,__LINE__, tty->driver->name, port->count );
48540 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48541
48542 spin_lock_irqsave(&info->lock, flags);
48543 if (!tty_hung_up_p(filp)) {
48544 extra_count = true;
48545 - port->count--;
48546 + atomic_dec(&port->count);
48547 }
48548 spin_unlock_irqrestore(&info->lock, flags);
48549 port->blocked_open++;
48550 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48551
48552 if (debug_level >= DEBUG_LEVEL_INFO)
48553 printk("%s(%d):%s block_til_ready() count=%d\n",
48554 - __FILE__,__LINE__, tty->driver->name, port->count );
48555 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48556
48557 tty_unlock(tty);
48558 schedule();
48559 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48560 remove_wait_queue(&port->open_wait, &wait);
48561
48562 if (extra_count)
48563 - port->count++;
48564 + atomic_inc(&port->count);
48565 port->blocked_open--;
48566
48567 if (debug_level >= DEBUG_LEVEL_INFO)
48568 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48569 - __FILE__,__LINE__, tty->driver->name, port->count );
48570 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48571
48572 if (!retval)
48573 port->flags |= ASYNC_NORMAL_ACTIVE;
48574 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48575 index d5cc3ac..3263411 100644
48576 --- a/drivers/tty/sysrq.c
48577 +++ b/drivers/tty/sysrq.c
48578 @@ -1033,7 +1033,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48579 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48580 size_t count, loff_t *ppos)
48581 {
48582 - if (count) {
48583 + if (count && capable(CAP_SYS_ADMIN)) {
48584 char c;
48585
48586 if (get_user(c, buf))
48587 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48588 index 20689b9..7fd3a31 100644
48589 --- a/drivers/tty/tty_io.c
48590 +++ b/drivers/tty/tty_io.c
48591 @@ -3468,7 +3468,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48592
48593 void tty_default_fops(struct file_operations *fops)
48594 {
48595 - *fops = tty_fops;
48596 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48597 }
48598
48599 /*
48600 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48601 index 1afe192..73d2c20 100644
48602 --- a/drivers/tty/tty_ldisc.c
48603 +++ b/drivers/tty/tty_ldisc.c
48604 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48605 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48606 tty_ldiscs[disc] = new_ldisc;
48607 new_ldisc->num = disc;
48608 - new_ldisc->refcount = 0;
48609 + atomic_set(&new_ldisc->refcount, 0);
48610 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48611
48612 return ret;
48613 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48614 return -EINVAL;
48615
48616 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48617 - if (tty_ldiscs[disc]->refcount)
48618 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48619 ret = -EBUSY;
48620 else
48621 tty_ldiscs[disc] = NULL;
48622 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48623 if (ldops) {
48624 ret = ERR_PTR(-EAGAIN);
48625 if (try_module_get(ldops->owner)) {
48626 - ldops->refcount++;
48627 + atomic_inc(&ldops->refcount);
48628 ret = ldops;
48629 }
48630 }
48631 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48632 unsigned long flags;
48633
48634 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48635 - ldops->refcount--;
48636 + atomic_dec(&ldops->refcount);
48637 module_put(ldops->owner);
48638 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48639 }
48640 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48641 /* unreleased reader reference(s) will cause this WARN */
48642 WARN_ON(!atomic_dec_and_test(&ld->users));
48643
48644 - ld->ops->refcount--;
48645 + atomic_dec(&ld->ops->refcount);
48646 module_put(ld->ops->owner);
48647 kfree(ld);
48648 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48649 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48650 index f597e88..b7f68ed 100644
48651 --- a/drivers/tty/tty_port.c
48652 +++ b/drivers/tty/tty_port.c
48653 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48654 unsigned long flags;
48655
48656 spin_lock_irqsave(&port->lock, flags);
48657 - port->count = 0;
48658 + atomic_set(&port->count, 0);
48659 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48660 tty = port->tty;
48661 if (tty)
48662 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48663 /* The port lock protects the port counts */
48664 spin_lock_irqsave(&port->lock, flags);
48665 if (!tty_hung_up_p(filp))
48666 - port->count--;
48667 + atomic_dec(&port->count);
48668 port->blocked_open++;
48669 spin_unlock_irqrestore(&port->lock, flags);
48670
48671 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48672 we must not mess that up further */
48673 spin_lock_irqsave(&port->lock, flags);
48674 if (!tty_hung_up_p(filp))
48675 - port->count++;
48676 + atomic_inc(&port->count);
48677 port->blocked_open--;
48678 if (retval == 0)
48679 port->flags |= ASYNC_NORMAL_ACTIVE;
48680 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48681 return 0;
48682 }
48683
48684 - if (tty->count == 1 && port->count != 1) {
48685 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48686 printk(KERN_WARNING
48687 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48688 - port->count);
48689 - port->count = 1;
48690 + atomic_read(&port->count));
48691 + atomic_set(&port->count, 1);
48692 }
48693 - if (--port->count < 0) {
48694 + if (atomic_dec_return(&port->count) < 0) {
48695 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48696 - port->count);
48697 - port->count = 0;
48698 + atomic_read(&port->count));
48699 + atomic_set(&port->count, 0);
48700 }
48701
48702 - if (port->count) {
48703 + if (atomic_read(&port->count)) {
48704 spin_unlock_irqrestore(&port->lock, flags);
48705 if (port->ops->drop)
48706 port->ops->drop(port);
48707 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48708 {
48709 spin_lock_irq(&port->lock);
48710 if (!tty_hung_up_p(filp))
48711 - ++port->count;
48712 + atomic_inc(&port->count);
48713 spin_unlock_irq(&port->lock);
48714 tty_port_tty_set(port, tty);
48715
48716 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48717 index a9af1b9a..1e08e7f 100644
48718 --- a/drivers/tty/vt/keyboard.c
48719 +++ b/drivers/tty/vt/keyboard.c
48720 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48721 kbd->kbdmode == VC_OFF) &&
48722 value != KVAL(K_SAK))
48723 return; /* SAK is allowed even in raw mode */
48724 +
48725 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48726 + {
48727 + void *func = fn_handler[value];
48728 + if (func == fn_show_state || func == fn_show_ptregs ||
48729 + func == fn_show_mem)
48730 + return;
48731 + }
48732 +#endif
48733 +
48734 fn_handler[value](vc);
48735 }
48736
48737 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48738 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48739 return -EFAULT;
48740
48741 - if (!capable(CAP_SYS_TTY_CONFIG))
48742 - perm = 0;
48743 -
48744 switch (cmd) {
48745 case KDGKBENT:
48746 /* Ensure another thread doesn't free it under us */
48747 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48748 spin_unlock_irqrestore(&kbd_event_lock, flags);
48749 return put_user(val, &user_kbe->kb_value);
48750 case KDSKBENT:
48751 + if (!capable(CAP_SYS_TTY_CONFIG))
48752 + perm = 0;
48753 +
48754 if (!perm)
48755 return -EPERM;
48756 if (!i && v == K_NOSUCHMAP) {
48757 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48758 int i, j, k;
48759 int ret;
48760
48761 - if (!capable(CAP_SYS_TTY_CONFIG))
48762 - perm = 0;
48763 -
48764 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48765 if (!kbs) {
48766 ret = -ENOMEM;
48767 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48768 kfree(kbs);
48769 return ((p && *p) ? -EOVERFLOW : 0);
48770 case KDSKBSENT:
48771 + if (!capable(CAP_SYS_TTY_CONFIG))
48772 + perm = 0;
48773 +
48774 if (!perm) {
48775 ret = -EPERM;
48776 goto reterr;
48777 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48778 index 4bf4bb2..52ae8c7 100644
48779 --- a/drivers/uio/uio.c
48780 +++ b/drivers/uio/uio.c
48781 @@ -25,6 +25,7 @@
48782 #include <linux/kobject.h>
48783 #include <linux/cdev.h>
48784 #include <linux/uio_driver.h>
48785 +#include <asm/local.h>
48786
48787 #define UIO_MAX_DEVICES (1U << MINORBITS)
48788
48789 @@ -32,10 +33,10 @@ struct uio_device {
48790 struct module *owner;
48791 struct device *dev;
48792 int minor;
48793 - atomic_t event;
48794 + atomic_unchecked_t event;
48795 struct fasync_struct *async_queue;
48796 wait_queue_head_t wait;
48797 - int vma_count;
48798 + local_t vma_count;
48799 struct uio_info *info;
48800 struct kobject *map_dir;
48801 struct kobject *portio_dir;
48802 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
48803 struct device_attribute *attr, char *buf)
48804 {
48805 struct uio_device *idev = dev_get_drvdata(dev);
48806 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48807 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48808 }
48809
48810 static struct device_attribute uio_class_attributes[] = {
48811 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
48812 {
48813 struct uio_device *idev = info->uio_dev;
48814
48815 - atomic_inc(&idev->event);
48816 + atomic_inc_unchecked(&idev->event);
48817 wake_up_interruptible(&idev->wait);
48818 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48819 }
48820 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48821 }
48822
48823 listener->dev = idev;
48824 - listener->event_count = atomic_read(&idev->event);
48825 + listener->event_count = atomic_read_unchecked(&idev->event);
48826 filep->private_data = listener;
48827
48828 if (idev->info->open) {
48829 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48830 return -EIO;
48831
48832 poll_wait(filep, &idev->wait, wait);
48833 - if (listener->event_count != atomic_read(&idev->event))
48834 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48835 return POLLIN | POLLRDNORM;
48836 return 0;
48837 }
48838 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48839 do {
48840 set_current_state(TASK_INTERRUPTIBLE);
48841
48842 - event_count = atomic_read(&idev->event);
48843 + event_count = atomic_read_unchecked(&idev->event);
48844 if (event_count != listener->event_count) {
48845 if (copy_to_user(buf, &event_count, count))
48846 retval = -EFAULT;
48847 @@ -584,9 +585,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
48848 static int uio_find_mem_index(struct vm_area_struct *vma)
48849 {
48850 struct uio_device *idev = vma->vm_private_data;
48851 + unsigned long size;
48852
48853 if (vma->vm_pgoff < MAX_UIO_MAPS) {
48854 - if (idev->info->mem[vma->vm_pgoff].size == 0)
48855 + size = idev->info->mem[vma->vm_pgoff].size;
48856 + if (size == 0)
48857 + return -1;
48858 + if (vma->vm_end - vma->vm_start > size)
48859 return -1;
48860 return (int)vma->vm_pgoff;
48861 }
48862 @@ -596,13 +601,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
48863 static void uio_vma_open(struct vm_area_struct *vma)
48864 {
48865 struct uio_device *idev = vma->vm_private_data;
48866 - idev->vma_count++;
48867 + local_inc(&idev->vma_count);
48868 }
48869
48870 static void uio_vma_close(struct vm_area_struct *vma)
48871 {
48872 struct uio_device *idev = vma->vm_private_data;
48873 - idev->vma_count--;
48874 + local_dec(&idev->vma_count);
48875 }
48876
48877 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
48878 @@ -830,7 +835,7 @@ int __uio_register_device(struct module *owner,
48879 idev->owner = owner;
48880 idev->info = info;
48881 init_waitqueue_head(&idev->wait);
48882 - atomic_set(&idev->event, 0);
48883 + atomic_set_unchecked(&idev->event, 0);
48884
48885 ret = uio_get_minor(idev);
48886 if (ret)
48887 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48888 index 8a7eb77..c00402f 100644
48889 --- a/drivers/usb/atm/cxacru.c
48890 +++ b/drivers/usb/atm/cxacru.c
48891 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48892 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48893 if (ret < 2)
48894 return -EINVAL;
48895 - if (index < 0 || index > 0x7f)
48896 + if (index > 0x7f)
48897 return -EINVAL;
48898 pos += tmp;
48899
48900 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48901 index 5e0d33a..cc10579 100644
48902 --- a/drivers/usb/atm/usbatm.c
48903 +++ b/drivers/usb/atm/usbatm.c
48904 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48905 if (printk_ratelimit())
48906 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48907 __func__, vpi, vci);
48908 - atomic_inc(&vcc->stats->rx_err);
48909 + atomic_inc_unchecked(&vcc->stats->rx_err);
48910 return;
48911 }
48912
48913 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48914 if (length > ATM_MAX_AAL5_PDU) {
48915 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48916 __func__, length, vcc);
48917 - atomic_inc(&vcc->stats->rx_err);
48918 + atomic_inc_unchecked(&vcc->stats->rx_err);
48919 goto out;
48920 }
48921
48922 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48923 if (sarb->len < pdu_length) {
48924 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48925 __func__, pdu_length, sarb->len, vcc);
48926 - atomic_inc(&vcc->stats->rx_err);
48927 + atomic_inc_unchecked(&vcc->stats->rx_err);
48928 goto out;
48929 }
48930
48931 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48932 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48933 __func__, vcc);
48934 - atomic_inc(&vcc->stats->rx_err);
48935 + atomic_inc_unchecked(&vcc->stats->rx_err);
48936 goto out;
48937 }
48938
48939 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48940 if (printk_ratelimit())
48941 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48942 __func__, length);
48943 - atomic_inc(&vcc->stats->rx_drop);
48944 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48945 goto out;
48946 }
48947
48948 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48949
48950 vcc->push(vcc, skb);
48951
48952 - atomic_inc(&vcc->stats->rx);
48953 + atomic_inc_unchecked(&vcc->stats->rx);
48954 out:
48955 skb_trim(sarb, 0);
48956 }
48957 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
48958 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
48959
48960 usbatm_pop(vcc, skb);
48961 - atomic_inc(&vcc->stats->tx);
48962 + atomic_inc_unchecked(&vcc->stats->tx);
48963
48964 skb = skb_dequeue(&instance->sndqueue);
48965 }
48966 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
48967 if (!left--)
48968 return sprintf(page,
48969 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
48970 - atomic_read(&atm_dev->stats.aal5.tx),
48971 - atomic_read(&atm_dev->stats.aal5.tx_err),
48972 - atomic_read(&atm_dev->stats.aal5.rx),
48973 - atomic_read(&atm_dev->stats.aal5.rx_err),
48974 - atomic_read(&atm_dev->stats.aal5.rx_drop));
48975 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
48976 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
48977 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
48978 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
48979 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
48980
48981 if (!left--) {
48982 if (instance->disconnected)
48983 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
48984 index 2a3bbdf..91d72cf 100644
48985 --- a/drivers/usb/core/devices.c
48986 +++ b/drivers/usb/core/devices.c
48987 @@ -126,7 +126,7 @@ static const char format_endpt[] =
48988 * time it gets called.
48989 */
48990 static struct device_connect_event {
48991 - atomic_t count;
48992 + atomic_unchecked_t count;
48993 wait_queue_head_t wait;
48994 } device_event = {
48995 .count = ATOMIC_INIT(1),
48996 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
48997
48998 void usbfs_conn_disc_event(void)
48999 {
49000 - atomic_add(2, &device_event.count);
49001 + atomic_add_unchecked(2, &device_event.count);
49002 wake_up(&device_event.wait);
49003 }
49004
49005 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49006
49007 poll_wait(file, &device_event.wait, wait);
49008
49009 - event_count = atomic_read(&device_event.count);
49010 + event_count = atomic_read_unchecked(&device_event.count);
49011 if (file->f_version != event_count) {
49012 file->f_version = event_count;
49013 return POLLIN | POLLRDNORM;
49014 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49015 index 7b8bc0b..31bd7ad 100644
49016 --- a/drivers/usb/core/hcd.c
49017 +++ b/drivers/usb/core/hcd.c
49018 @@ -1552,7 +1552,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49019 */
49020 usb_get_urb(urb);
49021 atomic_inc(&urb->use_count);
49022 - atomic_inc(&urb->dev->urbnum);
49023 + atomic_inc_unchecked(&urb->dev->urbnum);
49024 usbmon_urb_submit(&hcd->self, urb);
49025
49026 /* NOTE requirements on root-hub callers (usbfs and the hub
49027 @@ -1579,7 +1579,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49028 urb->hcpriv = NULL;
49029 INIT_LIST_HEAD(&urb->urb_list);
49030 atomic_dec(&urb->use_count);
49031 - atomic_dec(&urb->dev->urbnum);
49032 + atomic_dec_unchecked(&urb->dev->urbnum);
49033 if (atomic_read(&urb->reject))
49034 wake_up(&usb_kill_urb_queue);
49035 usb_put_urb(urb);
49036 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49037 index 1c11089..db98d78 100644
49038 --- a/drivers/usb/core/hub.c
49039 +++ b/drivers/usb/core/hub.c
49040 @@ -27,6 +27,7 @@
49041 #include <linux/freezer.h>
49042 #include <linux/random.h>
49043 #include <linux/pm_qos.h>
49044 +#include <linux/grsecurity.h>
49045
49046 #include <asm/uaccess.h>
49047 #include <asm/byteorder.h>
49048 @@ -4433,6 +4434,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49049 goto done;
49050 return;
49051 }
49052 +
49053 + if (gr_handle_new_usb())
49054 + goto done;
49055 +
49056 if (hub_is_superspeed(hub->hdev))
49057 unit_load = 150;
49058 else
49059 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49060 index e7ee1e4..1dfc9ea4 100644
49061 --- a/drivers/usb/core/message.c
49062 +++ b/drivers/usb/core/message.c
49063 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49064 * method can wait for it to complete. Since you don't have a handle on the
49065 * URB used, you can't cancel the request.
49066 */
49067 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49068 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49069 __u8 requesttype, __u16 value, __u16 index, void *data,
49070 __u16 size, int timeout)
49071 {
49072 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49073 index d9284b9..17023c7 100644
49074 --- a/drivers/usb/core/sysfs.c
49075 +++ b/drivers/usb/core/sysfs.c
49076 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
49077 struct usb_device *udev;
49078
49079 udev = to_usb_device(dev);
49080 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49081 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49082 }
49083 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
49084
49085 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49086 index 7dad603..350f7a9 100644
49087 --- a/drivers/usb/core/usb.c
49088 +++ b/drivers/usb/core/usb.c
49089 @@ -422,7 +422,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49090 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49091 dev->state = USB_STATE_ATTACHED;
49092 dev->lpm_disable_count = 1;
49093 - atomic_set(&dev->urbnum, 0);
49094 + atomic_set_unchecked(&dev->urbnum, 0);
49095
49096 INIT_LIST_HEAD(&dev->ep0.urb_list);
49097 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49098 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49099 index 14d28d6..5f511ac 100644
49100 --- a/drivers/usb/dwc3/gadget.c
49101 +++ b/drivers/usb/dwc3/gadget.c
49102 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49103 if (!usb_endpoint_xfer_isoc(desc))
49104 return 0;
49105
49106 - memset(&trb_link, 0, sizeof(trb_link));
49107 -
49108 /* Link TRB for ISOC. The HWO bit is never reset */
49109 trb_st_hw = &dep->trb_pool[0];
49110
49111 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49112 index 5e29dde..eca992f 100644
49113 --- a/drivers/usb/early/ehci-dbgp.c
49114 +++ b/drivers/usb/early/ehci-dbgp.c
49115 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49116
49117 #ifdef CONFIG_KGDB
49118 static struct kgdb_io kgdbdbgp_io_ops;
49119 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49120 +static struct kgdb_io kgdbdbgp_io_ops_console;
49121 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49122 #else
49123 #define dbgp_kgdb_mode (0)
49124 #endif
49125 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49126 .write_char = kgdbdbgp_write_char,
49127 };
49128
49129 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49130 + .name = "kgdbdbgp",
49131 + .read_char = kgdbdbgp_read_char,
49132 + .write_char = kgdbdbgp_write_char,
49133 + .is_console = 1
49134 +};
49135 +
49136 static int kgdbdbgp_wait_time;
49137
49138 static int __init kgdbdbgp_parse_config(char *str)
49139 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49140 ptr++;
49141 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49142 }
49143 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49144 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49145 + if (early_dbgp_console.index != -1)
49146 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49147 + else
49148 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49149
49150 return 0;
49151 }
49152 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49153 index b369292..9f3ba40 100644
49154 --- a/drivers/usb/gadget/u_serial.c
49155 +++ b/drivers/usb/gadget/u_serial.c
49156 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49157 spin_lock_irq(&port->port_lock);
49158
49159 /* already open? Great. */
49160 - if (port->port.count) {
49161 + if (atomic_read(&port->port.count)) {
49162 status = 0;
49163 - port->port.count++;
49164 + atomic_inc(&port->port.count);
49165
49166 /* currently opening/closing? wait ... */
49167 } else if (port->openclose) {
49168 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49169 tty->driver_data = port;
49170 port->port.tty = tty;
49171
49172 - port->port.count = 1;
49173 + atomic_set(&port->port.count, 1);
49174 port->openclose = false;
49175
49176 /* if connected, start the I/O stream */
49177 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49178
49179 spin_lock_irq(&port->port_lock);
49180
49181 - if (port->port.count != 1) {
49182 - if (port->port.count == 0)
49183 + if (atomic_read(&port->port.count) != 1) {
49184 + if (atomic_read(&port->port.count) == 0)
49185 WARN_ON(1);
49186 else
49187 - --port->port.count;
49188 + atomic_dec(&port->port.count);
49189 goto exit;
49190 }
49191
49192 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49193 * and sleep if necessary
49194 */
49195 port->openclose = true;
49196 - port->port.count = 0;
49197 + atomic_set(&port->port.count, 0);
49198
49199 gser = port->port_usb;
49200 if (gser && gser->disconnect)
49201 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49202 int cond;
49203
49204 spin_lock_irq(&port->port_lock);
49205 - cond = (port->port.count == 0) && !port->openclose;
49206 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49207 spin_unlock_irq(&port->port_lock);
49208 return cond;
49209 }
49210 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49211 /* if it's already open, start I/O ... and notify the serial
49212 * protocol about open/close status (connect/disconnect).
49213 */
49214 - if (port->port.count) {
49215 + if (atomic_read(&port->port.count)) {
49216 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49217 gs_start_io(port);
49218 if (gser->connect)
49219 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49220
49221 port->port_usb = NULL;
49222 gser->ioport = NULL;
49223 - if (port->port.count > 0 || port->openclose) {
49224 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49225 wake_up_interruptible(&port->drain_wait);
49226 if (port->port.tty)
49227 tty_hangup(port->port.tty);
49228 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49229
49230 /* finally, free any unused/unusable I/O buffers */
49231 spin_lock_irqsave(&port->port_lock, flags);
49232 - if (port->port.count == 0 && !port->openclose)
49233 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49234 gs_buf_free(&port->port_write_buf);
49235 gs_free_requests(gser->out, &port->read_pool, NULL);
49236 gs_free_requests(gser->out, &port->read_queue, NULL);
49237 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49238 index ba6a5d6..f88f7f3 100644
49239 --- a/drivers/usb/misc/appledisplay.c
49240 +++ b/drivers/usb/misc/appledisplay.c
49241 @@ -83,7 +83,7 @@ struct appledisplay {
49242 spinlock_t lock;
49243 };
49244
49245 -static atomic_t count_displays = ATOMIC_INIT(0);
49246 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49247 static struct workqueue_struct *wq;
49248
49249 static void appledisplay_complete(struct urb *urb)
49250 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49251
49252 /* Register backlight device */
49253 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49254 - atomic_inc_return(&count_displays) - 1);
49255 + atomic_inc_return_unchecked(&count_displays) - 1);
49256 memset(&props, 0, sizeof(struct backlight_properties));
49257 props.type = BACKLIGHT_RAW;
49258 props.max_brightness = 0xff;
49259 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49260 index afb50ea..6b837ab 100644
49261 --- a/drivers/usb/serial/console.c
49262 +++ b/drivers/usb/serial/console.c
49263 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49264
49265 info->port = port;
49266
49267 - ++port->port.count;
49268 + atomic_inc(&port->port.count);
49269 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49270 if (serial->type->set_termios) {
49271 /*
49272 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49273 }
49274 /* Now that any required fake tty operations are completed restore
49275 * the tty port count */
49276 - --port->port.count;
49277 + atomic_dec(&port->port.count);
49278 /* The console is special in terms of closing the device so
49279 * indicate this port is now acting as a system console. */
49280 port->port.console = 1;
49281 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49282 free_tty:
49283 kfree(tty);
49284 reset_open_count:
49285 - port->port.count = 0;
49286 + atomic_set(&port->port.count, 0);
49287 usb_autopm_put_interface(serial->interface);
49288 error_get_interface:
49289 usb_serial_put(serial);
49290 @@ -198,7 +198,7 @@ static int usb_console_setup(struct console *co, char *options)
49291 static void usb_console_write(struct console *co,
49292 const char *buf, unsigned count)
49293 {
49294 - static struct usbcons_info *info = &usbcons_info;
49295 + struct usbcons_info *info = &usbcons_info;
49296 struct usb_serial_port *port = info->port;
49297 struct usb_serial *serial;
49298 int retval = -ENODEV;
49299 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49300 index 75f70f0..d467e1a 100644
49301 --- a/drivers/usb/storage/usb.h
49302 +++ b/drivers/usb/storage/usb.h
49303 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49304 __u8 useProtocol;
49305 __u8 useTransport;
49306 int (*initFunction)(struct us_data *);
49307 -};
49308 +} __do_const;
49309
49310
49311 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49312 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49313 index d6bea3e..60b250e 100644
49314 --- a/drivers/usb/wusbcore/wa-hc.h
49315 +++ b/drivers/usb/wusbcore/wa-hc.h
49316 @@ -192,7 +192,7 @@ struct wahc {
49317 struct list_head xfer_delayed_list;
49318 spinlock_t xfer_list_lock;
49319 struct work_struct xfer_work;
49320 - atomic_t xfer_id_count;
49321 + atomic_unchecked_t xfer_id_count;
49322 };
49323
49324
49325 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49326 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49327 spin_lock_init(&wa->xfer_list_lock);
49328 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49329 - atomic_set(&wa->xfer_id_count, 1);
49330 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49331 }
49332
49333 /**
49334 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49335 index d3493ca..0c33b7e 100644
49336 --- a/drivers/usb/wusbcore/wa-xfer.c
49337 +++ b/drivers/usb/wusbcore/wa-xfer.c
49338 @@ -297,7 +297,7 @@ out:
49339 */
49340 static void wa_xfer_id_init(struct wa_xfer *xfer)
49341 {
49342 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49343 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49344 }
49345
49346 /*
49347 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49348 index 842f450..d1d7409 100644
49349 --- a/drivers/vfio/vfio.c
49350 +++ b/drivers/vfio/vfio.c
49351 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49352 return 0;
49353
49354 /* TODO Prevent device auto probing */
49355 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49356 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49357 iommu_group_id(group->iommu_group));
49358
49359 return 0;
49360 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49361 index 5174eba..86e764a 100644
49362 --- a/drivers/vhost/vringh.c
49363 +++ b/drivers/vhost/vringh.c
49364 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49365
49366 static inline int putu16_kern(u16 *p, u16 val)
49367 {
49368 - ACCESS_ONCE(*p) = val;
49369 + ACCESS_ONCE_RW(*p) = val;
49370 return 0;
49371 }
49372
49373 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
49374 index e43401a..dd49b3f 100644
49375 --- a/drivers/video/arcfb.c
49376 +++ b/drivers/video/arcfb.c
49377 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
49378 return -ENOSPC;
49379
49380 err = 0;
49381 - if ((count + p) > fbmemlength) {
49382 + if (count > (fbmemlength - p)) {
49383 count = fbmemlength - p;
49384 err = -ENOSPC;
49385 }
49386 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49387 index a4dfe8c..297ddd9 100644
49388 --- a/drivers/video/aty/aty128fb.c
49389 +++ b/drivers/video/aty/aty128fb.c
49390 @@ -149,7 +149,7 @@ enum {
49391 };
49392
49393 /* Must match above enum */
49394 -static char * const r128_family[] = {
49395 +static const char * const r128_family[] = {
49396 "AGP",
49397 "PCI",
49398 "PRO AGP",
49399 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49400 index 9b0f12c..024673d 100644
49401 --- a/drivers/video/aty/atyfb_base.c
49402 +++ b/drivers/video/aty/atyfb_base.c
49403 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49404 par->accel_flags = var->accel_flags; /* hack */
49405
49406 if (var->accel_flags) {
49407 - info->fbops->fb_sync = atyfb_sync;
49408 + pax_open_kernel();
49409 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49410 + pax_close_kernel();
49411 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49412 } else {
49413 - info->fbops->fb_sync = NULL;
49414 + pax_open_kernel();
49415 + *(void **)&info->fbops->fb_sync = NULL;
49416 + pax_close_kernel();
49417 info->flags |= FBINFO_HWACCEL_DISABLED;
49418 }
49419
49420 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49421 index 95ec042..e6affdd 100644
49422 --- a/drivers/video/aty/mach64_cursor.c
49423 +++ b/drivers/video/aty/mach64_cursor.c
49424 @@ -7,6 +7,7 @@
49425 #include <linux/string.h>
49426
49427 #include <asm/io.h>
49428 +#include <asm/pgtable.h>
49429
49430 #ifdef __sparc__
49431 #include <asm/fbio.h>
49432 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49433 info->sprite.buf_align = 16; /* and 64 lines tall. */
49434 info->sprite.flags = FB_PIXMAP_IO;
49435
49436 - info->fbops->fb_cursor = atyfb_cursor;
49437 + pax_open_kernel();
49438 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49439 + pax_close_kernel();
49440
49441 return 0;
49442 }
49443 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49444 index bca6ccc..252107e 100644
49445 --- a/drivers/video/backlight/kb3886_bl.c
49446 +++ b/drivers/video/backlight/kb3886_bl.c
49447 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49448 static unsigned long kb3886bl_flags;
49449 #define KB3886BL_SUSPENDED 0x01
49450
49451 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49452 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49453 {
49454 .ident = "Sahara Touch-iT",
49455 .matches = {
49456 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49457 index 900aa4e..6d49418 100644
49458 --- a/drivers/video/fb_defio.c
49459 +++ b/drivers/video/fb_defio.c
49460 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49461
49462 BUG_ON(!fbdefio);
49463 mutex_init(&fbdefio->lock);
49464 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49465 + pax_open_kernel();
49466 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49467 + pax_close_kernel();
49468 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49469 INIT_LIST_HEAD(&fbdefio->pagelist);
49470 if (fbdefio->delay == 0) /* set a default of 1 s */
49471 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49472 page->mapping = NULL;
49473 }
49474
49475 - info->fbops->fb_mmap = NULL;
49476 + *(void **)&info->fbops->fb_mmap = NULL;
49477 mutex_destroy(&fbdefio->lock);
49478 }
49479 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49480 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49481 index 5c3960d..15cf8fc 100644
49482 --- a/drivers/video/fbcmap.c
49483 +++ b/drivers/video/fbcmap.c
49484 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49485 rc = -ENODEV;
49486 goto out;
49487 }
49488 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49489 - !info->fbops->fb_setcmap)) {
49490 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49491 rc = -EINVAL;
49492 goto out1;
49493 }
49494 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49495 index 36e1fe2..c744820 100644
49496 --- a/drivers/video/fbmem.c
49497 +++ b/drivers/video/fbmem.c
49498 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49499 image->dx += image->width + 8;
49500 }
49501 } else if (rotate == FB_ROTATE_UD) {
49502 - for (x = 0; x < num && image->dx >= 0; x++) {
49503 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49504 info->fbops->fb_imageblit(info, image);
49505 image->dx -= image->width + 8;
49506 }
49507 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49508 image->dy += image->height + 8;
49509 }
49510 } else if (rotate == FB_ROTATE_CCW) {
49511 - for (x = 0; x < num && image->dy >= 0; x++) {
49512 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49513 info->fbops->fb_imageblit(info, image);
49514 image->dy -= image->height + 8;
49515 }
49516 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49517 return -EFAULT;
49518 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49519 return -EINVAL;
49520 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49521 + if (con2fb.framebuffer >= FB_MAX)
49522 return -EINVAL;
49523 if (!registered_fb[con2fb.framebuffer])
49524 request_module("fb%d", con2fb.framebuffer);
49525 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49526 index 0f3b33c..b4304eb 100644
49527 --- a/drivers/video/hyperv_fb.c
49528 +++ b/drivers/video/hyperv_fb.c
49529 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49530 static inline int synthvid_send(struct hv_device *hdev,
49531 struct synthvid_msg *msg)
49532 {
49533 - static atomic64_t request_id = ATOMIC64_INIT(0);
49534 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49535 int ret;
49536
49537 msg->pipe_hdr.type = PIPE_MSG_DATA;
49538 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49539
49540 ret = vmbus_sendpacket(hdev->channel, msg,
49541 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49542 - atomic64_inc_return(&request_id),
49543 + atomic64_inc_return_unchecked(&request_id),
49544 VM_PKT_DATA_INBAND, 0);
49545
49546 if (ret)
49547 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49548 index 7672d2e..b56437f 100644
49549 --- a/drivers/video/i810/i810_accel.c
49550 +++ b/drivers/video/i810/i810_accel.c
49551 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49552 }
49553 }
49554 printk("ringbuffer lockup!!!\n");
49555 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49556 i810_report_error(mmio);
49557 par->dev_flags |= LOCKUP;
49558 info->pixmap.scan_align = 1;
49559 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49560 index 285d552..eafa544 100644
49561 --- a/drivers/video/logo/logo_linux_clut224.ppm
49562 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49563 @@ -1,883 +1,1123 @@
49564 P3
49565 80 80
49566 255
49567 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49568 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 33 49 54 59 85 92 73 97 106
49569 -83 116 129 105 131 142 115 114 122 74 88 93 20 29 31 0 0 0 0 0 0 0 0 0
49570 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49571 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 10 10 10
49572 -10 10 10 6 6 6 6 6 6 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49573 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49574 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49575 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49576 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49577 -
49578 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49579 -0 0 0 0 0 0 2 3 3 17 23 26 50 67 72 73 97 106 59 85 92 73 97 106
49580 -105 131 142 124 127 131 105 131 142 105 131 142 53 75 83 6 8 8 0 0 0 0 0 0
49581 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49582 -0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 26 26 26 30 30 30 34 34 34
49583 -30 30 30 30 30 30 26 26 26 18 18 18 14 14 14 10 10 10 6 6 6 0 0 0
49584 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49585 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49586 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49587 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49588 -
49589 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0
49590 -0 0 0 1 1 1 26 35 39 59 85 92 59 85 92 59 85 92 29 43 47 53 75 83
49591 -108 122 132 132 98 104 108 122 132 105 131 142 101 101 101 43 45 48 6 8 8 0 0 0
49592 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49593 -6 6 6 14 14 14 26 26 26 42 42 42 54 54 54 66 66 66 78 78 78 78 78 78
49594 -78 78 78 74 74 74 66 66 66 54 54 54 42 42 42 26 26 26 18 18 18 10 10 10
49595 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49596 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49597 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49598 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49599 -
49600 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0
49601 -11 15 17 27 40 45 59 85 92 59 85 92 27 40 45 31 45 49 73 97 106 93 121 133
49602 -108 122 132 108 122 132 105 131 142 108 122 132 105 131 142 73 97 106 26 35 39 0 0 0
49603 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49604 -22 22 22 42 42 42 66 66 66 86 86 86 66 66 66 38 38 38 38 38 38 22 22 22
49605 -26 26 26 34 34 34 54 54 54 66 66 66 86 86 86 70 70 70 46 46 46 26 26 26
49606 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49607 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49608 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49609 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49610 -
49611 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 7 12 13 21 31 35 42 59 64
49612 -53 75 83 53 75 83 50 67 72 42 59 64 32 40 45 42 59 64 73 97 106 116 116 116
49613 -132 98 104 116 116 116 108 122 132 117 104 110 105 131 142 83 116 129 50 67 72 7 12 13
49614 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49615 -50 50 50 82 82 82 58 58 58 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49616 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 54 54 54 86 86 86 66 66 66
49617 -38 38 38 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49618 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49619 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49620 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49621 -
49622 -0 0 0 1 1 1 6 8 8 15 22 25 26 35 39 36 54 60 53 75 83 59 85 92
49623 -59 85 92 48 63 69 15 22 25 12 17 20 52 67 79 94 94 94 132 98 104 132 98 104
49624 -117 104 110 108 122 132 108 122 132 115 114 122 105 131 142 77 105 114 59 85 92 36 54 60
49625 -7 12 13 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49626 -78 78 78 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49627 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 70 70 70
49628 -78 78 78 46 46 46 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49629 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49630 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49631 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49632 -
49633 -0 0 0 15 22 25 29 43 47 36 54 60 42 59 64 42 59 64 48 63 69 21 31 35
49634 -6 8 8 29 43 47 36 50 56 43 45 48 79 78 84 132 98 104 165 78 79 132 98 104
49635 -108 122 132 117 104 110 117 104 110 108 122 132 77 105 114 73 97 106 95 131 149 78 102 129
49636 -36 50 56 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 42 42 42 82 82 82
49637 -26 26 26 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49638 -2 2 6 2 2 6 2 2 6 14 14 14 46 46 46 34 34 34 6 6 6 2 2 6
49639 -42 42 42 78 78 78 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49640 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49641 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49642 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49643 -
49644 -27 40 45 53 75 83 48 63 69 24 31 37 6 8 12 0 0 0 18 25 28 26 35 39
49645 -12 17 20 26 35 39 65 78 84 112 81 86 152 81 83 137 83 86 132 98 104 117 104 110
49646 -117 104 110 132 98 104 132 98 104 115 114 122 73 97 106 53 75 83 95 131 149 93 124 152
49647 -68 78 128 15 22 25 0 0 0 0 0 0 10 10 10 30 30 30 66 66 66 58 58 58
49648 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49649 -2 2 6 2 2 6 2 2 6 26 26 26 86 86 86 101 101 101 46 46 46 10 10 10
49650 -2 2 6 58 58 58 70 70 70 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
49651 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49652 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49653 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49654 -
49655 -36 50 56 21 30 33 4 7 7 0 0 0 1 1 1 17 12 12 69 31 31 68 59 64
49656 -57 59 63 21 31 35 32 40 45 86 73 69 152 81 83 152 81 83 117 104 110 132 98 104
49657 -152 81 83 132 98 104 108 122 132 77 105 114 77 105 114 93 121 133 95 131 149 93 124 152
49658 -95 131 149 53 75 83 11 15 17 0 0 0 14 14 14 42 42 42 86 86 86 10 10 10
49659 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49660 -2 2 6 2 2 6 2 2 6 30 30 30 94 94 94 94 94 94 58 58 58 26 26 26
49661 -2 2 6 6 6 6 78 78 78 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0
49662 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49663 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49664 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49665 -
49666 -17 23 26 2 3 3 0 0 0 17 12 12 69 31 31 123 55 55 123 55 55 152 81 83
49667 -86 73 69 17 23 26 7 12 13 45 54 57 101 101 101 137 83 86 132 98 104 132 98 104
49668 -137 83 86 117 104 110 77 105 114 42 59 64 50 67 72 78 102 129 91 117 157 91 117 157
49669 -95 131 149 83 116 129 40 48 73 6 6 6 22 22 22 62 62 62 62 62 62 2 2 6
49670 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49671 -2 2 6 2 2 6 2 2 6 26 26 26 54 54 54 38 38 38 18 18 18 10 10 10
49672 -2 2 6 2 2 6 34 34 34 82 82 82 38 38 38 14 14 14 0 0 0 0 0 0
49673 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49674 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49675 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49676 -
49677 -1 1 1 1 2 2 2 3 3 28 12 12 123 55 55 174 79 79 174 79 79 174 79 79
49678 -152 81 83 68 59 64 26 35 39 27 40 45 79 78 84 137 83 86 165 78 79 137 83 86
49679 -94 94 94 48 63 69 36 50 56 50 67 72 73 97 106 93 121 133 93 124 152 93 124 152
49680 -95 131 149 91 118 149 78 102 129 27 40 45 30 30 30 78 78 78 30 30 30 2 2 6
49681 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49682 -2 2 6 2 2 6 2 2 6 10 10 10 10 10 10 2 2 6 2 2 6 2 2 6
49683 -2 2 6 2 2 6 2 2 6 78 78 78 50 50 50 18 18 18 6 6 6 0 0 0
49684 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49685 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0
49687 -
49688 -4 5 3 24 53 24 19 31 15 8 7 3 90 61 47 165 78 79 174 79 79 174 79 79
49689 -174 79 79 137 83 86 60 52 57 7 12 13 17 23 26 70 70 70 132 98 104 112 81 86
49690 -79 78 84 31 45 49 15 22 25 53 75 83 91 118 149 86 106 160 91 117 157 93 124 152
49691 -91 117 157 93 124 152 95 131 149 53 75 83 50 50 50 86 86 86 14 14 14 2 2 6
49692 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49693 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49694 -2 2 6 2 2 6 2 2 6 54 54 54 66 66 66 26 26 26 6 6 6 0 0 0
49695 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49698 -
49699 -19 31 15 34 76 34 34 76 34 19 31 15 28 12 12 123 55 55 174 79 79 174 79 79
49700 -174 79 79 165 78 79 112 81 86 32 40 45 15 22 25 38 53 58 65 78 84 29 31 32
49701 -21 30 33 42 59 64 60 80 103 78 102 129 87 112 149 84 96 162 91 117 157 93 124 152
49702 -91 117 157 93 124 152 93 121 133 59 85 92 57 68 71 82 85 86 2 2 6 2 2 6
49703 -2 2 6 6 6 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49704 -2 2 6 2 2 6 2 2 6 6 6 6 14 14 14 10 10 10 2 2 6 2 2 6
49705 -2 2 6 2 2 6 2 2 6 18 18 18 82 82 82 34 34 34 10 10 10 0 0 0
49706 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49707 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49708 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49709 -
49710 -34 76 34 40 89 40 40 89 40 34 76 34 8 15 6 48 26 18 123 55 55 174 79 79
49711 -174 79 79 174 79 79 137 83 86 68 59 64 32 40 45 21 30 33 31 45 49 21 31 35
49712 -12 17 20 48 63 69 78 102 129 81 88 166 84 96 162 91 117 157 93 124 152 91 117 157
49713 -93 124 152 95 131 149 83 116 129 59 85 92 57 68 71 86 86 86 2 2 6 2 2 6
49714 -6 6 6 6 6 6 22 22 22 34 34 34 6 6 6 2 2 6 2 2 6 2 2 6
49715 -2 2 6 2 2 6 18 18 18 34 34 34 10 10 10 50 50 50 22 22 22 2 2 6
49716 -2 2 6 2 2 6 2 2 6 10 10 10 86 86 86 42 42 42 14 14 14 0 0 0
49717 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0
49719 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49720 -
49721 -40 89 40 40 89 40 40 89 40 40 89 40 24 53 24 6 6 6 69 31 31 123 55 55
49722 -123 55 55 90 61 47 69 31 31 36 32 33 21 31 35 7 12 13 18 25 28 48 63 69
49723 -60 80 103 68 78 128 84 101 153 84 96 162 84 96 162 91 117 157 91 117 157 84 96 162
49724 -91 117 157 73 97 106 48 63 69 50 67 72 57 59 63 86 86 86 2 2 6 2 2 6
49725 -38 38 38 116 116 116 94 94 94 22 22 22 22 22 22 2 2 6 2 2 6 2 2 6
49726 -14 14 14 86 86 86 124 131 137 170 170 170 151 151 151 38 38 38 26 26 26 6 6 6
49727 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 46 46 46 14 14 14 0 0 0
49728 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49729 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49730 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49731 -
49732 -34 76 34 40 89 40 40 89 40 40 89 40 34 76 34 19 31 15 17 12 12 48 26 18
49733 -48 26 18 8 7 3 10 10 22 23 29 47 51 61 92 42 59 64 21 30 33 34 45 54
49734 -68 78 128 81 88 166 81 82 173 86 106 160 86 106 160 84 96 162 86 106 160 87 112 149
49735 -91 118 149 77 105 114 52 67 79 32 40 45 50 50 50 86 86 86 2 2 6 14 14 14
49736 -124 131 137 198 198 198 195 195 195 116 116 116 10 10 10 2 2 6 2 2 6 6 6 6
49737 -101 98 89 187 187 187 210 210 210 218 218 218 214 214 214 124 131 137 14 14 14 6 6 6
49738 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 50 50 50 18 18 18 6 6 6
49739 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49740 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49741 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49742 -
49743 -19 31 15 34 76 34 40 89 40 40 89 40 40 89 40 24 53 24 8 7 3 0 0 0
49744 -6 8 12 28 32 52 51 61 92 54 54 122 74 77 160 68 78 128 26 35 39 6 8 8
49745 -34 45 54 68 78 128 84 96 162 86 106 160 86 106 160 81 88 166 84 96 162 87 112 149
49746 -73 97 106 36 50 56 33 49 54 18 18 18 46 46 46 86 86 86 2 2 6 54 54 54
49747 -218 218 218 195 195 195 226 226 226 246 246 246 58 58 58 2 2 6 2 2 6 30 30 30
49748 -210 210 210 253 253 253 170 170 170 124 127 131 221 221 221 234 234 234 74 74 74 2 2 6
49749 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49750 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49751 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49752 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49753 -
49754 -4 5 3 24 53 24 40 89 40 40 89 40 34 76 34 12 22 15 4 5 3 4 5 3
49755 -13 17 26 54 54 122 78 78 174 78 78 174 78 78 174 74 77 160 51 61 92 21 31 35
49756 -26 35 39 53 75 83 84 101 153 81 82 173 81 88 166 84 101 153 60 80 103 60 80 103
49757 -53 75 83 38 53 58 42 59 64 22 22 22 46 46 46 82 82 82 2 2 6 106 106 106
49758 -170 170 170 26 26 26 86 86 86 226 226 226 124 127 131 10 10 10 14 14 14 46 46 46
49759 -231 231 231 190 190 190 6 6 6 70 70 70 90 90 90 238 238 238 151 151 151 2 2 6
49760 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49761 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49762 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49763 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49764 -
49765 -1 2 2 8 15 6 24 53 24 34 76 34 19 31 15 8 15 6 63 55 20 63 55 20
49766 -18 18 18 40 48 73 74 77 160 78 78 174 78 78 174 81 82 173 74 77 160 52 67 79
49767 -17 23 26 21 31 35 60 80 103 81 88 166 74 77 160 78 102 129 36 54 60 12 17 20
49768 -42 59 64 48 63 69 21 31 35 18 18 18 42 42 42 86 86 86 6 6 6 116 116 116
49769 -106 106 106 6 6 6 70 70 70 151 151 151 124 127 131 18 18 18 38 38 38 54 54 54
49770 -221 221 221 106 106 106 2 2 6 14 14 14 46 46 46 190 190 190 198 198 198 2 2 6
49771 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49772 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49773 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49774 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49775 -
49776 -11 15 17 0 0 0 12 22 15 19 31 15 8 15 6 63 55 20 149 139 69 149 139 69
49777 -63 55 20 10 10 22 54 54 122 78 78 174 78 78 174 78 78 174 81 82 173 68 78 128
49778 -24 31 37 6 6 6 36 50 56 60 80 103 51 61 92 42 59 64 36 50 56 31 45 49
49779 -29 43 47 27 40 45 6 8 8 14 14 14 42 42 42 94 94 94 14 14 14 101 101 101
49780 -124 127 131 2 2 6 18 18 18 116 116 116 106 107 48 121 92 8 121 92 8 98 70 6
49781 -170 170 170 106 106 106 2 2 6 2 2 6 2 2 6 195 195 195 195 195 195 6 6 6
49782 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49783 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49784 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49785 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49786 -
49787 -26 35 39 3 5 6 1 1 1 2 3 3 35 31 12 133 118 54 175 176 80 175 176 80
49788 -133 118 54 35 31 12 23 29 47 54 54 122 78 78 174 78 78 174 74 77 160 68 78 128
49789 -51 61 92 31 45 49 26 35 39 36 50 56 29 43 47 7 12 13 21 30 33 42 59 64
49790 -18 25 28 7 12 13 1 1 1 10 10 10 38 38 38 90 90 90 14 14 14 58 58 58
49791 -210 210 210 26 26 26 62 42 6 154 114 10 226 170 11 237 188 10 220 174 15 184 138 11
49792 -220 174 15 174 140 55 35 31 12 2 2 6 70 70 70 246 246 246 124 131 137 2 2 6
49793 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 66 66 66 26 26 26 6 6 6
49794 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49795 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49796 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49797 -
49798 -27 40 45 17 23 26 2 3 3 1 1 1 56 77 35 165 152 80 175 176 80 175 176 80
49799 -175 176 80 106 107 48 22 22 22 28 32 52 54 54 122 54 54 122 51 61 92 28 32 52
49800 -20 27 34 31 45 49 11 15 17 7 12 13 36 50 56 31 45 49 29 43 47 36 50 56
49801 -6 8 8 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 14 14 14 10 10 10
49802 -195 195 195 198 179 130 192 133 9 220 174 15 239 182 13 237 188 10 232 195 16 239 207 25
49803 -237 201 50 241 208 19 232 195 16 184 138 11 198 179 130 208 206 196 42 42 42 2 2 6
49804 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 74 74 74 30 30 30 6 6 6
49805 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49806 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49807 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49808 -
49809 -15 22 25 26 35 39 15 22 25 0 0 0 35 31 12 133 118 54 175 176 80 175 176 80
49810 -175 176 80 165 152 80 56 77 35 6 8 12 23 29 47 13 17 26 2 2 6 0 0 0
49811 -1 2 2 26 35 39 26 35 39 26 35 39 42 59 64 42 59 64 20 29 31 6 8 8
49812 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 86 86 86 14 14 14 2 2 6
49813 -121 92 8 192 133 9 219 162 10 239 182 13 237 188 10 232 195 16 241 208 19 237 201 50
49814 -237 201 50 239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 121 92 8 2 2 6
49815 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 82 82 82 34 34 34 10 10 10
49816 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49817 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49818 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49819 -
49820 -1 2 2 15 22 25 31 45 49 6 8 12 4 5 3 63 55 20 149 139 69 175 176 80
49821 -175 176 80 175 176 80 106 107 48 20 16 6 1 1 1 0 0 0 2 3 3 11 15 17
49822 -21 30 33 36 50 56 36 50 56 24 31 37 15 22 25 6 8 8 0 0 0 0 0 0
49823 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 82 82 82 30 30 30 62 42 6
49824 -180 123 7 206 145 10 230 174 11 239 182 13 237 188 10 238 202 15 241 208 19 237 201 50
49825 -239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 220 174 15 184 138 11 6 6 6
49826 -2 2 6 2 2 6 2 2 6 2 2 6 26 26 26 94 94 94 42 42 42 14 14 14
49827 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49828 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49829 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49830 -
49831 -0 0 0 1 2 2 29 43 47 26 35 39 3 5 6 8 7 3 106 107 48 165 152 80
49832 -175 176 80 149 139 69 63 55 20 4 5 3 2 3 3 12 17 20 26 35 39 26 35 39
49833 -17 23 26 7 12 13 6 8 8 3 5 6 1 2 2 0 0 0 0 0 0 0 0 0
49834 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 50 50 50 104 69 6
49835 -192 133 9 216 158 10 236 178 12 237 188 10 232 195 16 241 208 19 237 201 50 237 201 50
49836 -241 208 19 241 208 19 241 208 19 204 160 10 200 144 11 216 158 10 156 118 10 2 2 6
49837 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 90 90 90 54 54 54 18 18 18
49838 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49839 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49840 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49841 -
49842 -0 0 0 0 0 0 12 17 20 27 40 45 18 25 28 1 1 1 35 31 12 106 107 48
49843 -149 139 69 56 77 35 8 7 3 1 2 2 12 17 20 26 35 39 21 31 35 11 15 17
49844 -3 5 6 1 1 1 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 10 10 10 30 30 30 78 78 78 46 46 46 22 22 22
49846 -137 92 6 204 160 10 239 182 13 237 188 10 238 202 15 241 208 19 241 208 19 241 208 19
49847 -241 208 19 204 160 10 184 138 11 210 150 10 216 158 10 210 150 10 98 70 6 2 2 6
49848 -6 6 6 54 54 54 14 14 14 2 2 6 2 2 6 62 62 62 74 74 74 30 30 30
49849 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49850 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49851 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49852 -
49853 -0 0 0 0 0 0 1 1 1 15 22 25 33 49 54 12 17 20 2 3 3 35 31 12
49854 -56 77 35 20 16 6 1 1 1 18 25 28 21 31 35 11 15 17 1 1 1 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 10 10 10 34 34 34 78 78 78 50 50 50 6 6 6
49857 -88 55 22 139 102 15 190 146 13 230 187 11 239 207 25 232 195 16 220 174 15 190 146 13
49858 -171 120 8 192 133 9 210 150 10 213 154 11 185 146 40 165 152 80 101 98 89 2 2 6
49859 -2 2 6 78 78 78 116 116 116 58 58 58 2 2 6 22 22 22 90 90 90 46 46 46
49860 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49861 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49862 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49863 -
49864 -0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 29 43 47 3 5 6 2 3 3
49865 -8 7 3 1 1 1 17 23 26 31 45 49 15 22 25 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 10 10 10 38 38 38 86 86 86 50 50 50 6 6 6
49868 -124 127 131 168 158 138 156 107 11 171 120 8 204 160 10 184 138 11 197 138 11 200 144 11
49869 -206 145 10 206 145 10 197 138 11 198 179 130 195 195 195 198 198 198 170 170 170 14 14 14
49870 -2 2 6 22 22 22 116 116 116 116 116 116 22 22 22 2 2 6 74 74 74 70 70 70
49871 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49872 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49873 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49874 -
49875 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 31 45 49 26 35 39 3 5 6
49876 -0 0 0 7 12 13 27 40 45 18 25 28 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 6 6 6 18 18 18 50 50 50 101 101 101 26 26 26 10 10 10
49879 -124 131 137 190 190 190 168 158 138 156 107 11 197 138 11 200 144 11 197 138 11 192 133 9
49880 -180 123 7 185 146 40 198 179 130 187 187 187 202 202 202 221 221 221 214 214 214 66 66 66
49881 -2 2 6 2 2 6 50 50 50 62 62 62 6 6 6 2 2 6 10 10 10 90 90 90
49882 -50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49883 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49884 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49885 -
49886 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 15 22 25 36 54 60 18 25 28
49887 -0 0 0 21 30 33 27 40 45 2 3 3 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 10 10 10 34 34 34 74 74 74 74 74 74 2 2 6 6 6 6
49890 -151 151 151 198 198 198 190 190 190 168 158 138 148 132 55 156 107 11 156 107 11 169 125 40
49891 -168 158 138 187 187 187 190 190 190 210 210 210 246 246 246 253 253 253 253 253 253 180 180 180
49892 -6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62
49893 -74 74 74 34 34 34 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49894 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49895 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49896 -
49897 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 35 52 58
49898 -18 25 28 35 52 58 17 23 26 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 10 10 10 22 22 22 54 54 54 94 94 94 18 18 18 2 2 6 46 46 46
49901 -234 234 234 221 221 221 190 190 190 190 190 190 190 190 190 187 187 187 187 187 187 190 190 190
49902 -190 190 190 195 195 195 214 214 214 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49903 -82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 14 14 14
49904 -86 86 86 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49905 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49906 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49907 -
49908 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 12 13 33 49 54
49909 -52 72 81 36 54 60 6 8 8 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 -6 6 6 18 18 18 46 46 46 90 90 90 46 46 46 18 18 18 6 6 6 180 180 180
49912 -253 253 253 246 246 246 202 202 202 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190
49913 -202 202 202 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49914 -202 202 202 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49915 -42 42 42 86 86 86 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49916 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49917 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49918 -
49919 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20
49920 -36 54 60 29 43 47 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 6 6 6
49922 -14 14 14 38 38 38 74 74 74 66 66 66 2 2 6 6 6 6 90 90 90 250 250 250
49923 -253 253 253 253 253 253 238 238 238 198 198 198 190 190 190 190 190 190 195 195 195 221 221 221
49924 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49925 -253 253 253 82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49926 -2 2 6 78 78 78 70 70 70 34 34 34 14 14 14 6 6 6 0 0 0 0 0 0
49927 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49928 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49929 -
49930 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49931 -21 30 33 35 52 58 6 8 12 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 14 14 14
49933 -34 34 34 66 66 66 78 78 78 6 6 6 2 2 6 18 18 18 218 218 218 253 253 253
49934 -253 253 253 253 253 253 253 253 253 246 246 246 226 226 226 231 231 231 246 246 246 253 253 253
49935 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49936 -253 253 253 180 180 180 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49937 -2 2 6 18 18 18 90 90 90 62 62 62 30 30 30 10 10 10 0 0 0 0 0 0
49938 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49939 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49940 -
49941 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49942 -12 17 20 36 54 60 29 43 47 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 10 10 10 26 26 26
49944 -58 58 58 90 90 90 18 18 18 2 2 6 2 2 6 106 106 106 253 253 253 253 253 253
49945 -253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253
49946 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49947 -253 253 253 231 231 231 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49948 -2 2 6 2 2 6 18 18 18 94 94 94 54 54 54 26 26 26 10 10 10 0 0 0
49949 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49950 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49951 -
49952 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49953 -0 0 0 21 30 33 35 52 58 6 8 12 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 6 6 6 22 22 22 50 50 50
49955 -90 90 90 26 26 26 2 2 6 2 2 6 14 14 14 195 195 195 250 250 250 253 253 253
49956 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49957 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49958 -250 250 250 242 242 242 54 54 54 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49959 -2 2 6 2 2 6 2 2 6 38 38 38 86 86 86 50 50 50 22 22 22 6 6 6
49960 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49961 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49962 -
49963 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49964 -0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0
49965 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 38 38 38 82 82 82
49966 -34 34 34 2 2 6 2 2 6 2 2 6 42 42 42 195 195 195 246 246 246 253 253 253
49967 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 242 242 242 250 250 250 253 253 253
49968 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 246 246 246 238 238 238
49969 -226 226 226 231 231 231 101 101 101 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49970 -2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 82 82 82 42 42 42 14 14 14
49971 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49972 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49973 -
49974 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49975 -0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0
49976 -0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 62 62 62 66 66 66
49977 -2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 170 170 170 202 202 202 234 234 234
49978 -246 246 246 250 250 250 250 250 250 238 238 238 226 226 226 231 231 231 238 238 238 250 250 250
49979 -250 250 250 250 250 250 246 246 246 231 231 231 214 214 214 202 202 202 202 202 202 202 202 202
49980 -198 198 198 202 202 202 180 180 180 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6
49981 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 30 30 30
49982 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49983 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49984 -
49985 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49986 -0 0 0 0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0
49987 -0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 82 82 82 18 18 18
49988 -2 2 6 2 2 6 2 2 6 10 10 10 94 94 94 180 180 180 218 218 218 242 242 242
49989 -250 250 250 253 253 253 253 253 253 250 250 250 234 234 234 253 253 253 253 253 253 253 253 253
49990 -253 253 253 253 253 253 253 253 253 246 246 246 238 238 238 226 226 226 210 210 210 202 202 202
49991 -195 195 195 195 195 195 210 210 210 151 151 151 6 6 6 14 14 14 50 50 50 14 14 14
49992 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 86 86 86 46 46 46
49993 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49994 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49995 -
49996 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49997 -0 0 0 0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0
49998 -0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 54 54 54 70 70 70 2 2 6
49999 -2 2 6 10 10 10 2 2 6 22 22 22 170 170 170 231 231 231 250 250 250 253 253 253
50000 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 253 253 253 253 253 253 253 253 253
50001 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246
50002 -231 231 231 202 202 202 198 198 198 226 226 226 94 94 94 2 2 6 6 6 6 38 38 38
50003 -30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66
50004 -26 26 26 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50005 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50006 -
50007 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50008 -0 0 0 0 0 0 0 0 0 0 0 0 6 8 8 33 49 54 29 43 47 6 8 12
50009 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 74 74 74 50 50 50 2 2 6
50010 -26 26 26 26 26 26 2 2 6 106 106 106 238 238 238 253 253 253 253 253 253 253 253 253
50011 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50012 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50013 -253 253 253 246 246 246 218 218 218 202 202 202 210 210 210 14 14 14 2 2 6 2 2 6
50014 -30 30 30 22 22 22 2 2 6 2 2 6 2 2 6 2 2 6 18 18 18 86 86 86
50015 -42 42 42 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50016 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50017 -
50018 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50019 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20 33 49 54 17 23 26
50020 -0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 90 90 90 22 22 22 2 2 6
50021 -42 42 42 2 2 6 18 18 18 218 218 218 253 253 253 253 253 253 253 253 253 253 253 253
50022 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50023 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50024 -253 253 253 253 253 253 250 250 250 221 221 221 218 218 218 101 101 101 2 2 6 14 14 14
50025 -18 18 18 38 38 38 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 78 78 78
50026 -58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50027 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50028 -
50029 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50030 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 22 25 36 54 60
50031 -0 0 0 0 0 0 0 0 0 18 18 18 54 54 54 82 82 82 2 2 6 26 26 26
50032 -22 22 22 2 2 6 124 127 131 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50033 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50034 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50035 -253 253 253 253 253 253 253 253 253 250 250 250 238 238 238 198 198 198 6 6 6 38 38 38
50036 -58 58 58 26 26 26 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 46 46 46
50037 -78 78 78 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50038 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50039 -
50040 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50041 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 30 33
50042 -36 54 60 0 0 0 0 0 0 30 30 30 74 74 74 58 58 58 2 2 6 42 42 42
50043 -2 2 6 22 22 22 231 231 231 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50044 -253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50045 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50046 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246 46 46 46 38 38 38
50047 -42 42 42 14 14 14 38 38 38 14 14 14 2 2 6 2 2 6 2 2 6 6 6 6
50048 -86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50049 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50050 -
50051 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50052 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50053 -36 54 60 0 0 0 0 0 0 42 42 42 90 90 90 18 18 18 18 18 18 26 26 26
50054 -2 2 6 116 116 116 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50055 -253 253 253 253 253 253 250 250 250 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50056 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50057 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 94 94 94 6 6 6
50058 -2 2 6 2 2 6 10 10 10 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6
50059 -74 74 74 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50060 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50061 -
50062 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50063 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50064 -0 0 0 36 54 60 26 26 26 66 66 66 82 82 82 2 2 6 38 38 38 6 6 6
50065 -14 14 14 210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50066 -253 253 253 253 253 253 246 246 246 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50067 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50068 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 2 2 6
50069 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50070 -42 42 42 74 74 74 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50071 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50072 -
50073 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50074 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50075 -6 6 6 36 54 60 21 30 33 90 90 90 26 26 26 6 6 6 42 42 42 2 2 6
50076 -74 74 74 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50077 -253 253 253 253 253 253 242 242 242 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50078 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50079 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 180 180 180 2 2 6
50080 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50081 -10 10 10 86 86 86 38 38 38 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50082 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50083 -
50084 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50085 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50086 -10 10 10 26 26 26 36 54 60 82 82 82 2 2 6 22 22 22 18 18 18 2 2 6
50087 -151 151 151 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50088 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50089 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50090 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50091 -2 2 6 2 2 6 2 2 6 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6
50092 -6 6 6 86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0
50093 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50094 -
50095 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50096 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50097 -18 18 18 46 46 46 86 86 86 36 54 60 2 2 6 34 34 34 10 10 10 6 6 6
50098 -210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50099 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50100 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50101 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 221 221 221 6 6 6
50102 -2 2 6 2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50103 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50104 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50105 -
50106 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50107 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50108 -26 26 26 66 66 66 62 62 62 2 2 6 2 2 6 38 38 38 10 10 10 26 26 26
50109 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50110 -253 253 253 253 253 253 231 231 231 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50111 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50112 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 231 231 231 6 6 6
50113 -2 2 6 2 2 6 10 10 10 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50114 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50115 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50116 -
50117 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50118 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50119 -38 38 38 78 78 78 6 6 6 2 2 6 2 2 6 46 46 46 14 14 14 42 42 42
50120 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50121 -253 253 253 253 253 253 231 231 231 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50122 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50123 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 10 10 10
50124 -2 2 6 2 2 6 22 22 22 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6
50125 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50126 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50127 -
50128 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50129 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50130 -50 50 50 74 74 74 2 2 6 2 2 6 14 14 14 70 70 70 34 34 34 62 62 62
50131 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50132 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50133 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50134 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 14 14 14
50135 -2 2 6 2 2 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50136 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50137 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50138 -
50139 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50140 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50141 -54 54 54 62 62 62 2 2 6 2 2 6 2 2 6 30 30 30 46 46 46 70 70 70
50142 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50143 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50144 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50145 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 226 226 226 10 10 10
50146 -2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50147 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50148 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50149 -
50150 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50151 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50152 -58 58 58 62 62 62 2 2 6 2 2 6 2 2 6 2 2 6 30 30 30 78 78 78
50153 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50154 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50155 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50156 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50157 -22 22 22 34 34 34 20 16 6 22 22 22 26 26 26 18 18 18 6 6 6 2 2 6
50158 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50159 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50160 -
50161 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50162 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 26 26 26
50163 -62 62 62 106 106 106 63 55 20 184 138 11 204 160 10 121 92 8 6 6 6 62 62 62
50164 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50165 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50166 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50167 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 18 18 18
50168 -14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 18 18 18 66 66 66 38 38 38
50169 -6 6 6 94 94 94 50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50170 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50171 -
50172 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50173 -0 0 0 0 0 0 0 0 0 6 6 6 10 10 10 10 10 10 18 18 18 38 38 38
50174 -78 78 78 138 132 106 216 158 10 242 186 14 246 190 14 246 190 14 156 118 10 10 10 10
50175 -90 90 90 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50176 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50177 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50178 -253 253 253 253 253 253 253 253 253 246 230 190 214 187 87 214 187 87 185 146 40 35 31 12
50179 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 46 46 46
50180 -26 26 26 106 106 106 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50181 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50182 -
50183 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50184 -0 0 0 6 6 6 14 14 14 22 22 22 30 30 30 38 38 38 50 50 50 70 70 70
50185 -106 106 106 185 146 40 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 154 114 10
50186 -6 6 6 74 74 74 226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50187 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50188 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50189 -253 253 253 253 253 253 253 253 253 237 201 50 241 196 14 241 208 19 232 195 16 35 31 12
50190 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 30 30 30 26 26 26
50191 -204 160 10 165 152 80 66 66 66 26 26 26 6 6 6 0 0 0 0 0 0 0 0 0
50192 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50193 -
50194 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50195 -6 6 6 18 18 18 38 38 38 58 58 58 78 78 78 86 86 86 101 101 101 124 127 131
50196 -174 140 55 210 150 10 234 174 13 246 186 14 246 190 14 246 190 14 246 190 14 237 188 10
50197 -98 70 6 2 2 6 46 46 46 198 198 198 253 253 253 253 253 253 253 253 253 253 253 253
50198 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50199 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50200 -253 253 253 253 253 253 253 253 253 214 187 87 242 186 14 241 196 14 204 160 10 20 16 6
50201 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 121 92 8
50202 -238 202 15 232 195 16 82 82 82 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
50203 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50204 -
50205 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50206 -14 14 14 38 38 38 70 70 70 148 132 55 185 146 40 200 144 11 197 138 11 197 138 11
50207 -213 154 11 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50208 -220 174 15 35 31 12 2 2 6 22 22 22 151 151 151 250 250 250 253 253 253 253 253 253
50209 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50210 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50211 -253 253 253 250 250 250 242 242 242 214 187 87 239 182 13 237 188 10 213 154 11 35 31 12
50212 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 42 6 220 174 15
50213 -237 188 10 237 188 10 113 101 86 42 42 42 14 14 14 0 0 0 0 0 0 0 0 0
50214 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50215 -
50216 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50217 -22 22 22 54 54 54 148 132 55 213 154 11 226 170 11 230 174 11 226 170 11 226 170 11
50218 -236 178 12 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50219 -241 196 14 184 138 11 10 10 10 2 2 6 6 6 6 116 116 116 242 242 242 253 253 253
50220 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50221 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50222 -253 253 253 231 231 231 198 198 198 213 164 39 236 178 12 236 178 12 210 150 10 137 92 6
50223 -20 16 6 2 2 6 2 2 6 2 2 6 6 6 6 62 42 6 200 144 11 236 178 12
50224 -239 182 13 239 182 13 124 112 88 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0
50225 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50226 -
50227 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50228 -30 30 30 70 70 70 169 125 40 226 170 11 239 182 13 242 186 14 242 186 14 246 186 14
50229 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50230 -246 190 14 232 195 16 98 70 6 2 2 6 2 2 6 2 2 6 66 66 66 221 221 221
50231 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50232 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50233 -253 253 253 202 202 202 198 198 198 213 164 39 230 174 11 230 174 11 216 158 10 192 133 9
50234 -163 110 8 120 80 7 98 70 6 120 80 7 167 114 7 197 138 11 226 170 11 239 182 13
50235 -242 186 14 242 186 14 165 152 80 78 78 78 34 34 34 14 14 14 6 6 6 0 0 0
50236 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50237 -
50238 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50239 -30 30 30 78 78 78 185 146 40 226 170 11 239 182 13 246 190 14 246 190 14 246 190 14
50240 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50241 -246 190 14 241 196 14 204 160 10 20 16 6 2 2 6 2 2 6 2 2 6 38 38 38
50242 -218 218 218 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50243 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50244 -250 250 250 202 202 202 198 198 198 213 164 39 226 170 11 236 178 12 224 166 10 210 150 10
50245 -200 144 11 197 138 11 192 133 9 197 138 11 210 150 10 226 170 11 242 186 14 246 190 14
50246 -246 190 14 246 186 14 220 174 15 124 112 88 62 62 62 30 30 30 14 14 14 6 6 6
50247 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50248 -
50249 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50250 -30 30 30 78 78 78 174 140 55 224 166 10 239 182 13 246 190 14 246 190 14 246 190 14
50251 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50252 -246 190 14 246 190 14 241 196 14 139 102 15 2 2 6 2 2 6 2 2 6 2 2 6
50253 -78 78 78 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50254 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50255 -250 250 250 214 214 214 198 198 198 185 146 40 219 162 10 236 178 12 234 174 13 224 166 10
50256 -216 158 10 213 154 11 213 154 11 216 158 10 226 170 11 239 182 13 246 190 14 246 190 14
50257 -246 190 14 246 190 14 242 186 14 213 164 39 101 101 101 58 58 58 30 30 30 14 14 14
50258 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50259 -
50260 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50261 -30 30 30 74 74 74 174 140 55 216 158 10 236 178 12 246 190 14 246 190 14 246 190 14
50262 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50263 -246 190 14 246 190 14 241 196 14 230 187 11 62 42 6 2 2 6 2 2 6 2 2 6
50264 -22 22 22 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50265 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50266 -253 253 253 226 226 226 187 187 187 169 125 40 216 158 10 236 178 12 239 182 13 236 178 12
50267 -230 174 11 226 170 11 226 170 11 230 174 11 236 178 12 242 186 14 246 190 14 246 190 14
50268 -246 190 14 246 190 14 246 186 14 239 182 13 213 164 39 106 106 106 66 66 66 34 34 34
50269 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50270 -
50271 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50272 -26 26 26 70 70 70 149 139 69 213 154 11 236 178 12 246 190 14 246 190 14 246 190 14
50273 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50274 -246 190 14 246 190 14 246 190 14 241 196 14 190 146 13 20 16 6 2 2 6 2 2 6
50275 -46 46 46 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50276 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50277 -253 253 253 221 221 221 86 86 86 156 107 11 216 158 10 236 178 12 242 186 14 246 186 14
50278 -242 186 14 239 182 13 239 182 13 242 186 14 242 186 14 246 186 14 246 190 14 246 190 14
50279 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 220 174 15 149 139 69 66 66 66
50280 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50281 -
50282 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50283 -26 26 26 70 70 70 149 139 69 210 150 10 236 178 12 246 190 14 246 190 14 246 190 14
50284 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50285 -246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 121 92 8 34 34 34 106 106 106
50286 -221 221 221 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50287 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50288 -242 242 242 82 82 82 20 16 6 163 110 8 216 158 10 236 178 12 242 186 14 246 190 14
50289 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50290 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 149 139 69
50291 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50292 -
50293 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50294 -30 30 30 78 78 78 149 139 69 210 150 10 236 178 12 246 186 14 246 190 14 246 190 14
50295 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50296 -246 190 14 246 190 14 246 190 14 246 190 14 241 196 14 220 174 15 198 179 130 253 253 253
50297 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50298 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 218 218 218
50299 -58 58 58 2 2 6 20 16 6 167 114 7 216 158 10 236 178 12 246 186 14 246 190 14
50300 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50301 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 242 186 14 185 146 40
50302 -54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50303 -
50304 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50305 -38 38 38 86 86 86 169 125 40 213 154 11 236 178 12 246 186 14 246 190 14 246 190 14
50306 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50307 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 190 146 13 214 214 214
50308 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50309 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 170 170 170 26 26 26
50310 -2 2 6 2 2 6 35 31 12 163 110 8 219 162 10 239 182 13 246 186 14 246 190 14
50311 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50312 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 224 166 10 149 139 69
50313 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50314 -
50315 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50316 -50 50 50 113 101 86 192 133 9 224 166 10 242 186 14 246 190 14 246 190 14 246 190 14
50317 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50318 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 230 187 11 204 160 10 133 118 54
50319 -226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50320 -253 253 253 253 253 253 253 253 253 253 253 253 198 198 198 66 66 66 2 2 6 2 2 6
50321 -2 2 6 2 2 6 62 42 6 156 107 11 219 162 10 239 182 13 246 186 14 246 190 14
50322 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50323 -246 190 14 246 190 14 246 190 14 242 186 14 234 174 13 213 154 11 148 132 55 66 66 66
50324 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50325 -
50326 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50327 -58 58 58 148 132 55 206 145 10 234 174 13 242 186 14 246 186 14 246 190 14 246 190 14
50328 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50329 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 204 160 10 163 110 8
50330 -62 42 6 124 131 137 218 218 218 250 250 250 253 253 253 253 253 253 253 253 253 250 250 250
50331 -242 242 242 210 210 210 151 151 151 66 66 66 6 6 6 2 2 6 2 2 6 2 2 6
50332 -2 2 6 2 2 6 62 42 6 163 110 8 216 158 10 236 178 12 246 190 14 246 190 14
50333 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50334 -246 190 14 239 182 13 230 174 11 216 158 10 185 146 40 124 112 88 70 70 70 38 38 38
50335 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50336 -
50337 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50338 -62 62 62 169 125 40 206 145 10 224 166 10 236 178 12 239 182 13 242 186 14 242 186 14
50339 -246 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50340 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 236 178 12 216 158 10 171 120 8
50341 -85 57 6 2 2 6 6 6 6 30 30 30 54 54 54 62 62 62 50 50 50 38 38 38
50342 -14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50343 -2 2 6 6 6 6 85 57 6 167 114 7 213 154 11 236 178 12 246 190 14 246 190 14
50344 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 239 182 13 239 182 13
50345 -230 174 11 210 150 10 174 140 55 124 112 88 82 82 82 54 54 54 34 34 34 18 18 18
50346 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50347 -
50348 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50349 -50 50 50 169 125 40 192 133 9 200 144 11 216 158 10 219 162 10 224 166 10 226 170 11
50350 -230 174 11 236 178 12 239 182 13 239 182 13 242 186 14 246 186 14 246 190 14 246 190 14
50351 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 230 174 11 210 150 10 163 110 8
50352 -104 69 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50353 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50354 -2 2 6 6 6 6 85 57 6 167 114 7 206 145 10 230 174 11 242 186 14 246 190 14
50355 -246 190 14 246 190 14 246 186 14 242 186 14 239 182 13 230 174 11 224 166 10 213 154 11
50356 -169 125 40 124 112 88 86 86 86 58 58 58 38 38 38 22 22 22 10 10 10 6 6 6
50357 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50358 -
50359 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50360 -34 34 34 70 70 70 133 118 54 169 125 40 167 114 7 180 123 7 192 133 9 197 138 11
50361 -200 144 11 206 145 10 213 154 11 219 162 10 224 166 10 230 174 11 239 182 13 242 186 14
50362 -246 186 14 246 186 14 246 186 14 246 186 14 239 182 13 216 158 10 184 138 11 152 99 6
50363 -104 69 6 20 16 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50364 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50365 -2 2 6 6 6 6 85 57 6 152 99 6 192 133 9 219 162 10 236 178 12 239 182 13
50366 -246 186 14 242 186 14 239 182 13 236 178 12 224 166 10 206 145 10 192 133 9 148 132 55
50367 -94 94 94 62 62 62 42 42 42 22 22 22 14 14 14 6 6 6 0 0 0 0 0 0
50368 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50369 -
50370 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50371 -18 18 18 34 34 34 58 58 58 78 78 78 101 98 89 124 112 88 133 118 54 156 107 11
50372 -163 110 8 167 114 7 171 120 8 180 123 7 184 138 11 197 138 11 210 150 10 219 162 10
50373 -226 170 11 236 178 12 236 178 12 234 174 13 219 162 10 197 138 11 163 110 8 134 84 6
50374 -85 57 6 10 10 10 2 2 6 2 2 6 18 18 18 38 38 38 38 38 38 38 38 38
50375 -38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 26 26 26 2 2 6
50376 -2 2 6 6 6 6 62 42 6 137 92 6 171 120 8 200 144 11 219 162 10 230 174 11
50377 -234 174 13 230 174 11 219 162 10 210 150 10 192 133 9 163 110 8 124 112 88 82 82 82
50378 -50 50 50 30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50379 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50380 -
50381 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50382 -6 6 6 14 14 14 22 22 22 34 34 34 42 42 42 58 58 58 74 74 74 86 86 86
50383 -101 98 89 113 101 86 133 118 54 121 92 8 137 92 6 152 99 6 163 110 8 180 123 7
50384 -184 138 11 197 138 11 206 145 10 200 144 11 180 123 7 156 107 11 134 84 6 104 69 6
50385 -62 42 6 54 54 54 106 106 106 101 98 89 86 86 86 82 82 82 78 78 78 78 78 78
50386 -78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 82 82 82 86 86 86 94 94 94
50387 -106 106 106 101 101 101 90 61 47 120 80 7 156 107 11 180 123 7 192 133 9 200 144 11
50388 -206 145 10 200 144 11 192 133 9 171 120 8 139 102 15 113 101 86 70 70 70 42 42 42
50389 -22 22 22 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50390 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50391 -
50392 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50393 -0 0 0 0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 30 30 30 38 38 38
50394 -50 50 50 62 62 62 74 74 74 90 90 90 101 98 89 113 101 86 121 92 8 120 80 7
50395 -137 92 6 152 99 6 152 99 6 152 99 6 134 84 6 120 80 7 98 70 6 88 55 22
50396 -101 98 89 82 82 82 58 58 58 46 46 46 38 38 38 34 34 34 34 34 34 34 34 34
50397 -34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 38 38 38 42 42 42
50398 -54 54 54 82 82 82 94 86 71 85 57 6 134 84 6 156 107 11 167 114 7 171 120 8
50399 -171 120 8 167 114 7 152 99 6 121 92 8 101 98 89 62 62 62 34 34 34 18 18 18
50400 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50401 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50402 -
50403 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50404 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10
50405 -18 18 18 22 22 22 30 30 30 42 42 42 50 50 50 66 66 66 86 86 86 101 98 89
50406 -94 86 71 98 70 6 104 69 6 104 69 6 104 69 6 85 57 6 88 55 22 90 90 90
50407 -62 62 62 38 38 38 22 22 22 14 14 14 10 10 10 10 10 10 10 10 10 10 10 10
50408 -10 10 10 10 10 10 6 6 6 10 10 10 10 10 10 10 10 10 10 10 10 14 14 14
50409 -22 22 22 42 42 42 70 70 70 94 86 71 85 57 6 104 69 6 120 80 7 137 92 6
50410 -134 84 6 120 80 7 94 86 71 86 86 86 58 58 58 30 30 30 14 14 14 6 6 6
50411 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50412 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50413 -
50414 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50415 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50416 -0 0 0 6 6 6 10 10 10 14 14 14 18 18 18 26 26 26 38 38 38 54 54 54
50417 -70 70 70 86 86 86 94 86 71 94 86 71 94 86 71 86 86 86 74 74 74 50 50 50
50418 -30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50419 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50420 -6 6 6 18 18 18 34 34 34 58 58 58 82 82 82 94 86 71 94 86 71 94 86 71
50421 -94 86 71 94 86 71 74 74 74 50 50 50 26 26 26 14 14 14 6 6 6 0 0 0
50422 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50423 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50424 -
50425 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50426 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50427 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 14 14 14 18 18 18
50428 -30 30 30 38 38 38 46 46 46 54 54 54 50 50 50 42 42 42 30 30 30 18 18 18
50429 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50430 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50431 -0 0 0 6 6 6 14 14 14 26 26 26 38 38 38 50 50 50 58 58 58 58 58 58
50432 -54 54 54 42 42 42 30 30 30 18 18 18 10 10 10 0 0 0 0 0 0 0 0 0
50433 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50434 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50435 -
50436 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50437 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50438 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50439 -6 6 6 10 10 10 14 14 14 18 18 18 18 18 18 14 14 14 10 10 10 6 6 6
50440 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50441 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50442 -0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 18 18 18 22 22 22 22 22 22
50443 -18 18 18 14 14 14 10 10 10 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50444 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50445 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50446 -
50447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50460 +4 4 4 4 4 4
50461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50474 +4 4 4 4 4 4
50475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50488 +4 4 4 4 4 4
50489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50502 +4 4 4 4 4 4
50503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50516 +4 4 4 4 4 4
50517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50530 +4 4 4 4 4 4
50531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50535 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
50536 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
50537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50540 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
50541 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50542 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
50543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50544 +4 4 4 4 4 4
50545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50549 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
50550 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
50551 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50554 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
50555 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
50556 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
50557 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50558 +4 4 4 4 4 4
50559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50563 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
50564 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
50565 +0 0 0 3 3 3 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 0 0 0 4 4 4 41 54 63 125 124 125
50569 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
50570 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
50571 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
50572 +4 4 4 4 4 4
50573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50576 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
50577 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
50578 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
50579 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 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 5 5 5 5 5 5
50582 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
50583 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
50584 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
50585 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
50586 +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 4 4 4 4 4 4 4 4 4 4 4 4
50590 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
50591 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
50592 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
50593 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
50594 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
50595 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
50596 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
50597 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
50598 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
50599 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
50600 +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 4 4 4 4 4 4 4 4 4 5 5 5
50604 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
50605 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
50606 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
50607 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
50608 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
50609 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
50610 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
50611 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
50612 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
50613 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
50614 +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 4 4 4 4 4 4 5 5 5 3 3 3
50618 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
50619 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
50620 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
50621 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
50622 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
50623 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
50624 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
50625 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
50626 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
50627 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
50628 +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 4 4 4 2 2 2 0 0 0 4 0 0
50632 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
50633 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
50634 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
50635 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
50636 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
50637 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
50638 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
50639 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
50640 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
50641 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
50642 +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 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
50646 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
50647 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
50648 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
50649 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
50650 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
50651 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
50652 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
50653 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
50654 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
50655 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50656 +4 4 4 4 4 4
50657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50659 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
50660 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
50661 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
50662 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
50663 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
50664 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
50665 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
50666 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
50667 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
50668 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
50669 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
50670 +4 4 4 4 4 4
50671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50672 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
50673 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
50674 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
50675 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
50676 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
50677 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
50678 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
50679 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
50680 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
50681 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
50682 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
50683 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
50684 +4 4 4 4 4 4
50685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50686 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
50687 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
50688 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
50689 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
50690 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
50691 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
50692 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
50693 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
50694 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
50695 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
50696 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
50697 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
50698 +0 0 0 4 4 4
50699 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50700 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
50701 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
50702 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
50703 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
50704 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
50705 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
50706 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
50707 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
50708 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
50709 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
50710 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
50711 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
50712 +2 0 0 0 0 0
50713 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
50714 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
50715 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
50716 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
50717 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
50718 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
50719 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
50720 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
50721 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
50722 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
50723 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
50724 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
50725 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
50726 +37 38 37 0 0 0
50727 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50728 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
50729 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
50730 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
50731 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
50732 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
50733 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
50734 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
50735 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
50736 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
50737 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
50738 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
50739 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
50740 +85 115 134 4 0 0
50741 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
50742 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
50743 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
50744 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
50745 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
50746 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
50747 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
50748 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
50749 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
50750 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
50751 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
50752 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
50753 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
50754 +60 73 81 4 0 0
50755 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
50756 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
50757 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
50758 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
50759 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
50760 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
50761 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
50762 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
50763 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
50764 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
50765 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
50766 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
50767 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
50768 +16 19 21 4 0 0
50769 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
50770 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
50771 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
50772 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
50773 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
50774 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
50775 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
50776 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
50777 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
50778 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
50779 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
50780 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
50781 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
50782 +4 0 0 4 3 3
50783 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
50784 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
50785 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
50786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
50787 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
50788 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
50789 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
50790 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
50791 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
50792 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
50793 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
50794 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
50795 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
50796 +3 2 2 4 4 4
50797 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
50798 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
50799 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
50800 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50801 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
50802 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
50803 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50804 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
50805 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
50806 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
50807 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
50808 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
50809 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
50810 +4 4 4 4 4 4
50811 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
50812 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
50813 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
50814 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
50815 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
50816 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
50817 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
50818 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
50819 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
50820 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
50821 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
50822 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
50823 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
50824 +4 4 4 4 4 4
50825 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
50826 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
50827 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
50828 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
50829 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
50830 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50831 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
50832 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
50833 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
50834 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
50835 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
50836 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
50837 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
50838 +5 5 5 5 5 5
50839 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
50840 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
50841 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
50842 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
50843 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
50844 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50845 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
50846 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
50847 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
50848 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
50849 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
50850 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
50851 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
50852 +5 5 5 4 4 4
50853 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
50854 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
50855 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
50856 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
50857 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50858 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
50859 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
50860 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
50861 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
50862 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
50863 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
50864 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
50865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50866 +4 4 4 4 4 4
50867 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
50868 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
50869 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
50870 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
50871 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
50872 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50873 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50874 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
50875 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
50876 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
50877 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
50878 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
50879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50880 +4 4 4 4 4 4
50881 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
50882 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
50883 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
50884 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
50885 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50886 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
50887 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
50888 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
50889 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
50890 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
50891 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
50892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50894 +4 4 4 4 4 4
50895 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
50896 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
50897 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
50898 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
50899 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50900 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50901 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50902 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
50903 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
50904 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
50905 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
50906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50908 +4 4 4 4 4 4
50909 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
50910 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
50911 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
50912 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
50913 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50914 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
50915 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50916 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
50917 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
50918 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
50919 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50922 +4 4 4 4 4 4
50923 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
50924 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
50925 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
50926 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
50927 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50928 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
50929 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
50930 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
50931 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
50932 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
50933 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
50934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50936 +4 4 4 4 4 4
50937 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
50938 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
50939 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
50940 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
50941 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50942 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
50943 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
50944 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
50945 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
50946 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
50947 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
50948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50950 +4 4 4 4 4 4
50951 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
50952 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
50953 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
50954 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50955 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
50956 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
50957 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
50958 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
50959 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
50960 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
50961 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50964 +4 4 4 4 4 4
50965 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
50966 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
50967 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
50968 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
50969 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50970 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
50971 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
50972 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
50973 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
50974 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
50975 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50978 +4 4 4 4 4 4
50979 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
50980 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
50981 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
50982 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50983 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50984 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
50985 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
50986 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
50987 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
50988 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
50989 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50992 +4 4 4 4 4 4
50993 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
50994 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
50995 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
50996 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
50997 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50998 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
50999 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51000 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51001 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51002 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51003 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51006 +4 4 4 4 4 4
51007 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51008 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51009 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51010 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51011 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51012 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51013 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51014 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51015 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51016 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51017 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51020 +4 4 4 4 4 4
51021 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51022 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51023 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51024 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51025 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51026 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51027 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51028 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51029 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51030 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51031 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51033 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51034 +4 4 4 4 4 4
51035 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51036 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51037 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51038 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51039 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51040 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51041 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51042 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51043 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51044 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51045 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51047 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51048 +4 4 4 4 4 4
51049 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51050 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51051 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51052 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51053 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51054 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51055 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51056 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51057 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51058 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51059 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51061 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51062 +4 4 4 4 4 4
51063 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51064 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51065 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51066 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51067 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51068 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51069 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51070 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51071 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51072 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51073 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51075 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51076 +4 4 4 4 4 4
51077 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51078 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51079 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51080 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51081 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51082 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51083 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51084 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51085 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51086 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51087 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51089 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51090 +4 4 4 4 4 4
51091 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51092 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51093 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51094 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51095 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51096 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51097 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51098 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51099 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51100 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51101 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51103 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51104 +4 4 4 4 4 4
51105 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51106 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51107 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51108 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51109 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51110 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51111 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51112 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51113 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51114 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51115 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51117 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51118 +4 4 4 4 4 4
51119 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51120 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51121 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51122 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51123 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51124 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51125 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51126 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51127 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51128 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51129 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51131 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51132 +4 4 4 4 4 4
51133 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51134 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51135 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51136 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51137 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51138 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51139 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51140 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51141 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51142 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51143 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51145 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51146 +4 4 4 4 4 4
51147 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51148 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51149 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51150 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51151 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51152 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51153 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51154 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51155 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51156 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51157 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51158 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51159 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51160 +4 4 4 4 4 4
51161 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51162 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51163 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51164 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51165 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51166 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51167 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51168 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51169 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51170 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51171 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51172 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51173 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51174 +4 4 4 4 4 4
51175 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51176 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51177 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51178 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51179 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51180 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51181 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51182 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51183 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51184 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51185 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51186 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51187 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51188 +4 4 4 4 4 4
51189 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51190 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51191 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51192 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51193 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51194 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51195 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51196 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51197 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51198 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51199 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51200 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51201 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51202 +4 4 4 4 4 4
51203 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51204 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51205 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51206 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51207 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51208 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51209 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51210 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51211 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51212 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51213 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51214 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51215 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51216 +4 4 4 4 4 4
51217 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51218 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51219 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51220 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51221 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51222 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51223 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51224 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51225 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51226 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51227 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51228 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51229 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51230 +4 4 4 4 4 4
51231 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51232 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51233 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51234 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51235 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51236 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51237 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51238 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51239 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51240 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51241 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51242 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51243 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51244 +4 4 4 4 4 4
51245 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51246 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51247 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51248 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51249 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51250 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51251 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51252 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51253 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51254 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51255 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51256 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51257 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51258 +4 4 4 4 4 4
51259 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51260 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51261 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51262 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51263 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51264 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51265 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51266 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51267 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51268 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51269 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51270 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51271 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51272 +4 4 4 4 4 4
51273 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51274 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51275 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51276 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51277 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51278 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51279 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51280 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51281 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51282 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51283 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51284 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51285 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51286 +4 4 4 4 4 4
51287 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51288 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51289 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51290 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51291 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51292 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51293 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51294 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51295 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51296 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51297 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51298 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51299 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51300 +4 4 4 4 4 4
51301 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51302 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51303 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51304 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51305 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51306 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51307 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51308 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51309 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51310 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51311 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51312 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51313 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51314 +4 4 4 4 4 4
51315 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51316 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51317 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51318 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51319 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51320 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51321 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51322 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51323 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51325 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51326 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51327 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51328 +4 4 4 4 4 4
51329 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51330 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51331 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51332 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51333 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51334 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51335 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51336 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51337 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51339 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51340 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51341 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51342 +4 4 4 4 4 4
51343 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51344 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51345 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51346 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51347 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51348 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51349 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51350 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51351 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51352 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51353 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51354 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51355 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51356 +4 4 4 4 4 4
51357 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51358 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51359 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51360 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51361 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51362 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51363 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51364 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51366 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51369 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51370 +4 4 4 4 4 4
51371 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51372 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51373 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51374 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51375 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51376 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51377 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51378 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51380 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51383 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51384 +4 4 4 4 4 4
51385 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51386 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51387 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51388 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51389 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51390 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51391 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51392 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51394 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51397 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51398 +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 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51401 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51402 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51403 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51404 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51405 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51406 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51411 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51412 +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 5 5 5 5 5 5 5 5 5
51415 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51416 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51417 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51418 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51419 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51420 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51421 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51425 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51426 +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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51430 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51431 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51432 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51433 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51434 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51435 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51440 +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 4 4 4 4 4 4 4 4 4 5 5 5
51444 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51445 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51446 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51447 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
51448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51454 +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 4 4 4 4 4 4 4 4 4 4 4 4
51458 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51459 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51460 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51461 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
51462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51468 +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 4 4 4 4 4 4 4 4 4 4 4 4
51472 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51473 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51474 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51475 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51482 +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 4 4 4 4 4 4 4 4 4 4 4 4
51486 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51487 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51488 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51489 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51496 +4 4 4 4 4 4
51497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51501 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51502 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51503 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51510 +4 4 4 4 4 4
51511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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 5 5 5 4 0 0 6 6 6
51516 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51517 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51524 +4 4 4 4 4 4
51525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51529 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
51530 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
51531 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51538 +4 4 4 4 4 4
51539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51543 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
51544 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
51545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51552 +4 4 4 4 4 4
51553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51557 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51558 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
51559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51566 +4 4 4 4 4 4
51567 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
51568 index fe92eed..106e085 100644
51569 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
51570 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
51571 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
51572 struct mb862xxfb_par *par = info->par;
51573
51574 if (info->var.bits_per_pixel == 32) {
51575 - info->fbops->fb_fillrect = cfb_fillrect;
51576 - info->fbops->fb_copyarea = cfb_copyarea;
51577 - info->fbops->fb_imageblit = cfb_imageblit;
51578 + pax_open_kernel();
51579 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51580 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51581 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51582 + pax_close_kernel();
51583 } else {
51584 outreg(disp, GC_L0EM, 3);
51585 - info->fbops->fb_fillrect = mb86290fb_fillrect;
51586 - info->fbops->fb_copyarea = mb86290fb_copyarea;
51587 - info->fbops->fb_imageblit = mb86290fb_imageblit;
51588 + pax_open_kernel();
51589 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
51590 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
51591 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
51592 + pax_close_kernel();
51593 }
51594 outreg(draw, GDC_REG_DRAW_BASE, 0);
51595 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
51596 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
51597 index ff22871..b129bed 100644
51598 --- a/drivers/video/nvidia/nvidia.c
51599 +++ b/drivers/video/nvidia/nvidia.c
51600 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
51601 info->fix.line_length = (info->var.xres_virtual *
51602 info->var.bits_per_pixel) >> 3;
51603 if (info->var.accel_flags) {
51604 - info->fbops->fb_imageblit = nvidiafb_imageblit;
51605 - info->fbops->fb_fillrect = nvidiafb_fillrect;
51606 - info->fbops->fb_copyarea = nvidiafb_copyarea;
51607 - info->fbops->fb_sync = nvidiafb_sync;
51608 + pax_open_kernel();
51609 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
51610 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
51611 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
51612 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
51613 + pax_close_kernel();
51614 info->pixmap.scan_align = 4;
51615 info->flags &= ~FBINFO_HWACCEL_DISABLED;
51616 info->flags |= FBINFO_READS_FAST;
51617 NVResetGraphics(info);
51618 } else {
51619 - info->fbops->fb_imageblit = cfb_imageblit;
51620 - info->fbops->fb_fillrect = cfb_fillrect;
51621 - info->fbops->fb_copyarea = cfb_copyarea;
51622 - info->fbops->fb_sync = NULL;
51623 + pax_open_kernel();
51624 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51625 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51626 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51627 + *(void **)&info->fbops->fb_sync = NULL;
51628 + pax_close_kernel();
51629 info->pixmap.scan_align = 1;
51630 info->flags |= FBINFO_HWACCEL_DISABLED;
51631 info->flags &= ~FBINFO_READS_FAST;
51632 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
51633 info->pixmap.size = 8 * 1024;
51634 info->pixmap.flags = FB_PIXMAP_SYSTEM;
51635
51636 - if (!hwcur)
51637 - info->fbops->fb_cursor = NULL;
51638 + if (!hwcur) {
51639 + pax_open_kernel();
51640 + *(void **)&info->fbops->fb_cursor = NULL;
51641 + pax_close_kernel();
51642 + }
51643
51644 info->var.accel_flags = (!noaccel);
51645
51646 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
51647 index 05c2dc3..ea1f391 100644
51648 --- a/drivers/video/s1d13xxxfb.c
51649 +++ b/drivers/video/s1d13xxxfb.c
51650 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
51651
51652 switch(prod_id) {
51653 case S1D13506_PROD_ID: /* activate acceleration */
51654 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51655 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51656 + pax_open_kernel();
51657 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51658 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51659 + pax_close_kernel();
51660 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
51661 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
51662 break;
51663 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
51664 index e188ada..aac63c8 100644
51665 --- a/drivers/video/smscufx.c
51666 +++ b/drivers/video/smscufx.c
51667 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
51668 fb_deferred_io_cleanup(info);
51669 kfree(info->fbdefio);
51670 info->fbdefio = NULL;
51671 - info->fbops->fb_mmap = ufx_ops_mmap;
51672 + pax_open_kernel();
51673 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
51674 + pax_close_kernel();
51675 }
51676
51677 pr_debug("released /dev/fb%d user=%d count=%d",
51678 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
51679 index d2e5bc3..4cb05d1 100644
51680 --- a/drivers/video/udlfb.c
51681 +++ b/drivers/video/udlfb.c
51682 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
51683 dlfb_urb_completion(urb);
51684
51685 error:
51686 - atomic_add(bytes_sent, &dev->bytes_sent);
51687 - atomic_add(bytes_identical, &dev->bytes_identical);
51688 - atomic_add(width*height*2, &dev->bytes_rendered);
51689 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51690 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51691 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
51692 end_cycles = get_cycles();
51693 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51694 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51695 >> 10)), /* Kcycles */
51696 &dev->cpu_kcycles_used);
51697
51698 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
51699 dlfb_urb_completion(urb);
51700
51701 error:
51702 - atomic_add(bytes_sent, &dev->bytes_sent);
51703 - atomic_add(bytes_identical, &dev->bytes_identical);
51704 - atomic_add(bytes_rendered, &dev->bytes_rendered);
51705 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51706 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51707 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
51708 end_cycles = get_cycles();
51709 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51710 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51711 >> 10)), /* Kcycles */
51712 &dev->cpu_kcycles_used);
51713 }
51714 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
51715 fb_deferred_io_cleanup(info);
51716 kfree(info->fbdefio);
51717 info->fbdefio = NULL;
51718 - info->fbops->fb_mmap = dlfb_ops_mmap;
51719 + pax_open_kernel();
51720 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
51721 + pax_close_kernel();
51722 }
51723
51724 pr_warn("released /dev/fb%d user=%d count=%d\n",
51725 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
51726 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51727 struct dlfb_data *dev = fb_info->par;
51728 return snprintf(buf, PAGE_SIZE, "%u\n",
51729 - atomic_read(&dev->bytes_rendered));
51730 + atomic_read_unchecked(&dev->bytes_rendered));
51731 }
51732
51733 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51734 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51735 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51736 struct dlfb_data *dev = fb_info->par;
51737 return snprintf(buf, PAGE_SIZE, "%u\n",
51738 - atomic_read(&dev->bytes_identical));
51739 + atomic_read_unchecked(&dev->bytes_identical));
51740 }
51741
51742 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51743 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51744 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51745 struct dlfb_data *dev = fb_info->par;
51746 return snprintf(buf, PAGE_SIZE, "%u\n",
51747 - atomic_read(&dev->bytes_sent));
51748 + atomic_read_unchecked(&dev->bytes_sent));
51749 }
51750
51751 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51752 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51753 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51754 struct dlfb_data *dev = fb_info->par;
51755 return snprintf(buf, PAGE_SIZE, "%u\n",
51756 - atomic_read(&dev->cpu_kcycles_used));
51757 + atomic_read_unchecked(&dev->cpu_kcycles_used));
51758 }
51759
51760 static ssize_t edid_show(
51761 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
51762 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51763 struct dlfb_data *dev = fb_info->par;
51764
51765 - atomic_set(&dev->bytes_rendered, 0);
51766 - atomic_set(&dev->bytes_identical, 0);
51767 - atomic_set(&dev->bytes_sent, 0);
51768 - atomic_set(&dev->cpu_kcycles_used, 0);
51769 + atomic_set_unchecked(&dev->bytes_rendered, 0);
51770 + atomic_set_unchecked(&dev->bytes_identical, 0);
51771 + atomic_set_unchecked(&dev->bytes_sent, 0);
51772 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
51773
51774 return count;
51775 }
51776 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
51777 index 7aec6f3..e3b2d55 100644
51778 --- a/drivers/video/uvesafb.c
51779 +++ b/drivers/video/uvesafb.c
51780 @@ -19,6 +19,7 @@
51781 #include <linux/io.h>
51782 #include <linux/mutex.h>
51783 #include <linux/slab.h>
51784 +#include <linux/moduleloader.h>
51785 #include <video/edid.h>
51786 #include <video/uvesafb.h>
51787 #ifdef CONFIG_X86
51788 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
51789 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
51790 par->pmi_setpal = par->ypan = 0;
51791 } else {
51792 +
51793 +#ifdef CONFIG_PAX_KERNEXEC
51794 +#ifdef CONFIG_MODULES
51795 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
51796 +#endif
51797 + if (!par->pmi_code) {
51798 + par->pmi_setpal = par->ypan = 0;
51799 + return 0;
51800 + }
51801 +#endif
51802 +
51803 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
51804 + task->t.regs.edi);
51805 +
51806 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51807 + pax_open_kernel();
51808 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
51809 + pax_close_kernel();
51810 +
51811 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
51812 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
51813 +#else
51814 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
51815 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
51816 +#endif
51817 +
51818 printk(KERN_INFO "uvesafb: protected mode interface info at "
51819 "%04x:%04x\n",
51820 (u16)task->t.regs.es, (u16)task->t.regs.edi);
51821 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
51822 par->ypan = ypan;
51823
51824 if (par->pmi_setpal || par->ypan) {
51825 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
51826 if (__supported_pte_mask & _PAGE_NX) {
51827 par->pmi_setpal = par->ypan = 0;
51828 printk(KERN_WARNING "uvesafb: NX protection is active, "
51829 "better not use the PMI.\n");
51830 - } else {
51831 + } else
51832 +#endif
51833 uvesafb_vbe_getpmi(task, par);
51834 - }
51835 }
51836 #else
51837 /* The protected mode interface is not available on non-x86. */
51838 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51839 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
51840
51841 /* Disable blanking if the user requested so. */
51842 - if (!blank)
51843 - info->fbops->fb_blank = NULL;
51844 + if (!blank) {
51845 + pax_open_kernel();
51846 + *(void **)&info->fbops->fb_blank = NULL;
51847 + pax_close_kernel();
51848 + }
51849
51850 /*
51851 * Find out how much IO memory is required for the mode with
51852 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51853 info->flags = FBINFO_FLAG_DEFAULT |
51854 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
51855
51856 - if (!par->ypan)
51857 - info->fbops->fb_pan_display = NULL;
51858 + if (!par->ypan) {
51859 + pax_open_kernel();
51860 + *(void **)&info->fbops->fb_pan_display = NULL;
51861 + pax_close_kernel();
51862 + }
51863 }
51864
51865 static void uvesafb_init_mtrr(struct fb_info *info)
51866 @@ -1796,6 +1826,11 @@ out:
51867 if (par->vbe_modes)
51868 kfree(par->vbe_modes);
51869
51870 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51871 + if (par->pmi_code)
51872 + module_free_exec(NULL, par->pmi_code);
51873 +#endif
51874 +
51875 framebuffer_release(info);
51876 return err;
51877 }
51878 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
51879 kfree(par->vbe_state_orig);
51880 if (par->vbe_state_saved)
51881 kfree(par->vbe_state_saved);
51882 +
51883 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51884 + if (par->pmi_code)
51885 + module_free_exec(NULL, par->pmi_code);
51886 +#endif
51887 +
51888 }
51889
51890 framebuffer_release(info);
51891 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
51892 index 501b340..d80aa17 100644
51893 --- a/drivers/video/vesafb.c
51894 +++ b/drivers/video/vesafb.c
51895 @@ -9,6 +9,7 @@
51896 */
51897
51898 #include <linux/module.h>
51899 +#include <linux/moduleloader.h>
51900 #include <linux/kernel.h>
51901 #include <linux/errno.h>
51902 #include <linux/string.h>
51903 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
51904 static int vram_total __initdata; /* Set total amount of memory */
51905 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
51906 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
51907 -static void (*pmi_start)(void) __read_mostly;
51908 -static void (*pmi_pal) (void) __read_mostly;
51909 +static void (*pmi_start)(void) __read_only;
51910 +static void (*pmi_pal) (void) __read_only;
51911 static int depth __read_mostly;
51912 static int vga_compat __read_mostly;
51913 /* --------------------------------------------------------------------- */
51914 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
51915 unsigned int size_vmode;
51916 unsigned int size_remap;
51917 unsigned int size_total;
51918 + void *pmi_code = NULL;
51919
51920 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
51921 return -ENODEV;
51922 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
51923 size_remap = size_total;
51924 vesafb_fix.smem_len = size_remap;
51925
51926 -#ifndef __i386__
51927 - screen_info.vesapm_seg = 0;
51928 -#endif
51929 -
51930 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
51931 printk(KERN_WARNING
51932 "vesafb: cannot reserve video memory at 0x%lx\n",
51933 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
51934 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
51935 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
51936
51937 +#ifdef __i386__
51938 +
51939 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51940 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
51941 + if (!pmi_code)
51942 +#elif !defined(CONFIG_PAX_KERNEXEC)
51943 + if (0)
51944 +#endif
51945 +
51946 +#endif
51947 + screen_info.vesapm_seg = 0;
51948 +
51949 if (screen_info.vesapm_seg) {
51950 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
51951 - screen_info.vesapm_seg,screen_info.vesapm_off);
51952 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
51953 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
51954 }
51955
51956 if (screen_info.vesapm_seg < 0xc000)
51957 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
51958
51959 if (ypan || pmi_setpal) {
51960 unsigned short *pmi_base;
51961 +
51962 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
51963 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
51964 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
51965 +
51966 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51967 + pax_open_kernel();
51968 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
51969 +#else
51970 + pmi_code = pmi_base;
51971 +#endif
51972 +
51973 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
51974 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
51975 +
51976 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51977 + pmi_start = ktva_ktla(pmi_start);
51978 + pmi_pal = ktva_ktla(pmi_pal);
51979 + pax_close_kernel();
51980 +#endif
51981 +
51982 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
51983 if (pmi_base[3]) {
51984 printk(KERN_INFO "vesafb: pmi: ports = ");
51985 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
51986 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
51987 (ypan ? FBINFO_HWACCEL_YPAN : 0);
51988
51989 - if (!ypan)
51990 - info->fbops->fb_pan_display = NULL;
51991 + if (!ypan) {
51992 + pax_open_kernel();
51993 + *(void **)&info->fbops->fb_pan_display = NULL;
51994 + pax_close_kernel();
51995 + }
51996
51997 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
51998 err = -ENOMEM;
51999 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52000 info->node, info->fix.id);
52001 return 0;
52002 err:
52003 +
52004 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52005 + module_free_exec(NULL, pmi_code);
52006 +#endif
52007 +
52008 if (info->screen_base)
52009 iounmap(info->screen_base);
52010 framebuffer_release(info);
52011 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52012 index 88714ae..16c2e11 100644
52013 --- a/drivers/video/via/via_clock.h
52014 +++ b/drivers/video/via/via_clock.h
52015 @@ -56,7 +56,7 @@ struct via_clock {
52016
52017 void (*set_engine_pll_state)(u8 state);
52018 void (*set_engine_pll)(struct via_pll_config config);
52019 -};
52020 +} __no_const;
52021
52022
52023 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52024 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52025 index fef20db..d28b1ab 100644
52026 --- a/drivers/xen/xenfs/xenstored.c
52027 +++ b/drivers/xen/xenfs/xenstored.c
52028 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52029 static int xsd_kva_open(struct inode *inode, struct file *file)
52030 {
52031 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52032 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52033 + NULL);
52034 +#else
52035 xen_store_interface);
52036 +#endif
52037 +
52038 if (!file->private_data)
52039 return -ENOMEM;
52040 return 0;
52041 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52042 index 9ff073f..05cef23 100644
52043 --- a/fs/9p/vfs_addr.c
52044 +++ b/fs/9p/vfs_addr.c
52045 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52046
52047 retval = v9fs_file_write_internal(inode,
52048 v9inode->writeback_fid,
52049 - (__force const char __user *)buffer,
52050 + (const char __force_user *)buffer,
52051 len, &offset, 0);
52052 if (retval > 0)
52053 retval = 0;
52054 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52055 index 25b018e..b941525 100644
52056 --- a/fs/9p/vfs_inode.c
52057 +++ b/fs/9p/vfs_inode.c
52058 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52059 void
52060 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52061 {
52062 - char *s = nd_get_link(nd);
52063 + const char *s = nd_get_link(nd);
52064
52065 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52066 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52067 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52068 index 370b24c..ff0be7b 100644
52069 --- a/fs/Kconfig.binfmt
52070 +++ b/fs/Kconfig.binfmt
52071 @@ -103,7 +103,7 @@ config HAVE_AOUT
52072
52073 config BINFMT_AOUT
52074 tristate "Kernel support for a.out and ECOFF binaries"
52075 - depends on HAVE_AOUT
52076 + depends on HAVE_AOUT && BROKEN
52077 ---help---
52078 A.out (Assembler.OUTput) is a set of formats for libraries and
52079 executables used in the earliest versions of UNIX. Linux used
52080 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52081 index 789bc25..fafaeea 100644
52082 --- a/fs/afs/inode.c
52083 +++ b/fs/afs/inode.c
52084 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52085 struct afs_vnode *vnode;
52086 struct super_block *sb;
52087 struct inode *inode;
52088 - static atomic_t afs_autocell_ino;
52089 + static atomic_unchecked_t afs_autocell_ino;
52090
52091 _enter("{%x:%u},%*.*s,",
52092 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52093 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52094 data.fid.unique = 0;
52095 data.fid.vnode = 0;
52096
52097 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52098 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52099 afs_iget5_autocell_test, afs_iget5_set,
52100 &data);
52101 if (!inode) {
52102 diff --git a/fs/aio.c b/fs/aio.c
52103 index 9b5ca11..c530886 100644
52104 --- a/fs/aio.c
52105 +++ b/fs/aio.c
52106 @@ -162,7 +162,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52107 size += sizeof(struct io_event) * nr_events;
52108 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
52109
52110 - if (nr_pages < 0)
52111 + if (nr_pages <= 0)
52112 return -EINVAL;
52113
52114 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
52115 @@ -952,6 +952,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
52116 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52117 {
52118 ssize_t ret;
52119 + struct iovec iovstack;
52120
52121 kiocb->ki_nr_segs = kiocb->ki_nbytes;
52122
52123 @@ -959,17 +960,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52124 if (compat)
52125 ret = compat_rw_copy_check_uvector(rw,
52126 (struct compat_iovec __user *)kiocb->ki_buf,
52127 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52128 + kiocb->ki_nr_segs, 1, &iovstack,
52129 &kiocb->ki_iovec);
52130 else
52131 #endif
52132 ret = rw_copy_check_uvector(rw,
52133 (struct iovec __user *)kiocb->ki_buf,
52134 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52135 + kiocb->ki_nr_segs, 1, &iovstack,
52136 &kiocb->ki_iovec);
52137 if (ret < 0)
52138 return ret;
52139
52140 + if (kiocb->ki_iovec == &iovstack) {
52141 + kiocb->ki_inline_vec = iovstack;
52142 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
52143 + }
52144 +
52145 /* ki_nbytes now reflect bytes instead of segs */
52146 kiocb->ki_nbytes = ret;
52147 return 0;
52148 diff --git a/fs/attr.c b/fs/attr.c
52149 index 1449adb..a2038c2 100644
52150 --- a/fs/attr.c
52151 +++ b/fs/attr.c
52152 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52153 unsigned long limit;
52154
52155 limit = rlimit(RLIMIT_FSIZE);
52156 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52157 if (limit != RLIM_INFINITY && offset > limit)
52158 goto out_sig;
52159 if (offset > inode->i_sb->s_maxbytes)
52160 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52161 index 3db70da..7aeec5b 100644
52162 --- a/fs/autofs4/waitq.c
52163 +++ b/fs/autofs4/waitq.c
52164 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52165 {
52166 unsigned long sigpipe, flags;
52167 mm_segment_t fs;
52168 - const char *data = (const char *)addr;
52169 + const char __user *data = (const char __force_user *)addr;
52170 ssize_t wr = 0;
52171
52172 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52173 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52174 return 1;
52175 }
52176
52177 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52178 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52179 +#endif
52180 +
52181 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52182 enum autofs_notify notify)
52183 {
52184 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52185
52186 /* If this is a direct mount request create a dummy name */
52187 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52188 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52189 + /* this name does get written to userland via autofs4_write() */
52190 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52191 +#else
52192 qstr.len = sprintf(name, "%p", dentry);
52193 +#endif
52194 else {
52195 qstr.len = autofs4_getpath(sbi, dentry, &name);
52196 if (!qstr.len) {
52197 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52198 index 2722387..c8dd2a7 100644
52199 --- a/fs/befs/endian.h
52200 +++ b/fs/befs/endian.h
52201 @@ -11,7 +11,7 @@
52202
52203 #include <asm/byteorder.h>
52204
52205 -static inline u64
52206 +static inline u64 __intentional_overflow(-1)
52207 fs64_to_cpu(const struct super_block *sb, fs64 n)
52208 {
52209 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52210 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52211 return (__force fs64)cpu_to_be64(n);
52212 }
52213
52214 -static inline u32
52215 +static inline u32 __intentional_overflow(-1)
52216 fs32_to_cpu(const struct super_block *sb, fs32 n)
52217 {
52218 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52219 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52220 index e9c75e2..1baece1 100644
52221 --- a/fs/befs/linuxvfs.c
52222 +++ b/fs/befs/linuxvfs.c
52223 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52224 {
52225 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52226 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52227 - char *link = nd_get_link(nd);
52228 + const char *link = nd_get_link(nd);
52229 if (!IS_ERR(link))
52230 kfree(link);
52231 }
52232 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52233 index 89dec7f..361b0d75 100644
52234 --- a/fs/binfmt_aout.c
52235 +++ b/fs/binfmt_aout.c
52236 @@ -16,6 +16,7 @@
52237 #include <linux/string.h>
52238 #include <linux/fs.h>
52239 #include <linux/file.h>
52240 +#include <linux/security.h>
52241 #include <linux/stat.h>
52242 #include <linux/fcntl.h>
52243 #include <linux/ptrace.h>
52244 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52245 #endif
52246 # define START_STACK(u) ((void __user *)u.start_stack)
52247
52248 + memset(&dump, 0, sizeof(dump));
52249 +
52250 fs = get_fs();
52251 set_fs(KERNEL_DS);
52252 has_dumped = 1;
52253 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52254
52255 /* If the size of the dump file exceeds the rlimit, then see what would happen
52256 if we wrote the stack, but not the data area. */
52257 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52258 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52259 dump.u_dsize = 0;
52260
52261 /* Make sure we have enough room to write the stack and data areas. */
52262 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52263 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52264 dump.u_ssize = 0;
52265
52266 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52267 rlim = rlimit(RLIMIT_DATA);
52268 if (rlim >= RLIM_INFINITY)
52269 rlim = ~0;
52270 +
52271 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52272 if (ex.a_data + ex.a_bss > rlim)
52273 return -ENOMEM;
52274
52275 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52276
52277 install_exec_creds(bprm);
52278
52279 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52280 + current->mm->pax_flags = 0UL;
52281 +#endif
52282 +
52283 +#ifdef CONFIG_PAX_PAGEEXEC
52284 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52285 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52286 +
52287 +#ifdef CONFIG_PAX_EMUTRAMP
52288 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52289 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52290 +#endif
52291 +
52292 +#ifdef CONFIG_PAX_MPROTECT
52293 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52294 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52295 +#endif
52296 +
52297 + }
52298 +#endif
52299 +
52300 if (N_MAGIC(ex) == OMAGIC) {
52301 unsigned long text_addr, map_size;
52302 loff_t pos;
52303 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52304 }
52305
52306 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52307 - PROT_READ | PROT_WRITE | PROT_EXEC,
52308 + PROT_READ | PROT_WRITE,
52309 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52310 fd_offset + ex.a_text);
52311 if (error != N_DATADDR(ex)) {
52312 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52313 index 4c94a79..f428019 100644
52314 --- a/fs/binfmt_elf.c
52315 +++ b/fs/binfmt_elf.c
52316 @@ -34,6 +34,7 @@
52317 #include <linux/utsname.h>
52318 #include <linux/coredump.h>
52319 #include <linux/sched.h>
52320 +#include <linux/xattr.h>
52321 #include <asm/uaccess.h>
52322 #include <asm/param.h>
52323 #include <asm/page.h>
52324 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52325 #define elf_core_dump NULL
52326 #endif
52327
52328 +#ifdef CONFIG_PAX_MPROTECT
52329 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52330 +#endif
52331 +
52332 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52333 +static void elf_handle_mmap(struct file *file);
52334 +#endif
52335 +
52336 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52337 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52338 #else
52339 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52340 .load_binary = load_elf_binary,
52341 .load_shlib = load_elf_library,
52342 .core_dump = elf_core_dump,
52343 +
52344 +#ifdef CONFIG_PAX_MPROTECT
52345 + .handle_mprotect= elf_handle_mprotect,
52346 +#endif
52347 +
52348 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52349 + .handle_mmap = elf_handle_mmap,
52350 +#endif
52351 +
52352 .min_coredump = ELF_EXEC_PAGESIZE,
52353 };
52354
52355 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52356
52357 static int set_brk(unsigned long start, unsigned long end)
52358 {
52359 + unsigned long e = end;
52360 +
52361 start = ELF_PAGEALIGN(start);
52362 end = ELF_PAGEALIGN(end);
52363 if (end > start) {
52364 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52365 if (BAD_ADDR(addr))
52366 return addr;
52367 }
52368 - current->mm->start_brk = current->mm->brk = end;
52369 + current->mm->start_brk = current->mm->brk = e;
52370 return 0;
52371 }
52372
52373 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52374 elf_addr_t __user *u_rand_bytes;
52375 const char *k_platform = ELF_PLATFORM;
52376 const char *k_base_platform = ELF_BASE_PLATFORM;
52377 - unsigned char k_rand_bytes[16];
52378 + u32 k_rand_bytes[4];
52379 int items;
52380 elf_addr_t *elf_info;
52381 int ei_index = 0;
52382 const struct cred *cred = current_cred();
52383 struct vm_area_struct *vma;
52384 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52385
52386 /*
52387 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52388 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52389 * Generate 16 random bytes for userspace PRNG seeding.
52390 */
52391 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52392 - u_rand_bytes = (elf_addr_t __user *)
52393 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52394 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52395 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52396 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52397 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52398 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52399 + u_rand_bytes = (elf_addr_t __user *) p;
52400 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52401 return -EFAULT;
52402
52403 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52404 return -EFAULT;
52405 current->mm->env_end = p;
52406
52407 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52408 +
52409 /* Put the elf_info on the stack in the right place. */
52410 sp = (elf_addr_t __user *)envp + 1;
52411 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52412 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52413 return -EFAULT;
52414 return 0;
52415 }
52416 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52417 an ELF header */
52418
52419 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52420 - struct file *interpreter, unsigned long *interp_map_addr,
52421 - unsigned long no_base)
52422 + struct file *interpreter, unsigned long no_base)
52423 {
52424 struct elf_phdr *elf_phdata;
52425 struct elf_phdr *eppnt;
52426 - unsigned long load_addr = 0;
52427 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52428 int load_addr_set = 0;
52429 unsigned long last_bss = 0, elf_bss = 0;
52430 - unsigned long error = ~0UL;
52431 + unsigned long error = -EINVAL;
52432 unsigned long total_size;
52433 int retval, i, size;
52434
52435 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52436 goto out_close;
52437 }
52438
52439 +#ifdef CONFIG_PAX_SEGMEXEC
52440 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52441 + pax_task_size = SEGMEXEC_TASK_SIZE;
52442 +#endif
52443 +
52444 eppnt = elf_phdata;
52445 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52446 if (eppnt->p_type == PT_LOAD) {
52447 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52448 map_addr = elf_map(interpreter, load_addr + vaddr,
52449 eppnt, elf_prot, elf_type, total_size);
52450 total_size = 0;
52451 - if (!*interp_map_addr)
52452 - *interp_map_addr = map_addr;
52453 error = map_addr;
52454 if (BAD_ADDR(map_addr))
52455 goto out_close;
52456 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52457 k = load_addr + eppnt->p_vaddr;
52458 if (BAD_ADDR(k) ||
52459 eppnt->p_filesz > eppnt->p_memsz ||
52460 - eppnt->p_memsz > TASK_SIZE ||
52461 - TASK_SIZE - eppnt->p_memsz < k) {
52462 + eppnt->p_memsz > pax_task_size ||
52463 + pax_task_size - eppnt->p_memsz < k) {
52464 error = -ENOMEM;
52465 goto out_close;
52466 }
52467 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52468 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52469
52470 /* Map the last of the bss segment */
52471 - error = vm_brk(elf_bss, last_bss - elf_bss);
52472 - if (BAD_ADDR(error))
52473 - goto out_close;
52474 + if (last_bss > elf_bss) {
52475 + error = vm_brk(elf_bss, last_bss - elf_bss);
52476 + if (BAD_ADDR(error))
52477 + goto out_close;
52478 + }
52479 }
52480
52481 error = load_addr;
52482 @@ -538,6 +569,315 @@ out:
52483 return error;
52484 }
52485
52486 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52487 +#ifdef CONFIG_PAX_SOFTMODE
52488 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52489 +{
52490 + unsigned long pax_flags = 0UL;
52491 +
52492 +#ifdef CONFIG_PAX_PAGEEXEC
52493 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52494 + pax_flags |= MF_PAX_PAGEEXEC;
52495 +#endif
52496 +
52497 +#ifdef CONFIG_PAX_SEGMEXEC
52498 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52499 + pax_flags |= MF_PAX_SEGMEXEC;
52500 +#endif
52501 +
52502 +#ifdef CONFIG_PAX_EMUTRAMP
52503 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52504 + pax_flags |= MF_PAX_EMUTRAMP;
52505 +#endif
52506 +
52507 +#ifdef CONFIG_PAX_MPROTECT
52508 + if (elf_phdata->p_flags & PF_MPROTECT)
52509 + pax_flags |= MF_PAX_MPROTECT;
52510 +#endif
52511 +
52512 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52513 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52514 + pax_flags |= MF_PAX_RANDMMAP;
52515 +#endif
52516 +
52517 + return pax_flags;
52518 +}
52519 +#endif
52520 +
52521 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52522 +{
52523 + unsigned long pax_flags = 0UL;
52524 +
52525 +#ifdef CONFIG_PAX_PAGEEXEC
52526 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52527 + pax_flags |= MF_PAX_PAGEEXEC;
52528 +#endif
52529 +
52530 +#ifdef CONFIG_PAX_SEGMEXEC
52531 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52532 + pax_flags |= MF_PAX_SEGMEXEC;
52533 +#endif
52534 +
52535 +#ifdef CONFIG_PAX_EMUTRAMP
52536 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52537 + pax_flags |= MF_PAX_EMUTRAMP;
52538 +#endif
52539 +
52540 +#ifdef CONFIG_PAX_MPROTECT
52541 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
52542 + pax_flags |= MF_PAX_MPROTECT;
52543 +#endif
52544 +
52545 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52546 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
52547 + pax_flags |= MF_PAX_RANDMMAP;
52548 +#endif
52549 +
52550 + return pax_flags;
52551 +}
52552 +#endif
52553 +
52554 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52555 +#ifdef CONFIG_PAX_SOFTMODE
52556 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
52557 +{
52558 + unsigned long pax_flags = 0UL;
52559 +
52560 +#ifdef CONFIG_PAX_PAGEEXEC
52561 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
52562 + pax_flags |= MF_PAX_PAGEEXEC;
52563 +#endif
52564 +
52565 +#ifdef CONFIG_PAX_SEGMEXEC
52566 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
52567 + pax_flags |= MF_PAX_SEGMEXEC;
52568 +#endif
52569 +
52570 +#ifdef CONFIG_PAX_EMUTRAMP
52571 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52572 + pax_flags |= MF_PAX_EMUTRAMP;
52573 +#endif
52574 +
52575 +#ifdef CONFIG_PAX_MPROTECT
52576 + if (pax_flags_softmode & MF_PAX_MPROTECT)
52577 + pax_flags |= MF_PAX_MPROTECT;
52578 +#endif
52579 +
52580 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52581 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
52582 + pax_flags |= MF_PAX_RANDMMAP;
52583 +#endif
52584 +
52585 + return pax_flags;
52586 +}
52587 +#endif
52588 +
52589 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
52590 +{
52591 + unsigned long pax_flags = 0UL;
52592 +
52593 +#ifdef CONFIG_PAX_PAGEEXEC
52594 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
52595 + pax_flags |= MF_PAX_PAGEEXEC;
52596 +#endif
52597 +
52598 +#ifdef CONFIG_PAX_SEGMEXEC
52599 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
52600 + pax_flags |= MF_PAX_SEGMEXEC;
52601 +#endif
52602 +
52603 +#ifdef CONFIG_PAX_EMUTRAMP
52604 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
52605 + pax_flags |= MF_PAX_EMUTRAMP;
52606 +#endif
52607 +
52608 +#ifdef CONFIG_PAX_MPROTECT
52609 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
52610 + pax_flags |= MF_PAX_MPROTECT;
52611 +#endif
52612 +
52613 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52614 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
52615 + pax_flags |= MF_PAX_RANDMMAP;
52616 +#endif
52617 +
52618 + return pax_flags;
52619 +}
52620 +#endif
52621 +
52622 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52623 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
52624 +{
52625 + unsigned long pax_flags = 0UL;
52626 +
52627 +#ifdef CONFIG_PAX_EI_PAX
52628 +
52629 +#ifdef CONFIG_PAX_PAGEEXEC
52630 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
52631 + pax_flags |= MF_PAX_PAGEEXEC;
52632 +#endif
52633 +
52634 +#ifdef CONFIG_PAX_SEGMEXEC
52635 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
52636 + pax_flags |= MF_PAX_SEGMEXEC;
52637 +#endif
52638 +
52639 +#ifdef CONFIG_PAX_EMUTRAMP
52640 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
52641 + pax_flags |= MF_PAX_EMUTRAMP;
52642 +#endif
52643 +
52644 +#ifdef CONFIG_PAX_MPROTECT
52645 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
52646 + pax_flags |= MF_PAX_MPROTECT;
52647 +#endif
52648 +
52649 +#ifdef CONFIG_PAX_ASLR
52650 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
52651 + pax_flags |= MF_PAX_RANDMMAP;
52652 +#endif
52653 +
52654 +#else
52655 +
52656 +#ifdef CONFIG_PAX_PAGEEXEC
52657 + pax_flags |= MF_PAX_PAGEEXEC;
52658 +#endif
52659 +
52660 +#ifdef CONFIG_PAX_SEGMEXEC
52661 + pax_flags |= MF_PAX_SEGMEXEC;
52662 +#endif
52663 +
52664 +#ifdef CONFIG_PAX_MPROTECT
52665 + pax_flags |= MF_PAX_MPROTECT;
52666 +#endif
52667 +
52668 +#ifdef CONFIG_PAX_RANDMMAP
52669 + if (randomize_va_space)
52670 + pax_flags |= MF_PAX_RANDMMAP;
52671 +#endif
52672 +
52673 +#endif
52674 +
52675 + return pax_flags;
52676 +}
52677 +
52678 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
52679 +{
52680 +
52681 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52682 + unsigned long i;
52683 +
52684 + for (i = 0UL; i < elf_ex->e_phnum; i++)
52685 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
52686 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
52687 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
52688 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
52689 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
52690 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
52691 + return ~0UL;
52692 +
52693 +#ifdef CONFIG_PAX_SOFTMODE
52694 + if (pax_softmode)
52695 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
52696 + else
52697 +#endif
52698 +
52699 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
52700 + break;
52701 + }
52702 +#endif
52703 +
52704 + return ~0UL;
52705 +}
52706 +
52707 +static unsigned long pax_parse_xattr_pax(struct file * const file)
52708 +{
52709 +
52710 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52711 + ssize_t xattr_size, i;
52712 + unsigned char xattr_value[sizeof("pemrs") - 1];
52713 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
52714 +
52715 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
52716 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
52717 + return ~0UL;
52718 +
52719 + for (i = 0; i < xattr_size; i++)
52720 + switch (xattr_value[i]) {
52721 + default:
52722 + return ~0UL;
52723 +
52724 +#define parse_flag(option1, option2, flag) \
52725 + case option1: \
52726 + if (pax_flags_hardmode & MF_PAX_##flag) \
52727 + return ~0UL; \
52728 + pax_flags_hardmode |= MF_PAX_##flag; \
52729 + break; \
52730 + case option2: \
52731 + if (pax_flags_softmode & MF_PAX_##flag) \
52732 + return ~0UL; \
52733 + pax_flags_softmode |= MF_PAX_##flag; \
52734 + break;
52735 +
52736 + parse_flag('p', 'P', PAGEEXEC);
52737 + parse_flag('e', 'E', EMUTRAMP);
52738 + parse_flag('m', 'M', MPROTECT);
52739 + parse_flag('r', 'R', RANDMMAP);
52740 + parse_flag('s', 'S', SEGMEXEC);
52741 +
52742 +#undef parse_flag
52743 + }
52744 +
52745 + if (pax_flags_hardmode & pax_flags_softmode)
52746 + return ~0UL;
52747 +
52748 +#ifdef CONFIG_PAX_SOFTMODE
52749 + if (pax_softmode)
52750 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
52751 + else
52752 +#endif
52753 +
52754 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
52755 +#else
52756 + return ~0UL;
52757 +#endif
52758 +
52759 +}
52760 +
52761 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
52762 +{
52763 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
52764 +
52765 + pax_flags = pax_parse_ei_pax(elf_ex);
52766 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
52767 + xattr_pax_flags = pax_parse_xattr_pax(file);
52768 +
52769 + if (pt_pax_flags == ~0UL)
52770 + pt_pax_flags = xattr_pax_flags;
52771 + else if (xattr_pax_flags == ~0UL)
52772 + xattr_pax_flags = pt_pax_flags;
52773 + if (pt_pax_flags != xattr_pax_flags)
52774 + return -EINVAL;
52775 + if (pt_pax_flags != ~0UL)
52776 + pax_flags = pt_pax_flags;
52777 +
52778 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
52779 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52780 + if ((__supported_pte_mask & _PAGE_NX))
52781 + pax_flags &= ~MF_PAX_SEGMEXEC;
52782 + else
52783 + pax_flags &= ~MF_PAX_PAGEEXEC;
52784 + }
52785 +#endif
52786 +
52787 + if (0 > pax_check_flags(&pax_flags))
52788 + return -EINVAL;
52789 +
52790 + current->mm->pax_flags = pax_flags;
52791 + return 0;
52792 +}
52793 +#endif
52794 +
52795 /*
52796 * These are the functions used to load ELF style executables and shared
52797 * libraries. There is no binary dependent code anywhere else.
52798 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
52799 {
52800 unsigned int random_variable = 0;
52801
52802 +#ifdef CONFIG_PAX_RANDUSTACK
52803 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
52804 + return stack_top - current->mm->delta_stack;
52805 +#endif
52806 +
52807 if ((current->flags & PF_RANDOMIZE) &&
52808 !(current->personality & ADDR_NO_RANDOMIZE)) {
52809 random_variable = get_random_int() & STACK_RND_MASK;
52810 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
52811 unsigned long load_addr = 0, load_bias = 0;
52812 int load_addr_set = 0;
52813 char * elf_interpreter = NULL;
52814 - unsigned long error;
52815 + unsigned long error = 0;
52816 struct elf_phdr *elf_ppnt, *elf_phdata;
52817 unsigned long elf_bss, elf_brk;
52818 int retval, i;
52819 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
52820 unsigned long start_code, end_code, start_data, end_data;
52821 unsigned long reloc_func_desc __maybe_unused = 0;
52822 int executable_stack = EXSTACK_DEFAULT;
52823 - unsigned long def_flags = 0;
52824 struct pt_regs *regs = current_pt_regs();
52825 struct {
52826 struct elfhdr elf_ex;
52827 struct elfhdr interp_elf_ex;
52828 } *loc;
52829 + unsigned long pax_task_size = TASK_SIZE;
52830
52831 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
52832 if (!loc) {
52833 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
52834 goto out_free_dentry;
52835
52836 /* OK, This is the point of no return */
52837 - current->mm->def_flags = def_flags;
52838 +
52839 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52840 + current->mm->pax_flags = 0UL;
52841 +#endif
52842 +
52843 +#ifdef CONFIG_PAX_DLRESOLVE
52844 + current->mm->call_dl_resolve = 0UL;
52845 +#endif
52846 +
52847 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
52848 + current->mm->call_syscall = 0UL;
52849 +#endif
52850 +
52851 +#ifdef CONFIG_PAX_ASLR
52852 + current->mm->delta_mmap = 0UL;
52853 + current->mm->delta_stack = 0UL;
52854 +#endif
52855 +
52856 + current->mm->def_flags = 0;
52857 +
52858 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52859 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
52860 + send_sig(SIGKILL, current, 0);
52861 + goto out_free_dentry;
52862 + }
52863 +#endif
52864 +
52865 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52866 + pax_set_initial_flags(bprm);
52867 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
52868 + if (pax_set_initial_flags_func)
52869 + (pax_set_initial_flags_func)(bprm);
52870 +#endif
52871 +
52872 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
52873 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
52874 + current->mm->context.user_cs_limit = PAGE_SIZE;
52875 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
52876 + }
52877 +#endif
52878 +
52879 +#ifdef CONFIG_PAX_SEGMEXEC
52880 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
52881 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
52882 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
52883 + pax_task_size = SEGMEXEC_TASK_SIZE;
52884 + current->mm->def_flags |= VM_NOHUGEPAGE;
52885 + }
52886 +#endif
52887 +
52888 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
52889 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52890 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
52891 + put_cpu();
52892 + }
52893 +#endif
52894
52895 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
52896 may depend on the personality. */
52897 SET_PERSONALITY(loc->elf_ex);
52898 +
52899 +#ifdef CONFIG_PAX_ASLR
52900 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52901 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
52902 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
52903 + }
52904 +#endif
52905 +
52906 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
52907 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52908 + executable_stack = EXSTACK_DISABLE_X;
52909 + current->personality &= ~READ_IMPLIES_EXEC;
52910 + } else
52911 +#endif
52912 +
52913 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
52914 current->personality |= READ_IMPLIES_EXEC;
52915
52916 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
52917 #else
52918 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
52919 #endif
52920 +
52921 +#ifdef CONFIG_PAX_RANDMMAP
52922 + /* PaX: randomize base address at the default exe base if requested */
52923 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
52924 +#ifdef CONFIG_SPARC64
52925 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
52926 +#else
52927 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
52928 +#endif
52929 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
52930 + elf_flags |= MAP_FIXED;
52931 + }
52932 +#endif
52933 +
52934 }
52935
52936 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
52937 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
52938 * allowed task size. Note that p_filesz must always be
52939 * <= p_memsz so it is only necessary to check p_memsz.
52940 */
52941 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52942 - elf_ppnt->p_memsz > TASK_SIZE ||
52943 - TASK_SIZE - elf_ppnt->p_memsz < k) {
52944 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52945 + elf_ppnt->p_memsz > pax_task_size ||
52946 + pax_task_size - elf_ppnt->p_memsz < k) {
52947 /* set_brk can never work. Avoid overflows. */
52948 send_sig(SIGKILL, current, 0);
52949 retval = -EINVAL;
52950 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
52951 goto out_free_dentry;
52952 }
52953 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
52954 - send_sig(SIGSEGV, current, 0);
52955 - retval = -EFAULT; /* Nobody gets to see this, but.. */
52956 - goto out_free_dentry;
52957 + /*
52958 + * This bss-zeroing can fail if the ELF
52959 + * file specifies odd protections. So
52960 + * we don't check the return value
52961 + */
52962 }
52963
52964 +#ifdef CONFIG_PAX_RANDMMAP
52965 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52966 + unsigned long start, size, flags;
52967 + vm_flags_t vm_flags;
52968 +
52969 + start = ELF_PAGEALIGN(elf_brk);
52970 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
52971 + flags = MAP_FIXED | MAP_PRIVATE;
52972 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
52973 +
52974 + down_write(&current->mm->mmap_sem);
52975 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
52976 + retval = -ENOMEM;
52977 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
52978 +// if (current->personality & ADDR_NO_RANDOMIZE)
52979 +// vm_flags |= VM_READ | VM_MAYREAD;
52980 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
52981 + retval = IS_ERR_VALUE(start) ? start : 0;
52982 + }
52983 + up_write(&current->mm->mmap_sem);
52984 + if (retval == 0)
52985 + retval = set_brk(start + size, start + size + PAGE_SIZE);
52986 + if (retval < 0) {
52987 + send_sig(SIGKILL, current, 0);
52988 + goto out_free_dentry;
52989 + }
52990 + }
52991 +#endif
52992 +
52993 if (elf_interpreter) {
52994 - unsigned long interp_map_addr = 0;
52995 -
52996 elf_entry = load_elf_interp(&loc->interp_elf_ex,
52997 interpreter,
52998 - &interp_map_addr,
52999 load_bias);
53000 if (!IS_ERR((void *)elf_entry)) {
53001 /*
53002 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53003 * Decide what to dump of a segment, part, all or none.
53004 */
53005 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53006 - unsigned long mm_flags)
53007 + unsigned long mm_flags, long signr)
53008 {
53009 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53010
53011 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53012 if (vma->vm_file == NULL)
53013 return 0;
53014
53015 - if (FILTER(MAPPED_PRIVATE))
53016 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53017 goto whole;
53018
53019 /*
53020 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53021 {
53022 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53023 int i = 0;
53024 - do
53025 + do {
53026 i += 2;
53027 - while (auxv[i - 2] != AT_NULL);
53028 + } while (auxv[i - 2] != AT_NULL);
53029 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53030 }
53031
53032 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53033 {
53034 mm_segment_t old_fs = get_fs();
53035 set_fs(KERNEL_DS);
53036 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53037 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53038 set_fs(old_fs);
53039 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53040 }
53041 @@ -2023,14 +2480,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53042 }
53043
53044 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53045 - unsigned long mm_flags)
53046 + struct coredump_params *cprm)
53047 {
53048 struct vm_area_struct *vma;
53049 size_t size = 0;
53050
53051 for (vma = first_vma(current, gate_vma); vma != NULL;
53052 vma = next_vma(vma, gate_vma))
53053 - size += vma_dump_size(vma, mm_flags);
53054 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53055 return size;
53056 }
53057
53058 @@ -2123,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53059
53060 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53061
53062 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53063 + offset += elf_core_vma_data_size(gate_vma, cprm);
53064 offset += elf_core_extra_data_size();
53065 e_shoff = offset;
53066
53067 @@ -2137,10 +2594,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53068 offset = dataoff;
53069
53070 size += sizeof(*elf);
53071 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53072 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53073 goto end_coredump;
53074
53075 size += sizeof(*phdr4note);
53076 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53077 if (size > cprm->limit
53078 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53079 goto end_coredump;
53080 @@ -2154,7 +2613,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53081 phdr.p_offset = offset;
53082 phdr.p_vaddr = vma->vm_start;
53083 phdr.p_paddr = 0;
53084 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53085 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53086 phdr.p_memsz = vma->vm_end - vma->vm_start;
53087 offset += phdr.p_filesz;
53088 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53089 @@ -2165,6 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53090 phdr.p_align = ELF_EXEC_PAGESIZE;
53091
53092 size += sizeof(phdr);
53093 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53094 if (size > cprm->limit
53095 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53096 goto end_coredump;
53097 @@ -2189,7 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53098 unsigned long addr;
53099 unsigned long end;
53100
53101 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53102 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53103
53104 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53105 struct page *page;
53106 @@ -2198,6 +2658,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53107 page = get_dump_page(addr);
53108 if (page) {
53109 void *kaddr = kmap(page);
53110 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53111 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53112 !dump_write(cprm->file, kaddr,
53113 PAGE_SIZE);
53114 @@ -2215,6 +2676,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53115
53116 if (e_phnum == PN_XNUM) {
53117 size += sizeof(*shdr4extnum);
53118 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53119 if (size > cprm->limit
53120 || !dump_write(cprm->file, shdr4extnum,
53121 sizeof(*shdr4extnum)))
53122 @@ -2235,6 +2697,167 @@ out:
53123
53124 #endif /* CONFIG_ELF_CORE */
53125
53126 +#ifdef CONFIG_PAX_MPROTECT
53127 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53128 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53129 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53130 + *
53131 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53132 + * basis because we want to allow the common case and not the special ones.
53133 + */
53134 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53135 +{
53136 + struct elfhdr elf_h;
53137 + struct elf_phdr elf_p;
53138 + unsigned long i;
53139 + unsigned long oldflags;
53140 + bool is_textrel_rw, is_textrel_rx, is_relro;
53141 +
53142 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53143 + return;
53144 +
53145 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53146 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53147 +
53148 +#ifdef CONFIG_PAX_ELFRELOCS
53149 + /* possible TEXTREL */
53150 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53151 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53152 +#else
53153 + is_textrel_rw = false;
53154 + is_textrel_rx = false;
53155 +#endif
53156 +
53157 + /* possible RELRO */
53158 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53159 +
53160 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53161 + return;
53162 +
53163 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53164 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53165 +
53166 +#ifdef CONFIG_PAX_ETEXECRELOCS
53167 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53168 +#else
53169 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53170 +#endif
53171 +
53172 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53173 + !elf_check_arch(&elf_h) ||
53174 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53175 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53176 + return;
53177 +
53178 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53179 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53180 + return;
53181 + switch (elf_p.p_type) {
53182 + case PT_DYNAMIC:
53183 + if (!is_textrel_rw && !is_textrel_rx)
53184 + continue;
53185 + i = 0UL;
53186 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53187 + elf_dyn dyn;
53188 +
53189 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53190 + break;
53191 + if (dyn.d_tag == DT_NULL)
53192 + break;
53193 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53194 + gr_log_textrel(vma);
53195 + if (is_textrel_rw)
53196 + vma->vm_flags |= VM_MAYWRITE;
53197 + else
53198 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53199 + vma->vm_flags &= ~VM_MAYWRITE;
53200 + break;
53201 + }
53202 + i++;
53203 + }
53204 + is_textrel_rw = false;
53205 + is_textrel_rx = false;
53206 + continue;
53207 +
53208 + case PT_GNU_RELRO:
53209 + if (!is_relro)
53210 + continue;
53211 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53212 + vma->vm_flags &= ~VM_MAYWRITE;
53213 + is_relro = false;
53214 + continue;
53215 +
53216 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53217 + case PT_PAX_FLAGS: {
53218 + const char *msg_mprotect = "", *msg_emutramp = "";
53219 + char *buffer_lib, *buffer_exe;
53220 +
53221 + if (elf_p.p_flags & PF_NOMPROTECT)
53222 + msg_mprotect = "MPROTECT disabled";
53223 +
53224 +#ifdef CONFIG_PAX_EMUTRAMP
53225 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53226 + msg_emutramp = "EMUTRAMP enabled";
53227 +#endif
53228 +
53229 + if (!msg_mprotect[0] && !msg_emutramp[0])
53230 + continue;
53231 +
53232 + if (!printk_ratelimit())
53233 + continue;
53234 +
53235 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53236 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53237 + if (buffer_lib && buffer_exe) {
53238 + char *path_lib, *path_exe;
53239 +
53240 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53241 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53242 +
53243 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53244 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53245 +
53246 + }
53247 + free_page((unsigned long)buffer_exe);
53248 + free_page((unsigned long)buffer_lib);
53249 + continue;
53250 + }
53251 +#endif
53252 +
53253 + }
53254 + }
53255 +}
53256 +#endif
53257 +
53258 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53259 +
53260 +extern int grsec_enable_log_rwxmaps;
53261 +
53262 +static void elf_handle_mmap(struct file *file)
53263 +{
53264 + struct elfhdr elf_h;
53265 + struct elf_phdr elf_p;
53266 + unsigned long i;
53267 +
53268 + if (!grsec_enable_log_rwxmaps)
53269 + return;
53270 +
53271 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53272 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53273 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53274 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53275 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53276 + return;
53277 +
53278 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53279 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53280 + return;
53281 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53282 + gr_log_ptgnustack(file);
53283 + }
53284 +}
53285 +#endif
53286 +
53287 static int __init init_elf_binfmt(void)
53288 {
53289 register_binfmt(&elf_format);
53290 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53291 index d50bbe5..af3b649 100644
53292 --- a/fs/binfmt_flat.c
53293 +++ b/fs/binfmt_flat.c
53294 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53295 realdatastart = (unsigned long) -ENOMEM;
53296 printk("Unable to allocate RAM for process data, errno %d\n",
53297 (int)-realdatastart);
53298 + down_write(&current->mm->mmap_sem);
53299 vm_munmap(textpos, text_len);
53300 + up_write(&current->mm->mmap_sem);
53301 ret = realdatastart;
53302 goto err;
53303 }
53304 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53305 }
53306 if (IS_ERR_VALUE(result)) {
53307 printk("Unable to read data+bss, errno %d\n", (int)-result);
53308 + down_write(&current->mm->mmap_sem);
53309 vm_munmap(textpos, text_len);
53310 vm_munmap(realdatastart, len);
53311 + up_write(&current->mm->mmap_sem);
53312 ret = result;
53313 goto err;
53314 }
53315 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53316 }
53317 if (IS_ERR_VALUE(result)) {
53318 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53319 + down_write(&current->mm->mmap_sem);
53320 vm_munmap(textpos, text_len + data_len + extra +
53321 MAX_SHARED_LIBS * sizeof(unsigned long));
53322 + up_write(&current->mm->mmap_sem);
53323 ret = result;
53324 goto err;
53325 }
53326 diff --git a/fs/bio.c b/fs/bio.c
53327 index 5e7507d..418c639 100644
53328 --- a/fs/bio.c
53329 +++ b/fs/bio.c
53330 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53331 /*
53332 * Overflow, abort
53333 */
53334 - if (end < start)
53335 + if (end < start || end - start > INT_MAX - nr_pages)
53336 return ERR_PTR(-EINVAL);
53337
53338 nr_pages += end - start;
53339 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53340 /*
53341 * Overflow, abort
53342 */
53343 - if (end < start)
53344 + if (end < start || end - start > INT_MAX - nr_pages)
53345 return ERR_PTR(-EINVAL);
53346
53347 nr_pages += end - start;
53348 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53349 const int read = bio_data_dir(bio) == READ;
53350 struct bio_map_data *bmd = bio->bi_private;
53351 int i;
53352 - char *p = bmd->sgvecs[0].iov_base;
53353 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53354
53355 bio_for_each_segment_all(bvec, bio, i) {
53356 char *addr = page_address(bvec->bv_page);
53357 diff --git a/fs/block_dev.c b/fs/block_dev.c
53358 index c7bda5c..2121e94 100644
53359 --- a/fs/block_dev.c
53360 +++ b/fs/block_dev.c
53361 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53362 else if (bdev->bd_contains == bdev)
53363 return true; /* is a whole device which isn't held */
53364
53365 - else if (whole->bd_holder == bd_may_claim)
53366 + else if (whole->bd_holder == (void *)bd_may_claim)
53367 return true; /* is a partition of a device that is being partitioned */
53368 else if (whole->bd_holder != NULL)
53369 return false; /* is a partition of a held device */
53370 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53371 index ed50460..fe84385 100644
53372 --- a/fs/btrfs/ctree.c
53373 +++ b/fs/btrfs/ctree.c
53374 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53375 free_extent_buffer(buf);
53376 add_root_to_dirty_list(root);
53377 } else {
53378 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53379 - parent_start = parent->start;
53380 - else
53381 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53382 + if (parent)
53383 + parent_start = parent->start;
53384 + else
53385 + parent_start = 0;
53386 + } else
53387 parent_start = 0;
53388
53389 WARN_ON(trans->transid != btrfs_header_generation(parent));
53390 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53391 index 3755109..e3d457f 100644
53392 --- a/fs/btrfs/delayed-inode.c
53393 +++ b/fs/btrfs/delayed-inode.c
53394 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53395
53396 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53397 {
53398 - int seq = atomic_inc_return(&delayed_root->items_seq);
53399 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53400 if ((atomic_dec_return(&delayed_root->items) <
53401 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53402 waitqueue_active(&delayed_root->wait))
53403 @@ -1377,7 +1377,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53404 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53405 int seq, int count)
53406 {
53407 - int val = atomic_read(&delayed_root->items_seq);
53408 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53409
53410 if (val < seq || val >= seq + count)
53411 return 1;
53412 @@ -1394,7 +1394,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53413 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53414 return;
53415
53416 - seq = atomic_read(&delayed_root->items_seq);
53417 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53418
53419 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53420 int ret;
53421 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53422 index a4b38f9..f86a509 100644
53423 --- a/fs/btrfs/delayed-inode.h
53424 +++ b/fs/btrfs/delayed-inode.h
53425 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53426 */
53427 struct list_head prepare_list;
53428 atomic_t items; /* for delayed items */
53429 - atomic_t items_seq; /* for delayed items */
53430 + atomic_unchecked_t items_seq; /* for delayed items */
53431 int nodes; /* for delayed nodes */
53432 wait_queue_head_t wait;
53433 };
53434 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53435 struct btrfs_delayed_root *delayed_root)
53436 {
53437 atomic_set(&delayed_root->items, 0);
53438 - atomic_set(&delayed_root->items_seq, 0);
53439 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53440 delayed_root->nodes = 0;
53441 spin_lock_init(&delayed_root->lock);
53442 init_waitqueue_head(&delayed_root->wait);
53443 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53444 index 9877a2a..7ebf9ab 100644
53445 --- a/fs/btrfs/ioctl.c
53446 +++ b/fs/btrfs/ioctl.c
53447 @@ -3097,9 +3097,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53448 for (i = 0; i < num_types; i++) {
53449 struct btrfs_space_info *tmp;
53450
53451 + /* Don't copy in more than we allocated */
53452 if (!slot_count)
53453 break;
53454
53455 + slot_count--;
53456 +
53457 info = NULL;
53458 rcu_read_lock();
53459 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53460 @@ -3121,10 +3124,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53461 memcpy(dest, &space, sizeof(space));
53462 dest++;
53463 space_args.total_spaces++;
53464 - slot_count--;
53465 }
53466 - if (!slot_count)
53467 - break;
53468 }
53469 up_read(&info->groups_sem);
53470 }
53471 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53472 index 8eb6191..eda91e2 100644
53473 --- a/fs/btrfs/super.c
53474 +++ b/fs/btrfs/super.c
53475 @@ -264,7 +264,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53476 function, line, errstr);
53477 return;
53478 }
53479 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53480 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53481 /* Wake up anybody who may be waiting on this transaction */
53482 wake_up(&root->fs_info->transaction_wait);
53483 wake_up(&root->fs_info->transaction_blocked_wait);
53484 diff --git a/fs/buffer.c b/fs/buffer.c
53485 index 4d74335..7bd000a 100644
53486 --- a/fs/buffer.c
53487 +++ b/fs/buffer.c
53488 @@ -1005,9 +1005,19 @@ grow_dev_page(struct block_device *bdev, sector_t block,
53489 struct buffer_head *bh;
53490 sector_t end_block;
53491 int ret = 0; /* Will call free_more_memory() */
53492 + gfp_t gfp_mask;
53493
53494 - page = find_or_create_page(inode->i_mapping, index,
53495 - (mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS)|__GFP_MOVABLE);
53496 + gfp_mask = mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS;
53497 + gfp_mask |= __GFP_MOVABLE;
53498 + /*
53499 + * XXX: __getblk_slow() can not really deal with failure and
53500 + * will endlessly loop on improvised global reclaim. Prefer
53501 + * looping in the allocator rather than here, at least that
53502 + * code knows what it's doing.
53503 + */
53504 + gfp_mask |= __GFP_NOFAIL;
53505 +
53506 + page = find_or_create_page(inode->i_mapping, index, gfp_mask);
53507 if (!page)
53508 return ret;
53509
53510 @@ -3416,7 +3426,7 @@ void __init buffer_init(void)
53511 bh_cachep = kmem_cache_create("buffer_head",
53512 sizeof(struct buffer_head), 0,
53513 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53514 - SLAB_MEM_SPREAD),
53515 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53516 NULL);
53517
53518 /*
53519 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53520 index 622f469..e8d2d55 100644
53521 --- a/fs/cachefiles/bind.c
53522 +++ b/fs/cachefiles/bind.c
53523 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53524 args);
53525
53526 /* start by checking things over */
53527 - ASSERT(cache->fstop_percent >= 0 &&
53528 - cache->fstop_percent < cache->fcull_percent &&
53529 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53530 cache->fcull_percent < cache->frun_percent &&
53531 cache->frun_percent < 100);
53532
53533 - ASSERT(cache->bstop_percent >= 0 &&
53534 - cache->bstop_percent < cache->bcull_percent &&
53535 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53536 cache->bcull_percent < cache->brun_percent &&
53537 cache->brun_percent < 100);
53538
53539 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53540 index 0a1467b..6a53245 100644
53541 --- a/fs/cachefiles/daemon.c
53542 +++ b/fs/cachefiles/daemon.c
53543 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53544 if (n > buflen)
53545 return -EMSGSIZE;
53546
53547 - if (copy_to_user(_buffer, buffer, n) != 0)
53548 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53549 return -EFAULT;
53550
53551 return n;
53552 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53553 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53554 return -EIO;
53555
53556 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53557 + if (datalen > PAGE_SIZE - 1)
53558 return -EOPNOTSUPP;
53559
53560 /* drag the command string into the kernel so we can parse it */
53561 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53562 if (args[0] != '%' || args[1] != '\0')
53563 return -EINVAL;
53564
53565 - if (fstop < 0 || fstop >= cache->fcull_percent)
53566 + if (fstop >= cache->fcull_percent)
53567 return cachefiles_daemon_range_error(cache, args);
53568
53569 cache->fstop_percent = fstop;
53570 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
53571 if (args[0] != '%' || args[1] != '\0')
53572 return -EINVAL;
53573
53574 - if (bstop < 0 || bstop >= cache->bcull_percent)
53575 + if (bstop >= cache->bcull_percent)
53576 return cachefiles_daemon_range_error(cache, args);
53577
53578 cache->bstop_percent = bstop;
53579 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
53580 index 4938251..7e01445 100644
53581 --- a/fs/cachefiles/internal.h
53582 +++ b/fs/cachefiles/internal.h
53583 @@ -59,7 +59,7 @@ struct cachefiles_cache {
53584 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
53585 struct rb_root active_nodes; /* active nodes (can't be culled) */
53586 rwlock_t active_lock; /* lock for active_nodes */
53587 - atomic_t gravecounter; /* graveyard uniquifier */
53588 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
53589 unsigned frun_percent; /* when to stop culling (% files) */
53590 unsigned fcull_percent; /* when to start culling (% files) */
53591 unsigned fstop_percent; /* when to stop allocating (% files) */
53592 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
53593 * proc.c
53594 */
53595 #ifdef CONFIG_CACHEFILES_HISTOGRAM
53596 -extern atomic_t cachefiles_lookup_histogram[HZ];
53597 -extern atomic_t cachefiles_mkdir_histogram[HZ];
53598 -extern atomic_t cachefiles_create_histogram[HZ];
53599 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53600 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53601 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
53602
53603 extern int __init cachefiles_proc_init(void);
53604 extern void cachefiles_proc_cleanup(void);
53605 static inline
53606 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
53607 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
53608 {
53609 unsigned long jif = jiffies - start_jif;
53610 if (jif >= HZ)
53611 jif = HZ - 1;
53612 - atomic_inc(&histogram[jif]);
53613 + atomic_inc_unchecked(&histogram[jif]);
53614 }
53615
53616 #else
53617 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
53618 index 25badd1..d70d918 100644
53619 --- a/fs/cachefiles/namei.c
53620 +++ b/fs/cachefiles/namei.c
53621 @@ -317,7 +317,7 @@ try_again:
53622 /* first step is to make up a grave dentry in the graveyard */
53623 sprintf(nbuffer, "%08x%08x",
53624 (uint32_t) get_seconds(),
53625 - (uint32_t) atomic_inc_return(&cache->gravecounter));
53626 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
53627
53628 /* do the multiway lock magic */
53629 trap = lock_rename(cache->graveyard, dir);
53630 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
53631 index eccd339..4c1d995 100644
53632 --- a/fs/cachefiles/proc.c
53633 +++ b/fs/cachefiles/proc.c
53634 @@ -14,9 +14,9 @@
53635 #include <linux/seq_file.h>
53636 #include "internal.h"
53637
53638 -atomic_t cachefiles_lookup_histogram[HZ];
53639 -atomic_t cachefiles_mkdir_histogram[HZ];
53640 -atomic_t cachefiles_create_histogram[HZ];
53641 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53642 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53643 +atomic_unchecked_t cachefiles_create_histogram[HZ];
53644
53645 /*
53646 * display the latency histogram
53647 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
53648 return 0;
53649 default:
53650 index = (unsigned long) v - 3;
53651 - x = atomic_read(&cachefiles_lookup_histogram[index]);
53652 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
53653 - z = atomic_read(&cachefiles_create_histogram[index]);
53654 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
53655 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
53656 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
53657 if (x == 0 && y == 0 && z == 0)
53658 return 0;
53659
53660 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
53661 index ebaff36..7e3ea26 100644
53662 --- a/fs/cachefiles/rdwr.c
53663 +++ b/fs/cachefiles/rdwr.c
53664 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
53665 old_fs = get_fs();
53666 set_fs(KERNEL_DS);
53667 ret = file->f_op->write(
53668 - file, (const void __user *) data, len, &pos);
53669 + file, (const void __force_user *) data, len, &pos);
53670 set_fs(old_fs);
53671 kunmap(page);
53672 file_end_write(file);
53673 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
53674 index a40ceda..f43d17c 100644
53675 --- a/fs/ceph/dir.c
53676 +++ b/fs/ceph/dir.c
53677 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
53678 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
53679 struct ceph_mds_client *mdsc = fsc->mdsc;
53680 unsigned frag = fpos_frag(ctx->pos);
53681 - int off = fpos_off(ctx->pos);
53682 + unsigned int off = fpos_off(ctx->pos);
53683 int err;
53684 u32 ftype;
53685 struct ceph_mds_reply_info_parsed *rinfo;
53686 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
53687 index 6627b26..634ec4b 100644
53688 --- a/fs/ceph/super.c
53689 +++ b/fs/ceph/super.c
53690 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
53691 /*
53692 * construct our own bdi so we can control readahead, etc.
53693 */
53694 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
53695 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
53696
53697 static int ceph_register_bdi(struct super_block *sb,
53698 struct ceph_fs_client *fsc)
53699 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
53700 default_backing_dev_info.ra_pages;
53701
53702 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
53703 - atomic_long_inc_return(&bdi_seq));
53704 + atomic_long_inc_return_unchecked(&bdi_seq));
53705 if (!err)
53706 sb->s_bdi = &fsc->backing_dev_info;
53707 return err;
53708 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
53709 index f3ac415..3d2420c 100644
53710 --- a/fs/cifs/cifs_debug.c
53711 +++ b/fs/cifs/cifs_debug.c
53712 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53713
53714 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
53715 #ifdef CONFIG_CIFS_STATS2
53716 - atomic_set(&totBufAllocCount, 0);
53717 - atomic_set(&totSmBufAllocCount, 0);
53718 + atomic_set_unchecked(&totBufAllocCount, 0);
53719 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53720 #endif /* CONFIG_CIFS_STATS2 */
53721 spin_lock(&cifs_tcp_ses_lock);
53722 list_for_each(tmp1, &cifs_tcp_ses_list) {
53723 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53724 tcon = list_entry(tmp3,
53725 struct cifs_tcon,
53726 tcon_list);
53727 - atomic_set(&tcon->num_smbs_sent, 0);
53728 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
53729 if (server->ops->clear_stats)
53730 server->ops->clear_stats(tcon);
53731 }
53732 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53733 smBufAllocCount.counter, cifs_min_small);
53734 #ifdef CONFIG_CIFS_STATS2
53735 seq_printf(m, "Total Large %d Small %d Allocations\n",
53736 - atomic_read(&totBufAllocCount),
53737 - atomic_read(&totSmBufAllocCount));
53738 + atomic_read_unchecked(&totBufAllocCount),
53739 + atomic_read_unchecked(&totSmBufAllocCount));
53740 #endif /* CONFIG_CIFS_STATS2 */
53741
53742 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
53743 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53744 if (tcon->need_reconnect)
53745 seq_puts(m, "\tDISCONNECTED ");
53746 seq_printf(m, "\nSMBs: %d",
53747 - atomic_read(&tcon->num_smbs_sent));
53748 + atomic_read_unchecked(&tcon->num_smbs_sent));
53749 if (server->ops->print_stats)
53750 server->ops->print_stats(m, tcon);
53751 }
53752 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
53753 index 40cfef5..1eee040 100644
53754 --- a/fs/cifs/cifsfs.c
53755 +++ b/fs/cifs/cifsfs.c
53756 @@ -1039,7 +1039,7 @@ cifs_init_request_bufs(void)
53757 */
53758 cifs_req_cachep = kmem_cache_create("cifs_request",
53759 CIFSMaxBufSize + max_hdr_size, 0,
53760 - SLAB_HWCACHE_ALIGN, NULL);
53761 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
53762 if (cifs_req_cachep == NULL)
53763 return -ENOMEM;
53764
53765 @@ -1066,7 +1066,7 @@ cifs_init_request_bufs(void)
53766 efficient to alloc 1 per page off the slab compared to 17K (5page)
53767 alloc of large cifs buffers even when page debugging is on */
53768 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
53769 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
53770 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
53771 NULL);
53772 if (cifs_sm_req_cachep == NULL) {
53773 mempool_destroy(cifs_req_poolp);
53774 @@ -1151,8 +1151,8 @@ init_cifs(void)
53775 atomic_set(&bufAllocCount, 0);
53776 atomic_set(&smBufAllocCount, 0);
53777 #ifdef CONFIG_CIFS_STATS2
53778 - atomic_set(&totBufAllocCount, 0);
53779 - atomic_set(&totSmBufAllocCount, 0);
53780 + atomic_set_unchecked(&totBufAllocCount, 0);
53781 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53782 #endif /* CONFIG_CIFS_STATS2 */
53783
53784 atomic_set(&midCount, 0);
53785 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
53786 index 52ca861..47f309c 100644
53787 --- a/fs/cifs/cifsglob.h
53788 +++ b/fs/cifs/cifsglob.h
53789 @@ -756,35 +756,35 @@ struct cifs_tcon {
53790 __u16 Flags; /* optional support bits */
53791 enum statusEnum tidStatus;
53792 #ifdef CONFIG_CIFS_STATS
53793 - atomic_t num_smbs_sent;
53794 + atomic_unchecked_t num_smbs_sent;
53795 union {
53796 struct {
53797 - atomic_t num_writes;
53798 - atomic_t num_reads;
53799 - atomic_t num_flushes;
53800 - atomic_t num_oplock_brks;
53801 - atomic_t num_opens;
53802 - atomic_t num_closes;
53803 - atomic_t num_deletes;
53804 - atomic_t num_mkdirs;
53805 - atomic_t num_posixopens;
53806 - atomic_t num_posixmkdirs;
53807 - atomic_t num_rmdirs;
53808 - atomic_t num_renames;
53809 - atomic_t num_t2renames;
53810 - atomic_t num_ffirst;
53811 - atomic_t num_fnext;
53812 - atomic_t num_fclose;
53813 - atomic_t num_hardlinks;
53814 - atomic_t num_symlinks;
53815 - atomic_t num_locks;
53816 - atomic_t num_acl_get;
53817 - atomic_t num_acl_set;
53818 + atomic_unchecked_t num_writes;
53819 + atomic_unchecked_t num_reads;
53820 + atomic_unchecked_t num_flushes;
53821 + atomic_unchecked_t num_oplock_brks;
53822 + atomic_unchecked_t num_opens;
53823 + atomic_unchecked_t num_closes;
53824 + atomic_unchecked_t num_deletes;
53825 + atomic_unchecked_t num_mkdirs;
53826 + atomic_unchecked_t num_posixopens;
53827 + atomic_unchecked_t num_posixmkdirs;
53828 + atomic_unchecked_t num_rmdirs;
53829 + atomic_unchecked_t num_renames;
53830 + atomic_unchecked_t num_t2renames;
53831 + atomic_unchecked_t num_ffirst;
53832 + atomic_unchecked_t num_fnext;
53833 + atomic_unchecked_t num_fclose;
53834 + atomic_unchecked_t num_hardlinks;
53835 + atomic_unchecked_t num_symlinks;
53836 + atomic_unchecked_t num_locks;
53837 + atomic_unchecked_t num_acl_get;
53838 + atomic_unchecked_t num_acl_set;
53839 } cifs_stats;
53840 #ifdef CONFIG_CIFS_SMB2
53841 struct {
53842 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53843 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53844 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53845 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53846 } smb2_stats;
53847 #endif /* CONFIG_CIFS_SMB2 */
53848 } stats;
53849 @@ -1096,7 +1096,7 @@ convert_delimiter(char *path, char delim)
53850 }
53851
53852 #ifdef CONFIG_CIFS_STATS
53853 -#define cifs_stats_inc atomic_inc
53854 +#define cifs_stats_inc atomic_inc_unchecked
53855
53856 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
53857 unsigned int bytes)
53858 @@ -1461,8 +1461,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
53859 /* Various Debug counters */
53860 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
53861 #ifdef CONFIG_CIFS_STATS2
53862 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
53863 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
53864 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
53865 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
53866 #endif
53867 GLOBAL_EXTERN atomic_t smBufAllocCount;
53868 GLOBAL_EXTERN atomic_t midCount;
53869 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
53870 index 562044f..4af6a17 100644
53871 --- a/fs/cifs/link.c
53872 +++ b/fs/cifs/link.c
53873 @@ -638,7 +638,7 @@ symlink_exit:
53874
53875 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
53876 {
53877 - char *p = nd_get_link(nd);
53878 + const char *p = nd_get_link(nd);
53879 if (!IS_ERR(p))
53880 kfree(p);
53881 }
53882 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
53883 index f7d4b22..1254377 100644
53884 --- a/fs/cifs/misc.c
53885 +++ b/fs/cifs/misc.c
53886 @@ -169,7 +169,7 @@ cifs_buf_get(void)
53887 memset(ret_buf, 0, buf_size + 3);
53888 atomic_inc(&bufAllocCount);
53889 #ifdef CONFIG_CIFS_STATS2
53890 - atomic_inc(&totBufAllocCount);
53891 + atomic_inc_unchecked(&totBufAllocCount);
53892 #endif /* CONFIG_CIFS_STATS2 */
53893 }
53894
53895 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
53896 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
53897 atomic_inc(&smBufAllocCount);
53898 #ifdef CONFIG_CIFS_STATS2
53899 - atomic_inc(&totSmBufAllocCount);
53900 + atomic_inc_unchecked(&totSmBufAllocCount);
53901 #endif /* CONFIG_CIFS_STATS2 */
53902
53903 }
53904 diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
53905 index af847e1..651a527 100644
53906 --- a/fs/cifs/netmisc.c
53907 +++ b/fs/cifs/netmisc.c
53908 @@ -780,7 +780,9 @@ static const struct {
53909 ERRDOS, ERRnoaccess, 0xc0000290}, {
53910 ERRDOS, ERRbadfunc, 0xc000029c}, {
53911 ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
53912 - ERRDOS, ERRinvlevel, 0x007c0001}, };
53913 + ERRDOS, ERRinvlevel, 0x007c0001}, {
53914 + 0, 0, 0 }
53915 +};
53916
53917 /*****************************************************************************
53918 Print an error message from the status code
53919 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
53920 index 6094397..51e576f 100644
53921 --- a/fs/cifs/smb1ops.c
53922 +++ b/fs/cifs/smb1ops.c
53923 @@ -590,27 +590,27 @@ static void
53924 cifs_clear_stats(struct cifs_tcon *tcon)
53925 {
53926 #ifdef CONFIG_CIFS_STATS
53927 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
53928 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
53929 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
53930 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53931 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
53932 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
53933 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53934 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
53935 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
53936 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
53937 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
53938 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
53939 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
53940 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
53941 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
53942 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
53943 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
53944 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
53945 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
53946 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
53947 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
53948 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
53949 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
53950 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
53951 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53952 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
53953 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
53954 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53955 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
53956 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
53957 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
53958 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
53959 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
53960 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
53961 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
53962 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
53963 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
53964 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
53965 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
53966 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
53967 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
53968 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
53969 #endif
53970 }
53971
53972 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
53973 {
53974 #ifdef CONFIG_CIFS_STATS
53975 seq_printf(m, " Oplocks breaks: %d",
53976 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
53977 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
53978 seq_printf(m, "\nReads: %d Bytes: %llu",
53979 - atomic_read(&tcon->stats.cifs_stats.num_reads),
53980 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
53981 (long long)(tcon->bytes_read));
53982 seq_printf(m, "\nWrites: %d Bytes: %llu",
53983 - atomic_read(&tcon->stats.cifs_stats.num_writes),
53984 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
53985 (long long)(tcon->bytes_written));
53986 seq_printf(m, "\nFlushes: %d",
53987 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
53988 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
53989 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
53990 - atomic_read(&tcon->stats.cifs_stats.num_locks),
53991 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
53992 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
53993 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
53994 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
53995 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
53996 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
53997 - atomic_read(&tcon->stats.cifs_stats.num_opens),
53998 - atomic_read(&tcon->stats.cifs_stats.num_closes),
53999 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54000 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54001 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54002 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54003 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54004 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54005 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54006 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54007 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54008 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54009 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54010 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54011 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54012 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54013 seq_printf(m, "\nRenames: %d T2 Renames %d",
54014 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54015 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54016 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54017 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54018 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54019 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54020 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54021 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54022 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54023 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54024 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54025 #endif
54026 }
54027
54028 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54029 index f259e6c..ca948ff 100644
54030 --- a/fs/cifs/smb2ops.c
54031 +++ b/fs/cifs/smb2ops.c
54032 @@ -281,8 +281,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54033 #ifdef CONFIG_CIFS_STATS
54034 int i;
54035 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54036 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54037 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54038 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54039 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54040 }
54041 #endif
54042 }
54043 @@ -310,65 +310,65 @@ static void
54044 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54045 {
54046 #ifdef CONFIG_CIFS_STATS
54047 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54048 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54049 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54050 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54051 seq_printf(m, "\nNegotiates: %d sent %d failed",
54052 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54053 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54054 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54055 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54056 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54057 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54058 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54059 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54060 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54061 seq_printf(m, "\nLogoffs: %d sent %d failed",
54062 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54063 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54064 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54065 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54066 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54067 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54068 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54069 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54070 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54071 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54072 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54073 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54074 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54075 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54076 seq_printf(m, "\nCreates: %d sent %d failed",
54077 - atomic_read(&sent[SMB2_CREATE_HE]),
54078 - atomic_read(&failed[SMB2_CREATE_HE]));
54079 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54080 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54081 seq_printf(m, "\nCloses: %d sent %d failed",
54082 - atomic_read(&sent[SMB2_CLOSE_HE]),
54083 - atomic_read(&failed[SMB2_CLOSE_HE]));
54084 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54085 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54086 seq_printf(m, "\nFlushes: %d sent %d failed",
54087 - atomic_read(&sent[SMB2_FLUSH_HE]),
54088 - atomic_read(&failed[SMB2_FLUSH_HE]));
54089 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54090 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54091 seq_printf(m, "\nReads: %d sent %d failed",
54092 - atomic_read(&sent[SMB2_READ_HE]),
54093 - atomic_read(&failed[SMB2_READ_HE]));
54094 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54095 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54096 seq_printf(m, "\nWrites: %d sent %d failed",
54097 - atomic_read(&sent[SMB2_WRITE_HE]),
54098 - atomic_read(&failed[SMB2_WRITE_HE]));
54099 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54100 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54101 seq_printf(m, "\nLocks: %d sent %d failed",
54102 - atomic_read(&sent[SMB2_LOCK_HE]),
54103 - atomic_read(&failed[SMB2_LOCK_HE]));
54104 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54105 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54106 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54107 - atomic_read(&sent[SMB2_IOCTL_HE]),
54108 - atomic_read(&failed[SMB2_IOCTL_HE]));
54109 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54110 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54111 seq_printf(m, "\nCancels: %d sent %d failed",
54112 - atomic_read(&sent[SMB2_CANCEL_HE]),
54113 - atomic_read(&failed[SMB2_CANCEL_HE]));
54114 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54115 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54116 seq_printf(m, "\nEchos: %d sent %d failed",
54117 - atomic_read(&sent[SMB2_ECHO_HE]),
54118 - atomic_read(&failed[SMB2_ECHO_HE]));
54119 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54120 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54121 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54122 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54123 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54124 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54125 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54126 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54127 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54128 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54129 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54130 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54131 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54132 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54133 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54134 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54135 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54136 seq_printf(m, "\nSetInfos: %d sent %d failed",
54137 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54138 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54139 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54140 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54141 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54142 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54143 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54144 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54145 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54146 #endif
54147 }
54148
54149 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54150 index abc9c28..3fdae28 100644
54151 --- a/fs/cifs/smb2pdu.c
54152 +++ b/fs/cifs/smb2pdu.c
54153 @@ -1946,8 +1946,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54154 default:
54155 cifs_dbg(VFS, "info level %u isn't supported\n",
54156 srch_inf->info_level);
54157 - rc = -EINVAL;
54158 - goto qdir_exit;
54159 + return -EINVAL;
54160 }
54161
54162 req->FileIndex = cpu_to_le32(index);
54163 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54164 index 1da168c..8bc7ff6 100644
54165 --- a/fs/coda/cache.c
54166 +++ b/fs/coda/cache.c
54167 @@ -24,7 +24,7 @@
54168 #include "coda_linux.h"
54169 #include "coda_cache.h"
54170
54171 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54172 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54173
54174 /* replace or extend an acl cache hit */
54175 void coda_cache_enter(struct inode *inode, int mask)
54176 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54177 struct coda_inode_info *cii = ITOC(inode);
54178
54179 spin_lock(&cii->c_lock);
54180 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54181 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54182 if (!uid_eq(cii->c_uid, current_fsuid())) {
54183 cii->c_uid = current_fsuid();
54184 cii->c_cached_perm = mask;
54185 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54186 {
54187 struct coda_inode_info *cii = ITOC(inode);
54188 spin_lock(&cii->c_lock);
54189 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54190 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54191 spin_unlock(&cii->c_lock);
54192 }
54193
54194 /* remove all acl caches */
54195 void coda_cache_clear_all(struct super_block *sb)
54196 {
54197 - atomic_inc(&permission_epoch);
54198 + atomic_inc_unchecked(&permission_epoch);
54199 }
54200
54201
54202 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54203 spin_lock(&cii->c_lock);
54204 hit = (mask & cii->c_cached_perm) == mask &&
54205 uid_eq(cii->c_uid, current_fsuid()) &&
54206 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54207 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54208 spin_unlock(&cii->c_lock);
54209
54210 return hit;
54211 diff --git a/fs/compat.c b/fs/compat.c
54212 index 6af20de..fec3fbb 100644
54213 --- a/fs/compat.c
54214 +++ b/fs/compat.c
54215 @@ -54,7 +54,7 @@
54216 #include <asm/ioctls.h>
54217 #include "internal.h"
54218
54219 -int compat_log = 1;
54220 +int compat_log = 0;
54221
54222 int compat_printk(const char *fmt, ...)
54223 {
54224 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54225
54226 set_fs(KERNEL_DS);
54227 /* The __user pointer cast is valid because of the set_fs() */
54228 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54229 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54230 set_fs(oldfs);
54231 /* truncating is ok because it's a user address */
54232 if (!ret)
54233 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54234 goto out;
54235
54236 ret = -EINVAL;
54237 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54238 + if (nr_segs > UIO_MAXIOV)
54239 goto out;
54240 if (nr_segs > fast_segs) {
54241 ret = -ENOMEM;
54242 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54243 struct compat_readdir_callback {
54244 struct dir_context ctx;
54245 struct compat_old_linux_dirent __user *dirent;
54246 + struct file * file;
54247 int result;
54248 };
54249
54250 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54251 buf->result = -EOVERFLOW;
54252 return -EOVERFLOW;
54253 }
54254 +
54255 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54256 + return 0;
54257 +
54258 buf->result++;
54259 dirent = buf->dirent;
54260 if (!access_ok(VERIFY_WRITE, dirent,
54261 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54262 if (!f.file)
54263 return -EBADF;
54264
54265 + buf.file = f.file;
54266 error = iterate_dir(f.file, &buf.ctx);
54267 if (buf.result)
54268 error = buf.result;
54269 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54270 struct dir_context ctx;
54271 struct compat_linux_dirent __user *current_dir;
54272 struct compat_linux_dirent __user *previous;
54273 + struct file * file;
54274 int count;
54275 int error;
54276 };
54277 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54278 buf->error = -EOVERFLOW;
54279 return -EOVERFLOW;
54280 }
54281 +
54282 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54283 + return 0;
54284 +
54285 dirent = buf->previous;
54286 if (dirent) {
54287 if (__put_user(offset, &dirent->d_off))
54288 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54289 if (!f.file)
54290 return -EBADF;
54291
54292 + buf.file = f.file;
54293 error = iterate_dir(f.file, &buf.ctx);
54294 if (error >= 0)
54295 error = buf.error;
54296 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54297 struct dir_context ctx;
54298 struct linux_dirent64 __user *current_dir;
54299 struct linux_dirent64 __user *previous;
54300 + struct file * file;
54301 int count;
54302 int error;
54303 };
54304 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54305 buf->error = -EINVAL; /* only used if we fail.. */
54306 if (reclen > buf->count)
54307 return -EINVAL;
54308 +
54309 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54310 + return 0;
54311 +
54312 dirent = buf->previous;
54313
54314 if (dirent) {
54315 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54316 if (!f.file)
54317 return -EBADF;
54318
54319 + buf.file = f.file;
54320 error = iterate_dir(f.file, &buf.ctx);
54321 if (error >= 0)
54322 error = buf.error;
54323 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54324 index a81147e..20bf2b5 100644
54325 --- a/fs/compat_binfmt_elf.c
54326 +++ b/fs/compat_binfmt_elf.c
54327 @@ -30,11 +30,13 @@
54328 #undef elf_phdr
54329 #undef elf_shdr
54330 #undef elf_note
54331 +#undef elf_dyn
54332 #undef elf_addr_t
54333 #define elfhdr elf32_hdr
54334 #define elf_phdr elf32_phdr
54335 #define elf_shdr elf32_shdr
54336 #define elf_note elf32_note
54337 +#define elf_dyn Elf32_Dyn
54338 #define elf_addr_t Elf32_Addr
54339
54340 /*
54341 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54342 index 5d19acf..9ab093b 100644
54343 --- a/fs/compat_ioctl.c
54344 +++ b/fs/compat_ioctl.c
54345 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54346 return -EFAULT;
54347 if (__get_user(udata, &ss32->iomem_base))
54348 return -EFAULT;
54349 - ss.iomem_base = compat_ptr(udata);
54350 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54351 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54352 __get_user(ss.port_high, &ss32->port_high))
54353 return -EFAULT;
54354 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54355 for (i = 0; i < nmsgs; i++) {
54356 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54357 return -EFAULT;
54358 - if (get_user(datap, &umsgs[i].buf) ||
54359 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54360 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54361 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54362 return -EFAULT;
54363 }
54364 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54365 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54366 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54367 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54368 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54369 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54370 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54371 return -EFAULT;
54372
54373 return ioctl_preallocate(file, p);
54374 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54375 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54376 {
54377 unsigned int a, b;
54378 - a = *(unsigned int *)p;
54379 - b = *(unsigned int *)q;
54380 + a = *(const unsigned int *)p;
54381 + b = *(const unsigned int *)q;
54382 if (a > b)
54383 return 1;
54384 if (a < b)
54385 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54386 index 277bd1b..f312c9e 100644
54387 --- a/fs/configfs/dir.c
54388 +++ b/fs/configfs/dir.c
54389 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54390 }
54391 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54392 struct configfs_dirent *next;
54393 - const char *name;
54394 + const unsigned char * name;
54395 + char d_name[sizeof(next->s_dentry->d_iname)];
54396 int len;
54397 struct inode *inode = NULL;
54398
54399 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54400 continue;
54401
54402 name = configfs_get_name(next);
54403 - len = strlen(name);
54404 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54405 + len = next->s_dentry->d_name.len;
54406 + memcpy(d_name, name, len);
54407 + name = d_name;
54408 + } else
54409 + len = strlen(name);
54410
54411 /*
54412 * We'll have a dentry and an inode for
54413 diff --git a/fs/coredump.c b/fs/coredump.c
54414 index 72f816d..1ba8eff 100644
54415 --- a/fs/coredump.c
54416 +++ b/fs/coredump.c
54417 @@ -433,8 +433,8 @@ static void wait_for_dump_helpers(struct file *file)
54418 struct pipe_inode_info *pipe = file->private_data;
54419
54420 pipe_lock(pipe);
54421 - pipe->readers++;
54422 - pipe->writers--;
54423 + atomic_inc(&pipe->readers);
54424 + atomic_dec(&pipe->writers);
54425 wake_up_interruptible_sync(&pipe->wait);
54426 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54427 pipe_unlock(pipe);
54428 @@ -443,11 +443,11 @@ static void wait_for_dump_helpers(struct file *file)
54429 * We actually want wait_event_freezable() but then we need
54430 * to clear TIF_SIGPENDING and improve dump_interrupted().
54431 */
54432 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54433 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54434
54435 pipe_lock(pipe);
54436 - pipe->readers--;
54437 - pipe->writers++;
54438 + atomic_dec(&pipe->readers);
54439 + atomic_inc(&pipe->writers);
54440 pipe_unlock(pipe);
54441 }
54442
54443 @@ -494,7 +494,8 @@ void do_coredump(siginfo_t *siginfo)
54444 struct files_struct *displaced;
54445 bool need_nonrelative = false;
54446 bool core_dumped = false;
54447 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54448 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54449 + long signr = siginfo->si_signo;
54450 struct coredump_params cprm = {
54451 .siginfo = siginfo,
54452 .regs = signal_pt_regs(),
54453 @@ -507,7 +508,10 @@ void do_coredump(siginfo_t *siginfo)
54454 .mm_flags = mm->flags,
54455 };
54456
54457 - audit_core_dumps(siginfo->si_signo);
54458 + audit_core_dumps(signr);
54459 +
54460 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54461 + gr_handle_brute_attach(cprm.mm_flags);
54462
54463 binfmt = mm->binfmt;
54464 if (!binfmt || !binfmt->core_dump)
54465 @@ -531,7 +535,7 @@ void do_coredump(siginfo_t *siginfo)
54466 need_nonrelative = true;
54467 }
54468
54469 - retval = coredump_wait(siginfo->si_signo, &core_state);
54470 + retval = coredump_wait(signr, &core_state);
54471 if (retval < 0)
54472 goto fail_creds;
54473
54474 @@ -574,7 +578,7 @@ void do_coredump(siginfo_t *siginfo)
54475 }
54476 cprm.limit = RLIM_INFINITY;
54477
54478 - dump_count = atomic_inc_return(&core_dump_count);
54479 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54480 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54481 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54482 task_tgid_vnr(current), current->comm);
54483 @@ -606,6 +610,8 @@ void do_coredump(siginfo_t *siginfo)
54484 } else {
54485 struct inode *inode;
54486
54487 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54488 +
54489 if (cprm.limit < binfmt->min_coredump)
54490 goto fail_unlock;
54491
54492 @@ -664,7 +670,7 @@ close_fail:
54493 filp_close(cprm.file, NULL);
54494 fail_dropcount:
54495 if (ispipe)
54496 - atomic_dec(&core_dump_count);
54497 + atomic_dec_unchecked(&core_dump_count);
54498 fail_unlock:
54499 kfree(cn.corename);
54500 coredump_finish(mm, core_dumped);
54501 @@ -684,7 +690,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54502 {
54503 return !dump_interrupted() &&
54504 access_ok(VERIFY_READ, addr, nr) &&
54505 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54506 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54507 }
54508 EXPORT_SYMBOL(dump_write);
54509
54510 diff --git a/fs/dcache.c b/fs/dcache.c
54511 index b949af8..5978926 100644
54512 --- a/fs/dcache.c
54513 +++ b/fs/dcache.c
54514 @@ -3073,7 +3073,8 @@ void __init vfs_caches_init(unsigned long mempages)
54515 mempages -= reserve;
54516
54517 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54518 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54519 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54520 + SLAB_NO_SANITIZE, NULL);
54521
54522 dcache_init();
54523 inode_init();
54524 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54525 index c7c83ff..bda9461 100644
54526 --- a/fs/debugfs/inode.c
54527 +++ b/fs/debugfs/inode.c
54528 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54529 */
54530 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54531 {
54532 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54533 + return __create_file(name, S_IFDIR | S_IRWXU,
54534 +#else
54535 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54536 +#endif
54537 parent, NULL, NULL);
54538 }
54539 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54540 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54541 index 67e9b63..a9adb68 100644
54542 --- a/fs/ecryptfs/inode.c
54543 +++ b/fs/ecryptfs/inode.c
54544 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54545 old_fs = get_fs();
54546 set_fs(get_ds());
54547 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54548 - (char __user *)lower_buf,
54549 + (char __force_user *)lower_buf,
54550 PATH_MAX);
54551 set_fs(old_fs);
54552 if (rc < 0)
54553 @@ -706,7 +706,7 @@ out:
54554 static void
54555 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54556 {
54557 - char *buf = nd_get_link(nd);
54558 + const char *buf = nd_get_link(nd);
54559 if (!IS_ERR(buf)) {
54560 /* Free the char* */
54561 kfree(buf);
54562 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54563 index e4141f2..d8263e8 100644
54564 --- a/fs/ecryptfs/miscdev.c
54565 +++ b/fs/ecryptfs/miscdev.c
54566 @@ -304,7 +304,7 @@ check_list:
54567 goto out_unlock_msg_ctx;
54568 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54569 if (msg_ctx->msg) {
54570 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
54571 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
54572 goto out_unlock_msg_ctx;
54573 i += packet_length_size;
54574 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
54575 diff --git a/fs/exec.c b/fs/exec.c
54576 index fd774c7..1c6a7bf 100644
54577 --- a/fs/exec.c
54578 +++ b/fs/exec.c
54579 @@ -55,8 +55,20 @@
54580 #include <linux/pipe_fs_i.h>
54581 #include <linux/oom.h>
54582 #include <linux/compat.h>
54583 +#include <linux/random.h>
54584 +#include <linux/seq_file.h>
54585 +#include <linux/coredump.h>
54586 +#include <linux/mman.h>
54587 +
54588 +#ifdef CONFIG_PAX_REFCOUNT
54589 +#include <linux/kallsyms.h>
54590 +#include <linux/kdebug.h>
54591 +#endif
54592 +
54593 +#include <trace/events/fs.h>
54594
54595 #include <asm/uaccess.h>
54596 +#include <asm/sections.h>
54597 #include <asm/mmu_context.h>
54598 #include <asm/tlb.h>
54599
54600 @@ -66,17 +78,32 @@
54601
54602 #include <trace/events/sched.h>
54603
54604 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54605 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
54606 +{
54607 + 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");
54608 +}
54609 +#endif
54610 +
54611 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
54612 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
54613 +EXPORT_SYMBOL(pax_set_initial_flags_func);
54614 +#endif
54615 +
54616 int suid_dumpable = 0;
54617
54618 static LIST_HEAD(formats);
54619 static DEFINE_RWLOCK(binfmt_lock);
54620
54621 +extern int gr_process_kernel_exec_ban(void);
54622 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
54623 +
54624 void __register_binfmt(struct linux_binfmt * fmt, int insert)
54625 {
54626 BUG_ON(!fmt);
54627 write_lock(&binfmt_lock);
54628 - insert ? list_add(&fmt->lh, &formats) :
54629 - list_add_tail(&fmt->lh, &formats);
54630 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
54631 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
54632 write_unlock(&binfmt_lock);
54633 }
54634
54635 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
54636 void unregister_binfmt(struct linux_binfmt * fmt)
54637 {
54638 write_lock(&binfmt_lock);
54639 - list_del(&fmt->lh);
54640 + pax_list_del((struct list_head *)&fmt->lh);
54641 write_unlock(&binfmt_lock);
54642 }
54643
54644 @@ -181,18 +208,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54645 int write)
54646 {
54647 struct page *page;
54648 - int ret;
54649
54650 -#ifdef CONFIG_STACK_GROWSUP
54651 - if (write) {
54652 - ret = expand_downwards(bprm->vma, pos);
54653 - if (ret < 0)
54654 - return NULL;
54655 - }
54656 -#endif
54657 - ret = get_user_pages(current, bprm->mm, pos,
54658 - 1, write, 1, &page, NULL);
54659 - if (ret <= 0)
54660 + if (0 > expand_downwards(bprm->vma, pos))
54661 + return NULL;
54662 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
54663 return NULL;
54664
54665 if (write) {
54666 @@ -208,6 +227,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54667 if (size <= ARG_MAX)
54668 return page;
54669
54670 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54671 + // only allow 512KB for argv+env on suid/sgid binaries
54672 + // to prevent easy ASLR exhaustion
54673 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
54674 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
54675 + (size > (512 * 1024))) {
54676 + put_page(page);
54677 + return NULL;
54678 + }
54679 +#endif
54680 +
54681 /*
54682 * Limit to 1/4-th the stack size for the argv+env strings.
54683 * This ensures that:
54684 @@ -267,6 +297,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54685 vma->vm_end = STACK_TOP_MAX;
54686 vma->vm_start = vma->vm_end - PAGE_SIZE;
54687 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
54688 +
54689 +#ifdef CONFIG_PAX_SEGMEXEC
54690 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
54691 +#endif
54692 +
54693 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
54694 INIT_LIST_HEAD(&vma->anon_vma_chain);
54695
54696 @@ -277,6 +312,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54697 mm->stack_vm = mm->total_vm = 1;
54698 up_write(&mm->mmap_sem);
54699 bprm->p = vma->vm_end - sizeof(void *);
54700 +
54701 +#ifdef CONFIG_PAX_RANDUSTACK
54702 + if (randomize_va_space)
54703 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
54704 +#endif
54705 +
54706 return 0;
54707 err:
54708 up_write(&mm->mmap_sem);
54709 @@ -397,7 +438,7 @@ struct user_arg_ptr {
54710 } ptr;
54711 };
54712
54713 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54714 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54715 {
54716 const char __user *native;
54717
54718 @@ -406,14 +447,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54719 compat_uptr_t compat;
54720
54721 if (get_user(compat, argv.ptr.compat + nr))
54722 - return ERR_PTR(-EFAULT);
54723 + return (const char __force_user *)ERR_PTR(-EFAULT);
54724
54725 return compat_ptr(compat);
54726 }
54727 #endif
54728
54729 if (get_user(native, argv.ptr.native + nr))
54730 - return ERR_PTR(-EFAULT);
54731 + return (const char __force_user *)ERR_PTR(-EFAULT);
54732
54733 return native;
54734 }
54735 @@ -432,7 +473,7 @@ static int count(struct user_arg_ptr argv, int max)
54736 if (!p)
54737 break;
54738
54739 - if (IS_ERR(p))
54740 + if (IS_ERR((const char __force_kernel *)p))
54741 return -EFAULT;
54742
54743 if (i >= max)
54744 @@ -467,7 +508,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
54745
54746 ret = -EFAULT;
54747 str = get_user_arg_ptr(argv, argc);
54748 - if (IS_ERR(str))
54749 + if (IS_ERR((const char __force_kernel *)str))
54750 goto out;
54751
54752 len = strnlen_user(str, MAX_ARG_STRLEN);
54753 @@ -549,7 +590,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
54754 int r;
54755 mm_segment_t oldfs = get_fs();
54756 struct user_arg_ptr argv = {
54757 - .ptr.native = (const char __user *const __user *)__argv,
54758 + .ptr.native = (const char __force_user * const __force_user *)__argv,
54759 };
54760
54761 set_fs(KERNEL_DS);
54762 @@ -584,7 +625,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54763 unsigned long new_end = old_end - shift;
54764 struct mmu_gather tlb;
54765
54766 - BUG_ON(new_start > new_end);
54767 + if (new_start >= new_end || new_start < mmap_min_addr)
54768 + return -ENOMEM;
54769
54770 /*
54771 * ensure there are no vmas between where we want to go
54772 @@ -593,6 +635,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54773 if (vma != find_vma(mm, new_start))
54774 return -EFAULT;
54775
54776 +#ifdef CONFIG_PAX_SEGMEXEC
54777 + BUG_ON(pax_find_mirror_vma(vma));
54778 +#endif
54779 +
54780 /*
54781 * cover the whole range: [new_start, old_end)
54782 */
54783 @@ -673,10 +719,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54784 stack_top = arch_align_stack(stack_top);
54785 stack_top = PAGE_ALIGN(stack_top);
54786
54787 - if (unlikely(stack_top < mmap_min_addr) ||
54788 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
54789 - return -ENOMEM;
54790 -
54791 stack_shift = vma->vm_end - stack_top;
54792
54793 bprm->p -= stack_shift;
54794 @@ -688,8 +730,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
54795 bprm->exec -= stack_shift;
54796
54797 down_write(&mm->mmap_sem);
54798 +
54799 + /* Move stack pages down in memory. */
54800 + if (stack_shift) {
54801 + ret = shift_arg_pages(vma, stack_shift);
54802 + if (ret)
54803 + goto out_unlock;
54804 + }
54805 +
54806 vm_flags = VM_STACK_FLAGS;
54807
54808 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54809 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54810 + vm_flags &= ~VM_EXEC;
54811 +
54812 +#ifdef CONFIG_PAX_MPROTECT
54813 + if (mm->pax_flags & MF_PAX_MPROTECT)
54814 + vm_flags &= ~VM_MAYEXEC;
54815 +#endif
54816 +
54817 + }
54818 +#endif
54819 +
54820 /*
54821 * Adjust stack execute permissions; explicitly enable for
54822 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
54823 @@ -708,13 +770,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54824 goto out_unlock;
54825 BUG_ON(prev != vma);
54826
54827 - /* Move stack pages down in memory. */
54828 - if (stack_shift) {
54829 - ret = shift_arg_pages(vma, stack_shift);
54830 - if (ret)
54831 - goto out_unlock;
54832 - }
54833 -
54834 /* mprotect_fixup is overkill to remove the temporary stack flags */
54835 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
54836
54837 @@ -738,6 +793,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
54838 #endif
54839 current->mm->start_stack = bprm->p;
54840 ret = expand_stack(vma, stack_base);
54841 +
54842 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
54843 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
54844 + unsigned long size;
54845 + vm_flags_t vm_flags;
54846 +
54847 + size = STACK_TOP - vma->vm_end;
54848 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
54849 +
54850 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
54851 +
54852 +#ifdef CONFIG_X86
54853 + if (!ret) {
54854 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
54855 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
54856 + }
54857 +#endif
54858 +
54859 + }
54860 +#endif
54861 +
54862 if (ret)
54863 ret = -EFAULT;
54864
54865 @@ -774,6 +850,8 @@ struct file *open_exec(const char *name)
54866
54867 fsnotify_open(file);
54868
54869 + trace_open_exec(name);
54870 +
54871 err = deny_write_access(file);
54872 if (err)
54873 goto exit;
54874 @@ -797,7 +875,7 @@ int kernel_read(struct file *file, loff_t offset,
54875 old_fs = get_fs();
54876 set_fs(get_ds());
54877 /* The cast to a user pointer is valid due to the set_fs() */
54878 - result = vfs_read(file, (void __user *)addr, count, &pos);
54879 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
54880 set_fs(old_fs);
54881 return result;
54882 }
54883 @@ -1253,7 +1331,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
54884 }
54885 rcu_read_unlock();
54886
54887 - if (p->fs->users > n_fs) {
54888 + if (atomic_read(&p->fs->users) > n_fs) {
54889 bprm->unsafe |= LSM_UNSAFE_SHARE;
54890 } else {
54891 res = -EAGAIN;
54892 @@ -1453,6 +1531,31 @@ int search_binary_handler(struct linux_binprm *bprm)
54893
54894 EXPORT_SYMBOL(search_binary_handler);
54895
54896 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54897 +static DEFINE_PER_CPU(u64, exec_counter);
54898 +static int __init init_exec_counters(void)
54899 +{
54900 + unsigned int cpu;
54901 +
54902 + for_each_possible_cpu(cpu) {
54903 + per_cpu(exec_counter, cpu) = (u64)cpu;
54904 + }
54905 +
54906 + return 0;
54907 +}
54908 +early_initcall(init_exec_counters);
54909 +static inline void increment_exec_counter(void)
54910 +{
54911 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
54912 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
54913 +}
54914 +#else
54915 +static inline void increment_exec_counter(void) {}
54916 +#endif
54917 +
54918 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
54919 + struct user_arg_ptr argv);
54920 +
54921 /*
54922 * sys_execve() executes a new program.
54923 */
54924 @@ -1460,12 +1563,19 @@ static int do_execve_common(const char *filename,
54925 struct user_arg_ptr argv,
54926 struct user_arg_ptr envp)
54927 {
54928 +#ifdef CONFIG_GRKERNSEC
54929 + struct file *old_exec_file;
54930 + struct acl_subject_label *old_acl;
54931 + struct rlimit old_rlim[RLIM_NLIMITS];
54932 +#endif
54933 struct linux_binprm *bprm;
54934 struct file *file;
54935 struct files_struct *displaced;
54936 bool clear_in_exec;
54937 int retval;
54938
54939 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
54940 +
54941 /*
54942 * We move the actual failure in case of RLIMIT_NPROC excess from
54943 * set*uid() to execve() because too many poorly written programs
54944 @@ -1506,12 +1616,22 @@ static int do_execve_common(const char *filename,
54945 if (IS_ERR(file))
54946 goto out_unmark;
54947
54948 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
54949 + retval = -EPERM;
54950 + goto out_file;
54951 + }
54952 +
54953 sched_exec();
54954
54955 bprm->file = file;
54956 bprm->filename = filename;
54957 bprm->interp = filename;
54958
54959 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
54960 + retval = -EACCES;
54961 + goto out_file;
54962 + }
54963 +
54964 retval = bprm_mm_init(bprm);
54965 if (retval)
54966 goto out_file;
54967 @@ -1528,24 +1648,70 @@ static int do_execve_common(const char *filename,
54968 if (retval < 0)
54969 goto out;
54970
54971 +#ifdef CONFIG_GRKERNSEC
54972 + old_acl = current->acl;
54973 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
54974 + old_exec_file = current->exec_file;
54975 + get_file(file);
54976 + current->exec_file = file;
54977 +#endif
54978 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54979 + /* limit suid stack to 8MB
54980 + * we saved the old limits above and will restore them if this exec fails
54981 + */
54982 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
54983 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
54984 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
54985 +#endif
54986 +
54987 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
54988 + retval = -EPERM;
54989 + goto out_fail;
54990 + }
54991 +
54992 + if (!gr_tpe_allow(file)) {
54993 + retval = -EACCES;
54994 + goto out_fail;
54995 + }
54996 +
54997 + if (gr_check_crash_exec(file)) {
54998 + retval = -EACCES;
54999 + goto out_fail;
55000 + }
55001 +
55002 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55003 + bprm->unsafe);
55004 + if (retval < 0)
55005 + goto out_fail;
55006 +
55007 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55008 if (retval < 0)
55009 - goto out;
55010 + goto out_fail;
55011
55012 bprm->exec = bprm->p;
55013 retval = copy_strings(bprm->envc, envp, bprm);
55014 if (retval < 0)
55015 - goto out;
55016 + goto out_fail;
55017
55018 retval = copy_strings(bprm->argc, argv, bprm);
55019 if (retval < 0)
55020 - goto out;
55021 + goto out_fail;
55022 +
55023 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55024 +
55025 + gr_handle_exec_args(bprm, argv);
55026
55027 retval = search_binary_handler(bprm);
55028 if (retval < 0)
55029 - goto out;
55030 + goto out_fail;
55031 +#ifdef CONFIG_GRKERNSEC
55032 + if (old_exec_file)
55033 + fput(old_exec_file);
55034 +#endif
55035
55036 /* execve succeeded */
55037 +
55038 + increment_exec_counter();
55039 current->fs->in_exec = 0;
55040 current->in_execve = 0;
55041 acct_update_integrals(current);
55042 @@ -1554,6 +1720,14 @@ static int do_execve_common(const char *filename,
55043 put_files_struct(displaced);
55044 return retval;
55045
55046 +out_fail:
55047 +#ifdef CONFIG_GRKERNSEC
55048 + current->acl = old_acl;
55049 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55050 + fput(current->exec_file);
55051 + current->exec_file = old_exec_file;
55052 +#endif
55053 +
55054 out:
55055 if (bprm->mm) {
55056 acct_arg_size(bprm, 0);
55057 @@ -1702,3 +1876,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55058 return error;
55059 }
55060 #endif
55061 +
55062 +int pax_check_flags(unsigned long *flags)
55063 +{
55064 + int retval = 0;
55065 +
55066 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55067 + if (*flags & MF_PAX_SEGMEXEC)
55068 + {
55069 + *flags &= ~MF_PAX_SEGMEXEC;
55070 + retval = -EINVAL;
55071 + }
55072 +#endif
55073 +
55074 + if ((*flags & MF_PAX_PAGEEXEC)
55075 +
55076 +#ifdef CONFIG_PAX_PAGEEXEC
55077 + && (*flags & MF_PAX_SEGMEXEC)
55078 +#endif
55079 +
55080 + )
55081 + {
55082 + *flags &= ~MF_PAX_PAGEEXEC;
55083 + retval = -EINVAL;
55084 + }
55085 +
55086 + if ((*flags & MF_PAX_MPROTECT)
55087 +
55088 +#ifdef CONFIG_PAX_MPROTECT
55089 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55090 +#endif
55091 +
55092 + )
55093 + {
55094 + *flags &= ~MF_PAX_MPROTECT;
55095 + retval = -EINVAL;
55096 + }
55097 +
55098 + if ((*flags & MF_PAX_EMUTRAMP)
55099 +
55100 +#ifdef CONFIG_PAX_EMUTRAMP
55101 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55102 +#endif
55103 +
55104 + )
55105 + {
55106 + *flags &= ~MF_PAX_EMUTRAMP;
55107 + retval = -EINVAL;
55108 + }
55109 +
55110 + return retval;
55111 +}
55112 +
55113 +EXPORT_SYMBOL(pax_check_flags);
55114 +
55115 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55116 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55117 +{
55118 + char *pathname = d_path(path, buf, buflen);
55119 +
55120 + if (IS_ERR(pathname))
55121 + goto toolong;
55122 +
55123 + pathname = mangle_path(buf, pathname, "\t\n\\");
55124 + if (!pathname)
55125 + goto toolong;
55126 +
55127 + *pathname = 0;
55128 + return buf;
55129 +
55130 +toolong:
55131 + return "<path too long>";
55132 +}
55133 +EXPORT_SYMBOL(pax_get_path);
55134 +
55135 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55136 +{
55137 + struct task_struct *tsk = current;
55138 + struct mm_struct *mm = current->mm;
55139 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55140 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55141 + char *path_exec = NULL;
55142 + char *path_fault = NULL;
55143 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55144 + siginfo_t info = { };
55145 +
55146 + if (buffer_exec && buffer_fault) {
55147 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55148 +
55149 + down_read(&mm->mmap_sem);
55150 + vma = mm->mmap;
55151 + while (vma && (!vma_exec || !vma_fault)) {
55152 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55153 + vma_exec = vma;
55154 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55155 + vma_fault = vma;
55156 + vma = vma->vm_next;
55157 + }
55158 + if (vma_exec)
55159 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55160 + if (vma_fault) {
55161 + start = vma_fault->vm_start;
55162 + end = vma_fault->vm_end;
55163 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55164 + if (vma_fault->vm_file)
55165 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55166 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55167 + path_fault = "<heap>";
55168 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55169 + path_fault = "<stack>";
55170 + else
55171 + path_fault = "<anonymous mapping>";
55172 + }
55173 + up_read(&mm->mmap_sem);
55174 + }
55175 + if (tsk->signal->curr_ip)
55176 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55177 + else
55178 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55179 + 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),
55180 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55181 + free_page((unsigned long)buffer_exec);
55182 + free_page((unsigned long)buffer_fault);
55183 + pax_report_insns(regs, pc, sp);
55184 + info.si_signo = SIGKILL;
55185 + info.si_errno = 0;
55186 + info.si_code = SI_KERNEL;
55187 + info.si_pid = 0;
55188 + info.si_uid = 0;
55189 + do_coredump(&info);
55190 +}
55191 +#endif
55192 +
55193 +#ifdef CONFIG_PAX_REFCOUNT
55194 +void pax_report_refcount_overflow(struct pt_regs *regs)
55195 +{
55196 + if (current->signal->curr_ip)
55197 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55198 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55199 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55200 + else
55201 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55202 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55203 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55204 + preempt_disable();
55205 + show_regs(regs);
55206 + preempt_enable();
55207 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55208 +}
55209 +#endif
55210 +
55211 +#ifdef CONFIG_PAX_USERCOPY
55212 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55213 +static noinline int check_stack_object(const void *obj, unsigned long len)
55214 +{
55215 + const void * const stack = task_stack_page(current);
55216 + const void * const stackend = stack + THREAD_SIZE;
55217 +
55218 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55219 + const void *frame = NULL;
55220 + const void *oldframe;
55221 +#endif
55222 +
55223 + if (obj + len < obj)
55224 + return -1;
55225 +
55226 + if (obj + len <= stack || stackend <= obj)
55227 + return 0;
55228 +
55229 + if (obj < stack || stackend < obj + len)
55230 + return -1;
55231 +
55232 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55233 + oldframe = __builtin_frame_address(1);
55234 + if (oldframe)
55235 + frame = __builtin_frame_address(2);
55236 + /*
55237 + low ----------------------------------------------> high
55238 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55239 + ^----------------^
55240 + allow copies only within here
55241 + */
55242 + while (stack <= frame && frame < stackend) {
55243 + /* if obj + len extends past the last frame, this
55244 + check won't pass and the next frame will be 0,
55245 + causing us to bail out and correctly report
55246 + the copy as invalid
55247 + */
55248 + if (obj + len <= frame)
55249 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55250 + oldframe = frame;
55251 + frame = *(const void * const *)frame;
55252 + }
55253 + return -1;
55254 +#else
55255 + return 1;
55256 +#endif
55257 +}
55258 +
55259 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55260 +{
55261 + if (current->signal->curr_ip)
55262 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55263 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55264 + else
55265 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55266 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55267 + dump_stack();
55268 + gr_handle_kernel_exploit();
55269 + do_group_exit(SIGKILL);
55270 +}
55271 +#endif
55272 +
55273 +#ifdef CONFIG_PAX_USERCOPY
55274 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55275 +{
55276 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55277 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55278 +#ifdef CONFIG_MODULES
55279 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55280 +#else
55281 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55282 +#endif
55283 +
55284 +#else
55285 + unsigned long textlow = (unsigned long)_stext;
55286 + unsigned long texthigh = (unsigned long)_etext;
55287 +#endif
55288 +
55289 + if (high <= textlow || low > texthigh)
55290 + return false;
55291 + else
55292 + return true;
55293 +}
55294 +#endif
55295 +
55296 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55297 +{
55298 +
55299 +#ifdef CONFIG_PAX_USERCOPY
55300 + const char *type;
55301 +
55302 + if (!n)
55303 + return;
55304 +
55305 + type = check_heap_object(ptr, n);
55306 + if (!type) {
55307 + int ret = check_stack_object(ptr, n);
55308 + if (ret == 1 || ret == 2)
55309 + return;
55310 + if (ret == 0) {
55311 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55312 + type = "<kernel text>";
55313 + else
55314 + return;
55315 + } else
55316 + type = "<process stack>";
55317 + }
55318 +
55319 + pax_report_usercopy(ptr, n, to_user, type);
55320 +#endif
55321 +
55322 +}
55323 +EXPORT_SYMBOL(__check_object_size);
55324 +
55325 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55326 +void pax_track_stack(void)
55327 +{
55328 + unsigned long sp = (unsigned long)&sp;
55329 + if (sp < current_thread_info()->lowest_stack &&
55330 + sp > (unsigned long)task_stack_page(current))
55331 + current_thread_info()->lowest_stack = sp;
55332 +}
55333 +EXPORT_SYMBOL(pax_track_stack);
55334 +#endif
55335 +
55336 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55337 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55338 +{
55339 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55340 + dump_stack();
55341 + do_group_exit(SIGKILL);
55342 +}
55343 +EXPORT_SYMBOL(report_size_overflow);
55344 +#endif
55345 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55346 index 9f9992b..8b59411 100644
55347 --- a/fs/ext2/balloc.c
55348 +++ b/fs/ext2/balloc.c
55349 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55350
55351 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55352 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55353 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55354 + if (free_blocks < root_blocks + 1 &&
55355 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55356 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55357 - !in_group_p (sbi->s_resgid))) {
55358 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55359 return 0;
55360 }
55361 return 1;
55362 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55363 index 22548f5..41521d8 100644
55364 --- a/fs/ext3/balloc.c
55365 +++ b/fs/ext3/balloc.c
55366 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55367
55368 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55369 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55370 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55371 + if (free_blocks < root_blocks + 1 &&
55372 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55373 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55374 - !in_group_p (sbi->s_resgid))) {
55375 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55376 return 0;
55377 }
55378 return 1;
55379 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55380 index ddd715e..c772f88 100644
55381 --- a/fs/ext4/balloc.c
55382 +++ b/fs/ext4/balloc.c
55383 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55384 /* Hm, nope. Are (enough) root reserved clusters available? */
55385 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55386 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55387 - capable(CAP_SYS_RESOURCE) ||
55388 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55389 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55390 + capable_nolog(CAP_SYS_RESOURCE)) {
55391
55392 if (free_clusters >= (nclusters + dirty_clusters +
55393 resv_clusters))
55394 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55395 index 0ab26fb..b6ecb39 100644
55396 --- a/fs/ext4/ext4.h
55397 +++ b/fs/ext4/ext4.h
55398 @@ -1247,19 +1247,19 @@ struct ext4_sb_info {
55399 unsigned long s_mb_last_start;
55400
55401 /* stats for buddy allocator */
55402 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55403 - atomic_t s_bal_success; /* we found long enough chunks */
55404 - atomic_t s_bal_allocated; /* in blocks */
55405 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55406 - atomic_t s_bal_goals; /* goal hits */
55407 - atomic_t s_bal_breaks; /* too long searches */
55408 - atomic_t s_bal_2orders; /* 2^order hits */
55409 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55410 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55411 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55412 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55413 + atomic_unchecked_t s_bal_goals; /* goal hits */
55414 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55415 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55416 spinlock_t s_bal_lock;
55417 unsigned long s_mb_buddies_generated;
55418 unsigned long long s_mb_generation_time;
55419 - atomic_t s_mb_lost_chunks;
55420 - atomic_t s_mb_preallocated;
55421 - atomic_t s_mb_discarded;
55422 + atomic_unchecked_t s_mb_lost_chunks;
55423 + atomic_unchecked_t s_mb_preallocated;
55424 + atomic_unchecked_t s_mb_discarded;
55425 atomic_t s_lock_busy;
55426
55427 /* locality groups */
55428 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55429 index 4bbbf13b..dcceaeb 100644
55430 --- a/fs/ext4/mballoc.c
55431 +++ b/fs/ext4/mballoc.c
55432 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55433 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55434
55435 if (EXT4_SB(sb)->s_mb_stats)
55436 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55437 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55438
55439 break;
55440 }
55441 @@ -2171,7 +2171,7 @@ repeat:
55442 ac->ac_status = AC_STATUS_CONTINUE;
55443 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55444 cr = 3;
55445 - atomic_inc(&sbi->s_mb_lost_chunks);
55446 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55447 goto repeat;
55448 }
55449 }
55450 @@ -2679,25 +2679,25 @@ int ext4_mb_release(struct super_block *sb)
55451 if (sbi->s_mb_stats) {
55452 ext4_msg(sb, KERN_INFO,
55453 "mballoc: %u blocks %u reqs (%u success)",
55454 - atomic_read(&sbi->s_bal_allocated),
55455 - atomic_read(&sbi->s_bal_reqs),
55456 - atomic_read(&sbi->s_bal_success));
55457 + atomic_read_unchecked(&sbi->s_bal_allocated),
55458 + atomic_read_unchecked(&sbi->s_bal_reqs),
55459 + atomic_read_unchecked(&sbi->s_bal_success));
55460 ext4_msg(sb, KERN_INFO,
55461 "mballoc: %u extents scanned, %u goal hits, "
55462 "%u 2^N hits, %u breaks, %u lost",
55463 - atomic_read(&sbi->s_bal_ex_scanned),
55464 - atomic_read(&sbi->s_bal_goals),
55465 - atomic_read(&sbi->s_bal_2orders),
55466 - atomic_read(&sbi->s_bal_breaks),
55467 - atomic_read(&sbi->s_mb_lost_chunks));
55468 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55469 + atomic_read_unchecked(&sbi->s_bal_goals),
55470 + atomic_read_unchecked(&sbi->s_bal_2orders),
55471 + atomic_read_unchecked(&sbi->s_bal_breaks),
55472 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55473 ext4_msg(sb, KERN_INFO,
55474 "mballoc: %lu generated and it took %Lu",
55475 sbi->s_mb_buddies_generated,
55476 sbi->s_mb_generation_time);
55477 ext4_msg(sb, KERN_INFO,
55478 "mballoc: %u preallocated, %u discarded",
55479 - atomic_read(&sbi->s_mb_preallocated),
55480 - atomic_read(&sbi->s_mb_discarded));
55481 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55482 + atomic_read_unchecked(&sbi->s_mb_discarded));
55483 }
55484
55485 free_percpu(sbi->s_locality_groups);
55486 @@ -3151,16 +3151,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55487 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55488
55489 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55490 - atomic_inc(&sbi->s_bal_reqs);
55491 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55492 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55493 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55494 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55495 - atomic_inc(&sbi->s_bal_success);
55496 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55497 + atomic_inc_unchecked(&sbi->s_bal_success);
55498 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55499 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55500 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55501 - atomic_inc(&sbi->s_bal_goals);
55502 + atomic_inc_unchecked(&sbi->s_bal_goals);
55503 if (ac->ac_found > sbi->s_mb_max_to_scan)
55504 - atomic_inc(&sbi->s_bal_breaks);
55505 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55506 }
55507
55508 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55509 @@ -3560,7 +3560,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55510 trace_ext4_mb_new_inode_pa(ac, pa);
55511
55512 ext4_mb_use_inode_pa(ac, pa);
55513 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
55514 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
55515
55516 ei = EXT4_I(ac->ac_inode);
55517 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55518 @@ -3620,7 +3620,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
55519 trace_ext4_mb_new_group_pa(ac, pa);
55520
55521 ext4_mb_use_group_pa(ac, pa);
55522 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55523 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55524
55525 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55526 lg = ac->ac_lg;
55527 @@ -3709,7 +3709,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
55528 * from the bitmap and continue.
55529 */
55530 }
55531 - atomic_add(free, &sbi->s_mb_discarded);
55532 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
55533
55534 return err;
55535 }
55536 @@ -3727,7 +3727,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
55537 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
55538 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
55539 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
55540 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55541 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55542 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
55543
55544 return 0;
55545 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
55546 index 214461e..3614c89 100644
55547 --- a/fs/ext4/mmp.c
55548 +++ b/fs/ext4/mmp.c
55549 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
55550 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
55551 const char *function, unsigned int line, const char *msg)
55552 {
55553 - __ext4_warning(sb, function, line, msg);
55554 + __ext4_warning(sb, function, line, "%s", msg);
55555 __ext4_warning(sb, function, line,
55556 "MMP failure info: last update time: %llu, last update "
55557 "node: %s, last update device: %s\n",
55558 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
55559 index b59373b..f41c2b5 100644
55560 --- a/fs/ext4/super.c
55561 +++ b/fs/ext4/super.c
55562 @@ -1254,7 +1254,7 @@ static ext4_fsblk_t get_sb_block(void **data)
55563 }
55564
55565 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
55566 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55567 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55568 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
55569
55570 #ifdef CONFIG_QUOTA
55571 @@ -2394,7 +2394,7 @@ struct ext4_attr {
55572 int offset;
55573 int deprecated_val;
55574 } u;
55575 -};
55576 +} __do_const;
55577
55578 static int parse_strtoull(const char *buf,
55579 unsigned long long max, unsigned long long *value)
55580 diff --git a/fs/fcntl.c b/fs/fcntl.c
55581 index 65343c3..9969dcf 100644
55582 --- a/fs/fcntl.c
55583 +++ b/fs/fcntl.c
55584 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
55585 if (err)
55586 return err;
55587
55588 + if (gr_handle_chroot_fowner(pid, type))
55589 + return -ENOENT;
55590 + if (gr_check_protected_task_fowner(pid, type))
55591 + return -EACCES;
55592 +
55593 f_modown(filp, pid, type, force);
55594 return 0;
55595 }
55596 diff --git a/fs/fhandle.c b/fs/fhandle.c
55597 index 999ff5c..41f4109 100644
55598 --- a/fs/fhandle.c
55599 +++ b/fs/fhandle.c
55600 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
55601 } else
55602 retval = 0;
55603 /* copy the mount id */
55604 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
55605 - sizeof(*mnt_id)) ||
55606 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
55607 copy_to_user(ufh, handle,
55608 sizeof(struct file_handle) + handle_bytes))
55609 retval = -EFAULT;
55610 diff --git a/fs/file.c b/fs/file.c
55611 index 4a78f98..9447397 100644
55612 --- a/fs/file.c
55613 +++ b/fs/file.c
55614 @@ -16,6 +16,7 @@
55615 #include <linux/slab.h>
55616 #include <linux/vmalloc.h>
55617 #include <linux/file.h>
55618 +#include <linux/security.h>
55619 #include <linux/fdtable.h>
55620 #include <linux/bitops.h>
55621 #include <linux/interrupt.h>
55622 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
55623 if (!file)
55624 return __close_fd(files, fd);
55625
55626 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
55627 if (fd >= rlimit(RLIMIT_NOFILE))
55628 return -EBADF;
55629
55630 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
55631 if (unlikely(oldfd == newfd))
55632 return -EINVAL;
55633
55634 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
55635 if (newfd >= rlimit(RLIMIT_NOFILE))
55636 return -EBADF;
55637
55638 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
55639 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
55640 {
55641 int err;
55642 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
55643 if (from >= rlimit(RLIMIT_NOFILE))
55644 return -EINVAL;
55645 err = alloc_fd(from, flags);
55646 diff --git a/fs/filesystems.c b/fs/filesystems.c
55647 index 92567d9..fcd8cbf 100644
55648 --- a/fs/filesystems.c
55649 +++ b/fs/filesystems.c
55650 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
55651 int len = dot ? dot - name : strlen(name);
55652
55653 fs = __get_fs_type(name, len);
55654 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
55655 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
55656 +#else
55657 if (!fs && (request_module("fs-%.*s", len, name) == 0))
55658 +#endif
55659 fs = __get_fs_type(name, len);
55660
55661 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
55662 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
55663 index d8ac61d..79a36f0 100644
55664 --- a/fs/fs_struct.c
55665 +++ b/fs/fs_struct.c
55666 @@ -4,6 +4,7 @@
55667 #include <linux/path.h>
55668 #include <linux/slab.h>
55669 #include <linux/fs_struct.h>
55670 +#include <linux/grsecurity.h>
55671 #include "internal.h"
55672
55673 /*
55674 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
55675 write_seqcount_begin(&fs->seq);
55676 old_root = fs->root;
55677 fs->root = *path;
55678 + gr_set_chroot_entries(current, path);
55679 write_seqcount_end(&fs->seq);
55680 spin_unlock(&fs->lock);
55681 if (old_root.dentry)
55682 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
55683 int hits = 0;
55684 spin_lock(&fs->lock);
55685 write_seqcount_begin(&fs->seq);
55686 + /* this root replacement is only done by pivot_root,
55687 + leave grsec's chroot tagging alone for this task
55688 + so that a pivoted root isn't treated as a chroot
55689 + */
55690 hits += replace_path(&fs->root, old_root, new_root);
55691 hits += replace_path(&fs->pwd, old_root, new_root);
55692 write_seqcount_end(&fs->seq);
55693 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
55694 task_lock(tsk);
55695 spin_lock(&fs->lock);
55696 tsk->fs = NULL;
55697 - kill = !--fs->users;
55698 + gr_clear_chroot_entries(tsk);
55699 + kill = !atomic_dec_return(&fs->users);
55700 spin_unlock(&fs->lock);
55701 task_unlock(tsk);
55702 if (kill)
55703 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55704 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
55705 /* We don't need to lock fs - think why ;-) */
55706 if (fs) {
55707 - fs->users = 1;
55708 + atomic_set(&fs->users, 1);
55709 fs->in_exec = 0;
55710 spin_lock_init(&fs->lock);
55711 seqcount_init(&fs->seq);
55712 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55713 spin_lock(&old->lock);
55714 fs->root = old->root;
55715 path_get(&fs->root);
55716 + /* instead of calling gr_set_chroot_entries here,
55717 + we call it from every caller of this function
55718 + */
55719 fs->pwd = old->pwd;
55720 path_get(&fs->pwd);
55721 spin_unlock(&old->lock);
55722 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
55723
55724 task_lock(current);
55725 spin_lock(&fs->lock);
55726 - kill = !--fs->users;
55727 + kill = !atomic_dec_return(&fs->users);
55728 current->fs = new_fs;
55729 + gr_set_chroot_entries(current, &new_fs->root);
55730 spin_unlock(&fs->lock);
55731 task_unlock(current);
55732
55733 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
55734
55735 int current_umask(void)
55736 {
55737 - return current->fs->umask;
55738 + return current->fs->umask | gr_acl_umask();
55739 }
55740 EXPORT_SYMBOL(current_umask);
55741
55742 /* to be mentioned only in INIT_TASK */
55743 struct fs_struct init_fs = {
55744 - .users = 1,
55745 + .users = ATOMIC_INIT(1),
55746 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
55747 .seq = SEQCNT_ZERO,
55748 .umask = 0022,
55749 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
55750 index 0e91a3c..6c6d2e0 100644
55751 --- a/fs/fscache/cookie.c
55752 +++ b/fs/fscache/cookie.c
55753 @@ -19,7 +19,7 @@
55754
55755 struct kmem_cache *fscache_cookie_jar;
55756
55757 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
55758 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
55759
55760 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
55761 static int fscache_alloc_object(struct fscache_cache *cache,
55762 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
55763 parent ? (char *) parent->def->name : "<no-parent>",
55764 def->name, netfs_data);
55765
55766 - fscache_stat(&fscache_n_acquires);
55767 + fscache_stat_unchecked(&fscache_n_acquires);
55768
55769 /* if there's no parent cookie, then we don't create one here either */
55770 if (!parent) {
55771 - fscache_stat(&fscache_n_acquires_null);
55772 + fscache_stat_unchecked(&fscache_n_acquires_null);
55773 _leave(" [no parent]");
55774 return NULL;
55775 }
55776 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
55777 /* allocate and initialise a cookie */
55778 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
55779 if (!cookie) {
55780 - fscache_stat(&fscache_n_acquires_oom);
55781 + fscache_stat_unchecked(&fscache_n_acquires_oom);
55782 _leave(" [ENOMEM]");
55783 return NULL;
55784 }
55785 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55786
55787 switch (cookie->def->type) {
55788 case FSCACHE_COOKIE_TYPE_INDEX:
55789 - fscache_stat(&fscache_n_cookie_index);
55790 + fscache_stat_unchecked(&fscache_n_cookie_index);
55791 break;
55792 case FSCACHE_COOKIE_TYPE_DATAFILE:
55793 - fscache_stat(&fscache_n_cookie_data);
55794 + fscache_stat_unchecked(&fscache_n_cookie_data);
55795 break;
55796 default:
55797 - fscache_stat(&fscache_n_cookie_special);
55798 + fscache_stat_unchecked(&fscache_n_cookie_special);
55799 break;
55800 }
55801
55802 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55803 if (fscache_acquire_non_index_cookie(cookie) < 0) {
55804 atomic_dec(&parent->n_children);
55805 __fscache_cookie_put(cookie);
55806 - fscache_stat(&fscache_n_acquires_nobufs);
55807 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
55808 _leave(" = NULL");
55809 return NULL;
55810 }
55811 }
55812
55813 - fscache_stat(&fscache_n_acquires_ok);
55814 + fscache_stat_unchecked(&fscache_n_acquires_ok);
55815 _leave(" = %p", cookie);
55816 return cookie;
55817 }
55818 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
55819 cache = fscache_select_cache_for_object(cookie->parent);
55820 if (!cache) {
55821 up_read(&fscache_addremove_sem);
55822 - fscache_stat(&fscache_n_acquires_no_cache);
55823 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
55824 _leave(" = -ENOMEDIUM [no cache]");
55825 return -ENOMEDIUM;
55826 }
55827 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
55828 object = cache->ops->alloc_object(cache, cookie);
55829 fscache_stat_d(&fscache_n_cop_alloc_object);
55830 if (IS_ERR(object)) {
55831 - fscache_stat(&fscache_n_object_no_alloc);
55832 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
55833 ret = PTR_ERR(object);
55834 goto error;
55835 }
55836
55837 - fscache_stat(&fscache_n_object_alloc);
55838 + fscache_stat_unchecked(&fscache_n_object_alloc);
55839
55840 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
55841 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
55842
55843 _debug("ALLOC OBJ%x: %s {%lx}",
55844 object->debug_id, cookie->def->name, object->events);
55845 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
55846
55847 _enter("{%s}", cookie->def->name);
55848
55849 - fscache_stat(&fscache_n_invalidates);
55850 + fscache_stat_unchecked(&fscache_n_invalidates);
55851
55852 /* Only permit invalidation of data files. Invalidating an index will
55853 * require the caller to release all its attachments to the tree rooted
55854 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
55855 {
55856 struct fscache_object *object;
55857
55858 - fscache_stat(&fscache_n_updates);
55859 + fscache_stat_unchecked(&fscache_n_updates);
55860
55861 if (!cookie) {
55862 - fscache_stat(&fscache_n_updates_null);
55863 + fscache_stat_unchecked(&fscache_n_updates_null);
55864 _leave(" [no cookie]");
55865 return;
55866 }
55867 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
55868 {
55869 struct fscache_object *object;
55870
55871 - fscache_stat(&fscache_n_relinquishes);
55872 + fscache_stat_unchecked(&fscache_n_relinquishes);
55873 if (retire)
55874 - fscache_stat(&fscache_n_relinquishes_retire);
55875 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
55876
55877 if (!cookie) {
55878 - fscache_stat(&fscache_n_relinquishes_null);
55879 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
55880 _leave(" [no cookie]");
55881 return;
55882 }
55883 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
55884 index 12d505b..86473a3 100644
55885 --- a/fs/fscache/internal.h
55886 +++ b/fs/fscache/internal.h
55887 @@ -147,101 +147,101 @@ extern void fscache_proc_cleanup(void);
55888 * stats.c
55889 */
55890 #ifdef CONFIG_FSCACHE_STATS
55891 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55892 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55893 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55894 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55895
55896 -extern atomic_t fscache_n_op_pend;
55897 -extern atomic_t fscache_n_op_run;
55898 -extern atomic_t fscache_n_op_enqueue;
55899 -extern atomic_t fscache_n_op_deferred_release;
55900 -extern atomic_t fscache_n_op_release;
55901 -extern atomic_t fscache_n_op_gc;
55902 -extern atomic_t fscache_n_op_cancelled;
55903 -extern atomic_t fscache_n_op_rejected;
55904 +extern atomic_unchecked_t fscache_n_op_pend;
55905 +extern atomic_unchecked_t fscache_n_op_run;
55906 +extern atomic_unchecked_t fscache_n_op_enqueue;
55907 +extern atomic_unchecked_t fscache_n_op_deferred_release;
55908 +extern atomic_unchecked_t fscache_n_op_release;
55909 +extern atomic_unchecked_t fscache_n_op_gc;
55910 +extern atomic_unchecked_t fscache_n_op_cancelled;
55911 +extern atomic_unchecked_t fscache_n_op_rejected;
55912
55913 -extern atomic_t fscache_n_attr_changed;
55914 -extern atomic_t fscache_n_attr_changed_ok;
55915 -extern atomic_t fscache_n_attr_changed_nobufs;
55916 -extern atomic_t fscache_n_attr_changed_nomem;
55917 -extern atomic_t fscache_n_attr_changed_calls;
55918 +extern atomic_unchecked_t fscache_n_attr_changed;
55919 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
55920 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
55921 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
55922 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
55923
55924 -extern atomic_t fscache_n_allocs;
55925 -extern atomic_t fscache_n_allocs_ok;
55926 -extern atomic_t fscache_n_allocs_wait;
55927 -extern atomic_t fscache_n_allocs_nobufs;
55928 -extern atomic_t fscache_n_allocs_intr;
55929 -extern atomic_t fscache_n_allocs_object_dead;
55930 -extern atomic_t fscache_n_alloc_ops;
55931 -extern atomic_t fscache_n_alloc_op_waits;
55932 +extern atomic_unchecked_t fscache_n_allocs;
55933 +extern atomic_unchecked_t fscache_n_allocs_ok;
55934 +extern atomic_unchecked_t fscache_n_allocs_wait;
55935 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
55936 +extern atomic_unchecked_t fscache_n_allocs_intr;
55937 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
55938 +extern atomic_unchecked_t fscache_n_alloc_ops;
55939 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
55940
55941 -extern atomic_t fscache_n_retrievals;
55942 -extern atomic_t fscache_n_retrievals_ok;
55943 -extern atomic_t fscache_n_retrievals_wait;
55944 -extern atomic_t fscache_n_retrievals_nodata;
55945 -extern atomic_t fscache_n_retrievals_nobufs;
55946 -extern atomic_t fscache_n_retrievals_intr;
55947 -extern atomic_t fscache_n_retrievals_nomem;
55948 -extern atomic_t fscache_n_retrievals_object_dead;
55949 -extern atomic_t fscache_n_retrieval_ops;
55950 -extern atomic_t fscache_n_retrieval_op_waits;
55951 +extern atomic_unchecked_t fscache_n_retrievals;
55952 +extern atomic_unchecked_t fscache_n_retrievals_ok;
55953 +extern atomic_unchecked_t fscache_n_retrievals_wait;
55954 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
55955 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
55956 +extern atomic_unchecked_t fscache_n_retrievals_intr;
55957 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
55958 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
55959 +extern atomic_unchecked_t fscache_n_retrieval_ops;
55960 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
55961
55962 -extern atomic_t fscache_n_stores;
55963 -extern atomic_t fscache_n_stores_ok;
55964 -extern atomic_t fscache_n_stores_again;
55965 -extern atomic_t fscache_n_stores_nobufs;
55966 -extern atomic_t fscache_n_stores_oom;
55967 -extern atomic_t fscache_n_store_ops;
55968 -extern atomic_t fscache_n_store_calls;
55969 -extern atomic_t fscache_n_store_pages;
55970 -extern atomic_t fscache_n_store_radix_deletes;
55971 -extern atomic_t fscache_n_store_pages_over_limit;
55972 +extern atomic_unchecked_t fscache_n_stores;
55973 +extern atomic_unchecked_t fscache_n_stores_ok;
55974 +extern atomic_unchecked_t fscache_n_stores_again;
55975 +extern atomic_unchecked_t fscache_n_stores_nobufs;
55976 +extern atomic_unchecked_t fscache_n_stores_oom;
55977 +extern atomic_unchecked_t fscache_n_store_ops;
55978 +extern atomic_unchecked_t fscache_n_store_calls;
55979 +extern atomic_unchecked_t fscache_n_store_pages;
55980 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
55981 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
55982
55983 -extern atomic_t fscache_n_store_vmscan_not_storing;
55984 -extern atomic_t fscache_n_store_vmscan_gone;
55985 -extern atomic_t fscache_n_store_vmscan_busy;
55986 -extern atomic_t fscache_n_store_vmscan_cancelled;
55987 -extern atomic_t fscache_n_store_vmscan_wait;
55988 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
55989 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
55990 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
55991 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
55992 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
55993
55994 -extern atomic_t fscache_n_marks;
55995 -extern atomic_t fscache_n_uncaches;
55996 +extern atomic_unchecked_t fscache_n_marks;
55997 +extern atomic_unchecked_t fscache_n_uncaches;
55998
55999 -extern atomic_t fscache_n_acquires;
56000 -extern atomic_t fscache_n_acquires_null;
56001 -extern atomic_t fscache_n_acquires_no_cache;
56002 -extern atomic_t fscache_n_acquires_ok;
56003 -extern atomic_t fscache_n_acquires_nobufs;
56004 -extern atomic_t fscache_n_acquires_oom;
56005 +extern atomic_unchecked_t fscache_n_acquires;
56006 +extern atomic_unchecked_t fscache_n_acquires_null;
56007 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56008 +extern atomic_unchecked_t fscache_n_acquires_ok;
56009 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56010 +extern atomic_unchecked_t fscache_n_acquires_oom;
56011
56012 -extern atomic_t fscache_n_invalidates;
56013 -extern atomic_t fscache_n_invalidates_run;
56014 +extern atomic_unchecked_t fscache_n_invalidates;
56015 +extern atomic_unchecked_t fscache_n_invalidates_run;
56016
56017 -extern atomic_t fscache_n_updates;
56018 -extern atomic_t fscache_n_updates_null;
56019 -extern atomic_t fscache_n_updates_run;
56020 +extern atomic_unchecked_t fscache_n_updates;
56021 +extern atomic_unchecked_t fscache_n_updates_null;
56022 +extern atomic_unchecked_t fscache_n_updates_run;
56023
56024 -extern atomic_t fscache_n_relinquishes;
56025 -extern atomic_t fscache_n_relinquishes_null;
56026 -extern atomic_t fscache_n_relinquishes_waitcrt;
56027 -extern atomic_t fscache_n_relinquishes_retire;
56028 +extern atomic_unchecked_t fscache_n_relinquishes;
56029 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56030 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56031 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56032
56033 -extern atomic_t fscache_n_cookie_index;
56034 -extern atomic_t fscache_n_cookie_data;
56035 -extern atomic_t fscache_n_cookie_special;
56036 +extern atomic_unchecked_t fscache_n_cookie_index;
56037 +extern atomic_unchecked_t fscache_n_cookie_data;
56038 +extern atomic_unchecked_t fscache_n_cookie_special;
56039
56040 -extern atomic_t fscache_n_object_alloc;
56041 -extern atomic_t fscache_n_object_no_alloc;
56042 -extern atomic_t fscache_n_object_lookups;
56043 -extern atomic_t fscache_n_object_lookups_negative;
56044 -extern atomic_t fscache_n_object_lookups_positive;
56045 -extern atomic_t fscache_n_object_lookups_timed_out;
56046 -extern atomic_t fscache_n_object_created;
56047 -extern atomic_t fscache_n_object_avail;
56048 -extern atomic_t fscache_n_object_dead;
56049 +extern atomic_unchecked_t fscache_n_object_alloc;
56050 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56051 +extern atomic_unchecked_t fscache_n_object_lookups;
56052 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56053 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56054 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56055 +extern atomic_unchecked_t fscache_n_object_created;
56056 +extern atomic_unchecked_t fscache_n_object_avail;
56057 +extern atomic_unchecked_t fscache_n_object_dead;
56058
56059 -extern atomic_t fscache_n_checkaux_none;
56060 -extern atomic_t fscache_n_checkaux_okay;
56061 -extern atomic_t fscache_n_checkaux_update;
56062 -extern atomic_t fscache_n_checkaux_obsolete;
56063 +extern atomic_unchecked_t fscache_n_checkaux_none;
56064 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56065 +extern atomic_unchecked_t fscache_n_checkaux_update;
56066 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56067
56068 extern atomic_t fscache_n_cop_alloc_object;
56069 extern atomic_t fscache_n_cop_lookup_object;
56070 @@ -266,6 +266,11 @@ static inline void fscache_stat(atomic_t *stat)
56071 atomic_inc(stat);
56072 }
56073
56074 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56075 +{
56076 + atomic_inc_unchecked(stat);
56077 +}
56078 +
56079 static inline void fscache_stat_d(atomic_t *stat)
56080 {
56081 atomic_dec(stat);
56082 @@ -278,6 +283,7 @@ extern const struct file_operations fscache_stats_fops;
56083
56084 #define __fscache_stat(stat) (NULL)
56085 #define fscache_stat(stat) do {} while (0)
56086 +#define fscache_stat_unchecked(stat) do {} while (0)
56087 #define fscache_stat_d(stat) do {} while (0)
56088 #endif
56089
56090 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56091 index 86d75a6..5f3d7a0 100644
56092 --- a/fs/fscache/object.c
56093 +++ b/fs/fscache/object.c
56094 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56095 _debug("LOOKUP \"%s\" in \"%s\"",
56096 cookie->def->name, object->cache->tag->name);
56097
56098 - fscache_stat(&fscache_n_object_lookups);
56099 + fscache_stat_unchecked(&fscache_n_object_lookups);
56100 fscache_stat(&fscache_n_cop_lookup_object);
56101 ret = object->cache->ops->lookup_object(object);
56102 fscache_stat_d(&fscache_n_cop_lookup_object);
56103 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56104 if (ret == -ETIMEDOUT) {
56105 /* probably stuck behind another object, so move this one to
56106 * the back of the queue */
56107 - fscache_stat(&fscache_n_object_lookups_timed_out);
56108 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56109 _leave(" [timeout]");
56110 return NO_TRANSIT;
56111 }
56112 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56113 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56114
56115 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56116 - fscache_stat(&fscache_n_object_lookups_negative);
56117 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56118
56119 /* Allow write requests to begin stacking up and read requests to begin
56120 * returning ENODATA.
56121 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56122 /* if we were still looking up, then we must have a positive lookup
56123 * result, in which case there may be data available */
56124 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56125 - fscache_stat(&fscache_n_object_lookups_positive);
56126 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56127
56128 /* We do (presumably) have data */
56129 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56130 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56131 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56132 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56133 } else {
56134 - fscache_stat(&fscache_n_object_created);
56135 + fscache_stat_unchecked(&fscache_n_object_created);
56136 }
56137
56138 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56139 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56140 fscache_stat_d(&fscache_n_cop_lookup_complete);
56141
56142 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56143 - fscache_stat(&fscache_n_object_avail);
56144 + fscache_stat_unchecked(&fscache_n_object_avail);
56145
56146 _leave("");
56147 return transit_to(JUMPSTART_DEPS);
56148 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56149
56150 /* this just shifts the object release to the work processor */
56151 fscache_put_object(object);
56152 - fscache_stat(&fscache_n_object_dead);
56153 + fscache_stat_unchecked(&fscache_n_object_dead);
56154
56155 _leave("");
56156 return transit_to(OBJECT_DEAD);
56157 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56158 enum fscache_checkaux result;
56159
56160 if (!object->cookie->def->check_aux) {
56161 - fscache_stat(&fscache_n_checkaux_none);
56162 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56163 return FSCACHE_CHECKAUX_OKAY;
56164 }
56165
56166 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56167 switch (result) {
56168 /* entry okay as is */
56169 case FSCACHE_CHECKAUX_OKAY:
56170 - fscache_stat(&fscache_n_checkaux_okay);
56171 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56172 break;
56173
56174 /* entry requires update */
56175 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56176 - fscache_stat(&fscache_n_checkaux_update);
56177 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56178 break;
56179
56180 /* entry requires deletion */
56181 case FSCACHE_CHECKAUX_OBSOLETE:
56182 - fscache_stat(&fscache_n_checkaux_obsolete);
56183 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56184 break;
56185
56186 default:
56187 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56188 {
56189 const struct fscache_state *s;
56190
56191 - fscache_stat(&fscache_n_invalidates_run);
56192 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56193 fscache_stat(&fscache_n_cop_invalidate_object);
56194 s = _fscache_invalidate_object(object, event);
56195 fscache_stat_d(&fscache_n_cop_invalidate_object);
56196 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56197 {
56198 _enter("{OBJ%x},%d", object->debug_id, event);
56199
56200 - fscache_stat(&fscache_n_updates_run);
56201 + fscache_stat_unchecked(&fscache_n_updates_run);
56202 fscache_stat(&fscache_n_cop_update_object);
56203 object->cache->ops->update_object(object);
56204 fscache_stat_d(&fscache_n_cop_update_object);
56205 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56206 index 318071a..379938b 100644
56207 --- a/fs/fscache/operation.c
56208 +++ b/fs/fscache/operation.c
56209 @@ -17,7 +17,7 @@
56210 #include <linux/slab.h>
56211 #include "internal.h"
56212
56213 -atomic_t fscache_op_debug_id;
56214 +atomic_unchecked_t fscache_op_debug_id;
56215 EXPORT_SYMBOL(fscache_op_debug_id);
56216
56217 /**
56218 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56219 ASSERTCMP(atomic_read(&op->usage), >, 0);
56220 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56221
56222 - fscache_stat(&fscache_n_op_enqueue);
56223 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56224 switch (op->flags & FSCACHE_OP_TYPE) {
56225 case FSCACHE_OP_ASYNC:
56226 _debug("queue async");
56227 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56228 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56229 if (op->processor)
56230 fscache_enqueue_operation(op);
56231 - fscache_stat(&fscache_n_op_run);
56232 + fscache_stat_unchecked(&fscache_n_op_run);
56233 }
56234
56235 /*
56236 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56237 if (object->n_in_progress > 0) {
56238 atomic_inc(&op->usage);
56239 list_add_tail(&op->pend_link, &object->pending_ops);
56240 - fscache_stat(&fscache_n_op_pend);
56241 + fscache_stat_unchecked(&fscache_n_op_pend);
56242 } else if (!list_empty(&object->pending_ops)) {
56243 atomic_inc(&op->usage);
56244 list_add_tail(&op->pend_link, &object->pending_ops);
56245 - fscache_stat(&fscache_n_op_pend);
56246 + fscache_stat_unchecked(&fscache_n_op_pend);
56247 fscache_start_operations(object);
56248 } else {
56249 ASSERTCMP(object->n_in_progress, ==, 0);
56250 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56251 object->n_exclusive++; /* reads and writes must wait */
56252 atomic_inc(&op->usage);
56253 list_add_tail(&op->pend_link, &object->pending_ops);
56254 - fscache_stat(&fscache_n_op_pend);
56255 + fscache_stat_unchecked(&fscache_n_op_pend);
56256 ret = 0;
56257 } else {
56258 /* If we're in any other state, there must have been an I/O
56259 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56260 if (object->n_exclusive > 0) {
56261 atomic_inc(&op->usage);
56262 list_add_tail(&op->pend_link, &object->pending_ops);
56263 - fscache_stat(&fscache_n_op_pend);
56264 + fscache_stat_unchecked(&fscache_n_op_pend);
56265 } else if (!list_empty(&object->pending_ops)) {
56266 atomic_inc(&op->usage);
56267 list_add_tail(&op->pend_link, &object->pending_ops);
56268 - fscache_stat(&fscache_n_op_pend);
56269 + fscache_stat_unchecked(&fscache_n_op_pend);
56270 fscache_start_operations(object);
56271 } else {
56272 ASSERTCMP(object->n_exclusive, ==, 0);
56273 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56274 object->n_ops++;
56275 atomic_inc(&op->usage);
56276 list_add_tail(&op->pend_link, &object->pending_ops);
56277 - fscache_stat(&fscache_n_op_pend);
56278 + fscache_stat_unchecked(&fscache_n_op_pend);
56279 ret = 0;
56280 } else if (fscache_object_is_dying(object)) {
56281 - fscache_stat(&fscache_n_op_rejected);
56282 + fscache_stat_unchecked(&fscache_n_op_rejected);
56283 op->state = FSCACHE_OP_ST_CANCELLED;
56284 ret = -ENOBUFS;
56285 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56286 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56287 ret = -EBUSY;
56288 if (op->state == FSCACHE_OP_ST_PENDING) {
56289 ASSERT(!list_empty(&op->pend_link));
56290 - fscache_stat(&fscache_n_op_cancelled);
56291 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56292 list_del_init(&op->pend_link);
56293 if (do_cancel)
56294 do_cancel(op);
56295 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56296 while (!list_empty(&object->pending_ops)) {
56297 op = list_entry(object->pending_ops.next,
56298 struct fscache_operation, pend_link);
56299 - fscache_stat(&fscache_n_op_cancelled);
56300 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56301 list_del_init(&op->pend_link);
56302
56303 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56304 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56305 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56306 op->state = FSCACHE_OP_ST_DEAD;
56307
56308 - fscache_stat(&fscache_n_op_release);
56309 + fscache_stat_unchecked(&fscache_n_op_release);
56310
56311 if (op->release) {
56312 op->release(op);
56313 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56314 * lock, and defer it otherwise */
56315 if (!spin_trylock(&object->lock)) {
56316 _debug("defer put");
56317 - fscache_stat(&fscache_n_op_deferred_release);
56318 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56319
56320 cache = object->cache;
56321 spin_lock(&cache->op_gc_list_lock);
56322 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56323
56324 _debug("GC DEFERRED REL OBJ%x OP%x",
56325 object->debug_id, op->debug_id);
56326 - fscache_stat(&fscache_n_op_gc);
56327 + fscache_stat_unchecked(&fscache_n_op_gc);
56328
56329 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56330 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56331 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56332 index d479ab3..727a7f2 100644
56333 --- a/fs/fscache/page.c
56334 +++ b/fs/fscache/page.c
56335 @@ -61,7 +61,7 @@ try_again:
56336 val = radix_tree_lookup(&cookie->stores, page->index);
56337 if (!val) {
56338 rcu_read_unlock();
56339 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56340 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56341 __fscache_uncache_page(cookie, page);
56342 return true;
56343 }
56344 @@ -91,11 +91,11 @@ try_again:
56345 spin_unlock(&cookie->stores_lock);
56346
56347 if (xpage) {
56348 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56349 - fscache_stat(&fscache_n_store_radix_deletes);
56350 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56351 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56352 ASSERTCMP(xpage, ==, page);
56353 } else {
56354 - fscache_stat(&fscache_n_store_vmscan_gone);
56355 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56356 }
56357
56358 wake_up_bit(&cookie->flags, 0);
56359 @@ -110,11 +110,11 @@ page_busy:
56360 * sleeping on memory allocation, so we may need to impose a timeout
56361 * too. */
56362 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56363 - fscache_stat(&fscache_n_store_vmscan_busy);
56364 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56365 return false;
56366 }
56367
56368 - fscache_stat(&fscache_n_store_vmscan_wait);
56369 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56370 __fscache_wait_on_page_write(cookie, page);
56371 gfp &= ~__GFP_WAIT;
56372 goto try_again;
56373 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56374 FSCACHE_COOKIE_STORING_TAG);
56375 if (!radix_tree_tag_get(&cookie->stores, page->index,
56376 FSCACHE_COOKIE_PENDING_TAG)) {
56377 - fscache_stat(&fscache_n_store_radix_deletes);
56378 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56379 xpage = radix_tree_delete(&cookie->stores, page->index);
56380 }
56381 spin_unlock(&cookie->stores_lock);
56382 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56383
56384 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56385
56386 - fscache_stat(&fscache_n_attr_changed_calls);
56387 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56388
56389 if (fscache_object_is_active(object) &&
56390 fscache_use_cookie(object)) {
56391 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56392
56393 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56394
56395 - fscache_stat(&fscache_n_attr_changed);
56396 + fscache_stat_unchecked(&fscache_n_attr_changed);
56397
56398 op = kzalloc(sizeof(*op), GFP_KERNEL);
56399 if (!op) {
56400 - fscache_stat(&fscache_n_attr_changed_nomem);
56401 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56402 _leave(" = -ENOMEM");
56403 return -ENOMEM;
56404 }
56405 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56406 if (fscache_submit_exclusive_op(object, op) < 0)
56407 goto nobufs;
56408 spin_unlock(&cookie->lock);
56409 - fscache_stat(&fscache_n_attr_changed_ok);
56410 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56411 fscache_put_operation(op);
56412 _leave(" = 0");
56413 return 0;
56414 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56415 nobufs:
56416 spin_unlock(&cookie->lock);
56417 kfree(op);
56418 - fscache_stat(&fscache_n_attr_changed_nobufs);
56419 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56420 _leave(" = %d", -ENOBUFS);
56421 return -ENOBUFS;
56422 }
56423 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56424 /* allocate a retrieval operation and attempt to submit it */
56425 op = kzalloc(sizeof(*op), GFP_NOIO);
56426 if (!op) {
56427 - fscache_stat(&fscache_n_retrievals_nomem);
56428 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56429 return NULL;
56430 }
56431
56432 @@ -289,13 +289,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56433 return 0;
56434 }
56435
56436 - fscache_stat(&fscache_n_retrievals_wait);
56437 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56438
56439 jif = jiffies;
56440 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56441 fscache_wait_bit_interruptible,
56442 TASK_INTERRUPTIBLE) != 0) {
56443 - fscache_stat(&fscache_n_retrievals_intr);
56444 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56445 _leave(" = -ERESTARTSYS");
56446 return -ERESTARTSYS;
56447 }
56448 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56449 */
56450 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56451 struct fscache_retrieval *op,
56452 - atomic_t *stat_op_waits,
56453 - atomic_t *stat_object_dead)
56454 + atomic_unchecked_t *stat_op_waits,
56455 + atomic_unchecked_t *stat_object_dead)
56456 {
56457 int ret;
56458
56459 @@ -333,7 +333,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56460 goto check_if_dead;
56461
56462 _debug(">>> WT");
56463 - fscache_stat(stat_op_waits);
56464 + fscache_stat_unchecked(stat_op_waits);
56465 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
56466 fscache_wait_bit_interruptible,
56467 TASK_INTERRUPTIBLE) != 0) {
56468 @@ -350,14 +350,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56469
56470 check_if_dead:
56471 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
56472 - fscache_stat(stat_object_dead);
56473 + fscache_stat_unchecked(stat_object_dead);
56474 _leave(" = -ENOBUFS [cancelled]");
56475 return -ENOBUFS;
56476 }
56477 if (unlikely(fscache_object_is_dead(object))) {
56478 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
56479 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
56480 - fscache_stat(stat_object_dead);
56481 + fscache_stat_unchecked(stat_object_dead);
56482 return -ENOBUFS;
56483 }
56484 return 0;
56485 @@ -384,7 +384,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56486
56487 _enter("%p,%p,,,", cookie, page);
56488
56489 - fscache_stat(&fscache_n_retrievals);
56490 + fscache_stat_unchecked(&fscache_n_retrievals);
56491
56492 if (hlist_empty(&cookie->backing_objects))
56493 goto nobufs;
56494 @@ -424,7 +424,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56495 goto nobufs_unlock_dec;
56496 spin_unlock(&cookie->lock);
56497
56498 - fscache_stat(&fscache_n_retrieval_ops);
56499 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56500
56501 /* pin the netfs read context in case we need to do the actual netfs
56502 * read because we've encountered a cache read failure */
56503 @@ -454,15 +454,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56504
56505 error:
56506 if (ret == -ENOMEM)
56507 - fscache_stat(&fscache_n_retrievals_nomem);
56508 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56509 else if (ret == -ERESTARTSYS)
56510 - fscache_stat(&fscache_n_retrievals_intr);
56511 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56512 else if (ret == -ENODATA)
56513 - fscache_stat(&fscache_n_retrievals_nodata);
56514 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56515 else if (ret < 0)
56516 - fscache_stat(&fscache_n_retrievals_nobufs);
56517 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56518 else
56519 - fscache_stat(&fscache_n_retrievals_ok);
56520 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56521
56522 fscache_put_retrieval(op);
56523 _leave(" = %d", ret);
56524 @@ -475,7 +475,7 @@ nobufs_unlock:
56525 atomic_dec(&cookie->n_active);
56526 kfree(op);
56527 nobufs:
56528 - fscache_stat(&fscache_n_retrievals_nobufs);
56529 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56530 _leave(" = -ENOBUFS");
56531 return -ENOBUFS;
56532 }
56533 @@ -513,7 +513,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56534
56535 _enter("%p,,%d,,,", cookie, *nr_pages);
56536
56537 - fscache_stat(&fscache_n_retrievals);
56538 + fscache_stat_unchecked(&fscache_n_retrievals);
56539
56540 if (hlist_empty(&cookie->backing_objects))
56541 goto nobufs;
56542 @@ -549,7 +549,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56543 goto nobufs_unlock_dec;
56544 spin_unlock(&cookie->lock);
56545
56546 - fscache_stat(&fscache_n_retrieval_ops);
56547 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56548
56549 /* pin the netfs read context in case we need to do the actual netfs
56550 * read because we've encountered a cache read failure */
56551 @@ -579,15 +579,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56552
56553 error:
56554 if (ret == -ENOMEM)
56555 - fscache_stat(&fscache_n_retrievals_nomem);
56556 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56557 else if (ret == -ERESTARTSYS)
56558 - fscache_stat(&fscache_n_retrievals_intr);
56559 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56560 else if (ret == -ENODATA)
56561 - fscache_stat(&fscache_n_retrievals_nodata);
56562 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56563 else if (ret < 0)
56564 - fscache_stat(&fscache_n_retrievals_nobufs);
56565 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56566 else
56567 - fscache_stat(&fscache_n_retrievals_ok);
56568 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56569
56570 fscache_put_retrieval(op);
56571 _leave(" = %d", ret);
56572 @@ -600,7 +600,7 @@ nobufs_unlock:
56573 atomic_dec(&cookie->n_active);
56574 kfree(op);
56575 nobufs:
56576 - fscache_stat(&fscache_n_retrievals_nobufs);
56577 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56578 _leave(" = -ENOBUFS");
56579 return -ENOBUFS;
56580 }
56581 @@ -624,7 +624,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56582
56583 _enter("%p,%p,,,", cookie, page);
56584
56585 - fscache_stat(&fscache_n_allocs);
56586 + fscache_stat_unchecked(&fscache_n_allocs);
56587
56588 if (hlist_empty(&cookie->backing_objects))
56589 goto nobufs;
56590 @@ -656,7 +656,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56591 goto nobufs_unlock;
56592 spin_unlock(&cookie->lock);
56593
56594 - fscache_stat(&fscache_n_alloc_ops);
56595 + fscache_stat_unchecked(&fscache_n_alloc_ops);
56596
56597 ret = fscache_wait_for_retrieval_activation(
56598 object, op,
56599 @@ -672,11 +672,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56600
56601 error:
56602 if (ret == -ERESTARTSYS)
56603 - fscache_stat(&fscache_n_allocs_intr);
56604 + fscache_stat_unchecked(&fscache_n_allocs_intr);
56605 else if (ret < 0)
56606 - fscache_stat(&fscache_n_allocs_nobufs);
56607 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56608 else
56609 - fscache_stat(&fscache_n_allocs_ok);
56610 + fscache_stat_unchecked(&fscache_n_allocs_ok);
56611
56612 fscache_put_retrieval(op);
56613 _leave(" = %d", ret);
56614 @@ -687,7 +687,7 @@ nobufs_unlock:
56615 atomic_dec(&cookie->n_active);
56616 kfree(op);
56617 nobufs:
56618 - fscache_stat(&fscache_n_allocs_nobufs);
56619 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56620 _leave(" = -ENOBUFS");
56621 return -ENOBUFS;
56622 }
56623 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56624
56625 spin_lock(&cookie->stores_lock);
56626
56627 - fscache_stat(&fscache_n_store_calls);
56628 + fscache_stat_unchecked(&fscache_n_store_calls);
56629
56630 /* find a page to store */
56631 page = NULL;
56632 @@ -758,7 +758,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56633 page = results[0];
56634 _debug("gang %d [%lx]", n, page->index);
56635 if (page->index > op->store_limit) {
56636 - fscache_stat(&fscache_n_store_pages_over_limit);
56637 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
56638 goto superseded;
56639 }
56640
56641 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56642 spin_unlock(&cookie->stores_lock);
56643 spin_unlock(&object->lock);
56644
56645 - fscache_stat(&fscache_n_store_pages);
56646 + fscache_stat_unchecked(&fscache_n_store_pages);
56647 fscache_stat(&fscache_n_cop_write_page);
56648 ret = object->cache->ops->write_page(op, page);
56649 fscache_stat_d(&fscache_n_cop_write_page);
56650 @@ -873,7 +873,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56651 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56652 ASSERT(PageFsCache(page));
56653
56654 - fscache_stat(&fscache_n_stores);
56655 + fscache_stat_unchecked(&fscache_n_stores);
56656
56657 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
56658 _leave(" = -ENOBUFS [invalidating]");
56659 @@ -931,7 +931,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56660 spin_unlock(&cookie->stores_lock);
56661 spin_unlock(&object->lock);
56662
56663 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
56664 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56665 op->store_limit = object->store_limit;
56666
56667 atomic_inc(&cookie->n_active);
56668 @@ -940,8 +940,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56669
56670 spin_unlock(&cookie->lock);
56671 radix_tree_preload_end();
56672 - fscache_stat(&fscache_n_store_ops);
56673 - fscache_stat(&fscache_n_stores_ok);
56674 + fscache_stat_unchecked(&fscache_n_store_ops);
56675 + fscache_stat_unchecked(&fscache_n_stores_ok);
56676
56677 /* the work queue now carries its own ref on the object */
56678 fscache_put_operation(&op->op);
56679 @@ -949,14 +949,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56680 return 0;
56681
56682 already_queued:
56683 - fscache_stat(&fscache_n_stores_again);
56684 + fscache_stat_unchecked(&fscache_n_stores_again);
56685 already_pending:
56686 spin_unlock(&cookie->stores_lock);
56687 spin_unlock(&object->lock);
56688 spin_unlock(&cookie->lock);
56689 radix_tree_preload_end();
56690 kfree(op);
56691 - fscache_stat(&fscache_n_stores_ok);
56692 + fscache_stat_unchecked(&fscache_n_stores_ok);
56693 _leave(" = 0");
56694 return 0;
56695
56696 @@ -976,14 +976,14 @@ nobufs:
56697 spin_unlock(&cookie->lock);
56698 radix_tree_preload_end();
56699 kfree(op);
56700 - fscache_stat(&fscache_n_stores_nobufs);
56701 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
56702 _leave(" = -ENOBUFS");
56703 return -ENOBUFS;
56704
56705 nomem_free:
56706 kfree(op);
56707 nomem:
56708 - fscache_stat(&fscache_n_stores_oom);
56709 + fscache_stat_unchecked(&fscache_n_stores_oom);
56710 _leave(" = -ENOMEM");
56711 return -ENOMEM;
56712 }
56713 @@ -1001,7 +1001,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
56714 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56715 ASSERTCMP(page, !=, NULL);
56716
56717 - fscache_stat(&fscache_n_uncaches);
56718 + fscache_stat_unchecked(&fscache_n_uncaches);
56719
56720 /* cache withdrawal may beat us to it */
56721 if (!PageFsCache(page))
56722 @@ -1052,7 +1052,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
56723 struct fscache_cookie *cookie = op->op.object->cookie;
56724
56725 #ifdef CONFIG_FSCACHE_STATS
56726 - atomic_inc(&fscache_n_marks);
56727 + atomic_inc_unchecked(&fscache_n_marks);
56728 #endif
56729
56730 _debug("- mark %p{%lx}", page, page->index);
56731 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
56732 index 40d13c7..ddf52b9 100644
56733 --- a/fs/fscache/stats.c
56734 +++ b/fs/fscache/stats.c
56735 @@ -18,99 +18,99 @@
56736 /*
56737 * operation counters
56738 */
56739 -atomic_t fscache_n_op_pend;
56740 -atomic_t fscache_n_op_run;
56741 -atomic_t fscache_n_op_enqueue;
56742 -atomic_t fscache_n_op_requeue;
56743 -atomic_t fscache_n_op_deferred_release;
56744 -atomic_t fscache_n_op_release;
56745 -atomic_t fscache_n_op_gc;
56746 -atomic_t fscache_n_op_cancelled;
56747 -atomic_t fscache_n_op_rejected;
56748 +atomic_unchecked_t fscache_n_op_pend;
56749 +atomic_unchecked_t fscache_n_op_run;
56750 +atomic_unchecked_t fscache_n_op_enqueue;
56751 +atomic_unchecked_t fscache_n_op_requeue;
56752 +atomic_unchecked_t fscache_n_op_deferred_release;
56753 +atomic_unchecked_t fscache_n_op_release;
56754 +atomic_unchecked_t fscache_n_op_gc;
56755 +atomic_unchecked_t fscache_n_op_cancelled;
56756 +atomic_unchecked_t fscache_n_op_rejected;
56757
56758 -atomic_t fscache_n_attr_changed;
56759 -atomic_t fscache_n_attr_changed_ok;
56760 -atomic_t fscache_n_attr_changed_nobufs;
56761 -atomic_t fscache_n_attr_changed_nomem;
56762 -atomic_t fscache_n_attr_changed_calls;
56763 +atomic_unchecked_t fscache_n_attr_changed;
56764 +atomic_unchecked_t fscache_n_attr_changed_ok;
56765 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
56766 +atomic_unchecked_t fscache_n_attr_changed_nomem;
56767 +atomic_unchecked_t fscache_n_attr_changed_calls;
56768
56769 -atomic_t fscache_n_allocs;
56770 -atomic_t fscache_n_allocs_ok;
56771 -atomic_t fscache_n_allocs_wait;
56772 -atomic_t fscache_n_allocs_nobufs;
56773 -atomic_t fscache_n_allocs_intr;
56774 -atomic_t fscache_n_allocs_object_dead;
56775 -atomic_t fscache_n_alloc_ops;
56776 -atomic_t fscache_n_alloc_op_waits;
56777 +atomic_unchecked_t fscache_n_allocs;
56778 +atomic_unchecked_t fscache_n_allocs_ok;
56779 +atomic_unchecked_t fscache_n_allocs_wait;
56780 +atomic_unchecked_t fscache_n_allocs_nobufs;
56781 +atomic_unchecked_t fscache_n_allocs_intr;
56782 +atomic_unchecked_t fscache_n_allocs_object_dead;
56783 +atomic_unchecked_t fscache_n_alloc_ops;
56784 +atomic_unchecked_t fscache_n_alloc_op_waits;
56785
56786 -atomic_t fscache_n_retrievals;
56787 -atomic_t fscache_n_retrievals_ok;
56788 -atomic_t fscache_n_retrievals_wait;
56789 -atomic_t fscache_n_retrievals_nodata;
56790 -atomic_t fscache_n_retrievals_nobufs;
56791 -atomic_t fscache_n_retrievals_intr;
56792 -atomic_t fscache_n_retrievals_nomem;
56793 -atomic_t fscache_n_retrievals_object_dead;
56794 -atomic_t fscache_n_retrieval_ops;
56795 -atomic_t fscache_n_retrieval_op_waits;
56796 +atomic_unchecked_t fscache_n_retrievals;
56797 +atomic_unchecked_t fscache_n_retrievals_ok;
56798 +atomic_unchecked_t fscache_n_retrievals_wait;
56799 +atomic_unchecked_t fscache_n_retrievals_nodata;
56800 +atomic_unchecked_t fscache_n_retrievals_nobufs;
56801 +atomic_unchecked_t fscache_n_retrievals_intr;
56802 +atomic_unchecked_t fscache_n_retrievals_nomem;
56803 +atomic_unchecked_t fscache_n_retrievals_object_dead;
56804 +atomic_unchecked_t fscache_n_retrieval_ops;
56805 +atomic_unchecked_t fscache_n_retrieval_op_waits;
56806
56807 -atomic_t fscache_n_stores;
56808 -atomic_t fscache_n_stores_ok;
56809 -atomic_t fscache_n_stores_again;
56810 -atomic_t fscache_n_stores_nobufs;
56811 -atomic_t fscache_n_stores_oom;
56812 -atomic_t fscache_n_store_ops;
56813 -atomic_t fscache_n_store_calls;
56814 -atomic_t fscache_n_store_pages;
56815 -atomic_t fscache_n_store_radix_deletes;
56816 -atomic_t fscache_n_store_pages_over_limit;
56817 +atomic_unchecked_t fscache_n_stores;
56818 +atomic_unchecked_t fscache_n_stores_ok;
56819 +atomic_unchecked_t fscache_n_stores_again;
56820 +atomic_unchecked_t fscache_n_stores_nobufs;
56821 +atomic_unchecked_t fscache_n_stores_oom;
56822 +atomic_unchecked_t fscache_n_store_ops;
56823 +atomic_unchecked_t fscache_n_store_calls;
56824 +atomic_unchecked_t fscache_n_store_pages;
56825 +atomic_unchecked_t fscache_n_store_radix_deletes;
56826 +atomic_unchecked_t fscache_n_store_pages_over_limit;
56827
56828 -atomic_t fscache_n_store_vmscan_not_storing;
56829 -atomic_t fscache_n_store_vmscan_gone;
56830 -atomic_t fscache_n_store_vmscan_busy;
56831 -atomic_t fscache_n_store_vmscan_cancelled;
56832 -atomic_t fscache_n_store_vmscan_wait;
56833 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56834 +atomic_unchecked_t fscache_n_store_vmscan_gone;
56835 +atomic_unchecked_t fscache_n_store_vmscan_busy;
56836 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56837 +atomic_unchecked_t fscache_n_store_vmscan_wait;
56838
56839 -atomic_t fscache_n_marks;
56840 -atomic_t fscache_n_uncaches;
56841 +atomic_unchecked_t fscache_n_marks;
56842 +atomic_unchecked_t fscache_n_uncaches;
56843
56844 -atomic_t fscache_n_acquires;
56845 -atomic_t fscache_n_acquires_null;
56846 -atomic_t fscache_n_acquires_no_cache;
56847 -atomic_t fscache_n_acquires_ok;
56848 -atomic_t fscache_n_acquires_nobufs;
56849 -atomic_t fscache_n_acquires_oom;
56850 +atomic_unchecked_t fscache_n_acquires;
56851 +atomic_unchecked_t fscache_n_acquires_null;
56852 +atomic_unchecked_t fscache_n_acquires_no_cache;
56853 +atomic_unchecked_t fscache_n_acquires_ok;
56854 +atomic_unchecked_t fscache_n_acquires_nobufs;
56855 +atomic_unchecked_t fscache_n_acquires_oom;
56856
56857 -atomic_t fscache_n_invalidates;
56858 -atomic_t fscache_n_invalidates_run;
56859 +atomic_unchecked_t fscache_n_invalidates;
56860 +atomic_unchecked_t fscache_n_invalidates_run;
56861
56862 -atomic_t fscache_n_updates;
56863 -atomic_t fscache_n_updates_null;
56864 -atomic_t fscache_n_updates_run;
56865 +atomic_unchecked_t fscache_n_updates;
56866 +atomic_unchecked_t fscache_n_updates_null;
56867 +atomic_unchecked_t fscache_n_updates_run;
56868
56869 -atomic_t fscache_n_relinquishes;
56870 -atomic_t fscache_n_relinquishes_null;
56871 -atomic_t fscache_n_relinquishes_waitcrt;
56872 -atomic_t fscache_n_relinquishes_retire;
56873 +atomic_unchecked_t fscache_n_relinquishes;
56874 +atomic_unchecked_t fscache_n_relinquishes_null;
56875 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56876 +atomic_unchecked_t fscache_n_relinquishes_retire;
56877
56878 -atomic_t fscache_n_cookie_index;
56879 -atomic_t fscache_n_cookie_data;
56880 -atomic_t fscache_n_cookie_special;
56881 +atomic_unchecked_t fscache_n_cookie_index;
56882 +atomic_unchecked_t fscache_n_cookie_data;
56883 +atomic_unchecked_t fscache_n_cookie_special;
56884
56885 -atomic_t fscache_n_object_alloc;
56886 -atomic_t fscache_n_object_no_alloc;
56887 -atomic_t fscache_n_object_lookups;
56888 -atomic_t fscache_n_object_lookups_negative;
56889 -atomic_t fscache_n_object_lookups_positive;
56890 -atomic_t fscache_n_object_lookups_timed_out;
56891 -atomic_t fscache_n_object_created;
56892 -atomic_t fscache_n_object_avail;
56893 -atomic_t fscache_n_object_dead;
56894 +atomic_unchecked_t fscache_n_object_alloc;
56895 +atomic_unchecked_t fscache_n_object_no_alloc;
56896 +atomic_unchecked_t fscache_n_object_lookups;
56897 +atomic_unchecked_t fscache_n_object_lookups_negative;
56898 +atomic_unchecked_t fscache_n_object_lookups_positive;
56899 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
56900 +atomic_unchecked_t fscache_n_object_created;
56901 +atomic_unchecked_t fscache_n_object_avail;
56902 +atomic_unchecked_t fscache_n_object_dead;
56903
56904 -atomic_t fscache_n_checkaux_none;
56905 -atomic_t fscache_n_checkaux_okay;
56906 -atomic_t fscache_n_checkaux_update;
56907 -atomic_t fscache_n_checkaux_obsolete;
56908 +atomic_unchecked_t fscache_n_checkaux_none;
56909 +atomic_unchecked_t fscache_n_checkaux_okay;
56910 +atomic_unchecked_t fscache_n_checkaux_update;
56911 +atomic_unchecked_t fscache_n_checkaux_obsolete;
56912
56913 atomic_t fscache_n_cop_alloc_object;
56914 atomic_t fscache_n_cop_lookup_object;
56915 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
56916 seq_puts(m, "FS-Cache statistics\n");
56917
56918 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
56919 - atomic_read(&fscache_n_cookie_index),
56920 - atomic_read(&fscache_n_cookie_data),
56921 - atomic_read(&fscache_n_cookie_special));
56922 + atomic_read_unchecked(&fscache_n_cookie_index),
56923 + atomic_read_unchecked(&fscache_n_cookie_data),
56924 + atomic_read_unchecked(&fscache_n_cookie_special));
56925
56926 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
56927 - atomic_read(&fscache_n_object_alloc),
56928 - atomic_read(&fscache_n_object_no_alloc),
56929 - atomic_read(&fscache_n_object_avail),
56930 - atomic_read(&fscache_n_object_dead));
56931 + atomic_read_unchecked(&fscache_n_object_alloc),
56932 + atomic_read_unchecked(&fscache_n_object_no_alloc),
56933 + atomic_read_unchecked(&fscache_n_object_avail),
56934 + atomic_read_unchecked(&fscache_n_object_dead));
56935 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
56936 - atomic_read(&fscache_n_checkaux_none),
56937 - atomic_read(&fscache_n_checkaux_okay),
56938 - atomic_read(&fscache_n_checkaux_update),
56939 - atomic_read(&fscache_n_checkaux_obsolete));
56940 + atomic_read_unchecked(&fscache_n_checkaux_none),
56941 + atomic_read_unchecked(&fscache_n_checkaux_okay),
56942 + atomic_read_unchecked(&fscache_n_checkaux_update),
56943 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
56944
56945 seq_printf(m, "Pages : mrk=%u unc=%u\n",
56946 - atomic_read(&fscache_n_marks),
56947 - atomic_read(&fscache_n_uncaches));
56948 + atomic_read_unchecked(&fscache_n_marks),
56949 + atomic_read_unchecked(&fscache_n_uncaches));
56950
56951 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
56952 " oom=%u\n",
56953 - atomic_read(&fscache_n_acquires),
56954 - atomic_read(&fscache_n_acquires_null),
56955 - atomic_read(&fscache_n_acquires_no_cache),
56956 - atomic_read(&fscache_n_acquires_ok),
56957 - atomic_read(&fscache_n_acquires_nobufs),
56958 - atomic_read(&fscache_n_acquires_oom));
56959 + atomic_read_unchecked(&fscache_n_acquires),
56960 + atomic_read_unchecked(&fscache_n_acquires_null),
56961 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
56962 + atomic_read_unchecked(&fscache_n_acquires_ok),
56963 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
56964 + atomic_read_unchecked(&fscache_n_acquires_oom));
56965
56966 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
56967 - atomic_read(&fscache_n_object_lookups),
56968 - atomic_read(&fscache_n_object_lookups_negative),
56969 - atomic_read(&fscache_n_object_lookups_positive),
56970 - atomic_read(&fscache_n_object_created),
56971 - atomic_read(&fscache_n_object_lookups_timed_out));
56972 + atomic_read_unchecked(&fscache_n_object_lookups),
56973 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
56974 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
56975 + atomic_read_unchecked(&fscache_n_object_created),
56976 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
56977
56978 seq_printf(m, "Invals : n=%u run=%u\n",
56979 - atomic_read(&fscache_n_invalidates),
56980 - atomic_read(&fscache_n_invalidates_run));
56981 + atomic_read_unchecked(&fscache_n_invalidates),
56982 + atomic_read_unchecked(&fscache_n_invalidates_run));
56983
56984 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
56985 - atomic_read(&fscache_n_updates),
56986 - atomic_read(&fscache_n_updates_null),
56987 - atomic_read(&fscache_n_updates_run));
56988 + atomic_read_unchecked(&fscache_n_updates),
56989 + atomic_read_unchecked(&fscache_n_updates_null),
56990 + atomic_read_unchecked(&fscache_n_updates_run));
56991
56992 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
56993 - atomic_read(&fscache_n_relinquishes),
56994 - atomic_read(&fscache_n_relinquishes_null),
56995 - atomic_read(&fscache_n_relinquishes_waitcrt),
56996 - atomic_read(&fscache_n_relinquishes_retire));
56997 + atomic_read_unchecked(&fscache_n_relinquishes),
56998 + atomic_read_unchecked(&fscache_n_relinquishes_null),
56999 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57000 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57001
57002 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57003 - atomic_read(&fscache_n_attr_changed),
57004 - atomic_read(&fscache_n_attr_changed_ok),
57005 - atomic_read(&fscache_n_attr_changed_nobufs),
57006 - atomic_read(&fscache_n_attr_changed_nomem),
57007 - atomic_read(&fscache_n_attr_changed_calls));
57008 + atomic_read_unchecked(&fscache_n_attr_changed),
57009 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57010 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57011 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57012 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57013
57014 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57015 - atomic_read(&fscache_n_allocs),
57016 - atomic_read(&fscache_n_allocs_ok),
57017 - atomic_read(&fscache_n_allocs_wait),
57018 - atomic_read(&fscache_n_allocs_nobufs),
57019 - atomic_read(&fscache_n_allocs_intr));
57020 + atomic_read_unchecked(&fscache_n_allocs),
57021 + atomic_read_unchecked(&fscache_n_allocs_ok),
57022 + atomic_read_unchecked(&fscache_n_allocs_wait),
57023 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57024 + atomic_read_unchecked(&fscache_n_allocs_intr));
57025 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57026 - atomic_read(&fscache_n_alloc_ops),
57027 - atomic_read(&fscache_n_alloc_op_waits),
57028 - atomic_read(&fscache_n_allocs_object_dead));
57029 + atomic_read_unchecked(&fscache_n_alloc_ops),
57030 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57031 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57032
57033 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57034 " int=%u oom=%u\n",
57035 - atomic_read(&fscache_n_retrievals),
57036 - atomic_read(&fscache_n_retrievals_ok),
57037 - atomic_read(&fscache_n_retrievals_wait),
57038 - atomic_read(&fscache_n_retrievals_nodata),
57039 - atomic_read(&fscache_n_retrievals_nobufs),
57040 - atomic_read(&fscache_n_retrievals_intr),
57041 - atomic_read(&fscache_n_retrievals_nomem));
57042 + atomic_read_unchecked(&fscache_n_retrievals),
57043 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57044 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57045 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57046 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57047 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57048 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57049 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57050 - atomic_read(&fscache_n_retrieval_ops),
57051 - atomic_read(&fscache_n_retrieval_op_waits),
57052 - atomic_read(&fscache_n_retrievals_object_dead));
57053 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57054 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57055 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57056
57057 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57058 - atomic_read(&fscache_n_stores),
57059 - atomic_read(&fscache_n_stores_ok),
57060 - atomic_read(&fscache_n_stores_again),
57061 - atomic_read(&fscache_n_stores_nobufs),
57062 - atomic_read(&fscache_n_stores_oom));
57063 + atomic_read_unchecked(&fscache_n_stores),
57064 + atomic_read_unchecked(&fscache_n_stores_ok),
57065 + atomic_read_unchecked(&fscache_n_stores_again),
57066 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57067 + atomic_read_unchecked(&fscache_n_stores_oom));
57068 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57069 - atomic_read(&fscache_n_store_ops),
57070 - atomic_read(&fscache_n_store_calls),
57071 - atomic_read(&fscache_n_store_pages),
57072 - atomic_read(&fscache_n_store_radix_deletes),
57073 - atomic_read(&fscache_n_store_pages_over_limit));
57074 + atomic_read_unchecked(&fscache_n_store_ops),
57075 + atomic_read_unchecked(&fscache_n_store_calls),
57076 + atomic_read_unchecked(&fscache_n_store_pages),
57077 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57078 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57079
57080 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57081 - atomic_read(&fscache_n_store_vmscan_not_storing),
57082 - atomic_read(&fscache_n_store_vmscan_gone),
57083 - atomic_read(&fscache_n_store_vmscan_busy),
57084 - atomic_read(&fscache_n_store_vmscan_cancelled),
57085 - atomic_read(&fscache_n_store_vmscan_wait));
57086 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57087 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57088 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57089 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57090 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57091
57092 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57093 - atomic_read(&fscache_n_op_pend),
57094 - atomic_read(&fscache_n_op_run),
57095 - atomic_read(&fscache_n_op_enqueue),
57096 - atomic_read(&fscache_n_op_cancelled),
57097 - atomic_read(&fscache_n_op_rejected));
57098 + atomic_read_unchecked(&fscache_n_op_pend),
57099 + atomic_read_unchecked(&fscache_n_op_run),
57100 + atomic_read_unchecked(&fscache_n_op_enqueue),
57101 + atomic_read_unchecked(&fscache_n_op_cancelled),
57102 + atomic_read_unchecked(&fscache_n_op_rejected));
57103 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57104 - atomic_read(&fscache_n_op_deferred_release),
57105 - atomic_read(&fscache_n_op_release),
57106 - atomic_read(&fscache_n_op_gc));
57107 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57108 + atomic_read_unchecked(&fscache_n_op_release),
57109 + atomic_read_unchecked(&fscache_n_op_gc));
57110
57111 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57112 atomic_read(&fscache_n_cop_alloc_object),
57113 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57114 index aef34b1..59bfd7b 100644
57115 --- a/fs/fuse/cuse.c
57116 +++ b/fs/fuse/cuse.c
57117 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
57118 INIT_LIST_HEAD(&cuse_conntbl[i]);
57119
57120 /* inherit and extend fuse_dev_operations */
57121 - cuse_channel_fops = fuse_dev_operations;
57122 - cuse_channel_fops.owner = THIS_MODULE;
57123 - cuse_channel_fops.open = cuse_channel_open;
57124 - cuse_channel_fops.release = cuse_channel_release;
57125 + pax_open_kernel();
57126 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57127 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57128 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57129 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57130 + pax_close_kernel();
57131
57132 cuse_class = class_create(THIS_MODULE, "cuse");
57133 if (IS_ERR(cuse_class))
57134 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57135 index 1d55f94..088da65 100644
57136 --- a/fs/fuse/dev.c
57137 +++ b/fs/fuse/dev.c
57138 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57139 ret = 0;
57140 pipe_lock(pipe);
57141
57142 - if (!pipe->readers) {
57143 + if (!atomic_read(&pipe->readers)) {
57144 send_sig(SIGPIPE, current, 0);
57145 if (!ret)
57146 ret = -EPIPE;
57147 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57148 page_nr++;
57149 ret += buf->len;
57150
57151 - if (pipe->files)
57152 + if (atomic_read(&pipe->files))
57153 do_wakeup = 1;
57154 }
57155
57156 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57157 index 8fec28f..cd40dba 100644
57158 --- a/fs/fuse/dir.c
57159 +++ b/fs/fuse/dir.c
57160 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
57161 return link;
57162 }
57163
57164 -static void free_link(char *link)
57165 +static void free_link(const char *link)
57166 {
57167 if (!IS_ERR(link))
57168 free_page((unsigned long) link);
57169 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57170 index 64915ee..6bed500 100644
57171 --- a/fs/gfs2/inode.c
57172 +++ b/fs/gfs2/inode.c
57173 @@ -1506,7 +1506,7 @@ out:
57174
57175 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57176 {
57177 - char *s = nd_get_link(nd);
57178 + const char *s = nd_get_link(nd);
57179 if (!IS_ERR(s))
57180 kfree(s);
57181 }
57182 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57183 index d19b30a..ef89c36 100644
57184 --- a/fs/hugetlbfs/inode.c
57185 +++ b/fs/hugetlbfs/inode.c
57186 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57187 struct mm_struct *mm = current->mm;
57188 struct vm_area_struct *vma;
57189 struct hstate *h = hstate_file(file);
57190 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57191 struct vm_unmapped_area_info info;
57192
57193 if (len & ~huge_page_mask(h))
57194 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57195 return addr;
57196 }
57197
57198 +#ifdef CONFIG_PAX_RANDMMAP
57199 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57200 +#endif
57201 +
57202 if (addr) {
57203 addr = ALIGN(addr, huge_page_size(h));
57204 vma = find_vma(mm, addr);
57205 - if (TASK_SIZE - len >= addr &&
57206 - (!vma || addr + len <= vma->vm_start))
57207 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57208 return addr;
57209 }
57210
57211 info.flags = 0;
57212 info.length = len;
57213 info.low_limit = TASK_UNMAPPED_BASE;
57214 +
57215 +#ifdef CONFIG_PAX_RANDMMAP
57216 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57217 + info.low_limit += mm->delta_mmap;
57218 +#endif
57219 +
57220 info.high_limit = TASK_SIZE;
57221 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57222 info.align_offset = 0;
57223 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57224 };
57225 MODULE_ALIAS_FS("hugetlbfs");
57226
57227 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57228 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57229
57230 static int can_do_hugetlb_shm(void)
57231 {
57232 diff --git a/fs/inode.c b/fs/inode.c
57233 index d6dfb09..602e77e 100644
57234 --- a/fs/inode.c
57235 +++ b/fs/inode.c
57236 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
57237
57238 #ifdef CONFIG_SMP
57239 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57240 - static atomic_t shared_last_ino;
57241 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57242 + static atomic_unchecked_t shared_last_ino;
57243 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57244
57245 res = next - LAST_INO_BATCH;
57246 }
57247 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57248 index 4a6cf28..d3a29d3 100644
57249 --- a/fs/jffs2/erase.c
57250 +++ b/fs/jffs2/erase.c
57251 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57252 struct jffs2_unknown_node marker = {
57253 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57254 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57255 - .totlen = cpu_to_je32(c->cleanmarker_size)
57256 + .totlen = cpu_to_je32(c->cleanmarker_size),
57257 + .hdr_crc = cpu_to_je32(0)
57258 };
57259
57260 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57261 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57262 index a6597d6..41b30ec 100644
57263 --- a/fs/jffs2/wbuf.c
57264 +++ b/fs/jffs2/wbuf.c
57265 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57266 {
57267 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57268 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57269 - .totlen = constant_cpu_to_je32(8)
57270 + .totlen = constant_cpu_to_je32(8),
57271 + .hdr_crc = constant_cpu_to_je32(0)
57272 };
57273
57274 /*
57275 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57276 index 6669aa2..36b033d 100644
57277 --- a/fs/jfs/super.c
57278 +++ b/fs/jfs/super.c
57279 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57280
57281 jfs_inode_cachep =
57282 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57283 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57284 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57285 init_once);
57286 if (jfs_inode_cachep == NULL)
57287 return -ENOMEM;
57288 diff --git a/fs/libfs.c b/fs/libfs.c
57289 index 3a3a9b5..3a9b074 100644
57290 --- a/fs/libfs.c
57291 +++ b/fs/libfs.c
57292 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57293
57294 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57295 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57296 + char d_name[sizeof(next->d_iname)];
57297 + const unsigned char *name;
57298 +
57299 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57300 if (!simple_positive(next)) {
57301 spin_unlock(&next->d_lock);
57302 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57303
57304 spin_unlock(&next->d_lock);
57305 spin_unlock(&dentry->d_lock);
57306 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57307 + name = next->d_name.name;
57308 + if (name == next->d_iname) {
57309 + memcpy(d_name, name, next->d_name.len);
57310 + name = d_name;
57311 + }
57312 + if (!dir_emit(ctx, name, next->d_name.len,
57313 next->d_inode->i_ino, dt_type(next->d_inode)))
57314 return 0;
57315 spin_lock(&dentry->d_lock);
57316 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57317 index acd3947..1f896e2 100644
57318 --- a/fs/lockd/clntproc.c
57319 +++ b/fs/lockd/clntproc.c
57320 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57321 /*
57322 * Cookie counter for NLM requests
57323 */
57324 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57325 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57326
57327 void nlmclnt_next_cookie(struct nlm_cookie *c)
57328 {
57329 - u32 cookie = atomic_inc_return(&nlm_cookie);
57330 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57331
57332 memcpy(c->data, &cookie, 4);
57333 c->len=4;
57334 diff --git a/fs/locks.c b/fs/locks.c
57335 index b27a300..4156d0b 100644
57336 --- a/fs/locks.c
57337 +++ b/fs/locks.c
57338 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57339 return;
57340
57341 if (filp->f_op && filp->f_op->flock) {
57342 - struct file_lock fl = {
57343 + struct file_lock flock = {
57344 .fl_pid = current->tgid,
57345 .fl_file = filp,
57346 .fl_flags = FL_FLOCK,
57347 .fl_type = F_UNLCK,
57348 .fl_end = OFFSET_MAX,
57349 };
57350 - filp->f_op->flock(filp, F_SETLKW, &fl);
57351 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57352 - fl.fl_ops->fl_release_private(&fl);
57353 + filp->f_op->flock(filp, F_SETLKW, &flock);
57354 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57355 + flock.fl_ops->fl_release_private(&flock);
57356 }
57357
57358 spin_lock(&inode->i_lock);
57359 diff --git a/fs/namei.c b/fs/namei.c
57360 index 7720fbd..7934bb2 100644
57361 --- a/fs/namei.c
57362 +++ b/fs/namei.c
57363 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57364 if (ret != -EACCES)
57365 return ret;
57366
57367 +#ifdef CONFIG_GRKERNSEC
57368 + /* we'll block if we have to log due to a denied capability use */
57369 + if (mask & MAY_NOT_BLOCK)
57370 + return -ECHILD;
57371 +#endif
57372 +
57373 if (S_ISDIR(inode->i_mode)) {
57374 /* DACs are overridable for directories */
57375 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57376 - return 0;
57377 if (!(mask & MAY_WRITE))
57378 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57379 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57380 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57381 return 0;
57382 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57383 + return 0;
57384 return -EACCES;
57385 }
57386 /*
57387 + * Searching includes executable on directories, else just read.
57388 + */
57389 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57390 + if (mask == MAY_READ)
57391 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57392 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57393 + return 0;
57394 +
57395 + /*
57396 * Read/write DACs are always overridable.
57397 * Executable DACs are overridable when there is
57398 * at least one exec bit set.
57399 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57400 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57401 return 0;
57402
57403 - /*
57404 - * Searching includes executable on directories, else just read.
57405 - */
57406 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57407 - if (mask == MAY_READ)
57408 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57409 - return 0;
57410 -
57411 return -EACCES;
57412 }
57413
57414 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57415 {
57416 struct dentry *dentry = link->dentry;
57417 int error;
57418 - char *s;
57419 + const char *s;
57420
57421 BUG_ON(nd->flags & LOOKUP_RCU);
57422
57423 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57424 if (error)
57425 goto out_put_nd_path;
57426
57427 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57428 + dentry->d_inode, dentry, nd->path.mnt)) {
57429 + error = -EACCES;
57430 + goto out_put_nd_path;
57431 + }
57432 +
57433 nd->last_type = LAST_BIND;
57434 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57435 error = PTR_ERR(*p);
57436 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57437 if (res)
57438 break;
57439 res = walk_component(nd, path, LOOKUP_FOLLOW);
57440 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57441 + res = -EACCES;
57442 put_link(nd, &link, cookie);
57443 } while (res > 0);
57444
57445 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
57446 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57447 {
57448 unsigned long a, b, adata, bdata, mask, hash, len;
57449 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57450 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57451
57452 hash = a = 0;
57453 len = -sizeof(unsigned long);
57454 @@ -1967,6 +1983,8 @@ static int path_lookupat(int dfd, const char *name,
57455 if (err)
57456 break;
57457 err = lookup_last(nd, &path);
57458 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
57459 + err = -EACCES;
57460 put_link(nd, &link, cookie);
57461 }
57462 }
57463 @@ -1974,6 +1992,13 @@ static int path_lookupat(int dfd, const char *name,
57464 if (!err)
57465 err = complete_walk(nd);
57466
57467 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
57468 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57469 + path_put(&nd->path);
57470 + err = -ENOENT;
57471 + }
57472 + }
57473 +
57474 if (!err && nd->flags & LOOKUP_DIRECTORY) {
57475 if (!can_lookup(nd->inode)) {
57476 path_put(&nd->path);
57477 @@ -2001,8 +2026,15 @@ static int filename_lookup(int dfd, struct filename *name,
57478 retval = path_lookupat(dfd, name->name,
57479 flags | LOOKUP_REVAL, nd);
57480
57481 - if (likely(!retval))
57482 + if (likely(!retval)) {
57483 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
57484 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
57485 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
57486 + path_put(&nd->path);
57487 + return -ENOENT;
57488 + }
57489 + }
57490 + }
57491 return retval;
57492 }
57493
57494 @@ -2380,6 +2412,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
57495 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
57496 return -EPERM;
57497
57498 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
57499 + return -EPERM;
57500 + if (gr_handle_rawio(inode))
57501 + return -EPERM;
57502 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
57503 + return -EACCES;
57504 +
57505 return 0;
57506 }
57507
57508 @@ -2601,7 +2640,7 @@ looked_up:
57509 * cleared otherwise prior to returning.
57510 */
57511 static int lookup_open(struct nameidata *nd, struct path *path,
57512 - struct file *file,
57513 + struct path *link, struct file *file,
57514 const struct open_flags *op,
57515 bool got_write, int *opened)
57516 {
57517 @@ -2636,6 +2675,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57518 /* Negative dentry, just create the file */
57519 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
57520 umode_t mode = op->mode;
57521 +
57522 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
57523 + error = -EACCES;
57524 + goto out_dput;
57525 + }
57526 +
57527 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
57528 + error = -EACCES;
57529 + goto out_dput;
57530 + }
57531 +
57532 if (!IS_POSIXACL(dir->d_inode))
57533 mode &= ~current_umask();
57534 /*
57535 @@ -2657,6 +2707,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57536 nd->flags & LOOKUP_EXCL);
57537 if (error)
57538 goto out_dput;
57539 + else
57540 + gr_handle_create(dentry, nd->path.mnt);
57541 }
57542 out_no_open:
57543 path->dentry = dentry;
57544 @@ -2671,7 +2723,7 @@ out_dput:
57545 /*
57546 * Handle the last step of open()
57547 */
57548 -static int do_last(struct nameidata *nd, struct path *path,
57549 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
57550 struct file *file, const struct open_flags *op,
57551 int *opened, struct filename *name)
57552 {
57553 @@ -2721,6 +2773,15 @@ static int do_last(struct nameidata *nd, struct path *path,
57554 if (error)
57555 return error;
57556
57557 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
57558 + error = -ENOENT;
57559 + goto out;
57560 + }
57561 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57562 + error = -EACCES;
57563 + goto out;
57564 + }
57565 +
57566 audit_inode(name, dir, LOOKUP_PARENT);
57567 error = -EISDIR;
57568 /* trailing slashes? */
57569 @@ -2740,7 +2801,7 @@ retry_lookup:
57570 */
57571 }
57572 mutex_lock(&dir->d_inode->i_mutex);
57573 - error = lookup_open(nd, path, file, op, got_write, opened);
57574 + error = lookup_open(nd, path, link, file, op, got_write, opened);
57575 mutex_unlock(&dir->d_inode->i_mutex);
57576
57577 if (error <= 0) {
57578 @@ -2764,11 +2825,28 @@ retry_lookup:
57579 goto finish_open_created;
57580 }
57581
57582 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
57583 + error = -ENOENT;
57584 + goto exit_dput;
57585 + }
57586 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
57587 + error = -EACCES;
57588 + goto exit_dput;
57589 + }
57590 +
57591 /*
57592 * create/update audit record if it already exists.
57593 */
57594 - if (path->dentry->d_inode)
57595 + if (path->dentry->d_inode) {
57596 + /* only check if O_CREAT is specified, all other checks need to go
57597 + into may_open */
57598 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
57599 + error = -EACCES;
57600 + goto exit_dput;
57601 + }
57602 +
57603 audit_inode(name, path->dentry, 0);
57604 + }
57605
57606 /*
57607 * If atomic_open() acquired write access it is dropped now due to
57608 @@ -2809,6 +2887,11 @@ finish_lookup:
57609 }
57610 }
57611 BUG_ON(inode != path->dentry->d_inode);
57612 + /* if we're resolving a symlink to another symlink */
57613 + if (link && gr_handle_symlink_owner(link, inode)) {
57614 + error = -EACCES;
57615 + goto out;
57616 + }
57617 return 1;
57618 }
57619
57620 @@ -2818,7 +2901,6 @@ finish_lookup:
57621 save_parent.dentry = nd->path.dentry;
57622 save_parent.mnt = mntget(path->mnt);
57623 nd->path.dentry = path->dentry;
57624 -
57625 }
57626 nd->inode = inode;
57627 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
57628 @@ -2828,7 +2910,18 @@ finish_open:
57629 path_put(&save_parent);
57630 return error;
57631 }
57632 +
57633 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57634 + error = -ENOENT;
57635 + goto out;
57636 + }
57637 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57638 + error = -EACCES;
57639 + goto out;
57640 + }
57641 +
57642 audit_inode(name, nd->path.dentry, 0);
57643 +
57644 error = -EISDIR;
57645 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
57646 goto out;
57647 @@ -2991,7 +3084,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57648 if (unlikely(error))
57649 goto out;
57650
57651 - error = do_last(nd, &path, file, op, &opened, pathname);
57652 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
57653 while (unlikely(error > 0)) { /* trailing symlink */
57654 struct path link = path;
57655 void *cookie;
57656 @@ -3009,7 +3102,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57657 error = follow_link(&link, nd, &cookie);
57658 if (unlikely(error))
57659 break;
57660 - error = do_last(nd, &path, file, op, &opened, pathname);
57661 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
57662 put_link(nd, &link, cookie);
57663 }
57664 out:
57665 @@ -3109,8 +3202,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
57666 goto unlock;
57667
57668 error = -EEXIST;
57669 - if (dentry->d_inode)
57670 + if (dentry->d_inode) {
57671 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
57672 + error = -ENOENT;
57673 + }
57674 goto fail;
57675 + }
57676 /*
57677 * Special case - lookup gave negative, but... we had foo/bar/
57678 * From the vfs_mknod() POV we just have a negative dentry -
57679 @@ -3162,6 +3259,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
57680 }
57681 EXPORT_SYMBOL(user_path_create);
57682
57683 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
57684 +{
57685 + struct filename *tmp = getname(pathname);
57686 + struct dentry *res;
57687 + if (IS_ERR(tmp))
57688 + return ERR_CAST(tmp);
57689 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
57690 + if (IS_ERR(res))
57691 + putname(tmp);
57692 + else
57693 + *to = tmp;
57694 + return res;
57695 +}
57696 +
57697 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
57698 {
57699 int error = may_create(dir, dentry);
57700 @@ -3224,6 +3335,17 @@ retry:
57701
57702 if (!IS_POSIXACL(path.dentry->d_inode))
57703 mode &= ~current_umask();
57704 +
57705 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
57706 + error = -EPERM;
57707 + goto out;
57708 + }
57709 +
57710 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
57711 + error = -EACCES;
57712 + goto out;
57713 + }
57714 +
57715 error = security_path_mknod(&path, dentry, mode, dev);
57716 if (error)
57717 goto out;
57718 @@ -3240,6 +3362,8 @@ retry:
57719 break;
57720 }
57721 out:
57722 + if (!error)
57723 + gr_handle_create(dentry, path.mnt);
57724 done_path_create(&path, dentry);
57725 if (retry_estale(error, lookup_flags)) {
57726 lookup_flags |= LOOKUP_REVAL;
57727 @@ -3292,9 +3416,16 @@ retry:
57728
57729 if (!IS_POSIXACL(path.dentry->d_inode))
57730 mode &= ~current_umask();
57731 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
57732 + error = -EACCES;
57733 + goto out;
57734 + }
57735 error = security_path_mkdir(&path, dentry, mode);
57736 if (!error)
57737 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
57738 + if (!error)
57739 + gr_handle_create(dentry, path.mnt);
57740 +out:
57741 done_path_create(&path, dentry);
57742 if (retry_estale(error, lookup_flags)) {
57743 lookup_flags |= LOOKUP_REVAL;
57744 @@ -3375,6 +3506,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
57745 struct filename *name;
57746 struct dentry *dentry;
57747 struct nameidata nd;
57748 + ino_t saved_ino = 0;
57749 + dev_t saved_dev = 0;
57750 unsigned int lookup_flags = 0;
57751 retry:
57752 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57753 @@ -3407,10 +3540,21 @@ retry:
57754 error = -ENOENT;
57755 goto exit3;
57756 }
57757 +
57758 + saved_ino = dentry->d_inode->i_ino;
57759 + saved_dev = gr_get_dev_from_dentry(dentry);
57760 +
57761 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
57762 + error = -EACCES;
57763 + goto exit3;
57764 + }
57765 +
57766 error = security_path_rmdir(&nd.path, dentry);
57767 if (error)
57768 goto exit3;
57769 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
57770 + if (!error && (saved_dev || saved_ino))
57771 + gr_handle_delete(saved_ino, saved_dev);
57772 exit3:
57773 dput(dentry);
57774 exit2:
57775 @@ -3476,6 +3620,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
57776 struct dentry *dentry;
57777 struct nameidata nd;
57778 struct inode *inode = NULL;
57779 + ino_t saved_ino = 0;
57780 + dev_t saved_dev = 0;
57781 unsigned int lookup_flags = 0;
57782 retry:
57783 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57784 @@ -3502,10 +3648,22 @@ retry:
57785 if (!inode)
57786 goto slashes;
57787 ihold(inode);
57788 +
57789 + if (inode->i_nlink <= 1) {
57790 + saved_ino = inode->i_ino;
57791 + saved_dev = gr_get_dev_from_dentry(dentry);
57792 + }
57793 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
57794 + error = -EACCES;
57795 + goto exit2;
57796 + }
57797 +
57798 error = security_path_unlink(&nd.path, dentry);
57799 if (error)
57800 goto exit2;
57801 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
57802 + if (!error && (saved_ino || saved_dev))
57803 + gr_handle_delete(saved_ino, saved_dev);
57804 exit2:
57805 dput(dentry);
57806 }
57807 @@ -3583,9 +3741,17 @@ retry:
57808 if (IS_ERR(dentry))
57809 goto out_putname;
57810
57811 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
57812 + error = -EACCES;
57813 + goto out;
57814 + }
57815 +
57816 error = security_path_symlink(&path, dentry, from->name);
57817 if (!error)
57818 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
57819 + if (!error)
57820 + gr_handle_create(dentry, path.mnt);
57821 +out:
57822 done_path_create(&path, dentry);
57823 if (retry_estale(error, lookup_flags)) {
57824 lookup_flags |= LOOKUP_REVAL;
57825 @@ -3665,6 +3831,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
57826 {
57827 struct dentry *new_dentry;
57828 struct path old_path, new_path;
57829 + struct filename *to = NULL;
57830 int how = 0;
57831 int error;
57832
57833 @@ -3688,7 +3855,7 @@ retry:
57834 if (error)
57835 return error;
57836
57837 - new_dentry = user_path_create(newdfd, newname, &new_path,
57838 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
57839 (how & LOOKUP_REVAL));
57840 error = PTR_ERR(new_dentry);
57841 if (IS_ERR(new_dentry))
57842 @@ -3700,11 +3867,28 @@ retry:
57843 error = may_linkat(&old_path);
57844 if (unlikely(error))
57845 goto out_dput;
57846 +
57847 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
57848 + old_path.dentry->d_inode,
57849 + old_path.dentry->d_inode->i_mode, to)) {
57850 + error = -EACCES;
57851 + goto out_dput;
57852 + }
57853 +
57854 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
57855 + old_path.dentry, old_path.mnt, to)) {
57856 + error = -EACCES;
57857 + goto out_dput;
57858 + }
57859 +
57860 error = security_path_link(old_path.dentry, &new_path, new_dentry);
57861 if (error)
57862 goto out_dput;
57863 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
57864 + if (!error)
57865 + gr_handle_create(new_dentry, new_path.mnt);
57866 out_dput:
57867 + putname(to);
57868 done_path_create(&new_path, new_dentry);
57869 if (retry_estale(error, how)) {
57870 how |= LOOKUP_REVAL;
57871 @@ -3950,12 +4134,21 @@ retry:
57872 if (new_dentry == trap)
57873 goto exit5;
57874
57875 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
57876 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
57877 + to);
57878 + if (error)
57879 + goto exit5;
57880 +
57881 error = security_path_rename(&oldnd.path, old_dentry,
57882 &newnd.path, new_dentry);
57883 if (error)
57884 goto exit5;
57885 error = vfs_rename(old_dir->d_inode, old_dentry,
57886 new_dir->d_inode, new_dentry);
57887 + if (!error)
57888 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
57889 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
57890 exit5:
57891 dput(new_dentry);
57892 exit4:
57893 @@ -3987,6 +4180,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
57894
57895 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
57896 {
57897 + char tmpbuf[64];
57898 + const char *newlink;
57899 int len;
57900
57901 len = PTR_ERR(link);
57902 @@ -3996,7 +4191,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
57903 len = strlen(link);
57904 if (len > (unsigned) buflen)
57905 len = buflen;
57906 - if (copy_to_user(buffer, link, len))
57907 +
57908 + if (len < sizeof(tmpbuf)) {
57909 + memcpy(tmpbuf, link, len);
57910 + newlink = tmpbuf;
57911 + } else
57912 + newlink = link;
57913 +
57914 + if (copy_to_user(buffer, newlink, len))
57915 len = -EFAULT;
57916 out:
57917 return len;
57918 diff --git a/fs/namespace.c b/fs/namespace.c
57919 index a45ba4f..b4c7d07 100644
57920 --- a/fs/namespace.c
57921 +++ b/fs/namespace.c
57922 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
57923 if (!(sb->s_flags & MS_RDONLY))
57924 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
57925 up_write(&sb->s_umount);
57926 +
57927 + gr_log_remount(mnt->mnt_devname, retval);
57928 +
57929 return retval;
57930 }
57931
57932 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
57933 }
57934 br_write_unlock(&vfsmount_lock);
57935 namespace_unlock();
57936 +
57937 + gr_log_unmount(mnt->mnt_devname, retval);
57938 +
57939 return retval;
57940 }
57941
57942 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
57943 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
57944 */
57945
57946 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
57947 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
57948 {
57949 struct path path;
57950 struct mount *mnt;
57951 @@ -1342,7 +1348,7 @@ out:
57952 /*
57953 * The 2.0 compatible umount. No flags.
57954 */
57955 -SYSCALL_DEFINE1(oldumount, char __user *, name)
57956 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
57957 {
57958 return sys_umount(name, 0);
57959 }
57960 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
57961 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
57962 MS_STRICTATIME);
57963
57964 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
57965 + retval = -EPERM;
57966 + goto dput_out;
57967 + }
57968 +
57969 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
57970 + retval = -EPERM;
57971 + goto dput_out;
57972 + }
57973 +
57974 if (flags & MS_REMOUNT)
57975 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
57976 data_page);
57977 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
57978 dev_name, data_page);
57979 dput_out:
57980 path_put(&path);
57981 +
57982 + gr_log_mount(dev_name, dir_name, retval);
57983 +
57984 return retval;
57985 }
57986
57987 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
57988 * number incrementing at 10Ghz will take 12,427 years to wrap which
57989 * is effectively never, so we can ignore the possibility.
57990 */
57991 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
57992 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
57993
57994 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
57995 {
57996 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
57997 kfree(new_ns);
57998 return ERR_PTR(ret);
57999 }
58000 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58001 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58002 atomic_set(&new_ns->count, 1);
58003 new_ns->root = NULL;
58004 INIT_LIST_HEAD(&new_ns->list);
58005 @@ -2373,7 +2392,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58006 * Allocate a new namespace structure and populate it with contents
58007 * copied from the namespace of the passed in task structure.
58008 */
58009 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58010 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58011 struct user_namespace *user_ns, struct fs_struct *fs)
58012 {
58013 struct mnt_namespace *new_ns;
58014 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58015 }
58016 EXPORT_SYMBOL(mount_subtree);
58017
58018 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58019 - char __user *, type, unsigned long, flags, void __user *, data)
58020 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58021 + const char __user *, type, unsigned long, flags, void __user *, data)
58022 {
58023 int ret;
58024 char *kernel_type;
58025 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58026 if (error)
58027 goto out2;
58028
58029 + if (gr_handle_chroot_pivot()) {
58030 + error = -EPERM;
58031 + goto out2;
58032 + }
58033 +
58034 get_fs_root(current->fs, &root);
58035 old_mp = lock_mount(&old);
58036 error = PTR_ERR(old_mp);
58037 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58038 !nsown_capable(CAP_SYS_ADMIN))
58039 return -EPERM;
58040
58041 - if (fs->users != 1)
58042 + if (atomic_read(&fs->users) != 1)
58043 return -EINVAL;
58044
58045 get_mnt_ns(mnt_ns);
58046 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58047 index f4ccfe6..a5cf064 100644
58048 --- a/fs/nfs/callback_xdr.c
58049 +++ b/fs/nfs/callback_xdr.c
58050 @@ -51,7 +51,7 @@ struct callback_op {
58051 callback_decode_arg_t decode_args;
58052 callback_encode_res_t encode_res;
58053 long res_maxsize;
58054 -};
58055 +} __do_const;
58056
58057 static struct callback_op callback_ops[];
58058
58059 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58060 index 941246f..17d8724 100644
58061 --- a/fs/nfs/inode.c
58062 +++ b/fs/nfs/inode.c
58063 @@ -1138,16 +1138,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58064 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58065 }
58066
58067 -static atomic_long_t nfs_attr_generation_counter;
58068 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58069
58070 static unsigned long nfs_read_attr_generation_counter(void)
58071 {
58072 - return atomic_long_read(&nfs_attr_generation_counter);
58073 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58074 }
58075
58076 unsigned long nfs_inc_attr_generation_counter(void)
58077 {
58078 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58079 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58080 }
58081
58082 void nfs_fattr_init(struct nfs_fattr *fattr)
58083 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
58084 index e22862f..92d66eb 100644
58085 --- a/fs/nfs/nfs4state.c
58086 +++ b/fs/nfs/nfs4state.c
58087 @@ -154,6 +154,19 @@ struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp)
58088 return cred;
58089 }
58090
58091 +static void nfs4_root_machine_cred(struct nfs_client *clp)
58092 +{
58093 + struct rpc_cred *cred, *new;
58094 +
58095 + new = rpc_lookup_machine_cred(NULL);
58096 + spin_lock(&clp->cl_lock);
58097 + cred = clp->cl_machine_cred;
58098 + clp->cl_machine_cred = new;
58099 + spin_unlock(&clp->cl_lock);
58100 + if (cred != NULL)
58101 + put_rpccred(cred);
58102 +}
58103 +
58104 static struct rpc_cred *
58105 nfs4_get_renew_cred_server_locked(struct nfs_server *server)
58106 {
58107 @@ -1896,10 +1909,19 @@ again:
58108 __func__, status);
58109 goto again;
58110 case -EACCES:
58111 - if (i++)
58112 + if (i++ == 0) {
58113 + nfs4_root_machine_cred(clp);
58114 + goto again;
58115 + }
58116 + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX)
58117 break;
58118 case -NFS4ERR_CLID_INUSE:
58119 case -NFS4ERR_WRONGSEC:
58120 + /* No point in retrying if we already used RPC_AUTH_UNIX */
58121 + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX) {
58122 + status = -EPERM;
58123 + break;
58124 + }
58125 clnt = rpc_clone_client_set_auth(clnt, RPC_AUTH_UNIX);
58126 if (IS_ERR(clnt)) {
58127 status = PTR_ERR(clnt);
58128 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58129 index 419572f..5414a23 100644
58130 --- a/fs/nfsd/nfs4proc.c
58131 +++ b/fs/nfsd/nfs4proc.c
58132 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58133 nfsd4op_rsize op_rsize_bop;
58134 stateid_getter op_get_currentstateid;
58135 stateid_setter op_set_currentstateid;
58136 -};
58137 +} __do_const;
58138
58139 static struct nfsd4_operation nfsd4_ops[];
58140
58141 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58142 index c2a4701..fd80e29 100644
58143 --- a/fs/nfsd/nfs4xdr.c
58144 +++ b/fs/nfsd/nfs4xdr.c
58145 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58146
58147 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58148
58149 -static nfsd4_dec nfsd4_dec_ops[] = {
58150 +static const nfsd4_dec nfsd4_dec_ops[] = {
58151 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58152 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58153 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58154 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58155 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58156 };
58157
58158 -static nfsd4_dec nfsd41_dec_ops[] = {
58159 +static const nfsd4_dec nfsd41_dec_ops[] = {
58160 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58161 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58162 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58163 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58164 };
58165
58166 struct nfsd4_minorversion_ops {
58167 - nfsd4_dec *decoders;
58168 + const nfsd4_dec *decoders;
58169 int nops;
58170 };
58171
58172 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58173 index e76244e..9fe8f2f1 100644
58174 --- a/fs/nfsd/nfscache.c
58175 +++ b/fs/nfsd/nfscache.c
58176 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58177 {
58178 struct svc_cacherep *rp = rqstp->rq_cacherep;
58179 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58180 - int len;
58181 + long len;
58182 size_t bufsize = 0;
58183
58184 if (!rp)
58185 return;
58186
58187 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58188 - len >>= 2;
58189 + if (statp) {
58190 + len = (char*)statp - (char*)resv->iov_base;
58191 + len = resv->iov_len - len;
58192 + len >>= 2;
58193 + }
58194
58195 /* Don't cache excessive amounts of data and XDR failures */
58196 if (!statp || len > (256 >> 2)) {
58197 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58198 index c827acb..b253b77 100644
58199 --- a/fs/nfsd/vfs.c
58200 +++ b/fs/nfsd/vfs.c
58201 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58202 } else {
58203 oldfs = get_fs();
58204 set_fs(KERNEL_DS);
58205 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58206 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58207 set_fs(oldfs);
58208 }
58209
58210 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58211
58212 /* Write the data. */
58213 oldfs = get_fs(); set_fs(KERNEL_DS);
58214 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58215 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58216 set_fs(oldfs);
58217 if (host_err < 0)
58218 goto out_nfserr;
58219 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58220 */
58221
58222 oldfs = get_fs(); set_fs(KERNEL_DS);
58223 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58224 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58225 set_fs(oldfs);
58226
58227 if (host_err < 0)
58228 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58229 index fea6bd5..8ee9d81 100644
58230 --- a/fs/nls/nls_base.c
58231 +++ b/fs/nls/nls_base.c
58232 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58233
58234 int register_nls(struct nls_table * nls)
58235 {
58236 - struct nls_table ** tmp = &tables;
58237 + struct nls_table *tmp = tables;
58238
58239 if (nls->next)
58240 return -EBUSY;
58241
58242 spin_lock(&nls_lock);
58243 - while (*tmp) {
58244 - if (nls == *tmp) {
58245 + while (tmp) {
58246 + if (nls == tmp) {
58247 spin_unlock(&nls_lock);
58248 return -EBUSY;
58249 }
58250 - tmp = &(*tmp)->next;
58251 + tmp = tmp->next;
58252 }
58253 - nls->next = tables;
58254 + pax_open_kernel();
58255 + *(struct nls_table **)&nls->next = tables;
58256 + pax_close_kernel();
58257 tables = nls;
58258 spin_unlock(&nls_lock);
58259 return 0;
58260 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58261
58262 int unregister_nls(struct nls_table * nls)
58263 {
58264 - struct nls_table ** tmp = &tables;
58265 + struct nls_table * const * tmp = &tables;
58266
58267 spin_lock(&nls_lock);
58268 while (*tmp) {
58269 if (nls == *tmp) {
58270 - *tmp = nls->next;
58271 + pax_open_kernel();
58272 + *(struct nls_table **)tmp = nls->next;
58273 + pax_close_kernel();
58274 spin_unlock(&nls_lock);
58275 return 0;
58276 }
58277 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58278 index 7424929..35f6be5 100644
58279 --- a/fs/nls/nls_euc-jp.c
58280 +++ b/fs/nls/nls_euc-jp.c
58281 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58282 p_nls = load_nls("cp932");
58283
58284 if (p_nls) {
58285 - table.charset2upper = p_nls->charset2upper;
58286 - table.charset2lower = p_nls->charset2lower;
58287 + pax_open_kernel();
58288 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58289 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58290 + pax_close_kernel();
58291 return register_nls(&table);
58292 }
58293
58294 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58295 index e7bc1d7..06bd4bb 100644
58296 --- a/fs/nls/nls_koi8-ru.c
58297 +++ b/fs/nls/nls_koi8-ru.c
58298 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58299 p_nls = load_nls("koi8-u");
58300
58301 if (p_nls) {
58302 - table.charset2upper = p_nls->charset2upper;
58303 - table.charset2lower = p_nls->charset2lower;
58304 + pax_open_kernel();
58305 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58306 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58307 + pax_close_kernel();
58308 return register_nls(&table);
58309 }
58310
58311 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58312 index e44cb64..4807084 100644
58313 --- a/fs/notify/fanotify/fanotify_user.c
58314 +++ b/fs/notify/fanotify/fanotify_user.c
58315 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58316
58317 fd = fanotify_event_metadata.fd;
58318 ret = -EFAULT;
58319 - if (copy_to_user(buf, &fanotify_event_metadata,
58320 - fanotify_event_metadata.event_len))
58321 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58322 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58323 goto out_close_fd;
58324
58325 ret = prepare_for_access_response(group, event, fd);
58326 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58327 index 7b51b05..5ea5ef6 100644
58328 --- a/fs/notify/notification.c
58329 +++ b/fs/notify/notification.c
58330 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58331 * get set to 0 so it will never get 'freed'
58332 */
58333 static struct fsnotify_event *q_overflow_event;
58334 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58335 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58336
58337 /**
58338 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58339 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58340 */
58341 u32 fsnotify_get_cookie(void)
58342 {
58343 - return atomic_inc_return(&fsnotify_sync_cookie);
58344 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58345 }
58346 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58347
58348 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58349 index 9e38daf..5727cae 100644
58350 --- a/fs/ntfs/dir.c
58351 +++ b/fs/ntfs/dir.c
58352 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58353 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58354 ~(s64)(ndir->itype.index.block_size - 1)));
58355 /* Bounds checks. */
58356 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58357 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58358 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58359 "inode 0x%lx or driver bug.", vdir->i_ino);
58360 goto err_out;
58361 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58362 index c5670b8..d590213 100644
58363 --- a/fs/ntfs/file.c
58364 +++ b/fs/ntfs/file.c
58365 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58366 char *addr;
58367 size_t total = 0;
58368 unsigned len;
58369 - int left;
58370 + unsigned left;
58371
58372 do {
58373 len = PAGE_CACHE_SIZE - ofs;
58374 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58375 index 82650d5..db37dcf 100644
58376 --- a/fs/ntfs/super.c
58377 +++ b/fs/ntfs/super.c
58378 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58379 if (!silent)
58380 ntfs_error(sb, "Primary boot sector is invalid.");
58381 } else if (!silent)
58382 - ntfs_error(sb, read_err_str, "primary");
58383 + ntfs_error(sb, read_err_str, "%s", "primary");
58384 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58385 if (bh_primary)
58386 brelse(bh_primary);
58387 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58388 goto hotfix_primary_boot_sector;
58389 brelse(bh_backup);
58390 } else if (!silent)
58391 - ntfs_error(sb, read_err_str, "backup");
58392 + ntfs_error(sb, read_err_str, "%s", "backup");
58393 /* Try to read NT3.51- backup boot sector. */
58394 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58395 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58396 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58397 "sector.");
58398 brelse(bh_backup);
58399 } else if (!silent)
58400 - ntfs_error(sb, read_err_str, "backup");
58401 + ntfs_error(sb, read_err_str, "%s", "backup");
58402 /* We failed. Cleanup and return. */
58403 if (bh_primary)
58404 brelse(bh_primary);
58405 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58406 index aebeacd..0dcdd26 100644
58407 --- a/fs/ocfs2/localalloc.c
58408 +++ b/fs/ocfs2/localalloc.c
58409 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58410 goto bail;
58411 }
58412
58413 - atomic_inc(&osb->alloc_stats.moves);
58414 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58415
58416 bail:
58417 if (handle)
58418 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58419 index 3a90347..c40bef8 100644
58420 --- a/fs/ocfs2/ocfs2.h
58421 +++ b/fs/ocfs2/ocfs2.h
58422 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58423
58424 struct ocfs2_alloc_stats
58425 {
58426 - atomic_t moves;
58427 - atomic_t local_data;
58428 - atomic_t bitmap_data;
58429 - atomic_t bg_allocs;
58430 - atomic_t bg_extends;
58431 + atomic_unchecked_t moves;
58432 + atomic_unchecked_t local_data;
58433 + atomic_unchecked_t bitmap_data;
58434 + atomic_unchecked_t bg_allocs;
58435 + atomic_unchecked_t bg_extends;
58436 };
58437
58438 enum ocfs2_local_alloc_state
58439 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58440 index 5397c07..54afc55 100644
58441 --- a/fs/ocfs2/suballoc.c
58442 +++ b/fs/ocfs2/suballoc.c
58443 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58444 mlog_errno(status);
58445 goto bail;
58446 }
58447 - atomic_inc(&osb->alloc_stats.bg_extends);
58448 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58449
58450 /* You should never ask for this much metadata */
58451 BUG_ON(bits_wanted >
58452 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58453 mlog_errno(status);
58454 goto bail;
58455 }
58456 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58457 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58458
58459 *suballoc_loc = res.sr_bg_blkno;
58460 *suballoc_bit_start = res.sr_bit_offset;
58461 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58462 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58463 res->sr_bits);
58464
58465 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58466 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58467
58468 BUG_ON(res->sr_bits != 1);
58469
58470 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58471 mlog_errno(status);
58472 goto bail;
58473 }
58474 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58475 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58476
58477 BUG_ON(res.sr_bits != 1);
58478
58479 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58480 cluster_start,
58481 num_clusters);
58482 if (!status)
58483 - atomic_inc(&osb->alloc_stats.local_data);
58484 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
58485 } else {
58486 if (min_clusters > (osb->bitmap_cpg - 1)) {
58487 /* The only paths asking for contiguousness
58488 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58489 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
58490 res.sr_bg_blkno,
58491 res.sr_bit_offset);
58492 - atomic_inc(&osb->alloc_stats.bitmap_data);
58493 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
58494 *num_clusters = res.sr_bits;
58495 }
58496 }
58497 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
58498 index 121da2d..a0232bc 100644
58499 --- a/fs/ocfs2/super.c
58500 +++ b/fs/ocfs2/super.c
58501 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
58502 "%10s => GlobalAllocs: %d LocalAllocs: %d "
58503 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
58504 "Stats",
58505 - atomic_read(&osb->alloc_stats.bitmap_data),
58506 - atomic_read(&osb->alloc_stats.local_data),
58507 - atomic_read(&osb->alloc_stats.bg_allocs),
58508 - atomic_read(&osb->alloc_stats.moves),
58509 - atomic_read(&osb->alloc_stats.bg_extends));
58510 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
58511 + atomic_read_unchecked(&osb->alloc_stats.local_data),
58512 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
58513 + atomic_read_unchecked(&osb->alloc_stats.moves),
58514 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
58515
58516 out += snprintf(buf + out, len - out,
58517 "%10s => State: %u Descriptor: %llu Size: %u bits "
58518 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
58519 spin_lock_init(&osb->osb_xattr_lock);
58520 ocfs2_init_steal_slots(osb);
58521
58522 - atomic_set(&osb->alloc_stats.moves, 0);
58523 - atomic_set(&osb->alloc_stats.local_data, 0);
58524 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
58525 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
58526 - atomic_set(&osb->alloc_stats.bg_extends, 0);
58527 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
58528 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
58529 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
58530 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
58531 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
58532
58533 /* Copy the blockcheck stats from the superblock probe */
58534 osb->osb_ecc_stats = *stats;
58535 diff --git a/fs/open.c b/fs/open.c
58536 index 7931f76..7b03f3b 100644
58537 --- a/fs/open.c
58538 +++ b/fs/open.c
58539 @@ -32,6 +32,8 @@
58540 #include <linux/dnotify.h>
58541 #include <linux/compat.h>
58542
58543 +#define CREATE_TRACE_POINTS
58544 +#include <trace/events/fs.h>
58545 #include "internal.h"
58546
58547 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
58548 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
58549 error = locks_verify_truncate(inode, NULL, length);
58550 if (!error)
58551 error = security_path_truncate(path);
58552 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
58553 + error = -EACCES;
58554 if (!error)
58555 error = do_truncate(path->dentry, length, 0, NULL);
58556
58557 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
58558 error = locks_verify_truncate(inode, f.file, length);
58559 if (!error)
58560 error = security_path_truncate(&f.file->f_path);
58561 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
58562 + error = -EACCES;
58563 if (!error)
58564 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
58565 sb_end_write(inode->i_sb);
58566 @@ -360,6 +366,9 @@ retry:
58567 if (__mnt_is_readonly(path.mnt))
58568 res = -EROFS;
58569
58570 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
58571 + res = -EACCES;
58572 +
58573 out_path_release:
58574 path_put(&path);
58575 if (retry_estale(res, lookup_flags)) {
58576 @@ -391,6 +400,8 @@ retry:
58577 if (error)
58578 goto dput_and_out;
58579
58580 + gr_log_chdir(path.dentry, path.mnt);
58581 +
58582 set_fs_pwd(current->fs, &path);
58583
58584 dput_and_out:
58585 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
58586 goto out_putf;
58587
58588 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
58589 +
58590 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
58591 + error = -EPERM;
58592 +
58593 + if (!error)
58594 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
58595 +
58596 if (!error)
58597 set_fs_pwd(current->fs, &f.file->f_path);
58598 out_putf:
58599 @@ -449,7 +467,13 @@ retry:
58600 if (error)
58601 goto dput_and_out;
58602
58603 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
58604 + goto dput_and_out;
58605 +
58606 set_fs_root(current->fs, &path);
58607 +
58608 + gr_handle_chroot_chdir(&path);
58609 +
58610 error = 0;
58611 dput_and_out:
58612 path_put(&path);
58613 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
58614 if (error)
58615 return error;
58616 mutex_lock(&inode->i_mutex);
58617 +
58618 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
58619 + error = -EACCES;
58620 + goto out_unlock;
58621 + }
58622 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
58623 + error = -EACCES;
58624 + goto out_unlock;
58625 + }
58626 +
58627 error = security_path_chmod(path, mode);
58628 if (error)
58629 goto out_unlock;
58630 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
58631 uid = make_kuid(current_user_ns(), user);
58632 gid = make_kgid(current_user_ns(), group);
58633
58634 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
58635 + return -EACCES;
58636 +
58637 newattrs.ia_valid = ATTR_CTIME;
58638 if (user != (uid_t) -1) {
58639 if (!uid_valid(uid))
58640 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
58641 } else {
58642 fsnotify_open(f);
58643 fd_install(fd, f);
58644 + trace_do_sys_open(tmp->name, flags, mode);
58645 }
58646 }
58647 putname(tmp);
58648 diff --git a/fs/pipe.c b/fs/pipe.c
58649 index d2c45e1..009fe1c 100644
58650 --- a/fs/pipe.c
58651 +++ b/fs/pipe.c
58652 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
58653
58654 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
58655 {
58656 - if (pipe->files)
58657 + if (atomic_read(&pipe->files))
58658 mutex_lock_nested(&pipe->mutex, subclass);
58659 }
58660
58661 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
58662
58663 void pipe_unlock(struct pipe_inode_info *pipe)
58664 {
58665 - if (pipe->files)
58666 + if (atomic_read(&pipe->files))
58667 mutex_unlock(&pipe->mutex);
58668 }
58669 EXPORT_SYMBOL(pipe_unlock);
58670 @@ -449,9 +449,9 @@ redo:
58671 }
58672 if (bufs) /* More to do? */
58673 continue;
58674 - if (!pipe->writers)
58675 + if (!atomic_read(&pipe->writers))
58676 break;
58677 - if (!pipe->waiting_writers) {
58678 + if (!atomic_read(&pipe->waiting_writers)) {
58679 /* syscall merging: Usually we must not sleep
58680 * if O_NONBLOCK is set, or if we got some data.
58681 * But if a writer sleeps in kernel space, then
58682 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
58683 ret = 0;
58684 __pipe_lock(pipe);
58685
58686 - if (!pipe->readers) {
58687 + if (!atomic_read(&pipe->readers)) {
58688 send_sig(SIGPIPE, current, 0);
58689 ret = -EPIPE;
58690 goto out;
58691 @@ -562,7 +562,7 @@ redo1:
58692 for (;;) {
58693 int bufs;
58694
58695 - if (!pipe->readers) {
58696 + if (!atomic_read(&pipe->readers)) {
58697 send_sig(SIGPIPE, current, 0);
58698 if (!ret)
58699 ret = -EPIPE;
58700 @@ -653,9 +653,9 @@ redo2:
58701 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58702 do_wakeup = 0;
58703 }
58704 - pipe->waiting_writers++;
58705 + atomic_inc(&pipe->waiting_writers);
58706 pipe_wait(pipe);
58707 - pipe->waiting_writers--;
58708 + atomic_dec(&pipe->waiting_writers);
58709 }
58710 out:
58711 __pipe_unlock(pipe);
58712 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58713 mask = 0;
58714 if (filp->f_mode & FMODE_READ) {
58715 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
58716 - if (!pipe->writers && filp->f_version != pipe->w_counter)
58717 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
58718 mask |= POLLHUP;
58719 }
58720
58721 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58722 * Most Unices do not set POLLERR for FIFOs but on Linux they
58723 * behave exactly like pipes for poll().
58724 */
58725 - if (!pipe->readers)
58726 + if (!atomic_read(&pipe->readers))
58727 mask |= POLLERR;
58728 }
58729
58730 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
58731
58732 __pipe_lock(pipe);
58733 if (file->f_mode & FMODE_READ)
58734 - pipe->readers--;
58735 + atomic_dec(&pipe->readers);
58736 if (file->f_mode & FMODE_WRITE)
58737 - pipe->writers--;
58738 + atomic_dec(&pipe->writers);
58739
58740 - if (pipe->readers || pipe->writers) {
58741 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
58742 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
58743 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58744 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
58745 }
58746 spin_lock(&inode->i_lock);
58747 - if (!--pipe->files) {
58748 + if (atomic_dec_and_test(&pipe->files)) {
58749 inode->i_pipe = NULL;
58750 kill = 1;
58751 }
58752 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
58753 kfree(pipe);
58754 }
58755
58756 -static struct vfsmount *pipe_mnt __read_mostly;
58757 +struct vfsmount *pipe_mnt __read_mostly;
58758
58759 /*
58760 * pipefs_dname() is called from d_path().
58761 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
58762 goto fail_iput;
58763
58764 inode->i_pipe = pipe;
58765 - pipe->files = 2;
58766 - pipe->readers = pipe->writers = 1;
58767 + atomic_set(&pipe->files, 2);
58768 + atomic_set(&pipe->readers, 1);
58769 + atomic_set(&pipe->writers, 1);
58770 inode->i_fop = &pipefifo_fops;
58771
58772 /*
58773 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
58774 spin_lock(&inode->i_lock);
58775 if (inode->i_pipe) {
58776 pipe = inode->i_pipe;
58777 - pipe->files++;
58778 + atomic_inc(&pipe->files);
58779 spin_unlock(&inode->i_lock);
58780 } else {
58781 spin_unlock(&inode->i_lock);
58782 pipe = alloc_pipe_info();
58783 if (!pipe)
58784 return -ENOMEM;
58785 - pipe->files = 1;
58786 + atomic_set(&pipe->files, 1);
58787 spin_lock(&inode->i_lock);
58788 if (unlikely(inode->i_pipe)) {
58789 - inode->i_pipe->files++;
58790 + atomic_inc(&inode->i_pipe->files);
58791 spin_unlock(&inode->i_lock);
58792 free_pipe_info(pipe);
58793 pipe = inode->i_pipe;
58794 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
58795 * opened, even when there is no process writing the FIFO.
58796 */
58797 pipe->r_counter++;
58798 - if (pipe->readers++ == 0)
58799 + if (atomic_inc_return(&pipe->readers) == 1)
58800 wake_up_partner(pipe);
58801
58802 - if (!is_pipe && !pipe->writers) {
58803 + if (!is_pipe && !atomic_read(&pipe->writers)) {
58804 if ((filp->f_flags & O_NONBLOCK)) {
58805 /* suppress POLLHUP until we have
58806 * seen a writer */
58807 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
58808 * errno=ENXIO when there is no process reading the FIFO.
58809 */
58810 ret = -ENXIO;
58811 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
58812 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
58813 goto err;
58814
58815 pipe->w_counter++;
58816 - if (!pipe->writers++)
58817 + if (atomic_inc_return(&pipe->writers) == 1)
58818 wake_up_partner(pipe);
58819
58820 - if (!is_pipe && !pipe->readers) {
58821 + if (!is_pipe && !atomic_read(&pipe->readers)) {
58822 if (wait_for_partner(pipe, &pipe->r_counter))
58823 goto err_wr;
58824 }
58825 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
58826 * the process can at least talk to itself.
58827 */
58828
58829 - pipe->readers++;
58830 - pipe->writers++;
58831 + atomic_inc(&pipe->readers);
58832 + atomic_inc(&pipe->writers);
58833 pipe->r_counter++;
58834 pipe->w_counter++;
58835 - if (pipe->readers == 1 || pipe->writers == 1)
58836 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
58837 wake_up_partner(pipe);
58838 break;
58839
58840 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
58841 return 0;
58842
58843 err_rd:
58844 - if (!--pipe->readers)
58845 + if (atomic_dec_and_test(&pipe->readers))
58846 wake_up_interruptible(&pipe->wait);
58847 ret = -ERESTARTSYS;
58848 goto err;
58849
58850 err_wr:
58851 - if (!--pipe->writers)
58852 + if (atomic_dec_and_test(&pipe->writers))
58853 wake_up_interruptible(&pipe->wait);
58854 ret = -ERESTARTSYS;
58855 goto err;
58856
58857 err:
58858 spin_lock(&inode->i_lock);
58859 - if (!--pipe->files) {
58860 + if (atomic_dec_and_test(&pipe->files)) {
58861 inode->i_pipe = NULL;
58862 kill = 1;
58863 }
58864 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
58865 index 15af622..0e9f4467 100644
58866 --- a/fs/proc/Kconfig
58867 +++ b/fs/proc/Kconfig
58868 @@ -30,12 +30,12 @@ config PROC_FS
58869
58870 config PROC_KCORE
58871 bool "/proc/kcore support" if !ARM
58872 - depends on PROC_FS && MMU
58873 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
58874
58875 config PROC_VMCORE
58876 bool "/proc/vmcore support"
58877 - depends on PROC_FS && CRASH_DUMP
58878 - default y
58879 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
58880 + default n
58881 help
58882 Exports the dump image of crashed kernel in ELF format.
58883
58884 @@ -59,8 +59,8 @@ config PROC_SYSCTL
58885 limited in memory.
58886
58887 config PROC_PAGE_MONITOR
58888 - default y
58889 - depends on PROC_FS && MMU
58890 + default n
58891 + depends on PROC_FS && MMU && !GRKERNSEC
58892 bool "Enable /proc page monitoring" if EXPERT
58893 help
58894 Various /proc files exist to monitor process memory utilization:
58895 diff --git a/fs/proc/array.c b/fs/proc/array.c
58896 index cbd0f1b..adec3f0 100644
58897 --- a/fs/proc/array.c
58898 +++ b/fs/proc/array.c
58899 @@ -60,6 +60,7 @@
58900 #include <linux/tty.h>
58901 #include <linux/string.h>
58902 #include <linux/mman.h>
58903 +#include <linux/grsecurity.h>
58904 #include <linux/proc_fs.h>
58905 #include <linux/ioport.h>
58906 #include <linux/uaccess.h>
58907 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
58908 seq_putc(m, '\n');
58909 }
58910
58911 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58912 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
58913 +{
58914 + if (p->mm)
58915 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
58916 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
58917 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
58918 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
58919 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
58920 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
58921 + else
58922 + seq_printf(m, "PaX:\t-----\n");
58923 +}
58924 +#endif
58925 +
58926 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58927 struct pid *pid, struct task_struct *task)
58928 {
58929 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58930 task_cpus_allowed(m, task);
58931 cpuset_task_status_allowed(m, task);
58932 task_context_switch_counts(m, task);
58933 +
58934 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58935 + task_pax(m, task);
58936 +#endif
58937 +
58938 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
58939 + task_grsec_rbac(m, task);
58940 +#endif
58941 +
58942 return 0;
58943 }
58944
58945 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58946 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58947 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58948 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58949 +#endif
58950 +
58951 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58952 struct pid *pid, struct task_struct *task, int whole)
58953 {
58954 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58955 char tcomm[sizeof(task->comm)];
58956 unsigned long flags;
58957
58958 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58959 + if (current->exec_id != m->exec_id) {
58960 + gr_log_badprocpid("stat");
58961 + return 0;
58962 + }
58963 +#endif
58964 +
58965 state = *get_task_state(task);
58966 vsize = eip = esp = 0;
58967 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
58968 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58969 gtime = task_gtime(task);
58970 }
58971
58972 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58973 + if (PAX_RAND_FLAGS(mm)) {
58974 + eip = 0;
58975 + esp = 0;
58976 + wchan = 0;
58977 + }
58978 +#endif
58979 +#ifdef CONFIG_GRKERNSEC_HIDESYM
58980 + wchan = 0;
58981 + eip =0;
58982 + esp =0;
58983 +#endif
58984 +
58985 /* scale priority and nice values from timeslices to -20..20 */
58986 /* to make it look like a "normal" Unix priority/nice value */
58987 priority = task_prio(task);
58988 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58989 seq_put_decimal_ull(m, ' ', vsize);
58990 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
58991 seq_put_decimal_ull(m, ' ', rsslim);
58992 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58993 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
58994 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
58995 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
58996 +#else
58997 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
58998 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
58999 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
59000 +#endif
59001 seq_put_decimal_ull(m, ' ', esp);
59002 seq_put_decimal_ull(m, ' ', eip);
59003 /* The signal information here is obsolete.
59004 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59005 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
59006 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
59007
59008 - if (mm && permitted) {
59009 + if (mm && permitted
59010 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59011 + && !PAX_RAND_FLAGS(mm)
59012 +#endif
59013 + ) {
59014 seq_put_decimal_ull(m, ' ', mm->start_data);
59015 seq_put_decimal_ull(m, ' ', mm->end_data);
59016 seq_put_decimal_ull(m, ' ', mm->start_brk);
59017 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59018 struct pid *pid, struct task_struct *task)
59019 {
59020 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
59021 - struct mm_struct *mm = get_task_mm(task);
59022 + struct mm_struct *mm;
59023
59024 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59025 + if (current->exec_id != m->exec_id) {
59026 + gr_log_badprocpid("statm");
59027 + return 0;
59028 + }
59029 +#endif
59030 + mm = get_task_mm(task);
59031 if (mm) {
59032 size = task_statm(mm, &shared, &text, &data, &resident);
59033 mmput(mm);
59034 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59035 return 0;
59036 }
59037
59038 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59039 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59040 +{
59041 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59042 +}
59043 +#endif
59044 +
59045 #ifdef CONFIG_CHECKPOINT_RESTORE
59046 static struct pid *
59047 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59048 diff --git a/fs/proc/base.c b/fs/proc/base.c
59049 index 1485e38..8ad4236 100644
59050 --- a/fs/proc/base.c
59051 +++ b/fs/proc/base.c
59052 @@ -113,6 +113,14 @@ struct pid_entry {
59053 union proc_op op;
59054 };
59055
59056 +struct getdents_callback {
59057 + struct linux_dirent __user * current_dir;
59058 + struct linux_dirent __user * previous;
59059 + struct file * file;
59060 + int count;
59061 + int error;
59062 +};
59063 +
59064 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59065 .name = (NAME), \
59066 .len = sizeof(NAME) - 1, \
59067 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59068 if (!mm->arg_end)
59069 goto out_mm; /* Shh! No looking before we're done */
59070
59071 + if (gr_acl_handle_procpidmem(task))
59072 + goto out_mm;
59073 +
59074 len = mm->arg_end - mm->arg_start;
59075
59076 if (len > PAGE_SIZE)
59077 @@ -237,12 +248,28 @@ out:
59078 return res;
59079 }
59080
59081 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59082 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59083 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59084 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59085 +#endif
59086 +
59087 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59088 {
59089 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59090 int res = PTR_ERR(mm);
59091 if (mm && !IS_ERR(mm)) {
59092 unsigned int nwords = 0;
59093 +
59094 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59095 + /* allow if we're currently ptracing this task */
59096 + if (PAX_RAND_FLAGS(mm) &&
59097 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59098 + mmput(mm);
59099 + return 0;
59100 + }
59101 +#endif
59102 +
59103 do {
59104 nwords += 2;
59105 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59106 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59107 }
59108
59109
59110 -#ifdef CONFIG_KALLSYMS
59111 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59112 /*
59113 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59114 * Returns the resolved symbol. If that fails, simply return the address.
59115 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59116 mutex_unlock(&task->signal->cred_guard_mutex);
59117 }
59118
59119 -#ifdef CONFIG_STACKTRACE
59120 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59121
59122 #define MAX_STACK_TRACE_DEPTH 64
59123
59124 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59125 return count;
59126 }
59127
59128 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59129 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59130 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59131 {
59132 long nr;
59133 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59134 /************************************************************************/
59135
59136 /* permission checks */
59137 -static int proc_fd_access_allowed(struct inode *inode)
59138 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59139 {
59140 struct task_struct *task;
59141 int allowed = 0;
59142 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59143 */
59144 task = get_proc_task(inode);
59145 if (task) {
59146 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59147 + if (log)
59148 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59149 + else
59150 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59151 put_task_struct(task);
59152 }
59153 return allowed;
59154 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59155 struct task_struct *task,
59156 int hide_pid_min)
59157 {
59158 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59159 + return false;
59160 +
59161 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59162 + rcu_read_lock();
59163 + {
59164 + const struct cred *tmpcred = current_cred();
59165 + const struct cred *cred = __task_cred(task);
59166 +
59167 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59168 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59169 + || in_group_p(grsec_proc_gid)
59170 +#endif
59171 + ) {
59172 + rcu_read_unlock();
59173 + return true;
59174 + }
59175 + }
59176 + rcu_read_unlock();
59177 +
59178 + if (!pid->hide_pid)
59179 + return false;
59180 +#endif
59181 +
59182 if (pid->hide_pid < hide_pid_min)
59183 return true;
59184 if (in_group_p(pid->pid_gid))
59185 return true;
59186 +
59187 return ptrace_may_access(task, PTRACE_MODE_READ);
59188 }
59189
59190 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59191 put_task_struct(task);
59192
59193 if (!has_perms) {
59194 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59195 + {
59196 +#else
59197 if (pid->hide_pid == 2) {
59198 +#endif
59199 /*
59200 * Let's make getdents(), stat(), and open()
59201 * consistent with each other. If a process
59202 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59203 if (!task)
59204 return -ESRCH;
59205
59206 + if (gr_acl_handle_procpidmem(task)) {
59207 + put_task_struct(task);
59208 + return -EPERM;
59209 + }
59210 +
59211 mm = mm_access(task, mode);
59212 put_task_struct(task);
59213
59214 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59215
59216 file->private_data = mm;
59217
59218 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59219 + file->f_version = current->exec_id;
59220 +#endif
59221 +
59222 return 0;
59223 }
59224
59225 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59226 ssize_t copied;
59227 char *page;
59228
59229 +#ifdef CONFIG_GRKERNSEC
59230 + if (write)
59231 + return -EPERM;
59232 +#endif
59233 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59234 + if (file->f_version != current->exec_id) {
59235 + gr_log_badprocpid("mem");
59236 + return 0;
59237 + }
59238 +#endif
59239 +
59240 if (!mm)
59241 return 0;
59242
59243 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59244 goto free;
59245
59246 while (count > 0) {
59247 - int this_len = min_t(int, count, PAGE_SIZE);
59248 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59249
59250 if (write && copy_from_user(page, buf, this_len)) {
59251 copied = -EFAULT;
59252 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59253 if (!mm)
59254 return 0;
59255
59256 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59257 + if (file->f_version != current->exec_id) {
59258 + gr_log_badprocpid("environ");
59259 + return 0;
59260 + }
59261 +#endif
59262 +
59263 page = (char *)__get_free_page(GFP_TEMPORARY);
59264 if (!page)
59265 return -ENOMEM;
59266 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59267 goto free;
59268 while (count > 0) {
59269 size_t this_len, max_len;
59270 - int retval;
59271 + ssize_t retval;
59272
59273 if (src >= (mm->env_end - mm->env_start))
59274 break;
59275 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59276 int error = -EACCES;
59277
59278 /* Are we allowed to snoop on the tasks file descriptors? */
59279 - if (!proc_fd_access_allowed(inode))
59280 + if (!proc_fd_access_allowed(inode, 0))
59281 goto out;
59282
59283 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59284 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59285 struct path path;
59286
59287 /* Are we allowed to snoop on the tasks file descriptors? */
59288 - if (!proc_fd_access_allowed(inode))
59289 - goto out;
59290 + /* logging this is needed for learning on chromium to work properly,
59291 + but we don't want to flood the logs from 'ps' which does a readlink
59292 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59293 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59294 + */
59295 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59296 + if (!proc_fd_access_allowed(inode,0))
59297 + goto out;
59298 + } else {
59299 + if (!proc_fd_access_allowed(inode,1))
59300 + goto out;
59301 + }
59302
59303 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59304 if (error)
59305 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59306 rcu_read_lock();
59307 cred = __task_cred(task);
59308 inode->i_uid = cred->euid;
59309 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59310 + inode->i_gid = grsec_proc_gid;
59311 +#else
59312 inode->i_gid = cred->egid;
59313 +#endif
59314 rcu_read_unlock();
59315 }
59316 security_task_to_inode(task, inode);
59317 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59318 return -ENOENT;
59319 }
59320 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59321 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59322 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59323 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59324 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59325 +#endif
59326 task_dumpable(task)) {
59327 cred = __task_cred(task);
59328 stat->uid = cred->euid;
59329 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59330 + stat->gid = grsec_proc_gid;
59331 +#else
59332 stat->gid = cred->egid;
59333 +#endif
59334 }
59335 }
59336 rcu_read_unlock();
59337 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59338
59339 if (task) {
59340 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59341 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59342 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59343 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59344 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59345 +#endif
59346 task_dumpable(task)) {
59347 rcu_read_lock();
59348 cred = __task_cred(task);
59349 inode->i_uid = cred->euid;
59350 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59351 + inode->i_gid = grsec_proc_gid;
59352 +#else
59353 inode->i_gid = cred->egid;
59354 +#endif
59355 rcu_read_unlock();
59356 } else {
59357 inode->i_uid = GLOBAL_ROOT_UID;
59358 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59359 if (!task)
59360 goto out_no_task;
59361
59362 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59363 + goto out;
59364 +
59365 /*
59366 * Yes, it does not scale. And it should not. Don't add
59367 * new entries into /proc/<tgid>/ without very good reasons.
59368 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59369 if (!task)
59370 return -ENOENT;
59371
59372 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59373 + goto out;
59374 +
59375 if (!dir_emit_dots(file, ctx))
59376 goto out;
59377
59378 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59379 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59380 #endif
59381 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59382 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59383 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59384 INF("syscall", S_IRUGO, proc_pid_syscall),
59385 #endif
59386 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59387 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59388 #ifdef CONFIG_SECURITY
59389 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59390 #endif
59391 -#ifdef CONFIG_KALLSYMS
59392 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59393 INF("wchan", S_IRUGO, proc_pid_wchan),
59394 #endif
59395 -#ifdef CONFIG_STACKTRACE
59396 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59397 ONE("stack", S_IRUGO, proc_pid_stack),
59398 #endif
59399 #ifdef CONFIG_SCHEDSTATS
59400 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59401 #ifdef CONFIG_HARDWALL
59402 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59403 #endif
59404 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59405 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59406 +#endif
59407 #ifdef CONFIG_USER_NS
59408 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59409 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59410 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59411 if (!inode)
59412 goto out;
59413
59414 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59415 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59416 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59417 + inode->i_gid = grsec_proc_gid;
59418 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59419 +#else
59420 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59421 +#endif
59422 inode->i_op = &proc_tgid_base_inode_operations;
59423 inode->i_fop = &proc_tgid_base_operations;
59424 inode->i_flags|=S_IMMUTABLE;
59425 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59426 if (!task)
59427 goto out;
59428
59429 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59430 + goto out_put_task;
59431 +
59432 result = proc_pid_instantiate(dir, dentry, task, NULL);
59433 +out_put_task:
59434 put_task_struct(task);
59435 out:
59436 return ERR_PTR(result);
59437 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59438 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59439 #endif
59440 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59441 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59442 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59443 INF("syscall", S_IRUGO, proc_pid_syscall),
59444 #endif
59445 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59446 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59447 #ifdef CONFIG_SECURITY
59448 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59449 #endif
59450 -#ifdef CONFIG_KALLSYMS
59451 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59452 INF("wchan", S_IRUGO, proc_pid_wchan),
59453 #endif
59454 -#ifdef CONFIG_STACKTRACE
59455 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59456 ONE("stack", S_IRUGO, proc_pid_stack),
59457 #endif
59458 #ifdef CONFIG_SCHEDSTATS
59459 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59460 index 82676e3..5f8518a 100644
59461 --- a/fs/proc/cmdline.c
59462 +++ b/fs/proc/cmdline.c
59463 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59464
59465 static int __init proc_cmdline_init(void)
59466 {
59467 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59468 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59469 +#else
59470 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59471 +#endif
59472 return 0;
59473 }
59474 module_init(proc_cmdline_init);
59475 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59476 index b143471..bb105e5 100644
59477 --- a/fs/proc/devices.c
59478 +++ b/fs/proc/devices.c
59479 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59480
59481 static int __init proc_devices_init(void)
59482 {
59483 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59484 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
59485 +#else
59486 proc_create("devices", 0, NULL, &proc_devinfo_operations);
59487 +#endif
59488 return 0;
59489 }
59490 module_init(proc_devices_init);
59491 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
59492 index 0ff80f9..a1d7500 100644
59493 --- a/fs/proc/fd.c
59494 +++ b/fs/proc/fd.c
59495 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
59496 if (!task)
59497 return -ENOENT;
59498
59499 - files = get_files_struct(task);
59500 + if (!gr_acl_handle_procpidmem(task))
59501 + files = get_files_struct(task);
59502 put_task_struct(task);
59503
59504 if (files) {
59505 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
59506 */
59507 int proc_fd_permission(struct inode *inode, int mask)
59508 {
59509 + struct task_struct *task;
59510 int rv = generic_permission(inode, mask);
59511 - if (rv == 0)
59512 - return 0;
59513 +
59514 if (task_pid(current) == proc_pid(inode))
59515 rv = 0;
59516 +
59517 + task = get_proc_task(inode);
59518 + if (task == NULL)
59519 + return rv;
59520 +
59521 + if (gr_acl_handle_procpidmem(task))
59522 + rv = -EACCES;
59523 +
59524 + put_task_struct(task);
59525 +
59526 return rv;
59527 }
59528
59529 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
59530 index 073aea6..0630370 100644
59531 --- a/fs/proc/inode.c
59532 +++ b/fs/proc/inode.c
59533 @@ -23,11 +23,17 @@
59534 #include <linux/slab.h>
59535 #include <linux/mount.h>
59536 #include <linux/magic.h>
59537 +#include <linux/grsecurity.h>
59538
59539 #include <asm/uaccess.h>
59540
59541 #include "internal.h"
59542
59543 +#ifdef CONFIG_PROC_SYSCTL
59544 +extern const struct inode_operations proc_sys_inode_operations;
59545 +extern const struct inode_operations proc_sys_dir_operations;
59546 +#endif
59547 +
59548 static void proc_evict_inode(struct inode *inode)
59549 {
59550 struct proc_dir_entry *de;
59551 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
59552 ns = PROC_I(inode)->ns.ns;
59553 if (ns_ops && ns)
59554 ns_ops->put(ns);
59555 +
59556 +#ifdef CONFIG_PROC_SYSCTL
59557 + if (inode->i_op == &proc_sys_inode_operations ||
59558 + inode->i_op == &proc_sys_dir_operations)
59559 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
59560 +#endif
59561 +
59562 }
59563
59564 static struct kmem_cache * proc_inode_cachep;
59565 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
59566 if (de->mode) {
59567 inode->i_mode = de->mode;
59568 inode->i_uid = de->uid;
59569 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59570 + inode->i_gid = grsec_proc_gid;
59571 +#else
59572 inode->i_gid = de->gid;
59573 +#endif
59574 }
59575 if (de->size)
59576 inode->i_size = de->size;
59577 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
59578 index 651d09a..60c73ae 100644
59579 --- a/fs/proc/internal.h
59580 +++ b/fs/proc/internal.h
59581 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
59582 struct pid *, struct task_struct *);
59583 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
59584 struct pid *, struct task_struct *);
59585 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59586 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
59587 +#endif
59588
59589 /*
59590 * base.c
59591 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
59592 index 06ea155..9a798c7 100644
59593 --- a/fs/proc/kcore.c
59594 +++ b/fs/proc/kcore.c
59595 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59596 * the addresses in the elf_phdr on our list.
59597 */
59598 start = kc_offset_to_vaddr(*fpos - elf_buflen);
59599 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
59600 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
59601 + if (tsz > buflen)
59602 tsz = buflen;
59603 -
59604 +
59605 while (buflen) {
59606 struct kcore_list *m;
59607
59608 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59609 kfree(elf_buf);
59610 } else {
59611 if (kern_addr_valid(start)) {
59612 - unsigned long n;
59613 + char *elf_buf;
59614 + mm_segment_t oldfs;
59615
59616 - n = copy_to_user(buffer, (char *)start, tsz);
59617 - /*
59618 - * We cannot distinguish between fault on source
59619 - * and fault on destination. When this happens
59620 - * we clear too and hope it will trigger the
59621 - * EFAULT again.
59622 - */
59623 - if (n) {
59624 - if (clear_user(buffer + tsz - n,
59625 - n))
59626 + elf_buf = kmalloc(tsz, GFP_KERNEL);
59627 + if (!elf_buf)
59628 + return -ENOMEM;
59629 + oldfs = get_fs();
59630 + set_fs(KERNEL_DS);
59631 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
59632 + set_fs(oldfs);
59633 + if (copy_to_user(buffer, elf_buf, tsz)) {
59634 + kfree(elf_buf);
59635 return -EFAULT;
59636 + }
59637 }
59638 + set_fs(oldfs);
59639 + kfree(elf_buf);
59640 } else {
59641 if (clear_user(buffer, tsz))
59642 return -EFAULT;
59643 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59644
59645 static int open_kcore(struct inode *inode, struct file *filp)
59646 {
59647 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
59648 + return -EPERM;
59649 +#endif
59650 if (!capable(CAP_SYS_RAWIO))
59651 return -EPERM;
59652 if (kcore_need_update)
59653 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
59654 index 5aa847a..f77c8d4 100644
59655 --- a/fs/proc/meminfo.c
59656 +++ b/fs/proc/meminfo.c
59657 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
59658 vmi.used >> 10,
59659 vmi.largest_chunk >> 10
59660 #ifdef CONFIG_MEMORY_FAILURE
59661 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59662 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59663 #endif
59664 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
59665 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
59666 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
59667 index ccfd99b..1b7e255 100644
59668 --- a/fs/proc/nommu.c
59669 +++ b/fs/proc/nommu.c
59670 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
59671 if (len < 1)
59672 len = 1;
59673 seq_printf(m, "%*c", len, ' ');
59674 - seq_path(m, &file->f_path, "");
59675 + seq_path(m, &file->f_path, "\n\\");
59676 }
59677
59678 seq_putc(m, '\n');
59679 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
59680 index 4677bb7..408e936 100644
59681 --- a/fs/proc/proc_net.c
59682 +++ b/fs/proc/proc_net.c
59683 @@ -23,6 +23,7 @@
59684 #include <linux/nsproxy.h>
59685 #include <net/net_namespace.h>
59686 #include <linux/seq_file.h>
59687 +#include <linux/grsecurity.h>
59688
59689 #include "internal.h"
59690
59691 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
59692 struct task_struct *task;
59693 struct nsproxy *ns;
59694 struct net *net = NULL;
59695 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59696 + const struct cred *cred = current_cred();
59697 +#endif
59698 +
59699 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59700 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
59701 + return net;
59702 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59703 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
59704 + return net;
59705 +#endif
59706
59707 rcu_read_lock();
59708 task = pid_task(proc_pid(dir), PIDTYPE_PID);
59709 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
59710 index 7129046..130793a 100644
59711 --- a/fs/proc/proc_sysctl.c
59712 +++ b/fs/proc/proc_sysctl.c
59713 @@ -11,13 +11,18 @@
59714 #include <linux/namei.h>
59715 #include <linux/mm.h>
59716 #include <linux/module.h>
59717 +#include <linux/nsproxy.h>
59718 #include "internal.h"
59719
59720 +extern int gr_handle_chroot_sysctl(const int op);
59721 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
59722 + const int op);
59723 +
59724 static const struct dentry_operations proc_sys_dentry_operations;
59725 static const struct file_operations proc_sys_file_operations;
59726 -static const struct inode_operations proc_sys_inode_operations;
59727 +const struct inode_operations proc_sys_inode_operations;
59728 static const struct file_operations proc_sys_dir_file_operations;
59729 -static const struct inode_operations proc_sys_dir_operations;
59730 +const struct inode_operations proc_sys_dir_operations;
59731
59732 void proc_sys_poll_notify(struct ctl_table_poll *poll)
59733 {
59734 @@ -467,6 +472,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
59735
59736 err = NULL;
59737 d_set_d_op(dentry, &proc_sys_dentry_operations);
59738 +
59739 + gr_handle_proc_create(dentry, inode);
59740 +
59741 d_add(dentry, inode);
59742
59743 out:
59744 @@ -482,6 +490,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59745 struct inode *inode = file_inode(filp);
59746 struct ctl_table_header *head = grab_header(inode);
59747 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
59748 + int op = write ? MAY_WRITE : MAY_READ;
59749 ssize_t error;
59750 size_t res;
59751
59752 @@ -493,7 +502,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59753 * and won't be until we finish.
59754 */
59755 error = -EPERM;
59756 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
59757 + if (sysctl_perm(head, table, op))
59758 goto out;
59759
59760 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
59761 @@ -501,6 +510,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59762 if (!table->proc_handler)
59763 goto out;
59764
59765 +#ifdef CONFIG_GRKERNSEC
59766 + error = -EPERM;
59767 + if (gr_handle_chroot_sysctl(op))
59768 + goto out;
59769 + dget(filp->f_path.dentry);
59770 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
59771 + dput(filp->f_path.dentry);
59772 + goto out;
59773 + }
59774 + dput(filp->f_path.dentry);
59775 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
59776 + goto out;
59777 + if (write) {
59778 + if (current->nsproxy->net_ns != table->extra2) {
59779 + if (!capable(CAP_SYS_ADMIN))
59780 + goto out;
59781 + } else if (!nsown_capable(CAP_NET_ADMIN))
59782 + goto out;
59783 + }
59784 +#endif
59785 +
59786 /* careful: calling conventions are nasty here */
59787 res = count;
59788 error = table->proc_handler(table, write, buf, &res, ppos);
59789 @@ -598,6 +628,9 @@ static bool proc_sys_fill_cache(struct file *file,
59790 return false;
59791 } else {
59792 d_set_d_op(child, &proc_sys_dentry_operations);
59793 +
59794 + gr_handle_proc_create(child, inode);
59795 +
59796 d_add(child, inode);
59797 }
59798 } else {
59799 @@ -641,6 +674,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
59800 if ((*pos)++ < ctx->pos)
59801 return true;
59802
59803 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
59804 + return 0;
59805 +
59806 if (unlikely(S_ISLNK(table->mode)))
59807 res = proc_sys_link_fill_cache(file, ctx, head, table);
59808 else
59809 @@ -734,6 +770,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
59810 if (IS_ERR(head))
59811 return PTR_ERR(head);
59812
59813 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
59814 + return -ENOENT;
59815 +
59816 generic_fillattr(inode, stat);
59817 if (table)
59818 stat->mode = (stat->mode & S_IFMT) | table->mode;
59819 @@ -756,13 +795,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
59820 .llseek = generic_file_llseek,
59821 };
59822
59823 -static const struct inode_operations proc_sys_inode_operations = {
59824 +const struct inode_operations proc_sys_inode_operations = {
59825 .permission = proc_sys_permission,
59826 .setattr = proc_sys_setattr,
59827 .getattr = proc_sys_getattr,
59828 };
59829
59830 -static const struct inode_operations proc_sys_dir_operations = {
59831 +const struct inode_operations proc_sys_dir_operations = {
59832 .lookup = proc_sys_lookup,
59833 .permission = proc_sys_permission,
59834 .setattr = proc_sys_setattr,
59835 @@ -839,7 +878,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
59836 static struct ctl_dir *new_dir(struct ctl_table_set *set,
59837 const char *name, int namelen)
59838 {
59839 - struct ctl_table *table;
59840 + ctl_table_no_const *table;
59841 struct ctl_dir *new;
59842 struct ctl_node *node;
59843 char *new_name;
59844 @@ -851,7 +890,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
59845 return NULL;
59846
59847 node = (struct ctl_node *)(new + 1);
59848 - table = (struct ctl_table *)(node + 1);
59849 + table = (ctl_table_no_const *)(node + 1);
59850 new_name = (char *)(table + 2);
59851 memcpy(new_name, name, namelen);
59852 new_name[namelen] = '\0';
59853 @@ -1020,7 +1059,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
59854 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
59855 struct ctl_table_root *link_root)
59856 {
59857 - struct ctl_table *link_table, *entry, *link;
59858 + ctl_table_no_const *link_table, *link;
59859 + struct ctl_table *entry;
59860 struct ctl_table_header *links;
59861 struct ctl_node *node;
59862 char *link_name;
59863 @@ -1043,7 +1083,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
59864 return NULL;
59865
59866 node = (struct ctl_node *)(links + 1);
59867 - link_table = (struct ctl_table *)(node + nr_entries);
59868 + link_table = (ctl_table_no_const *)(node + nr_entries);
59869 link_name = (char *)&link_table[nr_entries + 1];
59870
59871 for (link = link_table, entry = table; entry->procname; link++, entry++) {
59872 @@ -1291,8 +1331,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59873 struct ctl_table_header ***subheader, struct ctl_table_set *set,
59874 struct ctl_table *table)
59875 {
59876 - struct ctl_table *ctl_table_arg = NULL;
59877 - struct ctl_table *entry, *files;
59878 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
59879 + struct ctl_table *entry;
59880 int nr_files = 0;
59881 int nr_dirs = 0;
59882 int err = -ENOMEM;
59883 @@ -1304,10 +1344,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59884 nr_files++;
59885 }
59886
59887 - files = table;
59888 /* If there are mixed files and directories we need a new table */
59889 if (nr_dirs && nr_files) {
59890 - struct ctl_table *new;
59891 + ctl_table_no_const *new;
59892 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
59893 GFP_KERNEL);
59894 if (!files)
59895 @@ -1325,7 +1364,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59896 /* Register everything except a directory full of subdirectories */
59897 if (nr_files || !nr_dirs) {
59898 struct ctl_table_header *header;
59899 - header = __register_sysctl_table(set, path, files);
59900 + header = __register_sysctl_table(set, path, files ? files : table);
59901 if (!header) {
59902 kfree(ctl_table_arg);
59903 goto out;
59904 diff --git a/fs/proc/root.c b/fs/proc/root.c
59905 index 0e0e83c..005ba6a 100644
59906 --- a/fs/proc/root.c
59907 +++ b/fs/proc/root.c
59908 @@ -183,7 +183,15 @@ void __init proc_root_init(void)
59909 #ifdef CONFIG_PROC_DEVICETREE
59910 proc_device_tree_init();
59911 #endif
59912 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59913 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59914 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
59915 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59916 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
59917 +#endif
59918 +#else
59919 proc_mkdir("bus", NULL);
59920 +#endif
59921 proc_sys_init();
59922 }
59923
59924 diff --git a/fs/proc/self.c b/fs/proc/self.c
59925 index 6b6a993..807cccc 100644
59926 --- a/fs/proc/self.c
59927 +++ b/fs/proc/self.c
59928 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
59929 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
59930 void *cookie)
59931 {
59932 - char *s = nd_get_link(nd);
59933 + const char *s = nd_get_link(nd);
59934 if (!IS_ERR(s))
59935 kfree(s);
59936 }
59937 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
59938 index 7a9e255..03763e3 100644
59939 --- a/fs/proc/task_mmu.c
59940 +++ b/fs/proc/task_mmu.c
59941 @@ -12,12 +12,19 @@
59942 #include <linux/swap.h>
59943 #include <linux/swapops.h>
59944 #include <linux/mmu_notifier.h>
59945 +#include <linux/grsecurity.h>
59946
59947 #include <asm/elf.h>
59948 #include <asm/uaccess.h>
59949 #include <asm/tlbflush.h>
59950 #include "internal.h"
59951
59952 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59953 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59954 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59955 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59956 +#endif
59957 +
59958 void task_mem(struct seq_file *m, struct mm_struct *mm)
59959 {
59960 unsigned long data, text, lib, swap;
59961 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59962 "VmExe:\t%8lu kB\n"
59963 "VmLib:\t%8lu kB\n"
59964 "VmPTE:\t%8lu kB\n"
59965 - "VmSwap:\t%8lu kB\n",
59966 - hiwater_vm << (PAGE_SHIFT-10),
59967 + "VmSwap:\t%8lu kB\n"
59968 +
59969 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59970 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
59971 +#endif
59972 +
59973 + ,hiwater_vm << (PAGE_SHIFT-10),
59974 total_vm << (PAGE_SHIFT-10),
59975 mm->locked_vm << (PAGE_SHIFT-10),
59976 mm->pinned_vm << (PAGE_SHIFT-10),
59977 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59978 data << (PAGE_SHIFT-10),
59979 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
59980 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
59981 - swap << (PAGE_SHIFT-10));
59982 + swap << (PAGE_SHIFT-10)
59983 +
59984 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59985 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59986 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
59987 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
59988 +#else
59989 + , mm->context.user_cs_base
59990 + , mm->context.user_cs_limit
59991 +#endif
59992 +#endif
59993 +
59994 + );
59995 }
59996
59997 unsigned long task_vsize(struct mm_struct *mm)
59998 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59999 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
60000 }
60001
60002 - /* We don't show the stack guard page in /proc/maps */
60003 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60004 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
60005 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
60006 +#else
60007 start = vma->vm_start;
60008 - if (stack_guard_page_start(vma, start))
60009 - start += PAGE_SIZE;
60010 end = vma->vm_end;
60011 - if (stack_guard_page_end(vma, end))
60012 - end -= PAGE_SIZE;
60013 +#endif
60014
60015 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
60016 start,
60017 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60018 flags & VM_WRITE ? 'w' : '-',
60019 flags & VM_EXEC ? 'x' : '-',
60020 flags & VM_MAYSHARE ? 's' : 'p',
60021 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60022 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
60023 +#else
60024 pgoff,
60025 +#endif
60026 MAJOR(dev), MINOR(dev), ino, &len);
60027
60028 /*
60029 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60030 */
60031 if (file) {
60032 pad_len_spaces(m, len);
60033 - seq_path(m, &file->f_path, "\n");
60034 + seq_path(m, &file->f_path, "\n\\");
60035 goto done;
60036 }
60037
60038 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60039 * Thread stack in /proc/PID/task/TID/maps or
60040 * the main process stack.
60041 */
60042 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60043 - vma->vm_end >= mm->start_stack)) {
60044 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60045 + (vma->vm_start <= mm->start_stack &&
60046 + vma->vm_end >= mm->start_stack)) {
60047 name = "[stack]";
60048 } else {
60049 /* Thread stack in /proc/PID/maps */
60050 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60051 struct proc_maps_private *priv = m->private;
60052 struct task_struct *task = priv->task;
60053
60054 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60055 + if (current->exec_id != m->exec_id) {
60056 + gr_log_badprocpid("maps");
60057 + return 0;
60058 + }
60059 +#endif
60060 +
60061 show_map_vma(m, vma, is_pid);
60062
60063 if (m->count < m->size) /* vma is copied successfully */
60064 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60065 .private = &mss,
60066 };
60067
60068 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60069 + if (current->exec_id != m->exec_id) {
60070 + gr_log_badprocpid("smaps");
60071 + return 0;
60072 + }
60073 +#endif
60074 memset(&mss, 0, sizeof mss);
60075 - mss.vma = vma;
60076 - /* mmap_sem is held in m_start */
60077 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60078 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60079 -
60080 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60081 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60082 +#endif
60083 + mss.vma = vma;
60084 + /* mmap_sem is held in m_start */
60085 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60086 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60087 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60088 + }
60089 +#endif
60090 show_map_vma(m, vma, is_pid);
60091
60092 seq_printf(m,
60093 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60094 "KernelPageSize: %8lu kB\n"
60095 "MMUPageSize: %8lu kB\n"
60096 "Locked: %8lu kB\n",
60097 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60098 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60099 +#else
60100 (vma->vm_end - vma->vm_start) >> 10,
60101 +#endif
60102 mss.resident >> 10,
60103 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60104 mss.shared_clean >> 10,
60105 @@ -1362,6 +1413,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60106 int n;
60107 char buffer[50];
60108
60109 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60110 + if (current->exec_id != m->exec_id) {
60111 + gr_log_badprocpid("numa_maps");
60112 + return 0;
60113 + }
60114 +#endif
60115 +
60116 if (!mm)
60117 return 0;
60118
60119 @@ -1379,11 +1437,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60120 mpol_to_str(buffer, sizeof(buffer), pol);
60121 mpol_cond_put(pol);
60122
60123 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60124 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60125 +#else
60126 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60127 +#endif
60128
60129 if (file) {
60130 seq_printf(m, " file=");
60131 - seq_path(m, &file->f_path, "\n\t= ");
60132 + seq_path(m, &file->f_path, "\n\t\\= ");
60133 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60134 seq_printf(m, " heap");
60135 } else {
60136 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60137 index 56123a6..5a2f6ec 100644
60138 --- a/fs/proc/task_nommu.c
60139 +++ b/fs/proc/task_nommu.c
60140 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60141 else
60142 bytes += kobjsize(mm);
60143
60144 - if (current->fs && current->fs->users > 1)
60145 + if (current->fs && atomic_read(&current->fs->users) > 1)
60146 sbytes += kobjsize(current->fs);
60147 else
60148 bytes += kobjsize(current->fs);
60149 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60150
60151 if (file) {
60152 pad_len_spaces(m, len);
60153 - seq_path(m, &file->f_path, "");
60154 + seq_path(m, &file->f_path, "\n\\");
60155 } else if (mm) {
60156 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60157
60158 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60159 index a1a16eb..6be46ed 100644
60160 --- a/fs/proc/vmcore.c
60161 +++ b/fs/proc/vmcore.c
60162 @@ -104,9 +104,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60163 nr_bytes = count;
60164
60165 /* If pfn is not ram, return zeros for sparse dump files */
60166 - if (pfn_is_ram(pfn) == 0)
60167 - memset(buf, 0, nr_bytes);
60168 - else {
60169 + if (pfn_is_ram(pfn) == 0) {
60170 + if (userbuf) {
60171 + if (clear_user((char __force_user *)buf, nr_bytes))
60172 + return -EFAULT;
60173 + } else
60174 + memset(buf, 0, nr_bytes);
60175 + } else {
60176 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60177 offset, userbuf);
60178 if (tmp < 0)
60179 @@ -178,7 +182,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
60180 if (*fpos < m->offset + m->size) {
60181 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60182 start = m->paddr + *fpos - m->offset;
60183 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
60184 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
60185 if (tmp < 0)
60186 return tmp;
60187 buflen -= tsz;
60188 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60189 index b00fcc9..e0c6381 100644
60190 --- a/fs/qnx6/qnx6.h
60191 +++ b/fs/qnx6/qnx6.h
60192 @@ -74,7 +74,7 @@ enum {
60193 BYTESEX_BE,
60194 };
60195
60196 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60197 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60198 {
60199 if (sbi->s_bytesex == BYTESEX_LE)
60200 return le64_to_cpu((__force __le64)n);
60201 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60202 return (__force __fs64)cpu_to_be64(n);
60203 }
60204
60205 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60206 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60207 {
60208 if (sbi->s_bytesex == BYTESEX_LE)
60209 return le32_to_cpu((__force __le32)n);
60210 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60211 index 16e8abb..2dcf914 100644
60212 --- a/fs/quota/netlink.c
60213 +++ b/fs/quota/netlink.c
60214 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60215 void quota_send_warning(struct kqid qid, dev_t dev,
60216 const char warntype)
60217 {
60218 - static atomic_t seq;
60219 + static atomic_unchecked_t seq;
60220 struct sk_buff *skb;
60221 void *msg_head;
60222 int ret;
60223 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60224 "VFS: Not enough memory to send quota warning.\n");
60225 return;
60226 }
60227 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60228 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60229 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60230 if (!msg_head) {
60231 printk(KERN_ERR
60232 diff --git a/fs/read_write.c b/fs/read_write.c
60233 index 122a384..0b7ecf2 100644
60234 --- a/fs/read_write.c
60235 +++ b/fs/read_write.c
60236 @@ -440,7 +440,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60237
60238 old_fs = get_fs();
60239 set_fs(get_ds());
60240 - p = (__force const char __user *)buf;
60241 + p = (const char __force_user *)buf;
60242 if (count > MAX_RW_COUNT)
60243 count = MAX_RW_COUNT;
60244 if (file->f_op->write)
60245 diff --git a/fs/readdir.c b/fs/readdir.c
60246 index 93d71e5..6a14be8 100644
60247 --- a/fs/readdir.c
60248 +++ b/fs/readdir.c
60249 @@ -17,6 +17,7 @@
60250 #include <linux/security.h>
60251 #include <linux/syscalls.h>
60252 #include <linux/unistd.h>
60253 +#include <linux/namei.h>
60254
60255 #include <asm/uaccess.h>
60256
60257 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60258 struct readdir_callback {
60259 struct dir_context ctx;
60260 struct old_linux_dirent __user * dirent;
60261 + struct file * file;
60262 int result;
60263 };
60264
60265 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60266 buf->result = -EOVERFLOW;
60267 return -EOVERFLOW;
60268 }
60269 +
60270 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60271 + return 0;
60272 +
60273 buf->result++;
60274 dirent = buf->dirent;
60275 if (!access_ok(VERIFY_WRITE, dirent,
60276 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60277 if (!f.file)
60278 return -EBADF;
60279
60280 + buf.file = f.file;
60281 error = iterate_dir(f.file, &buf.ctx);
60282 if (buf.result)
60283 error = buf.result;
60284 @@ -142,6 +149,7 @@ struct getdents_callback {
60285 struct dir_context ctx;
60286 struct linux_dirent __user * current_dir;
60287 struct linux_dirent __user * previous;
60288 + struct file * file;
60289 int count;
60290 int error;
60291 };
60292 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60293 buf->error = -EOVERFLOW;
60294 return -EOVERFLOW;
60295 }
60296 +
60297 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60298 + return 0;
60299 +
60300 dirent = buf->previous;
60301 if (dirent) {
60302 if (__put_user(offset, &dirent->d_off))
60303 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60304 if (!f.file)
60305 return -EBADF;
60306
60307 + buf.file = f.file;
60308 error = iterate_dir(f.file, &buf.ctx);
60309 if (error >= 0)
60310 error = buf.error;
60311 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60312 struct dir_context ctx;
60313 struct linux_dirent64 __user * current_dir;
60314 struct linux_dirent64 __user * previous;
60315 + struct file *file;
60316 int count;
60317 int error;
60318 };
60319 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60320 buf->error = -EINVAL; /* only used if we fail.. */
60321 if (reclen > buf->count)
60322 return -EINVAL;
60323 +
60324 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60325 + return 0;
60326 +
60327 dirent = buf->previous;
60328 if (dirent) {
60329 if (__put_user(offset, &dirent->d_off))
60330 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60331 if (!f.file)
60332 return -EBADF;
60333
60334 + buf.file = f.file;
60335 error = iterate_dir(f.file, &buf.ctx);
60336 if (error >= 0)
60337 error = buf.error;
60338 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60339 index 2b7882b..1c5ef48 100644
60340 --- a/fs/reiserfs/do_balan.c
60341 +++ b/fs/reiserfs/do_balan.c
60342 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60343 return;
60344 }
60345
60346 - atomic_inc(&(fs_generation(tb->tb_sb)));
60347 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60348 do_balance_starts(tb);
60349
60350 /* balance leaf returns 0 except if combining L R and S into
60351 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60352 index a958444..42b2323 100644
60353 --- a/fs/reiserfs/procfs.c
60354 +++ b/fs/reiserfs/procfs.c
60355 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60356 "SMALL_TAILS " : "NO_TAILS ",
60357 replay_only(sb) ? "REPLAY_ONLY " : "",
60358 convert_reiserfs(sb) ? "CONV " : "",
60359 - atomic_read(&r->s_generation_counter),
60360 + atomic_read_unchecked(&r->s_generation_counter),
60361 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60362 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60363 SF(s_good_search_by_key_reada), SF(s_bmaps),
60364 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60365 index 3df5ce6..8c0f4b0 100644
60366 --- a/fs/reiserfs/reiserfs.h
60367 +++ b/fs/reiserfs/reiserfs.h
60368 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60369 /* Comment? -Hans */
60370 wait_queue_head_t s_wait;
60371 /* To be obsoleted soon by per buffer seals.. -Hans */
60372 - atomic_t s_generation_counter; // increased by one every time the
60373 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60374 // tree gets re-balanced
60375 unsigned long s_properties; /* File system properties. Currently holds
60376 on-disk FS format */
60377 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60378 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60379
60380 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60381 -#define get_generation(s) atomic_read (&fs_generation(s))
60382 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60383 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60384 #define __fs_changed(gen,s) (gen != get_generation (s))
60385 #define fs_changed(gen,s) \
60386 diff --git a/fs/select.c b/fs/select.c
60387 index dfd5cb1..1754d57 100644
60388 --- a/fs/select.c
60389 +++ b/fs/select.c
60390 @@ -20,6 +20,7 @@
60391 #include <linux/export.h>
60392 #include <linux/slab.h>
60393 #include <linux/poll.h>
60394 +#include <linux/security.h>
60395 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60396 #include <linux/file.h>
60397 #include <linux/fdtable.h>
60398 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60399 struct poll_list *walk = head;
60400 unsigned long todo = nfds;
60401
60402 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60403 if (nfds > rlimit(RLIMIT_NOFILE))
60404 return -EINVAL;
60405
60406 diff --git a/fs/seq_file.c b/fs/seq_file.c
60407 index a290157..5fa85e4 100644
60408 --- a/fs/seq_file.c
60409 +++ b/fs/seq_file.c
60410 @@ -10,6 +10,7 @@
60411 #include <linux/seq_file.h>
60412 #include <linux/slab.h>
60413 #include <linux/cred.h>
60414 +#include <linux/sched.h>
60415
60416 #include <asm/uaccess.h>
60417 #include <asm/page.h>
60418 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60419 #ifdef CONFIG_USER_NS
60420 p->user_ns = file->f_cred->user_ns;
60421 #endif
60422 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60423 + p->exec_id = current->exec_id;
60424 +#endif
60425
60426 /*
60427 * Wrappers around seq_open(e.g. swaps_open) need to be
60428 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60429 return 0;
60430 }
60431 if (!m->buf) {
60432 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60433 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60434 if (!m->buf)
60435 return -ENOMEM;
60436 }
60437 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60438 Eoverflow:
60439 m->op->stop(m, p);
60440 kfree(m->buf);
60441 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60442 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60443 return !m->buf ? -ENOMEM : -EAGAIN;
60444 }
60445
60446 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60447
60448 /* grab buffer if we didn't have one */
60449 if (!m->buf) {
60450 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60451 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60452 if (!m->buf)
60453 goto Enomem;
60454 }
60455 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60456 goto Fill;
60457 m->op->stop(m, p);
60458 kfree(m->buf);
60459 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60460 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60461 if (!m->buf)
60462 goto Enomem;
60463 m->count = 0;
60464 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
60465 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60466 void *data)
60467 {
60468 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60469 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60470 int res = -ENOMEM;
60471
60472 if (op) {
60473 diff --git a/fs/splice.c b/fs/splice.c
60474 index 3b7ee65..87fc2e4 100644
60475 --- a/fs/splice.c
60476 +++ b/fs/splice.c
60477 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60478 pipe_lock(pipe);
60479
60480 for (;;) {
60481 - if (!pipe->readers) {
60482 + if (!atomic_read(&pipe->readers)) {
60483 send_sig(SIGPIPE, current, 0);
60484 if (!ret)
60485 ret = -EPIPE;
60486 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60487 page_nr++;
60488 ret += buf->len;
60489
60490 - if (pipe->files)
60491 + if (atomic_read(&pipe->files))
60492 do_wakeup = 1;
60493
60494 if (!--spd->nr_pages)
60495 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60496 do_wakeup = 0;
60497 }
60498
60499 - pipe->waiting_writers++;
60500 + atomic_inc(&pipe->waiting_writers);
60501 pipe_wait(pipe);
60502 - pipe->waiting_writers--;
60503 + atomic_dec(&pipe->waiting_writers);
60504 }
60505
60506 pipe_unlock(pipe);
60507 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
60508 old_fs = get_fs();
60509 set_fs(get_ds());
60510 /* The cast to a user pointer is valid due to the set_fs() */
60511 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
60512 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
60513 set_fs(old_fs);
60514
60515 return res;
60516 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
60517 old_fs = get_fs();
60518 set_fs(get_ds());
60519 /* The cast to a user pointer is valid due to the set_fs() */
60520 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
60521 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
60522 set_fs(old_fs);
60523
60524 return res;
60525 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
60526 goto err;
60527
60528 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
60529 - vec[i].iov_base = (void __user *) page_address(page);
60530 + vec[i].iov_base = (void __force_user *) page_address(page);
60531 vec[i].iov_len = this_len;
60532 spd.pages[i] = page;
60533 spd.nr_pages++;
60534 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
60535 ops->release(pipe, buf);
60536 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
60537 pipe->nrbufs--;
60538 - if (pipe->files)
60539 + if (atomic_read(&pipe->files))
60540 sd->need_wakeup = true;
60541 }
60542
60543 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
60544 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
60545 {
60546 while (!pipe->nrbufs) {
60547 - if (!pipe->writers)
60548 + if (!atomic_read(&pipe->writers))
60549 return 0;
60550
60551 - if (!pipe->waiting_writers && sd->num_spliced)
60552 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
60553 return 0;
60554
60555 if (sd->flags & SPLICE_F_NONBLOCK)
60556 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
60557 * out of the pipe right after the splice_to_pipe(). So set
60558 * PIPE_READERS appropriately.
60559 */
60560 - pipe->readers = 1;
60561 + atomic_set(&pipe->readers, 1);
60562
60563 current->splice_pipe = pipe;
60564 }
60565 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
60566
60567 partial[buffers].offset = off;
60568 partial[buffers].len = plen;
60569 + partial[buffers].private = 0;
60570
60571 off = 0;
60572 len -= plen;
60573 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60574 ret = -ERESTARTSYS;
60575 break;
60576 }
60577 - if (!pipe->writers)
60578 + if (!atomic_read(&pipe->writers))
60579 break;
60580 - if (!pipe->waiting_writers) {
60581 + if (!atomic_read(&pipe->waiting_writers)) {
60582 if (flags & SPLICE_F_NONBLOCK) {
60583 ret = -EAGAIN;
60584 break;
60585 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60586 pipe_lock(pipe);
60587
60588 while (pipe->nrbufs >= pipe->buffers) {
60589 - if (!pipe->readers) {
60590 + if (!atomic_read(&pipe->readers)) {
60591 send_sig(SIGPIPE, current, 0);
60592 ret = -EPIPE;
60593 break;
60594 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60595 ret = -ERESTARTSYS;
60596 break;
60597 }
60598 - pipe->waiting_writers++;
60599 + atomic_inc(&pipe->waiting_writers);
60600 pipe_wait(pipe);
60601 - pipe->waiting_writers--;
60602 + atomic_dec(&pipe->waiting_writers);
60603 }
60604
60605 pipe_unlock(pipe);
60606 @@ -1862,14 +1863,14 @@ retry:
60607 pipe_double_lock(ipipe, opipe);
60608
60609 do {
60610 - if (!opipe->readers) {
60611 + if (!atomic_read(&opipe->readers)) {
60612 send_sig(SIGPIPE, current, 0);
60613 if (!ret)
60614 ret = -EPIPE;
60615 break;
60616 }
60617
60618 - if (!ipipe->nrbufs && !ipipe->writers)
60619 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
60620 break;
60621
60622 /*
60623 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60624 pipe_double_lock(ipipe, opipe);
60625
60626 do {
60627 - if (!opipe->readers) {
60628 + if (!atomic_read(&opipe->readers)) {
60629 send_sig(SIGPIPE, current, 0);
60630 if (!ret)
60631 ret = -EPIPE;
60632 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60633 * return EAGAIN if we have the potential of some data in the
60634 * future, otherwise just return 0
60635 */
60636 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
60637 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
60638 ret = -EAGAIN;
60639
60640 pipe_unlock(ipipe);
60641 diff --git a/fs/stat.c b/fs/stat.c
60642 index 04ce1ac..a13dd1e 100644
60643 --- a/fs/stat.c
60644 +++ b/fs/stat.c
60645 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
60646 stat->gid = inode->i_gid;
60647 stat->rdev = inode->i_rdev;
60648 stat->size = i_size_read(inode);
60649 - stat->atime = inode->i_atime;
60650 - stat->mtime = inode->i_mtime;
60651 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60652 + stat->atime = inode->i_ctime;
60653 + stat->mtime = inode->i_ctime;
60654 + } else {
60655 + stat->atime = inode->i_atime;
60656 + stat->mtime = inode->i_mtime;
60657 + }
60658 stat->ctime = inode->i_ctime;
60659 stat->blksize = (1 << inode->i_blkbits);
60660 stat->blocks = inode->i_blocks;
60661 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
60662 if (retval)
60663 return retval;
60664
60665 - if (inode->i_op->getattr)
60666 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
60667 + if (inode->i_op->getattr) {
60668 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
60669 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60670 + stat->atime = stat->ctime;
60671 + stat->mtime = stat->ctime;
60672 + }
60673 + return retval;
60674 + }
60675
60676 generic_fillattr(inode, stat);
60677 return 0;
60678 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
60679 index 15c68f9..36a8b3e 100644
60680 --- a/fs/sysfs/bin.c
60681 +++ b/fs/sysfs/bin.c
60682 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
60683 return ret;
60684 }
60685
60686 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
60687 - void *buf, int len, int write)
60688 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
60689 + void *buf, size_t len, int write)
60690 {
60691 struct file *file = vma->vm_file;
60692 struct bin_buffer *bb = file->private_data;
60693 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
60694 - int ret;
60695 + ssize_t ret;
60696
60697 if (!bb->vm_ops)
60698 return -EINVAL;
60699 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
60700 index e068e74..92edeb8 100644
60701 --- a/fs/sysfs/dir.c
60702 +++ b/fs/sysfs/dir.c
60703 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
60704 *
60705 * Returns 31 bit hash of ns + name (so it fits in an off_t )
60706 */
60707 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
60708 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
60709 {
60710 unsigned long hash = init_name_hash();
60711 unsigned int len = strlen(name);
60712 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
60713 struct sysfs_dirent *sd;
60714 int rc;
60715
60716 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
60717 + const char *parent_name = parent_sd->s_name;
60718 +
60719 + mode = S_IFDIR | S_IRWXU;
60720 +
60721 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
60722 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
60723 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
60724 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
60725 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
60726 +#endif
60727 +
60728 /* allocate */
60729 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
60730 if (!sd)
60731 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
60732 index d2bb7ed..fe8c331 100644
60733 --- a/fs/sysfs/file.c
60734 +++ b/fs/sysfs/file.c
60735 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
60736
60737 struct sysfs_open_dirent {
60738 atomic_t refcnt;
60739 - atomic_t event;
60740 + atomic_unchecked_t event;
60741 wait_queue_head_t poll;
60742 struct list_head buffers; /* goes through sysfs_buffer.list */
60743 };
60744 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
60745 if (!sysfs_get_active(attr_sd))
60746 return -ENODEV;
60747
60748 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
60749 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
60750 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
60751
60752 sysfs_put_active(attr_sd);
60753 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
60754 return -ENOMEM;
60755
60756 atomic_set(&new_od->refcnt, 0);
60757 - atomic_set(&new_od->event, 1);
60758 + atomic_set_unchecked(&new_od->event, 1);
60759 init_waitqueue_head(&new_od->poll);
60760 INIT_LIST_HEAD(&new_od->buffers);
60761 goto retry;
60762 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
60763
60764 sysfs_put_active(attr_sd);
60765
60766 - if (buffer->event != atomic_read(&od->event))
60767 + if (buffer->event != atomic_read_unchecked(&od->event))
60768 goto trigger;
60769
60770 return DEFAULT_POLLMASK;
60771 @@ -452,7 +452,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
60772 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
60773 od = sd->s_attr.open;
60774 if (od) {
60775 - atomic_inc(&od->event);
60776 + atomic_inc_unchecked(&od->event);
60777 wake_up_interruptible(&od->poll);
60778 }
60779 }
60780 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
60781 index 8c940df..25b733e 100644
60782 --- a/fs/sysfs/symlink.c
60783 +++ b/fs/sysfs/symlink.c
60784 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
60785
60786 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
60787 {
60788 - char *page = nd_get_link(nd);
60789 + const char *page = nd_get_link(nd);
60790 if (!IS_ERR(page))
60791 free_page((unsigned long)page);
60792 }
60793 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
60794 index 69d4889..a810bd4 100644
60795 --- a/fs/sysv/sysv.h
60796 +++ b/fs/sysv/sysv.h
60797 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
60798 #endif
60799 }
60800
60801 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60802 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60803 {
60804 if (sbi->s_bytesex == BYTESEX_PDP)
60805 return PDP_swab((__force __u32)n);
60806 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
60807 index e18b988..f1d4ad0f 100644
60808 --- a/fs/ubifs/io.c
60809 +++ b/fs/ubifs/io.c
60810 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
60811 return err;
60812 }
60813
60814 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60815 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60816 {
60817 int err;
60818
60819 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
60820 index c175b4d..8f36a16 100644
60821 --- a/fs/udf/misc.c
60822 +++ b/fs/udf/misc.c
60823 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
60824
60825 u8 udf_tag_checksum(const struct tag *t)
60826 {
60827 - u8 *data = (u8 *)t;
60828 + const u8 *data = (const u8 *)t;
60829 u8 checksum = 0;
60830 int i;
60831 for (i = 0; i < sizeof(struct tag); ++i)
60832 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
60833 index 8d974c4..b82f6ec 100644
60834 --- a/fs/ufs/swab.h
60835 +++ b/fs/ufs/swab.h
60836 @@ -22,7 +22,7 @@ enum {
60837 BYTESEX_BE
60838 };
60839
60840 -static inline u64
60841 +static inline u64 __intentional_overflow(-1)
60842 fs64_to_cpu(struct super_block *sbp, __fs64 n)
60843 {
60844 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60845 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
60846 return (__force __fs64)cpu_to_be64(n);
60847 }
60848
60849 -static inline u32
60850 +static inline u32 __intentional_overflow(-1)
60851 fs32_to_cpu(struct super_block *sbp, __fs32 n)
60852 {
60853 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60854 diff --git a/fs/utimes.c b/fs/utimes.c
60855 index f4fb7ec..3fe03c0 100644
60856 --- a/fs/utimes.c
60857 +++ b/fs/utimes.c
60858 @@ -1,6 +1,7 @@
60859 #include <linux/compiler.h>
60860 #include <linux/file.h>
60861 #include <linux/fs.h>
60862 +#include <linux/security.h>
60863 #include <linux/linkage.h>
60864 #include <linux/mount.h>
60865 #include <linux/namei.h>
60866 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
60867 goto mnt_drop_write_and_out;
60868 }
60869 }
60870 +
60871 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
60872 + error = -EACCES;
60873 + goto mnt_drop_write_and_out;
60874 + }
60875 +
60876 mutex_lock(&inode->i_mutex);
60877 error = notify_change(path->dentry, &newattrs);
60878 mutex_unlock(&inode->i_mutex);
60879 diff --git a/fs/xattr.c b/fs/xattr.c
60880 index 3377dff..4d074d9 100644
60881 --- a/fs/xattr.c
60882 +++ b/fs/xattr.c
60883 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
60884 return rc;
60885 }
60886
60887 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
60888 +ssize_t
60889 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
60890 +{
60891 + struct inode *inode = dentry->d_inode;
60892 + ssize_t error;
60893 +
60894 + error = inode_permission(inode, MAY_EXEC);
60895 + if (error)
60896 + return error;
60897 +
60898 + if (inode->i_op->getxattr)
60899 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
60900 + else
60901 + error = -EOPNOTSUPP;
60902 +
60903 + return error;
60904 +}
60905 +EXPORT_SYMBOL(pax_getxattr);
60906 +#endif
60907 +
60908 ssize_t
60909 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
60910 {
60911 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
60912 * Extended attribute SET operations
60913 */
60914 static long
60915 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
60916 +setxattr(struct path *path, const char __user *name, const void __user *value,
60917 size_t size, int flags)
60918 {
60919 int error;
60920 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
60921 posix_acl_fix_xattr_from_user(kvalue, size);
60922 }
60923
60924 - error = vfs_setxattr(d, kname, kvalue, size, flags);
60925 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
60926 + error = -EACCES;
60927 + goto out;
60928 + }
60929 +
60930 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
60931 out:
60932 if (vvalue)
60933 vfree(vvalue);
60934 @@ -377,7 +403,7 @@ retry:
60935 return error;
60936 error = mnt_want_write(path.mnt);
60937 if (!error) {
60938 - error = setxattr(path.dentry, name, value, size, flags);
60939 + error = setxattr(&path, name, value, size, flags);
60940 mnt_drop_write(path.mnt);
60941 }
60942 path_put(&path);
60943 @@ -401,7 +427,7 @@ retry:
60944 return error;
60945 error = mnt_want_write(path.mnt);
60946 if (!error) {
60947 - error = setxattr(path.dentry, name, value, size, flags);
60948 + error = setxattr(&path, name, value, size, flags);
60949 mnt_drop_write(path.mnt);
60950 }
60951 path_put(&path);
60952 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
60953 const void __user *,value, size_t, size, int, flags)
60954 {
60955 struct fd f = fdget(fd);
60956 - struct dentry *dentry;
60957 int error = -EBADF;
60958
60959 if (!f.file)
60960 return error;
60961 - dentry = f.file->f_path.dentry;
60962 - audit_inode(NULL, dentry, 0);
60963 + audit_inode(NULL, f.file->f_path.dentry, 0);
60964 error = mnt_want_write_file(f.file);
60965 if (!error) {
60966 - error = setxattr(dentry, name, value, size, flags);
60967 + error = setxattr(&f.file->f_path, name, value, size, flags);
60968 mnt_drop_write_file(f.file);
60969 }
60970 fdput(f);
60971 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
60972 index 9fbea87..6b19972 100644
60973 --- a/fs/xattr_acl.c
60974 +++ b/fs/xattr_acl.c
60975 @@ -76,8 +76,8 @@ struct posix_acl *
60976 posix_acl_from_xattr(struct user_namespace *user_ns,
60977 const void *value, size_t size)
60978 {
60979 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
60980 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
60981 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
60982 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
60983 int count;
60984 struct posix_acl *acl;
60985 struct posix_acl_entry *acl_e;
60986 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
60987 index 05c698c..6b918af 100644
60988 --- a/fs/xfs/xfs_bmap.c
60989 +++ b/fs/xfs/xfs_bmap.c
60990 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
60991
60992 #else
60993 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
60994 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
60995 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
60996 #endif /* DEBUG */
60997
60998 /*
60999 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
61000 index 97676a3..399a75d 100644
61001 --- a/fs/xfs/xfs_dir2_sf.c
61002 +++ b/fs/xfs/xfs_dir2_sf.c
61003 @@ -848,7 +848,12 @@ xfs_dir2_sf_getdents(
61004
61005 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
61006 ctx->pos = off & 0x7fffffff;
61007 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61008 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
61009 + char name[sfep->namelen];
61010 + memcpy(name, sfep->name, sfep->namelen);
61011 + if (!dir_emit(ctx, name, sfep->namelen, ino, DT_UNKNOWN))
61012 + return 0;
61013 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61014 ino, DT_UNKNOWN))
61015 return 0;
61016 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
61017 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
61018 index 6e2bca5..6ce80d3 100644
61019 --- a/fs/xfs/xfs_ioctl.c
61020 +++ b/fs/xfs/xfs_ioctl.c
61021 @@ -127,7 +127,7 @@ xfs_find_handle(
61022 }
61023
61024 error = -EFAULT;
61025 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
61026 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
61027 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
61028 goto out_put;
61029
61030 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
61031 index 96dda62..d6c6a52 100644
61032 --- a/fs/xfs/xfs_iops.c
61033 +++ b/fs/xfs/xfs_iops.c
61034 @@ -395,7 +395,7 @@ xfs_vn_put_link(
61035 struct nameidata *nd,
61036 void *p)
61037 {
61038 - char *s = nd_get_link(nd);
61039 + const char *s = nd_get_link(nd);
61040
61041 if (!IS_ERR(s))
61042 kfree(s);
61043 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61044 new file mode 100644
61045 index 0000000..a326c8d
61046 --- /dev/null
61047 +++ b/grsecurity/Kconfig
61048 @@ -0,0 +1,1112 @@
61049 +#
61050 +# grecurity configuration
61051 +#
61052 +menu "Memory Protections"
61053 +depends on GRKERNSEC
61054 +
61055 +config GRKERNSEC_KMEM
61056 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61057 + default y if GRKERNSEC_CONFIG_AUTO
61058 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61059 + help
61060 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61061 + be written to or read from to modify or leak the contents of the running
61062 + kernel. /dev/port will also not be allowed to be opened and support
61063 + for /dev/cpu/*/msr will be removed. If you have module
61064 + support disabled, enabling this will close up five ways that are
61065 + currently used to insert malicious code into the running kernel.
61066 +
61067 + Even with all these features enabled, we still highly recommend that
61068 + you use the RBAC system, as it is still possible for an attacker to
61069 + modify the running kernel through privileged I/O granted by ioperm/iopl.
61070 +
61071 + If you are not using XFree86, you may be able to stop this additional
61072 + case by enabling the 'Disable privileged I/O' option. Though nothing
61073 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
61074 + but only to video memory, which is the only writing we allow in this
61075 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
61076 + not be allowed to mprotect it with PROT_WRITE later.
61077 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61078 + from working.
61079 +
61080 + It is highly recommended that you say Y here if you meet all the
61081 + conditions above.
61082 +
61083 +config GRKERNSEC_VM86
61084 + bool "Restrict VM86 mode"
61085 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61086 + depends on X86_32
61087 +
61088 + help
61089 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61090 + make use of a special execution mode on 32bit x86 processors called
61091 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61092 + video cards and will still work with this option enabled. The purpose
61093 + of the option is to prevent exploitation of emulation errors in
61094 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61095 + Nearly all users should be able to enable this option.
61096 +
61097 +config GRKERNSEC_IO
61098 + bool "Disable privileged I/O"
61099 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61100 + depends on X86
61101 + select RTC_CLASS
61102 + select RTC_INTF_DEV
61103 + select RTC_DRV_CMOS
61104 +
61105 + help
61106 + If you say Y here, all ioperm and iopl calls will return an error.
61107 + Ioperm and iopl can be used to modify the running kernel.
61108 + Unfortunately, some programs need this access to operate properly,
61109 + the most notable of which are XFree86 and hwclock. hwclock can be
61110 + remedied by having RTC support in the kernel, so real-time
61111 + clock support is enabled if this option is enabled, to ensure
61112 + that hwclock operates correctly. XFree86 still will not
61113 + operate correctly with this option enabled, so DO NOT CHOOSE Y
61114 + IF YOU USE XFree86. If you use XFree86 and you still want to
61115 + protect your kernel against modification, use the RBAC system.
61116 +
61117 +config GRKERNSEC_JIT_HARDEN
61118 + bool "Harden BPF JIT against spray attacks"
61119 + default y if GRKERNSEC_CONFIG_AUTO
61120 + depends on BPF_JIT
61121 + help
61122 + If you say Y here, the native code generated by the kernel's Berkeley
61123 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61124 + attacks that attempt to fit attacker-beneficial instructions in
61125 + 32bit immediate fields of JIT-generated native instructions. The
61126 + attacker will generally aim to cause an unintended instruction sequence
61127 + of JIT-generated native code to execute by jumping into the middle of
61128 + a generated instruction. This feature effectively randomizes the 32bit
61129 + immediate constants present in the generated code to thwart such attacks.
61130 +
61131 + If you're using KERNEXEC, it's recommended that you enable this option
61132 + to supplement the hardening of the kernel.
61133 +
61134 +config GRKERNSEC_PERF_HARDEN
61135 + bool "Disable unprivileged PERF_EVENTS usage by default"
61136 + default y if GRKERNSEC_CONFIG_AUTO
61137 + depends on PERF_EVENTS
61138 + help
61139 + If you say Y here, the range of acceptable values for the
61140 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61141 + default to a new value: 3. When the sysctl is set to this value, no
61142 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61143 +
61144 + Though PERF_EVENTS can be used legitimately for performance monitoring
61145 + and low-level application profiling, it is forced on regardless of
61146 + configuration, has been at fault for several vulnerabilities, and
61147 + creates new opportunities for side channels and other information leaks.
61148 +
61149 + This feature puts PERF_EVENTS into a secure default state and permits
61150 + the administrator to change out of it temporarily if unprivileged
61151 + application profiling is needed.
61152 +
61153 +config GRKERNSEC_RAND_THREADSTACK
61154 + bool "Insert random gaps between thread stacks"
61155 + default y if GRKERNSEC_CONFIG_AUTO
61156 + depends on PAX_RANDMMAP && !PPC
61157 + help
61158 + If you say Y here, a random-sized gap will be enforced between allocated
61159 + thread stacks. Glibc's NPTL and other threading libraries that
61160 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61161 + The implementation currently provides 8 bits of entropy for the gap.
61162 +
61163 + Many distributions do not compile threaded remote services with the
61164 + -fstack-check argument to GCC, causing the variable-sized stack-based
61165 + allocator, alloca(), to not probe the stack on allocation. This
61166 + permits an unbounded alloca() to skip over any guard page and potentially
61167 + modify another thread's stack reliably. An enforced random gap
61168 + reduces the reliability of such an attack and increases the chance
61169 + that such a read/write to another thread's stack instead lands in
61170 + an unmapped area, causing a crash and triggering grsecurity's
61171 + anti-bruteforcing logic.
61172 +
61173 +config GRKERNSEC_PROC_MEMMAP
61174 + bool "Harden ASLR against information leaks and entropy reduction"
61175 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61176 + depends on PAX_NOEXEC || PAX_ASLR
61177 + help
61178 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61179 + give no information about the addresses of its mappings if
61180 + PaX features that rely on random addresses are enabled on the task.
61181 + In addition to sanitizing this information and disabling other
61182 + dangerous sources of information, this option causes reads of sensitive
61183 + /proc/<pid> entries where the file descriptor was opened in a different
61184 + task than the one performing the read. Such attempts are logged.
61185 + This option also limits argv/env strings for suid/sgid binaries
61186 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61187 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61188 + binaries to prevent alternative mmap layouts from being abused.
61189 +
61190 + If you use PaX it is essential that you say Y here as it closes up
61191 + several holes that make full ASLR useless locally.
61192 +
61193 +config GRKERNSEC_BRUTE
61194 + bool "Deter exploit bruteforcing"
61195 + default y if GRKERNSEC_CONFIG_AUTO
61196 + help
61197 + If you say Y here, attempts to bruteforce exploits against forking
61198 + daemons such as apache or sshd, as well as against suid/sgid binaries
61199 + will be deterred. When a child of a forking daemon is killed by PaX
61200 + or crashes due to an illegal instruction or other suspicious signal,
61201 + the parent process will be delayed 30 seconds upon every subsequent
61202 + fork until the administrator is able to assess the situation and
61203 + restart the daemon.
61204 + In the suid/sgid case, the attempt is logged, the user has all their
61205 + existing instances of the suid/sgid binary terminated and will
61206 + be unable to execute any suid/sgid binaries for 15 minutes.
61207 +
61208 + It is recommended that you also enable signal logging in the auditing
61209 + section so that logs are generated when a process triggers a suspicious
61210 + signal.
61211 + If the sysctl option is enabled, a sysctl option with name
61212 + "deter_bruteforce" is created.
61213 +
61214 +
61215 +config GRKERNSEC_MODHARDEN
61216 + bool "Harden module auto-loading"
61217 + default y if GRKERNSEC_CONFIG_AUTO
61218 + depends on MODULES
61219 + help
61220 + If you say Y here, module auto-loading in response to use of some
61221 + feature implemented by an unloaded module will be restricted to
61222 + root users. Enabling this option helps defend against attacks
61223 + by unprivileged users who abuse the auto-loading behavior to
61224 + cause a vulnerable module to load that is then exploited.
61225 +
61226 + If this option prevents a legitimate use of auto-loading for a
61227 + non-root user, the administrator can execute modprobe manually
61228 + with the exact name of the module mentioned in the alert log.
61229 + Alternatively, the administrator can add the module to the list
61230 + of modules loaded at boot by modifying init scripts.
61231 +
61232 + Modification of init scripts will most likely be needed on
61233 + Ubuntu servers with encrypted home directory support enabled,
61234 + as the first non-root user logging in will cause the ecb(aes),
61235 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61236 +
61237 +config GRKERNSEC_HIDESYM
61238 + bool "Hide kernel symbols"
61239 + default y if GRKERNSEC_CONFIG_AUTO
61240 + select PAX_USERCOPY_SLABS
61241 + help
61242 + If you say Y here, getting information on loaded modules, and
61243 + displaying all kernel symbols through a syscall will be restricted
61244 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61245 + /proc/kallsyms will be restricted to the root user. The RBAC
61246 + system can hide that entry even from root.
61247 +
61248 + This option also prevents leaking of kernel addresses through
61249 + several /proc entries.
61250 +
61251 + Note that this option is only effective provided the following
61252 + conditions are met:
61253 + 1) The kernel using grsecurity is not precompiled by some distribution
61254 + 2) You have also enabled GRKERNSEC_DMESG
61255 + 3) You are using the RBAC system and hiding other files such as your
61256 + kernel image and System.map. Alternatively, enabling this option
61257 + causes the permissions on /boot, /lib/modules, and the kernel
61258 + source directory to change at compile time to prevent
61259 + reading by non-root users.
61260 + If the above conditions are met, this option will aid in providing a
61261 + useful protection against local kernel exploitation of overflows
61262 + and arbitrary read/write vulnerabilities.
61263 +
61264 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61265 + in addition to this feature.
61266 +
61267 +config GRKERNSEC_KERN_LOCKOUT
61268 + bool "Active kernel exploit response"
61269 + default y if GRKERNSEC_CONFIG_AUTO
61270 + depends on X86 || ARM || PPC || SPARC
61271 + help
61272 + If you say Y here, when a PaX alert is triggered due to suspicious
61273 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61274 + or an OOPS occurs due to bad memory accesses, instead of just
61275 + terminating the offending process (and potentially allowing
61276 + a subsequent exploit from the same user), we will take one of two
61277 + actions:
61278 + If the user was root, we will panic the system
61279 + If the user was non-root, we will log the attempt, terminate
61280 + all processes owned by the user, then prevent them from creating
61281 + any new processes until the system is restarted
61282 + This deters repeated kernel exploitation/bruteforcing attempts
61283 + and is useful for later forensics.
61284 +
61285 +config GRKERNSEC_OLD_ARM_USERLAND
61286 + bool "Old ARM userland compatibility"
61287 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
61288 + help
61289 + If you say Y here, stubs of executable code to perform such operations
61290 + as "compare-exchange" will be placed at fixed locations in the ARM vector
61291 + table. This is unfortunately needed for old ARM userland meant to run
61292 + across a wide range of processors. Without this option enabled,
61293 + the get_tls and data memory barrier stubs will be emulated by the kernel,
61294 + which is enough for Linaro userlands or other userlands designed for v6
61295 + and newer ARM CPUs. It's recommended that you try without this option enabled
61296 + first, and only enable it if your userland does not boot (it will likely fail
61297 + at init time).
61298 +
61299 +endmenu
61300 +menu "Role Based Access Control Options"
61301 +depends on GRKERNSEC
61302 +
61303 +config GRKERNSEC_RBAC_DEBUG
61304 + bool
61305 +
61306 +config GRKERNSEC_NO_RBAC
61307 + bool "Disable RBAC system"
61308 + help
61309 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61310 + preventing the RBAC system from being enabled. You should only say Y
61311 + here if you have no intention of using the RBAC system, so as to prevent
61312 + an attacker with root access from misusing the RBAC system to hide files
61313 + and processes when loadable module support and /dev/[k]mem have been
61314 + locked down.
61315 +
61316 +config GRKERNSEC_ACL_HIDEKERN
61317 + bool "Hide kernel processes"
61318 + help
61319 + If you say Y here, all kernel threads will be hidden to all
61320 + processes but those whose subject has the "view hidden processes"
61321 + flag.
61322 +
61323 +config GRKERNSEC_ACL_MAXTRIES
61324 + int "Maximum tries before password lockout"
61325 + default 3
61326 + help
61327 + This option enforces the maximum number of times a user can attempt
61328 + to authorize themselves with the grsecurity RBAC system before being
61329 + denied the ability to attempt authorization again for a specified time.
61330 + The lower the number, the harder it will be to brute-force a password.
61331 +
61332 +config GRKERNSEC_ACL_TIMEOUT
61333 + int "Time to wait after max password tries, in seconds"
61334 + default 30
61335 + help
61336 + This option specifies the time the user must wait after attempting to
61337 + authorize to the RBAC system with the maximum number of invalid
61338 + passwords. The higher the number, the harder it will be to brute-force
61339 + a password.
61340 +
61341 +endmenu
61342 +menu "Filesystem Protections"
61343 +depends on GRKERNSEC
61344 +
61345 +config GRKERNSEC_PROC
61346 + bool "Proc restrictions"
61347 + default y if GRKERNSEC_CONFIG_AUTO
61348 + help
61349 + If you say Y here, the permissions of the /proc filesystem
61350 + will be altered to enhance system security and privacy. You MUST
61351 + choose either a user only restriction or a user and group restriction.
61352 + Depending upon the option you choose, you can either restrict users to
61353 + see only the processes they themselves run, or choose a group that can
61354 + view all processes and files normally restricted to root if you choose
61355 + the "restrict to user only" option. NOTE: If you're running identd or
61356 + ntpd as a non-root user, you will have to run it as the group you
61357 + specify here.
61358 +
61359 +config GRKERNSEC_PROC_USER
61360 + bool "Restrict /proc to user only"
61361 + depends on GRKERNSEC_PROC
61362 + help
61363 + If you say Y here, non-root users will only be able to view their own
61364 + processes, and restricts them from viewing network-related information,
61365 + and viewing kernel symbol and module information.
61366 +
61367 +config GRKERNSEC_PROC_USERGROUP
61368 + bool "Allow special group"
61369 + default y if GRKERNSEC_CONFIG_AUTO
61370 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61371 + help
61372 + If you say Y here, you will be able to select a group that will be
61373 + able to view all processes and network-related information. If you've
61374 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61375 + remain hidden. This option is useful if you want to run identd as
61376 + a non-root user. The group you select may also be chosen at boot time
61377 + via "grsec_proc_gid=" on the kernel commandline.
61378 +
61379 +config GRKERNSEC_PROC_GID
61380 + int "GID for special group"
61381 + depends on GRKERNSEC_PROC_USERGROUP
61382 + default 1001
61383 +
61384 +config GRKERNSEC_PROC_ADD
61385 + bool "Additional restrictions"
61386 + default y if GRKERNSEC_CONFIG_AUTO
61387 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61388 + help
61389 + If you say Y here, additional restrictions will be placed on
61390 + /proc that keep normal users from viewing device information and
61391 + slabinfo information that could be useful for exploits.
61392 +
61393 +config GRKERNSEC_LINK
61394 + bool "Linking restrictions"
61395 + default y if GRKERNSEC_CONFIG_AUTO
61396 + help
61397 + If you say Y here, /tmp race exploits will be prevented, since users
61398 + will no longer be able to follow symlinks owned by other users in
61399 + world-writable +t directories (e.g. /tmp), unless the owner of the
61400 + symlink is the owner of the directory. users will also not be
61401 + able to hardlink to files they do not own. If the sysctl option is
61402 + enabled, a sysctl option with name "linking_restrictions" is created.
61403 +
61404 +config GRKERNSEC_SYMLINKOWN
61405 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61406 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61407 + help
61408 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61409 + that prevents it from being used as a security feature. As Apache
61410 + verifies the symlink by performing a stat() against the target of
61411 + the symlink before it is followed, an attacker can setup a symlink
61412 + to point to a same-owned file, then replace the symlink with one
61413 + that targets another user's file just after Apache "validates" the
61414 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61415 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61416 + will be in place for the group you specify. If the sysctl option
61417 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61418 + created.
61419 +
61420 +config GRKERNSEC_SYMLINKOWN_GID
61421 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61422 + depends on GRKERNSEC_SYMLINKOWN
61423 + default 1006
61424 + help
61425 + Setting this GID determines what group kernel-enforced
61426 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61427 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61428 +
61429 +config GRKERNSEC_FIFO
61430 + bool "FIFO restrictions"
61431 + default y if GRKERNSEC_CONFIG_AUTO
61432 + help
61433 + If you say Y here, users will not be able to write to FIFOs they don't
61434 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61435 + the FIFO is the same owner of the directory it's held in. If the sysctl
61436 + option is enabled, a sysctl option with name "fifo_restrictions" is
61437 + created.
61438 +
61439 +config GRKERNSEC_SYSFS_RESTRICT
61440 + bool "Sysfs/debugfs restriction"
61441 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61442 + depends on SYSFS
61443 + help
61444 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61445 + any filesystem normally mounted under it (e.g. debugfs) will be
61446 + mostly accessible only by root. These filesystems generally provide access
61447 + to hardware and debug information that isn't appropriate for unprivileged
61448 + users of the system. Sysfs and debugfs have also become a large source
61449 + of new vulnerabilities, ranging from infoleaks to local compromise.
61450 + There has been very little oversight with an eye toward security involved
61451 + in adding new exporters of information to these filesystems, so their
61452 + use is discouraged.
61453 + For reasons of compatibility, a few directories have been whitelisted
61454 + for access by non-root users:
61455 + /sys/fs/selinux
61456 + /sys/fs/fuse
61457 + /sys/devices/system/cpu
61458 +
61459 +config GRKERNSEC_ROFS
61460 + bool "Runtime read-only mount protection"
61461 + depends on SYSCTL
61462 + help
61463 + If you say Y here, a sysctl option with name "romount_protect" will
61464 + be created. By setting this option to 1 at runtime, filesystems
61465 + will be protected in the following ways:
61466 + * No new writable mounts will be allowed
61467 + * Existing read-only mounts won't be able to be remounted read/write
61468 + * Write operations will be denied on all block devices
61469 + This option acts independently of grsec_lock: once it is set to 1,
61470 + it cannot be turned off. Therefore, please be mindful of the resulting
61471 + behavior if this option is enabled in an init script on a read-only
61472 + filesystem. This feature is mainly intended for secure embedded systems.
61473 +
61474 +config GRKERNSEC_DEVICE_SIDECHANNEL
61475 + bool "Eliminate stat/notify-based device sidechannels"
61476 + default y if GRKERNSEC_CONFIG_AUTO
61477 + help
61478 + If you say Y here, timing analyses on block or character
61479 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
61480 + will be thwarted for unprivileged users. If a process without
61481 + CAP_MKNOD stats such a device, the last access and last modify times
61482 + will match the device's create time. No access or modify events
61483 + will be triggered through inotify/dnotify/fanotify for such devices.
61484 + This feature will prevent attacks that may at a minimum
61485 + allow an attacker to determine the administrator's password length.
61486 +
61487 +config GRKERNSEC_CHROOT
61488 + bool "Chroot jail restrictions"
61489 + default y if GRKERNSEC_CONFIG_AUTO
61490 + help
61491 + If you say Y here, you will be able to choose several options that will
61492 + make breaking out of a chrooted jail much more difficult. If you
61493 + encounter no software incompatibilities with the following options, it
61494 + is recommended that you enable each one.
61495 +
61496 +config GRKERNSEC_CHROOT_MOUNT
61497 + bool "Deny mounts"
61498 + default y if GRKERNSEC_CONFIG_AUTO
61499 + depends on GRKERNSEC_CHROOT
61500 + help
61501 + If you say Y here, processes inside a chroot will not be able to
61502 + mount or remount filesystems. If the sysctl option is enabled, a
61503 + sysctl option with name "chroot_deny_mount" is created.
61504 +
61505 +config GRKERNSEC_CHROOT_DOUBLE
61506 + bool "Deny double-chroots"
61507 + default y if GRKERNSEC_CONFIG_AUTO
61508 + depends on GRKERNSEC_CHROOT
61509 + help
61510 + If you say Y here, processes inside a chroot will not be able to chroot
61511 + again outside the chroot. This is a widely used method of breaking
61512 + out of a chroot jail and should not be allowed. If the sysctl
61513 + option is enabled, a sysctl option with name
61514 + "chroot_deny_chroot" is created.
61515 +
61516 +config GRKERNSEC_CHROOT_PIVOT
61517 + bool "Deny pivot_root in chroot"
61518 + default y if GRKERNSEC_CONFIG_AUTO
61519 + depends on GRKERNSEC_CHROOT
61520 + help
61521 + If you say Y here, processes inside a chroot will not be able to use
61522 + a function called pivot_root() that was introduced in Linux 2.3.41. It
61523 + works similar to chroot in that it changes the root filesystem. This
61524 + function could be misused in a chrooted process to attempt to break out
61525 + of the chroot, and therefore should not be allowed. If the sysctl
61526 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
61527 + created.
61528 +
61529 +config GRKERNSEC_CHROOT_CHDIR
61530 + bool "Enforce chdir(\"/\") on all chroots"
61531 + default y if GRKERNSEC_CONFIG_AUTO
61532 + depends on GRKERNSEC_CHROOT
61533 + help
61534 + If you say Y here, the current working directory of all newly-chrooted
61535 + applications will be set to the the root directory of the chroot.
61536 + The man page on chroot(2) states:
61537 + Note that this call does not change the current working
61538 + directory, so that `.' can be outside the tree rooted at
61539 + `/'. In particular, the super-user can escape from a
61540 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
61541 +
61542 + It is recommended that you say Y here, since it's not known to break
61543 + any software. If the sysctl option is enabled, a sysctl option with
61544 + name "chroot_enforce_chdir" is created.
61545 +
61546 +config GRKERNSEC_CHROOT_CHMOD
61547 + bool "Deny (f)chmod +s"
61548 + default y if GRKERNSEC_CONFIG_AUTO
61549 + depends on GRKERNSEC_CHROOT
61550 + help
61551 + If you say Y here, processes inside a chroot will not be able to chmod
61552 + or fchmod files to make them have suid or sgid bits. This protects
61553 + against another published method of breaking a chroot. If the sysctl
61554 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
61555 + created.
61556 +
61557 +config GRKERNSEC_CHROOT_FCHDIR
61558 + bool "Deny fchdir out of chroot"
61559 + default y if GRKERNSEC_CONFIG_AUTO
61560 + depends on GRKERNSEC_CHROOT
61561 + help
61562 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
61563 + to a file descriptor of the chrooting process that points to a directory
61564 + outside the filesystem will be stopped. If the sysctl option
61565 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
61566 +
61567 +config GRKERNSEC_CHROOT_MKNOD
61568 + bool "Deny mknod"
61569 + default y if GRKERNSEC_CONFIG_AUTO
61570 + depends on GRKERNSEC_CHROOT
61571 + help
61572 + If you say Y here, processes inside a chroot will not be allowed to
61573 + mknod. The problem with using mknod inside a chroot is that it
61574 + would allow an attacker to create a device entry that is the same
61575 + as one on the physical root of your system, which could range from
61576 + anything from the console device to a device for your harddrive (which
61577 + they could then use to wipe the drive or steal data). It is recommended
61578 + that you say Y here, unless you run into software incompatibilities.
61579 + If the sysctl option is enabled, a sysctl option with name
61580 + "chroot_deny_mknod" is created.
61581 +
61582 +config GRKERNSEC_CHROOT_SHMAT
61583 + bool "Deny shmat() out of chroot"
61584 + default y if GRKERNSEC_CONFIG_AUTO
61585 + depends on GRKERNSEC_CHROOT
61586 + help
61587 + If you say Y here, processes inside a chroot will not be able to attach
61588 + to shared memory segments that were created outside of the chroot jail.
61589 + It is recommended that you say Y here. If the sysctl option is enabled,
61590 + a sysctl option with name "chroot_deny_shmat" is created.
61591 +
61592 +config GRKERNSEC_CHROOT_UNIX
61593 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
61594 + default y if GRKERNSEC_CONFIG_AUTO
61595 + depends on GRKERNSEC_CHROOT
61596 + help
61597 + If you say Y here, processes inside a chroot will not be able to
61598 + connect to abstract (meaning not belonging to a filesystem) Unix
61599 + domain sockets that were bound outside of a chroot. It is recommended
61600 + that you say Y here. If the sysctl option is enabled, a sysctl option
61601 + with name "chroot_deny_unix" is created.
61602 +
61603 +config GRKERNSEC_CHROOT_FINDTASK
61604 + bool "Protect outside processes"
61605 + default y if GRKERNSEC_CONFIG_AUTO
61606 + depends on GRKERNSEC_CHROOT
61607 + help
61608 + If you say Y here, processes inside a chroot will not be able to
61609 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
61610 + getsid, or view any process outside of the chroot. If the sysctl
61611 + option is enabled, a sysctl option with name "chroot_findtask" is
61612 + created.
61613 +
61614 +config GRKERNSEC_CHROOT_NICE
61615 + bool "Restrict priority changes"
61616 + default y if GRKERNSEC_CONFIG_AUTO
61617 + depends on GRKERNSEC_CHROOT
61618 + help
61619 + If you say Y here, processes inside a chroot will not be able to raise
61620 + the priority of processes in the chroot, or alter the priority of
61621 + processes outside the chroot. This provides more security than simply
61622 + removing CAP_SYS_NICE from the process' capability set. If the
61623 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
61624 + is created.
61625 +
61626 +config GRKERNSEC_CHROOT_SYSCTL
61627 + bool "Deny sysctl writes"
61628 + default y if GRKERNSEC_CONFIG_AUTO
61629 + depends on GRKERNSEC_CHROOT
61630 + help
61631 + If you say Y here, an attacker in a chroot will not be able to
61632 + write to sysctl entries, either by sysctl(2) or through a /proc
61633 + interface. It is strongly recommended that you say Y here. If the
61634 + sysctl option is enabled, a sysctl option with name
61635 + "chroot_deny_sysctl" is created.
61636 +
61637 +config GRKERNSEC_CHROOT_CAPS
61638 + bool "Capability restrictions"
61639 + default y if GRKERNSEC_CONFIG_AUTO
61640 + depends on GRKERNSEC_CHROOT
61641 + help
61642 + If you say Y here, the capabilities on all processes within a
61643 + chroot jail will be lowered to stop module insertion, raw i/o,
61644 + system and net admin tasks, rebooting the system, modifying immutable
61645 + files, modifying IPC owned by another, and changing the system time.
61646 + This is left an option because it can break some apps. Disable this
61647 + if your chrooted apps are having problems performing those kinds of
61648 + tasks. If the sysctl option is enabled, a sysctl option with
61649 + name "chroot_caps" is created.
61650 +
61651 +config GRKERNSEC_CHROOT_INITRD
61652 + bool "Exempt initrd tasks from restrictions"
61653 + default y if GRKERNSEC_CONFIG_AUTO
61654 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
61655 + help
61656 + If you say Y here, tasks started prior to init will be exempted from
61657 + grsecurity's chroot restrictions. This option is mainly meant to
61658 + resolve Plymouth's performing privileged operations unnecessarily
61659 + in a chroot.
61660 +
61661 +endmenu
61662 +menu "Kernel Auditing"
61663 +depends on GRKERNSEC
61664 +
61665 +config GRKERNSEC_AUDIT_GROUP
61666 + bool "Single group for auditing"
61667 + help
61668 + If you say Y here, the exec and chdir logging features will only operate
61669 + on a group you specify. This option is recommended if you only want to
61670 + watch certain users instead of having a large amount of logs from the
61671 + entire system. If the sysctl option is enabled, a sysctl option with
61672 + name "audit_group" is created.
61673 +
61674 +config GRKERNSEC_AUDIT_GID
61675 + int "GID for auditing"
61676 + depends on GRKERNSEC_AUDIT_GROUP
61677 + default 1007
61678 +
61679 +config GRKERNSEC_EXECLOG
61680 + bool "Exec logging"
61681 + help
61682 + If you say Y here, all execve() calls will be logged (since the
61683 + other exec*() calls are frontends to execve(), all execution
61684 + will be logged). Useful for shell-servers that like to keep track
61685 + of their users. If the sysctl option is enabled, a sysctl option with
61686 + name "exec_logging" is created.
61687 + WARNING: This option when enabled will produce a LOT of logs, especially
61688 + on an active system.
61689 +
61690 +config GRKERNSEC_RESLOG
61691 + bool "Resource logging"
61692 + default y if GRKERNSEC_CONFIG_AUTO
61693 + help
61694 + If you say Y here, all attempts to overstep resource limits will
61695 + be logged with the resource name, the requested size, and the current
61696 + limit. It is highly recommended that you say Y here. If the sysctl
61697 + option is enabled, a sysctl option with name "resource_logging" is
61698 + created. If the RBAC system is enabled, the sysctl value is ignored.
61699 +
61700 +config GRKERNSEC_CHROOT_EXECLOG
61701 + bool "Log execs within chroot"
61702 + help
61703 + If you say Y here, all executions inside a chroot jail will be logged
61704 + to syslog. This can cause a large amount of logs if certain
61705 + applications (eg. djb's daemontools) are installed on the system, and
61706 + is therefore left as an option. If the sysctl option is enabled, a
61707 + sysctl option with name "chroot_execlog" is created.
61708 +
61709 +config GRKERNSEC_AUDIT_PTRACE
61710 + bool "Ptrace logging"
61711 + help
61712 + If you say Y here, all attempts to attach to a process via ptrace
61713 + will be logged. If the sysctl option is enabled, a sysctl option
61714 + with name "audit_ptrace" is created.
61715 +
61716 +config GRKERNSEC_AUDIT_CHDIR
61717 + bool "Chdir logging"
61718 + help
61719 + If you say Y here, all chdir() calls will be logged. If the sysctl
61720 + option is enabled, a sysctl option with name "audit_chdir" is created.
61721 +
61722 +config GRKERNSEC_AUDIT_MOUNT
61723 + bool "(Un)Mount logging"
61724 + help
61725 + If you say Y here, all mounts and unmounts will be logged. If the
61726 + sysctl option is enabled, a sysctl option with name "audit_mount" is
61727 + created.
61728 +
61729 +config GRKERNSEC_SIGNAL
61730 + bool "Signal logging"
61731 + default y if GRKERNSEC_CONFIG_AUTO
61732 + help
61733 + If you say Y here, certain important signals will be logged, such as
61734 + SIGSEGV, which will as a result inform you of when a error in a program
61735 + occurred, which in some cases could mean a possible exploit attempt.
61736 + If the sysctl option is enabled, a sysctl option with name
61737 + "signal_logging" is created.
61738 +
61739 +config GRKERNSEC_FORKFAIL
61740 + bool "Fork failure logging"
61741 + help
61742 + If you say Y here, all failed fork() attempts will be logged.
61743 + This could suggest a fork bomb, or someone attempting to overstep
61744 + their process limit. If the sysctl option is enabled, a sysctl option
61745 + with name "forkfail_logging" is created.
61746 +
61747 +config GRKERNSEC_TIME
61748 + bool "Time change logging"
61749 + default y if GRKERNSEC_CONFIG_AUTO
61750 + help
61751 + If you say Y here, any changes of the system clock will be logged.
61752 + If the sysctl option is enabled, a sysctl option with name
61753 + "timechange_logging" is created.
61754 +
61755 +config GRKERNSEC_PROC_IPADDR
61756 + bool "/proc/<pid>/ipaddr support"
61757 + default y if GRKERNSEC_CONFIG_AUTO
61758 + help
61759 + If you say Y here, a new entry will be added to each /proc/<pid>
61760 + directory that contains the IP address of the person using the task.
61761 + The IP is carried across local TCP and AF_UNIX stream sockets.
61762 + This information can be useful for IDS/IPSes to perform remote response
61763 + to a local attack. The entry is readable by only the owner of the
61764 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
61765 + the RBAC system), and thus does not create privacy concerns.
61766 +
61767 +config GRKERNSEC_RWXMAP_LOG
61768 + bool 'Denied RWX mmap/mprotect logging'
61769 + default y if GRKERNSEC_CONFIG_AUTO
61770 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
61771 + help
61772 + If you say Y here, calls to mmap() and mprotect() with explicit
61773 + usage of PROT_WRITE and PROT_EXEC together will be logged when
61774 + denied by the PAX_MPROTECT feature. This feature will also
61775 + log other problematic scenarios that can occur when PAX_MPROTECT
61776 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
61777 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
61778 + is created.
61779 +
61780 +endmenu
61781 +
61782 +menu "Executable Protections"
61783 +depends on GRKERNSEC
61784 +
61785 +config GRKERNSEC_DMESG
61786 + bool "Dmesg(8) restriction"
61787 + default y if GRKERNSEC_CONFIG_AUTO
61788 + help
61789 + If you say Y here, non-root users will not be able to use dmesg(8)
61790 + to view the contents of the kernel's circular log buffer.
61791 + The kernel's log buffer often contains kernel addresses and other
61792 + identifying information useful to an attacker in fingerprinting a
61793 + system for a targeted exploit.
61794 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
61795 + created.
61796 +
61797 +config GRKERNSEC_HARDEN_PTRACE
61798 + bool "Deter ptrace-based process snooping"
61799 + default y if GRKERNSEC_CONFIG_AUTO
61800 + help
61801 + If you say Y here, TTY sniffers and other malicious monitoring
61802 + programs implemented through ptrace will be defeated. If you
61803 + have been using the RBAC system, this option has already been
61804 + enabled for several years for all users, with the ability to make
61805 + fine-grained exceptions.
61806 +
61807 + This option only affects the ability of non-root users to ptrace
61808 + processes that are not a descendent of the ptracing process.
61809 + This means that strace ./binary and gdb ./binary will still work,
61810 + but attaching to arbitrary processes will not. If the sysctl
61811 + option is enabled, a sysctl option with name "harden_ptrace" is
61812 + created.
61813 +
61814 +config GRKERNSEC_PTRACE_READEXEC
61815 + bool "Require read access to ptrace sensitive binaries"
61816 + default y if GRKERNSEC_CONFIG_AUTO
61817 + help
61818 + If you say Y here, unprivileged users will not be able to ptrace unreadable
61819 + binaries. This option is useful in environments that
61820 + remove the read bits (e.g. file mode 4711) from suid binaries to
61821 + prevent infoleaking of their contents. This option adds
61822 + consistency to the use of that file mode, as the binary could normally
61823 + be read out when run without privileges while ptracing.
61824 +
61825 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
61826 + is created.
61827 +
61828 +config GRKERNSEC_SETXID
61829 + bool "Enforce consistent multithreaded privileges"
61830 + default y if GRKERNSEC_CONFIG_AUTO
61831 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
61832 + help
61833 + If you say Y here, a change from a root uid to a non-root uid
61834 + in a multithreaded application will cause the resulting uids,
61835 + gids, supplementary groups, and capabilities in that thread
61836 + to be propagated to the other threads of the process. In most
61837 + cases this is unnecessary, as glibc will emulate this behavior
61838 + on behalf of the application. Other libcs do not act in the
61839 + same way, allowing the other threads of the process to continue
61840 + running with root privileges. If the sysctl option is enabled,
61841 + a sysctl option with name "consistent_setxid" is created.
61842 +
61843 +config GRKERNSEC_HARDEN_IPC
61844 + bool "Disallow access to world-accessible IPC objects"
61845 + default y if GRKERNSEC_CONFIG_AUTO
61846 + depends on SYSVIPC
61847 + help
61848 + If you say Y here, access to overly-permissive IPC (shared memory,
61849 + message queues, and semaphores) will be denied for processes whose
61850 + effective user or group would not grant them permission. It's a
61851 + common error to grant too much permission to these objects, with
61852 + impact ranging from denial of service and information leaking to
61853 + privilege escalation. This feature was developed in response to
61854 + research by Tim Brown:
61855 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
61856 + who found hundreds of such insecure usages. Processes with
61857 + CAP_IPC_OWNER are still permitted to access these IPC objects.
61858 + If the sysctl option is enabled, a sysctl option with name
61859 + "harden_ipc" is created.
61860 +
61861 +config GRKERNSEC_TPE
61862 + bool "Trusted Path Execution (TPE)"
61863 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61864 + help
61865 + If you say Y here, you will be able to choose a gid to add to the
61866 + supplementary groups of users you want to mark as "untrusted."
61867 + These users will not be able to execute any files that are not in
61868 + root-owned directories writable only by root. If the sysctl option
61869 + is enabled, a sysctl option with name "tpe" is created.
61870 +
61871 +config GRKERNSEC_TPE_ALL
61872 + bool "Partially restrict all non-root users"
61873 + depends on GRKERNSEC_TPE
61874 + help
61875 + If you say Y here, all non-root users will be covered under
61876 + a weaker TPE restriction. This is separate from, and in addition to,
61877 + the main TPE options that you have selected elsewhere. Thus, if a
61878 + "trusted" GID is chosen, this restriction applies to even that GID.
61879 + Under this restriction, all non-root users will only be allowed to
61880 + execute files in directories they own that are not group or
61881 + world-writable, or in directories owned by root and writable only by
61882 + root. If the sysctl option is enabled, a sysctl option with name
61883 + "tpe_restrict_all" is created.
61884 +
61885 +config GRKERNSEC_TPE_INVERT
61886 + bool "Invert GID option"
61887 + depends on GRKERNSEC_TPE
61888 + help
61889 + If you say Y here, the group you specify in the TPE configuration will
61890 + decide what group TPE restrictions will be *disabled* for. This
61891 + option is useful if you want TPE restrictions to be applied to most
61892 + users on the system. If the sysctl option is enabled, a sysctl option
61893 + with name "tpe_invert" is created. Unlike other sysctl options, this
61894 + entry will default to on for backward-compatibility.
61895 +
61896 +config GRKERNSEC_TPE_GID
61897 + int
61898 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
61899 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
61900 +
61901 +config GRKERNSEC_TPE_UNTRUSTED_GID
61902 + int "GID for TPE-untrusted users"
61903 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
61904 + default 1005
61905 + help
61906 + Setting this GID determines what group TPE restrictions will be
61907 + *enabled* for. If the sysctl option is enabled, a sysctl option
61908 + with name "tpe_gid" is created.
61909 +
61910 +config GRKERNSEC_TPE_TRUSTED_GID
61911 + int "GID for TPE-trusted users"
61912 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
61913 + default 1005
61914 + help
61915 + Setting this GID determines what group TPE restrictions will be
61916 + *disabled* for. If the sysctl option is enabled, a sysctl option
61917 + with name "tpe_gid" is created.
61918 +
61919 +endmenu
61920 +menu "Network Protections"
61921 +depends on GRKERNSEC
61922 +
61923 +config GRKERNSEC_RANDNET
61924 + bool "Larger entropy pools"
61925 + default y if GRKERNSEC_CONFIG_AUTO
61926 + help
61927 + If you say Y here, the entropy pools used for many features of Linux
61928 + and grsecurity will be doubled in size. Since several grsecurity
61929 + features use additional randomness, it is recommended that you say Y
61930 + here. Saying Y here has a similar effect as modifying
61931 + /proc/sys/kernel/random/poolsize.
61932 +
61933 +config GRKERNSEC_BLACKHOLE
61934 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
61935 + default y if GRKERNSEC_CONFIG_AUTO
61936 + depends on NET
61937 + help
61938 + If you say Y here, neither TCP resets nor ICMP
61939 + destination-unreachable packets will be sent in response to packets
61940 + sent to ports for which no associated listening process exists.
61941 + This feature supports both IPV4 and IPV6 and exempts the
61942 + loopback interface from blackholing. Enabling this feature
61943 + makes a host more resilient to DoS attacks and reduces network
61944 + visibility against scanners.
61945 +
61946 + The blackhole feature as-implemented is equivalent to the FreeBSD
61947 + blackhole feature, as it prevents RST responses to all packets, not
61948 + just SYNs. Under most application behavior this causes no
61949 + problems, but applications (like haproxy) may not close certain
61950 + connections in a way that cleanly terminates them on the remote
61951 + end, leaving the remote host in LAST_ACK state. Because of this
61952 + side-effect and to prevent intentional LAST_ACK DoSes, this
61953 + feature also adds automatic mitigation against such attacks.
61954 + The mitigation drastically reduces the amount of time a socket
61955 + can spend in LAST_ACK state. If you're using haproxy and not
61956 + all servers it connects to have this option enabled, consider
61957 + disabling this feature on the haproxy host.
61958 +
61959 + If the sysctl option is enabled, two sysctl options with names
61960 + "ip_blackhole" and "lastack_retries" will be created.
61961 + While "ip_blackhole" takes the standard zero/non-zero on/off
61962 + toggle, "lastack_retries" uses the same kinds of values as
61963 + "tcp_retries1" and "tcp_retries2". The default value of 4
61964 + prevents a socket from lasting more than 45 seconds in LAST_ACK
61965 + state.
61966 +
61967 +config GRKERNSEC_NO_SIMULT_CONNECT
61968 + bool "Disable TCP Simultaneous Connect"
61969 + default y if GRKERNSEC_CONFIG_AUTO
61970 + depends on NET
61971 + help
61972 + If you say Y here, a feature by Willy Tarreau will be enabled that
61973 + removes a weakness in Linux's strict implementation of TCP that
61974 + allows two clients to connect to each other without either entering
61975 + a listening state. The weakness allows an attacker to easily prevent
61976 + a client from connecting to a known server provided the source port
61977 + for the connection is guessed correctly.
61978 +
61979 + As the weakness could be used to prevent an antivirus or IPS from
61980 + fetching updates, or prevent an SSL gateway from fetching a CRL,
61981 + it should be eliminated by enabling this option. Though Linux is
61982 + one of few operating systems supporting simultaneous connect, it
61983 + has no legitimate use in practice and is rarely supported by firewalls.
61984 +
61985 +config GRKERNSEC_SOCKET
61986 + bool "Socket restrictions"
61987 + depends on NET
61988 + help
61989 + If you say Y here, you will be able to choose from several options.
61990 + If you assign a GID on your system and add it to the supplementary
61991 + groups of users you want to restrict socket access to, this patch
61992 + will perform up to three things, based on the option(s) you choose.
61993 +
61994 +config GRKERNSEC_SOCKET_ALL
61995 + bool "Deny any sockets to group"
61996 + depends on GRKERNSEC_SOCKET
61997 + help
61998 + If you say Y here, you will be able to choose a GID of whose users will
61999 + be unable to connect to other hosts from your machine or run server
62000 + applications from your machine. If the sysctl option is enabled, a
62001 + sysctl option with name "socket_all" is created.
62002 +
62003 +config GRKERNSEC_SOCKET_ALL_GID
62004 + int "GID to deny all sockets for"
62005 + depends on GRKERNSEC_SOCKET_ALL
62006 + default 1004
62007 + help
62008 + Here you can choose the GID to disable socket access for. Remember to
62009 + add the users you want socket access disabled for to the GID
62010 + specified here. If the sysctl option is enabled, a sysctl option
62011 + with name "socket_all_gid" is created.
62012 +
62013 +config GRKERNSEC_SOCKET_CLIENT
62014 + bool "Deny client sockets to group"
62015 + depends on GRKERNSEC_SOCKET
62016 + help
62017 + If you say Y here, you will be able to choose a GID of whose users will
62018 + be unable to connect to other hosts from your machine, but will be
62019 + able to run servers. If this option is enabled, all users in the group
62020 + you specify will have to use passive mode when initiating ftp transfers
62021 + from the shell on your machine. If the sysctl option is enabled, a
62022 + sysctl option with name "socket_client" is created.
62023 +
62024 +config GRKERNSEC_SOCKET_CLIENT_GID
62025 + int "GID to deny client sockets for"
62026 + depends on GRKERNSEC_SOCKET_CLIENT
62027 + default 1003
62028 + help
62029 + Here you can choose the GID to disable client socket access for.
62030 + Remember to add the users you want client socket access disabled for to
62031 + the GID specified here. If the sysctl option is enabled, a sysctl
62032 + option with name "socket_client_gid" is created.
62033 +
62034 +config GRKERNSEC_SOCKET_SERVER
62035 + bool "Deny server sockets to group"
62036 + depends on GRKERNSEC_SOCKET
62037 + help
62038 + If you say Y here, you will be able to choose a GID of whose users will
62039 + be unable to run server applications from your machine. If the sysctl
62040 + option is enabled, a sysctl option with name "socket_server" is created.
62041 +
62042 +config GRKERNSEC_SOCKET_SERVER_GID
62043 + int "GID to deny server sockets for"
62044 + depends on GRKERNSEC_SOCKET_SERVER
62045 + default 1002
62046 + help
62047 + Here you can choose the GID to disable server socket access for.
62048 + Remember to add the users you want server socket access disabled for to
62049 + the GID specified here. If the sysctl option is enabled, a sysctl
62050 + option with name "socket_server_gid" is created.
62051 +
62052 +endmenu
62053 +
62054 +menu "Physical Protections"
62055 +depends on GRKERNSEC
62056 +
62057 +config GRKERNSEC_DENYUSB
62058 + bool "Deny new USB connections after toggle"
62059 + default y if GRKERNSEC_CONFIG_AUTO
62060 + depends on SYSCTL && USB_SUPPORT
62061 + help
62062 + If you say Y here, a new sysctl option with name "deny_new_usb"
62063 + will be created. Setting its value to 1 will prevent any new
62064 + USB devices from being recognized by the OS. Any attempted USB
62065 + device insertion will be logged. This option is intended to be
62066 + used against custom USB devices designed to exploit vulnerabilities
62067 + in various USB device drivers.
62068 +
62069 + For greatest effectiveness, this sysctl should be set after any
62070 + relevant init scripts. This option is safe to enable in distros
62071 + as each user can choose whether or not to toggle the sysctl.
62072 +
62073 +config GRKERNSEC_DENYUSB_FORCE
62074 + bool "Reject all USB devices not connected at boot"
62075 + select USB
62076 + depends on GRKERNSEC_DENYUSB
62077 + help
62078 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62079 + that doesn't involve a sysctl entry. This option should only be
62080 + enabled if you're sure you want to deny all new USB connections
62081 + at runtime and don't want to modify init scripts. This should not
62082 + be enabled by distros. It forces the core USB code to be built
62083 + into the kernel image so that all devices connected at boot time
62084 + can be recognized and new USB device connections can be prevented
62085 + prior to init running.
62086 +
62087 +endmenu
62088 +
62089 +menu "Sysctl Support"
62090 +depends on GRKERNSEC && SYSCTL
62091 +
62092 +config GRKERNSEC_SYSCTL
62093 + bool "Sysctl support"
62094 + default y if GRKERNSEC_CONFIG_AUTO
62095 + help
62096 + If you say Y here, you will be able to change the options that
62097 + grsecurity runs with at bootup, without having to recompile your
62098 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62099 + to enable (1) or disable (0) various features. All the sysctl entries
62100 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62101 + All features enabled in the kernel configuration are disabled at boot
62102 + if you do not say Y to the "Turn on features by default" option.
62103 + All options should be set at startup, and the grsec_lock entry should
62104 + be set to a non-zero value after all the options are set.
62105 + *THIS IS EXTREMELY IMPORTANT*
62106 +
62107 +config GRKERNSEC_SYSCTL_DISTRO
62108 + bool "Extra sysctl support for distro makers (READ HELP)"
62109 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62110 + help
62111 + If you say Y here, additional sysctl options will be created
62112 + for features that affect processes running as root. Therefore,
62113 + it is critical when using this option that the grsec_lock entry be
62114 + enabled after boot. Only distros with prebuilt kernel packages
62115 + with this option enabled that can ensure grsec_lock is enabled
62116 + after boot should use this option.
62117 + *Failure to set grsec_lock after boot makes all grsec features
62118 + this option covers useless*
62119 +
62120 + Currently this option creates the following sysctl entries:
62121 + "Disable Privileged I/O": "disable_priv_io"
62122 +
62123 +config GRKERNSEC_SYSCTL_ON
62124 + bool "Turn on features by default"
62125 + default y if GRKERNSEC_CONFIG_AUTO
62126 + depends on GRKERNSEC_SYSCTL
62127 + help
62128 + If you say Y here, instead of having all features enabled in the
62129 + kernel configuration disabled at boot time, the features will be
62130 + enabled at boot time. It is recommended you say Y here unless
62131 + there is some reason you would want all sysctl-tunable features to
62132 + be disabled by default. As mentioned elsewhere, it is important
62133 + to enable the grsec_lock entry once you have finished modifying
62134 + the sysctl entries.
62135 +
62136 +endmenu
62137 +menu "Logging Options"
62138 +depends on GRKERNSEC
62139 +
62140 +config GRKERNSEC_FLOODTIME
62141 + int "Seconds in between log messages (minimum)"
62142 + default 10
62143 + help
62144 + This option allows you to enforce the number of seconds between
62145 + grsecurity log messages. The default should be suitable for most
62146 + people, however, if you choose to change it, choose a value small enough
62147 + to allow informative logs to be produced, but large enough to
62148 + prevent flooding.
62149 +
62150 +config GRKERNSEC_FLOODBURST
62151 + int "Number of messages in a burst (maximum)"
62152 + default 6
62153 + help
62154 + This option allows you to choose the maximum number of messages allowed
62155 + within the flood time interval you chose in a separate option. The
62156 + default should be suitable for most people, however if you find that
62157 + many of your logs are being interpreted as flooding, you may want to
62158 + raise this value.
62159 +
62160 +endmenu
62161 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62162 new file mode 100644
62163 index 0000000..0bc0a5c
62164 --- /dev/null
62165 +++ b/grsecurity/Makefile
62166 @@ -0,0 +1,43 @@
62167 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62168 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62169 +# into an RBAC system
62170 +#
62171 +# All code in this directory and various hooks inserted throughout the kernel
62172 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62173 +# under the GPL v2 or higher
62174 +
62175 +KBUILD_CFLAGS += -Werror
62176 +
62177 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62178 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62179 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62180 + grsec_usb.o grsec_ipc.o
62181 +
62182 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62183 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62184 + gracl_learn.o grsec_log.o
62185 +ifdef CONFIG_COMPAT
62186 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62187 +endif
62188 +
62189 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62190 +
62191 +ifdef CONFIG_NET
62192 +obj-y += grsec_sock.o
62193 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62194 +endif
62195 +
62196 +ifndef CONFIG_GRKERNSEC
62197 +obj-y += grsec_disabled.o
62198 +endif
62199 +
62200 +ifdef CONFIG_GRKERNSEC_HIDESYM
62201 +extra-y := grsec_hidesym.o
62202 +$(obj)/grsec_hidesym.o:
62203 + @-chmod -f 500 /boot
62204 + @-chmod -f 500 /lib/modules
62205 + @-chmod -f 500 /lib64/modules
62206 + @-chmod -f 500 /lib32/modules
62207 + @-chmod -f 700 .
62208 + @echo ' grsec: protected kernel image paths'
62209 +endif
62210 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62211 new file mode 100644
62212 index 0000000..c0793fd
62213 --- /dev/null
62214 +++ b/grsecurity/gracl.c
62215 @@ -0,0 +1,4178 @@
62216 +#include <linux/kernel.h>
62217 +#include <linux/module.h>
62218 +#include <linux/sched.h>
62219 +#include <linux/mm.h>
62220 +#include <linux/file.h>
62221 +#include <linux/fs.h>
62222 +#include <linux/namei.h>
62223 +#include <linux/mount.h>
62224 +#include <linux/tty.h>
62225 +#include <linux/proc_fs.h>
62226 +#include <linux/lglock.h>
62227 +#include <linux/slab.h>
62228 +#include <linux/vmalloc.h>
62229 +#include <linux/types.h>
62230 +#include <linux/sysctl.h>
62231 +#include <linux/netdevice.h>
62232 +#include <linux/ptrace.h>
62233 +#include <linux/gracl.h>
62234 +#include <linux/gralloc.h>
62235 +#include <linux/security.h>
62236 +#include <linux/grinternal.h>
62237 +#include <linux/pid_namespace.h>
62238 +#include <linux/stop_machine.h>
62239 +#include <linux/fdtable.h>
62240 +#include <linux/percpu.h>
62241 +#include <linux/lglock.h>
62242 +#include <linux/hugetlb.h>
62243 +#include <linux/posix-timers.h>
62244 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62245 +#include <linux/magic.h>
62246 +#include <linux/pagemap.h>
62247 +#include "../fs/btrfs/async-thread.h"
62248 +#include "../fs/btrfs/ctree.h"
62249 +#include "../fs/btrfs/btrfs_inode.h"
62250 +#endif
62251 +#include "../fs/mount.h"
62252 +
62253 +#include <asm/uaccess.h>
62254 +#include <asm/errno.h>
62255 +#include <asm/mman.h>
62256 +
62257 +extern struct lglock vfsmount_lock;
62258 +
62259 +static struct acl_role_db acl_role_set;
62260 +static struct name_db name_set;
62261 +static struct inodev_db inodev_set;
62262 +
62263 +/* for keeping track of userspace pointers used for subjects, so we
62264 + can share references in the kernel as well
62265 +*/
62266 +
62267 +static struct path real_root;
62268 +
62269 +static struct acl_subj_map_db subj_map_set;
62270 +
62271 +static struct acl_role_label *default_role;
62272 +
62273 +static struct acl_role_label *role_list;
62274 +
62275 +static u16 acl_sp_role_value;
62276 +
62277 +extern char *gr_shared_page[4];
62278 +static DEFINE_MUTEX(gr_dev_mutex);
62279 +DEFINE_RWLOCK(gr_inode_lock);
62280 +
62281 +struct gr_arg *gr_usermode;
62282 +
62283 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62284 +
62285 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
62286 +extern void gr_clear_learn_entries(void);
62287 +
62288 +unsigned char *gr_system_salt;
62289 +unsigned char *gr_system_sum;
62290 +
62291 +static struct sprole_pw **acl_special_roles = NULL;
62292 +static __u16 num_sprole_pws = 0;
62293 +
62294 +static struct acl_role_label *kernel_role = NULL;
62295 +
62296 +static unsigned int gr_auth_attempts = 0;
62297 +static unsigned long gr_auth_expires = 0UL;
62298 +
62299 +#ifdef CONFIG_NET
62300 +extern struct vfsmount *sock_mnt;
62301 +#endif
62302 +
62303 +extern struct vfsmount *pipe_mnt;
62304 +extern struct vfsmount *shm_mnt;
62305 +
62306 +#ifdef CONFIG_HUGETLBFS
62307 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62308 +#endif
62309 +
62310 +static struct acl_object_label *fakefs_obj_rw;
62311 +static struct acl_object_label *fakefs_obj_rwx;
62312 +
62313 +extern int gr_init_uidset(void);
62314 +extern void gr_free_uidset(void);
62315 +extern void gr_remove_uid(uid_t uid);
62316 +extern int gr_find_uid(uid_t uid);
62317 +
62318 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
62319 +{
62320 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
62321 + return -EFAULT;
62322 +
62323 + return 0;
62324 +}
62325 +
62326 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
62327 +{
62328 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
62329 + return -EFAULT;
62330 +
62331 + return 0;
62332 +}
62333 +
62334 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
62335 +{
62336 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
62337 + return -EFAULT;
62338 +
62339 + return 0;
62340 +}
62341 +
62342 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
62343 +{
62344 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
62345 + return -EFAULT;
62346 +
62347 + return 0;
62348 +}
62349 +
62350 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
62351 +{
62352 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
62353 + return -EFAULT;
62354 +
62355 + return 0;
62356 +}
62357 +
62358 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
62359 +{
62360 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
62361 + return -EFAULT;
62362 +
62363 + return 0;
62364 +}
62365 +
62366 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
62367 +{
62368 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
62369 + return -EFAULT;
62370 +
62371 + return 0;
62372 +}
62373 +
62374 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
62375 +{
62376 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
62377 + return -EFAULT;
62378 +
62379 + return 0;
62380 +}
62381 +
62382 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
62383 +{
62384 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
62385 + return -EFAULT;
62386 +
62387 + return 0;
62388 +}
62389 +
62390 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
62391 +{
62392 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
62393 + return -EFAULT;
62394 +
62395 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
62396 + return -EINVAL;
62397 +
62398 + return 0;
62399 +}
62400 +
62401 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
62402 +{
62403 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
62404 + return -EFAULT;
62405 +
62406 + return 0;
62407 +}
62408 +
62409 +static size_t get_gr_arg_wrapper_size_normal(void)
62410 +{
62411 + return sizeof(struct gr_arg_wrapper);
62412 +}
62413 +
62414 +#ifdef CONFIG_COMPAT
62415 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
62416 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
62417 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
62418 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
62419 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
62420 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
62421 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
62422 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
62423 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
62424 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
62425 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
62426 +extern size_t get_gr_arg_wrapper_size_compat(void);
62427 +
62428 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
62429 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
62430 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
62431 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
62432 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
62433 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
62434 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
62435 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
62436 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
62437 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
62438 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
62439 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
62440 +
62441 +#else
62442 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
62443 +#define copy_gr_arg copy_gr_arg_normal
62444 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
62445 +#define copy_acl_object_label copy_acl_object_label_normal
62446 +#define copy_acl_subject_label copy_acl_subject_label_normal
62447 +#define copy_acl_role_label copy_acl_role_label_normal
62448 +#define copy_acl_ip_label copy_acl_ip_label_normal
62449 +#define copy_pointer_from_array copy_pointer_from_array_normal
62450 +#define copy_sprole_pw copy_sprole_pw_normal
62451 +#define copy_role_transition copy_role_transition_normal
62452 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
62453 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
62454 +#endif
62455 +
62456 +__inline__ int
62457 +gr_acl_is_enabled(void)
62458 +{
62459 + return (gr_status & GR_READY);
62460 +}
62461 +
62462 +static inline dev_t __get_dev(const struct dentry *dentry)
62463 +{
62464 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62465 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62466 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62467 + else
62468 +#endif
62469 + return dentry->d_sb->s_dev;
62470 +}
62471 +
62472 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62473 +{
62474 + return __get_dev(dentry);
62475 +}
62476 +
62477 +static char gr_task_roletype_to_char(struct task_struct *task)
62478 +{
62479 + switch (task->role->roletype &
62480 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62481 + GR_ROLE_SPECIAL)) {
62482 + case GR_ROLE_DEFAULT:
62483 + return 'D';
62484 + case GR_ROLE_USER:
62485 + return 'U';
62486 + case GR_ROLE_GROUP:
62487 + return 'G';
62488 + case GR_ROLE_SPECIAL:
62489 + return 'S';
62490 + }
62491 +
62492 + return 'X';
62493 +}
62494 +
62495 +char gr_roletype_to_char(void)
62496 +{
62497 + return gr_task_roletype_to_char(current);
62498 +}
62499 +
62500 +__inline__ int
62501 +gr_acl_tpe_check(void)
62502 +{
62503 + if (unlikely(!(gr_status & GR_READY)))
62504 + return 0;
62505 + if (current->role->roletype & GR_ROLE_TPE)
62506 + return 1;
62507 + else
62508 + return 0;
62509 +}
62510 +
62511 +int
62512 +gr_handle_rawio(const struct inode *inode)
62513 +{
62514 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62515 + if (inode && S_ISBLK(inode->i_mode) &&
62516 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62517 + !capable(CAP_SYS_RAWIO))
62518 + return 1;
62519 +#endif
62520 + return 0;
62521 +}
62522 +
62523 +static int
62524 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62525 +{
62526 + if (likely(lena != lenb))
62527 + return 0;
62528 +
62529 + return !memcmp(a, b, lena);
62530 +}
62531 +
62532 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62533 +{
62534 + *buflen -= namelen;
62535 + if (*buflen < 0)
62536 + return -ENAMETOOLONG;
62537 + *buffer -= namelen;
62538 + memcpy(*buffer, str, namelen);
62539 + return 0;
62540 +}
62541 +
62542 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62543 +{
62544 + return prepend(buffer, buflen, name->name, name->len);
62545 +}
62546 +
62547 +static int prepend_path(const struct path *path, struct path *root,
62548 + char **buffer, int *buflen)
62549 +{
62550 + struct dentry *dentry = path->dentry;
62551 + struct vfsmount *vfsmnt = path->mnt;
62552 + struct mount *mnt = real_mount(vfsmnt);
62553 + bool slash = false;
62554 + int error = 0;
62555 +
62556 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62557 + struct dentry * parent;
62558 +
62559 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62560 + /* Global root? */
62561 + if (!mnt_has_parent(mnt)) {
62562 + goto out;
62563 + }
62564 + dentry = mnt->mnt_mountpoint;
62565 + mnt = mnt->mnt_parent;
62566 + vfsmnt = &mnt->mnt;
62567 + continue;
62568 + }
62569 + parent = dentry->d_parent;
62570 + prefetch(parent);
62571 + spin_lock(&dentry->d_lock);
62572 + error = prepend_name(buffer, buflen, &dentry->d_name);
62573 + spin_unlock(&dentry->d_lock);
62574 + if (!error)
62575 + error = prepend(buffer, buflen, "/", 1);
62576 + if (error)
62577 + break;
62578 +
62579 + slash = true;
62580 + dentry = parent;
62581 + }
62582 +
62583 +out:
62584 + if (!error && !slash)
62585 + error = prepend(buffer, buflen, "/", 1);
62586 +
62587 + return error;
62588 +}
62589 +
62590 +/* this must be called with vfsmount_lock and rename_lock held */
62591 +
62592 +static char *__our_d_path(const struct path *path, struct path *root,
62593 + char *buf, int buflen)
62594 +{
62595 + char *res = buf + buflen;
62596 + int error;
62597 +
62598 + prepend(&res, &buflen, "\0", 1);
62599 + error = prepend_path(path, root, &res, &buflen);
62600 + if (error)
62601 + return ERR_PTR(error);
62602 +
62603 + return res;
62604 +}
62605 +
62606 +static char *
62607 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62608 +{
62609 + char *retval;
62610 +
62611 + retval = __our_d_path(path, root, buf, buflen);
62612 + if (unlikely(IS_ERR(retval)))
62613 + retval = strcpy(buf, "<path too long>");
62614 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62615 + retval[1] = '\0';
62616 +
62617 + return retval;
62618 +}
62619 +
62620 +static char *
62621 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62622 + char *buf, int buflen)
62623 +{
62624 + struct path path;
62625 + char *res;
62626 +
62627 + path.dentry = (struct dentry *)dentry;
62628 + path.mnt = (struct vfsmount *)vfsmnt;
62629 +
62630 + /* we can use real_root.dentry, real_root.mnt, because this is only called
62631 + by the RBAC system */
62632 + res = gen_full_path(&path, &real_root, buf, buflen);
62633 +
62634 + return res;
62635 +}
62636 +
62637 +static char *
62638 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62639 + char *buf, int buflen)
62640 +{
62641 + char *res;
62642 + struct path path;
62643 + struct path root;
62644 + struct task_struct *reaper = init_pid_ns.child_reaper;
62645 +
62646 + path.dentry = (struct dentry *)dentry;
62647 + path.mnt = (struct vfsmount *)vfsmnt;
62648 +
62649 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
62650 + get_fs_root(reaper->fs, &root);
62651 +
62652 + br_read_lock(&vfsmount_lock);
62653 + write_seqlock(&rename_lock);
62654 + res = gen_full_path(&path, &root, buf, buflen);
62655 + write_sequnlock(&rename_lock);
62656 + br_read_unlock(&vfsmount_lock);
62657 +
62658 + path_put(&root);
62659 + return res;
62660 +}
62661 +
62662 +static char *
62663 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62664 +{
62665 + char *ret;
62666 + br_read_lock(&vfsmount_lock);
62667 + write_seqlock(&rename_lock);
62668 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62669 + PAGE_SIZE);
62670 + write_sequnlock(&rename_lock);
62671 + br_read_unlock(&vfsmount_lock);
62672 + return ret;
62673 +}
62674 +
62675 +static char *
62676 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62677 +{
62678 + char *ret;
62679 + char *buf;
62680 + int buflen;
62681 +
62682 + br_read_lock(&vfsmount_lock);
62683 + write_seqlock(&rename_lock);
62684 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
62685 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
62686 + buflen = (int)(ret - buf);
62687 + if (buflen >= 5)
62688 + prepend(&ret, &buflen, "/proc", 5);
62689 + else
62690 + ret = strcpy(buf, "<path too long>");
62691 + write_sequnlock(&rename_lock);
62692 + br_read_unlock(&vfsmount_lock);
62693 + return ret;
62694 +}
62695 +
62696 +char *
62697 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
62698 +{
62699 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62700 + PAGE_SIZE);
62701 +}
62702 +
62703 +char *
62704 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
62705 +{
62706 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62707 + PAGE_SIZE);
62708 +}
62709 +
62710 +char *
62711 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
62712 +{
62713 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
62714 + PAGE_SIZE);
62715 +}
62716 +
62717 +char *
62718 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
62719 +{
62720 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
62721 + PAGE_SIZE);
62722 +}
62723 +
62724 +char *
62725 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
62726 +{
62727 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
62728 + PAGE_SIZE);
62729 +}
62730 +
62731 +__inline__ __u32
62732 +to_gr_audit(const __u32 reqmode)
62733 +{
62734 + /* masks off auditable permission flags, then shifts them to create
62735 + auditing flags, and adds the special case of append auditing if
62736 + we're requesting write */
62737 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
62738 +}
62739 +
62740 +struct acl_subject_label *
62741 +lookup_subject_map(const struct acl_subject_label *userp)
62742 +{
62743 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
62744 + struct subject_map *match;
62745 +
62746 + match = subj_map_set.s_hash[index];
62747 +
62748 + while (match && match->user != userp)
62749 + match = match->next;
62750 +
62751 + if (match != NULL)
62752 + return match->kernel;
62753 + else
62754 + return NULL;
62755 +}
62756 +
62757 +static void
62758 +insert_subj_map_entry(struct subject_map *subjmap)
62759 +{
62760 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
62761 + struct subject_map **curr;
62762 +
62763 + subjmap->prev = NULL;
62764 +
62765 + curr = &subj_map_set.s_hash[index];
62766 + if (*curr != NULL)
62767 + (*curr)->prev = subjmap;
62768 +
62769 + subjmap->next = *curr;
62770 + *curr = subjmap;
62771 +
62772 + return;
62773 +}
62774 +
62775 +static struct acl_role_label *
62776 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
62777 + const gid_t gid)
62778 +{
62779 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
62780 + struct acl_role_label *match;
62781 + struct role_allowed_ip *ipp;
62782 + unsigned int x;
62783 + u32 curr_ip = task->signal->curr_ip;
62784 +
62785 + task->signal->saved_ip = curr_ip;
62786 +
62787 + match = acl_role_set.r_hash[index];
62788 +
62789 + while (match) {
62790 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
62791 + for (x = 0; x < match->domain_child_num; x++) {
62792 + if (match->domain_children[x] == uid)
62793 + goto found;
62794 + }
62795 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
62796 + break;
62797 + match = match->next;
62798 + }
62799 +found:
62800 + if (match == NULL) {
62801 + try_group:
62802 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
62803 + match = acl_role_set.r_hash[index];
62804 +
62805 + while (match) {
62806 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
62807 + for (x = 0; x < match->domain_child_num; x++) {
62808 + if (match->domain_children[x] == gid)
62809 + goto found2;
62810 + }
62811 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
62812 + break;
62813 + match = match->next;
62814 + }
62815 +found2:
62816 + if (match == NULL)
62817 + match = default_role;
62818 + if (match->allowed_ips == NULL)
62819 + return match;
62820 + else {
62821 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62822 + if (likely
62823 + ((ntohl(curr_ip) & ipp->netmask) ==
62824 + (ntohl(ipp->addr) & ipp->netmask)))
62825 + return match;
62826 + }
62827 + match = default_role;
62828 + }
62829 + } else if (match->allowed_ips == NULL) {
62830 + return match;
62831 + } else {
62832 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62833 + if (likely
62834 + ((ntohl(curr_ip) & ipp->netmask) ==
62835 + (ntohl(ipp->addr) & ipp->netmask)))
62836 + return match;
62837 + }
62838 + goto try_group;
62839 + }
62840 +
62841 + return match;
62842 +}
62843 +
62844 +struct acl_subject_label *
62845 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
62846 + const struct acl_role_label *role)
62847 +{
62848 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62849 + struct acl_subject_label *match;
62850 +
62851 + match = role->subj_hash[index];
62852 +
62853 + while (match && (match->inode != ino || match->device != dev ||
62854 + (match->mode & GR_DELETED))) {
62855 + match = match->next;
62856 + }
62857 +
62858 + if (match && !(match->mode & GR_DELETED))
62859 + return match;
62860 + else
62861 + return NULL;
62862 +}
62863 +
62864 +struct acl_subject_label *
62865 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
62866 + const struct acl_role_label *role)
62867 +{
62868 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62869 + struct acl_subject_label *match;
62870 +
62871 + match = role->subj_hash[index];
62872 +
62873 + while (match && (match->inode != ino || match->device != dev ||
62874 + !(match->mode & GR_DELETED))) {
62875 + match = match->next;
62876 + }
62877 +
62878 + if (match && (match->mode & GR_DELETED))
62879 + return match;
62880 + else
62881 + return NULL;
62882 +}
62883 +
62884 +static struct acl_object_label *
62885 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
62886 + const struct acl_subject_label *subj)
62887 +{
62888 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62889 + struct acl_object_label *match;
62890 +
62891 + match = subj->obj_hash[index];
62892 +
62893 + while (match && (match->inode != ino || match->device != dev ||
62894 + (match->mode & GR_DELETED))) {
62895 + match = match->next;
62896 + }
62897 +
62898 + if (match && !(match->mode & GR_DELETED))
62899 + return match;
62900 + else
62901 + return NULL;
62902 +}
62903 +
62904 +static struct acl_object_label *
62905 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
62906 + const struct acl_subject_label *subj)
62907 +{
62908 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62909 + struct acl_object_label *match;
62910 +
62911 + match = subj->obj_hash[index];
62912 +
62913 + while (match && (match->inode != ino || match->device != dev ||
62914 + !(match->mode & GR_DELETED))) {
62915 + match = match->next;
62916 + }
62917 +
62918 + if (match && (match->mode & GR_DELETED))
62919 + return match;
62920 +
62921 + match = subj->obj_hash[index];
62922 +
62923 + while (match && (match->inode != ino || match->device != dev ||
62924 + (match->mode & GR_DELETED))) {
62925 + match = match->next;
62926 + }
62927 +
62928 + if (match && !(match->mode & GR_DELETED))
62929 + return match;
62930 + else
62931 + return NULL;
62932 +}
62933 +
62934 +static struct name_entry *
62935 +lookup_name_entry(const char *name)
62936 +{
62937 + unsigned int len = strlen(name);
62938 + unsigned int key = full_name_hash(name, len);
62939 + unsigned int index = key % name_set.n_size;
62940 + struct name_entry *match;
62941 +
62942 + match = name_set.n_hash[index];
62943 +
62944 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
62945 + match = match->next;
62946 +
62947 + return match;
62948 +}
62949 +
62950 +static struct name_entry *
62951 +lookup_name_entry_create(const char *name)
62952 +{
62953 + unsigned int len = strlen(name);
62954 + unsigned int key = full_name_hash(name, len);
62955 + unsigned int index = key % name_set.n_size;
62956 + struct name_entry *match;
62957 +
62958 + match = name_set.n_hash[index];
62959 +
62960 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62961 + !match->deleted))
62962 + match = match->next;
62963 +
62964 + if (match && match->deleted)
62965 + return match;
62966 +
62967 + match = name_set.n_hash[index];
62968 +
62969 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62970 + match->deleted))
62971 + match = match->next;
62972 +
62973 + if (match && !match->deleted)
62974 + return match;
62975 + else
62976 + return NULL;
62977 +}
62978 +
62979 +static struct inodev_entry *
62980 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
62981 +{
62982 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
62983 + struct inodev_entry *match;
62984 +
62985 + match = inodev_set.i_hash[index];
62986 +
62987 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
62988 + match = match->next;
62989 +
62990 + return match;
62991 +}
62992 +
62993 +static void
62994 +insert_inodev_entry(struct inodev_entry *entry)
62995 +{
62996 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
62997 + inodev_set.i_size);
62998 + struct inodev_entry **curr;
62999 +
63000 + entry->prev = NULL;
63001 +
63002 + curr = &inodev_set.i_hash[index];
63003 + if (*curr != NULL)
63004 + (*curr)->prev = entry;
63005 +
63006 + entry->next = *curr;
63007 + *curr = entry;
63008 +
63009 + return;
63010 +}
63011 +
63012 +static void
63013 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
63014 +{
63015 + unsigned int index =
63016 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
63017 + struct acl_role_label **curr;
63018 + struct acl_role_label *tmp, *tmp2;
63019 +
63020 + curr = &acl_role_set.r_hash[index];
63021 +
63022 + /* simple case, slot is empty, just set it to our role */
63023 + if (*curr == NULL) {
63024 + *curr = role;
63025 + } else {
63026 + /* example:
63027 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
63028 + 2 -> 3
63029 + */
63030 + /* first check to see if we can already be reached via this slot */
63031 + tmp = *curr;
63032 + while (tmp && tmp != role)
63033 + tmp = tmp->next;
63034 + if (tmp == role) {
63035 + /* we don't need to add ourselves to this slot's chain */
63036 + return;
63037 + }
63038 + /* we need to add ourselves to this chain, two cases */
63039 + if (role->next == NULL) {
63040 + /* simple case, append the current chain to our role */
63041 + role->next = *curr;
63042 + *curr = role;
63043 + } else {
63044 + /* 1 -> 2 -> 3 -> 4
63045 + 2 -> 3 -> 4
63046 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
63047 + */
63048 + /* trickier case: walk our role's chain until we find
63049 + the role for the start of the current slot's chain */
63050 + tmp = role;
63051 + tmp2 = *curr;
63052 + while (tmp->next && tmp->next != tmp2)
63053 + tmp = tmp->next;
63054 + if (tmp->next == tmp2) {
63055 + /* from example above, we found 3, so just
63056 + replace this slot's chain with ours */
63057 + *curr = role;
63058 + } else {
63059 + /* we didn't find a subset of our role's chain
63060 + in the current slot's chain, so append their
63061 + chain to ours, and set us as the first role in
63062 + the slot's chain
63063 +
63064 + we could fold this case with the case above,
63065 + but making it explicit for clarity
63066 + */
63067 + tmp->next = tmp2;
63068 + *curr = role;
63069 + }
63070 + }
63071 + }
63072 +
63073 + return;
63074 +}
63075 +
63076 +static void
63077 +insert_acl_role_label(struct acl_role_label *role)
63078 +{
63079 + int i;
63080 +
63081 + if (role_list == NULL) {
63082 + role_list = role;
63083 + role->prev = NULL;
63084 + } else {
63085 + role->prev = role_list;
63086 + role_list = role;
63087 + }
63088 +
63089 + /* used for hash chains */
63090 + role->next = NULL;
63091 +
63092 + if (role->roletype & GR_ROLE_DOMAIN) {
63093 + for (i = 0; i < role->domain_child_num; i++)
63094 + __insert_acl_role_label(role, role->domain_children[i]);
63095 + } else
63096 + __insert_acl_role_label(role, role->uidgid);
63097 +}
63098 +
63099 +static int
63100 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
63101 +{
63102 + struct name_entry **curr, *nentry;
63103 + struct inodev_entry *ientry;
63104 + unsigned int len = strlen(name);
63105 + unsigned int key = full_name_hash(name, len);
63106 + unsigned int index = key % name_set.n_size;
63107 +
63108 + curr = &name_set.n_hash[index];
63109 +
63110 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
63111 + curr = &((*curr)->next);
63112 +
63113 + if (*curr != NULL)
63114 + return 1;
63115 +
63116 + nentry = acl_alloc(sizeof (struct name_entry));
63117 + if (nentry == NULL)
63118 + return 0;
63119 + ientry = acl_alloc(sizeof (struct inodev_entry));
63120 + if (ientry == NULL)
63121 + return 0;
63122 + ientry->nentry = nentry;
63123 +
63124 + nentry->key = key;
63125 + nentry->name = name;
63126 + nentry->inode = inode;
63127 + nentry->device = device;
63128 + nentry->len = len;
63129 + nentry->deleted = deleted;
63130 +
63131 + nentry->prev = NULL;
63132 + curr = &name_set.n_hash[index];
63133 + if (*curr != NULL)
63134 + (*curr)->prev = nentry;
63135 + nentry->next = *curr;
63136 + *curr = nentry;
63137 +
63138 + /* insert us into the table searchable by inode/dev */
63139 + insert_inodev_entry(ientry);
63140 +
63141 + return 1;
63142 +}
63143 +
63144 +static void
63145 +insert_acl_obj_label(struct acl_object_label *obj,
63146 + struct acl_subject_label *subj)
63147 +{
63148 + unsigned int index =
63149 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
63150 + struct acl_object_label **curr;
63151 +
63152 +
63153 + obj->prev = NULL;
63154 +
63155 + curr = &subj->obj_hash[index];
63156 + if (*curr != NULL)
63157 + (*curr)->prev = obj;
63158 +
63159 + obj->next = *curr;
63160 + *curr = obj;
63161 +
63162 + return;
63163 +}
63164 +
63165 +static void
63166 +insert_acl_subj_label(struct acl_subject_label *obj,
63167 + struct acl_role_label *role)
63168 +{
63169 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
63170 + struct acl_subject_label **curr;
63171 +
63172 + obj->prev = NULL;
63173 +
63174 + curr = &role->subj_hash[index];
63175 + if (*curr != NULL)
63176 + (*curr)->prev = obj;
63177 +
63178 + obj->next = *curr;
63179 + *curr = obj;
63180 +
63181 + return;
63182 +}
63183 +
63184 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
63185 +
63186 +static void *
63187 +create_table(__u32 * len, int elementsize)
63188 +{
63189 + unsigned int table_sizes[] = {
63190 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
63191 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
63192 + 4194301, 8388593, 16777213, 33554393, 67108859
63193 + };
63194 + void *newtable = NULL;
63195 + unsigned int pwr = 0;
63196 +
63197 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
63198 + table_sizes[pwr] <= *len)
63199 + pwr++;
63200 +
63201 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
63202 + return newtable;
63203 +
63204 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
63205 + newtable =
63206 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
63207 + else
63208 + newtable = vmalloc(table_sizes[pwr] * elementsize);
63209 +
63210 + *len = table_sizes[pwr];
63211 +
63212 + return newtable;
63213 +}
63214 +
63215 +static int
63216 +init_variables(const struct gr_arg *arg)
63217 +{
63218 + struct task_struct *reaper = init_pid_ns.child_reaper;
63219 + unsigned int stacksize;
63220 +
63221 + subj_map_set.s_size = arg->role_db.num_subjects;
63222 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
63223 + name_set.n_size = arg->role_db.num_objects;
63224 + inodev_set.i_size = arg->role_db.num_objects;
63225 +
63226 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
63227 + !name_set.n_size || !inodev_set.i_size)
63228 + return 1;
63229 +
63230 + if (!gr_init_uidset())
63231 + return 1;
63232 +
63233 + /* set up the stack that holds allocation info */
63234 +
63235 + stacksize = arg->role_db.num_pointers + 5;
63236 +
63237 + if (!acl_alloc_stack_init(stacksize))
63238 + return 1;
63239 +
63240 + /* grab reference for the real root dentry and vfsmount */
63241 + get_fs_root(reaper->fs, &real_root);
63242 +
63243 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63244 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
63245 +#endif
63246 +
63247 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
63248 + if (fakefs_obj_rw == NULL)
63249 + return 1;
63250 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
63251 +
63252 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
63253 + if (fakefs_obj_rwx == NULL)
63254 + return 1;
63255 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
63256 +
63257 + subj_map_set.s_hash =
63258 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
63259 + acl_role_set.r_hash =
63260 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
63261 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
63262 + inodev_set.i_hash =
63263 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
63264 +
63265 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
63266 + !name_set.n_hash || !inodev_set.i_hash)
63267 + return 1;
63268 +
63269 + memset(subj_map_set.s_hash, 0,
63270 + sizeof(struct subject_map *) * subj_map_set.s_size);
63271 + memset(acl_role_set.r_hash, 0,
63272 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
63273 + memset(name_set.n_hash, 0,
63274 + sizeof (struct name_entry *) * name_set.n_size);
63275 + memset(inodev_set.i_hash, 0,
63276 + sizeof (struct inodev_entry *) * inodev_set.i_size);
63277 +
63278 + return 0;
63279 +}
63280 +
63281 +/* free information not needed after startup
63282 + currently contains user->kernel pointer mappings for subjects
63283 +*/
63284 +
63285 +static void
63286 +free_init_variables(void)
63287 +{
63288 + __u32 i;
63289 +
63290 + if (subj_map_set.s_hash) {
63291 + for (i = 0; i < subj_map_set.s_size; i++) {
63292 + if (subj_map_set.s_hash[i]) {
63293 + kfree(subj_map_set.s_hash[i]);
63294 + subj_map_set.s_hash[i] = NULL;
63295 + }
63296 + }
63297 +
63298 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
63299 + PAGE_SIZE)
63300 + kfree(subj_map_set.s_hash);
63301 + else
63302 + vfree(subj_map_set.s_hash);
63303 + }
63304 +
63305 + return;
63306 +}
63307 +
63308 +static void
63309 +free_variables(void)
63310 +{
63311 + struct acl_subject_label *s;
63312 + struct acl_role_label *r;
63313 + struct task_struct *task, *task2;
63314 + unsigned int x;
63315 +
63316 + gr_clear_learn_entries();
63317 +
63318 + read_lock(&tasklist_lock);
63319 + do_each_thread(task2, task) {
63320 + task->acl_sp_role = 0;
63321 + task->acl_role_id = 0;
63322 + task->acl = NULL;
63323 + task->role = NULL;
63324 + } while_each_thread(task2, task);
63325 + read_unlock(&tasklist_lock);
63326 +
63327 + /* release the reference to the real root dentry and vfsmount */
63328 + path_put(&real_root);
63329 + memset(&real_root, 0, sizeof(real_root));
63330 +
63331 + /* free all object hash tables */
63332 +
63333 + FOR_EACH_ROLE_START(r)
63334 + if (r->subj_hash == NULL)
63335 + goto next_role;
63336 + FOR_EACH_SUBJECT_START(r, s, x)
63337 + if (s->obj_hash == NULL)
63338 + break;
63339 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63340 + kfree(s->obj_hash);
63341 + else
63342 + vfree(s->obj_hash);
63343 + FOR_EACH_SUBJECT_END(s, x)
63344 + FOR_EACH_NESTED_SUBJECT_START(r, s)
63345 + if (s->obj_hash == NULL)
63346 + break;
63347 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63348 + kfree(s->obj_hash);
63349 + else
63350 + vfree(s->obj_hash);
63351 + FOR_EACH_NESTED_SUBJECT_END(s)
63352 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
63353 + kfree(r->subj_hash);
63354 + else
63355 + vfree(r->subj_hash);
63356 + r->subj_hash = NULL;
63357 +next_role:
63358 + FOR_EACH_ROLE_END(r)
63359 +
63360 + acl_free_all();
63361 +
63362 + if (acl_role_set.r_hash) {
63363 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
63364 + PAGE_SIZE)
63365 + kfree(acl_role_set.r_hash);
63366 + else
63367 + vfree(acl_role_set.r_hash);
63368 + }
63369 + if (name_set.n_hash) {
63370 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
63371 + PAGE_SIZE)
63372 + kfree(name_set.n_hash);
63373 + else
63374 + vfree(name_set.n_hash);
63375 + }
63376 +
63377 + if (inodev_set.i_hash) {
63378 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
63379 + PAGE_SIZE)
63380 + kfree(inodev_set.i_hash);
63381 + else
63382 + vfree(inodev_set.i_hash);
63383 + }
63384 +
63385 + gr_free_uidset();
63386 +
63387 + memset(&name_set, 0, sizeof (struct name_db));
63388 + memset(&inodev_set, 0, sizeof (struct inodev_db));
63389 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
63390 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
63391 +
63392 + default_role = NULL;
63393 + kernel_role = NULL;
63394 + role_list = NULL;
63395 +
63396 + return;
63397 +}
63398 +
63399 +static struct acl_subject_label *
63400 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
63401 +
63402 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
63403 +{
63404 + unsigned int len = strnlen_user(*name, maxlen);
63405 + char *tmp;
63406 +
63407 + if (!len || len >= maxlen)
63408 + return -EINVAL;
63409 +
63410 + if ((tmp = (char *) acl_alloc(len)) == NULL)
63411 + return -ENOMEM;
63412 +
63413 + if (copy_from_user(tmp, *name, len))
63414 + return -EFAULT;
63415 +
63416 + tmp[len-1] = '\0';
63417 + *name = tmp;
63418 +
63419 + return 0;
63420 +}
63421 +
63422 +static int
63423 +copy_user_glob(struct acl_object_label *obj)
63424 +{
63425 + struct acl_object_label *g_tmp, **guser;
63426 + int error;
63427 +
63428 + if (obj->globbed == NULL)
63429 + return 0;
63430 +
63431 + guser = &obj->globbed;
63432 + while (*guser) {
63433 + g_tmp = (struct acl_object_label *)
63434 + acl_alloc(sizeof (struct acl_object_label));
63435 + if (g_tmp == NULL)
63436 + return -ENOMEM;
63437 +
63438 + if (copy_acl_object_label(g_tmp, *guser))
63439 + return -EFAULT;
63440 +
63441 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
63442 + if (error)
63443 + return error;
63444 +
63445 + *guser = g_tmp;
63446 + guser = &(g_tmp->next);
63447 + }
63448 +
63449 + return 0;
63450 +}
63451 +
63452 +static int
63453 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
63454 + struct acl_role_label *role)
63455 +{
63456 + struct acl_object_label *o_tmp;
63457 + int ret;
63458 +
63459 + while (userp) {
63460 + if ((o_tmp = (struct acl_object_label *)
63461 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
63462 + return -ENOMEM;
63463 +
63464 + if (copy_acl_object_label(o_tmp, userp))
63465 + return -EFAULT;
63466 +
63467 + userp = o_tmp->prev;
63468 +
63469 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
63470 + if (ret)
63471 + return ret;
63472 +
63473 + insert_acl_obj_label(o_tmp, subj);
63474 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
63475 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
63476 + return -ENOMEM;
63477 +
63478 + ret = copy_user_glob(o_tmp);
63479 + if (ret)
63480 + return ret;
63481 +
63482 + if (o_tmp->nested) {
63483 + int already_copied;
63484 +
63485 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
63486 + if (IS_ERR(o_tmp->nested))
63487 + return PTR_ERR(o_tmp->nested);
63488 +
63489 + /* insert into nested subject list if we haven't copied this one yet
63490 + to prevent duplicate entries */
63491 + if (!already_copied) {
63492 + o_tmp->nested->next = role->hash->first;
63493 + role->hash->first = o_tmp->nested;
63494 + }
63495 + }
63496 + }
63497 +
63498 + return 0;
63499 +}
63500 +
63501 +static __u32
63502 +count_user_subjs(struct acl_subject_label *userp)
63503 +{
63504 + struct acl_subject_label s_tmp;
63505 + __u32 num = 0;
63506 +
63507 + while (userp) {
63508 + if (copy_acl_subject_label(&s_tmp, userp))
63509 + break;
63510 +
63511 + userp = s_tmp.prev;
63512 + }
63513 +
63514 + return num;
63515 +}
63516 +
63517 +static int
63518 +copy_user_allowedips(struct acl_role_label *rolep)
63519 +{
63520 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
63521 +
63522 + ruserip = rolep->allowed_ips;
63523 +
63524 + while (ruserip) {
63525 + rlast = rtmp;
63526 +
63527 + if ((rtmp = (struct role_allowed_ip *)
63528 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
63529 + return -ENOMEM;
63530 +
63531 + if (copy_role_allowed_ip(rtmp, ruserip))
63532 + return -EFAULT;
63533 +
63534 + ruserip = rtmp->prev;
63535 +
63536 + if (!rlast) {
63537 + rtmp->prev = NULL;
63538 + rolep->allowed_ips = rtmp;
63539 + } else {
63540 + rlast->next = rtmp;
63541 + rtmp->prev = rlast;
63542 + }
63543 +
63544 + if (!ruserip)
63545 + rtmp->next = NULL;
63546 + }
63547 +
63548 + return 0;
63549 +}
63550 +
63551 +static int
63552 +copy_user_transitions(struct acl_role_label *rolep)
63553 +{
63554 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
63555 + int error;
63556 +
63557 + rusertp = rolep->transitions;
63558 +
63559 + while (rusertp) {
63560 + rlast = rtmp;
63561 +
63562 + if ((rtmp = (struct role_transition *)
63563 + acl_alloc(sizeof (struct role_transition))) == NULL)
63564 + return -ENOMEM;
63565 +
63566 + if (copy_role_transition(rtmp, rusertp))
63567 + return -EFAULT;
63568 +
63569 + rusertp = rtmp->prev;
63570 +
63571 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
63572 + if (error)
63573 + return error;
63574 +
63575 + if (!rlast) {
63576 + rtmp->prev = NULL;
63577 + rolep->transitions = rtmp;
63578 + } else {
63579 + rlast->next = rtmp;
63580 + rtmp->prev = rlast;
63581 + }
63582 +
63583 + if (!rusertp)
63584 + rtmp->next = NULL;
63585 + }
63586 +
63587 + return 0;
63588 +}
63589 +
63590 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
63591 +{
63592 + struct acl_object_label o_tmp;
63593 + __u32 num = 0;
63594 +
63595 + while (userp) {
63596 + if (copy_acl_object_label(&o_tmp, userp))
63597 + break;
63598 +
63599 + userp = o_tmp.prev;
63600 + num++;
63601 + }
63602 +
63603 + return num;
63604 +}
63605 +
63606 +static struct acl_subject_label *
63607 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
63608 +{
63609 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
63610 + __u32 num_objs;
63611 + struct acl_ip_label **i_tmp, *i_utmp2;
63612 + struct gr_hash_struct ghash;
63613 + struct subject_map *subjmap;
63614 + unsigned int i_num;
63615 + int err;
63616 +
63617 + if (already_copied != NULL)
63618 + *already_copied = 0;
63619 +
63620 + s_tmp = lookup_subject_map(userp);
63621 +
63622 + /* we've already copied this subject into the kernel, just return
63623 + the reference to it, and don't copy it over again
63624 + */
63625 + if (s_tmp) {
63626 + if (already_copied != NULL)
63627 + *already_copied = 1;
63628 + return(s_tmp);
63629 + }
63630 +
63631 + if ((s_tmp = (struct acl_subject_label *)
63632 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
63633 + return ERR_PTR(-ENOMEM);
63634 +
63635 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
63636 + if (subjmap == NULL)
63637 + return ERR_PTR(-ENOMEM);
63638 +
63639 + subjmap->user = userp;
63640 + subjmap->kernel = s_tmp;
63641 + insert_subj_map_entry(subjmap);
63642 +
63643 + if (copy_acl_subject_label(s_tmp, userp))
63644 + return ERR_PTR(-EFAULT);
63645 +
63646 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
63647 + if (err)
63648 + return ERR_PTR(err);
63649 +
63650 + if (!strcmp(s_tmp->filename, "/"))
63651 + role->root_label = s_tmp;
63652 +
63653 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
63654 + return ERR_PTR(-EFAULT);
63655 +
63656 + /* copy user and group transition tables */
63657 +
63658 + if (s_tmp->user_trans_num) {
63659 + uid_t *uidlist;
63660 +
63661 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
63662 + if (uidlist == NULL)
63663 + return ERR_PTR(-ENOMEM);
63664 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
63665 + return ERR_PTR(-EFAULT);
63666 +
63667 + s_tmp->user_transitions = uidlist;
63668 + }
63669 +
63670 + if (s_tmp->group_trans_num) {
63671 + gid_t *gidlist;
63672 +
63673 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
63674 + if (gidlist == NULL)
63675 + return ERR_PTR(-ENOMEM);
63676 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
63677 + return ERR_PTR(-EFAULT);
63678 +
63679 + s_tmp->group_transitions = gidlist;
63680 + }
63681 +
63682 + /* set up object hash table */
63683 + num_objs = count_user_objs(ghash.first);
63684 +
63685 + s_tmp->obj_hash_size = num_objs;
63686 + s_tmp->obj_hash =
63687 + (struct acl_object_label **)
63688 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
63689 +
63690 + if (!s_tmp->obj_hash)
63691 + return ERR_PTR(-ENOMEM);
63692 +
63693 + memset(s_tmp->obj_hash, 0,
63694 + s_tmp->obj_hash_size *
63695 + sizeof (struct acl_object_label *));
63696 +
63697 + /* add in objects */
63698 + err = copy_user_objs(ghash.first, s_tmp, role);
63699 +
63700 + if (err)
63701 + return ERR_PTR(err);
63702 +
63703 + /* set pointer for parent subject */
63704 + if (s_tmp->parent_subject) {
63705 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
63706 +
63707 + if (IS_ERR(s_tmp2))
63708 + return s_tmp2;
63709 +
63710 + s_tmp->parent_subject = s_tmp2;
63711 + }
63712 +
63713 + /* add in ip acls */
63714 +
63715 + if (!s_tmp->ip_num) {
63716 + s_tmp->ips = NULL;
63717 + goto insert;
63718 + }
63719 +
63720 + i_tmp =
63721 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
63722 + sizeof (struct acl_ip_label *));
63723 +
63724 + if (!i_tmp)
63725 + return ERR_PTR(-ENOMEM);
63726 +
63727 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
63728 + *(i_tmp + i_num) =
63729 + (struct acl_ip_label *)
63730 + acl_alloc(sizeof (struct acl_ip_label));
63731 + if (!*(i_tmp + i_num))
63732 + return ERR_PTR(-ENOMEM);
63733 +
63734 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
63735 + return ERR_PTR(-EFAULT);
63736 +
63737 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
63738 + return ERR_PTR(-EFAULT);
63739 +
63740 + if ((*(i_tmp + i_num))->iface == NULL)
63741 + continue;
63742 +
63743 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
63744 + if (err)
63745 + return ERR_PTR(err);
63746 + }
63747 +
63748 + s_tmp->ips = i_tmp;
63749 +
63750 +insert:
63751 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
63752 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
63753 + return ERR_PTR(-ENOMEM);
63754 +
63755 + return s_tmp;
63756 +}
63757 +
63758 +static int
63759 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
63760 +{
63761 + struct acl_subject_label s_pre;
63762 + struct acl_subject_label * ret;
63763 + int err;
63764 +
63765 + while (userp) {
63766 + if (copy_acl_subject_label(&s_pre, userp))
63767 + return -EFAULT;
63768 +
63769 + ret = do_copy_user_subj(userp, role, NULL);
63770 +
63771 + err = PTR_ERR(ret);
63772 + if (IS_ERR(ret))
63773 + return err;
63774 +
63775 + insert_acl_subj_label(ret, role);
63776 +
63777 + userp = s_pre.prev;
63778 + }
63779 +
63780 + return 0;
63781 +}
63782 +
63783 +static int
63784 +copy_user_acl(struct gr_arg *arg)
63785 +{
63786 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
63787 + struct acl_subject_label *subj_list;
63788 + struct sprole_pw *sptmp;
63789 + struct gr_hash_struct *ghash;
63790 + uid_t *domainlist;
63791 + unsigned int r_num;
63792 + int err = 0;
63793 + __u16 i;
63794 + __u32 num_subjs;
63795 +
63796 + /* we need a default and kernel role */
63797 + if (arg->role_db.num_roles < 2)
63798 + return -EINVAL;
63799 +
63800 + /* copy special role authentication info from userspace */
63801 +
63802 + num_sprole_pws = arg->num_sprole_pws;
63803 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
63804 +
63805 + if (!acl_special_roles && num_sprole_pws)
63806 + return -ENOMEM;
63807 +
63808 + for (i = 0; i < num_sprole_pws; i++) {
63809 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
63810 + if (!sptmp)
63811 + return -ENOMEM;
63812 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
63813 + return -EFAULT;
63814 +
63815 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
63816 + if (err)
63817 + return err;
63818 +
63819 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63820 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
63821 +#endif
63822 +
63823 + acl_special_roles[i] = sptmp;
63824 + }
63825 +
63826 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
63827 +
63828 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
63829 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
63830 +
63831 + if (!r_tmp)
63832 + return -ENOMEM;
63833 +
63834 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
63835 + return -EFAULT;
63836 +
63837 + if (copy_acl_role_label(r_tmp, r_utmp2))
63838 + return -EFAULT;
63839 +
63840 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
63841 + if (err)
63842 + return err;
63843 +
63844 + if (!strcmp(r_tmp->rolename, "default")
63845 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
63846 + default_role = r_tmp;
63847 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
63848 + kernel_role = r_tmp;
63849 + }
63850 +
63851 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
63852 + return -ENOMEM;
63853 +
63854 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
63855 + return -EFAULT;
63856 +
63857 + r_tmp->hash = ghash;
63858 +
63859 + num_subjs = count_user_subjs(r_tmp->hash->first);
63860 +
63861 + r_tmp->subj_hash_size = num_subjs;
63862 + r_tmp->subj_hash =
63863 + (struct acl_subject_label **)
63864 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
63865 +
63866 + if (!r_tmp->subj_hash)
63867 + return -ENOMEM;
63868 +
63869 + err = copy_user_allowedips(r_tmp);
63870 + if (err)
63871 + return err;
63872 +
63873 + /* copy domain info */
63874 + if (r_tmp->domain_children != NULL) {
63875 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
63876 + if (domainlist == NULL)
63877 + return -ENOMEM;
63878 +
63879 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
63880 + return -EFAULT;
63881 +
63882 + r_tmp->domain_children = domainlist;
63883 + }
63884 +
63885 + err = copy_user_transitions(r_tmp);
63886 + if (err)
63887 + return err;
63888 +
63889 + memset(r_tmp->subj_hash, 0,
63890 + r_tmp->subj_hash_size *
63891 + sizeof (struct acl_subject_label *));
63892 +
63893 + /* acquire the list of subjects, then NULL out
63894 + the list prior to parsing the subjects for this role,
63895 + as during this parsing the list is replaced with a list
63896 + of *nested* subjects for the role
63897 + */
63898 + subj_list = r_tmp->hash->first;
63899 +
63900 + /* set nested subject list to null */
63901 + r_tmp->hash->first = NULL;
63902 +
63903 + err = copy_user_subjs(subj_list, r_tmp);
63904 +
63905 + if (err)
63906 + return err;
63907 +
63908 + insert_acl_role_label(r_tmp);
63909 + }
63910 +
63911 + if (default_role == NULL || kernel_role == NULL)
63912 + return -EINVAL;
63913 +
63914 + return err;
63915 +}
63916 +
63917 +static int
63918 +gracl_init(struct gr_arg *args)
63919 +{
63920 + int error = 0;
63921 +
63922 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
63923 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
63924 +
63925 + if (init_variables(args)) {
63926 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
63927 + error = -ENOMEM;
63928 + free_variables();
63929 + goto out;
63930 + }
63931 +
63932 + error = copy_user_acl(args);
63933 + free_init_variables();
63934 + if (error) {
63935 + free_variables();
63936 + goto out;
63937 + }
63938 +
63939 + if ((error = gr_set_acls(0))) {
63940 + free_variables();
63941 + goto out;
63942 + }
63943 +
63944 + pax_open_kernel();
63945 + gr_status |= GR_READY;
63946 + pax_close_kernel();
63947 +
63948 + out:
63949 + return error;
63950 +}
63951 +
63952 +/* derived from glibc fnmatch() 0: match, 1: no match*/
63953 +
63954 +static int
63955 +glob_match(const char *p, const char *n)
63956 +{
63957 + char c;
63958 +
63959 + while ((c = *p++) != '\0') {
63960 + switch (c) {
63961 + case '?':
63962 + if (*n == '\0')
63963 + return 1;
63964 + else if (*n == '/')
63965 + return 1;
63966 + break;
63967 + case '\\':
63968 + if (*n != c)
63969 + return 1;
63970 + break;
63971 + case '*':
63972 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
63973 + if (*n == '/')
63974 + return 1;
63975 + else if (c == '?') {
63976 + if (*n == '\0')
63977 + return 1;
63978 + else
63979 + ++n;
63980 + }
63981 + }
63982 + if (c == '\0') {
63983 + return 0;
63984 + } else {
63985 + const char *endp;
63986 +
63987 + if ((endp = strchr(n, '/')) == NULL)
63988 + endp = n + strlen(n);
63989 +
63990 + if (c == '[') {
63991 + for (--p; n < endp; ++n)
63992 + if (!glob_match(p, n))
63993 + return 0;
63994 + } else if (c == '/') {
63995 + while (*n != '\0' && *n != '/')
63996 + ++n;
63997 + if (*n == '/' && !glob_match(p, n + 1))
63998 + return 0;
63999 + } else {
64000 + for (--p; n < endp; ++n)
64001 + if (*n == c && !glob_match(p, n))
64002 + return 0;
64003 + }
64004 +
64005 + return 1;
64006 + }
64007 + case '[':
64008 + {
64009 + int not;
64010 + char cold;
64011 +
64012 + if (*n == '\0' || *n == '/')
64013 + return 1;
64014 +
64015 + not = (*p == '!' || *p == '^');
64016 + if (not)
64017 + ++p;
64018 +
64019 + c = *p++;
64020 + for (;;) {
64021 + unsigned char fn = (unsigned char)*n;
64022 +
64023 + if (c == '\0')
64024 + return 1;
64025 + else {
64026 + if (c == fn)
64027 + goto matched;
64028 + cold = c;
64029 + c = *p++;
64030 +
64031 + if (c == '-' && *p != ']') {
64032 + unsigned char cend = *p++;
64033 +
64034 + if (cend == '\0')
64035 + return 1;
64036 +
64037 + if (cold <= fn && fn <= cend)
64038 + goto matched;
64039 +
64040 + c = *p++;
64041 + }
64042 + }
64043 +
64044 + if (c == ']')
64045 + break;
64046 + }
64047 + if (!not)
64048 + return 1;
64049 + break;
64050 + matched:
64051 + while (c != ']') {
64052 + if (c == '\0')
64053 + return 1;
64054 +
64055 + c = *p++;
64056 + }
64057 + if (not)
64058 + return 1;
64059 + }
64060 + break;
64061 + default:
64062 + if (c != *n)
64063 + return 1;
64064 + }
64065 +
64066 + ++n;
64067 + }
64068 +
64069 + if (*n == '\0')
64070 + return 0;
64071 +
64072 + if (*n == '/')
64073 + return 0;
64074 +
64075 + return 1;
64076 +}
64077 +
64078 +static struct acl_object_label *
64079 +chk_glob_label(struct acl_object_label *globbed,
64080 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
64081 +{
64082 + struct acl_object_label *tmp;
64083 +
64084 + if (*path == NULL)
64085 + *path = gr_to_filename_nolock(dentry, mnt);
64086 +
64087 + tmp = globbed;
64088 +
64089 + while (tmp) {
64090 + if (!glob_match(tmp->filename, *path))
64091 + return tmp;
64092 + tmp = tmp->next;
64093 + }
64094 +
64095 + return NULL;
64096 +}
64097 +
64098 +static struct acl_object_label *
64099 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64100 + const ino_t curr_ino, const dev_t curr_dev,
64101 + const struct acl_subject_label *subj, char **path, const int checkglob)
64102 +{
64103 + struct acl_subject_label *tmpsubj;
64104 + struct acl_object_label *retval;
64105 + struct acl_object_label *retval2;
64106 +
64107 + tmpsubj = (struct acl_subject_label *) subj;
64108 + read_lock(&gr_inode_lock);
64109 + do {
64110 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
64111 + if (retval) {
64112 + if (checkglob && retval->globbed) {
64113 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
64114 + if (retval2)
64115 + retval = retval2;
64116 + }
64117 + break;
64118 + }
64119 + } while ((tmpsubj = tmpsubj->parent_subject));
64120 + read_unlock(&gr_inode_lock);
64121 +
64122 + return retval;
64123 +}
64124 +
64125 +static __inline__ struct acl_object_label *
64126 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64127 + struct dentry *curr_dentry,
64128 + const struct acl_subject_label *subj, char **path, const int checkglob)
64129 +{
64130 + int newglob = checkglob;
64131 + ino_t inode;
64132 + dev_t device;
64133 +
64134 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
64135 + as we don't want a / * rule to match instead of the / object
64136 + don't do this for create lookups that call this function though, since they're looking up
64137 + on the parent and thus need globbing checks on all paths
64138 + */
64139 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
64140 + newglob = GR_NO_GLOB;
64141 +
64142 + spin_lock(&curr_dentry->d_lock);
64143 + inode = curr_dentry->d_inode->i_ino;
64144 + device = __get_dev(curr_dentry);
64145 + spin_unlock(&curr_dentry->d_lock);
64146 +
64147 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
64148 +}
64149 +
64150 +#ifdef CONFIG_HUGETLBFS
64151 +static inline bool
64152 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
64153 +{
64154 + int i;
64155 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
64156 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
64157 + return true;
64158 + }
64159 +
64160 + return false;
64161 +}
64162 +#endif
64163 +
64164 +static struct acl_object_label *
64165 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64166 + const struct acl_subject_label *subj, char *path, const int checkglob)
64167 +{
64168 + struct dentry *dentry = (struct dentry *) l_dentry;
64169 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64170 + struct mount *real_mnt = real_mount(mnt);
64171 + struct acl_object_label *retval;
64172 + struct dentry *parent;
64173 +
64174 + br_read_lock(&vfsmount_lock);
64175 + write_seqlock(&rename_lock);
64176 +
64177 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
64178 +#ifdef CONFIG_NET
64179 + mnt == sock_mnt ||
64180 +#endif
64181 +#ifdef CONFIG_HUGETLBFS
64182 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64183 +#endif
64184 + /* ignore Eric Biederman */
64185 + IS_PRIVATE(l_dentry->d_inode))) {
64186 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64187 + goto out;
64188 + }
64189 +
64190 + for (;;) {
64191 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64192 + break;
64193 +
64194 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64195 + if (!mnt_has_parent(real_mnt))
64196 + break;
64197 +
64198 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64199 + if (retval != NULL)
64200 + goto out;
64201 +
64202 + dentry = real_mnt->mnt_mountpoint;
64203 + real_mnt = real_mnt->mnt_parent;
64204 + mnt = &real_mnt->mnt;
64205 + continue;
64206 + }
64207 +
64208 + parent = dentry->d_parent;
64209 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64210 + if (retval != NULL)
64211 + goto out;
64212 +
64213 + dentry = parent;
64214 + }
64215 +
64216 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64217 +
64218 + /* real_root is pinned so we don't have to hold a reference */
64219 + if (retval == NULL)
64220 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
64221 +out:
64222 + write_sequnlock(&rename_lock);
64223 + br_read_unlock(&vfsmount_lock);
64224 +
64225 + BUG_ON(retval == NULL);
64226 +
64227 + return retval;
64228 +}
64229 +
64230 +static __inline__ struct acl_object_label *
64231 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64232 + const struct acl_subject_label *subj)
64233 +{
64234 + char *path = NULL;
64235 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64236 +}
64237 +
64238 +static __inline__ struct acl_object_label *
64239 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64240 + const struct acl_subject_label *subj)
64241 +{
64242 + char *path = NULL;
64243 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64244 +}
64245 +
64246 +static __inline__ struct acl_object_label *
64247 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64248 + const struct acl_subject_label *subj, char *path)
64249 +{
64250 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64251 +}
64252 +
64253 +static struct acl_subject_label *
64254 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64255 + const struct acl_role_label *role)
64256 +{
64257 + struct dentry *dentry = (struct dentry *) l_dentry;
64258 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64259 + struct mount *real_mnt = real_mount(mnt);
64260 + struct acl_subject_label *retval;
64261 + struct dentry *parent;
64262 +
64263 + br_read_lock(&vfsmount_lock);
64264 + write_seqlock(&rename_lock);
64265 +
64266 + for (;;) {
64267 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64268 + break;
64269 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64270 + if (!mnt_has_parent(real_mnt))
64271 + break;
64272 +
64273 + spin_lock(&dentry->d_lock);
64274 + read_lock(&gr_inode_lock);
64275 + retval =
64276 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64277 + __get_dev(dentry), role);
64278 + read_unlock(&gr_inode_lock);
64279 + spin_unlock(&dentry->d_lock);
64280 + if (retval != NULL)
64281 + goto out;
64282 +
64283 + dentry = real_mnt->mnt_mountpoint;
64284 + real_mnt = real_mnt->mnt_parent;
64285 + mnt = &real_mnt->mnt;
64286 + continue;
64287 + }
64288 +
64289 + spin_lock(&dentry->d_lock);
64290 + read_lock(&gr_inode_lock);
64291 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64292 + __get_dev(dentry), role);
64293 + read_unlock(&gr_inode_lock);
64294 + parent = dentry->d_parent;
64295 + spin_unlock(&dentry->d_lock);
64296 +
64297 + if (retval != NULL)
64298 + goto out;
64299 +
64300 + dentry = parent;
64301 + }
64302 +
64303 + spin_lock(&dentry->d_lock);
64304 + read_lock(&gr_inode_lock);
64305 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64306 + __get_dev(dentry), role);
64307 + read_unlock(&gr_inode_lock);
64308 + spin_unlock(&dentry->d_lock);
64309 +
64310 + if (unlikely(retval == NULL)) {
64311 + /* real_root is pinned, we don't need to hold a reference */
64312 + read_lock(&gr_inode_lock);
64313 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
64314 + __get_dev(real_root.dentry), role);
64315 + read_unlock(&gr_inode_lock);
64316 + }
64317 +out:
64318 + write_sequnlock(&rename_lock);
64319 + br_read_unlock(&vfsmount_lock);
64320 +
64321 + BUG_ON(retval == NULL);
64322 +
64323 + return retval;
64324 +}
64325 +
64326 +static void
64327 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
64328 +{
64329 + struct task_struct *task = current;
64330 + const struct cred *cred = current_cred();
64331 +
64332 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64333 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64334 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64335 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64336 +
64337 + return;
64338 +}
64339 +
64340 +static void
64341 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64342 +{
64343 + struct task_struct *task = current;
64344 + const struct cred *cred = current_cred();
64345 +
64346 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64347 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64348 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64349 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64350 +
64351 + return;
64352 +}
64353 +
64354 +static void
64355 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64356 +{
64357 + struct task_struct *task = current;
64358 + const struct cred *cred = current_cred();
64359 +
64360 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64361 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64362 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64363 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64364 +
64365 + return;
64366 +}
64367 +
64368 +__u32
64369 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64370 + const struct vfsmount * mnt)
64371 +{
64372 + __u32 retval = mode;
64373 + struct acl_subject_label *curracl;
64374 + struct acl_object_label *currobj;
64375 +
64376 + if (unlikely(!(gr_status & GR_READY)))
64377 + return (mode & ~GR_AUDITS);
64378 +
64379 + curracl = current->acl;
64380 +
64381 + currobj = chk_obj_label(dentry, mnt, curracl);
64382 + retval = currobj->mode & mode;
64383 +
64384 + /* if we're opening a specified transfer file for writing
64385 + (e.g. /dev/initctl), then transfer our role to init
64386 + */
64387 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64388 + current->role->roletype & GR_ROLE_PERSIST)) {
64389 + struct task_struct *task = init_pid_ns.child_reaper;
64390 +
64391 + if (task->role != current->role) {
64392 + task->acl_sp_role = 0;
64393 + task->acl_role_id = current->acl_role_id;
64394 + task->role = current->role;
64395 + rcu_read_lock();
64396 + read_lock(&grsec_exec_file_lock);
64397 + gr_apply_subject_to_task(task);
64398 + read_unlock(&grsec_exec_file_lock);
64399 + rcu_read_unlock();
64400 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64401 + }
64402 + }
64403 +
64404 + if (unlikely
64405 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64406 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64407 + __u32 new_mode = mode;
64408 +
64409 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64410 +
64411 + retval = new_mode;
64412 +
64413 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64414 + new_mode |= GR_INHERIT;
64415 +
64416 + if (!(mode & GR_NOLEARN))
64417 + gr_log_learn(dentry, mnt, new_mode);
64418 + }
64419 +
64420 + return retval;
64421 +}
64422 +
64423 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64424 + const struct dentry *parent,
64425 + const struct vfsmount *mnt)
64426 +{
64427 + struct name_entry *match;
64428 + struct acl_object_label *matchpo;
64429 + struct acl_subject_label *curracl;
64430 + char *path;
64431 +
64432 + if (unlikely(!(gr_status & GR_READY)))
64433 + return NULL;
64434 +
64435 + preempt_disable();
64436 + path = gr_to_filename_rbac(new_dentry, mnt);
64437 + match = lookup_name_entry_create(path);
64438 +
64439 + curracl = current->acl;
64440 +
64441 + if (match) {
64442 + read_lock(&gr_inode_lock);
64443 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64444 + read_unlock(&gr_inode_lock);
64445 +
64446 + if (matchpo) {
64447 + preempt_enable();
64448 + return matchpo;
64449 + }
64450 + }
64451 +
64452 + // lookup parent
64453 +
64454 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64455 +
64456 + preempt_enable();
64457 + return matchpo;
64458 +}
64459 +
64460 +__u32
64461 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64462 + const struct vfsmount * mnt, const __u32 mode)
64463 +{
64464 + struct acl_object_label *matchpo;
64465 + __u32 retval;
64466 +
64467 + if (unlikely(!(gr_status & GR_READY)))
64468 + return (mode & ~GR_AUDITS);
64469 +
64470 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64471 +
64472 + retval = matchpo->mode & mode;
64473 +
64474 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64475 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64476 + __u32 new_mode = mode;
64477 +
64478 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64479 +
64480 + gr_log_learn(new_dentry, mnt, new_mode);
64481 + return new_mode;
64482 + }
64483 +
64484 + return retval;
64485 +}
64486 +
64487 +__u32
64488 +gr_check_link(const struct dentry * new_dentry,
64489 + const struct dentry * parent_dentry,
64490 + const struct vfsmount * parent_mnt,
64491 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64492 +{
64493 + struct acl_object_label *obj;
64494 + __u32 oldmode, newmode;
64495 + __u32 needmode;
64496 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64497 + GR_DELETE | GR_INHERIT;
64498 +
64499 + if (unlikely(!(gr_status & GR_READY)))
64500 + return (GR_CREATE | GR_LINK);
64501 +
64502 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64503 + oldmode = obj->mode;
64504 +
64505 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64506 + newmode = obj->mode;
64507 +
64508 + needmode = newmode & checkmodes;
64509 +
64510 + // old name for hardlink must have at least the permissions of the new name
64511 + if ((oldmode & needmode) != needmode)
64512 + goto bad;
64513 +
64514 + // if old name had restrictions/auditing, make sure the new name does as well
64515 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64516 +
64517 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64518 + if (is_privileged_binary(old_dentry))
64519 + needmode |= GR_SETID;
64520 +
64521 + if ((newmode & needmode) != needmode)
64522 + goto bad;
64523 +
64524 + // enforce minimum permissions
64525 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64526 + return newmode;
64527 +bad:
64528 + needmode = oldmode;
64529 + if (is_privileged_binary(old_dentry))
64530 + needmode |= GR_SETID;
64531 +
64532 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64533 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64534 + return (GR_CREATE | GR_LINK);
64535 + } else if (newmode & GR_SUPPRESS)
64536 + return GR_SUPPRESS;
64537 + else
64538 + return 0;
64539 +}
64540 +
64541 +int
64542 +gr_check_hidden_task(const struct task_struct *task)
64543 +{
64544 + if (unlikely(!(gr_status & GR_READY)))
64545 + return 0;
64546 +
64547 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64548 + return 1;
64549 +
64550 + return 0;
64551 +}
64552 +
64553 +int
64554 +gr_check_protected_task(const struct task_struct *task)
64555 +{
64556 + if (unlikely(!(gr_status & GR_READY) || !task))
64557 + return 0;
64558 +
64559 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64560 + task->acl != current->acl)
64561 + return 1;
64562 +
64563 + return 0;
64564 +}
64565 +
64566 +int
64567 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64568 +{
64569 + struct task_struct *p;
64570 + int ret = 0;
64571 +
64572 + if (unlikely(!(gr_status & GR_READY) || !pid))
64573 + return ret;
64574 +
64575 + read_lock(&tasklist_lock);
64576 + do_each_pid_task(pid, type, p) {
64577 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64578 + p->acl != current->acl) {
64579 + ret = 1;
64580 + goto out;
64581 + }
64582 + } while_each_pid_task(pid, type, p);
64583 +out:
64584 + read_unlock(&tasklist_lock);
64585 +
64586 + return ret;
64587 +}
64588 +
64589 +void
64590 +gr_copy_label(struct task_struct *tsk)
64591 +{
64592 + tsk->signal->used_accept = 0;
64593 + tsk->acl_sp_role = 0;
64594 + tsk->acl_role_id = current->acl_role_id;
64595 + tsk->acl = current->acl;
64596 + tsk->role = current->role;
64597 + tsk->signal->curr_ip = current->signal->curr_ip;
64598 + tsk->signal->saved_ip = current->signal->saved_ip;
64599 + if (current->exec_file)
64600 + get_file(current->exec_file);
64601 + tsk->exec_file = current->exec_file;
64602 + tsk->is_writable = current->is_writable;
64603 + if (unlikely(current->signal->used_accept)) {
64604 + current->signal->curr_ip = 0;
64605 + current->signal->saved_ip = 0;
64606 + }
64607 +
64608 + return;
64609 +}
64610 +
64611 +static void
64612 +gr_set_proc_res(struct task_struct *task)
64613 +{
64614 + struct acl_subject_label *proc;
64615 + unsigned short i;
64616 +
64617 + proc = task->acl;
64618 +
64619 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64620 + return;
64621 +
64622 + for (i = 0; i < RLIM_NLIMITS; i++) {
64623 + if (!(proc->resmask & (1U << i)))
64624 + continue;
64625 +
64626 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64627 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64628 +
64629 + if (i == RLIMIT_CPU)
64630 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64631 + }
64632 +
64633 + return;
64634 +}
64635 +
64636 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64637 +
64638 +int
64639 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64640 +{
64641 + unsigned int i;
64642 + __u16 num;
64643 + uid_t *uidlist;
64644 + uid_t curuid;
64645 + int realok = 0;
64646 + int effectiveok = 0;
64647 + int fsok = 0;
64648 + uid_t globalreal, globaleffective, globalfs;
64649 +
64650 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64651 + struct user_struct *user;
64652 +
64653 + if (!uid_valid(real))
64654 + goto skipit;
64655 +
64656 + /* find user based on global namespace */
64657 +
64658 + globalreal = GR_GLOBAL_UID(real);
64659 +
64660 + user = find_user(make_kuid(&init_user_ns, globalreal));
64661 + if (user == NULL)
64662 + goto skipit;
64663 +
64664 + if (gr_process_kernel_setuid_ban(user)) {
64665 + /* for find_user */
64666 + free_uid(user);
64667 + return 1;
64668 + }
64669 +
64670 + /* for find_user */
64671 + free_uid(user);
64672 +
64673 +skipit:
64674 +#endif
64675 +
64676 + if (unlikely(!(gr_status & GR_READY)))
64677 + return 0;
64678 +
64679 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64680 + gr_log_learn_uid_change(real, effective, fs);
64681 +
64682 + num = current->acl->user_trans_num;
64683 + uidlist = current->acl->user_transitions;
64684 +
64685 + if (uidlist == NULL)
64686 + return 0;
64687 +
64688 + if (!uid_valid(real)) {
64689 + realok = 1;
64690 + globalreal = (uid_t)-1;
64691 + } else {
64692 + globalreal = GR_GLOBAL_UID(real);
64693 + }
64694 + if (!uid_valid(effective)) {
64695 + effectiveok = 1;
64696 + globaleffective = (uid_t)-1;
64697 + } else {
64698 + globaleffective = GR_GLOBAL_UID(effective);
64699 + }
64700 + if (!uid_valid(fs)) {
64701 + fsok = 1;
64702 + globalfs = (uid_t)-1;
64703 + } else {
64704 + globalfs = GR_GLOBAL_UID(fs);
64705 + }
64706 +
64707 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64708 + for (i = 0; i < num; i++) {
64709 + curuid = uidlist[i];
64710 + if (globalreal == curuid)
64711 + realok = 1;
64712 + if (globaleffective == curuid)
64713 + effectiveok = 1;
64714 + if (globalfs == curuid)
64715 + fsok = 1;
64716 + }
64717 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64718 + for (i = 0; i < num; i++) {
64719 + curuid = uidlist[i];
64720 + if (globalreal == curuid)
64721 + break;
64722 + if (globaleffective == curuid)
64723 + break;
64724 + if (globalfs == curuid)
64725 + break;
64726 + }
64727 + /* not in deny list */
64728 + if (i == num) {
64729 + realok = 1;
64730 + effectiveok = 1;
64731 + fsok = 1;
64732 + }
64733 + }
64734 +
64735 + if (realok && effectiveok && fsok)
64736 + return 0;
64737 + else {
64738 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64739 + return 1;
64740 + }
64741 +}
64742 +
64743 +int
64744 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64745 +{
64746 + unsigned int i;
64747 + __u16 num;
64748 + gid_t *gidlist;
64749 + gid_t curgid;
64750 + int realok = 0;
64751 + int effectiveok = 0;
64752 + int fsok = 0;
64753 + gid_t globalreal, globaleffective, globalfs;
64754 +
64755 + if (unlikely(!(gr_status & GR_READY)))
64756 + return 0;
64757 +
64758 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64759 + gr_log_learn_gid_change(real, effective, fs);
64760 +
64761 + num = current->acl->group_trans_num;
64762 + gidlist = current->acl->group_transitions;
64763 +
64764 + if (gidlist == NULL)
64765 + return 0;
64766 +
64767 + if (!gid_valid(real)) {
64768 + realok = 1;
64769 + globalreal = (gid_t)-1;
64770 + } else {
64771 + globalreal = GR_GLOBAL_GID(real);
64772 + }
64773 + if (!gid_valid(effective)) {
64774 + effectiveok = 1;
64775 + globaleffective = (gid_t)-1;
64776 + } else {
64777 + globaleffective = GR_GLOBAL_GID(effective);
64778 + }
64779 + if (!gid_valid(fs)) {
64780 + fsok = 1;
64781 + globalfs = (gid_t)-1;
64782 + } else {
64783 + globalfs = GR_GLOBAL_GID(fs);
64784 + }
64785 +
64786 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64787 + for (i = 0; i < num; i++) {
64788 + curgid = gidlist[i];
64789 + if (globalreal == curgid)
64790 + realok = 1;
64791 + if (globaleffective == curgid)
64792 + effectiveok = 1;
64793 + if (globalfs == curgid)
64794 + fsok = 1;
64795 + }
64796 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64797 + for (i = 0; i < num; i++) {
64798 + curgid = gidlist[i];
64799 + if (globalreal == curgid)
64800 + break;
64801 + if (globaleffective == curgid)
64802 + break;
64803 + if (globalfs == curgid)
64804 + break;
64805 + }
64806 + /* not in deny list */
64807 + if (i == num) {
64808 + realok = 1;
64809 + effectiveok = 1;
64810 + fsok = 1;
64811 + }
64812 + }
64813 +
64814 + if (realok && effectiveok && fsok)
64815 + return 0;
64816 + else {
64817 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64818 + return 1;
64819 + }
64820 +}
64821 +
64822 +extern int gr_acl_is_capable(const int cap);
64823 +
64824 +void
64825 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64826 +{
64827 + struct acl_role_label *role = task->role;
64828 + struct acl_subject_label *subj = NULL;
64829 + struct acl_object_label *obj;
64830 + struct file *filp;
64831 + uid_t uid;
64832 + gid_t gid;
64833 +
64834 + if (unlikely(!(gr_status & GR_READY)))
64835 + return;
64836 +
64837 + uid = GR_GLOBAL_UID(kuid);
64838 + gid = GR_GLOBAL_GID(kgid);
64839 +
64840 + filp = task->exec_file;
64841 +
64842 + /* kernel process, we'll give them the kernel role */
64843 + if (unlikely(!filp)) {
64844 + task->role = kernel_role;
64845 + task->acl = kernel_role->root_label;
64846 + return;
64847 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
64848 + role = lookup_acl_role_label(task, uid, gid);
64849 +
64850 + /* don't change the role if we're not a privileged process */
64851 + if (role && task->role != role &&
64852 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64853 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64854 + return;
64855 +
64856 + /* perform subject lookup in possibly new role
64857 + we can use this result below in the case where role == task->role
64858 + */
64859 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64860 +
64861 + /* if we changed uid/gid, but result in the same role
64862 + and are using inheritance, don't lose the inherited subject
64863 + if current subject is other than what normal lookup
64864 + would result in, we arrived via inheritance, don't
64865 + lose subject
64866 + */
64867 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64868 + (subj == task->acl)))
64869 + task->acl = subj;
64870 +
64871 + task->role = role;
64872 +
64873 + task->is_writable = 0;
64874 +
64875 + /* ignore additional mmap checks for processes that are writable
64876 + by the default ACL */
64877 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64878 + if (unlikely(obj->mode & GR_WRITE))
64879 + task->is_writable = 1;
64880 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64881 + if (unlikely(obj->mode & GR_WRITE))
64882 + task->is_writable = 1;
64883 +
64884 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64885 + 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);
64886 +#endif
64887 +
64888 + gr_set_proc_res(task);
64889 +
64890 + return;
64891 +}
64892 +
64893 +int
64894 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64895 + const int unsafe_flags)
64896 +{
64897 + struct task_struct *task = current;
64898 + struct acl_subject_label *newacl;
64899 + struct acl_object_label *obj;
64900 + __u32 retmode;
64901 +
64902 + if (unlikely(!(gr_status & GR_READY)))
64903 + return 0;
64904 +
64905 + newacl = chk_subj_label(dentry, mnt, task->role);
64906 +
64907 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64908 + did an exec
64909 + */
64910 + rcu_read_lock();
64911 + read_lock(&tasklist_lock);
64912 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64913 + (task->parent->acl->mode & GR_POVERRIDE))) {
64914 + read_unlock(&tasklist_lock);
64915 + rcu_read_unlock();
64916 + goto skip_check;
64917 + }
64918 + read_unlock(&tasklist_lock);
64919 + rcu_read_unlock();
64920 +
64921 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64922 + !(task->role->roletype & GR_ROLE_GOD) &&
64923 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64924 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64925 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64926 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64927 + else
64928 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64929 + return -EACCES;
64930 + }
64931 +
64932 +skip_check:
64933 +
64934 + obj = chk_obj_label(dentry, mnt, task->acl);
64935 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64936 +
64937 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64938 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
64939 + if (obj->nested)
64940 + task->acl = obj->nested;
64941 + else
64942 + task->acl = newacl;
64943 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64944 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64945 +
64946 + task->is_writable = 0;
64947 +
64948 + /* ignore additional mmap checks for processes that are writable
64949 + by the default ACL */
64950 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
64951 + if (unlikely(obj->mode & GR_WRITE))
64952 + task->is_writable = 1;
64953 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64954 + if (unlikely(obj->mode & GR_WRITE))
64955 + task->is_writable = 1;
64956 +
64957 + gr_set_proc_res(task);
64958 +
64959 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64960 + 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);
64961 +#endif
64962 + return 0;
64963 +}
64964 +
64965 +/* always called with valid inodev ptr */
64966 +static void
64967 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64968 +{
64969 + struct acl_object_label *matchpo;
64970 + struct acl_subject_label *matchps;
64971 + struct acl_subject_label *subj;
64972 + struct acl_role_label *role;
64973 + unsigned int x;
64974 +
64975 + FOR_EACH_ROLE_START(role)
64976 + FOR_EACH_SUBJECT_START(role, subj, x)
64977 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64978 + matchpo->mode |= GR_DELETED;
64979 + FOR_EACH_SUBJECT_END(subj,x)
64980 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64981 + /* nested subjects aren't in the role's subj_hash table */
64982 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64983 + matchpo->mode |= GR_DELETED;
64984 + FOR_EACH_NESTED_SUBJECT_END(subj)
64985 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64986 + matchps->mode |= GR_DELETED;
64987 + FOR_EACH_ROLE_END(role)
64988 +
64989 + inodev->nentry->deleted = 1;
64990 +
64991 + return;
64992 +}
64993 +
64994 +void
64995 +gr_handle_delete(const ino_t ino, const dev_t dev)
64996 +{
64997 + struct inodev_entry *inodev;
64998 +
64999 + if (unlikely(!(gr_status & GR_READY)))
65000 + return;
65001 +
65002 + write_lock(&gr_inode_lock);
65003 + inodev = lookup_inodev_entry(ino, dev);
65004 + if (inodev != NULL)
65005 + do_handle_delete(inodev, ino, dev);
65006 + write_unlock(&gr_inode_lock);
65007 +
65008 + return;
65009 +}
65010 +
65011 +static void
65012 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
65013 + const ino_t newinode, const dev_t newdevice,
65014 + struct acl_subject_label *subj)
65015 +{
65016 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
65017 + struct acl_object_label *match;
65018 +
65019 + match = subj->obj_hash[index];
65020 +
65021 + while (match && (match->inode != oldinode ||
65022 + match->device != olddevice ||
65023 + !(match->mode & GR_DELETED)))
65024 + match = match->next;
65025 +
65026 + if (match && (match->inode == oldinode)
65027 + && (match->device == olddevice)
65028 + && (match->mode & GR_DELETED)) {
65029 + if (match->prev == NULL) {
65030 + subj->obj_hash[index] = match->next;
65031 + if (match->next != NULL)
65032 + match->next->prev = NULL;
65033 + } else {
65034 + match->prev->next = match->next;
65035 + if (match->next != NULL)
65036 + match->next->prev = match->prev;
65037 + }
65038 + match->prev = NULL;
65039 + match->next = NULL;
65040 + match->inode = newinode;
65041 + match->device = newdevice;
65042 + match->mode &= ~GR_DELETED;
65043 +
65044 + insert_acl_obj_label(match, subj);
65045 + }
65046 +
65047 + return;
65048 +}
65049 +
65050 +static void
65051 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
65052 + const ino_t newinode, const dev_t newdevice,
65053 + struct acl_role_label *role)
65054 +{
65055 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
65056 + struct acl_subject_label *match;
65057 +
65058 + match = role->subj_hash[index];
65059 +
65060 + while (match && (match->inode != oldinode ||
65061 + match->device != olddevice ||
65062 + !(match->mode & GR_DELETED)))
65063 + match = match->next;
65064 +
65065 + if (match && (match->inode == oldinode)
65066 + && (match->device == olddevice)
65067 + && (match->mode & GR_DELETED)) {
65068 + if (match->prev == NULL) {
65069 + role->subj_hash[index] = match->next;
65070 + if (match->next != NULL)
65071 + match->next->prev = NULL;
65072 + } else {
65073 + match->prev->next = match->next;
65074 + if (match->next != NULL)
65075 + match->next->prev = match->prev;
65076 + }
65077 + match->prev = NULL;
65078 + match->next = NULL;
65079 + match->inode = newinode;
65080 + match->device = newdevice;
65081 + match->mode &= ~GR_DELETED;
65082 +
65083 + insert_acl_subj_label(match, role);
65084 + }
65085 +
65086 + return;
65087 +}
65088 +
65089 +static void
65090 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
65091 + const ino_t newinode, const dev_t newdevice)
65092 +{
65093 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
65094 + struct inodev_entry *match;
65095 +
65096 + match = inodev_set.i_hash[index];
65097 +
65098 + while (match && (match->nentry->inode != oldinode ||
65099 + match->nentry->device != olddevice || !match->nentry->deleted))
65100 + match = match->next;
65101 +
65102 + if (match && (match->nentry->inode == oldinode)
65103 + && (match->nentry->device == olddevice) &&
65104 + match->nentry->deleted) {
65105 + if (match->prev == NULL) {
65106 + inodev_set.i_hash[index] = match->next;
65107 + if (match->next != NULL)
65108 + match->next->prev = NULL;
65109 + } else {
65110 + match->prev->next = match->next;
65111 + if (match->next != NULL)
65112 + match->next->prev = match->prev;
65113 + }
65114 + match->prev = NULL;
65115 + match->next = NULL;
65116 + match->nentry->inode = newinode;
65117 + match->nentry->device = newdevice;
65118 + match->nentry->deleted = 0;
65119 +
65120 + insert_inodev_entry(match);
65121 + }
65122 +
65123 + return;
65124 +}
65125 +
65126 +static void
65127 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
65128 +{
65129 + struct acl_subject_label *subj;
65130 + struct acl_role_label *role;
65131 + unsigned int x;
65132 +
65133 + FOR_EACH_ROLE_START(role)
65134 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
65135 +
65136 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65137 + if ((subj->inode == ino) && (subj->device == dev)) {
65138 + subj->inode = ino;
65139 + subj->device = dev;
65140 + }
65141 + /* nested subjects aren't in the role's subj_hash table */
65142 + update_acl_obj_label(matchn->inode, matchn->device,
65143 + ino, dev, subj);
65144 + FOR_EACH_NESTED_SUBJECT_END(subj)
65145 + FOR_EACH_SUBJECT_START(role, subj, x)
65146 + update_acl_obj_label(matchn->inode, matchn->device,
65147 + ino, dev, subj);
65148 + FOR_EACH_SUBJECT_END(subj,x)
65149 + FOR_EACH_ROLE_END(role)
65150 +
65151 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
65152 +
65153 + return;
65154 +}
65155 +
65156 +static void
65157 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
65158 + const struct vfsmount *mnt)
65159 +{
65160 + ino_t ino = dentry->d_inode->i_ino;
65161 + dev_t dev = __get_dev(dentry);
65162 +
65163 + __do_handle_create(matchn, ino, dev);
65164 +
65165 + return;
65166 +}
65167 +
65168 +void
65169 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65170 +{
65171 + struct name_entry *matchn;
65172 +
65173 + if (unlikely(!(gr_status & GR_READY)))
65174 + return;
65175 +
65176 + preempt_disable();
65177 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
65178 +
65179 + if (unlikely((unsigned long)matchn)) {
65180 + write_lock(&gr_inode_lock);
65181 + do_handle_create(matchn, dentry, mnt);
65182 + write_unlock(&gr_inode_lock);
65183 + }
65184 + preempt_enable();
65185 +
65186 + return;
65187 +}
65188 +
65189 +void
65190 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65191 +{
65192 + struct name_entry *matchn;
65193 +
65194 + if (unlikely(!(gr_status & GR_READY)))
65195 + return;
65196 +
65197 + preempt_disable();
65198 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
65199 +
65200 + if (unlikely((unsigned long)matchn)) {
65201 + write_lock(&gr_inode_lock);
65202 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
65203 + write_unlock(&gr_inode_lock);
65204 + }
65205 + preempt_enable();
65206 +
65207 + return;
65208 +}
65209 +
65210 +void
65211 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65212 + struct dentry *old_dentry,
65213 + struct dentry *new_dentry,
65214 + struct vfsmount *mnt, const __u8 replace)
65215 +{
65216 + struct name_entry *matchn;
65217 + struct inodev_entry *inodev;
65218 + struct inode *inode = new_dentry->d_inode;
65219 + ino_t old_ino = old_dentry->d_inode->i_ino;
65220 + dev_t old_dev = __get_dev(old_dentry);
65221 +
65222 + /* vfs_rename swaps the name and parent link for old_dentry and
65223 + new_dentry
65224 + at this point, old_dentry has the new name, parent link, and inode
65225 + for the renamed file
65226 + if a file is being replaced by a rename, new_dentry has the inode
65227 + and name for the replaced file
65228 + */
65229 +
65230 + if (unlikely(!(gr_status & GR_READY)))
65231 + return;
65232 +
65233 + preempt_disable();
65234 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65235 +
65236 + /* we wouldn't have to check d_inode if it weren't for
65237 + NFS silly-renaming
65238 + */
65239 +
65240 + write_lock(&gr_inode_lock);
65241 + if (unlikely(replace && inode)) {
65242 + ino_t new_ino = inode->i_ino;
65243 + dev_t new_dev = __get_dev(new_dentry);
65244 +
65245 + inodev = lookup_inodev_entry(new_ino, new_dev);
65246 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65247 + do_handle_delete(inodev, new_ino, new_dev);
65248 + }
65249 +
65250 + inodev = lookup_inodev_entry(old_ino, old_dev);
65251 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65252 + do_handle_delete(inodev, old_ino, old_dev);
65253 +
65254 + if (unlikely((unsigned long)matchn))
65255 + do_handle_create(matchn, old_dentry, mnt);
65256 +
65257 + write_unlock(&gr_inode_lock);
65258 + preempt_enable();
65259 +
65260 + return;
65261 +}
65262 +
65263 +static int
65264 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
65265 + unsigned char **sum)
65266 +{
65267 + struct acl_role_label *r;
65268 + struct role_allowed_ip *ipp;
65269 + struct role_transition *trans;
65270 + unsigned int i;
65271 + int found = 0;
65272 + u32 curr_ip = current->signal->curr_ip;
65273 +
65274 + current->signal->saved_ip = curr_ip;
65275 +
65276 + /* check transition table */
65277 +
65278 + for (trans = current->role->transitions; trans; trans = trans->next) {
65279 + if (!strcmp(rolename, trans->rolename)) {
65280 + found = 1;
65281 + break;
65282 + }
65283 + }
65284 +
65285 + if (!found)
65286 + return 0;
65287 +
65288 + /* handle special roles that do not require authentication
65289 + and check ip */
65290 +
65291 + FOR_EACH_ROLE_START(r)
65292 + if (!strcmp(rolename, r->rolename) &&
65293 + (r->roletype & GR_ROLE_SPECIAL)) {
65294 + found = 0;
65295 + if (r->allowed_ips != NULL) {
65296 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
65297 + if ((ntohl(curr_ip) & ipp->netmask) ==
65298 + (ntohl(ipp->addr) & ipp->netmask))
65299 + found = 1;
65300 + }
65301 + } else
65302 + found = 2;
65303 + if (!found)
65304 + return 0;
65305 +
65306 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
65307 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
65308 + *salt = NULL;
65309 + *sum = NULL;
65310 + return 1;
65311 + }
65312 + }
65313 + FOR_EACH_ROLE_END(r)
65314 +
65315 + for (i = 0; i < num_sprole_pws; i++) {
65316 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
65317 + *salt = acl_special_roles[i]->salt;
65318 + *sum = acl_special_roles[i]->sum;
65319 + return 1;
65320 + }
65321 + }
65322 +
65323 + return 0;
65324 +}
65325 +
65326 +static void
65327 +assign_special_role(char *rolename)
65328 +{
65329 + struct acl_object_label *obj;
65330 + struct acl_role_label *r;
65331 + struct acl_role_label *assigned = NULL;
65332 + struct task_struct *tsk;
65333 + struct file *filp;
65334 +
65335 + FOR_EACH_ROLE_START(r)
65336 + if (!strcmp(rolename, r->rolename) &&
65337 + (r->roletype & GR_ROLE_SPECIAL)) {
65338 + assigned = r;
65339 + break;
65340 + }
65341 + FOR_EACH_ROLE_END(r)
65342 +
65343 + if (!assigned)
65344 + return;
65345 +
65346 + read_lock(&tasklist_lock);
65347 + read_lock(&grsec_exec_file_lock);
65348 +
65349 + tsk = current->real_parent;
65350 + if (tsk == NULL)
65351 + goto out_unlock;
65352 +
65353 + filp = tsk->exec_file;
65354 + if (filp == NULL)
65355 + goto out_unlock;
65356 +
65357 + tsk->is_writable = 0;
65358 +
65359 + tsk->acl_sp_role = 1;
65360 + tsk->acl_role_id = ++acl_sp_role_value;
65361 + tsk->role = assigned;
65362 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
65363 +
65364 + /* ignore additional mmap checks for processes that are writable
65365 + by the default ACL */
65366 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65367 + if (unlikely(obj->mode & GR_WRITE))
65368 + tsk->is_writable = 1;
65369 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
65370 + if (unlikely(obj->mode & GR_WRITE))
65371 + tsk->is_writable = 1;
65372 +
65373 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65374 + 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));
65375 +#endif
65376 +
65377 +out_unlock:
65378 + read_unlock(&grsec_exec_file_lock);
65379 + read_unlock(&tasklist_lock);
65380 + return;
65381 +}
65382 +
65383 +int gr_check_secure_terminal(struct task_struct *task)
65384 +{
65385 + struct task_struct *p, *p2, *p3;
65386 + struct files_struct *files;
65387 + struct fdtable *fdt;
65388 + struct file *our_file = NULL, *file;
65389 + int i;
65390 +
65391 + if (task->signal->tty == NULL)
65392 + return 1;
65393 +
65394 + files = get_files_struct(task);
65395 + if (files != NULL) {
65396 + rcu_read_lock();
65397 + fdt = files_fdtable(files);
65398 + for (i=0; i < fdt->max_fds; i++) {
65399 + file = fcheck_files(files, i);
65400 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
65401 + get_file(file);
65402 + our_file = file;
65403 + }
65404 + }
65405 + rcu_read_unlock();
65406 + put_files_struct(files);
65407 + }
65408 +
65409 + if (our_file == NULL)
65410 + return 1;
65411 +
65412 + read_lock(&tasklist_lock);
65413 + do_each_thread(p2, p) {
65414 + files = get_files_struct(p);
65415 + if (files == NULL ||
65416 + (p->signal && p->signal->tty == task->signal->tty)) {
65417 + if (files != NULL)
65418 + put_files_struct(files);
65419 + continue;
65420 + }
65421 + rcu_read_lock();
65422 + fdt = files_fdtable(files);
65423 + for (i=0; i < fdt->max_fds; i++) {
65424 + file = fcheck_files(files, i);
65425 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
65426 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
65427 + p3 = task;
65428 + while (task_pid_nr(p3) > 0) {
65429 + if (p3 == p)
65430 + break;
65431 + p3 = p3->real_parent;
65432 + }
65433 + if (p3 == p)
65434 + break;
65435 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
65436 + gr_handle_alertkill(p);
65437 + rcu_read_unlock();
65438 + put_files_struct(files);
65439 + read_unlock(&tasklist_lock);
65440 + fput(our_file);
65441 + return 0;
65442 + }
65443 + }
65444 + rcu_read_unlock();
65445 + put_files_struct(files);
65446 + } while_each_thread(p2, p);
65447 + read_unlock(&tasklist_lock);
65448 +
65449 + fput(our_file);
65450 + return 1;
65451 +}
65452 +
65453 +static int gr_rbac_disable(void *unused)
65454 +{
65455 + pax_open_kernel();
65456 + gr_status &= ~GR_READY;
65457 + pax_close_kernel();
65458 +
65459 + return 0;
65460 +}
65461 +
65462 +ssize_t
65463 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
65464 +{
65465 + struct gr_arg_wrapper uwrap;
65466 + unsigned char *sprole_salt = NULL;
65467 + unsigned char *sprole_sum = NULL;
65468 + int error = 0;
65469 + int error2 = 0;
65470 + size_t req_count = 0;
65471 +
65472 + mutex_lock(&gr_dev_mutex);
65473 +
65474 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
65475 + error = -EPERM;
65476 + goto out;
65477 + }
65478 +
65479 +#ifdef CONFIG_COMPAT
65480 + pax_open_kernel();
65481 + if (is_compat_task()) {
65482 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
65483 + copy_gr_arg = &copy_gr_arg_compat;
65484 + copy_acl_object_label = &copy_acl_object_label_compat;
65485 + copy_acl_subject_label = &copy_acl_subject_label_compat;
65486 + copy_acl_role_label = &copy_acl_role_label_compat;
65487 + copy_acl_ip_label = &copy_acl_ip_label_compat;
65488 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
65489 + copy_role_transition = &copy_role_transition_compat;
65490 + copy_sprole_pw = &copy_sprole_pw_compat;
65491 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
65492 + copy_pointer_from_array = &copy_pointer_from_array_compat;
65493 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
65494 + } else {
65495 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
65496 + copy_gr_arg = &copy_gr_arg_normal;
65497 + copy_acl_object_label = &copy_acl_object_label_normal;
65498 + copy_acl_subject_label = &copy_acl_subject_label_normal;
65499 + copy_acl_role_label = &copy_acl_role_label_normal;
65500 + copy_acl_ip_label = &copy_acl_ip_label_normal;
65501 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
65502 + copy_role_transition = &copy_role_transition_normal;
65503 + copy_sprole_pw = &copy_sprole_pw_normal;
65504 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
65505 + copy_pointer_from_array = &copy_pointer_from_array_normal;
65506 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
65507 + }
65508 + pax_close_kernel();
65509 +#endif
65510 +
65511 + req_count = get_gr_arg_wrapper_size();
65512 +
65513 + if (count != req_count) {
65514 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
65515 + error = -EINVAL;
65516 + goto out;
65517 + }
65518 +
65519 +
65520 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
65521 + gr_auth_expires = 0;
65522 + gr_auth_attempts = 0;
65523 + }
65524 +
65525 + error = copy_gr_arg_wrapper(buf, &uwrap);
65526 + if (error)
65527 + goto out;
65528 +
65529 + error = copy_gr_arg(uwrap.arg, gr_usermode);
65530 + if (error)
65531 + goto out;
65532 +
65533 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65534 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65535 + time_after(gr_auth_expires, get_seconds())) {
65536 + error = -EBUSY;
65537 + goto out;
65538 + }
65539 +
65540 + /* if non-root trying to do anything other than use a special role,
65541 + do not attempt authentication, do not count towards authentication
65542 + locking
65543 + */
65544 +
65545 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
65546 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65547 + gr_is_global_nonroot(current_uid())) {
65548 + error = -EPERM;
65549 + goto out;
65550 + }
65551 +
65552 + /* ensure pw and special role name are null terminated */
65553 +
65554 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
65555 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
65556 +
65557 + /* Okay.
65558 + * We have our enough of the argument structure..(we have yet
65559 + * to copy_from_user the tables themselves) . Copy the tables
65560 + * only if we need them, i.e. for loading operations. */
65561 +
65562 + switch (gr_usermode->mode) {
65563 + case GR_STATUS:
65564 + if (gr_status & GR_READY) {
65565 + error = 1;
65566 + if (!gr_check_secure_terminal(current))
65567 + error = 3;
65568 + } else
65569 + error = 2;
65570 + goto out;
65571 + case GR_SHUTDOWN:
65572 + if ((gr_status & GR_READY)
65573 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65574 + stop_machine(gr_rbac_disable, NULL, NULL);
65575 + free_variables();
65576 + memset(gr_usermode, 0, sizeof (struct gr_arg));
65577 + memset(gr_system_salt, 0, GR_SALT_LEN);
65578 + memset(gr_system_sum, 0, GR_SHA_LEN);
65579 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
65580 + } else if (gr_status & GR_READY) {
65581 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
65582 + error = -EPERM;
65583 + } else {
65584 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
65585 + error = -EAGAIN;
65586 + }
65587 + break;
65588 + case GR_ENABLE:
65589 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
65590 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
65591 + else {
65592 + if (gr_status & GR_READY)
65593 + error = -EAGAIN;
65594 + else
65595 + error = error2;
65596 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
65597 + }
65598 + break;
65599 + case GR_RELOAD:
65600 + if (!(gr_status & GR_READY)) {
65601 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
65602 + error = -EAGAIN;
65603 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65604 + stop_machine(gr_rbac_disable, NULL, NULL);
65605 + free_variables();
65606 + error2 = gracl_init(gr_usermode);
65607 + if (!error2)
65608 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
65609 + else {
65610 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65611 + error = error2;
65612 + }
65613 + } else {
65614 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65615 + error = -EPERM;
65616 + }
65617 + break;
65618 + case GR_SEGVMOD:
65619 + if (unlikely(!(gr_status & GR_READY))) {
65620 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
65621 + error = -EAGAIN;
65622 + break;
65623 + }
65624 +
65625 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65626 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
65627 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
65628 + struct acl_subject_label *segvacl;
65629 + segvacl =
65630 + lookup_acl_subj_label(gr_usermode->segv_inode,
65631 + gr_usermode->segv_device,
65632 + current->role);
65633 + if (segvacl) {
65634 + segvacl->crashes = 0;
65635 + segvacl->expires = 0;
65636 + }
65637 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
65638 + gr_remove_uid(gr_usermode->segv_uid);
65639 + }
65640 + } else {
65641 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
65642 + error = -EPERM;
65643 + }
65644 + break;
65645 + case GR_SPROLE:
65646 + case GR_SPROLEPAM:
65647 + if (unlikely(!(gr_status & GR_READY))) {
65648 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
65649 + error = -EAGAIN;
65650 + break;
65651 + }
65652 +
65653 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
65654 + current->role->expires = 0;
65655 + current->role->auth_attempts = 0;
65656 + }
65657 +
65658 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65659 + time_after(current->role->expires, get_seconds())) {
65660 + error = -EBUSY;
65661 + goto out;
65662 + }
65663 +
65664 + if (lookup_special_role_auth
65665 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
65666 + && ((!sprole_salt && !sprole_sum)
65667 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
65668 + char *p = "";
65669 + assign_special_role(gr_usermode->sp_role);
65670 + read_lock(&tasklist_lock);
65671 + if (current->real_parent)
65672 + p = current->real_parent->role->rolename;
65673 + read_unlock(&tasklist_lock);
65674 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
65675 + p, acl_sp_role_value);
65676 + } else {
65677 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
65678 + error = -EPERM;
65679 + if(!(current->role->auth_attempts++))
65680 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65681 +
65682 + goto out;
65683 + }
65684 + break;
65685 + case GR_UNSPROLE:
65686 + if (unlikely(!(gr_status & GR_READY))) {
65687 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
65688 + error = -EAGAIN;
65689 + break;
65690 + }
65691 +
65692 + if (current->role->roletype & GR_ROLE_SPECIAL) {
65693 + char *p = "";
65694 + int i = 0;
65695 +
65696 + read_lock(&tasklist_lock);
65697 + if (current->real_parent) {
65698 + p = current->real_parent->role->rolename;
65699 + i = current->real_parent->acl_role_id;
65700 + }
65701 + read_unlock(&tasklist_lock);
65702 +
65703 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
65704 + gr_set_acls(1);
65705 + } else {
65706 + error = -EPERM;
65707 + goto out;
65708 + }
65709 + break;
65710 + default:
65711 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
65712 + error = -EINVAL;
65713 + break;
65714 + }
65715 +
65716 + if (error != -EPERM)
65717 + goto out;
65718 +
65719 + if(!(gr_auth_attempts++))
65720 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65721 +
65722 + out:
65723 + mutex_unlock(&gr_dev_mutex);
65724 +
65725 + if (!error)
65726 + error = req_count;
65727 +
65728 + return error;
65729 +}
65730 +
65731 +/* must be called with
65732 + rcu_read_lock();
65733 + read_lock(&tasklist_lock);
65734 + read_lock(&grsec_exec_file_lock);
65735 +*/
65736 +int gr_apply_subject_to_task(struct task_struct *task)
65737 +{
65738 + struct acl_object_label *obj;
65739 + char *tmpname;
65740 + struct acl_subject_label *tmpsubj;
65741 + struct file *filp;
65742 + struct name_entry *nmatch;
65743 +
65744 + filp = task->exec_file;
65745 + if (filp == NULL)
65746 + return 0;
65747 +
65748 + /* the following is to apply the correct subject
65749 + on binaries running when the RBAC system
65750 + is enabled, when the binaries have been
65751 + replaced or deleted since their execution
65752 + -----
65753 + when the RBAC system starts, the inode/dev
65754 + from exec_file will be one the RBAC system
65755 + is unaware of. It only knows the inode/dev
65756 + of the present file on disk, or the absence
65757 + of it.
65758 + */
65759 + preempt_disable();
65760 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
65761 +
65762 + nmatch = lookup_name_entry(tmpname);
65763 + preempt_enable();
65764 + tmpsubj = NULL;
65765 + if (nmatch) {
65766 + if (nmatch->deleted)
65767 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
65768 + else
65769 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
65770 + if (tmpsubj != NULL)
65771 + task->acl = tmpsubj;
65772 + }
65773 + if (tmpsubj == NULL)
65774 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
65775 + task->role);
65776 + if (task->acl) {
65777 + task->is_writable = 0;
65778 + /* ignore additional mmap checks for processes that are writable
65779 + by the default ACL */
65780 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65781 + if (unlikely(obj->mode & GR_WRITE))
65782 + task->is_writable = 1;
65783 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65784 + if (unlikely(obj->mode & GR_WRITE))
65785 + task->is_writable = 1;
65786 +
65787 + gr_set_proc_res(task);
65788 +
65789 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65790 + 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);
65791 +#endif
65792 + } else {
65793 + return 1;
65794 + }
65795 +
65796 + return 0;
65797 +}
65798 +
65799 +int
65800 +gr_set_acls(const int type)
65801 +{
65802 + struct task_struct *task, *task2;
65803 + struct acl_role_label *role = current->role;
65804 + __u16 acl_role_id = current->acl_role_id;
65805 + const struct cred *cred;
65806 + int ret;
65807 +
65808 + rcu_read_lock();
65809 + read_lock(&tasklist_lock);
65810 + read_lock(&grsec_exec_file_lock);
65811 + do_each_thread(task2, task) {
65812 + /* check to see if we're called from the exit handler,
65813 + if so, only replace ACLs that have inherited the admin
65814 + ACL */
65815 +
65816 + if (type && (task->role != role ||
65817 + task->acl_role_id != acl_role_id))
65818 + continue;
65819 +
65820 + task->acl_role_id = 0;
65821 + task->acl_sp_role = 0;
65822 +
65823 + if (task->exec_file) {
65824 + cred = __task_cred(task);
65825 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
65826 + ret = gr_apply_subject_to_task(task);
65827 + if (ret) {
65828 + read_unlock(&grsec_exec_file_lock);
65829 + read_unlock(&tasklist_lock);
65830 + rcu_read_unlock();
65831 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
65832 + return ret;
65833 + }
65834 + } else {
65835 + // it's a kernel process
65836 + task->role = kernel_role;
65837 + task->acl = kernel_role->root_label;
65838 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
65839 + task->acl->mode &= ~GR_PROCFIND;
65840 +#endif
65841 + }
65842 + } while_each_thread(task2, task);
65843 + read_unlock(&grsec_exec_file_lock);
65844 + read_unlock(&tasklist_lock);
65845 + rcu_read_unlock();
65846 +
65847 + return 0;
65848 +}
65849 +
65850 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65851 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65852 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65853 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65854 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65855 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65856 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65857 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65858 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65859 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65860 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65861 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65862 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65863 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65864 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65865 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65866 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65867 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65868 +};
65869 +
65870 +void
65871 +gr_learn_resource(const struct task_struct *task,
65872 + const int res, const unsigned long wanted, const int gt)
65873 +{
65874 + struct acl_subject_label *acl;
65875 + const struct cred *cred;
65876 +
65877 + if (unlikely((gr_status & GR_READY) &&
65878 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65879 + goto skip_reslog;
65880 +
65881 + gr_log_resource(task, res, wanted, gt);
65882 +skip_reslog:
65883 +
65884 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65885 + return;
65886 +
65887 + acl = task->acl;
65888 +
65889 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65890 + !(acl->resmask & (1U << (unsigned short) res))))
65891 + return;
65892 +
65893 + if (wanted >= acl->res[res].rlim_cur) {
65894 + unsigned long res_add;
65895 +
65896 + res_add = wanted + res_learn_bumps[res];
65897 +
65898 + acl->res[res].rlim_cur = res_add;
65899 +
65900 + if (wanted > acl->res[res].rlim_max)
65901 + acl->res[res].rlim_max = res_add;
65902 +
65903 + /* only log the subject filename, since resource logging is supported for
65904 + single-subject learning only */
65905 + rcu_read_lock();
65906 + cred = __task_cred(task);
65907 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65908 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65909 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65910 + "", (unsigned long) res, &task->signal->saved_ip);
65911 + rcu_read_unlock();
65912 + }
65913 +
65914 + return;
65915 +}
65916 +EXPORT_SYMBOL(gr_learn_resource);
65917 +#endif
65918 +
65919 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65920 +void
65921 +pax_set_initial_flags(struct linux_binprm *bprm)
65922 +{
65923 + struct task_struct *task = current;
65924 + struct acl_subject_label *proc;
65925 + unsigned long flags;
65926 +
65927 + if (unlikely(!(gr_status & GR_READY)))
65928 + return;
65929 +
65930 + flags = pax_get_flags(task);
65931 +
65932 + proc = task->acl;
65933 +
65934 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65935 + flags &= ~MF_PAX_PAGEEXEC;
65936 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65937 + flags &= ~MF_PAX_SEGMEXEC;
65938 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
65939 + flags &= ~MF_PAX_RANDMMAP;
65940 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
65941 + flags &= ~MF_PAX_EMUTRAMP;
65942 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
65943 + flags &= ~MF_PAX_MPROTECT;
65944 +
65945 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
65946 + flags |= MF_PAX_PAGEEXEC;
65947 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
65948 + flags |= MF_PAX_SEGMEXEC;
65949 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
65950 + flags |= MF_PAX_RANDMMAP;
65951 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
65952 + flags |= MF_PAX_EMUTRAMP;
65953 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
65954 + flags |= MF_PAX_MPROTECT;
65955 +
65956 + pax_set_flags(task, flags);
65957 +
65958 + return;
65959 +}
65960 +#endif
65961 +
65962 +int
65963 +gr_handle_proc_ptrace(struct task_struct *task)
65964 +{
65965 + struct file *filp;
65966 + struct task_struct *tmp = task;
65967 + struct task_struct *curtemp = current;
65968 + __u32 retmode;
65969 +
65970 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65971 + if (unlikely(!(gr_status & GR_READY)))
65972 + return 0;
65973 +#endif
65974 +
65975 + read_lock(&tasklist_lock);
65976 + read_lock(&grsec_exec_file_lock);
65977 + filp = task->exec_file;
65978 +
65979 + while (task_pid_nr(tmp) > 0) {
65980 + if (tmp == curtemp)
65981 + break;
65982 + tmp = tmp->real_parent;
65983 + }
65984 +
65985 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65986 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
65987 + read_unlock(&grsec_exec_file_lock);
65988 + read_unlock(&tasklist_lock);
65989 + return 1;
65990 + }
65991 +
65992 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65993 + if (!(gr_status & GR_READY)) {
65994 + read_unlock(&grsec_exec_file_lock);
65995 + read_unlock(&tasklist_lock);
65996 + return 0;
65997 + }
65998 +#endif
65999 +
66000 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
66001 + read_unlock(&grsec_exec_file_lock);
66002 + read_unlock(&tasklist_lock);
66003 +
66004 + if (retmode & GR_NOPTRACE)
66005 + return 1;
66006 +
66007 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
66008 + && (current->acl != task->acl || (current->acl != current->role->root_label
66009 + && task_pid_nr(current) != task_pid_nr(task))))
66010 + return 1;
66011 +
66012 + return 0;
66013 +}
66014 +
66015 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
66016 +{
66017 + if (unlikely(!(gr_status & GR_READY)))
66018 + return;
66019 +
66020 + if (!(current->role->roletype & GR_ROLE_GOD))
66021 + return;
66022 +
66023 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
66024 + p->role->rolename, gr_task_roletype_to_char(p),
66025 + p->acl->filename);
66026 +}
66027 +
66028 +int
66029 +gr_handle_ptrace(struct task_struct *task, const long request)
66030 +{
66031 + struct task_struct *tmp = task;
66032 + struct task_struct *curtemp = current;
66033 + __u32 retmode;
66034 +
66035 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66036 + if (unlikely(!(gr_status & GR_READY)))
66037 + return 0;
66038 +#endif
66039 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
66040 + read_lock(&tasklist_lock);
66041 + while (task_pid_nr(tmp) > 0) {
66042 + if (tmp == curtemp)
66043 + break;
66044 + tmp = tmp->real_parent;
66045 + }
66046 +
66047 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66048 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
66049 + read_unlock(&tasklist_lock);
66050 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66051 + return 1;
66052 + }
66053 + read_unlock(&tasklist_lock);
66054 + }
66055 +
66056 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66057 + if (!(gr_status & GR_READY))
66058 + return 0;
66059 +#endif
66060 +
66061 + read_lock(&grsec_exec_file_lock);
66062 + if (unlikely(!task->exec_file)) {
66063 + read_unlock(&grsec_exec_file_lock);
66064 + return 0;
66065 + }
66066 +
66067 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
66068 + read_unlock(&grsec_exec_file_lock);
66069 +
66070 + if (retmode & GR_NOPTRACE) {
66071 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66072 + return 1;
66073 + }
66074 +
66075 + if (retmode & GR_PTRACERD) {
66076 + switch (request) {
66077 + case PTRACE_SEIZE:
66078 + case PTRACE_POKETEXT:
66079 + case PTRACE_POKEDATA:
66080 + case PTRACE_POKEUSR:
66081 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
66082 + case PTRACE_SETREGS:
66083 + case PTRACE_SETFPREGS:
66084 +#endif
66085 +#ifdef CONFIG_X86
66086 + case PTRACE_SETFPXREGS:
66087 +#endif
66088 +#ifdef CONFIG_ALTIVEC
66089 + case PTRACE_SETVRREGS:
66090 +#endif
66091 + return 1;
66092 + default:
66093 + return 0;
66094 + }
66095 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
66096 + !(current->role->roletype & GR_ROLE_GOD) &&
66097 + (current->acl != task->acl)) {
66098 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66099 + return 1;
66100 + }
66101 +
66102 + return 0;
66103 +}
66104 +
66105 +static int is_writable_mmap(const struct file *filp)
66106 +{
66107 + struct task_struct *task = current;
66108 + struct acl_object_label *obj, *obj2;
66109 +
66110 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
66111 + !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))) {
66112 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66113 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
66114 + task->role->root_label);
66115 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
66116 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
66117 + return 1;
66118 + }
66119 + }
66120 + return 0;
66121 +}
66122 +
66123 +int
66124 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
66125 +{
66126 + __u32 mode;
66127 +
66128 + if (unlikely(!file || !(prot & PROT_EXEC)))
66129 + return 1;
66130 +
66131 + if (is_writable_mmap(file))
66132 + return 0;
66133 +
66134 + mode =
66135 + gr_search_file(file->f_path.dentry,
66136 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66137 + file->f_path.mnt);
66138 +
66139 + if (!gr_tpe_allow(file))
66140 + return 0;
66141 +
66142 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66143 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66144 + return 0;
66145 + } else if (unlikely(!(mode & GR_EXEC))) {
66146 + return 0;
66147 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66148 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66149 + return 1;
66150 + }
66151 +
66152 + return 1;
66153 +}
66154 +
66155 +int
66156 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
66157 +{
66158 + __u32 mode;
66159 +
66160 + if (unlikely(!file || !(prot & PROT_EXEC)))
66161 + return 1;
66162 +
66163 + if (is_writable_mmap(file))
66164 + return 0;
66165 +
66166 + mode =
66167 + gr_search_file(file->f_path.dentry,
66168 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66169 + file->f_path.mnt);
66170 +
66171 + if (!gr_tpe_allow(file))
66172 + return 0;
66173 +
66174 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66175 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66176 + return 0;
66177 + } else if (unlikely(!(mode & GR_EXEC))) {
66178 + return 0;
66179 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66180 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66181 + return 1;
66182 + }
66183 +
66184 + return 1;
66185 +}
66186 +
66187 +void
66188 +gr_acl_handle_psacct(struct task_struct *task, const long code)
66189 +{
66190 + unsigned long runtime;
66191 + unsigned long cputime;
66192 + unsigned int wday, cday;
66193 + __u8 whr, chr;
66194 + __u8 wmin, cmin;
66195 + __u8 wsec, csec;
66196 + struct timespec timeval;
66197 +
66198 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
66199 + !(task->acl->mode & GR_PROCACCT)))
66200 + return;
66201 +
66202 + do_posix_clock_monotonic_gettime(&timeval);
66203 + runtime = timeval.tv_sec - task->start_time.tv_sec;
66204 + wday = runtime / (3600 * 24);
66205 + runtime -= wday * (3600 * 24);
66206 + whr = runtime / 3600;
66207 + runtime -= whr * 3600;
66208 + wmin = runtime / 60;
66209 + runtime -= wmin * 60;
66210 + wsec = runtime;
66211 +
66212 + cputime = (task->utime + task->stime) / HZ;
66213 + cday = cputime / (3600 * 24);
66214 + cputime -= cday * (3600 * 24);
66215 + chr = cputime / 3600;
66216 + cputime -= chr * 3600;
66217 + cmin = cputime / 60;
66218 + cputime -= cmin * 60;
66219 + csec = cputime;
66220 +
66221 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
66222 +
66223 + return;
66224 +}
66225 +
66226 +void gr_set_kernel_label(struct task_struct *task)
66227 +{
66228 + if (gr_status & GR_READY) {
66229 + task->role = kernel_role;
66230 + task->acl = kernel_role->root_label;
66231 + }
66232 + return;
66233 +}
66234 +
66235 +#ifdef CONFIG_TASKSTATS
66236 +int gr_is_taskstats_denied(int pid)
66237 +{
66238 + struct task_struct *task;
66239 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66240 + const struct cred *cred;
66241 +#endif
66242 + int ret = 0;
66243 +
66244 + /* restrict taskstats viewing to un-chrooted root users
66245 + who have the 'view' subject flag if the RBAC system is enabled
66246 + */
66247 +
66248 + rcu_read_lock();
66249 + read_lock(&tasklist_lock);
66250 + task = find_task_by_vpid(pid);
66251 + if (task) {
66252 +#ifdef CONFIG_GRKERNSEC_CHROOT
66253 + if (proc_is_chrooted(task))
66254 + ret = -EACCES;
66255 +#endif
66256 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66257 + cred = __task_cred(task);
66258 +#ifdef CONFIG_GRKERNSEC_PROC_USER
66259 + if (gr_is_global_nonroot(cred->uid))
66260 + ret = -EACCES;
66261 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66262 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
66263 + ret = -EACCES;
66264 +#endif
66265 +#endif
66266 + if (gr_status & GR_READY) {
66267 + if (!(task->acl->mode & GR_VIEW))
66268 + ret = -EACCES;
66269 + }
66270 + } else
66271 + ret = -ENOENT;
66272 +
66273 + read_unlock(&tasklist_lock);
66274 + rcu_read_unlock();
66275 +
66276 + return ret;
66277 +}
66278 +#endif
66279 +
66280 +/* AUXV entries are filled via a descendant of search_binary_handler
66281 + after we've already applied the subject for the target
66282 +*/
66283 +int gr_acl_enable_at_secure(void)
66284 +{
66285 + if (unlikely(!(gr_status & GR_READY)))
66286 + return 0;
66287 +
66288 + if (current->acl->mode & GR_ATSECURE)
66289 + return 1;
66290 +
66291 + return 0;
66292 +}
66293 +
66294 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66295 +{
66296 + struct task_struct *task = current;
66297 + struct dentry *dentry = file->f_path.dentry;
66298 + struct vfsmount *mnt = file->f_path.mnt;
66299 + struct acl_object_label *obj, *tmp;
66300 + struct acl_subject_label *subj;
66301 + unsigned int bufsize;
66302 + int is_not_root;
66303 + char *path;
66304 + dev_t dev = __get_dev(dentry);
66305 +
66306 + if (unlikely(!(gr_status & GR_READY)))
66307 + return 1;
66308 +
66309 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66310 + return 1;
66311 +
66312 + /* ignore Eric Biederman */
66313 + if (IS_PRIVATE(dentry->d_inode))
66314 + return 1;
66315 +
66316 + subj = task->acl;
66317 + read_lock(&gr_inode_lock);
66318 + do {
66319 + obj = lookup_acl_obj_label(ino, dev, subj);
66320 + if (obj != NULL) {
66321 + read_unlock(&gr_inode_lock);
66322 + return (obj->mode & GR_FIND) ? 1 : 0;
66323 + }
66324 + } while ((subj = subj->parent_subject));
66325 + read_unlock(&gr_inode_lock);
66326 +
66327 + /* this is purely an optimization since we're looking for an object
66328 + for the directory we're doing a readdir on
66329 + if it's possible for any globbed object to match the entry we're
66330 + filling into the directory, then the object we find here will be
66331 + an anchor point with attached globbed objects
66332 + */
66333 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66334 + if (obj->globbed == NULL)
66335 + return (obj->mode & GR_FIND) ? 1 : 0;
66336 +
66337 + is_not_root = ((obj->filename[0] == '/') &&
66338 + (obj->filename[1] == '\0')) ? 0 : 1;
66339 + bufsize = PAGE_SIZE - namelen - is_not_root;
66340 +
66341 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66342 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66343 + return 1;
66344 +
66345 + preempt_disable();
66346 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66347 + bufsize);
66348 +
66349 + bufsize = strlen(path);
66350 +
66351 + /* if base is "/", don't append an additional slash */
66352 + if (is_not_root)
66353 + *(path + bufsize) = '/';
66354 + memcpy(path + bufsize + is_not_root, name, namelen);
66355 + *(path + bufsize + namelen + is_not_root) = '\0';
66356 +
66357 + tmp = obj->globbed;
66358 + while (tmp) {
66359 + if (!glob_match(tmp->filename, path)) {
66360 + preempt_enable();
66361 + return (tmp->mode & GR_FIND) ? 1 : 0;
66362 + }
66363 + tmp = tmp->next;
66364 + }
66365 + preempt_enable();
66366 + return (obj->mode & GR_FIND) ? 1 : 0;
66367 +}
66368 +
66369 +void gr_put_exec_file(struct task_struct *task)
66370 +{
66371 + struct file *filp;
66372 +
66373 + write_lock(&grsec_exec_file_lock);
66374 + filp = task->exec_file;
66375 + task->exec_file = NULL;
66376 + write_unlock(&grsec_exec_file_lock);
66377 +
66378 + if (filp)
66379 + fput(filp);
66380 +
66381 + return;
66382 +}
66383 +
66384 +
66385 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66386 +EXPORT_SYMBOL(gr_acl_is_enabled);
66387 +#endif
66388 +EXPORT_SYMBOL(gr_set_kernel_label);
66389 +#ifdef CONFIG_SECURITY
66390 +EXPORT_SYMBOL(gr_check_user_change);
66391 +EXPORT_SYMBOL(gr_check_group_change);
66392 +#endif
66393 +
66394 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66395 new file mode 100644
66396 index 0000000..34fefda
66397 --- /dev/null
66398 +++ b/grsecurity/gracl_alloc.c
66399 @@ -0,0 +1,105 @@
66400 +#include <linux/kernel.h>
66401 +#include <linux/mm.h>
66402 +#include <linux/slab.h>
66403 +#include <linux/vmalloc.h>
66404 +#include <linux/gracl.h>
66405 +#include <linux/grsecurity.h>
66406 +
66407 +static unsigned long alloc_stack_next = 1;
66408 +static unsigned long alloc_stack_size = 1;
66409 +static void **alloc_stack;
66410 +
66411 +static __inline__ int
66412 +alloc_pop(void)
66413 +{
66414 + if (alloc_stack_next == 1)
66415 + return 0;
66416 +
66417 + kfree(alloc_stack[alloc_stack_next - 2]);
66418 +
66419 + alloc_stack_next--;
66420 +
66421 + return 1;
66422 +}
66423 +
66424 +static __inline__ int
66425 +alloc_push(void *buf)
66426 +{
66427 + if (alloc_stack_next >= alloc_stack_size)
66428 + return 1;
66429 +
66430 + alloc_stack[alloc_stack_next - 1] = buf;
66431 +
66432 + alloc_stack_next++;
66433 +
66434 + return 0;
66435 +}
66436 +
66437 +void *
66438 +acl_alloc(unsigned long len)
66439 +{
66440 + void *ret = NULL;
66441 +
66442 + if (!len || len > PAGE_SIZE)
66443 + goto out;
66444 +
66445 + ret = kmalloc(len, GFP_KERNEL);
66446 +
66447 + if (ret) {
66448 + if (alloc_push(ret)) {
66449 + kfree(ret);
66450 + ret = NULL;
66451 + }
66452 + }
66453 +
66454 +out:
66455 + return ret;
66456 +}
66457 +
66458 +void *
66459 +acl_alloc_num(unsigned long num, unsigned long len)
66460 +{
66461 + if (!len || (num > (PAGE_SIZE / len)))
66462 + return NULL;
66463 +
66464 + return acl_alloc(num * len);
66465 +}
66466 +
66467 +void
66468 +acl_free_all(void)
66469 +{
66470 + if (gr_acl_is_enabled() || !alloc_stack)
66471 + return;
66472 +
66473 + while (alloc_pop()) ;
66474 +
66475 + if (alloc_stack) {
66476 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66477 + kfree(alloc_stack);
66478 + else
66479 + vfree(alloc_stack);
66480 + }
66481 +
66482 + alloc_stack = NULL;
66483 + alloc_stack_size = 1;
66484 + alloc_stack_next = 1;
66485 +
66486 + return;
66487 +}
66488 +
66489 +int
66490 +acl_alloc_stack_init(unsigned long size)
66491 +{
66492 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66493 + alloc_stack =
66494 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66495 + else
66496 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
66497 +
66498 + alloc_stack_size = size;
66499 +
66500 + if (!alloc_stack)
66501 + return 0;
66502 + else
66503 + return 1;
66504 +}
66505 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66506 new file mode 100644
66507 index 0000000..bdd51ea
66508 --- /dev/null
66509 +++ b/grsecurity/gracl_cap.c
66510 @@ -0,0 +1,110 @@
66511 +#include <linux/kernel.h>
66512 +#include <linux/module.h>
66513 +#include <linux/sched.h>
66514 +#include <linux/gracl.h>
66515 +#include <linux/grsecurity.h>
66516 +#include <linux/grinternal.h>
66517 +
66518 +extern const char *captab_log[];
66519 +extern int captab_log_entries;
66520 +
66521 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66522 +{
66523 + struct acl_subject_label *curracl;
66524 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66525 + kernel_cap_t cap_audit = __cap_empty_set;
66526 +
66527 + if (!gr_acl_is_enabled())
66528 + return 1;
66529 +
66530 + curracl = task->acl;
66531 +
66532 + cap_drop = curracl->cap_lower;
66533 + cap_mask = curracl->cap_mask;
66534 + cap_audit = curracl->cap_invert_audit;
66535 +
66536 + while ((curracl = curracl->parent_subject)) {
66537 + /* if the cap isn't specified in the current computed mask but is specified in the
66538 + current level subject, and is lowered in the current level subject, then add
66539 + it to the set of dropped capabilities
66540 + otherwise, add the current level subject's mask to the current computed mask
66541 + */
66542 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66543 + cap_raise(cap_mask, cap);
66544 + if (cap_raised(curracl->cap_lower, cap))
66545 + cap_raise(cap_drop, cap);
66546 + if (cap_raised(curracl->cap_invert_audit, cap))
66547 + cap_raise(cap_audit, cap);
66548 + }
66549 + }
66550 +
66551 + if (!cap_raised(cap_drop, cap)) {
66552 + if (cap_raised(cap_audit, cap))
66553 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66554 + return 1;
66555 + }
66556 +
66557 + curracl = task->acl;
66558 +
66559 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66560 + && cap_raised(cred->cap_effective, cap)) {
66561 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66562 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66563 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66564 + gr_to_filename(task->exec_file->f_path.dentry,
66565 + task->exec_file->f_path.mnt) : curracl->filename,
66566 + curracl->filename, 0UL,
66567 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66568 + return 1;
66569 + }
66570 +
66571 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66572 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66573 +
66574 + return 0;
66575 +}
66576 +
66577 +int
66578 +gr_acl_is_capable(const int cap)
66579 +{
66580 + return gr_task_acl_is_capable(current, current_cred(), cap);
66581 +}
66582 +
66583 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66584 +{
66585 + struct acl_subject_label *curracl;
66586 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66587 +
66588 + if (!gr_acl_is_enabled())
66589 + return 1;
66590 +
66591 + curracl = task->acl;
66592 +
66593 + cap_drop = curracl->cap_lower;
66594 + cap_mask = curracl->cap_mask;
66595 +
66596 + while ((curracl = curracl->parent_subject)) {
66597 + /* if the cap isn't specified in the current computed mask but is specified in the
66598 + current level subject, and is lowered in the current level subject, then add
66599 + it to the set of dropped capabilities
66600 + otherwise, add the current level subject's mask to the current computed mask
66601 + */
66602 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66603 + cap_raise(cap_mask, cap);
66604 + if (cap_raised(curracl->cap_lower, cap))
66605 + cap_raise(cap_drop, cap);
66606 + }
66607 + }
66608 +
66609 + if (!cap_raised(cap_drop, cap))
66610 + return 1;
66611 +
66612 + return 0;
66613 +}
66614 +
66615 +int
66616 +gr_acl_is_capable_nolog(const int cap)
66617 +{
66618 + return gr_task_acl_is_capable_nolog(current, cap);
66619 +}
66620 +
66621 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66622 new file mode 100644
66623 index 0000000..a43dd06
66624 --- /dev/null
66625 +++ b/grsecurity/gracl_compat.c
66626 @@ -0,0 +1,269 @@
66627 +#include <linux/kernel.h>
66628 +#include <linux/gracl.h>
66629 +#include <linux/compat.h>
66630 +#include <linux/gracl_compat.h>
66631 +
66632 +#include <asm/uaccess.h>
66633 +
66634 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66635 +{
66636 + struct gr_arg_wrapper_compat uwrapcompat;
66637 +
66638 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66639 + return -EFAULT;
66640 +
66641 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
66642 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66643 + return -EINVAL;
66644 +
66645 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66646 + uwrap->version = uwrapcompat.version;
66647 + uwrap->size = sizeof(struct gr_arg);
66648 +
66649 + return 0;
66650 +}
66651 +
66652 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66653 +{
66654 + struct gr_arg_compat argcompat;
66655 +
66656 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66657 + return -EFAULT;
66658 +
66659 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66660 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66661 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66662 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66663 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66664 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66665 +
66666 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66667 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66668 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66669 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66670 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66671 + arg->segv_device = argcompat.segv_device;
66672 + arg->segv_inode = argcompat.segv_inode;
66673 + arg->segv_uid = argcompat.segv_uid;
66674 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66675 + arg->mode = argcompat.mode;
66676 +
66677 + return 0;
66678 +}
66679 +
66680 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66681 +{
66682 + struct acl_object_label_compat objcompat;
66683 +
66684 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66685 + return -EFAULT;
66686 +
66687 + obj->filename = compat_ptr(objcompat.filename);
66688 + obj->inode = objcompat.inode;
66689 + obj->device = objcompat.device;
66690 + obj->mode = objcompat.mode;
66691 +
66692 + obj->nested = compat_ptr(objcompat.nested);
66693 + obj->globbed = compat_ptr(objcompat.globbed);
66694 +
66695 + obj->prev = compat_ptr(objcompat.prev);
66696 + obj->next = compat_ptr(objcompat.next);
66697 +
66698 + return 0;
66699 +}
66700 +
66701 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66702 +{
66703 + unsigned int i;
66704 + struct acl_subject_label_compat subjcompat;
66705 +
66706 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66707 + return -EFAULT;
66708 +
66709 + subj->filename = compat_ptr(subjcompat.filename);
66710 + subj->inode = subjcompat.inode;
66711 + subj->device = subjcompat.device;
66712 + subj->mode = subjcompat.mode;
66713 + subj->cap_mask = subjcompat.cap_mask;
66714 + subj->cap_lower = subjcompat.cap_lower;
66715 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66716 +
66717 + for (i = 0; i < GR_NLIMITS; i++) {
66718 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66719 + subj->res[i].rlim_cur = RLIM_INFINITY;
66720 + else
66721 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66722 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66723 + subj->res[i].rlim_max = RLIM_INFINITY;
66724 + else
66725 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66726 + }
66727 + subj->resmask = subjcompat.resmask;
66728 +
66729 + subj->user_trans_type = subjcompat.user_trans_type;
66730 + subj->group_trans_type = subjcompat.group_trans_type;
66731 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66732 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66733 + subj->user_trans_num = subjcompat.user_trans_num;
66734 + subj->group_trans_num = subjcompat.group_trans_num;
66735 +
66736 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66737 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66738 + subj->ip_type = subjcompat.ip_type;
66739 + subj->ips = compat_ptr(subjcompat.ips);
66740 + subj->ip_num = subjcompat.ip_num;
66741 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66742 +
66743 + subj->crashes = subjcompat.crashes;
66744 + subj->expires = subjcompat.expires;
66745 +
66746 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66747 + subj->hash = compat_ptr(subjcompat.hash);
66748 + subj->prev = compat_ptr(subjcompat.prev);
66749 + subj->next = compat_ptr(subjcompat.next);
66750 +
66751 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66752 + subj->obj_hash_size = subjcompat.obj_hash_size;
66753 + subj->pax_flags = subjcompat.pax_flags;
66754 +
66755 + return 0;
66756 +}
66757 +
66758 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66759 +{
66760 + struct acl_role_label_compat rolecompat;
66761 +
66762 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66763 + return -EFAULT;
66764 +
66765 + role->rolename = compat_ptr(rolecompat.rolename);
66766 + role->uidgid = rolecompat.uidgid;
66767 + role->roletype = rolecompat.roletype;
66768 +
66769 + role->auth_attempts = rolecompat.auth_attempts;
66770 + role->expires = rolecompat.expires;
66771 +
66772 + role->root_label = compat_ptr(rolecompat.root_label);
66773 + role->hash = compat_ptr(rolecompat.hash);
66774 +
66775 + role->prev = compat_ptr(rolecompat.prev);
66776 + role->next = compat_ptr(rolecompat.next);
66777 +
66778 + role->transitions = compat_ptr(rolecompat.transitions);
66779 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66780 + role->domain_children = compat_ptr(rolecompat.domain_children);
66781 + role->domain_child_num = rolecompat.domain_child_num;
66782 +
66783 + role->umask = rolecompat.umask;
66784 +
66785 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66786 + role->subj_hash_size = rolecompat.subj_hash_size;
66787 +
66788 + return 0;
66789 +}
66790 +
66791 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66792 +{
66793 + struct role_allowed_ip_compat roleip_compat;
66794 +
66795 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66796 + return -EFAULT;
66797 +
66798 + roleip->addr = roleip_compat.addr;
66799 + roleip->netmask = roleip_compat.netmask;
66800 +
66801 + roleip->prev = compat_ptr(roleip_compat.prev);
66802 + roleip->next = compat_ptr(roleip_compat.next);
66803 +
66804 + return 0;
66805 +}
66806 +
66807 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66808 +{
66809 + struct role_transition_compat trans_compat;
66810 +
66811 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66812 + return -EFAULT;
66813 +
66814 + trans->rolename = compat_ptr(trans_compat.rolename);
66815 +
66816 + trans->prev = compat_ptr(trans_compat.prev);
66817 + trans->next = compat_ptr(trans_compat.next);
66818 +
66819 + return 0;
66820 +
66821 +}
66822 +
66823 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66824 +{
66825 + struct gr_hash_struct_compat hash_compat;
66826 +
66827 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66828 + return -EFAULT;
66829 +
66830 + hash->table = compat_ptr(hash_compat.table);
66831 + hash->nametable = compat_ptr(hash_compat.nametable);
66832 + hash->first = compat_ptr(hash_compat.first);
66833 +
66834 + hash->table_size = hash_compat.table_size;
66835 + hash->used_size = hash_compat.used_size;
66836 +
66837 + hash->type = hash_compat.type;
66838 +
66839 + return 0;
66840 +}
66841 +
66842 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66843 +{
66844 + compat_uptr_t ptrcompat;
66845 +
66846 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66847 + return -EFAULT;
66848 +
66849 + *(void **)ptr = compat_ptr(ptrcompat);
66850 +
66851 + return 0;
66852 +}
66853 +
66854 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66855 +{
66856 + struct acl_ip_label_compat ip_compat;
66857 +
66858 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66859 + return -EFAULT;
66860 +
66861 + ip->iface = compat_ptr(ip_compat.iface);
66862 + ip->addr = ip_compat.addr;
66863 + ip->netmask = ip_compat.netmask;
66864 + ip->low = ip_compat.low;
66865 + ip->high = ip_compat.high;
66866 + ip->mode = ip_compat.mode;
66867 + ip->type = ip_compat.type;
66868 +
66869 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66870 +
66871 + ip->prev = compat_ptr(ip_compat.prev);
66872 + ip->next = compat_ptr(ip_compat.next);
66873 +
66874 + return 0;
66875 +}
66876 +
66877 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66878 +{
66879 + struct sprole_pw_compat pw_compat;
66880 +
66881 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66882 + return -EFAULT;
66883 +
66884 + pw->rolename = compat_ptr(pw_compat.rolename);
66885 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66886 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66887 +
66888 + return 0;
66889 +}
66890 +
66891 +size_t get_gr_arg_wrapper_size_compat(void)
66892 +{
66893 + return sizeof(struct gr_arg_wrapper_compat);
66894 +}
66895 +
66896 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66897 new file mode 100644
66898 index 0000000..a340c17
66899 --- /dev/null
66900 +++ b/grsecurity/gracl_fs.c
66901 @@ -0,0 +1,431 @@
66902 +#include <linux/kernel.h>
66903 +#include <linux/sched.h>
66904 +#include <linux/types.h>
66905 +#include <linux/fs.h>
66906 +#include <linux/file.h>
66907 +#include <linux/stat.h>
66908 +#include <linux/grsecurity.h>
66909 +#include <linux/grinternal.h>
66910 +#include <linux/gracl.h>
66911 +
66912 +umode_t
66913 +gr_acl_umask(void)
66914 +{
66915 + if (unlikely(!gr_acl_is_enabled()))
66916 + return 0;
66917 +
66918 + return current->role->umask;
66919 +}
66920 +
66921 +__u32
66922 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66923 + const struct vfsmount * mnt)
66924 +{
66925 + __u32 mode;
66926 +
66927 + if (unlikely(!dentry->d_inode))
66928 + return GR_FIND;
66929 +
66930 + mode =
66931 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66932 +
66933 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66934 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66935 + return mode;
66936 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66937 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66938 + return 0;
66939 + } else if (unlikely(!(mode & GR_FIND)))
66940 + return 0;
66941 +
66942 + return GR_FIND;
66943 +}
66944 +
66945 +__u32
66946 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
66947 + int acc_mode)
66948 +{
66949 + __u32 reqmode = GR_FIND;
66950 + __u32 mode;
66951 +
66952 + if (unlikely(!dentry->d_inode))
66953 + return reqmode;
66954 +
66955 + if (acc_mode & MAY_APPEND)
66956 + reqmode |= GR_APPEND;
66957 + else if (acc_mode & MAY_WRITE)
66958 + reqmode |= GR_WRITE;
66959 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
66960 + reqmode |= GR_READ;
66961 +
66962 + mode =
66963 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66964 + mnt);
66965 +
66966 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66967 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66968 + reqmode & GR_READ ? " reading" : "",
66969 + reqmode & GR_WRITE ? " writing" : reqmode &
66970 + GR_APPEND ? " appending" : "");
66971 + return reqmode;
66972 + } else
66973 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66974 + {
66975 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66976 + reqmode & GR_READ ? " reading" : "",
66977 + reqmode & GR_WRITE ? " writing" : reqmode &
66978 + GR_APPEND ? " appending" : "");
66979 + return 0;
66980 + } else if (unlikely((mode & reqmode) != reqmode))
66981 + return 0;
66982 +
66983 + return reqmode;
66984 +}
66985 +
66986 +__u32
66987 +gr_acl_handle_creat(const struct dentry * dentry,
66988 + const struct dentry * p_dentry,
66989 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
66990 + const int imode)
66991 +{
66992 + __u32 reqmode = GR_WRITE | GR_CREATE;
66993 + __u32 mode;
66994 +
66995 + if (acc_mode & MAY_APPEND)
66996 + reqmode |= GR_APPEND;
66997 + // if a directory was required or the directory already exists, then
66998 + // don't count this open as a read
66999 + if ((acc_mode & MAY_READ) &&
67000 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
67001 + reqmode |= GR_READ;
67002 + if ((open_flags & O_CREAT) &&
67003 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67004 + reqmode |= GR_SETID;
67005 +
67006 + mode =
67007 + gr_check_create(dentry, p_dentry, p_mnt,
67008 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67009 +
67010 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67011 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67012 + reqmode & GR_READ ? " reading" : "",
67013 + reqmode & GR_WRITE ? " writing" : reqmode &
67014 + GR_APPEND ? " appending" : "");
67015 + return reqmode;
67016 + } else
67017 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67018 + {
67019 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67020 + reqmode & GR_READ ? " reading" : "",
67021 + reqmode & GR_WRITE ? " writing" : reqmode &
67022 + GR_APPEND ? " appending" : "");
67023 + return 0;
67024 + } else if (unlikely((mode & reqmode) != reqmode))
67025 + return 0;
67026 +
67027 + return reqmode;
67028 +}
67029 +
67030 +__u32
67031 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
67032 + const int fmode)
67033 +{
67034 + __u32 mode, reqmode = GR_FIND;
67035 +
67036 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
67037 + reqmode |= GR_EXEC;
67038 + if (fmode & S_IWOTH)
67039 + reqmode |= GR_WRITE;
67040 + if (fmode & S_IROTH)
67041 + reqmode |= GR_READ;
67042 +
67043 + mode =
67044 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67045 + mnt);
67046 +
67047 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67048 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67049 + reqmode & GR_READ ? " reading" : "",
67050 + reqmode & GR_WRITE ? " writing" : "",
67051 + reqmode & GR_EXEC ? " executing" : "");
67052 + return reqmode;
67053 + } else
67054 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67055 + {
67056 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67057 + reqmode & GR_READ ? " reading" : "",
67058 + reqmode & GR_WRITE ? " writing" : "",
67059 + reqmode & GR_EXEC ? " executing" : "");
67060 + return 0;
67061 + } else if (unlikely((mode & reqmode) != reqmode))
67062 + return 0;
67063 +
67064 + return reqmode;
67065 +}
67066 +
67067 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
67068 +{
67069 + __u32 mode;
67070 +
67071 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
67072 +
67073 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67074 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
67075 + return mode;
67076 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67077 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
67078 + return 0;
67079 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67080 + return 0;
67081 +
67082 + return (reqmode);
67083 +}
67084 +
67085 +__u32
67086 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67087 +{
67088 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
67089 +}
67090 +
67091 +__u32
67092 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
67093 +{
67094 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
67095 +}
67096 +
67097 +__u32
67098 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
67099 +{
67100 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
67101 +}
67102 +
67103 +__u32
67104 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
67105 +{
67106 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
67107 +}
67108 +
67109 +__u32
67110 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
67111 + umode_t *modeptr)
67112 +{
67113 + umode_t mode;
67114 +
67115 + *modeptr &= ~gr_acl_umask();
67116 + mode = *modeptr;
67117 +
67118 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
67119 + return 1;
67120 +
67121 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
67122 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
67123 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
67124 + GR_CHMOD_ACL_MSG);
67125 + } else {
67126 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
67127 + }
67128 +}
67129 +
67130 +__u32
67131 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
67132 +{
67133 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
67134 +}
67135 +
67136 +__u32
67137 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
67138 +{
67139 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
67140 +}
67141 +
67142 +__u32
67143 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
67144 +{
67145 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
67146 +}
67147 +
67148 +__u32
67149 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
67150 +{
67151 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
67152 + GR_UNIXCONNECT_ACL_MSG);
67153 +}
67154 +
67155 +/* hardlinks require at minimum create and link permission,
67156 + any additional privilege required is based on the
67157 + privilege of the file being linked to
67158 +*/
67159 +__u32
67160 +gr_acl_handle_link(const struct dentry * new_dentry,
67161 + const struct dentry * parent_dentry,
67162 + const struct vfsmount * parent_mnt,
67163 + const struct dentry * old_dentry,
67164 + const struct vfsmount * old_mnt, const struct filename *to)
67165 +{
67166 + __u32 mode;
67167 + __u32 needmode = GR_CREATE | GR_LINK;
67168 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
67169 +
67170 + mode =
67171 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
67172 + old_mnt);
67173 +
67174 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
67175 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67176 + return mode;
67177 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67178 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67179 + return 0;
67180 + } else if (unlikely((mode & needmode) != needmode))
67181 + return 0;
67182 +
67183 + return 1;
67184 +}
67185 +
67186 +__u32
67187 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67188 + const struct dentry * parent_dentry,
67189 + const struct vfsmount * parent_mnt, const struct filename *from)
67190 +{
67191 + __u32 needmode = GR_WRITE | GR_CREATE;
67192 + __u32 mode;
67193 +
67194 + mode =
67195 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
67196 + GR_CREATE | GR_AUDIT_CREATE |
67197 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
67198 +
67199 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
67200 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67201 + return mode;
67202 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67203 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67204 + return 0;
67205 + } else if (unlikely((mode & needmode) != needmode))
67206 + return 0;
67207 +
67208 + return (GR_WRITE | GR_CREATE);
67209 +}
67210 +
67211 +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)
67212 +{
67213 + __u32 mode;
67214 +
67215 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67216 +
67217 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67218 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
67219 + return mode;
67220 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67221 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
67222 + return 0;
67223 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67224 + return 0;
67225 +
67226 + return (reqmode);
67227 +}
67228 +
67229 +__u32
67230 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67231 + const struct dentry * parent_dentry,
67232 + const struct vfsmount * parent_mnt,
67233 + const int mode)
67234 +{
67235 + __u32 reqmode = GR_WRITE | GR_CREATE;
67236 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67237 + reqmode |= GR_SETID;
67238 +
67239 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67240 + reqmode, GR_MKNOD_ACL_MSG);
67241 +}
67242 +
67243 +__u32
67244 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
67245 + const struct dentry *parent_dentry,
67246 + const struct vfsmount *parent_mnt)
67247 +{
67248 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67249 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
67250 +}
67251 +
67252 +#define RENAME_CHECK_SUCCESS(old, new) \
67253 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
67254 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
67255 +
67256 +int
67257 +gr_acl_handle_rename(struct dentry *new_dentry,
67258 + struct dentry *parent_dentry,
67259 + const struct vfsmount *parent_mnt,
67260 + struct dentry *old_dentry,
67261 + struct inode *old_parent_inode,
67262 + struct vfsmount *old_mnt, const struct filename *newname)
67263 +{
67264 + __u32 comp1, comp2;
67265 + int error = 0;
67266 +
67267 + if (unlikely(!gr_acl_is_enabled()))
67268 + return 0;
67269 +
67270 + if (!new_dentry->d_inode) {
67271 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
67272 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
67273 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
67274 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
67275 + GR_DELETE | GR_AUDIT_DELETE |
67276 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67277 + GR_SUPPRESS, old_mnt);
67278 + } else {
67279 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
67280 + GR_CREATE | GR_DELETE |
67281 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
67282 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67283 + GR_SUPPRESS, parent_mnt);
67284 + comp2 =
67285 + gr_search_file(old_dentry,
67286 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67287 + GR_DELETE | GR_AUDIT_DELETE |
67288 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67289 + }
67290 +
67291 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67292 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67293 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67294 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67295 + && !(comp2 & GR_SUPPRESS)) {
67296 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67297 + error = -EACCES;
67298 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67299 + error = -EACCES;
67300 +
67301 + return error;
67302 +}
67303 +
67304 +void
67305 +gr_acl_handle_exit(void)
67306 +{
67307 + u16 id;
67308 + char *rolename;
67309 +
67310 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67311 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67312 + id = current->acl_role_id;
67313 + rolename = current->role->rolename;
67314 + gr_set_acls(1);
67315 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67316 + }
67317 +
67318 + gr_put_exec_file(current);
67319 + return;
67320 +}
67321 +
67322 +int
67323 +gr_acl_handle_procpidmem(const struct task_struct *task)
67324 +{
67325 + if (unlikely(!gr_acl_is_enabled()))
67326 + return 0;
67327 +
67328 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67329 + return -EACCES;
67330 +
67331 + return 0;
67332 +}
67333 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67334 new file mode 100644
67335 index 0000000..f056b81
67336 --- /dev/null
67337 +++ b/grsecurity/gracl_ip.c
67338 @@ -0,0 +1,386 @@
67339 +#include <linux/kernel.h>
67340 +#include <asm/uaccess.h>
67341 +#include <asm/errno.h>
67342 +#include <net/sock.h>
67343 +#include <linux/file.h>
67344 +#include <linux/fs.h>
67345 +#include <linux/net.h>
67346 +#include <linux/in.h>
67347 +#include <linux/skbuff.h>
67348 +#include <linux/ip.h>
67349 +#include <linux/udp.h>
67350 +#include <linux/types.h>
67351 +#include <linux/sched.h>
67352 +#include <linux/netdevice.h>
67353 +#include <linux/inetdevice.h>
67354 +#include <linux/gracl.h>
67355 +#include <linux/grsecurity.h>
67356 +#include <linux/grinternal.h>
67357 +
67358 +#define GR_BIND 0x01
67359 +#define GR_CONNECT 0x02
67360 +#define GR_INVERT 0x04
67361 +#define GR_BINDOVERRIDE 0x08
67362 +#define GR_CONNECTOVERRIDE 0x10
67363 +#define GR_SOCK_FAMILY 0x20
67364 +
67365 +static const char * gr_protocols[IPPROTO_MAX] = {
67366 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67367 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67368 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67369 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67370 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67371 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67372 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67373 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67374 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67375 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67376 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67377 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67378 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67379 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67380 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67381 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67382 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67383 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67384 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67385 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67386 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67387 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67388 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67389 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67390 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67391 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67392 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67393 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67394 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67395 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67396 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67397 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67398 + };
67399 +
67400 +static const char * gr_socktypes[SOCK_MAX] = {
67401 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67402 + "unknown:7", "unknown:8", "unknown:9", "packet"
67403 + };
67404 +
67405 +static const char * gr_sockfamilies[AF_MAX+1] = {
67406 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67407 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67408 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67409 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67410 + };
67411 +
67412 +const char *
67413 +gr_proto_to_name(unsigned char proto)
67414 +{
67415 + return gr_protocols[proto];
67416 +}
67417 +
67418 +const char *
67419 +gr_socktype_to_name(unsigned char type)
67420 +{
67421 + return gr_socktypes[type];
67422 +}
67423 +
67424 +const char *
67425 +gr_sockfamily_to_name(unsigned char family)
67426 +{
67427 + return gr_sockfamilies[family];
67428 +}
67429 +
67430 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67431 +
67432 +int
67433 +gr_search_socket(const int domain, const int type, const int protocol)
67434 +{
67435 + struct acl_subject_label *curr;
67436 + const struct cred *cred = current_cred();
67437 +
67438 + if (unlikely(!gr_acl_is_enabled()))
67439 + goto exit;
67440 +
67441 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67442 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67443 + goto exit; // let the kernel handle it
67444 +
67445 + curr = current->acl;
67446 +
67447 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67448 + /* the family is allowed, if this is PF_INET allow it only if
67449 + the extra sock type/protocol checks pass */
67450 + if (domain == PF_INET)
67451 + goto inet_check;
67452 + goto exit;
67453 + } else {
67454 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67455 + __u32 fakeip = 0;
67456 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67457 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67458 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67459 + gr_to_filename(current->exec_file->f_path.dentry,
67460 + current->exec_file->f_path.mnt) :
67461 + curr->filename, curr->filename,
67462 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67463 + &current->signal->saved_ip);
67464 + goto exit;
67465 + }
67466 + goto exit_fail;
67467 + }
67468 +
67469 +inet_check:
67470 + /* the rest of this checking is for IPv4 only */
67471 + if (!curr->ips)
67472 + goto exit;
67473 +
67474 + if ((curr->ip_type & (1U << type)) &&
67475 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67476 + goto exit;
67477 +
67478 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67479 + /* we don't place acls on raw sockets , and sometimes
67480 + dgram/ip sockets are opened for ioctl and not
67481 + bind/connect, so we'll fake a bind learn log */
67482 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67483 + __u32 fakeip = 0;
67484 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67485 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67486 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67487 + gr_to_filename(current->exec_file->f_path.dentry,
67488 + current->exec_file->f_path.mnt) :
67489 + curr->filename, curr->filename,
67490 + &fakeip, 0, type,
67491 + protocol, GR_CONNECT, &current->signal->saved_ip);
67492 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67493 + __u32 fakeip = 0;
67494 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67495 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67496 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67497 + gr_to_filename(current->exec_file->f_path.dentry,
67498 + current->exec_file->f_path.mnt) :
67499 + curr->filename, curr->filename,
67500 + &fakeip, 0, type,
67501 + protocol, GR_BIND, &current->signal->saved_ip);
67502 + }
67503 + /* we'll log when they use connect or bind */
67504 + goto exit;
67505 + }
67506 +
67507 +exit_fail:
67508 + if (domain == PF_INET)
67509 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67510 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67511 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67512 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67513 + gr_socktype_to_name(type), protocol);
67514 +
67515 + return 0;
67516 +exit:
67517 + return 1;
67518 +}
67519 +
67520 +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)
67521 +{
67522 + if ((ip->mode & mode) &&
67523 + (ip_port >= ip->low) &&
67524 + (ip_port <= ip->high) &&
67525 + ((ntohl(ip_addr) & our_netmask) ==
67526 + (ntohl(our_addr) & our_netmask))
67527 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67528 + && (ip->type & (1U << type))) {
67529 + if (ip->mode & GR_INVERT)
67530 + return 2; // specifically denied
67531 + else
67532 + return 1; // allowed
67533 + }
67534 +
67535 + return 0; // not specifically allowed, may continue parsing
67536 +}
67537 +
67538 +static int
67539 +gr_search_connectbind(const int full_mode, struct sock *sk,
67540 + struct sockaddr_in *addr, const int type)
67541 +{
67542 + char iface[IFNAMSIZ] = {0};
67543 + struct acl_subject_label *curr;
67544 + struct acl_ip_label *ip;
67545 + struct inet_sock *isk;
67546 + struct net_device *dev;
67547 + struct in_device *idev;
67548 + unsigned long i;
67549 + int ret;
67550 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67551 + __u32 ip_addr = 0;
67552 + __u32 our_addr;
67553 + __u32 our_netmask;
67554 + char *p;
67555 + __u16 ip_port = 0;
67556 + const struct cred *cred = current_cred();
67557 +
67558 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67559 + return 0;
67560 +
67561 + curr = current->acl;
67562 + isk = inet_sk(sk);
67563 +
67564 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67565 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67566 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67567 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67568 + struct sockaddr_in saddr;
67569 + int err;
67570 +
67571 + saddr.sin_family = AF_INET;
67572 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67573 + saddr.sin_port = isk->inet_sport;
67574 +
67575 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67576 + if (err)
67577 + return err;
67578 +
67579 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67580 + if (err)
67581 + return err;
67582 + }
67583 +
67584 + if (!curr->ips)
67585 + return 0;
67586 +
67587 + ip_addr = addr->sin_addr.s_addr;
67588 + ip_port = ntohs(addr->sin_port);
67589 +
67590 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67591 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67592 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67593 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67594 + gr_to_filename(current->exec_file->f_path.dentry,
67595 + current->exec_file->f_path.mnt) :
67596 + curr->filename, curr->filename,
67597 + &ip_addr, ip_port, type,
67598 + sk->sk_protocol, mode, &current->signal->saved_ip);
67599 + return 0;
67600 + }
67601 +
67602 + for (i = 0; i < curr->ip_num; i++) {
67603 + ip = *(curr->ips + i);
67604 + if (ip->iface != NULL) {
67605 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67606 + p = strchr(iface, ':');
67607 + if (p != NULL)
67608 + *p = '\0';
67609 + dev = dev_get_by_name(sock_net(sk), iface);
67610 + if (dev == NULL)
67611 + continue;
67612 + idev = in_dev_get(dev);
67613 + if (idev == NULL) {
67614 + dev_put(dev);
67615 + continue;
67616 + }
67617 + rcu_read_lock();
67618 + for_ifa(idev) {
67619 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67620 + our_addr = ifa->ifa_address;
67621 + our_netmask = 0xffffffff;
67622 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67623 + if (ret == 1) {
67624 + rcu_read_unlock();
67625 + in_dev_put(idev);
67626 + dev_put(dev);
67627 + return 0;
67628 + } else if (ret == 2) {
67629 + rcu_read_unlock();
67630 + in_dev_put(idev);
67631 + dev_put(dev);
67632 + goto denied;
67633 + }
67634 + }
67635 + } endfor_ifa(idev);
67636 + rcu_read_unlock();
67637 + in_dev_put(idev);
67638 + dev_put(dev);
67639 + } else {
67640 + our_addr = ip->addr;
67641 + our_netmask = ip->netmask;
67642 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67643 + if (ret == 1)
67644 + return 0;
67645 + else if (ret == 2)
67646 + goto denied;
67647 + }
67648 + }
67649 +
67650 +denied:
67651 + if (mode == GR_BIND)
67652 + 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));
67653 + else if (mode == GR_CONNECT)
67654 + 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));
67655 +
67656 + return -EACCES;
67657 +}
67658 +
67659 +int
67660 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67661 +{
67662 + /* always allow disconnection of dgram sockets with connect */
67663 + if (addr->sin_family == AF_UNSPEC)
67664 + return 0;
67665 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67666 +}
67667 +
67668 +int
67669 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67670 +{
67671 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67672 +}
67673 +
67674 +int gr_search_listen(struct socket *sock)
67675 +{
67676 + struct sock *sk = sock->sk;
67677 + struct sockaddr_in addr;
67678 +
67679 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67680 + addr.sin_port = inet_sk(sk)->inet_sport;
67681 +
67682 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67683 +}
67684 +
67685 +int gr_search_accept(struct socket *sock)
67686 +{
67687 + struct sock *sk = sock->sk;
67688 + struct sockaddr_in addr;
67689 +
67690 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67691 + addr.sin_port = inet_sk(sk)->inet_sport;
67692 +
67693 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67694 +}
67695 +
67696 +int
67697 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67698 +{
67699 + if (addr)
67700 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67701 + else {
67702 + struct sockaddr_in sin;
67703 + const struct inet_sock *inet = inet_sk(sk);
67704 +
67705 + sin.sin_addr.s_addr = inet->inet_daddr;
67706 + sin.sin_port = inet->inet_dport;
67707 +
67708 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67709 + }
67710 +}
67711 +
67712 +int
67713 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67714 +{
67715 + struct sockaddr_in sin;
67716 +
67717 + if (unlikely(skb->len < sizeof (struct udphdr)))
67718 + return 0; // skip this packet
67719 +
67720 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67721 + sin.sin_port = udp_hdr(skb)->source;
67722 +
67723 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67724 +}
67725 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67726 new file mode 100644
67727 index 0000000..25f54ef
67728 --- /dev/null
67729 +++ b/grsecurity/gracl_learn.c
67730 @@ -0,0 +1,207 @@
67731 +#include <linux/kernel.h>
67732 +#include <linux/mm.h>
67733 +#include <linux/sched.h>
67734 +#include <linux/poll.h>
67735 +#include <linux/string.h>
67736 +#include <linux/file.h>
67737 +#include <linux/types.h>
67738 +#include <linux/vmalloc.h>
67739 +#include <linux/grinternal.h>
67740 +
67741 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67742 + size_t count, loff_t *ppos);
67743 +extern int gr_acl_is_enabled(void);
67744 +
67745 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67746 +static int gr_learn_attached;
67747 +
67748 +/* use a 512k buffer */
67749 +#define LEARN_BUFFER_SIZE (512 * 1024)
67750 +
67751 +static DEFINE_SPINLOCK(gr_learn_lock);
67752 +static DEFINE_MUTEX(gr_learn_user_mutex);
67753 +
67754 +/* we need to maintain two buffers, so that the kernel context of grlearn
67755 + uses a semaphore around the userspace copying, and the other kernel contexts
67756 + use a spinlock when copying into the buffer, since they cannot sleep
67757 +*/
67758 +static char *learn_buffer;
67759 +static char *learn_buffer_user;
67760 +static int learn_buffer_len;
67761 +static int learn_buffer_user_len;
67762 +
67763 +static ssize_t
67764 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67765 +{
67766 + DECLARE_WAITQUEUE(wait, current);
67767 + ssize_t retval = 0;
67768 +
67769 + add_wait_queue(&learn_wait, &wait);
67770 + set_current_state(TASK_INTERRUPTIBLE);
67771 + do {
67772 + mutex_lock(&gr_learn_user_mutex);
67773 + spin_lock(&gr_learn_lock);
67774 + if (learn_buffer_len)
67775 + break;
67776 + spin_unlock(&gr_learn_lock);
67777 + mutex_unlock(&gr_learn_user_mutex);
67778 + if (file->f_flags & O_NONBLOCK) {
67779 + retval = -EAGAIN;
67780 + goto out;
67781 + }
67782 + if (signal_pending(current)) {
67783 + retval = -ERESTARTSYS;
67784 + goto out;
67785 + }
67786 +
67787 + schedule();
67788 + } while (1);
67789 +
67790 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67791 + learn_buffer_user_len = learn_buffer_len;
67792 + retval = learn_buffer_len;
67793 + learn_buffer_len = 0;
67794 +
67795 + spin_unlock(&gr_learn_lock);
67796 +
67797 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67798 + retval = -EFAULT;
67799 +
67800 + mutex_unlock(&gr_learn_user_mutex);
67801 +out:
67802 + set_current_state(TASK_RUNNING);
67803 + remove_wait_queue(&learn_wait, &wait);
67804 + return retval;
67805 +}
67806 +
67807 +static unsigned int
67808 +poll_learn(struct file * file, poll_table * wait)
67809 +{
67810 + poll_wait(file, &learn_wait, wait);
67811 +
67812 + if (learn_buffer_len)
67813 + return (POLLIN | POLLRDNORM);
67814 +
67815 + return 0;
67816 +}
67817 +
67818 +void
67819 +gr_clear_learn_entries(void)
67820 +{
67821 + char *tmp;
67822 +
67823 + mutex_lock(&gr_learn_user_mutex);
67824 + spin_lock(&gr_learn_lock);
67825 + tmp = learn_buffer;
67826 + learn_buffer = NULL;
67827 + spin_unlock(&gr_learn_lock);
67828 + if (tmp)
67829 + vfree(tmp);
67830 + if (learn_buffer_user != NULL) {
67831 + vfree(learn_buffer_user);
67832 + learn_buffer_user = NULL;
67833 + }
67834 + learn_buffer_len = 0;
67835 + mutex_unlock(&gr_learn_user_mutex);
67836 +
67837 + return;
67838 +}
67839 +
67840 +void
67841 +gr_add_learn_entry(const char *fmt, ...)
67842 +{
67843 + va_list args;
67844 + unsigned int len;
67845 +
67846 + if (!gr_learn_attached)
67847 + return;
67848 +
67849 + spin_lock(&gr_learn_lock);
67850 +
67851 + /* leave a gap at the end so we know when it's "full" but don't have to
67852 + compute the exact length of the string we're trying to append
67853 + */
67854 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67855 + spin_unlock(&gr_learn_lock);
67856 + wake_up_interruptible(&learn_wait);
67857 + return;
67858 + }
67859 + if (learn_buffer == NULL) {
67860 + spin_unlock(&gr_learn_lock);
67861 + return;
67862 + }
67863 +
67864 + va_start(args, fmt);
67865 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67866 + va_end(args);
67867 +
67868 + learn_buffer_len += len + 1;
67869 +
67870 + spin_unlock(&gr_learn_lock);
67871 + wake_up_interruptible(&learn_wait);
67872 +
67873 + return;
67874 +}
67875 +
67876 +static int
67877 +open_learn(struct inode *inode, struct file *file)
67878 +{
67879 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67880 + return -EBUSY;
67881 + if (file->f_mode & FMODE_READ) {
67882 + int retval = 0;
67883 + mutex_lock(&gr_learn_user_mutex);
67884 + if (learn_buffer == NULL)
67885 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67886 + if (learn_buffer_user == NULL)
67887 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67888 + if (learn_buffer == NULL) {
67889 + retval = -ENOMEM;
67890 + goto out_error;
67891 + }
67892 + if (learn_buffer_user == NULL) {
67893 + retval = -ENOMEM;
67894 + goto out_error;
67895 + }
67896 + learn_buffer_len = 0;
67897 + learn_buffer_user_len = 0;
67898 + gr_learn_attached = 1;
67899 +out_error:
67900 + mutex_unlock(&gr_learn_user_mutex);
67901 + return retval;
67902 + }
67903 + return 0;
67904 +}
67905 +
67906 +static int
67907 +close_learn(struct inode *inode, struct file *file)
67908 +{
67909 + if (file->f_mode & FMODE_READ) {
67910 + char *tmp = NULL;
67911 + mutex_lock(&gr_learn_user_mutex);
67912 + spin_lock(&gr_learn_lock);
67913 + tmp = learn_buffer;
67914 + learn_buffer = NULL;
67915 + spin_unlock(&gr_learn_lock);
67916 + if (tmp)
67917 + vfree(tmp);
67918 + if (learn_buffer_user != NULL) {
67919 + vfree(learn_buffer_user);
67920 + learn_buffer_user = NULL;
67921 + }
67922 + learn_buffer_len = 0;
67923 + learn_buffer_user_len = 0;
67924 + gr_learn_attached = 0;
67925 + mutex_unlock(&gr_learn_user_mutex);
67926 + }
67927 +
67928 + return 0;
67929 +}
67930 +
67931 +const struct file_operations grsec_fops = {
67932 + .read = read_learn,
67933 + .write = write_grsec_handler,
67934 + .open = open_learn,
67935 + .release = close_learn,
67936 + .poll = poll_learn,
67937 +};
67938 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
67939 new file mode 100644
67940 index 0000000..39645c9
67941 --- /dev/null
67942 +++ b/grsecurity/gracl_res.c
67943 @@ -0,0 +1,68 @@
67944 +#include <linux/kernel.h>
67945 +#include <linux/sched.h>
67946 +#include <linux/gracl.h>
67947 +#include <linux/grinternal.h>
67948 +
67949 +static const char *restab_log[] = {
67950 + [RLIMIT_CPU] = "RLIMIT_CPU",
67951 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
67952 + [RLIMIT_DATA] = "RLIMIT_DATA",
67953 + [RLIMIT_STACK] = "RLIMIT_STACK",
67954 + [RLIMIT_CORE] = "RLIMIT_CORE",
67955 + [RLIMIT_RSS] = "RLIMIT_RSS",
67956 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
67957 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
67958 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
67959 + [RLIMIT_AS] = "RLIMIT_AS",
67960 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
67961 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
67962 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
67963 + [RLIMIT_NICE] = "RLIMIT_NICE",
67964 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
67965 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
67966 + [GR_CRASH_RES] = "RLIMIT_CRASH"
67967 +};
67968 +
67969 +void
67970 +gr_log_resource(const struct task_struct *task,
67971 + const int res, const unsigned long wanted, const int gt)
67972 +{
67973 + const struct cred *cred;
67974 + unsigned long rlim;
67975 +
67976 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
67977 + return;
67978 +
67979 + // not yet supported resource
67980 + if (unlikely(!restab_log[res]))
67981 + return;
67982 +
67983 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
67984 + rlim = task_rlimit_max(task, res);
67985 + else
67986 + rlim = task_rlimit(task, res);
67987 +
67988 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
67989 + return;
67990 +
67991 + rcu_read_lock();
67992 + cred = __task_cred(task);
67993 +
67994 + if (res == RLIMIT_NPROC &&
67995 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
67996 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
67997 + goto out_rcu_unlock;
67998 + else if (res == RLIMIT_MEMLOCK &&
67999 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
68000 + goto out_rcu_unlock;
68001 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
68002 + goto out_rcu_unlock;
68003 + rcu_read_unlock();
68004 +
68005 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
68006 +
68007 + return;
68008 +out_rcu_unlock:
68009 + rcu_read_unlock();
68010 + return;
68011 +}
68012 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
68013 new file mode 100644
68014 index 0000000..3c38bfe
68015 --- /dev/null
68016 +++ b/grsecurity/gracl_segv.c
68017 @@ -0,0 +1,305 @@
68018 +#include <linux/kernel.h>
68019 +#include <linux/mm.h>
68020 +#include <asm/uaccess.h>
68021 +#include <asm/errno.h>
68022 +#include <asm/mman.h>
68023 +#include <net/sock.h>
68024 +#include <linux/file.h>
68025 +#include <linux/fs.h>
68026 +#include <linux/net.h>
68027 +#include <linux/in.h>
68028 +#include <linux/slab.h>
68029 +#include <linux/types.h>
68030 +#include <linux/sched.h>
68031 +#include <linux/timer.h>
68032 +#include <linux/gracl.h>
68033 +#include <linux/grsecurity.h>
68034 +#include <linux/grinternal.h>
68035 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68036 +#include <linux/magic.h>
68037 +#include <linux/pagemap.h>
68038 +#include "../fs/btrfs/async-thread.h"
68039 +#include "../fs/btrfs/ctree.h"
68040 +#include "../fs/btrfs/btrfs_inode.h"
68041 +#endif
68042 +
68043 +static struct crash_uid *uid_set;
68044 +static unsigned short uid_used;
68045 +static DEFINE_SPINLOCK(gr_uid_lock);
68046 +extern rwlock_t gr_inode_lock;
68047 +extern struct acl_subject_label *
68048 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
68049 + struct acl_role_label *role);
68050 +
68051 +static inline dev_t __get_dev(const struct dentry *dentry)
68052 +{
68053 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68054 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
68055 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
68056 + else
68057 +#endif
68058 + return dentry->d_sb->s_dev;
68059 +}
68060 +
68061 +int
68062 +gr_init_uidset(void)
68063 +{
68064 + uid_set =
68065 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
68066 + uid_used = 0;
68067 +
68068 + return uid_set ? 1 : 0;
68069 +}
68070 +
68071 +void
68072 +gr_free_uidset(void)
68073 +{
68074 + if (uid_set)
68075 + kfree(uid_set);
68076 +
68077 + return;
68078 +}
68079 +
68080 +int
68081 +gr_find_uid(const uid_t uid)
68082 +{
68083 + struct crash_uid *tmp = uid_set;
68084 + uid_t buid;
68085 + int low = 0, high = uid_used - 1, mid;
68086 +
68087 + while (high >= low) {
68088 + mid = (low + high) >> 1;
68089 + buid = tmp[mid].uid;
68090 + if (buid == uid)
68091 + return mid;
68092 + if (buid > uid)
68093 + high = mid - 1;
68094 + if (buid < uid)
68095 + low = mid + 1;
68096 + }
68097 +
68098 + return -1;
68099 +}
68100 +
68101 +static __inline__ void
68102 +gr_insertsort(void)
68103 +{
68104 + unsigned short i, j;
68105 + struct crash_uid index;
68106 +
68107 + for (i = 1; i < uid_used; i++) {
68108 + index = uid_set[i];
68109 + j = i;
68110 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
68111 + uid_set[j] = uid_set[j - 1];
68112 + j--;
68113 + }
68114 + uid_set[j] = index;
68115 + }
68116 +
68117 + return;
68118 +}
68119 +
68120 +static __inline__ void
68121 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
68122 +{
68123 + int loc;
68124 + uid_t uid = GR_GLOBAL_UID(kuid);
68125 +
68126 + if (uid_used == GR_UIDTABLE_MAX)
68127 + return;
68128 +
68129 + loc = gr_find_uid(uid);
68130 +
68131 + if (loc >= 0) {
68132 + uid_set[loc].expires = expires;
68133 + return;
68134 + }
68135 +
68136 + uid_set[uid_used].uid = uid;
68137 + uid_set[uid_used].expires = expires;
68138 + uid_used++;
68139 +
68140 + gr_insertsort();
68141 +
68142 + return;
68143 +}
68144 +
68145 +void
68146 +gr_remove_uid(const unsigned short loc)
68147 +{
68148 + unsigned short i;
68149 +
68150 + for (i = loc + 1; i < uid_used; i++)
68151 + uid_set[i - 1] = uid_set[i];
68152 +
68153 + uid_used--;
68154 +
68155 + return;
68156 +}
68157 +
68158 +int
68159 +gr_check_crash_uid(const kuid_t kuid)
68160 +{
68161 + int loc;
68162 + int ret = 0;
68163 + uid_t uid;
68164 +
68165 + if (unlikely(!gr_acl_is_enabled()))
68166 + return 0;
68167 +
68168 + uid = GR_GLOBAL_UID(kuid);
68169 +
68170 + spin_lock(&gr_uid_lock);
68171 + loc = gr_find_uid(uid);
68172 +
68173 + if (loc < 0)
68174 + goto out_unlock;
68175 +
68176 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
68177 + gr_remove_uid(loc);
68178 + else
68179 + ret = 1;
68180 +
68181 +out_unlock:
68182 + spin_unlock(&gr_uid_lock);
68183 + return ret;
68184 +}
68185 +
68186 +static __inline__ int
68187 +proc_is_setxid(const struct cred *cred)
68188 +{
68189 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
68190 + !uid_eq(cred->uid, cred->fsuid))
68191 + return 1;
68192 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
68193 + !gid_eq(cred->gid, cred->fsgid))
68194 + return 1;
68195 +
68196 + return 0;
68197 +}
68198 +
68199 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
68200 +
68201 +void
68202 +gr_handle_crash(struct task_struct *task, const int sig)
68203 +{
68204 + struct acl_subject_label *curr;
68205 + struct task_struct *tsk, *tsk2;
68206 + const struct cred *cred;
68207 + const struct cred *cred2;
68208 +
68209 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
68210 + return;
68211 +
68212 + if (unlikely(!gr_acl_is_enabled()))
68213 + return;
68214 +
68215 + curr = task->acl;
68216 +
68217 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
68218 + return;
68219 +
68220 + if (time_before_eq(curr->expires, get_seconds())) {
68221 + curr->expires = 0;
68222 + curr->crashes = 0;
68223 + }
68224 +
68225 + curr->crashes++;
68226 +
68227 + if (!curr->expires)
68228 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
68229 +
68230 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68231 + time_after(curr->expires, get_seconds())) {
68232 + rcu_read_lock();
68233 + cred = __task_cred(task);
68234 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
68235 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68236 + spin_lock(&gr_uid_lock);
68237 + gr_insert_uid(cred->uid, curr->expires);
68238 + spin_unlock(&gr_uid_lock);
68239 + curr->expires = 0;
68240 + curr->crashes = 0;
68241 + read_lock(&tasklist_lock);
68242 + do_each_thread(tsk2, tsk) {
68243 + cred2 = __task_cred(tsk);
68244 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
68245 + gr_fake_force_sig(SIGKILL, tsk);
68246 + } while_each_thread(tsk2, tsk);
68247 + read_unlock(&tasklist_lock);
68248 + } else {
68249 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68250 + read_lock(&tasklist_lock);
68251 + read_lock(&grsec_exec_file_lock);
68252 + do_each_thread(tsk2, tsk) {
68253 + if (likely(tsk != task)) {
68254 + // if this thread has the same subject as the one that triggered
68255 + // RES_CRASH and it's the same binary, kill it
68256 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
68257 + gr_fake_force_sig(SIGKILL, tsk);
68258 + }
68259 + } while_each_thread(tsk2, tsk);
68260 + read_unlock(&grsec_exec_file_lock);
68261 + read_unlock(&tasklist_lock);
68262 + }
68263 + rcu_read_unlock();
68264 + }
68265 +
68266 + return;
68267 +}
68268 +
68269 +int
68270 +gr_check_crash_exec(const struct file *filp)
68271 +{
68272 + struct acl_subject_label *curr;
68273 +
68274 + if (unlikely(!gr_acl_is_enabled()))
68275 + return 0;
68276 +
68277 + read_lock(&gr_inode_lock);
68278 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
68279 + __get_dev(filp->f_path.dentry),
68280 + current->role);
68281 + read_unlock(&gr_inode_lock);
68282 +
68283 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
68284 + (!curr->crashes && !curr->expires))
68285 + return 0;
68286 +
68287 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68288 + time_after(curr->expires, get_seconds()))
68289 + return 1;
68290 + else if (time_before_eq(curr->expires, get_seconds())) {
68291 + curr->crashes = 0;
68292 + curr->expires = 0;
68293 + }
68294 +
68295 + return 0;
68296 +}
68297 +
68298 +void
68299 +gr_handle_alertkill(struct task_struct *task)
68300 +{
68301 + struct acl_subject_label *curracl;
68302 + __u32 curr_ip;
68303 + struct task_struct *p, *p2;
68304 +
68305 + if (unlikely(!gr_acl_is_enabled()))
68306 + return;
68307 +
68308 + curracl = task->acl;
68309 + curr_ip = task->signal->curr_ip;
68310 +
68311 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
68312 + read_lock(&tasklist_lock);
68313 + do_each_thread(p2, p) {
68314 + if (p->signal->curr_ip == curr_ip)
68315 + gr_fake_force_sig(SIGKILL, p);
68316 + } while_each_thread(p2, p);
68317 + read_unlock(&tasklist_lock);
68318 + } else if (curracl->mode & GR_KILLPROC)
68319 + gr_fake_force_sig(SIGKILL, task);
68320 +
68321 + return;
68322 +}
68323 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
68324 new file mode 100644
68325 index 0000000..98011b0
68326 --- /dev/null
68327 +++ b/grsecurity/gracl_shm.c
68328 @@ -0,0 +1,40 @@
68329 +#include <linux/kernel.h>
68330 +#include <linux/mm.h>
68331 +#include <linux/sched.h>
68332 +#include <linux/file.h>
68333 +#include <linux/ipc.h>
68334 +#include <linux/gracl.h>
68335 +#include <linux/grsecurity.h>
68336 +#include <linux/grinternal.h>
68337 +
68338 +int
68339 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68340 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
68341 +{
68342 + struct task_struct *task;
68343 +
68344 + if (!gr_acl_is_enabled())
68345 + return 1;
68346 +
68347 + rcu_read_lock();
68348 + read_lock(&tasklist_lock);
68349 +
68350 + task = find_task_by_vpid(shm_cprid);
68351 +
68352 + if (unlikely(!task))
68353 + task = find_task_by_vpid(shm_lapid);
68354 +
68355 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
68356 + (task_pid_nr(task) == shm_lapid)) &&
68357 + (task->acl->mode & GR_PROTSHM) &&
68358 + (task->acl != current->acl))) {
68359 + read_unlock(&tasklist_lock);
68360 + rcu_read_unlock();
68361 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
68362 + return 0;
68363 + }
68364 + read_unlock(&tasklist_lock);
68365 + rcu_read_unlock();
68366 +
68367 + return 1;
68368 +}
68369 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
68370 new file mode 100644
68371 index 0000000..bc0be01
68372 --- /dev/null
68373 +++ b/grsecurity/grsec_chdir.c
68374 @@ -0,0 +1,19 @@
68375 +#include <linux/kernel.h>
68376 +#include <linux/sched.h>
68377 +#include <linux/fs.h>
68378 +#include <linux/file.h>
68379 +#include <linux/grsecurity.h>
68380 +#include <linux/grinternal.h>
68381 +
68382 +void
68383 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
68384 +{
68385 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
68386 + if ((grsec_enable_chdir && grsec_enable_group &&
68387 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
68388 + !grsec_enable_group)) {
68389 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
68390 + }
68391 +#endif
68392 + return;
68393 +}
68394 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
68395 new file mode 100644
68396 index 0000000..bd6e105
68397 --- /dev/null
68398 +++ b/grsecurity/grsec_chroot.c
68399 @@ -0,0 +1,370 @@
68400 +#include <linux/kernel.h>
68401 +#include <linux/module.h>
68402 +#include <linux/sched.h>
68403 +#include <linux/file.h>
68404 +#include <linux/fs.h>
68405 +#include <linux/mount.h>
68406 +#include <linux/types.h>
68407 +#include "../fs/mount.h"
68408 +#include <linux/grsecurity.h>
68409 +#include <linux/grinternal.h>
68410 +
68411 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68412 +static int gr_init_ran;
68413 +#endif
68414 +
68415 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
68416 +{
68417 +#ifdef CONFIG_GRKERNSEC
68418 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
68419 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
68420 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68421 + && gr_init_ran
68422 +#endif
68423 + )
68424 + task->gr_is_chrooted = 1;
68425 + else {
68426 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68427 + if (task_pid_nr(task) == 1 && !gr_init_ran)
68428 + gr_init_ran = 1;
68429 +#endif
68430 + task->gr_is_chrooted = 0;
68431 + }
68432 +
68433 + task->gr_chroot_dentry = path->dentry;
68434 +#endif
68435 + return;
68436 +}
68437 +
68438 +void gr_clear_chroot_entries(struct task_struct *task)
68439 +{
68440 +#ifdef CONFIG_GRKERNSEC
68441 + task->gr_is_chrooted = 0;
68442 + task->gr_chroot_dentry = NULL;
68443 +#endif
68444 + return;
68445 +}
68446 +
68447 +int
68448 +gr_handle_chroot_unix(const pid_t pid)
68449 +{
68450 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68451 + struct task_struct *p;
68452 +
68453 + if (unlikely(!grsec_enable_chroot_unix))
68454 + return 1;
68455 +
68456 + if (likely(!proc_is_chrooted(current)))
68457 + return 1;
68458 +
68459 + rcu_read_lock();
68460 + read_lock(&tasklist_lock);
68461 + p = find_task_by_vpid_unrestricted(pid);
68462 + if (unlikely(p && !have_same_root(current, p))) {
68463 + read_unlock(&tasklist_lock);
68464 + rcu_read_unlock();
68465 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
68466 + return 0;
68467 + }
68468 + read_unlock(&tasklist_lock);
68469 + rcu_read_unlock();
68470 +#endif
68471 + return 1;
68472 +}
68473 +
68474 +int
68475 +gr_handle_chroot_nice(void)
68476 +{
68477 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68478 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
68479 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
68480 + return -EPERM;
68481 + }
68482 +#endif
68483 + return 0;
68484 +}
68485 +
68486 +int
68487 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
68488 +{
68489 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68490 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
68491 + && proc_is_chrooted(current)) {
68492 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
68493 + return -EACCES;
68494 + }
68495 +#endif
68496 + return 0;
68497 +}
68498 +
68499 +int
68500 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
68501 +{
68502 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68503 + struct task_struct *p;
68504 + int ret = 0;
68505 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
68506 + return ret;
68507 +
68508 + read_lock(&tasklist_lock);
68509 + do_each_pid_task(pid, type, p) {
68510 + if (!have_same_root(current, p)) {
68511 + ret = 1;
68512 + goto out;
68513 + }
68514 + } while_each_pid_task(pid, type, p);
68515 +out:
68516 + read_unlock(&tasklist_lock);
68517 + return ret;
68518 +#endif
68519 + return 0;
68520 +}
68521 +
68522 +int
68523 +gr_pid_is_chrooted(struct task_struct *p)
68524 +{
68525 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68526 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
68527 + return 0;
68528 +
68529 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
68530 + !have_same_root(current, p)) {
68531 + return 1;
68532 + }
68533 +#endif
68534 + return 0;
68535 +}
68536 +
68537 +EXPORT_SYMBOL(gr_pid_is_chrooted);
68538 +
68539 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
68540 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
68541 +{
68542 + struct path path, currentroot;
68543 + int ret = 0;
68544 +
68545 + path.dentry = (struct dentry *)u_dentry;
68546 + path.mnt = (struct vfsmount *)u_mnt;
68547 + get_fs_root(current->fs, &currentroot);
68548 + if (path_is_under(&path, &currentroot))
68549 + ret = 1;
68550 + path_put(&currentroot);
68551 +
68552 + return ret;
68553 +}
68554 +#endif
68555 +
68556 +int
68557 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
68558 +{
68559 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68560 + if (!grsec_enable_chroot_fchdir)
68561 + return 1;
68562 +
68563 + if (!proc_is_chrooted(current))
68564 + return 1;
68565 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
68566 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
68567 + return 0;
68568 + }
68569 +#endif
68570 + return 1;
68571 +}
68572 +
68573 +int
68574 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68575 + const time_t shm_createtime)
68576 +{
68577 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68578 + struct task_struct *p;
68579 + time_t starttime;
68580 +
68581 + if (unlikely(!grsec_enable_chroot_shmat))
68582 + return 1;
68583 +
68584 + if (likely(!proc_is_chrooted(current)))
68585 + return 1;
68586 +
68587 + rcu_read_lock();
68588 + read_lock(&tasklist_lock);
68589 +
68590 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
68591 + starttime = p->start_time.tv_sec;
68592 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
68593 + if (have_same_root(current, p)) {
68594 + goto allow;
68595 + } else {
68596 + read_unlock(&tasklist_lock);
68597 + rcu_read_unlock();
68598 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68599 + return 0;
68600 + }
68601 + }
68602 + /* creator exited, pid reuse, fall through to next check */
68603 + }
68604 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
68605 + if (unlikely(!have_same_root(current, p))) {
68606 + read_unlock(&tasklist_lock);
68607 + rcu_read_unlock();
68608 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68609 + return 0;
68610 + }
68611 + }
68612 +
68613 +allow:
68614 + read_unlock(&tasklist_lock);
68615 + rcu_read_unlock();
68616 +#endif
68617 + return 1;
68618 +}
68619 +
68620 +void
68621 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
68622 +{
68623 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68624 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
68625 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
68626 +#endif
68627 + return;
68628 +}
68629 +
68630 +int
68631 +gr_handle_chroot_mknod(const struct dentry *dentry,
68632 + const struct vfsmount *mnt, const int mode)
68633 +{
68634 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68635 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
68636 + proc_is_chrooted(current)) {
68637 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
68638 + return -EPERM;
68639 + }
68640 +#endif
68641 + return 0;
68642 +}
68643 +
68644 +int
68645 +gr_handle_chroot_mount(const struct dentry *dentry,
68646 + const struct vfsmount *mnt, const char *dev_name)
68647 +{
68648 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68649 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
68650 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
68651 + return -EPERM;
68652 + }
68653 +#endif
68654 + return 0;
68655 +}
68656 +
68657 +int
68658 +gr_handle_chroot_pivot(void)
68659 +{
68660 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68661 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
68662 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
68663 + return -EPERM;
68664 + }
68665 +#endif
68666 + return 0;
68667 +}
68668 +
68669 +int
68670 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
68671 +{
68672 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68673 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
68674 + !gr_is_outside_chroot(dentry, mnt)) {
68675 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
68676 + return -EPERM;
68677 + }
68678 +#endif
68679 + return 0;
68680 +}
68681 +
68682 +extern const char *captab_log[];
68683 +extern int captab_log_entries;
68684 +
68685 +int
68686 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
68687 +{
68688 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68689 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68690 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68691 + if (cap_raised(chroot_caps, cap)) {
68692 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
68693 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
68694 + }
68695 + return 0;
68696 + }
68697 + }
68698 +#endif
68699 + return 1;
68700 +}
68701 +
68702 +int
68703 +gr_chroot_is_capable(const int cap)
68704 +{
68705 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68706 + return gr_task_chroot_is_capable(current, current_cred(), cap);
68707 +#endif
68708 + return 1;
68709 +}
68710 +
68711 +int
68712 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
68713 +{
68714 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68715 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68716 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68717 + if (cap_raised(chroot_caps, cap)) {
68718 + return 0;
68719 + }
68720 + }
68721 +#endif
68722 + return 1;
68723 +}
68724 +
68725 +int
68726 +gr_chroot_is_capable_nolog(const int cap)
68727 +{
68728 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68729 + return gr_task_chroot_is_capable_nolog(current, cap);
68730 +#endif
68731 + return 1;
68732 +}
68733 +
68734 +int
68735 +gr_handle_chroot_sysctl(const int op)
68736 +{
68737 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
68738 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
68739 + proc_is_chrooted(current))
68740 + return -EACCES;
68741 +#endif
68742 + return 0;
68743 +}
68744 +
68745 +void
68746 +gr_handle_chroot_chdir(const struct path *path)
68747 +{
68748 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
68749 + if (grsec_enable_chroot_chdir)
68750 + set_fs_pwd(current->fs, path);
68751 +#endif
68752 + return;
68753 +}
68754 +
68755 +int
68756 +gr_handle_chroot_chmod(const struct dentry *dentry,
68757 + const struct vfsmount *mnt, const int mode)
68758 +{
68759 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
68760 + /* allow chmod +s on directories, but not files */
68761 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
68762 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
68763 + proc_is_chrooted(current)) {
68764 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
68765 + return -EPERM;
68766 + }
68767 +#endif
68768 + return 0;
68769 +}
68770 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
68771 new file mode 100644
68772 index 0000000..ce65ceb
68773 --- /dev/null
68774 +++ b/grsecurity/grsec_disabled.c
68775 @@ -0,0 +1,434 @@
68776 +#include <linux/kernel.h>
68777 +#include <linux/module.h>
68778 +#include <linux/sched.h>
68779 +#include <linux/file.h>
68780 +#include <linux/fs.h>
68781 +#include <linux/kdev_t.h>
68782 +#include <linux/net.h>
68783 +#include <linux/in.h>
68784 +#include <linux/ip.h>
68785 +#include <linux/skbuff.h>
68786 +#include <linux/sysctl.h>
68787 +
68788 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
68789 +void
68790 +pax_set_initial_flags(struct linux_binprm *bprm)
68791 +{
68792 + return;
68793 +}
68794 +#endif
68795 +
68796 +#ifdef CONFIG_SYSCTL
68797 +__u32
68798 +gr_handle_sysctl(const struct ctl_table * table, const int op)
68799 +{
68800 + return 0;
68801 +}
68802 +#endif
68803 +
68804 +#ifdef CONFIG_TASKSTATS
68805 +int gr_is_taskstats_denied(int pid)
68806 +{
68807 + return 0;
68808 +}
68809 +#endif
68810 +
68811 +int
68812 +gr_acl_is_enabled(void)
68813 +{
68814 + return 0;
68815 +}
68816 +
68817 +void
68818 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
68819 +{
68820 + return;
68821 +}
68822 +
68823 +int
68824 +gr_handle_rawio(const struct inode *inode)
68825 +{
68826 + return 0;
68827 +}
68828 +
68829 +void
68830 +gr_acl_handle_psacct(struct task_struct *task, const long code)
68831 +{
68832 + return;
68833 +}
68834 +
68835 +int
68836 +gr_handle_ptrace(struct task_struct *task, const long request)
68837 +{
68838 + return 0;
68839 +}
68840 +
68841 +int
68842 +gr_handle_proc_ptrace(struct task_struct *task)
68843 +{
68844 + return 0;
68845 +}
68846 +
68847 +int
68848 +gr_set_acls(const int type)
68849 +{
68850 + return 0;
68851 +}
68852 +
68853 +int
68854 +gr_check_hidden_task(const struct task_struct *tsk)
68855 +{
68856 + return 0;
68857 +}
68858 +
68859 +int
68860 +gr_check_protected_task(const struct task_struct *task)
68861 +{
68862 + return 0;
68863 +}
68864 +
68865 +int
68866 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
68867 +{
68868 + return 0;
68869 +}
68870 +
68871 +void
68872 +gr_copy_label(struct task_struct *tsk)
68873 +{
68874 + return;
68875 +}
68876 +
68877 +void
68878 +gr_set_pax_flags(struct task_struct *task)
68879 +{
68880 + return;
68881 +}
68882 +
68883 +int
68884 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
68885 + const int unsafe_share)
68886 +{
68887 + return 0;
68888 +}
68889 +
68890 +void
68891 +gr_handle_delete(const ino_t ino, const dev_t dev)
68892 +{
68893 + return;
68894 +}
68895 +
68896 +void
68897 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
68898 +{
68899 + return;
68900 +}
68901 +
68902 +void
68903 +gr_handle_crash(struct task_struct *task, const int sig)
68904 +{
68905 + return;
68906 +}
68907 +
68908 +int
68909 +gr_check_crash_exec(const struct file *filp)
68910 +{
68911 + return 0;
68912 +}
68913 +
68914 +int
68915 +gr_check_crash_uid(const kuid_t uid)
68916 +{
68917 + return 0;
68918 +}
68919 +
68920 +void
68921 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68922 + struct dentry *old_dentry,
68923 + struct dentry *new_dentry,
68924 + struct vfsmount *mnt, const __u8 replace)
68925 +{
68926 + return;
68927 +}
68928 +
68929 +int
68930 +gr_search_socket(const int family, const int type, const int protocol)
68931 +{
68932 + return 1;
68933 +}
68934 +
68935 +int
68936 +gr_search_connectbind(const int mode, const struct socket *sock,
68937 + const struct sockaddr_in *addr)
68938 +{
68939 + return 0;
68940 +}
68941 +
68942 +void
68943 +gr_handle_alertkill(struct task_struct *task)
68944 +{
68945 + return;
68946 +}
68947 +
68948 +__u32
68949 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
68950 +{
68951 + return 1;
68952 +}
68953 +
68954 +__u32
68955 +gr_acl_handle_hidden_file(const struct dentry * dentry,
68956 + const struct vfsmount * mnt)
68957 +{
68958 + return 1;
68959 +}
68960 +
68961 +__u32
68962 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
68963 + int acc_mode)
68964 +{
68965 + return 1;
68966 +}
68967 +
68968 +__u32
68969 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
68970 +{
68971 + return 1;
68972 +}
68973 +
68974 +__u32
68975 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
68976 +{
68977 + return 1;
68978 +}
68979 +
68980 +int
68981 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
68982 + unsigned int *vm_flags)
68983 +{
68984 + return 1;
68985 +}
68986 +
68987 +__u32
68988 +gr_acl_handle_truncate(const struct dentry * dentry,
68989 + const struct vfsmount * mnt)
68990 +{
68991 + return 1;
68992 +}
68993 +
68994 +__u32
68995 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
68996 +{
68997 + return 1;
68998 +}
68999 +
69000 +__u32
69001 +gr_acl_handle_access(const struct dentry * dentry,
69002 + const struct vfsmount * mnt, const int fmode)
69003 +{
69004 + return 1;
69005 +}
69006 +
69007 +__u32
69008 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
69009 + umode_t *mode)
69010 +{
69011 + return 1;
69012 +}
69013 +
69014 +__u32
69015 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
69016 +{
69017 + return 1;
69018 +}
69019 +
69020 +__u32
69021 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
69022 +{
69023 + return 1;
69024 +}
69025 +
69026 +void
69027 +grsecurity_init(void)
69028 +{
69029 + return;
69030 +}
69031 +
69032 +umode_t gr_acl_umask(void)
69033 +{
69034 + return 0;
69035 +}
69036 +
69037 +__u32
69038 +gr_acl_handle_mknod(const struct dentry * new_dentry,
69039 + const struct dentry * parent_dentry,
69040 + const struct vfsmount * parent_mnt,
69041 + const int mode)
69042 +{
69043 + return 1;
69044 +}
69045 +
69046 +__u32
69047 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
69048 + const struct dentry * parent_dentry,
69049 + const struct vfsmount * parent_mnt)
69050 +{
69051 + return 1;
69052 +}
69053 +
69054 +__u32
69055 +gr_acl_handle_symlink(const struct dentry * new_dentry,
69056 + const struct dentry * parent_dentry,
69057 + const struct vfsmount * parent_mnt, const struct filename *from)
69058 +{
69059 + return 1;
69060 +}
69061 +
69062 +__u32
69063 +gr_acl_handle_link(const struct dentry * new_dentry,
69064 + const struct dentry * parent_dentry,
69065 + const struct vfsmount * parent_mnt,
69066 + const struct dentry * old_dentry,
69067 + const struct vfsmount * old_mnt, const struct filename *to)
69068 +{
69069 + return 1;
69070 +}
69071 +
69072 +int
69073 +gr_acl_handle_rename(const struct dentry *new_dentry,
69074 + const struct dentry *parent_dentry,
69075 + const struct vfsmount *parent_mnt,
69076 + const struct dentry *old_dentry,
69077 + const struct inode *old_parent_inode,
69078 + const struct vfsmount *old_mnt, const struct filename *newname)
69079 +{
69080 + return 0;
69081 +}
69082 +
69083 +int
69084 +gr_acl_handle_filldir(const struct file *file, const char *name,
69085 + const int namelen, const ino_t ino)
69086 +{
69087 + return 1;
69088 +}
69089 +
69090 +int
69091 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69092 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69093 +{
69094 + return 1;
69095 +}
69096 +
69097 +int
69098 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
69099 +{
69100 + return 0;
69101 +}
69102 +
69103 +int
69104 +gr_search_accept(const struct socket *sock)
69105 +{
69106 + return 0;
69107 +}
69108 +
69109 +int
69110 +gr_search_listen(const struct socket *sock)
69111 +{
69112 + return 0;
69113 +}
69114 +
69115 +int
69116 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
69117 +{
69118 + return 0;
69119 +}
69120 +
69121 +__u32
69122 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
69123 +{
69124 + return 1;
69125 +}
69126 +
69127 +__u32
69128 +gr_acl_handle_creat(const struct dentry * dentry,
69129 + const struct dentry * p_dentry,
69130 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69131 + const int imode)
69132 +{
69133 + return 1;
69134 +}
69135 +
69136 +void
69137 +gr_acl_handle_exit(void)
69138 +{
69139 + return;
69140 +}
69141 +
69142 +int
69143 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69144 +{
69145 + return 1;
69146 +}
69147 +
69148 +void
69149 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
69150 +{
69151 + return;
69152 +}
69153 +
69154 +int
69155 +gr_acl_handle_procpidmem(const struct task_struct *task)
69156 +{
69157 + return 0;
69158 +}
69159 +
69160 +int
69161 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
69162 +{
69163 + return 0;
69164 +}
69165 +
69166 +int
69167 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
69168 +{
69169 + return 0;
69170 +}
69171 +
69172 +void
69173 +gr_set_kernel_label(struct task_struct *task)
69174 +{
69175 + return;
69176 +}
69177 +
69178 +int
69179 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
69180 +{
69181 + return 0;
69182 +}
69183 +
69184 +int
69185 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
69186 +{
69187 + return 0;
69188 +}
69189 +
69190 +int gr_acl_enable_at_secure(void)
69191 +{
69192 + return 0;
69193 +}
69194 +
69195 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
69196 +{
69197 + return dentry->d_sb->s_dev;
69198 +}
69199 +
69200 +void gr_put_exec_file(struct task_struct *task)
69201 +{
69202 + return;
69203 +}
69204 +
69205 +EXPORT_SYMBOL(gr_set_kernel_label);
69206 +#ifdef CONFIG_SECURITY
69207 +EXPORT_SYMBOL(gr_check_user_change);
69208 +EXPORT_SYMBOL(gr_check_group_change);
69209 +#endif
69210 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
69211 new file mode 100644
69212 index 0000000..387032b
69213 --- /dev/null
69214 +++ b/grsecurity/grsec_exec.c
69215 @@ -0,0 +1,187 @@
69216 +#include <linux/kernel.h>
69217 +#include <linux/sched.h>
69218 +#include <linux/file.h>
69219 +#include <linux/binfmts.h>
69220 +#include <linux/fs.h>
69221 +#include <linux/types.h>
69222 +#include <linux/grdefs.h>
69223 +#include <linux/grsecurity.h>
69224 +#include <linux/grinternal.h>
69225 +#include <linux/capability.h>
69226 +#include <linux/module.h>
69227 +#include <linux/compat.h>
69228 +
69229 +#include <asm/uaccess.h>
69230 +
69231 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69232 +static char gr_exec_arg_buf[132];
69233 +static DEFINE_MUTEX(gr_exec_arg_mutex);
69234 +#endif
69235 +
69236 +struct user_arg_ptr {
69237 +#ifdef CONFIG_COMPAT
69238 + bool is_compat;
69239 +#endif
69240 + union {
69241 + const char __user *const __user *native;
69242 +#ifdef CONFIG_COMPAT
69243 + const compat_uptr_t __user *compat;
69244 +#endif
69245 + } ptr;
69246 +};
69247 +
69248 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
69249 +
69250 +void
69251 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
69252 +{
69253 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69254 + char *grarg = gr_exec_arg_buf;
69255 + unsigned int i, x, execlen = 0;
69256 + char c;
69257 +
69258 + if (!((grsec_enable_execlog && grsec_enable_group &&
69259 + in_group_p(grsec_audit_gid))
69260 + || (grsec_enable_execlog && !grsec_enable_group)))
69261 + return;
69262 +
69263 + mutex_lock(&gr_exec_arg_mutex);
69264 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
69265 +
69266 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
69267 + const char __user *p;
69268 + unsigned int len;
69269 +
69270 + p = get_user_arg_ptr(argv, i);
69271 + if (IS_ERR(p))
69272 + goto log;
69273 +
69274 + len = strnlen_user(p, 128 - execlen);
69275 + if (len > 128 - execlen)
69276 + len = 128 - execlen;
69277 + else if (len > 0)
69278 + len--;
69279 + if (copy_from_user(grarg + execlen, p, len))
69280 + goto log;
69281 +
69282 + /* rewrite unprintable characters */
69283 + for (x = 0; x < len; x++) {
69284 + c = *(grarg + execlen + x);
69285 + if (c < 32 || c > 126)
69286 + *(grarg + execlen + x) = ' ';
69287 + }
69288 +
69289 + execlen += len;
69290 + *(grarg + execlen) = ' ';
69291 + *(grarg + execlen + 1) = '\0';
69292 + execlen++;
69293 + }
69294 +
69295 + log:
69296 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
69297 + bprm->file->f_path.mnt, grarg);
69298 + mutex_unlock(&gr_exec_arg_mutex);
69299 +#endif
69300 + return;
69301 +}
69302 +
69303 +#ifdef CONFIG_GRKERNSEC
69304 +extern int gr_acl_is_capable(const int cap);
69305 +extern int gr_acl_is_capable_nolog(const int cap);
69306 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69307 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
69308 +extern int gr_chroot_is_capable(const int cap);
69309 +extern int gr_chroot_is_capable_nolog(const int cap);
69310 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69311 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
69312 +#endif
69313 +
69314 +const char *captab_log[] = {
69315 + "CAP_CHOWN",
69316 + "CAP_DAC_OVERRIDE",
69317 + "CAP_DAC_READ_SEARCH",
69318 + "CAP_FOWNER",
69319 + "CAP_FSETID",
69320 + "CAP_KILL",
69321 + "CAP_SETGID",
69322 + "CAP_SETUID",
69323 + "CAP_SETPCAP",
69324 + "CAP_LINUX_IMMUTABLE",
69325 + "CAP_NET_BIND_SERVICE",
69326 + "CAP_NET_BROADCAST",
69327 + "CAP_NET_ADMIN",
69328 + "CAP_NET_RAW",
69329 + "CAP_IPC_LOCK",
69330 + "CAP_IPC_OWNER",
69331 + "CAP_SYS_MODULE",
69332 + "CAP_SYS_RAWIO",
69333 + "CAP_SYS_CHROOT",
69334 + "CAP_SYS_PTRACE",
69335 + "CAP_SYS_PACCT",
69336 + "CAP_SYS_ADMIN",
69337 + "CAP_SYS_BOOT",
69338 + "CAP_SYS_NICE",
69339 + "CAP_SYS_RESOURCE",
69340 + "CAP_SYS_TIME",
69341 + "CAP_SYS_TTY_CONFIG",
69342 + "CAP_MKNOD",
69343 + "CAP_LEASE",
69344 + "CAP_AUDIT_WRITE",
69345 + "CAP_AUDIT_CONTROL",
69346 + "CAP_SETFCAP",
69347 + "CAP_MAC_OVERRIDE",
69348 + "CAP_MAC_ADMIN",
69349 + "CAP_SYSLOG",
69350 + "CAP_WAKE_ALARM"
69351 +};
69352 +
69353 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
69354 +
69355 +int gr_is_capable(const int cap)
69356 +{
69357 +#ifdef CONFIG_GRKERNSEC
69358 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
69359 + return 1;
69360 + return 0;
69361 +#else
69362 + return 1;
69363 +#endif
69364 +}
69365 +
69366 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69367 +{
69368 +#ifdef CONFIG_GRKERNSEC
69369 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
69370 + return 1;
69371 + return 0;
69372 +#else
69373 + return 1;
69374 +#endif
69375 +}
69376 +
69377 +int gr_is_capable_nolog(const int cap)
69378 +{
69379 +#ifdef CONFIG_GRKERNSEC
69380 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
69381 + return 1;
69382 + return 0;
69383 +#else
69384 + return 1;
69385 +#endif
69386 +}
69387 +
69388 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
69389 +{
69390 +#ifdef CONFIG_GRKERNSEC
69391 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
69392 + return 1;
69393 + return 0;
69394 +#else
69395 + return 1;
69396 +#endif
69397 +}
69398 +
69399 +EXPORT_SYMBOL(gr_is_capable);
69400 +EXPORT_SYMBOL(gr_is_capable_nolog);
69401 +EXPORT_SYMBOL(gr_task_is_capable);
69402 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
69403 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
69404 new file mode 100644
69405 index 0000000..06cc6ea
69406 --- /dev/null
69407 +++ b/grsecurity/grsec_fifo.c
69408 @@ -0,0 +1,24 @@
69409 +#include <linux/kernel.h>
69410 +#include <linux/sched.h>
69411 +#include <linux/fs.h>
69412 +#include <linux/file.h>
69413 +#include <linux/grinternal.h>
69414 +
69415 +int
69416 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
69417 + const struct dentry *dir, const int flag, const int acc_mode)
69418 +{
69419 +#ifdef CONFIG_GRKERNSEC_FIFO
69420 + const struct cred *cred = current_cred();
69421 +
69422 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
69423 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
69424 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
69425 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
69426 + if (!inode_permission(dentry->d_inode, acc_mode))
69427 + 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));
69428 + return -EACCES;
69429 + }
69430 +#endif
69431 + return 0;
69432 +}
69433 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
69434 new file mode 100644
69435 index 0000000..8ca18bf
69436 --- /dev/null
69437 +++ b/grsecurity/grsec_fork.c
69438 @@ -0,0 +1,23 @@
69439 +#include <linux/kernel.h>
69440 +#include <linux/sched.h>
69441 +#include <linux/grsecurity.h>
69442 +#include <linux/grinternal.h>
69443 +#include <linux/errno.h>
69444 +
69445 +void
69446 +gr_log_forkfail(const int retval)
69447 +{
69448 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69449 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
69450 + switch (retval) {
69451 + case -EAGAIN:
69452 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
69453 + break;
69454 + case -ENOMEM:
69455 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
69456 + break;
69457 + }
69458 + }
69459 +#endif
69460 + return;
69461 +}
69462 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
69463 new file mode 100644
69464 index 0000000..087cf30
69465 --- /dev/null
69466 +++ b/grsecurity/grsec_init.c
69467 @@ -0,0 +1,287 @@
69468 +#include <linux/kernel.h>
69469 +#include <linux/sched.h>
69470 +#include <linux/mm.h>
69471 +#include <linux/gracl.h>
69472 +#include <linux/slab.h>
69473 +#include <linux/vmalloc.h>
69474 +#include <linux/percpu.h>
69475 +#include <linux/module.h>
69476 +
69477 +int grsec_enable_ptrace_readexec;
69478 +int grsec_enable_setxid;
69479 +int grsec_enable_symlinkown;
69480 +kgid_t grsec_symlinkown_gid;
69481 +int grsec_enable_brute;
69482 +int grsec_enable_link;
69483 +int grsec_enable_dmesg;
69484 +int grsec_enable_harden_ptrace;
69485 +int grsec_enable_harden_ipc;
69486 +int grsec_enable_fifo;
69487 +int grsec_enable_execlog;
69488 +int grsec_enable_signal;
69489 +int grsec_enable_forkfail;
69490 +int grsec_enable_audit_ptrace;
69491 +int grsec_enable_time;
69492 +int grsec_enable_group;
69493 +kgid_t grsec_audit_gid;
69494 +int grsec_enable_chdir;
69495 +int grsec_enable_mount;
69496 +int grsec_enable_rofs;
69497 +int grsec_deny_new_usb;
69498 +int grsec_enable_chroot_findtask;
69499 +int grsec_enable_chroot_mount;
69500 +int grsec_enable_chroot_shmat;
69501 +int grsec_enable_chroot_fchdir;
69502 +int grsec_enable_chroot_double;
69503 +int grsec_enable_chroot_pivot;
69504 +int grsec_enable_chroot_chdir;
69505 +int grsec_enable_chroot_chmod;
69506 +int grsec_enable_chroot_mknod;
69507 +int grsec_enable_chroot_nice;
69508 +int grsec_enable_chroot_execlog;
69509 +int grsec_enable_chroot_caps;
69510 +int grsec_enable_chroot_sysctl;
69511 +int grsec_enable_chroot_unix;
69512 +int grsec_enable_tpe;
69513 +kgid_t grsec_tpe_gid;
69514 +int grsec_enable_blackhole;
69515 +#ifdef CONFIG_IPV6_MODULE
69516 +EXPORT_SYMBOL(grsec_enable_blackhole);
69517 +#endif
69518 +int grsec_lastack_retries;
69519 +int grsec_enable_tpe_all;
69520 +int grsec_enable_tpe_invert;
69521 +int grsec_enable_socket_all;
69522 +kgid_t grsec_socket_all_gid;
69523 +int grsec_enable_socket_client;
69524 +kgid_t grsec_socket_client_gid;
69525 +int grsec_enable_socket_server;
69526 +kgid_t grsec_socket_server_gid;
69527 +int grsec_resource_logging;
69528 +int grsec_disable_privio;
69529 +int grsec_enable_log_rwxmaps;
69530 +int grsec_lock;
69531 +
69532 +DEFINE_SPINLOCK(grsec_alert_lock);
69533 +unsigned long grsec_alert_wtime = 0;
69534 +unsigned long grsec_alert_fyet = 0;
69535 +
69536 +DEFINE_SPINLOCK(grsec_audit_lock);
69537 +
69538 +DEFINE_RWLOCK(grsec_exec_file_lock);
69539 +
69540 +char *gr_shared_page[4];
69541 +
69542 +char *gr_alert_log_fmt;
69543 +char *gr_audit_log_fmt;
69544 +char *gr_alert_log_buf;
69545 +char *gr_audit_log_buf;
69546 +
69547 +extern struct gr_arg *gr_usermode;
69548 +extern unsigned char *gr_system_salt;
69549 +extern unsigned char *gr_system_sum;
69550 +
69551 +void __init
69552 +grsecurity_init(void)
69553 +{
69554 + int j;
69555 + /* create the per-cpu shared pages */
69556 +
69557 +#ifdef CONFIG_X86
69558 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
69559 +#endif
69560 +
69561 + for (j = 0; j < 4; j++) {
69562 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
69563 + if (gr_shared_page[j] == NULL) {
69564 + panic("Unable to allocate grsecurity shared page");
69565 + return;
69566 + }
69567 + }
69568 +
69569 + /* allocate log buffers */
69570 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
69571 + if (!gr_alert_log_fmt) {
69572 + panic("Unable to allocate grsecurity alert log format buffer");
69573 + return;
69574 + }
69575 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
69576 + if (!gr_audit_log_fmt) {
69577 + panic("Unable to allocate grsecurity audit log format buffer");
69578 + return;
69579 + }
69580 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69581 + if (!gr_alert_log_buf) {
69582 + panic("Unable to allocate grsecurity alert log buffer");
69583 + return;
69584 + }
69585 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69586 + if (!gr_audit_log_buf) {
69587 + panic("Unable to allocate grsecurity audit log buffer");
69588 + return;
69589 + }
69590 +
69591 + /* allocate memory for authentication structure */
69592 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
69593 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
69594 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
69595 +
69596 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
69597 + panic("Unable to allocate grsecurity authentication structure");
69598 + return;
69599 + }
69600 +
69601 +
69602 +#ifdef CONFIG_GRKERNSEC_IO
69603 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
69604 + grsec_disable_privio = 1;
69605 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69606 + grsec_disable_privio = 1;
69607 +#else
69608 + grsec_disable_privio = 0;
69609 +#endif
69610 +#endif
69611 +
69612 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69613 + /* for backward compatibility, tpe_invert always defaults to on if
69614 + enabled in the kernel
69615 + */
69616 + grsec_enable_tpe_invert = 1;
69617 +#endif
69618 +
69619 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69620 +#ifndef CONFIG_GRKERNSEC_SYSCTL
69621 + grsec_lock = 1;
69622 +#endif
69623 +
69624 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69625 + grsec_enable_log_rwxmaps = 1;
69626 +#endif
69627 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69628 + grsec_enable_group = 1;
69629 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
69630 +#endif
69631 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69632 + grsec_enable_ptrace_readexec = 1;
69633 +#endif
69634 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69635 + grsec_enable_chdir = 1;
69636 +#endif
69637 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69638 + grsec_enable_harden_ptrace = 1;
69639 +#endif
69640 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
69641 + grsec_enable_harden_ipc = 1;
69642 +#endif
69643 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69644 + grsec_enable_mount = 1;
69645 +#endif
69646 +#ifdef CONFIG_GRKERNSEC_LINK
69647 + grsec_enable_link = 1;
69648 +#endif
69649 +#ifdef CONFIG_GRKERNSEC_BRUTE
69650 + grsec_enable_brute = 1;
69651 +#endif
69652 +#ifdef CONFIG_GRKERNSEC_DMESG
69653 + grsec_enable_dmesg = 1;
69654 +#endif
69655 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69656 + grsec_enable_blackhole = 1;
69657 + grsec_lastack_retries = 4;
69658 +#endif
69659 +#ifdef CONFIG_GRKERNSEC_FIFO
69660 + grsec_enable_fifo = 1;
69661 +#endif
69662 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69663 + grsec_enable_execlog = 1;
69664 +#endif
69665 +#ifdef CONFIG_GRKERNSEC_SETXID
69666 + grsec_enable_setxid = 1;
69667 +#endif
69668 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69669 + grsec_enable_signal = 1;
69670 +#endif
69671 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69672 + grsec_enable_forkfail = 1;
69673 +#endif
69674 +#ifdef CONFIG_GRKERNSEC_TIME
69675 + grsec_enable_time = 1;
69676 +#endif
69677 +#ifdef CONFIG_GRKERNSEC_RESLOG
69678 + grsec_resource_logging = 1;
69679 +#endif
69680 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69681 + grsec_enable_chroot_findtask = 1;
69682 +#endif
69683 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69684 + grsec_enable_chroot_unix = 1;
69685 +#endif
69686 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69687 + grsec_enable_chroot_mount = 1;
69688 +#endif
69689 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69690 + grsec_enable_chroot_fchdir = 1;
69691 +#endif
69692 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69693 + grsec_enable_chroot_shmat = 1;
69694 +#endif
69695 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69696 + grsec_enable_audit_ptrace = 1;
69697 +#endif
69698 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69699 + grsec_enable_chroot_double = 1;
69700 +#endif
69701 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69702 + grsec_enable_chroot_pivot = 1;
69703 +#endif
69704 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69705 + grsec_enable_chroot_chdir = 1;
69706 +#endif
69707 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69708 + grsec_enable_chroot_chmod = 1;
69709 +#endif
69710 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69711 + grsec_enable_chroot_mknod = 1;
69712 +#endif
69713 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69714 + grsec_enable_chroot_nice = 1;
69715 +#endif
69716 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69717 + grsec_enable_chroot_execlog = 1;
69718 +#endif
69719 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69720 + grsec_enable_chroot_caps = 1;
69721 +#endif
69722 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69723 + grsec_enable_chroot_sysctl = 1;
69724 +#endif
69725 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69726 + grsec_enable_symlinkown = 1;
69727 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
69728 +#endif
69729 +#ifdef CONFIG_GRKERNSEC_TPE
69730 + grsec_enable_tpe = 1;
69731 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
69732 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69733 + grsec_enable_tpe_all = 1;
69734 +#endif
69735 +#endif
69736 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69737 + grsec_enable_socket_all = 1;
69738 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
69739 +#endif
69740 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69741 + grsec_enable_socket_client = 1;
69742 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
69743 +#endif
69744 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69745 + grsec_enable_socket_server = 1;
69746 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
69747 +#endif
69748 +#endif
69749 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
69750 + grsec_deny_new_usb = 1;
69751 +#endif
69752 +
69753 + return;
69754 +}
69755 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
69756 new file mode 100644
69757 index 0000000..f365de0
69758 --- /dev/null
69759 +++ b/grsecurity/grsec_ipc.c
69760 @@ -0,0 +1,22 @@
69761 +#include <linux/kernel.h>
69762 +#include <linux/mm.h>
69763 +#include <linux/sched.h>
69764 +#include <linux/file.h>
69765 +#include <linux/ipc.h>
69766 +#include <linux/ipc_namespace.h>
69767 +#include <linux/grsecurity.h>
69768 +#include <linux/grinternal.h>
69769 +
69770 +int
69771 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
69772 +{
69773 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
69774 + int write = (requested_mode & 00002);
69775 +
69776 + if (grsec_enable_harden_ipc && !(requested_mode & ~granted_mode & 0007) && !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
69777 + gr_log_str2_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", write ? "writ" : "read", GR_GLOBAL_UID(ipcp->cuid));
69778 + return 0;
69779 + }
69780 +#endif
69781 + return 1;
69782 +}
69783 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
69784 new file mode 100644
69785 index 0000000..5e05e20
69786 --- /dev/null
69787 +++ b/grsecurity/grsec_link.c
69788 @@ -0,0 +1,58 @@
69789 +#include <linux/kernel.h>
69790 +#include <linux/sched.h>
69791 +#include <linux/fs.h>
69792 +#include <linux/file.h>
69793 +#include <linux/grinternal.h>
69794 +
69795 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
69796 +{
69797 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69798 + const struct inode *link_inode = link->dentry->d_inode;
69799 +
69800 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
69801 + /* ignore root-owned links, e.g. /proc/self */
69802 + gr_is_global_nonroot(link_inode->i_uid) && target &&
69803 + !uid_eq(link_inode->i_uid, target->i_uid)) {
69804 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
69805 + return 1;
69806 + }
69807 +#endif
69808 + return 0;
69809 +}
69810 +
69811 +int
69812 +gr_handle_follow_link(const struct inode *parent,
69813 + const struct inode *inode,
69814 + const struct dentry *dentry, const struct vfsmount *mnt)
69815 +{
69816 +#ifdef CONFIG_GRKERNSEC_LINK
69817 + const struct cred *cred = current_cred();
69818 +
69819 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
69820 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
69821 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
69822 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
69823 + return -EACCES;
69824 + }
69825 +#endif
69826 + return 0;
69827 +}
69828 +
69829 +int
69830 +gr_handle_hardlink(const struct dentry *dentry,
69831 + const struct vfsmount *mnt,
69832 + struct inode *inode, const int mode, const struct filename *to)
69833 +{
69834 +#ifdef CONFIG_GRKERNSEC_LINK
69835 + const struct cred *cred = current_cred();
69836 +
69837 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
69838 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
69839 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
69840 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
69841 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
69842 + return -EPERM;
69843 + }
69844 +#endif
69845 + return 0;
69846 +}
69847 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
69848 new file mode 100644
69849 index 0000000..dbe0a6b
69850 --- /dev/null
69851 +++ b/grsecurity/grsec_log.c
69852 @@ -0,0 +1,341 @@
69853 +#include <linux/kernel.h>
69854 +#include <linux/sched.h>
69855 +#include <linux/file.h>
69856 +#include <linux/tty.h>
69857 +#include <linux/fs.h>
69858 +#include <linux/mm.h>
69859 +#include <linux/grinternal.h>
69860 +
69861 +#ifdef CONFIG_TREE_PREEMPT_RCU
69862 +#define DISABLE_PREEMPT() preempt_disable()
69863 +#define ENABLE_PREEMPT() preempt_enable()
69864 +#else
69865 +#define DISABLE_PREEMPT()
69866 +#define ENABLE_PREEMPT()
69867 +#endif
69868 +
69869 +#define BEGIN_LOCKS(x) \
69870 + DISABLE_PREEMPT(); \
69871 + rcu_read_lock(); \
69872 + read_lock(&tasklist_lock); \
69873 + read_lock(&grsec_exec_file_lock); \
69874 + if (x != GR_DO_AUDIT) \
69875 + spin_lock(&grsec_alert_lock); \
69876 + else \
69877 + spin_lock(&grsec_audit_lock)
69878 +
69879 +#define END_LOCKS(x) \
69880 + if (x != GR_DO_AUDIT) \
69881 + spin_unlock(&grsec_alert_lock); \
69882 + else \
69883 + spin_unlock(&grsec_audit_lock); \
69884 + read_unlock(&grsec_exec_file_lock); \
69885 + read_unlock(&tasklist_lock); \
69886 + rcu_read_unlock(); \
69887 + ENABLE_PREEMPT(); \
69888 + if (x == GR_DONT_AUDIT) \
69889 + gr_handle_alertkill(current)
69890 +
69891 +enum {
69892 + FLOODING,
69893 + NO_FLOODING
69894 +};
69895 +
69896 +extern char *gr_alert_log_fmt;
69897 +extern char *gr_audit_log_fmt;
69898 +extern char *gr_alert_log_buf;
69899 +extern char *gr_audit_log_buf;
69900 +
69901 +static int gr_log_start(int audit)
69902 +{
69903 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
69904 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
69905 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69906 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
69907 + unsigned long curr_secs = get_seconds();
69908 +
69909 + if (audit == GR_DO_AUDIT)
69910 + goto set_fmt;
69911 +
69912 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
69913 + grsec_alert_wtime = curr_secs;
69914 + grsec_alert_fyet = 0;
69915 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
69916 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
69917 + grsec_alert_fyet++;
69918 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
69919 + grsec_alert_wtime = curr_secs;
69920 + grsec_alert_fyet++;
69921 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
69922 + return FLOODING;
69923 + }
69924 + else return FLOODING;
69925 +
69926 +set_fmt:
69927 +#endif
69928 + memset(buf, 0, PAGE_SIZE);
69929 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
69930 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
69931 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69932 + } else if (current->signal->curr_ip) {
69933 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
69934 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
69935 + } else if (gr_acl_is_enabled()) {
69936 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
69937 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69938 + } else {
69939 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
69940 + strcpy(buf, fmt);
69941 + }
69942 +
69943 + return NO_FLOODING;
69944 +}
69945 +
69946 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69947 + __attribute__ ((format (printf, 2, 0)));
69948 +
69949 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69950 +{
69951 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69952 + unsigned int len = strlen(buf);
69953 +
69954 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69955 +
69956 + return;
69957 +}
69958 +
69959 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69960 + __attribute__ ((format (printf, 2, 3)));
69961 +
69962 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69963 +{
69964 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69965 + unsigned int len = strlen(buf);
69966 + va_list ap;
69967 +
69968 + va_start(ap, msg);
69969 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69970 + va_end(ap);
69971 +
69972 + return;
69973 +}
69974 +
69975 +static void gr_log_end(int audit, int append_default)
69976 +{
69977 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69978 + if (append_default) {
69979 + struct task_struct *task = current;
69980 + struct task_struct *parent = task->real_parent;
69981 + const struct cred *cred = __task_cred(task);
69982 + const struct cred *pcred = __task_cred(parent);
69983 + unsigned int len = strlen(buf);
69984 +
69985 + 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));
69986 + }
69987 +
69988 + printk("%s\n", buf);
69989 +
69990 + return;
69991 +}
69992 +
69993 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
69994 +{
69995 + int logtype;
69996 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
69997 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
69998 + void *voidptr = NULL;
69999 + int num1 = 0, num2 = 0;
70000 + unsigned long ulong1 = 0, ulong2 = 0;
70001 + struct dentry *dentry = NULL;
70002 + struct vfsmount *mnt = NULL;
70003 + struct file *file = NULL;
70004 + struct task_struct *task = NULL;
70005 + struct vm_area_struct *vma = NULL;
70006 + const struct cred *cred, *pcred;
70007 + va_list ap;
70008 +
70009 + BEGIN_LOCKS(audit);
70010 + logtype = gr_log_start(audit);
70011 + if (logtype == FLOODING) {
70012 + END_LOCKS(audit);
70013 + return;
70014 + }
70015 + va_start(ap, argtypes);
70016 + switch (argtypes) {
70017 + case GR_TTYSNIFF:
70018 + task = va_arg(ap, struct task_struct *);
70019 + 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));
70020 + break;
70021 + case GR_SYSCTL_HIDDEN:
70022 + str1 = va_arg(ap, char *);
70023 + gr_log_middle_varargs(audit, msg, result, str1);
70024 + break;
70025 + case GR_RBAC:
70026 + dentry = va_arg(ap, struct dentry *);
70027 + mnt = va_arg(ap, struct vfsmount *);
70028 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
70029 + break;
70030 + case GR_RBAC_STR:
70031 + dentry = va_arg(ap, struct dentry *);
70032 + mnt = va_arg(ap, struct vfsmount *);
70033 + str1 = va_arg(ap, char *);
70034 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
70035 + break;
70036 + case GR_STR_RBAC:
70037 + str1 = va_arg(ap, char *);
70038 + dentry = va_arg(ap, struct dentry *);
70039 + mnt = va_arg(ap, struct vfsmount *);
70040 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
70041 + break;
70042 + case GR_RBAC_MODE2:
70043 + dentry = va_arg(ap, struct dentry *);
70044 + mnt = va_arg(ap, struct vfsmount *);
70045 + str1 = va_arg(ap, char *);
70046 + str2 = va_arg(ap, char *);
70047 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
70048 + break;
70049 + case GR_RBAC_MODE3:
70050 + dentry = va_arg(ap, struct dentry *);
70051 + mnt = va_arg(ap, struct vfsmount *);
70052 + str1 = va_arg(ap, char *);
70053 + str2 = va_arg(ap, char *);
70054 + str3 = va_arg(ap, char *);
70055 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
70056 + break;
70057 + case GR_FILENAME:
70058 + dentry = va_arg(ap, struct dentry *);
70059 + mnt = va_arg(ap, struct vfsmount *);
70060 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
70061 + break;
70062 + case GR_STR_FILENAME:
70063 + str1 = va_arg(ap, char *);
70064 + dentry = va_arg(ap, struct dentry *);
70065 + mnt = va_arg(ap, struct vfsmount *);
70066 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
70067 + break;
70068 + case GR_FILENAME_STR:
70069 + dentry = va_arg(ap, struct dentry *);
70070 + mnt = va_arg(ap, struct vfsmount *);
70071 + str1 = va_arg(ap, char *);
70072 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
70073 + break;
70074 + case GR_FILENAME_TWO_INT:
70075 + dentry = va_arg(ap, struct dentry *);
70076 + mnt = va_arg(ap, struct vfsmount *);
70077 + num1 = va_arg(ap, int);
70078 + num2 = va_arg(ap, int);
70079 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
70080 + break;
70081 + case GR_FILENAME_TWO_INT_STR:
70082 + dentry = va_arg(ap, struct dentry *);
70083 + mnt = va_arg(ap, struct vfsmount *);
70084 + num1 = va_arg(ap, int);
70085 + num2 = va_arg(ap, int);
70086 + str1 = va_arg(ap, char *);
70087 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
70088 + break;
70089 + case GR_TEXTREL:
70090 + file = va_arg(ap, struct file *);
70091 + ulong1 = va_arg(ap, unsigned long);
70092 + ulong2 = va_arg(ap, unsigned long);
70093 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
70094 + break;
70095 + case GR_PTRACE:
70096 + task = va_arg(ap, struct task_struct *);
70097 + 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));
70098 + break;
70099 + case GR_RESOURCE:
70100 + task = va_arg(ap, struct task_struct *);
70101 + cred = __task_cred(task);
70102 + pcred = __task_cred(task->real_parent);
70103 + ulong1 = va_arg(ap, unsigned long);
70104 + str1 = va_arg(ap, char *);
70105 + ulong2 = va_arg(ap, unsigned long);
70106 + 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));
70107 + break;
70108 + case GR_CAP:
70109 + task = va_arg(ap, struct task_struct *);
70110 + cred = __task_cred(task);
70111 + pcred = __task_cred(task->real_parent);
70112 + str1 = va_arg(ap, char *);
70113 + 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));
70114 + break;
70115 + case GR_SIG:
70116 + str1 = va_arg(ap, char *);
70117 + voidptr = va_arg(ap, void *);
70118 + gr_log_middle_varargs(audit, msg, str1, voidptr);
70119 + break;
70120 + case GR_SIG2:
70121 + task = va_arg(ap, struct task_struct *);
70122 + cred = __task_cred(task);
70123 + pcred = __task_cred(task->real_parent);
70124 + num1 = va_arg(ap, int);
70125 + 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));
70126 + break;
70127 + case GR_CRASH1:
70128 + task = va_arg(ap, struct task_struct *);
70129 + cred = __task_cred(task);
70130 + pcred = __task_cred(task->real_parent);
70131 + ulong1 = va_arg(ap, unsigned long);
70132 + 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);
70133 + break;
70134 + case GR_CRASH2:
70135 + task = va_arg(ap, struct task_struct *);
70136 + cred = __task_cred(task);
70137 + pcred = __task_cred(task->real_parent);
70138 + ulong1 = va_arg(ap, unsigned long);
70139 + 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);
70140 + break;
70141 + case GR_RWXMAP:
70142 + file = va_arg(ap, struct file *);
70143 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
70144 + break;
70145 + case GR_RWXMAPVMA:
70146 + vma = va_arg(ap, struct vm_area_struct *);
70147 + if (vma->vm_file)
70148 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
70149 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
70150 + str1 = "<stack>";
70151 + else if (vma->vm_start <= current->mm->brk &&
70152 + vma->vm_end >= current->mm->start_brk)
70153 + str1 = "<heap>";
70154 + else
70155 + str1 = "<anonymous mapping>";
70156 + gr_log_middle_varargs(audit, msg, str1);
70157 + break;
70158 + case GR_PSACCT:
70159 + {
70160 + unsigned int wday, cday;
70161 + __u8 whr, chr;
70162 + __u8 wmin, cmin;
70163 + __u8 wsec, csec;
70164 + char cur_tty[64] = { 0 };
70165 + char parent_tty[64] = { 0 };
70166 +
70167 + task = va_arg(ap, struct task_struct *);
70168 + wday = va_arg(ap, unsigned int);
70169 + cday = va_arg(ap, unsigned int);
70170 + whr = va_arg(ap, int);
70171 + chr = va_arg(ap, int);
70172 + wmin = va_arg(ap, int);
70173 + cmin = va_arg(ap, int);
70174 + wsec = va_arg(ap, int);
70175 + csec = va_arg(ap, int);
70176 + ulong1 = va_arg(ap, unsigned long);
70177 + cred = __task_cred(task);
70178 + pcred = __task_cred(task->real_parent);
70179 +
70180 + 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));
70181 + }
70182 + break;
70183 + default:
70184 + gr_log_middle(audit, msg, ap);
70185 + }
70186 + va_end(ap);
70187 + // these don't need DEFAULTSECARGS printed on the end
70188 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
70189 + gr_log_end(audit, 0);
70190 + else
70191 + gr_log_end(audit, 1);
70192 + END_LOCKS(audit);
70193 +}
70194 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
70195 new file mode 100644
70196 index 0000000..f536303
70197 --- /dev/null
70198 +++ b/grsecurity/grsec_mem.c
70199 @@ -0,0 +1,40 @@
70200 +#include <linux/kernel.h>
70201 +#include <linux/sched.h>
70202 +#include <linux/mm.h>
70203 +#include <linux/mman.h>
70204 +#include <linux/grinternal.h>
70205 +
70206 +void
70207 +gr_handle_ioperm(void)
70208 +{
70209 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
70210 + return;
70211 +}
70212 +
70213 +void
70214 +gr_handle_iopl(void)
70215 +{
70216 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
70217 + return;
70218 +}
70219 +
70220 +void
70221 +gr_handle_mem_readwrite(u64 from, u64 to)
70222 +{
70223 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
70224 + return;
70225 +}
70226 +
70227 +void
70228 +gr_handle_vm86(void)
70229 +{
70230 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
70231 + return;
70232 +}
70233 +
70234 +void
70235 +gr_log_badprocpid(const char *entry)
70236 +{
70237 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
70238 + return;
70239 +}
70240 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
70241 new file mode 100644
70242 index 0000000..2131422
70243 --- /dev/null
70244 +++ b/grsecurity/grsec_mount.c
70245 @@ -0,0 +1,62 @@
70246 +#include <linux/kernel.h>
70247 +#include <linux/sched.h>
70248 +#include <linux/mount.h>
70249 +#include <linux/grsecurity.h>
70250 +#include <linux/grinternal.h>
70251 +
70252 +void
70253 +gr_log_remount(const char *devname, const int retval)
70254 +{
70255 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70256 + if (grsec_enable_mount && (retval >= 0))
70257 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
70258 +#endif
70259 + return;
70260 +}
70261 +
70262 +void
70263 +gr_log_unmount(const char *devname, const int retval)
70264 +{
70265 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70266 + if (grsec_enable_mount && (retval >= 0))
70267 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
70268 +#endif
70269 + return;
70270 +}
70271 +
70272 +void
70273 +gr_log_mount(const char *from, const char *to, const int retval)
70274 +{
70275 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70276 + if (grsec_enable_mount && (retval >= 0))
70277 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
70278 +#endif
70279 + return;
70280 +}
70281 +
70282 +int
70283 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
70284 +{
70285 +#ifdef CONFIG_GRKERNSEC_ROFS
70286 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
70287 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
70288 + return -EPERM;
70289 + } else
70290 + return 0;
70291 +#endif
70292 + return 0;
70293 +}
70294 +
70295 +int
70296 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
70297 +{
70298 +#ifdef CONFIG_GRKERNSEC_ROFS
70299 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
70300 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
70301 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
70302 + return -EPERM;
70303 + } else
70304 + return 0;
70305 +#endif
70306 + return 0;
70307 +}
70308 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
70309 new file mode 100644
70310 index 0000000..6ee9d50
70311 --- /dev/null
70312 +++ b/grsecurity/grsec_pax.c
70313 @@ -0,0 +1,45 @@
70314 +#include <linux/kernel.h>
70315 +#include <linux/sched.h>
70316 +#include <linux/mm.h>
70317 +#include <linux/file.h>
70318 +#include <linux/grinternal.h>
70319 +#include <linux/grsecurity.h>
70320 +
70321 +void
70322 +gr_log_textrel(struct vm_area_struct * vma)
70323 +{
70324 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70325 + if (grsec_enable_log_rwxmaps)
70326 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
70327 +#endif
70328 + return;
70329 +}
70330 +
70331 +void gr_log_ptgnustack(struct file *file)
70332 +{
70333 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70334 + if (grsec_enable_log_rwxmaps)
70335 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
70336 +#endif
70337 + return;
70338 +}
70339 +
70340 +void
70341 +gr_log_rwxmmap(struct file *file)
70342 +{
70343 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70344 + if (grsec_enable_log_rwxmaps)
70345 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
70346 +#endif
70347 + return;
70348 +}
70349 +
70350 +void
70351 +gr_log_rwxmprotect(struct vm_area_struct *vma)
70352 +{
70353 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70354 + if (grsec_enable_log_rwxmaps)
70355 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
70356 +#endif
70357 + return;
70358 +}
70359 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
70360 new file mode 100644
70361 index 0000000..f7f29aa
70362 --- /dev/null
70363 +++ b/grsecurity/grsec_ptrace.c
70364 @@ -0,0 +1,30 @@
70365 +#include <linux/kernel.h>
70366 +#include <linux/sched.h>
70367 +#include <linux/grinternal.h>
70368 +#include <linux/security.h>
70369 +
70370 +void
70371 +gr_audit_ptrace(struct task_struct *task)
70372 +{
70373 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70374 + if (grsec_enable_audit_ptrace)
70375 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
70376 +#endif
70377 + return;
70378 +}
70379 +
70380 +int
70381 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
70382 +{
70383 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70384 + const struct dentry *dentry = file->f_path.dentry;
70385 + const struct vfsmount *mnt = file->f_path.mnt;
70386 +
70387 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
70388 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
70389 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
70390 + return -EACCES;
70391 + }
70392 +#endif
70393 + return 0;
70394 +}
70395 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
70396 new file mode 100644
70397 index 0000000..4e29cc7
70398 --- /dev/null
70399 +++ b/grsecurity/grsec_sig.c
70400 @@ -0,0 +1,246 @@
70401 +#include <linux/kernel.h>
70402 +#include <linux/sched.h>
70403 +#include <linux/fs.h>
70404 +#include <linux/delay.h>
70405 +#include <linux/grsecurity.h>
70406 +#include <linux/grinternal.h>
70407 +#include <linux/hardirq.h>
70408 +
70409 +char *signames[] = {
70410 + [SIGSEGV] = "Segmentation fault",
70411 + [SIGILL] = "Illegal instruction",
70412 + [SIGABRT] = "Abort",
70413 + [SIGBUS] = "Invalid alignment/Bus error"
70414 +};
70415 +
70416 +void
70417 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
70418 +{
70419 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70420 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
70421 + (sig == SIGABRT) || (sig == SIGBUS))) {
70422 + if (task_pid_nr(t) == task_pid_nr(current)) {
70423 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
70424 + } else {
70425 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
70426 + }
70427 + }
70428 +#endif
70429 + return;
70430 +}
70431 +
70432 +int
70433 +gr_handle_signal(const struct task_struct *p, const int sig)
70434 +{
70435 +#ifdef CONFIG_GRKERNSEC
70436 + /* ignore the 0 signal for protected task checks */
70437 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
70438 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
70439 + return -EPERM;
70440 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
70441 + return -EPERM;
70442 + }
70443 +#endif
70444 + return 0;
70445 +}
70446 +
70447 +#ifdef CONFIG_GRKERNSEC
70448 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
70449 +
70450 +int gr_fake_force_sig(int sig, struct task_struct *t)
70451 +{
70452 + unsigned long int flags;
70453 + int ret, blocked, ignored;
70454 + struct k_sigaction *action;
70455 +
70456 + spin_lock_irqsave(&t->sighand->siglock, flags);
70457 + action = &t->sighand->action[sig-1];
70458 + ignored = action->sa.sa_handler == SIG_IGN;
70459 + blocked = sigismember(&t->blocked, sig);
70460 + if (blocked || ignored) {
70461 + action->sa.sa_handler = SIG_DFL;
70462 + if (blocked) {
70463 + sigdelset(&t->blocked, sig);
70464 + recalc_sigpending_and_wake(t);
70465 + }
70466 + }
70467 + if (action->sa.sa_handler == SIG_DFL)
70468 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
70469 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
70470 +
70471 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
70472 +
70473 + return ret;
70474 +}
70475 +#endif
70476 +
70477 +#ifdef CONFIG_GRKERNSEC_BRUTE
70478 +#define GR_USER_BAN_TIME (15 * 60)
70479 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
70480 +
70481 +static int __get_dumpable(unsigned long mm_flags)
70482 +{
70483 + int ret;
70484 +
70485 + ret = mm_flags & MMF_DUMPABLE_MASK;
70486 + return (ret >= 2) ? 2 : ret;
70487 +}
70488 +#endif
70489 +
70490 +void gr_handle_brute_attach(unsigned long mm_flags)
70491 +{
70492 +#ifdef CONFIG_GRKERNSEC_BRUTE
70493 + struct task_struct *p = current;
70494 + kuid_t uid = GLOBAL_ROOT_UID;
70495 + int daemon = 0;
70496 +
70497 + if (!grsec_enable_brute)
70498 + return;
70499 +
70500 + rcu_read_lock();
70501 + read_lock(&tasklist_lock);
70502 + read_lock(&grsec_exec_file_lock);
70503 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
70504 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
70505 + p->real_parent->brute = 1;
70506 + daemon = 1;
70507 + } else {
70508 + const struct cred *cred = __task_cred(p), *cred2;
70509 + struct task_struct *tsk, *tsk2;
70510 +
70511 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
70512 + struct user_struct *user;
70513 +
70514 + uid = cred->uid;
70515 +
70516 + /* this is put upon execution past expiration */
70517 + user = find_user(uid);
70518 + if (user == NULL)
70519 + goto unlock;
70520 + user->suid_banned = 1;
70521 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
70522 + if (user->suid_ban_expires == ~0UL)
70523 + user->suid_ban_expires--;
70524 +
70525 + /* only kill other threads of the same binary, from the same user */
70526 + do_each_thread(tsk2, tsk) {
70527 + cred2 = __task_cred(tsk);
70528 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
70529 + gr_fake_force_sig(SIGKILL, tsk);
70530 + } while_each_thread(tsk2, tsk);
70531 + }
70532 + }
70533 +unlock:
70534 + read_unlock(&grsec_exec_file_lock);
70535 + read_unlock(&tasklist_lock);
70536 + rcu_read_unlock();
70537 +
70538 + if (gr_is_global_nonroot(uid))
70539 + 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);
70540 + else if (daemon)
70541 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
70542 +
70543 +#endif
70544 + return;
70545 +}
70546 +
70547 +void gr_handle_brute_check(void)
70548 +{
70549 +#ifdef CONFIG_GRKERNSEC_BRUTE
70550 + struct task_struct *p = current;
70551 +
70552 + if (unlikely(p->brute)) {
70553 + if (!grsec_enable_brute)
70554 + p->brute = 0;
70555 + else if (time_before(get_seconds(), p->brute_expires))
70556 + msleep(30 * 1000);
70557 + }
70558 +#endif
70559 + return;
70560 +}
70561 +
70562 +void gr_handle_kernel_exploit(void)
70563 +{
70564 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70565 + const struct cred *cred;
70566 + struct task_struct *tsk, *tsk2;
70567 + struct user_struct *user;
70568 + kuid_t uid;
70569 +
70570 + if (in_irq() || in_serving_softirq() || in_nmi())
70571 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
70572 +
70573 + uid = current_uid();
70574 +
70575 + if (gr_is_global_root(uid))
70576 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
70577 + else {
70578 + /* kill all the processes of this user, hold a reference
70579 + to their creds struct, and prevent them from creating
70580 + another process until system reset
70581 + */
70582 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
70583 + GR_GLOBAL_UID(uid));
70584 + /* we intentionally leak this ref */
70585 + user = get_uid(current->cred->user);
70586 + if (user)
70587 + user->kernel_banned = 1;
70588 +
70589 + /* kill all processes of this user */
70590 + read_lock(&tasklist_lock);
70591 + do_each_thread(tsk2, tsk) {
70592 + cred = __task_cred(tsk);
70593 + if (uid_eq(cred->uid, uid))
70594 + gr_fake_force_sig(SIGKILL, tsk);
70595 + } while_each_thread(tsk2, tsk);
70596 + read_unlock(&tasklist_lock);
70597 + }
70598 +#endif
70599 +}
70600 +
70601 +#ifdef CONFIG_GRKERNSEC_BRUTE
70602 +static bool suid_ban_expired(struct user_struct *user)
70603 +{
70604 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
70605 + user->suid_banned = 0;
70606 + user->suid_ban_expires = 0;
70607 + free_uid(user);
70608 + return true;
70609 + }
70610 +
70611 + return false;
70612 +}
70613 +#endif
70614 +
70615 +int gr_process_kernel_exec_ban(void)
70616 +{
70617 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70618 + if (unlikely(current->cred->user->kernel_banned))
70619 + return -EPERM;
70620 +#endif
70621 + return 0;
70622 +}
70623 +
70624 +int gr_process_kernel_setuid_ban(struct user_struct *user)
70625 +{
70626 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70627 + if (unlikely(user->kernel_banned))
70628 + gr_fake_force_sig(SIGKILL, current);
70629 +#endif
70630 + return 0;
70631 +}
70632 +
70633 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
70634 +{
70635 +#ifdef CONFIG_GRKERNSEC_BRUTE
70636 + struct user_struct *user = current->cred->user;
70637 + if (unlikely(user->suid_banned)) {
70638 + if (suid_ban_expired(user))
70639 + return 0;
70640 + /* disallow execution of suid binaries only */
70641 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
70642 + return -EPERM;
70643 + }
70644 +#endif
70645 + return 0;
70646 +}
70647 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
70648 new file mode 100644
70649 index 0000000..4030d57
70650 --- /dev/null
70651 +++ b/grsecurity/grsec_sock.c
70652 @@ -0,0 +1,244 @@
70653 +#include <linux/kernel.h>
70654 +#include <linux/module.h>
70655 +#include <linux/sched.h>
70656 +#include <linux/file.h>
70657 +#include <linux/net.h>
70658 +#include <linux/in.h>
70659 +#include <linux/ip.h>
70660 +#include <net/sock.h>
70661 +#include <net/inet_sock.h>
70662 +#include <linux/grsecurity.h>
70663 +#include <linux/grinternal.h>
70664 +#include <linux/gracl.h>
70665 +
70666 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
70667 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
70668 +
70669 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
70670 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
70671 +
70672 +#ifdef CONFIG_UNIX_MODULE
70673 +EXPORT_SYMBOL(gr_acl_handle_unix);
70674 +EXPORT_SYMBOL(gr_acl_handle_mknod);
70675 +EXPORT_SYMBOL(gr_handle_chroot_unix);
70676 +EXPORT_SYMBOL(gr_handle_create);
70677 +#endif
70678 +
70679 +#ifdef CONFIG_GRKERNSEC
70680 +#define gr_conn_table_size 32749
70681 +struct conn_table_entry {
70682 + struct conn_table_entry *next;
70683 + struct signal_struct *sig;
70684 +};
70685 +
70686 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
70687 +DEFINE_SPINLOCK(gr_conn_table_lock);
70688 +
70689 +extern const char * gr_socktype_to_name(unsigned char type);
70690 +extern const char * gr_proto_to_name(unsigned char proto);
70691 +extern const char * gr_sockfamily_to_name(unsigned char family);
70692 +
70693 +static __inline__ int
70694 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
70695 +{
70696 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
70697 +}
70698 +
70699 +static __inline__ int
70700 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
70701 + __u16 sport, __u16 dport)
70702 +{
70703 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
70704 + sig->gr_sport == sport && sig->gr_dport == dport))
70705 + return 1;
70706 + else
70707 + return 0;
70708 +}
70709 +
70710 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
70711 +{
70712 + struct conn_table_entry **match;
70713 + unsigned int index;
70714 +
70715 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70716 + sig->gr_sport, sig->gr_dport,
70717 + gr_conn_table_size);
70718 +
70719 + newent->sig = sig;
70720 +
70721 + match = &gr_conn_table[index];
70722 + newent->next = *match;
70723 + *match = newent;
70724 +
70725 + return;
70726 +}
70727 +
70728 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
70729 +{
70730 + struct conn_table_entry *match, *last = NULL;
70731 + unsigned int index;
70732 +
70733 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70734 + sig->gr_sport, sig->gr_dport,
70735 + gr_conn_table_size);
70736 +
70737 + match = gr_conn_table[index];
70738 + while (match && !conn_match(match->sig,
70739 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
70740 + sig->gr_dport)) {
70741 + last = match;
70742 + match = match->next;
70743 + }
70744 +
70745 + if (match) {
70746 + if (last)
70747 + last->next = match->next;
70748 + else
70749 + gr_conn_table[index] = NULL;
70750 + kfree(match);
70751 + }
70752 +
70753 + return;
70754 +}
70755 +
70756 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
70757 + __u16 sport, __u16 dport)
70758 +{
70759 + struct conn_table_entry *match;
70760 + unsigned int index;
70761 +
70762 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
70763 +
70764 + match = gr_conn_table[index];
70765 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
70766 + match = match->next;
70767 +
70768 + if (match)
70769 + return match->sig;
70770 + else
70771 + return NULL;
70772 +}
70773 +
70774 +#endif
70775 +
70776 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
70777 +{
70778 +#ifdef CONFIG_GRKERNSEC
70779 + struct signal_struct *sig = task->signal;
70780 + struct conn_table_entry *newent;
70781 +
70782 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
70783 + if (newent == NULL)
70784 + return;
70785 + /* no bh lock needed since we are called with bh disabled */
70786 + spin_lock(&gr_conn_table_lock);
70787 + gr_del_task_from_ip_table_nolock(sig);
70788 + sig->gr_saddr = inet->inet_rcv_saddr;
70789 + sig->gr_daddr = inet->inet_daddr;
70790 + sig->gr_sport = inet->inet_sport;
70791 + sig->gr_dport = inet->inet_dport;
70792 + gr_add_to_task_ip_table_nolock(sig, newent);
70793 + spin_unlock(&gr_conn_table_lock);
70794 +#endif
70795 + return;
70796 +}
70797 +
70798 +void gr_del_task_from_ip_table(struct task_struct *task)
70799 +{
70800 +#ifdef CONFIG_GRKERNSEC
70801 + spin_lock_bh(&gr_conn_table_lock);
70802 + gr_del_task_from_ip_table_nolock(task->signal);
70803 + spin_unlock_bh(&gr_conn_table_lock);
70804 +#endif
70805 + return;
70806 +}
70807 +
70808 +void
70809 +gr_attach_curr_ip(const struct sock *sk)
70810 +{
70811 +#ifdef CONFIG_GRKERNSEC
70812 + struct signal_struct *p, *set;
70813 + const struct inet_sock *inet = inet_sk(sk);
70814 +
70815 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
70816 + return;
70817 +
70818 + set = current->signal;
70819 +
70820 + spin_lock_bh(&gr_conn_table_lock);
70821 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
70822 + inet->inet_dport, inet->inet_sport);
70823 + if (unlikely(p != NULL)) {
70824 + set->curr_ip = p->curr_ip;
70825 + set->used_accept = 1;
70826 + gr_del_task_from_ip_table_nolock(p);
70827 + spin_unlock_bh(&gr_conn_table_lock);
70828 + return;
70829 + }
70830 + spin_unlock_bh(&gr_conn_table_lock);
70831 +
70832 + set->curr_ip = inet->inet_daddr;
70833 + set->used_accept = 1;
70834 +#endif
70835 + return;
70836 +}
70837 +
70838 +int
70839 +gr_handle_sock_all(const int family, const int type, const int protocol)
70840 +{
70841 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70842 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
70843 + (family != AF_UNIX)) {
70844 + if (family == AF_INET)
70845 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
70846 + else
70847 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
70848 + return -EACCES;
70849 + }
70850 +#endif
70851 + return 0;
70852 +}
70853 +
70854 +int
70855 +gr_handle_sock_server(const struct sockaddr *sck)
70856 +{
70857 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70858 + if (grsec_enable_socket_server &&
70859 + in_group_p(grsec_socket_server_gid) &&
70860 + sck && (sck->sa_family != AF_UNIX) &&
70861 + (sck->sa_family != AF_LOCAL)) {
70862 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70863 + return -EACCES;
70864 + }
70865 +#endif
70866 + return 0;
70867 +}
70868 +
70869 +int
70870 +gr_handle_sock_server_other(const struct sock *sck)
70871 +{
70872 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70873 + if (grsec_enable_socket_server &&
70874 + in_group_p(grsec_socket_server_gid) &&
70875 + sck && (sck->sk_family != AF_UNIX) &&
70876 + (sck->sk_family != AF_LOCAL)) {
70877 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70878 + return -EACCES;
70879 + }
70880 +#endif
70881 + return 0;
70882 +}
70883 +
70884 +int
70885 +gr_handle_sock_client(const struct sockaddr *sck)
70886 +{
70887 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70888 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
70889 + sck && (sck->sa_family != AF_UNIX) &&
70890 + (sck->sa_family != AF_LOCAL)) {
70891 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
70892 + return -EACCES;
70893 + }
70894 +#endif
70895 + return 0;
70896 +}
70897 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
70898 new file mode 100644
70899 index 0000000..8159888
70900 --- /dev/null
70901 +++ b/grsecurity/grsec_sysctl.c
70902 @@ -0,0 +1,479 @@
70903 +#include <linux/kernel.h>
70904 +#include <linux/sched.h>
70905 +#include <linux/sysctl.h>
70906 +#include <linux/grsecurity.h>
70907 +#include <linux/grinternal.h>
70908 +
70909 +int
70910 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
70911 +{
70912 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70913 + if (dirname == NULL || name == NULL)
70914 + return 0;
70915 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
70916 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
70917 + return -EACCES;
70918 + }
70919 +#endif
70920 + return 0;
70921 +}
70922 +
70923 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
70924 +static int __maybe_unused __read_only one = 1;
70925 +#endif
70926 +
70927 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
70928 + defined(CONFIG_GRKERNSEC_DENYUSB)
70929 +struct ctl_table grsecurity_table[] = {
70930 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70931 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
70932 +#ifdef CONFIG_GRKERNSEC_IO
70933 + {
70934 + .procname = "disable_priv_io",
70935 + .data = &grsec_disable_privio,
70936 + .maxlen = sizeof(int),
70937 + .mode = 0600,
70938 + .proc_handler = &proc_dointvec,
70939 + },
70940 +#endif
70941 +#endif
70942 +#ifdef CONFIG_GRKERNSEC_LINK
70943 + {
70944 + .procname = "linking_restrictions",
70945 + .data = &grsec_enable_link,
70946 + .maxlen = sizeof(int),
70947 + .mode = 0600,
70948 + .proc_handler = &proc_dointvec,
70949 + },
70950 +#endif
70951 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70952 + {
70953 + .procname = "enforce_symlinksifowner",
70954 + .data = &grsec_enable_symlinkown,
70955 + .maxlen = sizeof(int),
70956 + .mode = 0600,
70957 + .proc_handler = &proc_dointvec,
70958 + },
70959 + {
70960 + .procname = "symlinkown_gid",
70961 + .data = &grsec_symlinkown_gid,
70962 + .maxlen = sizeof(int),
70963 + .mode = 0600,
70964 + .proc_handler = &proc_dointvec,
70965 + },
70966 +#endif
70967 +#ifdef CONFIG_GRKERNSEC_BRUTE
70968 + {
70969 + .procname = "deter_bruteforce",
70970 + .data = &grsec_enable_brute,
70971 + .maxlen = sizeof(int),
70972 + .mode = 0600,
70973 + .proc_handler = &proc_dointvec,
70974 + },
70975 +#endif
70976 +#ifdef CONFIG_GRKERNSEC_FIFO
70977 + {
70978 + .procname = "fifo_restrictions",
70979 + .data = &grsec_enable_fifo,
70980 + .maxlen = sizeof(int),
70981 + .mode = 0600,
70982 + .proc_handler = &proc_dointvec,
70983 + },
70984 +#endif
70985 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70986 + {
70987 + .procname = "ptrace_readexec",
70988 + .data = &grsec_enable_ptrace_readexec,
70989 + .maxlen = sizeof(int),
70990 + .mode = 0600,
70991 + .proc_handler = &proc_dointvec,
70992 + },
70993 +#endif
70994 +#ifdef CONFIG_GRKERNSEC_SETXID
70995 + {
70996 + .procname = "consistent_setxid",
70997 + .data = &grsec_enable_setxid,
70998 + .maxlen = sizeof(int),
70999 + .mode = 0600,
71000 + .proc_handler = &proc_dointvec,
71001 + },
71002 +#endif
71003 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71004 + {
71005 + .procname = "ip_blackhole",
71006 + .data = &grsec_enable_blackhole,
71007 + .maxlen = sizeof(int),
71008 + .mode = 0600,
71009 + .proc_handler = &proc_dointvec,
71010 + },
71011 + {
71012 + .procname = "lastack_retries",
71013 + .data = &grsec_lastack_retries,
71014 + .maxlen = sizeof(int),
71015 + .mode = 0600,
71016 + .proc_handler = &proc_dointvec,
71017 + },
71018 +#endif
71019 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71020 + {
71021 + .procname = "exec_logging",
71022 + .data = &grsec_enable_execlog,
71023 + .maxlen = sizeof(int),
71024 + .mode = 0600,
71025 + .proc_handler = &proc_dointvec,
71026 + },
71027 +#endif
71028 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71029 + {
71030 + .procname = "rwxmap_logging",
71031 + .data = &grsec_enable_log_rwxmaps,
71032 + .maxlen = sizeof(int),
71033 + .mode = 0600,
71034 + .proc_handler = &proc_dointvec,
71035 + },
71036 +#endif
71037 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71038 + {
71039 + .procname = "signal_logging",
71040 + .data = &grsec_enable_signal,
71041 + .maxlen = sizeof(int),
71042 + .mode = 0600,
71043 + .proc_handler = &proc_dointvec,
71044 + },
71045 +#endif
71046 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71047 + {
71048 + .procname = "forkfail_logging",
71049 + .data = &grsec_enable_forkfail,
71050 + .maxlen = sizeof(int),
71051 + .mode = 0600,
71052 + .proc_handler = &proc_dointvec,
71053 + },
71054 +#endif
71055 +#ifdef CONFIG_GRKERNSEC_TIME
71056 + {
71057 + .procname = "timechange_logging",
71058 + .data = &grsec_enable_time,
71059 + .maxlen = sizeof(int),
71060 + .mode = 0600,
71061 + .proc_handler = &proc_dointvec,
71062 + },
71063 +#endif
71064 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71065 + {
71066 + .procname = "chroot_deny_shmat",
71067 + .data = &grsec_enable_chroot_shmat,
71068 + .maxlen = sizeof(int),
71069 + .mode = 0600,
71070 + .proc_handler = &proc_dointvec,
71071 + },
71072 +#endif
71073 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71074 + {
71075 + .procname = "chroot_deny_unix",
71076 + .data = &grsec_enable_chroot_unix,
71077 + .maxlen = sizeof(int),
71078 + .mode = 0600,
71079 + .proc_handler = &proc_dointvec,
71080 + },
71081 +#endif
71082 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71083 + {
71084 + .procname = "chroot_deny_mount",
71085 + .data = &grsec_enable_chroot_mount,
71086 + .maxlen = sizeof(int),
71087 + .mode = 0600,
71088 + .proc_handler = &proc_dointvec,
71089 + },
71090 +#endif
71091 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71092 + {
71093 + .procname = "chroot_deny_fchdir",
71094 + .data = &grsec_enable_chroot_fchdir,
71095 + .maxlen = sizeof(int),
71096 + .mode = 0600,
71097 + .proc_handler = &proc_dointvec,
71098 + },
71099 +#endif
71100 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71101 + {
71102 + .procname = "chroot_deny_chroot",
71103 + .data = &grsec_enable_chroot_double,
71104 + .maxlen = sizeof(int),
71105 + .mode = 0600,
71106 + .proc_handler = &proc_dointvec,
71107 + },
71108 +#endif
71109 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71110 + {
71111 + .procname = "chroot_deny_pivot",
71112 + .data = &grsec_enable_chroot_pivot,
71113 + .maxlen = sizeof(int),
71114 + .mode = 0600,
71115 + .proc_handler = &proc_dointvec,
71116 + },
71117 +#endif
71118 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71119 + {
71120 + .procname = "chroot_enforce_chdir",
71121 + .data = &grsec_enable_chroot_chdir,
71122 + .maxlen = sizeof(int),
71123 + .mode = 0600,
71124 + .proc_handler = &proc_dointvec,
71125 + },
71126 +#endif
71127 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71128 + {
71129 + .procname = "chroot_deny_chmod",
71130 + .data = &grsec_enable_chroot_chmod,
71131 + .maxlen = sizeof(int),
71132 + .mode = 0600,
71133 + .proc_handler = &proc_dointvec,
71134 + },
71135 +#endif
71136 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71137 + {
71138 + .procname = "chroot_deny_mknod",
71139 + .data = &grsec_enable_chroot_mknod,
71140 + .maxlen = sizeof(int),
71141 + .mode = 0600,
71142 + .proc_handler = &proc_dointvec,
71143 + },
71144 +#endif
71145 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71146 + {
71147 + .procname = "chroot_restrict_nice",
71148 + .data = &grsec_enable_chroot_nice,
71149 + .maxlen = sizeof(int),
71150 + .mode = 0600,
71151 + .proc_handler = &proc_dointvec,
71152 + },
71153 +#endif
71154 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71155 + {
71156 + .procname = "chroot_execlog",
71157 + .data = &grsec_enable_chroot_execlog,
71158 + .maxlen = sizeof(int),
71159 + .mode = 0600,
71160 + .proc_handler = &proc_dointvec,
71161 + },
71162 +#endif
71163 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71164 + {
71165 + .procname = "chroot_caps",
71166 + .data = &grsec_enable_chroot_caps,
71167 + .maxlen = sizeof(int),
71168 + .mode = 0600,
71169 + .proc_handler = &proc_dointvec,
71170 + },
71171 +#endif
71172 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71173 + {
71174 + .procname = "chroot_deny_sysctl",
71175 + .data = &grsec_enable_chroot_sysctl,
71176 + .maxlen = sizeof(int),
71177 + .mode = 0600,
71178 + .proc_handler = &proc_dointvec,
71179 + },
71180 +#endif
71181 +#ifdef CONFIG_GRKERNSEC_TPE
71182 + {
71183 + .procname = "tpe",
71184 + .data = &grsec_enable_tpe,
71185 + .maxlen = sizeof(int),
71186 + .mode = 0600,
71187 + .proc_handler = &proc_dointvec,
71188 + },
71189 + {
71190 + .procname = "tpe_gid",
71191 + .data = &grsec_tpe_gid,
71192 + .maxlen = sizeof(int),
71193 + .mode = 0600,
71194 + .proc_handler = &proc_dointvec,
71195 + },
71196 +#endif
71197 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71198 + {
71199 + .procname = "tpe_invert",
71200 + .data = &grsec_enable_tpe_invert,
71201 + .maxlen = sizeof(int),
71202 + .mode = 0600,
71203 + .proc_handler = &proc_dointvec,
71204 + },
71205 +#endif
71206 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71207 + {
71208 + .procname = "tpe_restrict_all",
71209 + .data = &grsec_enable_tpe_all,
71210 + .maxlen = sizeof(int),
71211 + .mode = 0600,
71212 + .proc_handler = &proc_dointvec,
71213 + },
71214 +#endif
71215 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71216 + {
71217 + .procname = "socket_all",
71218 + .data = &grsec_enable_socket_all,
71219 + .maxlen = sizeof(int),
71220 + .mode = 0600,
71221 + .proc_handler = &proc_dointvec,
71222 + },
71223 + {
71224 + .procname = "socket_all_gid",
71225 + .data = &grsec_socket_all_gid,
71226 + .maxlen = sizeof(int),
71227 + .mode = 0600,
71228 + .proc_handler = &proc_dointvec,
71229 + },
71230 +#endif
71231 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71232 + {
71233 + .procname = "socket_client",
71234 + .data = &grsec_enable_socket_client,
71235 + .maxlen = sizeof(int),
71236 + .mode = 0600,
71237 + .proc_handler = &proc_dointvec,
71238 + },
71239 + {
71240 + .procname = "socket_client_gid",
71241 + .data = &grsec_socket_client_gid,
71242 + .maxlen = sizeof(int),
71243 + .mode = 0600,
71244 + .proc_handler = &proc_dointvec,
71245 + },
71246 +#endif
71247 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71248 + {
71249 + .procname = "socket_server",
71250 + .data = &grsec_enable_socket_server,
71251 + .maxlen = sizeof(int),
71252 + .mode = 0600,
71253 + .proc_handler = &proc_dointvec,
71254 + },
71255 + {
71256 + .procname = "socket_server_gid",
71257 + .data = &grsec_socket_server_gid,
71258 + .maxlen = sizeof(int),
71259 + .mode = 0600,
71260 + .proc_handler = &proc_dointvec,
71261 + },
71262 +#endif
71263 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71264 + {
71265 + .procname = "audit_group",
71266 + .data = &grsec_enable_group,
71267 + .maxlen = sizeof(int),
71268 + .mode = 0600,
71269 + .proc_handler = &proc_dointvec,
71270 + },
71271 + {
71272 + .procname = "audit_gid",
71273 + .data = &grsec_audit_gid,
71274 + .maxlen = sizeof(int),
71275 + .mode = 0600,
71276 + .proc_handler = &proc_dointvec,
71277 + },
71278 +#endif
71279 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71280 + {
71281 + .procname = "audit_chdir",
71282 + .data = &grsec_enable_chdir,
71283 + .maxlen = sizeof(int),
71284 + .mode = 0600,
71285 + .proc_handler = &proc_dointvec,
71286 + },
71287 +#endif
71288 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71289 + {
71290 + .procname = "audit_mount",
71291 + .data = &grsec_enable_mount,
71292 + .maxlen = sizeof(int),
71293 + .mode = 0600,
71294 + .proc_handler = &proc_dointvec,
71295 + },
71296 +#endif
71297 +#ifdef CONFIG_GRKERNSEC_DMESG
71298 + {
71299 + .procname = "dmesg",
71300 + .data = &grsec_enable_dmesg,
71301 + .maxlen = sizeof(int),
71302 + .mode = 0600,
71303 + .proc_handler = &proc_dointvec,
71304 + },
71305 +#endif
71306 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71307 + {
71308 + .procname = "chroot_findtask",
71309 + .data = &grsec_enable_chroot_findtask,
71310 + .maxlen = sizeof(int),
71311 + .mode = 0600,
71312 + .proc_handler = &proc_dointvec,
71313 + },
71314 +#endif
71315 +#ifdef CONFIG_GRKERNSEC_RESLOG
71316 + {
71317 + .procname = "resource_logging",
71318 + .data = &grsec_resource_logging,
71319 + .maxlen = sizeof(int),
71320 + .mode = 0600,
71321 + .proc_handler = &proc_dointvec,
71322 + },
71323 +#endif
71324 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71325 + {
71326 + .procname = "audit_ptrace",
71327 + .data = &grsec_enable_audit_ptrace,
71328 + .maxlen = sizeof(int),
71329 + .mode = 0600,
71330 + .proc_handler = &proc_dointvec,
71331 + },
71332 +#endif
71333 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71334 + {
71335 + .procname = "harden_ptrace",
71336 + .data = &grsec_enable_harden_ptrace,
71337 + .maxlen = sizeof(int),
71338 + .mode = 0600,
71339 + .proc_handler = &proc_dointvec,
71340 + },
71341 +#endif
71342 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71343 + {
71344 + .procname = "harden_ipc",
71345 + .data = &grsec_enable_harden_ipc,
71346 + .maxlen = sizeof(int),
71347 + .mode = 0600,
71348 + .proc_handler = &proc_dointvec,
71349 + },
71350 +#endif
71351 + {
71352 + .procname = "grsec_lock",
71353 + .data = &grsec_lock,
71354 + .maxlen = sizeof(int),
71355 + .mode = 0600,
71356 + .proc_handler = &proc_dointvec,
71357 + },
71358 +#endif
71359 +#ifdef CONFIG_GRKERNSEC_ROFS
71360 + {
71361 + .procname = "romount_protect",
71362 + .data = &grsec_enable_rofs,
71363 + .maxlen = sizeof(int),
71364 + .mode = 0600,
71365 + .proc_handler = &proc_dointvec_minmax,
71366 + .extra1 = &one,
71367 + .extra2 = &one,
71368 + },
71369 +#endif
71370 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
71371 + {
71372 + .procname = "deny_new_usb",
71373 + .data = &grsec_deny_new_usb,
71374 + .maxlen = sizeof(int),
71375 + .mode = 0600,
71376 + .proc_handler = &proc_dointvec,
71377 + },
71378 +#endif
71379 + { }
71380 +};
71381 +#endif
71382 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
71383 new file mode 100644
71384 index 0000000..0dc13c3
71385 --- /dev/null
71386 +++ b/grsecurity/grsec_time.c
71387 @@ -0,0 +1,16 @@
71388 +#include <linux/kernel.h>
71389 +#include <linux/sched.h>
71390 +#include <linux/grinternal.h>
71391 +#include <linux/module.h>
71392 +
71393 +void
71394 +gr_log_timechange(void)
71395 +{
71396 +#ifdef CONFIG_GRKERNSEC_TIME
71397 + if (grsec_enable_time)
71398 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
71399 +#endif
71400 + return;
71401 +}
71402 +
71403 +EXPORT_SYMBOL(gr_log_timechange);
71404 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
71405 new file mode 100644
71406 index 0000000..ee57dcf
71407 --- /dev/null
71408 +++ b/grsecurity/grsec_tpe.c
71409 @@ -0,0 +1,73 @@
71410 +#include <linux/kernel.h>
71411 +#include <linux/sched.h>
71412 +#include <linux/file.h>
71413 +#include <linux/fs.h>
71414 +#include <linux/grinternal.h>
71415 +
71416 +extern int gr_acl_tpe_check(void);
71417 +
71418 +int
71419 +gr_tpe_allow(const struct file *file)
71420 +{
71421 +#ifdef CONFIG_GRKERNSEC
71422 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
71423 + const struct cred *cred = current_cred();
71424 + char *msg = NULL;
71425 + char *msg2 = NULL;
71426 +
71427 + // never restrict root
71428 + if (gr_is_global_root(cred->uid))
71429 + return 1;
71430 +
71431 + if (grsec_enable_tpe) {
71432 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71433 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
71434 + msg = "not being in trusted group";
71435 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
71436 + msg = "being in untrusted group";
71437 +#else
71438 + if (in_group_p(grsec_tpe_gid))
71439 + msg = "being in untrusted group";
71440 +#endif
71441 + }
71442 + if (!msg && gr_acl_tpe_check())
71443 + msg = "being in untrusted role";
71444 +
71445 + // not in any affected group/role
71446 + if (!msg)
71447 + goto next_check;
71448 +
71449 + if (gr_is_global_nonroot(inode->i_uid))
71450 + msg2 = "file in non-root-owned directory";
71451 + else if (inode->i_mode & S_IWOTH)
71452 + msg2 = "file in world-writable directory";
71453 + else if (inode->i_mode & S_IWGRP)
71454 + msg2 = "file in group-writable directory";
71455 +
71456 + if (msg && msg2) {
71457 + char fullmsg[70] = {0};
71458 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
71459 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
71460 + return 0;
71461 + }
71462 + msg = NULL;
71463 +next_check:
71464 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71465 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
71466 + return 1;
71467 +
71468 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
71469 + msg = "directory not owned by user";
71470 + else if (inode->i_mode & S_IWOTH)
71471 + msg = "file in world-writable directory";
71472 + else if (inode->i_mode & S_IWGRP)
71473 + msg = "file in group-writable directory";
71474 +
71475 + if (msg) {
71476 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
71477 + return 0;
71478 + }
71479 +#endif
71480 +#endif
71481 + return 1;
71482 +}
71483 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
71484 new file mode 100644
71485 index 0000000..ae02d8e
71486 --- /dev/null
71487 +++ b/grsecurity/grsec_usb.c
71488 @@ -0,0 +1,15 @@
71489 +#include <linux/kernel.h>
71490 +#include <linux/grinternal.h>
71491 +#include <linux/module.h>
71492 +
71493 +int gr_handle_new_usb(void)
71494 +{
71495 +#ifdef CONFIG_GRKERNSEC_DENYUSB
71496 + if (grsec_deny_new_usb) {
71497 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
71498 + return 1;
71499 + }
71500 +#endif
71501 + return 0;
71502 +}
71503 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
71504 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
71505 new file mode 100644
71506 index 0000000..9f7b1ac
71507 --- /dev/null
71508 +++ b/grsecurity/grsum.c
71509 @@ -0,0 +1,61 @@
71510 +#include <linux/err.h>
71511 +#include <linux/kernel.h>
71512 +#include <linux/sched.h>
71513 +#include <linux/mm.h>
71514 +#include <linux/scatterlist.h>
71515 +#include <linux/crypto.h>
71516 +#include <linux/gracl.h>
71517 +
71518 +
71519 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
71520 +#error "crypto and sha256 must be built into the kernel"
71521 +#endif
71522 +
71523 +int
71524 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
71525 +{
71526 + char *p;
71527 + struct crypto_hash *tfm;
71528 + struct hash_desc desc;
71529 + struct scatterlist sg;
71530 + unsigned char temp_sum[GR_SHA_LEN];
71531 + volatile int retval = 0;
71532 + volatile int dummy = 0;
71533 + unsigned int i;
71534 +
71535 + sg_init_table(&sg, 1);
71536 +
71537 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
71538 + if (IS_ERR(tfm)) {
71539 + /* should never happen, since sha256 should be built in */
71540 + return 1;
71541 + }
71542 +
71543 + desc.tfm = tfm;
71544 + desc.flags = 0;
71545 +
71546 + crypto_hash_init(&desc);
71547 +
71548 + p = salt;
71549 + sg_set_buf(&sg, p, GR_SALT_LEN);
71550 + crypto_hash_update(&desc, &sg, sg.length);
71551 +
71552 + p = entry->pw;
71553 + sg_set_buf(&sg, p, strlen(p));
71554 +
71555 + crypto_hash_update(&desc, &sg, sg.length);
71556 +
71557 + crypto_hash_final(&desc, temp_sum);
71558 +
71559 + memset(entry->pw, 0, GR_PW_LEN);
71560 +
71561 + for (i = 0; i < GR_SHA_LEN; i++)
71562 + if (sum[i] != temp_sum[i])
71563 + retval = 1;
71564 + else
71565 + dummy = 1; // waste a cycle
71566 +
71567 + crypto_free_hash(tfm);
71568 +
71569 + return retval;
71570 +}
71571 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
71572 index 77ff547..181834f 100644
71573 --- a/include/asm-generic/4level-fixup.h
71574 +++ b/include/asm-generic/4level-fixup.h
71575 @@ -13,8 +13,10 @@
71576 #define pmd_alloc(mm, pud, address) \
71577 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
71578 NULL: pmd_offset(pud, address))
71579 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
71580
71581 #define pud_alloc(mm, pgd, address) (pgd)
71582 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
71583 #define pud_offset(pgd, start) (pgd)
71584 #define pud_none(pud) 0
71585 #define pud_bad(pud) 0
71586 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
71587 index b7babf0..04ad282 100644
71588 --- a/include/asm-generic/atomic-long.h
71589 +++ b/include/asm-generic/atomic-long.h
71590 @@ -22,6 +22,12 @@
71591
71592 typedef atomic64_t atomic_long_t;
71593
71594 +#ifdef CONFIG_PAX_REFCOUNT
71595 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
71596 +#else
71597 +typedef atomic64_t atomic_long_unchecked_t;
71598 +#endif
71599 +
71600 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
71601
71602 static inline long atomic_long_read(atomic_long_t *l)
71603 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71604 return (long)atomic64_read(v);
71605 }
71606
71607 +#ifdef CONFIG_PAX_REFCOUNT
71608 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71609 +{
71610 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71611 +
71612 + return (long)atomic64_read_unchecked(v);
71613 +}
71614 +#endif
71615 +
71616 static inline void atomic_long_set(atomic_long_t *l, long i)
71617 {
71618 atomic64_t *v = (atomic64_t *)l;
71619 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71620 atomic64_set(v, i);
71621 }
71622
71623 +#ifdef CONFIG_PAX_REFCOUNT
71624 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71625 +{
71626 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71627 +
71628 + atomic64_set_unchecked(v, i);
71629 +}
71630 +#endif
71631 +
71632 static inline void atomic_long_inc(atomic_long_t *l)
71633 {
71634 atomic64_t *v = (atomic64_t *)l;
71635 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71636 atomic64_inc(v);
71637 }
71638
71639 +#ifdef CONFIG_PAX_REFCOUNT
71640 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71641 +{
71642 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71643 +
71644 + atomic64_inc_unchecked(v);
71645 +}
71646 +#endif
71647 +
71648 static inline void atomic_long_dec(atomic_long_t *l)
71649 {
71650 atomic64_t *v = (atomic64_t *)l;
71651 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71652 atomic64_dec(v);
71653 }
71654
71655 +#ifdef CONFIG_PAX_REFCOUNT
71656 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71657 +{
71658 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71659 +
71660 + atomic64_dec_unchecked(v);
71661 +}
71662 +#endif
71663 +
71664 static inline void atomic_long_add(long i, atomic_long_t *l)
71665 {
71666 atomic64_t *v = (atomic64_t *)l;
71667 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71668 atomic64_add(i, v);
71669 }
71670
71671 +#ifdef CONFIG_PAX_REFCOUNT
71672 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71673 +{
71674 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71675 +
71676 + atomic64_add_unchecked(i, v);
71677 +}
71678 +#endif
71679 +
71680 static inline void atomic_long_sub(long i, atomic_long_t *l)
71681 {
71682 atomic64_t *v = (atomic64_t *)l;
71683 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71684 atomic64_sub(i, v);
71685 }
71686
71687 +#ifdef CONFIG_PAX_REFCOUNT
71688 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71689 +{
71690 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71691 +
71692 + atomic64_sub_unchecked(i, v);
71693 +}
71694 +#endif
71695 +
71696 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71697 {
71698 atomic64_t *v = (atomic64_t *)l;
71699 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71700 return (long)atomic64_add_return(i, v);
71701 }
71702
71703 +#ifdef CONFIG_PAX_REFCOUNT
71704 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71705 +{
71706 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71707 +
71708 + return (long)atomic64_add_return_unchecked(i, v);
71709 +}
71710 +#endif
71711 +
71712 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71713 {
71714 atomic64_t *v = (atomic64_t *)l;
71715 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71716 return (long)atomic64_inc_return(v);
71717 }
71718
71719 +#ifdef CONFIG_PAX_REFCOUNT
71720 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71721 +{
71722 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71723 +
71724 + return (long)atomic64_inc_return_unchecked(v);
71725 +}
71726 +#endif
71727 +
71728 static inline long atomic_long_dec_return(atomic_long_t *l)
71729 {
71730 atomic64_t *v = (atomic64_t *)l;
71731 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71732
71733 typedef atomic_t atomic_long_t;
71734
71735 +#ifdef CONFIG_PAX_REFCOUNT
71736 +typedef atomic_unchecked_t atomic_long_unchecked_t;
71737 +#else
71738 +typedef atomic_t atomic_long_unchecked_t;
71739 +#endif
71740 +
71741 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
71742 static inline long atomic_long_read(atomic_long_t *l)
71743 {
71744 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71745 return (long)atomic_read(v);
71746 }
71747
71748 +#ifdef CONFIG_PAX_REFCOUNT
71749 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71750 +{
71751 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71752 +
71753 + return (long)atomic_read_unchecked(v);
71754 +}
71755 +#endif
71756 +
71757 static inline void atomic_long_set(atomic_long_t *l, long i)
71758 {
71759 atomic_t *v = (atomic_t *)l;
71760 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71761 atomic_set(v, i);
71762 }
71763
71764 +#ifdef CONFIG_PAX_REFCOUNT
71765 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71766 +{
71767 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71768 +
71769 + atomic_set_unchecked(v, i);
71770 +}
71771 +#endif
71772 +
71773 static inline void atomic_long_inc(atomic_long_t *l)
71774 {
71775 atomic_t *v = (atomic_t *)l;
71776 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71777 atomic_inc(v);
71778 }
71779
71780 +#ifdef CONFIG_PAX_REFCOUNT
71781 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71782 +{
71783 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71784 +
71785 + atomic_inc_unchecked(v);
71786 +}
71787 +#endif
71788 +
71789 static inline void atomic_long_dec(atomic_long_t *l)
71790 {
71791 atomic_t *v = (atomic_t *)l;
71792 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71793 atomic_dec(v);
71794 }
71795
71796 +#ifdef CONFIG_PAX_REFCOUNT
71797 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71798 +{
71799 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71800 +
71801 + atomic_dec_unchecked(v);
71802 +}
71803 +#endif
71804 +
71805 static inline void atomic_long_add(long i, atomic_long_t *l)
71806 {
71807 atomic_t *v = (atomic_t *)l;
71808 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71809 atomic_add(i, v);
71810 }
71811
71812 +#ifdef CONFIG_PAX_REFCOUNT
71813 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71814 +{
71815 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71816 +
71817 + atomic_add_unchecked(i, v);
71818 +}
71819 +#endif
71820 +
71821 static inline void atomic_long_sub(long i, atomic_long_t *l)
71822 {
71823 atomic_t *v = (atomic_t *)l;
71824 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71825 atomic_sub(i, v);
71826 }
71827
71828 +#ifdef CONFIG_PAX_REFCOUNT
71829 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71830 +{
71831 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71832 +
71833 + atomic_sub_unchecked(i, v);
71834 +}
71835 +#endif
71836 +
71837 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71838 {
71839 atomic_t *v = (atomic_t *)l;
71840 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71841 return (long)atomic_add_return(i, v);
71842 }
71843
71844 +#ifdef CONFIG_PAX_REFCOUNT
71845 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71846 +{
71847 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71848 +
71849 + return (long)atomic_add_return_unchecked(i, v);
71850 +}
71851 +
71852 +#endif
71853 +
71854 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71855 {
71856 atomic_t *v = (atomic_t *)l;
71857 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71858 return (long)atomic_inc_return(v);
71859 }
71860
71861 +#ifdef CONFIG_PAX_REFCOUNT
71862 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71863 +{
71864 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71865 +
71866 + return (long)atomic_inc_return_unchecked(v);
71867 +}
71868 +#endif
71869 +
71870 static inline long atomic_long_dec_return(atomic_long_t *l)
71871 {
71872 atomic_t *v = (atomic_t *)l;
71873 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71874
71875 #endif /* BITS_PER_LONG == 64 */
71876
71877 +#ifdef CONFIG_PAX_REFCOUNT
71878 +static inline void pax_refcount_needs_these_functions(void)
71879 +{
71880 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
71881 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
71882 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
71883 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
71884 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
71885 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
71886 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
71887 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
71888 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
71889 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
71890 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
71891 +#ifdef CONFIG_X86
71892 + atomic_clear_mask_unchecked(0, NULL);
71893 + atomic_set_mask_unchecked(0, NULL);
71894 +#endif
71895 +
71896 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
71897 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
71898 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
71899 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
71900 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
71901 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
71902 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
71903 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
71904 +}
71905 +#else
71906 +#define atomic_read_unchecked(v) atomic_read(v)
71907 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
71908 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
71909 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
71910 +#define atomic_inc_unchecked(v) atomic_inc(v)
71911 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
71912 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
71913 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
71914 +#define atomic_dec_unchecked(v) atomic_dec(v)
71915 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
71916 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
71917 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
71918 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
71919 +
71920 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
71921 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
71922 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
71923 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
71924 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
71925 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
71926 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
71927 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
71928 +#endif
71929 +
71930 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
71931 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
71932 index 33bd2de..f31bff97 100644
71933 --- a/include/asm-generic/atomic.h
71934 +++ b/include/asm-generic/atomic.h
71935 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
71936 * Atomically clears the bits set in @mask from @v
71937 */
71938 #ifndef atomic_clear_mask
71939 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
71940 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
71941 {
71942 unsigned long flags;
71943
71944 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
71945 index b18ce4f..2ee2843 100644
71946 --- a/include/asm-generic/atomic64.h
71947 +++ b/include/asm-generic/atomic64.h
71948 @@ -16,6 +16,8 @@ typedef struct {
71949 long long counter;
71950 } atomic64_t;
71951
71952 +typedef atomic64_t atomic64_unchecked_t;
71953 +
71954 #define ATOMIC64_INIT(i) { (i) }
71955
71956 extern long long atomic64_read(const atomic64_t *v);
71957 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
71958 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
71959 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
71960
71961 +#define atomic64_read_unchecked(v) atomic64_read(v)
71962 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
71963 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
71964 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
71965 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
71966 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
71967 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
71968 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
71969 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
71970 +
71971 #endif /* _ASM_GENERIC_ATOMIC64_H */
71972 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
71973 index 1bfcfe5..e04c5c9 100644
71974 --- a/include/asm-generic/cache.h
71975 +++ b/include/asm-generic/cache.h
71976 @@ -6,7 +6,7 @@
71977 * cache lines need to provide their own cache.h.
71978 */
71979
71980 -#define L1_CACHE_SHIFT 5
71981 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
71982 +#define L1_CACHE_SHIFT 5UL
71983 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
71984
71985 #endif /* __ASM_GENERIC_CACHE_H */
71986 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
71987 index 0d68a1e..b74a761 100644
71988 --- a/include/asm-generic/emergency-restart.h
71989 +++ b/include/asm-generic/emergency-restart.h
71990 @@ -1,7 +1,7 @@
71991 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
71992 #define _ASM_GENERIC_EMERGENCY_RESTART_H
71993
71994 -static inline void machine_emergency_restart(void)
71995 +static inline __noreturn void machine_emergency_restart(void)
71996 {
71997 machine_restart(NULL);
71998 }
71999 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
72000 index 90f99c7..00ce236 100644
72001 --- a/include/asm-generic/kmap_types.h
72002 +++ b/include/asm-generic/kmap_types.h
72003 @@ -2,9 +2,9 @@
72004 #define _ASM_GENERIC_KMAP_TYPES_H
72005
72006 #ifdef __WITH_KM_FENCE
72007 -# define KM_TYPE_NR 41
72008 +# define KM_TYPE_NR 42
72009 #else
72010 -# define KM_TYPE_NR 20
72011 +# define KM_TYPE_NR 21
72012 #endif
72013
72014 #endif
72015 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
72016 index 9ceb03b..62b0b8f 100644
72017 --- a/include/asm-generic/local.h
72018 +++ b/include/asm-generic/local.h
72019 @@ -23,24 +23,37 @@ typedef struct
72020 atomic_long_t a;
72021 } local_t;
72022
72023 +typedef struct {
72024 + atomic_long_unchecked_t a;
72025 +} local_unchecked_t;
72026 +
72027 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
72028
72029 #define local_read(l) atomic_long_read(&(l)->a)
72030 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
72031 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
72032 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
72033 #define local_inc(l) atomic_long_inc(&(l)->a)
72034 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
72035 #define local_dec(l) atomic_long_dec(&(l)->a)
72036 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
72037 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
72038 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
72039 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
72040 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
72041
72042 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
72043 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
72044 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
72045 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
72046 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
72047 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
72048 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
72049 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
72050 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
72051
72052 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72053 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72054 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
72055 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
72056 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
72057 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
72058 index 725612b..9cc513a 100644
72059 --- a/include/asm-generic/pgtable-nopmd.h
72060 +++ b/include/asm-generic/pgtable-nopmd.h
72061 @@ -1,14 +1,19 @@
72062 #ifndef _PGTABLE_NOPMD_H
72063 #define _PGTABLE_NOPMD_H
72064
72065 -#ifndef __ASSEMBLY__
72066 -
72067 #include <asm-generic/pgtable-nopud.h>
72068
72069 -struct mm_struct;
72070 -
72071 #define __PAGETABLE_PMD_FOLDED
72072
72073 +#define PMD_SHIFT PUD_SHIFT
72074 +#define PTRS_PER_PMD 1
72075 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
72076 +#define PMD_MASK (~(PMD_SIZE-1))
72077 +
72078 +#ifndef __ASSEMBLY__
72079 +
72080 +struct mm_struct;
72081 +
72082 /*
72083 * Having the pmd type consist of a pud gets the size right, and allows
72084 * us to conceptually access the pud entry that this pmd is folded into
72085 @@ -16,11 +21,6 @@ struct mm_struct;
72086 */
72087 typedef struct { pud_t pud; } pmd_t;
72088
72089 -#define PMD_SHIFT PUD_SHIFT
72090 -#define PTRS_PER_PMD 1
72091 -#define PMD_SIZE (1UL << PMD_SHIFT)
72092 -#define PMD_MASK (~(PMD_SIZE-1))
72093 -
72094 /*
72095 * The "pud_xxx()" functions here are trivial for a folded two-level
72096 * setup: the pmd is never bad, and a pmd always exists (as it's folded
72097 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
72098 index 810431d..0ec4804f 100644
72099 --- a/include/asm-generic/pgtable-nopud.h
72100 +++ b/include/asm-generic/pgtable-nopud.h
72101 @@ -1,10 +1,15 @@
72102 #ifndef _PGTABLE_NOPUD_H
72103 #define _PGTABLE_NOPUD_H
72104
72105 -#ifndef __ASSEMBLY__
72106 -
72107 #define __PAGETABLE_PUD_FOLDED
72108
72109 +#define PUD_SHIFT PGDIR_SHIFT
72110 +#define PTRS_PER_PUD 1
72111 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
72112 +#define PUD_MASK (~(PUD_SIZE-1))
72113 +
72114 +#ifndef __ASSEMBLY__
72115 +
72116 /*
72117 * Having the pud type consist of a pgd gets the size right, and allows
72118 * us to conceptually access the pgd entry that this pud is folded into
72119 @@ -12,11 +17,6 @@
72120 */
72121 typedef struct { pgd_t pgd; } pud_t;
72122
72123 -#define PUD_SHIFT PGDIR_SHIFT
72124 -#define PTRS_PER_PUD 1
72125 -#define PUD_SIZE (1UL << PUD_SHIFT)
72126 -#define PUD_MASK (~(PUD_SIZE-1))
72127 -
72128 /*
72129 * The "pgd_xxx()" functions here are trivial for a folded two-level
72130 * setup: the pud is never bad, and a pud always exists (as it's folded
72131 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
72132 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
72133
72134 #define pgd_populate(mm, pgd, pud) do { } while (0)
72135 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
72136 /*
72137 * (puds are folded into pgds so this doesn't get actually called,
72138 * but the define is needed for a generic inline function.)
72139 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
72140 index 0807ddf..cd67747 100644
72141 --- a/include/asm-generic/pgtable.h
72142 +++ b/include/asm-generic/pgtable.h
72143 @@ -741,6 +741,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
72144 }
72145 #endif /* CONFIG_NUMA_BALANCING */
72146
72147 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
72148 +#ifdef CONFIG_PAX_KERNEXEC
72149 +#error KERNEXEC requires pax_open_kernel
72150 +#else
72151 +static inline unsigned long pax_open_kernel(void) { return 0; }
72152 +#endif
72153 +#endif
72154 +
72155 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
72156 +#ifdef CONFIG_PAX_KERNEXEC
72157 +#error KERNEXEC requires pax_close_kernel
72158 +#else
72159 +static inline unsigned long pax_close_kernel(void) { return 0; }
72160 +#endif
72161 +#endif
72162 +
72163 #endif /* CONFIG_MMU */
72164
72165 #endif /* !__ASSEMBLY__ */
72166 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
72167 index dc1269c..48a4f51 100644
72168 --- a/include/asm-generic/uaccess.h
72169 +++ b/include/asm-generic/uaccess.h
72170 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
72171 return __clear_user(to, n);
72172 }
72173
72174 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
72175 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72176 +#error UDEREF requires pax_open_userland
72177 +#else
72178 +static inline unsigned long pax_open_userland(void) { return 0; }
72179 +#endif
72180 +#endif
72181 +
72182 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
72183 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72184 +#error UDEREF requires pax_close_userland
72185 +#else
72186 +static inline unsigned long pax_close_userland(void) { return 0; }
72187 +#endif
72188 +#endif
72189 +
72190 #endif /* __ASM_GENERIC_UACCESS_H */
72191 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
72192 index 69732d2..cbe16d9 100644
72193 --- a/include/asm-generic/vmlinux.lds.h
72194 +++ b/include/asm-generic/vmlinux.lds.h
72195 @@ -227,6 +227,7 @@
72196 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
72197 VMLINUX_SYMBOL(__start_rodata) = .; \
72198 *(.rodata) *(.rodata.*) \
72199 + *(.data..read_only) \
72200 *(__vermagic) /* Kernel version magic */ \
72201 . = ALIGN(8); \
72202 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
72203 @@ -710,17 +711,18 @@
72204 * section in the linker script will go there too. @phdr should have
72205 * a leading colon.
72206 *
72207 - * Note that this macros defines __per_cpu_load as an absolute symbol.
72208 + * Note that this macros defines per_cpu_load as an absolute symbol.
72209 * If there is no need to put the percpu section at a predetermined
72210 * address, use PERCPU_SECTION.
72211 */
72212 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
72213 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
72214 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
72215 + per_cpu_load = .; \
72216 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
72217 - LOAD_OFFSET) { \
72218 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
72219 PERCPU_INPUT(cacheline) \
72220 } phdr \
72221 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
72222 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
72223
72224 /**
72225 * PERCPU_SECTION - define output section for percpu area, simple version
72226 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
72227 index 418d270..bfd2794 100644
72228 --- a/include/crypto/algapi.h
72229 +++ b/include/crypto/algapi.h
72230 @@ -34,7 +34,7 @@ struct crypto_type {
72231 unsigned int maskclear;
72232 unsigned int maskset;
72233 unsigned int tfmsize;
72234 -};
72235 +} __do_const;
72236
72237 struct crypto_instance {
72238 struct crypto_alg alg;
72239 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
72240 index 12083dc..39740ec 100644
72241 --- a/include/drm/drmP.h
72242 +++ b/include/drm/drmP.h
72243 @@ -69,6 +69,7 @@
72244 #include <linux/workqueue.h>
72245 #include <linux/poll.h>
72246 #include <asm/pgalloc.h>
72247 +#include <asm/local.h>
72248 #include <drm/drm.h>
72249 #include <drm/drm_sarea.h>
72250
72251 @@ -293,10 +294,12 @@ do { \
72252 * \param cmd command.
72253 * \param arg argument.
72254 */
72255 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
72256 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
72257 + struct drm_file *file_priv);
72258 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
72259 struct drm_file *file_priv);
72260
72261 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72262 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
72263 unsigned long arg);
72264
72265 #define DRM_IOCTL_NR(n) _IOC_NR(n)
72266 @@ -311,10 +314,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72267 struct drm_ioctl_desc {
72268 unsigned int cmd;
72269 int flags;
72270 - drm_ioctl_t *func;
72271 + drm_ioctl_t func;
72272 unsigned int cmd_drv;
72273 const char *name;
72274 -};
72275 +} __do_const;
72276
72277 /**
72278 * Creates a driver or general drm_ioctl_desc array entry for the given
72279 @@ -1015,7 +1018,7 @@ struct drm_info_list {
72280 int (*show)(struct seq_file*, void*); /** show callback */
72281 u32 driver_features; /**< Required driver features for this entry */
72282 void *data;
72283 -};
72284 +} __do_const;
72285
72286 /**
72287 * debugfs node structure. This structure represents a debugfs file.
72288 @@ -1088,7 +1091,7 @@ struct drm_device {
72289
72290 /** \name Usage Counters */
72291 /*@{ */
72292 - int open_count; /**< Outstanding files open */
72293 + local_t open_count; /**< Outstanding files open */
72294 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
72295 atomic_t vma_count; /**< Outstanding vma areas open */
72296 int buf_use; /**< Buffers in use -- cannot alloc */
72297 @@ -1099,7 +1102,7 @@ struct drm_device {
72298 /*@{ */
72299 unsigned long counters;
72300 enum drm_stat_type types[15];
72301 - atomic_t counts[15];
72302 + atomic_unchecked_t counts[15];
72303 /*@} */
72304
72305 struct list_head filelist;
72306 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
72307 index f43d556..94d9343 100644
72308 --- a/include/drm/drm_crtc_helper.h
72309 +++ b/include/drm/drm_crtc_helper.h
72310 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
72311 struct drm_connector *connector);
72312 /* disable encoder when not in use - more explicit than dpms off */
72313 void (*disable)(struct drm_encoder *encoder);
72314 -};
72315 +} __no_const;
72316
72317 /**
72318 * drm_connector_helper_funcs - helper operations for connectors
72319 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
72320 index 72dcbe8..8db58d7 100644
72321 --- a/include/drm/ttm/ttm_memory.h
72322 +++ b/include/drm/ttm/ttm_memory.h
72323 @@ -48,7 +48,7 @@
72324
72325 struct ttm_mem_shrink {
72326 int (*do_shrink) (struct ttm_mem_shrink *);
72327 -};
72328 +} __no_const;
72329
72330 /**
72331 * struct ttm_mem_global - Global memory accounting structure.
72332 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
72333 index 4b840e8..155d235 100644
72334 --- a/include/keys/asymmetric-subtype.h
72335 +++ b/include/keys/asymmetric-subtype.h
72336 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
72337 /* Verify the signature on a key of this subtype (optional) */
72338 int (*verify_signature)(const struct key *key,
72339 const struct public_key_signature *sig);
72340 -};
72341 +} __do_const;
72342
72343 /**
72344 * asymmetric_key_subtype - Get the subtype from an asymmetric key
72345 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
72346 index c1da539..1dcec55 100644
72347 --- a/include/linux/atmdev.h
72348 +++ b/include/linux/atmdev.h
72349 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
72350 #endif
72351
72352 struct k_atm_aal_stats {
72353 -#define __HANDLE_ITEM(i) atomic_t i
72354 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72355 __AAL_STAT_ITEMS
72356 #undef __HANDLE_ITEM
72357 };
72358 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
72359 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
72360 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
72361 struct module *owner;
72362 -};
72363 +} __do_const ;
72364
72365 struct atmphy_ops {
72366 int (*start)(struct atm_dev *dev);
72367 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
72368 index 70cf138..0418ee2 100644
72369 --- a/include/linux/binfmts.h
72370 +++ b/include/linux/binfmts.h
72371 @@ -73,8 +73,10 @@ struct linux_binfmt {
72372 int (*load_binary)(struct linux_binprm *);
72373 int (*load_shlib)(struct file *);
72374 int (*core_dump)(struct coredump_params *cprm);
72375 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
72376 + void (*handle_mmap)(struct file *);
72377 unsigned long min_coredump; /* minimal dump size */
72378 -};
72379 +} __do_const;
72380
72381 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
72382
72383 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
72384 index 2fdb4a4..54aad7e 100644
72385 --- a/include/linux/blkdev.h
72386 +++ b/include/linux/blkdev.h
72387 @@ -1526,7 +1526,7 @@ struct block_device_operations {
72388 /* this callback is with swap_lock and sometimes page table lock held */
72389 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
72390 struct module *owner;
72391 -};
72392 +} __do_const;
72393
72394 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
72395 unsigned long);
72396 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
72397 index 7c2e030..b72475d 100644
72398 --- a/include/linux/blktrace_api.h
72399 +++ b/include/linux/blktrace_api.h
72400 @@ -23,7 +23,7 @@ struct blk_trace {
72401 struct dentry *dir;
72402 struct dentry *dropped_file;
72403 struct dentry *msg_file;
72404 - atomic_t dropped;
72405 + atomic_unchecked_t dropped;
72406 };
72407
72408 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
72409 diff --git a/include/linux/cache.h b/include/linux/cache.h
72410 index 4c57065..40346da 100644
72411 --- a/include/linux/cache.h
72412 +++ b/include/linux/cache.h
72413 @@ -16,6 +16,14 @@
72414 #define __read_mostly
72415 #endif
72416
72417 +#ifndef __read_only
72418 +#ifdef CONFIG_PAX_KERNEXEC
72419 +#error KERNEXEC requires __read_only
72420 +#else
72421 +#define __read_only __read_mostly
72422 +#endif
72423 +#endif
72424 +
72425 #ifndef ____cacheline_aligned
72426 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
72427 #endif
72428 diff --git a/include/linux/capability.h b/include/linux/capability.h
72429 index d9a4f7f4..19f77d6 100644
72430 --- a/include/linux/capability.h
72431 +++ b/include/linux/capability.h
72432 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
72433 extern bool nsown_capable(int cap);
72434 extern bool inode_capable(const struct inode *inode, int cap);
72435 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
72436 +extern bool capable_nolog(int cap);
72437 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
72438 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
72439
72440 /* audit system wants to get cap info from files as well */
72441 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
72442
72443 +extern int is_privileged_binary(const struct dentry *dentry);
72444 +
72445 #endif /* !_LINUX_CAPABILITY_H */
72446 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
72447 index 8609d57..86e4d79 100644
72448 --- a/include/linux/cdrom.h
72449 +++ b/include/linux/cdrom.h
72450 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
72451
72452 /* driver specifications */
72453 const int capability; /* capability flags */
72454 - int n_minors; /* number of active minor devices */
72455 /* handle uniform packets for scsi type devices (scsi,atapi) */
72456 int (*generic_packet) (struct cdrom_device_info *,
72457 struct packet_command *);
72458 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
72459 index 4ce9056..86caac6 100644
72460 --- a/include/linux/cleancache.h
72461 +++ b/include/linux/cleancache.h
72462 @@ -31,7 +31,7 @@ struct cleancache_ops {
72463 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
72464 void (*invalidate_inode)(int, struct cleancache_filekey);
72465 void (*invalidate_fs)(int);
72466 -};
72467 +} __no_const;
72468
72469 extern struct cleancache_ops *
72470 cleancache_register_ops(struct cleancache_ops *ops);
72471 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
72472 index 1ec14a7..d0654a2 100644
72473 --- a/include/linux/clk-provider.h
72474 +++ b/include/linux/clk-provider.h
72475 @@ -132,6 +132,7 @@ struct clk_ops {
72476 unsigned long);
72477 void (*init)(struct clk_hw *hw);
72478 };
72479 +typedef struct clk_ops __no_const clk_ops_no_const;
72480
72481 /**
72482 * struct clk_init_data - holds init data that's common to all clocks and is
72483 diff --git a/include/linux/compat.h b/include/linux/compat.h
72484 index ec1aee4..1077986 100644
72485 --- a/include/linux/compat.h
72486 +++ b/include/linux/compat.h
72487 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
72488 compat_size_t __user *len_ptr);
72489
72490 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
72491 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
72492 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
72493 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
72494 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
72495 compat_ssize_t msgsz, int msgflg);
72496 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
72497 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
72498 compat_ulong_t addr, compat_ulong_t data);
72499 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
72500 - compat_long_t addr, compat_long_t data);
72501 + compat_ulong_t addr, compat_ulong_t data);
72502
72503 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
72504 /*
72505 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
72506 index ded4299..da50e3b 100644
72507 --- a/include/linux/compiler-gcc4.h
72508 +++ b/include/linux/compiler-gcc4.h
72509 @@ -39,9 +39,29 @@
72510 # define __compiletime_warning(message) __attribute__((warning(message)))
72511 # define __compiletime_error(message) __attribute__((error(message)))
72512 #endif /* __CHECKER__ */
72513 +
72514 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
72515 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
72516 +#define __bos0(ptr) __bos((ptr), 0)
72517 +#define __bos1(ptr) __bos((ptr), 1)
72518 #endif /* GCC_VERSION >= 40300 */
72519
72520 #if GCC_VERSION >= 40500
72521 +
72522 +#ifdef CONSTIFY_PLUGIN
72523 +#define __no_const __attribute__((no_const))
72524 +#define __do_const __attribute__((do_const))
72525 +#endif
72526 +
72527 +#ifdef SIZE_OVERFLOW_PLUGIN
72528 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
72529 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
72530 +#endif
72531 +
72532 +#ifdef LATENT_ENTROPY_PLUGIN
72533 +#define __latent_entropy __attribute__((latent_entropy))
72534 +#endif
72535 +
72536 /*
72537 * Mark a position in code as unreachable. This can be used to
72538 * suppress control flow warnings after asm blocks that transfer
72539 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
72540 index 92669cd..1771a15 100644
72541 --- a/include/linux/compiler.h
72542 +++ b/include/linux/compiler.h
72543 @@ -5,11 +5,14 @@
72544
72545 #ifdef __CHECKER__
72546 # define __user __attribute__((noderef, address_space(1)))
72547 +# define __force_user __force __user
72548 # define __kernel __attribute__((address_space(0)))
72549 +# define __force_kernel __force __kernel
72550 # define __safe __attribute__((safe))
72551 # define __force __attribute__((force))
72552 # define __nocast __attribute__((nocast))
72553 # define __iomem __attribute__((noderef, address_space(2)))
72554 +# define __force_iomem __force __iomem
72555 # define __must_hold(x) __attribute__((context(x,1,1)))
72556 # define __acquires(x) __attribute__((context(x,0,1)))
72557 # define __releases(x) __attribute__((context(x,1,0)))
72558 @@ -17,20 +20,37 @@
72559 # define __release(x) __context__(x,-1)
72560 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
72561 # define __percpu __attribute__((noderef, address_space(3)))
72562 +# define __force_percpu __force __percpu
72563 #ifdef CONFIG_SPARSE_RCU_POINTER
72564 # define __rcu __attribute__((noderef, address_space(4)))
72565 +# define __force_rcu __force __rcu
72566 #else
72567 # define __rcu
72568 +# define __force_rcu
72569 #endif
72570 extern void __chk_user_ptr(const volatile void __user *);
72571 extern void __chk_io_ptr(const volatile void __iomem *);
72572 #else
72573 -# define __user
72574 -# define __kernel
72575 +# ifdef CHECKER_PLUGIN
72576 +//# define __user
72577 +//# define __force_user
72578 +//# define __kernel
72579 +//# define __force_kernel
72580 +# else
72581 +# ifdef STRUCTLEAK_PLUGIN
72582 +# define __user __attribute__((user))
72583 +# else
72584 +# define __user
72585 +# endif
72586 +# define __force_user
72587 +# define __kernel
72588 +# define __force_kernel
72589 +# endif
72590 # define __safe
72591 # define __force
72592 # define __nocast
72593 # define __iomem
72594 +# define __force_iomem
72595 # define __chk_user_ptr(x) (void)0
72596 # define __chk_io_ptr(x) (void)0
72597 # define __builtin_warning(x, y...) (1)
72598 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
72599 # define __release(x) (void)0
72600 # define __cond_lock(x,c) (c)
72601 # define __percpu
72602 +# define __force_percpu
72603 # define __rcu
72604 +# define __force_rcu
72605 #endif
72606
72607 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
72608 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72609 # define __attribute_const__ /* unimplemented */
72610 #endif
72611
72612 +#ifndef __no_const
72613 +# define __no_const
72614 +#endif
72615 +
72616 +#ifndef __do_const
72617 +# define __do_const
72618 +#endif
72619 +
72620 +#ifndef __size_overflow
72621 +# define __size_overflow(...)
72622 +#endif
72623 +
72624 +#ifndef __intentional_overflow
72625 +# define __intentional_overflow(...)
72626 +#endif
72627 +
72628 +#ifndef __latent_entropy
72629 +# define __latent_entropy
72630 +#endif
72631 +
72632 /*
72633 * Tell gcc if a function is cold. The compiler will assume any path
72634 * directly leading to the call is unlikely.
72635 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72636 #define __cold
72637 #endif
72638
72639 +#ifndef __alloc_size
72640 +#define __alloc_size(...)
72641 +#endif
72642 +
72643 +#ifndef __bos
72644 +#define __bos(ptr, arg)
72645 +#endif
72646 +
72647 +#ifndef __bos0
72648 +#define __bos0(ptr)
72649 +#endif
72650 +
72651 +#ifndef __bos1
72652 +#define __bos1(ptr)
72653 +#endif
72654 +
72655 /* Simple shorthand for a section definition */
72656 #ifndef __section
72657 # define __section(S) __attribute__ ((__section__(#S)))
72658 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72659 * use is to mediate communication between process-level code and irq/NMI
72660 * handlers, all running on the same CPU.
72661 */
72662 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
72663 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
72664 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
72665
72666 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
72667 #ifdef CONFIG_KPROBES
72668 diff --git a/include/linux/completion.h b/include/linux/completion.h
72669 index 3cd574d..adce5fa 100644
72670 --- a/include/linux/completion.h
72671 +++ b/include/linux/completion.h
72672 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
72673 extern void wait_for_completion(struct completion *);
72674 extern void wait_for_completion_io(struct completion *);
72675 extern int wait_for_completion_interruptible(struct completion *x);
72676 -extern int wait_for_completion_killable(struct completion *x);
72677 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
72678 extern unsigned long wait_for_completion_timeout(struct completion *x,
72679 unsigned long timeout);
72680 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
72681 unsigned long timeout);
72682 extern long wait_for_completion_interruptible_timeout(
72683 - struct completion *x, unsigned long timeout);
72684 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72685 extern long wait_for_completion_killable_timeout(
72686 - struct completion *x, unsigned long timeout);
72687 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72688 extern bool try_wait_for_completion(struct completion *x);
72689 extern bool completion_done(struct completion *x);
72690
72691 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
72692 index 34025df..d94bbbc 100644
72693 --- a/include/linux/configfs.h
72694 +++ b/include/linux/configfs.h
72695 @@ -125,7 +125,7 @@ struct configfs_attribute {
72696 const char *ca_name;
72697 struct module *ca_owner;
72698 umode_t ca_mode;
72699 -};
72700 +} __do_const;
72701
72702 /*
72703 * Users often need to create attribute structures for their configurable
72704 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
72705 index 90d5a15..950cb80 100644
72706 --- a/include/linux/cpufreq.h
72707 +++ b/include/linux/cpufreq.h
72708 @@ -266,7 +266,7 @@ struct cpufreq_driver {
72709 int (*suspend) (struct cpufreq_policy *policy);
72710 int (*resume) (struct cpufreq_policy *policy);
72711 struct freq_attr **attr;
72712 -};
72713 +} __do_const;
72714
72715 /* flags */
72716
72717 @@ -325,6 +325,7 @@ struct global_attr {
72718 ssize_t (*store)(struct kobject *a, struct attribute *b,
72719 const char *c, size_t count);
72720 };
72721 +typedef struct global_attr __no_const global_attr_no_const;
72722
72723 #define define_one_global_ro(_name) \
72724 static struct global_attr _name = \
72725 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
72726 index 0bc4b74..973b368 100644
72727 --- a/include/linux/cpuidle.h
72728 +++ b/include/linux/cpuidle.h
72729 @@ -52,7 +52,8 @@ struct cpuidle_state {
72730 int index);
72731
72732 int (*enter_dead) (struct cpuidle_device *dev, int index);
72733 -};
72734 +} __do_const;
72735 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
72736
72737 /* Idle State Flags */
72738 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
72739 @@ -191,7 +192,7 @@ struct cpuidle_governor {
72740 void (*reflect) (struct cpuidle_device *dev, int index);
72741
72742 struct module *owner;
72743 -};
72744 +} __do_const;
72745
72746 #ifdef CONFIG_CPU_IDLE
72747
72748 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
72749 index d08e4d2..95fad61 100644
72750 --- a/include/linux/cpumask.h
72751 +++ b/include/linux/cpumask.h
72752 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72753 }
72754
72755 /* Valid inputs for n are -1 and 0. */
72756 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72757 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72758 {
72759 return n+1;
72760 }
72761
72762 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72763 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72764 {
72765 return n+1;
72766 }
72767
72768 -static inline unsigned int cpumask_next_and(int n,
72769 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
72770 const struct cpumask *srcp,
72771 const struct cpumask *andp)
72772 {
72773 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72774 *
72775 * Returns >= nr_cpu_ids if no further cpus set.
72776 */
72777 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72778 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72779 {
72780 /* -1 is a legal arg here. */
72781 if (n != -1)
72782 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72783 *
72784 * Returns >= nr_cpu_ids if no further cpus unset.
72785 */
72786 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72787 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72788 {
72789 /* -1 is a legal arg here. */
72790 if (n != -1)
72791 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72792 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
72793 }
72794
72795 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
72796 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
72797 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
72798
72799 /**
72800 diff --git a/include/linux/cred.h b/include/linux/cred.h
72801 index 04421e8..6bce4ef 100644
72802 --- a/include/linux/cred.h
72803 +++ b/include/linux/cred.h
72804 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
72805 static inline void validate_process_creds(void)
72806 {
72807 }
72808 +static inline void validate_task_creds(struct task_struct *task)
72809 +{
72810 +}
72811 #endif
72812
72813 /**
72814 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
72815 index b92eadf..b4ecdc1 100644
72816 --- a/include/linux/crypto.h
72817 +++ b/include/linux/crypto.h
72818 @@ -373,7 +373,7 @@ struct cipher_tfm {
72819 const u8 *key, unsigned int keylen);
72820 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72821 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72822 -};
72823 +} __no_const;
72824
72825 struct hash_tfm {
72826 int (*init)(struct hash_desc *desc);
72827 @@ -394,13 +394,13 @@ struct compress_tfm {
72828 int (*cot_decompress)(struct crypto_tfm *tfm,
72829 const u8 *src, unsigned int slen,
72830 u8 *dst, unsigned int *dlen);
72831 -};
72832 +} __no_const;
72833
72834 struct rng_tfm {
72835 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
72836 unsigned int dlen);
72837 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
72838 -};
72839 +} __no_const;
72840
72841 #define crt_ablkcipher crt_u.ablkcipher
72842 #define crt_aead crt_u.aead
72843 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
72844 index 653589e..4ef254a 100644
72845 --- a/include/linux/ctype.h
72846 +++ b/include/linux/ctype.h
72847 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
72848 * Fast implementation of tolower() for internal usage. Do not use in your
72849 * code.
72850 */
72851 -static inline char _tolower(const char c)
72852 +static inline unsigned char _tolower(const unsigned char c)
72853 {
72854 return c | 0x20;
72855 }
72856 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
72857 index 7925bf0..d5143d2 100644
72858 --- a/include/linux/decompress/mm.h
72859 +++ b/include/linux/decompress/mm.h
72860 @@ -77,7 +77,7 @@ static void free(void *where)
72861 * warnings when not needed (indeed large_malloc / large_free are not
72862 * needed by inflate */
72863
72864 -#define malloc(a) kmalloc(a, GFP_KERNEL)
72865 +#define malloc(a) kmalloc((a), GFP_KERNEL)
72866 #define free(a) kfree(a)
72867
72868 #define large_malloc(a) vmalloc(a)
72869 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
72870 index 5f1ab92..39c35ae 100644
72871 --- a/include/linux/devfreq.h
72872 +++ b/include/linux/devfreq.h
72873 @@ -114,7 +114,7 @@ struct devfreq_governor {
72874 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
72875 int (*event_handler)(struct devfreq *devfreq,
72876 unsigned int event, void *data);
72877 -};
72878 +} __do_const;
72879
72880 /**
72881 * struct devfreq - Device devfreq structure
72882 diff --git a/include/linux/device.h b/include/linux/device.h
72883 index 22b546a..a573dc9 100644
72884 --- a/include/linux/device.h
72885 +++ b/include/linux/device.h
72886 @@ -305,7 +305,7 @@ struct subsys_interface {
72887 struct list_head node;
72888 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
72889 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
72890 -};
72891 +} __do_const;
72892
72893 int subsys_interface_register(struct subsys_interface *sif);
72894 void subsys_interface_unregister(struct subsys_interface *sif);
72895 @@ -493,7 +493,7 @@ struct device_type {
72896 void (*release)(struct device *dev);
72897
72898 const struct dev_pm_ops *pm;
72899 -};
72900 +} __do_const;
72901
72902 /* interface for exporting device attributes */
72903 struct device_attribute {
72904 @@ -503,11 +503,12 @@ struct device_attribute {
72905 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
72906 const char *buf, size_t count);
72907 };
72908 +typedef struct device_attribute __no_const device_attribute_no_const;
72909
72910 struct dev_ext_attribute {
72911 struct device_attribute attr;
72912 void *var;
72913 -};
72914 +} __do_const;
72915
72916 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
72917 char *buf);
72918 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
72919 index 94af418..b1ca7a2 100644
72920 --- a/include/linux/dma-mapping.h
72921 +++ b/include/linux/dma-mapping.h
72922 @@ -54,7 +54,7 @@ struct dma_map_ops {
72923 u64 (*get_required_mask)(struct device *dev);
72924 #endif
72925 int is_phys;
72926 -};
72927 +} __do_const;
72928
72929 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
72930
72931 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
72932 index cb286b1..923d066 100644
72933 --- a/include/linux/dmaengine.h
72934 +++ b/include/linux/dmaengine.h
72935 @@ -1030,9 +1030,9 @@ struct dma_pinned_list {
72936 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
72937 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
72938
72939 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72940 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72941 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
72942 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72943 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72944 struct dma_pinned_list *pinned_list, struct page *page,
72945 unsigned int offset, size_t len);
72946
72947 diff --git a/include/linux/efi.h b/include/linux/efi.h
72948 index 5f8f176..62a0556 100644
72949 --- a/include/linux/efi.h
72950 +++ b/include/linux/efi.h
72951 @@ -745,6 +745,7 @@ struct efivar_operations {
72952 efi_set_variable_t *set_variable;
72953 efi_query_variable_store_t *query_variable_store;
72954 };
72955 +typedef struct efivar_operations __no_const efivar_operations_no_const;
72956
72957 struct efivars {
72958 /*
72959 diff --git a/include/linux/elf.h b/include/linux/elf.h
72960 index 40a3c0e..4c45a38 100644
72961 --- a/include/linux/elf.h
72962 +++ b/include/linux/elf.h
72963 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
72964 #define elf_note elf32_note
72965 #define elf_addr_t Elf32_Off
72966 #define Elf_Half Elf32_Half
72967 +#define elf_dyn Elf32_Dyn
72968
72969 #else
72970
72971 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
72972 #define elf_note elf64_note
72973 #define elf_addr_t Elf64_Off
72974 #define Elf_Half Elf64_Half
72975 +#define elf_dyn Elf64_Dyn
72976
72977 #endif
72978
72979 diff --git a/include/linux/err.h b/include/linux/err.h
72980 index 221fcfb..f29e5e2 100644
72981 --- a/include/linux/err.h
72982 +++ b/include/linux/err.h
72983 @@ -19,12 +19,12 @@
72984
72985 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
72986
72987 -static inline void * __must_check ERR_PTR(long error)
72988 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
72989 {
72990 return (void *) error;
72991 }
72992
72993 -static inline long __must_check PTR_ERR(__force const void *ptr)
72994 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
72995 {
72996 return (long) ptr;
72997 }
72998 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
72999 index fcb51c8..bdafcf6 100644
73000 --- a/include/linux/extcon.h
73001 +++ b/include/linux/extcon.h
73002 @@ -134,7 +134,7 @@ struct extcon_dev {
73003 /* /sys/class/extcon/.../mutually_exclusive/... */
73004 struct attribute_group attr_g_muex;
73005 struct attribute **attrs_muex;
73006 - struct device_attribute *d_attrs_muex;
73007 + device_attribute_no_const *d_attrs_muex;
73008 };
73009
73010 /**
73011 diff --git a/include/linux/fb.h b/include/linux/fb.h
73012 index ffac70a..ca3e711 100644
73013 --- a/include/linux/fb.h
73014 +++ b/include/linux/fb.h
73015 @@ -304,7 +304,7 @@ struct fb_ops {
73016 /* called at KDB enter and leave time to prepare the console */
73017 int (*fb_debug_enter)(struct fb_info *info);
73018 int (*fb_debug_leave)(struct fb_info *info);
73019 -};
73020 +} __do_const;
73021
73022 #ifdef CONFIG_FB_TILEBLITTING
73023 #define FB_TILE_CURSOR_NONE 0
73024 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
73025 index 085197b..0fa6f0b 100644
73026 --- a/include/linux/fdtable.h
73027 +++ b/include/linux/fdtable.h
73028 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
73029 void put_files_struct(struct files_struct *fs);
73030 void reset_files_struct(struct files_struct *);
73031 int unshare_files(struct files_struct **);
73032 -struct files_struct *dup_fd(struct files_struct *, int *);
73033 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
73034 void do_close_on_exec(struct files_struct *);
73035 int iterate_fd(struct files_struct *, unsigned,
73036 int (*)(const void *, struct file *, unsigned),
73037 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
73038 index 8293262..2b3b8bd 100644
73039 --- a/include/linux/frontswap.h
73040 +++ b/include/linux/frontswap.h
73041 @@ -11,7 +11,7 @@ struct frontswap_ops {
73042 int (*load)(unsigned, pgoff_t, struct page *);
73043 void (*invalidate_page)(unsigned, pgoff_t);
73044 void (*invalidate_area)(unsigned);
73045 -};
73046 +} __no_const;
73047
73048 extern bool frontswap_enabled;
73049 extern struct frontswap_ops *
73050 diff --git a/include/linux/fs.h b/include/linux/fs.h
73051 index 9818747..788bfbd 100644
73052 --- a/include/linux/fs.h
73053 +++ b/include/linux/fs.h
73054 @@ -1554,7 +1554,8 @@ struct file_operations {
73055 long (*fallocate)(struct file *file, int mode, loff_t offset,
73056 loff_t len);
73057 int (*show_fdinfo)(struct seq_file *m, struct file *f);
73058 -};
73059 +} __do_const;
73060 +typedef struct file_operations __no_const file_operations_no_const;
73061
73062 struct inode_operations {
73063 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
73064 @@ -2740,4 +2741,14 @@ static inline bool dir_relax(struct inode *inode)
73065 return !IS_DEADDIR(inode);
73066 }
73067
73068 +static inline bool is_sidechannel_device(const struct inode *inode)
73069 +{
73070 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
73071 + umode_t mode = inode->i_mode;
73072 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
73073 +#else
73074 + return false;
73075 +#endif
73076 +}
73077 +
73078 #endif /* _LINUX_FS_H */
73079 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
73080 index 2b93a9a..855d94a 100644
73081 --- a/include/linux/fs_struct.h
73082 +++ b/include/linux/fs_struct.h
73083 @@ -6,7 +6,7 @@
73084 #include <linux/seqlock.h>
73085
73086 struct fs_struct {
73087 - int users;
73088 + atomic_t users;
73089 spinlock_t lock;
73090 seqcount_t seq;
73091 int umask;
73092 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
73093 index a9ff9a3..1ba1788 100644
73094 --- a/include/linux/fscache-cache.h
73095 +++ b/include/linux/fscache-cache.h
73096 @@ -113,7 +113,7 @@ struct fscache_operation {
73097 fscache_operation_release_t release;
73098 };
73099
73100 -extern atomic_t fscache_op_debug_id;
73101 +extern atomic_unchecked_t fscache_op_debug_id;
73102 extern void fscache_op_work_func(struct work_struct *work);
73103
73104 extern void fscache_enqueue_operation(struct fscache_operation *);
73105 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
73106 INIT_WORK(&op->work, fscache_op_work_func);
73107 atomic_set(&op->usage, 1);
73108 op->state = FSCACHE_OP_ST_INITIALISED;
73109 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
73110 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
73111 op->processor = processor;
73112 op->release = release;
73113 INIT_LIST_HEAD(&op->pend_link);
73114 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
73115 index 7a08623..4c07b0f 100644
73116 --- a/include/linux/fscache.h
73117 +++ b/include/linux/fscache.h
73118 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
73119 * - this is mandatory for any object that may have data
73120 */
73121 void (*now_uncached)(void *cookie_netfs_data);
73122 -};
73123 +} __do_const;
73124
73125 /*
73126 * fscache cached network filesystem type
73127 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
73128 index 1c804b0..1432c2b 100644
73129 --- a/include/linux/fsnotify.h
73130 +++ b/include/linux/fsnotify.h
73131 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
73132 struct inode *inode = file_inode(file);
73133 __u32 mask = FS_ACCESS;
73134
73135 + if (is_sidechannel_device(inode))
73136 + return;
73137 +
73138 if (S_ISDIR(inode->i_mode))
73139 mask |= FS_ISDIR;
73140
73141 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
73142 struct inode *inode = file_inode(file);
73143 __u32 mask = FS_MODIFY;
73144
73145 + if (is_sidechannel_device(inode))
73146 + return;
73147 +
73148 if (S_ISDIR(inode->i_mode))
73149 mask |= FS_ISDIR;
73150
73151 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
73152 */
73153 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
73154 {
73155 - return kstrdup(name, GFP_KERNEL);
73156 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
73157 }
73158
73159 /*
73160 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
73161 index 9f3c275..8bdff5d 100644
73162 --- a/include/linux/genhd.h
73163 +++ b/include/linux/genhd.h
73164 @@ -194,7 +194,7 @@ struct gendisk {
73165 struct kobject *slave_dir;
73166
73167 struct timer_rand_state *random;
73168 - atomic_t sync_io; /* RAID */
73169 + atomic_unchecked_t sync_io; /* RAID */
73170 struct disk_events *ev;
73171 #ifdef CONFIG_BLK_DEV_INTEGRITY
73172 struct blk_integrity *integrity;
73173 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
73174 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
73175
73176 /* drivers/char/random.c */
73177 -extern void add_disk_randomness(struct gendisk *disk);
73178 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
73179 extern void rand_initialize_disk(struct gendisk *disk);
73180
73181 static inline sector_t get_start_sect(struct block_device *bdev)
73182 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
73183 index 023bc34..b02b46a 100644
73184 --- a/include/linux/genl_magic_func.h
73185 +++ b/include/linux/genl_magic_func.h
73186 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
73187 },
73188
73189 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
73190 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
73191 +static struct genl_ops ZZZ_genl_ops[] = {
73192 #include GENL_MAGIC_INCLUDE_FILE
73193 };
73194
73195 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
73196 index 9b4dd49..61fd41d 100644
73197 --- a/include/linux/gfp.h
73198 +++ b/include/linux/gfp.h
73199 @@ -35,6 +35,13 @@ struct vm_area_struct;
73200 #define ___GFP_NO_KSWAPD 0x400000u
73201 #define ___GFP_OTHER_NODE 0x800000u
73202 #define ___GFP_WRITE 0x1000000u
73203 +
73204 +#ifdef CONFIG_PAX_USERCOPY_SLABS
73205 +#define ___GFP_USERCOPY 0x2000000u
73206 +#else
73207 +#define ___GFP_USERCOPY 0
73208 +#endif
73209 +
73210 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
73211
73212 /*
73213 @@ -92,6 +99,7 @@ struct vm_area_struct;
73214 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
73215 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
73216 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
73217 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
73218
73219 /*
73220 * This may seem redundant, but it's a way of annotating false positives vs.
73221 @@ -99,7 +107,7 @@ struct vm_area_struct;
73222 */
73223 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
73224
73225 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
73226 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
73227 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
73228
73229 /* This equals 0, but use constants in case they ever change */
73230 @@ -153,6 +161,8 @@ struct vm_area_struct;
73231 /* 4GB DMA on some platforms */
73232 #define GFP_DMA32 __GFP_DMA32
73233
73234 +#define GFP_USERCOPY __GFP_USERCOPY
73235 +
73236 /* Convert GFP flags to their corresponding migrate type */
73237 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
73238 {
73239 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
73240 new file mode 100644
73241 index 0000000..ebe6d72
73242 --- /dev/null
73243 +++ b/include/linux/gracl.h
73244 @@ -0,0 +1,319 @@
73245 +#ifndef GR_ACL_H
73246 +#define GR_ACL_H
73247 +
73248 +#include <linux/grdefs.h>
73249 +#include <linux/resource.h>
73250 +#include <linux/capability.h>
73251 +#include <linux/dcache.h>
73252 +#include <asm/resource.h>
73253 +
73254 +/* Major status information */
73255 +
73256 +#define GR_VERSION "grsecurity 2.9.1"
73257 +#define GRSECURITY_VERSION 0x2901
73258 +
73259 +enum {
73260 + GR_SHUTDOWN = 0,
73261 + GR_ENABLE = 1,
73262 + GR_SPROLE = 2,
73263 + GR_RELOAD = 3,
73264 + GR_SEGVMOD = 4,
73265 + GR_STATUS = 5,
73266 + GR_UNSPROLE = 6,
73267 + GR_PASSSET = 7,
73268 + GR_SPROLEPAM = 8,
73269 +};
73270 +
73271 +/* Password setup definitions
73272 + * kernel/grhash.c */
73273 +enum {
73274 + GR_PW_LEN = 128,
73275 + GR_SALT_LEN = 16,
73276 + GR_SHA_LEN = 32,
73277 +};
73278 +
73279 +enum {
73280 + GR_SPROLE_LEN = 64,
73281 +};
73282 +
73283 +enum {
73284 + GR_NO_GLOB = 0,
73285 + GR_REG_GLOB,
73286 + GR_CREATE_GLOB
73287 +};
73288 +
73289 +#define GR_NLIMITS 32
73290 +
73291 +/* Begin Data Structures */
73292 +
73293 +struct sprole_pw {
73294 + unsigned char *rolename;
73295 + unsigned char salt[GR_SALT_LEN];
73296 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
73297 +};
73298 +
73299 +struct name_entry {
73300 + __u32 key;
73301 + ino_t inode;
73302 + dev_t device;
73303 + char *name;
73304 + __u16 len;
73305 + __u8 deleted;
73306 + struct name_entry *prev;
73307 + struct name_entry *next;
73308 +};
73309 +
73310 +struct inodev_entry {
73311 + struct name_entry *nentry;
73312 + struct inodev_entry *prev;
73313 + struct inodev_entry *next;
73314 +};
73315 +
73316 +struct acl_role_db {
73317 + struct acl_role_label **r_hash;
73318 + __u32 r_size;
73319 +};
73320 +
73321 +struct inodev_db {
73322 + struct inodev_entry **i_hash;
73323 + __u32 i_size;
73324 +};
73325 +
73326 +struct name_db {
73327 + struct name_entry **n_hash;
73328 + __u32 n_size;
73329 +};
73330 +
73331 +struct crash_uid {
73332 + uid_t uid;
73333 + unsigned long expires;
73334 +};
73335 +
73336 +struct gr_hash_struct {
73337 + void **table;
73338 + void **nametable;
73339 + void *first;
73340 + __u32 table_size;
73341 + __u32 used_size;
73342 + int type;
73343 +};
73344 +
73345 +/* Userspace Grsecurity ACL data structures */
73346 +
73347 +struct acl_subject_label {
73348 + char *filename;
73349 + ino_t inode;
73350 + dev_t device;
73351 + __u32 mode;
73352 + kernel_cap_t cap_mask;
73353 + kernel_cap_t cap_lower;
73354 + kernel_cap_t cap_invert_audit;
73355 +
73356 + struct rlimit res[GR_NLIMITS];
73357 + __u32 resmask;
73358 +
73359 + __u8 user_trans_type;
73360 + __u8 group_trans_type;
73361 + uid_t *user_transitions;
73362 + gid_t *group_transitions;
73363 + __u16 user_trans_num;
73364 + __u16 group_trans_num;
73365 +
73366 + __u32 sock_families[2];
73367 + __u32 ip_proto[8];
73368 + __u32 ip_type;
73369 + struct acl_ip_label **ips;
73370 + __u32 ip_num;
73371 + __u32 inaddr_any_override;
73372 +
73373 + __u32 crashes;
73374 + unsigned long expires;
73375 +
73376 + struct acl_subject_label *parent_subject;
73377 + struct gr_hash_struct *hash;
73378 + struct acl_subject_label *prev;
73379 + struct acl_subject_label *next;
73380 +
73381 + struct acl_object_label **obj_hash;
73382 + __u32 obj_hash_size;
73383 + __u16 pax_flags;
73384 +};
73385 +
73386 +struct role_allowed_ip {
73387 + __u32 addr;
73388 + __u32 netmask;
73389 +
73390 + struct role_allowed_ip *prev;
73391 + struct role_allowed_ip *next;
73392 +};
73393 +
73394 +struct role_transition {
73395 + char *rolename;
73396 +
73397 + struct role_transition *prev;
73398 + struct role_transition *next;
73399 +};
73400 +
73401 +struct acl_role_label {
73402 + char *rolename;
73403 + uid_t uidgid;
73404 + __u16 roletype;
73405 +
73406 + __u16 auth_attempts;
73407 + unsigned long expires;
73408 +
73409 + struct acl_subject_label *root_label;
73410 + struct gr_hash_struct *hash;
73411 +
73412 + struct acl_role_label *prev;
73413 + struct acl_role_label *next;
73414 +
73415 + struct role_transition *transitions;
73416 + struct role_allowed_ip *allowed_ips;
73417 + uid_t *domain_children;
73418 + __u16 domain_child_num;
73419 +
73420 + umode_t umask;
73421 +
73422 + struct acl_subject_label **subj_hash;
73423 + __u32 subj_hash_size;
73424 +};
73425 +
73426 +struct user_acl_role_db {
73427 + struct acl_role_label **r_table;
73428 + __u32 num_pointers; /* Number of allocations to track */
73429 + __u32 num_roles; /* Number of roles */
73430 + __u32 num_domain_children; /* Number of domain children */
73431 + __u32 num_subjects; /* Number of subjects */
73432 + __u32 num_objects; /* Number of objects */
73433 +};
73434 +
73435 +struct acl_object_label {
73436 + char *filename;
73437 + ino_t inode;
73438 + dev_t device;
73439 + __u32 mode;
73440 +
73441 + struct acl_subject_label *nested;
73442 + struct acl_object_label *globbed;
73443 +
73444 + /* next two structures not used */
73445 +
73446 + struct acl_object_label *prev;
73447 + struct acl_object_label *next;
73448 +};
73449 +
73450 +struct acl_ip_label {
73451 + char *iface;
73452 + __u32 addr;
73453 + __u32 netmask;
73454 + __u16 low, high;
73455 + __u8 mode;
73456 + __u32 type;
73457 + __u32 proto[8];
73458 +
73459 + /* next two structures not used */
73460 +
73461 + struct acl_ip_label *prev;
73462 + struct acl_ip_label *next;
73463 +};
73464 +
73465 +struct gr_arg {
73466 + struct user_acl_role_db role_db;
73467 + unsigned char pw[GR_PW_LEN];
73468 + unsigned char salt[GR_SALT_LEN];
73469 + unsigned char sum[GR_SHA_LEN];
73470 + unsigned char sp_role[GR_SPROLE_LEN];
73471 + struct sprole_pw *sprole_pws;
73472 + dev_t segv_device;
73473 + ino_t segv_inode;
73474 + uid_t segv_uid;
73475 + __u16 num_sprole_pws;
73476 + __u16 mode;
73477 +};
73478 +
73479 +struct gr_arg_wrapper {
73480 + struct gr_arg *arg;
73481 + __u32 version;
73482 + __u32 size;
73483 +};
73484 +
73485 +struct subject_map {
73486 + struct acl_subject_label *user;
73487 + struct acl_subject_label *kernel;
73488 + struct subject_map *prev;
73489 + struct subject_map *next;
73490 +};
73491 +
73492 +struct acl_subj_map_db {
73493 + struct subject_map **s_hash;
73494 + __u32 s_size;
73495 +};
73496 +
73497 +/* End Data Structures Section */
73498 +
73499 +/* Hash functions generated by empirical testing by Brad Spengler
73500 + Makes good use of the low bits of the inode. Generally 0-1 times
73501 + in loop for successful match. 0-3 for unsuccessful match.
73502 + Shift/add algorithm with modulus of table size and an XOR*/
73503 +
73504 +static __inline__ unsigned int
73505 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
73506 +{
73507 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
73508 +}
73509 +
73510 + static __inline__ unsigned int
73511 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
73512 +{
73513 + return ((const unsigned long)userp % sz);
73514 +}
73515 +
73516 +static __inline__ unsigned int
73517 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
73518 +{
73519 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
73520 +}
73521 +
73522 +static __inline__ unsigned int
73523 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
73524 +{
73525 + return full_name_hash((const unsigned char *)name, len) % sz;
73526 +}
73527 +
73528 +#define FOR_EACH_ROLE_START(role) \
73529 + role = role_list; \
73530 + while (role) {
73531 +
73532 +#define FOR_EACH_ROLE_END(role) \
73533 + role = role->prev; \
73534 + }
73535 +
73536 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
73537 + subj = NULL; \
73538 + iter = 0; \
73539 + while (iter < role->subj_hash_size) { \
73540 + if (subj == NULL) \
73541 + subj = role->subj_hash[iter]; \
73542 + if (subj == NULL) { \
73543 + iter++; \
73544 + continue; \
73545 + }
73546 +
73547 +#define FOR_EACH_SUBJECT_END(subj,iter) \
73548 + subj = subj->next; \
73549 + if (subj == NULL) \
73550 + iter++; \
73551 + }
73552 +
73553 +
73554 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
73555 + subj = role->hash->first; \
73556 + while (subj != NULL) {
73557 +
73558 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
73559 + subj = subj->next; \
73560 + }
73561 +
73562 +#endif
73563 +
73564 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
73565 new file mode 100644
73566 index 0000000..33ebd1f
73567 --- /dev/null
73568 +++ b/include/linux/gracl_compat.h
73569 @@ -0,0 +1,156 @@
73570 +#ifndef GR_ACL_COMPAT_H
73571 +#define GR_ACL_COMPAT_H
73572 +
73573 +#include <linux/resource.h>
73574 +#include <asm/resource.h>
73575 +
73576 +struct sprole_pw_compat {
73577 + compat_uptr_t rolename;
73578 + unsigned char salt[GR_SALT_LEN];
73579 + unsigned char sum[GR_SHA_LEN];
73580 +};
73581 +
73582 +struct gr_hash_struct_compat {
73583 + compat_uptr_t table;
73584 + compat_uptr_t nametable;
73585 + compat_uptr_t first;
73586 + __u32 table_size;
73587 + __u32 used_size;
73588 + int type;
73589 +};
73590 +
73591 +struct acl_subject_label_compat {
73592 + compat_uptr_t filename;
73593 + compat_ino_t inode;
73594 + __u32 device;
73595 + __u32 mode;
73596 + kernel_cap_t cap_mask;
73597 + kernel_cap_t cap_lower;
73598 + kernel_cap_t cap_invert_audit;
73599 +
73600 + struct compat_rlimit res[GR_NLIMITS];
73601 + __u32 resmask;
73602 +
73603 + __u8 user_trans_type;
73604 + __u8 group_trans_type;
73605 + compat_uptr_t user_transitions;
73606 + compat_uptr_t group_transitions;
73607 + __u16 user_trans_num;
73608 + __u16 group_trans_num;
73609 +
73610 + __u32 sock_families[2];
73611 + __u32 ip_proto[8];
73612 + __u32 ip_type;
73613 + compat_uptr_t ips;
73614 + __u32 ip_num;
73615 + __u32 inaddr_any_override;
73616 +
73617 + __u32 crashes;
73618 + compat_ulong_t expires;
73619 +
73620 + compat_uptr_t parent_subject;
73621 + compat_uptr_t hash;
73622 + compat_uptr_t prev;
73623 + compat_uptr_t next;
73624 +
73625 + compat_uptr_t obj_hash;
73626 + __u32 obj_hash_size;
73627 + __u16 pax_flags;
73628 +};
73629 +
73630 +struct role_allowed_ip_compat {
73631 + __u32 addr;
73632 + __u32 netmask;
73633 +
73634 + compat_uptr_t prev;
73635 + compat_uptr_t next;
73636 +};
73637 +
73638 +struct role_transition_compat {
73639 + compat_uptr_t rolename;
73640 +
73641 + compat_uptr_t prev;
73642 + compat_uptr_t next;
73643 +};
73644 +
73645 +struct acl_role_label_compat {
73646 + compat_uptr_t rolename;
73647 + uid_t uidgid;
73648 + __u16 roletype;
73649 +
73650 + __u16 auth_attempts;
73651 + compat_ulong_t expires;
73652 +
73653 + compat_uptr_t root_label;
73654 + compat_uptr_t hash;
73655 +
73656 + compat_uptr_t prev;
73657 + compat_uptr_t next;
73658 +
73659 + compat_uptr_t transitions;
73660 + compat_uptr_t allowed_ips;
73661 + compat_uptr_t domain_children;
73662 + __u16 domain_child_num;
73663 +
73664 + umode_t umask;
73665 +
73666 + compat_uptr_t subj_hash;
73667 + __u32 subj_hash_size;
73668 +};
73669 +
73670 +struct user_acl_role_db_compat {
73671 + compat_uptr_t r_table;
73672 + __u32 num_pointers;
73673 + __u32 num_roles;
73674 + __u32 num_domain_children;
73675 + __u32 num_subjects;
73676 + __u32 num_objects;
73677 +};
73678 +
73679 +struct acl_object_label_compat {
73680 + compat_uptr_t filename;
73681 + compat_ino_t inode;
73682 + __u32 device;
73683 + __u32 mode;
73684 +
73685 + compat_uptr_t nested;
73686 + compat_uptr_t globbed;
73687 +
73688 + compat_uptr_t prev;
73689 + compat_uptr_t next;
73690 +};
73691 +
73692 +struct acl_ip_label_compat {
73693 + compat_uptr_t iface;
73694 + __u32 addr;
73695 + __u32 netmask;
73696 + __u16 low, high;
73697 + __u8 mode;
73698 + __u32 type;
73699 + __u32 proto[8];
73700 +
73701 + compat_uptr_t prev;
73702 + compat_uptr_t next;
73703 +};
73704 +
73705 +struct gr_arg_compat {
73706 + struct user_acl_role_db_compat role_db;
73707 + unsigned char pw[GR_PW_LEN];
73708 + unsigned char salt[GR_SALT_LEN];
73709 + unsigned char sum[GR_SHA_LEN];
73710 + unsigned char sp_role[GR_SPROLE_LEN];
73711 + compat_uptr_t sprole_pws;
73712 + __u32 segv_device;
73713 + compat_ino_t segv_inode;
73714 + uid_t segv_uid;
73715 + __u16 num_sprole_pws;
73716 + __u16 mode;
73717 +};
73718 +
73719 +struct gr_arg_wrapper_compat {
73720 + compat_uptr_t arg;
73721 + __u32 version;
73722 + __u32 size;
73723 +};
73724 +
73725 +#endif
73726 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
73727 new file mode 100644
73728 index 0000000..323ecf2
73729 --- /dev/null
73730 +++ b/include/linux/gralloc.h
73731 @@ -0,0 +1,9 @@
73732 +#ifndef __GRALLOC_H
73733 +#define __GRALLOC_H
73734 +
73735 +void acl_free_all(void);
73736 +int acl_alloc_stack_init(unsigned long size);
73737 +void *acl_alloc(unsigned long len);
73738 +void *acl_alloc_num(unsigned long num, unsigned long len);
73739 +
73740 +#endif
73741 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
73742 new file mode 100644
73743 index 0000000..be66033
73744 --- /dev/null
73745 +++ b/include/linux/grdefs.h
73746 @@ -0,0 +1,140 @@
73747 +#ifndef GRDEFS_H
73748 +#define GRDEFS_H
73749 +
73750 +/* Begin grsecurity status declarations */
73751 +
73752 +enum {
73753 + GR_READY = 0x01,
73754 + GR_STATUS_INIT = 0x00 // disabled state
73755 +};
73756 +
73757 +/* Begin ACL declarations */
73758 +
73759 +/* Role flags */
73760 +
73761 +enum {
73762 + GR_ROLE_USER = 0x0001,
73763 + GR_ROLE_GROUP = 0x0002,
73764 + GR_ROLE_DEFAULT = 0x0004,
73765 + GR_ROLE_SPECIAL = 0x0008,
73766 + GR_ROLE_AUTH = 0x0010,
73767 + GR_ROLE_NOPW = 0x0020,
73768 + GR_ROLE_GOD = 0x0040,
73769 + GR_ROLE_LEARN = 0x0080,
73770 + GR_ROLE_TPE = 0x0100,
73771 + GR_ROLE_DOMAIN = 0x0200,
73772 + GR_ROLE_PAM = 0x0400,
73773 + GR_ROLE_PERSIST = 0x0800
73774 +};
73775 +
73776 +/* ACL Subject and Object mode flags */
73777 +enum {
73778 + GR_DELETED = 0x80000000
73779 +};
73780 +
73781 +/* ACL Object-only mode flags */
73782 +enum {
73783 + GR_READ = 0x00000001,
73784 + GR_APPEND = 0x00000002,
73785 + GR_WRITE = 0x00000004,
73786 + GR_EXEC = 0x00000008,
73787 + GR_FIND = 0x00000010,
73788 + GR_INHERIT = 0x00000020,
73789 + GR_SETID = 0x00000040,
73790 + GR_CREATE = 0x00000080,
73791 + GR_DELETE = 0x00000100,
73792 + GR_LINK = 0x00000200,
73793 + GR_AUDIT_READ = 0x00000400,
73794 + GR_AUDIT_APPEND = 0x00000800,
73795 + GR_AUDIT_WRITE = 0x00001000,
73796 + GR_AUDIT_EXEC = 0x00002000,
73797 + GR_AUDIT_FIND = 0x00004000,
73798 + GR_AUDIT_INHERIT= 0x00008000,
73799 + GR_AUDIT_SETID = 0x00010000,
73800 + GR_AUDIT_CREATE = 0x00020000,
73801 + GR_AUDIT_DELETE = 0x00040000,
73802 + GR_AUDIT_LINK = 0x00080000,
73803 + GR_PTRACERD = 0x00100000,
73804 + GR_NOPTRACE = 0x00200000,
73805 + GR_SUPPRESS = 0x00400000,
73806 + GR_NOLEARN = 0x00800000,
73807 + GR_INIT_TRANSFER= 0x01000000
73808 +};
73809 +
73810 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
73811 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
73812 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
73813 +
73814 +/* ACL subject-only mode flags */
73815 +enum {
73816 + GR_KILL = 0x00000001,
73817 + GR_VIEW = 0x00000002,
73818 + GR_PROTECTED = 0x00000004,
73819 + GR_LEARN = 0x00000008,
73820 + GR_OVERRIDE = 0x00000010,
73821 + /* just a placeholder, this mode is only used in userspace */
73822 + GR_DUMMY = 0x00000020,
73823 + GR_PROTSHM = 0x00000040,
73824 + GR_KILLPROC = 0x00000080,
73825 + GR_KILLIPPROC = 0x00000100,
73826 + /* just a placeholder, this mode is only used in userspace */
73827 + GR_NOTROJAN = 0x00000200,
73828 + GR_PROTPROCFD = 0x00000400,
73829 + GR_PROCACCT = 0x00000800,
73830 + GR_RELAXPTRACE = 0x00001000,
73831 + //GR_NESTED = 0x00002000,
73832 + GR_INHERITLEARN = 0x00004000,
73833 + GR_PROCFIND = 0x00008000,
73834 + GR_POVERRIDE = 0x00010000,
73835 + GR_KERNELAUTH = 0x00020000,
73836 + GR_ATSECURE = 0x00040000,
73837 + GR_SHMEXEC = 0x00080000
73838 +};
73839 +
73840 +enum {
73841 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
73842 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
73843 + GR_PAX_ENABLE_MPROTECT = 0x0004,
73844 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
73845 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
73846 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
73847 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
73848 + GR_PAX_DISABLE_MPROTECT = 0x0400,
73849 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
73850 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
73851 +};
73852 +
73853 +enum {
73854 + GR_ID_USER = 0x01,
73855 + GR_ID_GROUP = 0x02,
73856 +};
73857 +
73858 +enum {
73859 + GR_ID_ALLOW = 0x01,
73860 + GR_ID_DENY = 0x02,
73861 +};
73862 +
73863 +#define GR_CRASH_RES 31
73864 +#define GR_UIDTABLE_MAX 500
73865 +
73866 +/* begin resource learning section */
73867 +enum {
73868 + GR_RLIM_CPU_BUMP = 60,
73869 + GR_RLIM_FSIZE_BUMP = 50000,
73870 + GR_RLIM_DATA_BUMP = 10000,
73871 + GR_RLIM_STACK_BUMP = 1000,
73872 + GR_RLIM_CORE_BUMP = 10000,
73873 + GR_RLIM_RSS_BUMP = 500000,
73874 + GR_RLIM_NPROC_BUMP = 1,
73875 + GR_RLIM_NOFILE_BUMP = 5,
73876 + GR_RLIM_MEMLOCK_BUMP = 50000,
73877 + GR_RLIM_AS_BUMP = 500000,
73878 + GR_RLIM_LOCKS_BUMP = 2,
73879 + GR_RLIM_SIGPENDING_BUMP = 5,
73880 + GR_RLIM_MSGQUEUE_BUMP = 10000,
73881 + GR_RLIM_NICE_BUMP = 1,
73882 + GR_RLIM_RTPRIO_BUMP = 1,
73883 + GR_RLIM_RTTIME_BUMP = 1000000
73884 +};
73885 +
73886 +#endif
73887 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
73888 new file mode 100644
73889 index 0000000..a5625be
73890 --- /dev/null
73891 +++ b/include/linux/grinternal.h
73892 @@ -0,0 +1,230 @@
73893 +#ifndef __GRINTERNAL_H
73894 +#define __GRINTERNAL_H
73895 +
73896 +#ifdef CONFIG_GRKERNSEC
73897 +
73898 +#include <linux/fs.h>
73899 +#include <linux/mnt_namespace.h>
73900 +#include <linux/nsproxy.h>
73901 +#include <linux/gracl.h>
73902 +#include <linux/grdefs.h>
73903 +#include <linux/grmsg.h>
73904 +
73905 +void gr_add_learn_entry(const char *fmt, ...)
73906 + __attribute__ ((format (printf, 1, 2)));
73907 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
73908 + const struct vfsmount *mnt);
73909 +__u32 gr_check_create(const struct dentry *new_dentry,
73910 + const struct dentry *parent,
73911 + const struct vfsmount *mnt, const __u32 mode);
73912 +int gr_check_protected_task(const struct task_struct *task);
73913 +__u32 to_gr_audit(const __u32 reqmode);
73914 +int gr_set_acls(const int type);
73915 +int gr_apply_subject_to_task(struct task_struct *task);
73916 +int gr_acl_is_enabled(void);
73917 +char gr_roletype_to_char(void);
73918 +
73919 +void gr_handle_alertkill(struct task_struct *task);
73920 +char *gr_to_filename(const struct dentry *dentry,
73921 + const struct vfsmount *mnt);
73922 +char *gr_to_filename1(const struct dentry *dentry,
73923 + const struct vfsmount *mnt);
73924 +char *gr_to_filename2(const struct dentry *dentry,
73925 + const struct vfsmount *mnt);
73926 +char *gr_to_filename3(const struct dentry *dentry,
73927 + const struct vfsmount *mnt);
73928 +
73929 +extern int grsec_enable_ptrace_readexec;
73930 +extern int grsec_enable_harden_ptrace;
73931 +extern int grsec_enable_link;
73932 +extern int grsec_enable_fifo;
73933 +extern int grsec_enable_execve;
73934 +extern int grsec_enable_shm;
73935 +extern int grsec_enable_execlog;
73936 +extern int grsec_enable_signal;
73937 +extern int grsec_enable_audit_ptrace;
73938 +extern int grsec_enable_forkfail;
73939 +extern int grsec_enable_time;
73940 +extern int grsec_enable_rofs;
73941 +extern int grsec_deny_new_usb;
73942 +extern int grsec_enable_chroot_shmat;
73943 +extern int grsec_enable_chroot_mount;
73944 +extern int grsec_enable_chroot_double;
73945 +extern int grsec_enable_chroot_pivot;
73946 +extern int grsec_enable_chroot_chdir;
73947 +extern int grsec_enable_chroot_chmod;
73948 +extern int grsec_enable_chroot_mknod;
73949 +extern int grsec_enable_chroot_fchdir;
73950 +extern int grsec_enable_chroot_nice;
73951 +extern int grsec_enable_chroot_execlog;
73952 +extern int grsec_enable_chroot_caps;
73953 +extern int grsec_enable_chroot_sysctl;
73954 +extern int grsec_enable_chroot_unix;
73955 +extern int grsec_enable_symlinkown;
73956 +extern kgid_t grsec_symlinkown_gid;
73957 +extern int grsec_enable_tpe;
73958 +extern kgid_t grsec_tpe_gid;
73959 +extern int grsec_enable_tpe_all;
73960 +extern int grsec_enable_tpe_invert;
73961 +extern int grsec_enable_socket_all;
73962 +extern kgid_t grsec_socket_all_gid;
73963 +extern int grsec_enable_socket_client;
73964 +extern kgid_t grsec_socket_client_gid;
73965 +extern int grsec_enable_socket_server;
73966 +extern kgid_t grsec_socket_server_gid;
73967 +extern kgid_t grsec_audit_gid;
73968 +extern int grsec_enable_group;
73969 +extern int grsec_enable_log_rwxmaps;
73970 +extern int grsec_enable_mount;
73971 +extern int grsec_enable_chdir;
73972 +extern int grsec_resource_logging;
73973 +extern int grsec_enable_blackhole;
73974 +extern int grsec_lastack_retries;
73975 +extern int grsec_enable_brute;
73976 +extern int grsec_enable_harden_ipc;
73977 +extern int grsec_lock;
73978 +
73979 +extern spinlock_t grsec_alert_lock;
73980 +extern unsigned long grsec_alert_wtime;
73981 +extern unsigned long grsec_alert_fyet;
73982 +
73983 +extern spinlock_t grsec_audit_lock;
73984 +
73985 +extern rwlock_t grsec_exec_file_lock;
73986 +
73987 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
73988 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
73989 + (tsk)->exec_file->f_path.mnt) : "/")
73990 +
73991 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
73992 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
73993 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
73994 +
73995 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
73996 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
73997 + (tsk)->exec_file->f_path.mnt) : "/")
73998 +
73999 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
74000 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
74001 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74002 +
74003 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
74004 +
74005 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
74006 +
74007 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
74008 +{
74009 + if (file1 && file2) {
74010 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
74011 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
74012 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
74013 + return true;
74014 + }
74015 +
74016 + return false;
74017 +}
74018 +
74019 +#define GR_CHROOT_CAPS {{ \
74020 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
74021 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
74022 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
74023 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
74024 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
74025 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
74026 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
74027 +
74028 +#define security_learn(normal_msg,args...) \
74029 +({ \
74030 + read_lock(&grsec_exec_file_lock); \
74031 + gr_add_learn_entry(normal_msg "\n", ## args); \
74032 + read_unlock(&grsec_exec_file_lock); \
74033 +})
74034 +
74035 +enum {
74036 + GR_DO_AUDIT,
74037 + GR_DONT_AUDIT,
74038 + /* used for non-audit messages that we shouldn't kill the task on */
74039 + GR_DONT_AUDIT_GOOD
74040 +};
74041 +
74042 +enum {
74043 + GR_TTYSNIFF,
74044 + GR_RBAC,
74045 + GR_RBAC_STR,
74046 + GR_STR_RBAC,
74047 + GR_RBAC_MODE2,
74048 + GR_RBAC_MODE3,
74049 + GR_FILENAME,
74050 + GR_SYSCTL_HIDDEN,
74051 + GR_NOARGS,
74052 + GR_ONE_INT,
74053 + GR_ONE_INT_TWO_STR,
74054 + GR_ONE_STR,
74055 + GR_STR_INT,
74056 + GR_TWO_STR_INT,
74057 + GR_TWO_INT,
74058 + GR_TWO_U64,
74059 + GR_THREE_INT,
74060 + GR_FIVE_INT_TWO_STR,
74061 + GR_TWO_STR,
74062 + GR_THREE_STR,
74063 + GR_FOUR_STR,
74064 + GR_STR_FILENAME,
74065 + GR_FILENAME_STR,
74066 + GR_FILENAME_TWO_INT,
74067 + GR_FILENAME_TWO_INT_STR,
74068 + GR_TEXTREL,
74069 + GR_PTRACE,
74070 + GR_RESOURCE,
74071 + GR_CAP,
74072 + GR_SIG,
74073 + GR_SIG2,
74074 + GR_CRASH1,
74075 + GR_CRASH2,
74076 + GR_PSACCT,
74077 + GR_RWXMAP,
74078 + GR_RWXMAPVMA
74079 +};
74080 +
74081 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
74082 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
74083 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
74084 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
74085 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
74086 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
74087 +#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)
74088 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
74089 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
74090 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
74091 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
74092 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
74093 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
74094 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
74095 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
74096 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
74097 +#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)
74098 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
74099 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
74100 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
74101 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
74102 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
74103 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
74104 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
74105 +#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)
74106 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
74107 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
74108 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
74109 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
74110 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
74111 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
74112 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
74113 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
74114 +#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)
74115 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
74116 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
74117 +
74118 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
74119 +
74120 +#endif
74121 +
74122 +#endif
74123 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
74124 new file mode 100644
74125 index 0000000..378a81a
74126 --- /dev/null
74127 +++ b/include/linux/grmsg.h
74128 @@ -0,0 +1,114 @@
74129 +#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"
74130 +#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"
74131 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
74132 +#define GR_STOPMOD_MSG "denied modification of module state by "
74133 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
74134 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
74135 +#define GR_IOPERM_MSG "denied use of ioperm() by "
74136 +#define GR_IOPL_MSG "denied use of iopl() by "
74137 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
74138 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
74139 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
74140 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
74141 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
74142 +#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"
74143 +#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"
74144 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
74145 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
74146 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
74147 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
74148 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
74149 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
74150 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
74151 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
74152 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
74153 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
74154 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
74155 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
74156 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
74157 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
74158 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
74159 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
74160 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
74161 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
74162 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
74163 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
74164 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
74165 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
74166 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
74167 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
74168 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
74169 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
74170 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
74171 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
74172 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
74173 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
74174 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
74175 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
74176 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
74177 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
74178 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
74179 +#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"
74180 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
74181 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
74182 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
74183 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
74184 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
74185 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
74186 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
74187 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
74188 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
74189 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
74190 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
74191 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
74192 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
74193 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
74194 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
74195 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
74196 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
74197 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
74198 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
74199 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
74200 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
74201 +#define GR_NICE_CHROOT_MSG "denied priority change by "
74202 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
74203 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
74204 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
74205 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
74206 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
74207 +#define GR_TIME_MSG "time set by "
74208 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
74209 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
74210 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
74211 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
74212 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
74213 +#define GR_BIND_MSG "denied bind() by "
74214 +#define GR_CONNECT_MSG "denied connect() by "
74215 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
74216 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
74217 +#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"
74218 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
74219 +#define GR_CAP_ACL_MSG "use of %s denied for "
74220 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
74221 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
74222 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
74223 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
74224 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
74225 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
74226 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
74227 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
74228 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
74229 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
74230 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
74231 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
74232 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
74233 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
74234 +#define GR_VM86_MSG "denied use of vm86 by "
74235 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
74236 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
74237 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
74238 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
74239 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
74240 +#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 "
74241 +#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 "
74242 +#define GR_IPC_DENIED_MSG "denied %s of globally-%sable IPC with creator uid %u by "
74243 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
74244 new file mode 100644
74245 index 0000000..d6f5a21
74246 --- /dev/null
74247 +++ b/include/linux/grsecurity.h
74248 @@ -0,0 +1,244 @@
74249 +#ifndef GR_SECURITY_H
74250 +#define GR_SECURITY_H
74251 +#include <linux/fs.h>
74252 +#include <linux/fs_struct.h>
74253 +#include <linux/binfmts.h>
74254 +#include <linux/gracl.h>
74255 +
74256 +/* notify of brain-dead configs */
74257 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74258 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
74259 +#endif
74260 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
74261 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
74262 +#endif
74263 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
74264 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
74265 +#endif
74266 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
74267 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
74268 +#endif
74269 +
74270 +int gr_handle_new_usb(void);
74271 +
74272 +void gr_handle_brute_attach(unsigned long mm_flags);
74273 +void gr_handle_brute_check(void);
74274 +void gr_handle_kernel_exploit(void);
74275 +
74276 +char gr_roletype_to_char(void);
74277 +
74278 +int gr_acl_enable_at_secure(void);
74279 +
74280 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
74281 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
74282 +
74283 +void gr_del_task_from_ip_table(struct task_struct *p);
74284 +
74285 +int gr_pid_is_chrooted(struct task_struct *p);
74286 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
74287 +int gr_handle_chroot_nice(void);
74288 +int gr_handle_chroot_sysctl(const int op);
74289 +int gr_handle_chroot_setpriority(struct task_struct *p,
74290 + const int niceval);
74291 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
74292 +int gr_handle_chroot_chroot(const struct dentry *dentry,
74293 + const struct vfsmount *mnt);
74294 +void gr_handle_chroot_chdir(const struct path *path);
74295 +int gr_handle_chroot_chmod(const struct dentry *dentry,
74296 + const struct vfsmount *mnt, const int mode);
74297 +int gr_handle_chroot_mknod(const struct dentry *dentry,
74298 + const struct vfsmount *mnt, const int mode);
74299 +int gr_handle_chroot_mount(const struct dentry *dentry,
74300 + const struct vfsmount *mnt,
74301 + const char *dev_name);
74302 +int gr_handle_chroot_pivot(void);
74303 +int gr_handle_chroot_unix(const pid_t pid);
74304 +
74305 +int gr_handle_rawio(const struct inode *inode);
74306 +
74307 +void gr_handle_ioperm(void);
74308 +void gr_handle_iopl(void);
74309 +
74310 +umode_t gr_acl_umask(void);
74311 +
74312 +int gr_tpe_allow(const struct file *file);
74313 +
74314 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
74315 +void gr_clear_chroot_entries(struct task_struct *task);
74316 +
74317 +void gr_log_forkfail(const int retval);
74318 +void gr_log_timechange(void);
74319 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
74320 +void gr_log_chdir(const struct dentry *dentry,
74321 + const struct vfsmount *mnt);
74322 +void gr_log_chroot_exec(const struct dentry *dentry,
74323 + const struct vfsmount *mnt);
74324 +void gr_log_remount(const char *devname, const int retval);
74325 +void gr_log_unmount(const char *devname, const int retval);
74326 +void gr_log_mount(const char *from, const char *to, const int retval);
74327 +void gr_log_textrel(struct vm_area_struct *vma);
74328 +void gr_log_ptgnustack(struct file *file);
74329 +void gr_log_rwxmmap(struct file *file);
74330 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
74331 +
74332 +int gr_handle_follow_link(const struct inode *parent,
74333 + const struct inode *inode,
74334 + const struct dentry *dentry,
74335 + const struct vfsmount *mnt);
74336 +int gr_handle_fifo(const struct dentry *dentry,
74337 + const struct vfsmount *mnt,
74338 + const struct dentry *dir, const int flag,
74339 + const int acc_mode);
74340 +int gr_handle_hardlink(const struct dentry *dentry,
74341 + const struct vfsmount *mnt,
74342 + struct inode *inode,
74343 + const int mode, const struct filename *to);
74344 +
74345 +int gr_is_capable(const int cap);
74346 +int gr_is_capable_nolog(const int cap);
74347 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
74348 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
74349 +
74350 +void gr_copy_label(struct task_struct *tsk);
74351 +void gr_handle_crash(struct task_struct *task, const int sig);
74352 +int gr_handle_signal(const struct task_struct *p, const int sig);
74353 +int gr_check_crash_uid(const kuid_t uid);
74354 +int gr_check_protected_task(const struct task_struct *task);
74355 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
74356 +int gr_acl_handle_mmap(const struct file *file,
74357 + const unsigned long prot);
74358 +int gr_acl_handle_mprotect(const struct file *file,
74359 + const unsigned long prot);
74360 +int gr_check_hidden_task(const struct task_struct *tsk);
74361 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
74362 + const struct vfsmount *mnt);
74363 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
74364 + const struct vfsmount *mnt);
74365 +__u32 gr_acl_handle_access(const struct dentry *dentry,
74366 + const struct vfsmount *mnt, const int fmode);
74367 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
74368 + const struct vfsmount *mnt, umode_t *mode);
74369 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
74370 + const struct vfsmount *mnt);
74371 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
74372 + const struct vfsmount *mnt);
74373 +int gr_handle_ptrace(struct task_struct *task, const long request);
74374 +int gr_handle_proc_ptrace(struct task_struct *task);
74375 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
74376 + const struct vfsmount *mnt);
74377 +int gr_check_crash_exec(const struct file *filp);
74378 +int gr_acl_is_enabled(void);
74379 +void gr_set_kernel_label(struct task_struct *task);
74380 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
74381 + const kgid_t gid);
74382 +int gr_set_proc_label(const struct dentry *dentry,
74383 + const struct vfsmount *mnt,
74384 + const int unsafe_flags);
74385 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
74386 + const struct vfsmount *mnt);
74387 +__u32 gr_acl_handle_open(const struct dentry *dentry,
74388 + const struct vfsmount *mnt, int acc_mode);
74389 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
74390 + const struct dentry *p_dentry,
74391 + const struct vfsmount *p_mnt,
74392 + int open_flags, int acc_mode, const int imode);
74393 +void gr_handle_create(const struct dentry *dentry,
74394 + const struct vfsmount *mnt);
74395 +void gr_handle_proc_create(const struct dentry *dentry,
74396 + const struct inode *inode);
74397 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
74398 + const struct dentry *parent_dentry,
74399 + const struct vfsmount *parent_mnt,
74400 + const int mode);
74401 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
74402 + const struct dentry *parent_dentry,
74403 + const struct vfsmount *parent_mnt);
74404 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
74405 + const struct vfsmount *mnt);
74406 +void gr_handle_delete(const ino_t ino, const dev_t dev);
74407 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
74408 + const struct vfsmount *mnt);
74409 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
74410 + const struct dentry *parent_dentry,
74411 + const struct vfsmount *parent_mnt,
74412 + const struct filename *from);
74413 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
74414 + const struct dentry *parent_dentry,
74415 + const struct vfsmount *parent_mnt,
74416 + const struct dentry *old_dentry,
74417 + const struct vfsmount *old_mnt, const struct filename *to);
74418 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
74419 +int gr_acl_handle_rename(struct dentry *new_dentry,
74420 + struct dentry *parent_dentry,
74421 + const struct vfsmount *parent_mnt,
74422 + struct dentry *old_dentry,
74423 + struct inode *old_parent_inode,
74424 + struct vfsmount *old_mnt, const struct filename *newname);
74425 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
74426 + struct dentry *old_dentry,
74427 + struct dentry *new_dentry,
74428 + struct vfsmount *mnt, const __u8 replace);
74429 +__u32 gr_check_link(const struct dentry *new_dentry,
74430 + const struct dentry *parent_dentry,
74431 + const struct vfsmount *parent_mnt,
74432 + const struct dentry *old_dentry,
74433 + const struct vfsmount *old_mnt);
74434 +int gr_acl_handle_filldir(const struct file *file, const char *name,
74435 + const unsigned int namelen, const ino_t ino);
74436 +
74437 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
74438 + const struct vfsmount *mnt);
74439 +void gr_acl_handle_exit(void);
74440 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
74441 +int gr_acl_handle_procpidmem(const struct task_struct *task);
74442 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
74443 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
74444 +void gr_audit_ptrace(struct task_struct *task);
74445 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
74446 +void gr_put_exec_file(struct task_struct *task);
74447 +
74448 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
74449 +
74450 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
74451 +extern void gr_learn_resource(const struct task_struct *task, const int res,
74452 + const unsigned long wanted, const int gt);
74453 +#else
74454 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
74455 + const unsigned long wanted, const int gt)
74456 +{
74457 +}
74458 +#endif
74459 +
74460 +#ifdef CONFIG_GRKERNSEC_RESLOG
74461 +extern void gr_log_resource(const struct task_struct *task, const int res,
74462 + const unsigned long wanted, const int gt);
74463 +#else
74464 +static inline void gr_log_resource(const struct task_struct *task, const int res,
74465 + const unsigned long wanted, const int gt)
74466 +{
74467 +}
74468 +#endif
74469 +
74470 +#ifdef CONFIG_GRKERNSEC
74471 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
74472 +void gr_handle_vm86(void);
74473 +void gr_handle_mem_readwrite(u64 from, u64 to);
74474 +
74475 +void gr_log_badprocpid(const char *entry);
74476 +
74477 +extern int grsec_enable_dmesg;
74478 +extern int grsec_disable_privio;
74479 +
74480 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74481 +extern kgid_t grsec_proc_gid;
74482 +#endif
74483 +
74484 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
74485 +extern int grsec_enable_chroot_findtask;
74486 +#endif
74487 +#ifdef CONFIG_GRKERNSEC_SETXID
74488 +extern int grsec_enable_setxid;
74489 +#endif
74490 +#endif
74491 +
74492 +#endif
74493 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
74494 new file mode 100644
74495 index 0000000..e7ffaaf
74496 --- /dev/null
74497 +++ b/include/linux/grsock.h
74498 @@ -0,0 +1,19 @@
74499 +#ifndef __GRSOCK_H
74500 +#define __GRSOCK_H
74501 +
74502 +extern void gr_attach_curr_ip(const struct sock *sk);
74503 +extern int gr_handle_sock_all(const int family, const int type,
74504 + const int protocol);
74505 +extern int gr_handle_sock_server(const struct sockaddr *sck);
74506 +extern int gr_handle_sock_server_other(const struct sock *sck);
74507 +extern int gr_handle_sock_client(const struct sockaddr *sck);
74508 +extern int gr_search_connect(struct socket * sock,
74509 + struct sockaddr_in * addr);
74510 +extern int gr_search_bind(struct socket * sock,
74511 + struct sockaddr_in * addr);
74512 +extern int gr_search_listen(struct socket * sock);
74513 +extern int gr_search_accept(struct socket * sock);
74514 +extern int gr_search_socket(const int domain, const int type,
74515 + const int protocol);
74516 +
74517 +#endif
74518 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
74519 index 7fb31da..08b5114 100644
74520 --- a/include/linux/highmem.h
74521 +++ b/include/linux/highmem.h
74522 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
74523 kunmap_atomic(kaddr);
74524 }
74525
74526 +static inline void sanitize_highpage(struct page *page)
74527 +{
74528 + void *kaddr;
74529 + unsigned long flags;
74530 +
74531 + local_irq_save(flags);
74532 + kaddr = kmap_atomic(page);
74533 + clear_page(kaddr);
74534 + kunmap_atomic(kaddr);
74535 + local_irq_restore(flags);
74536 +}
74537 +
74538 static inline void zero_user_segments(struct page *page,
74539 unsigned start1, unsigned end1,
74540 unsigned start2, unsigned end2)
74541 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
74542 index 1c7b89a..7f52502 100644
74543 --- a/include/linux/hwmon-sysfs.h
74544 +++ b/include/linux/hwmon-sysfs.h
74545 @@ -25,7 +25,8 @@
74546 struct sensor_device_attribute{
74547 struct device_attribute dev_attr;
74548 int index;
74549 -};
74550 +} __do_const;
74551 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
74552 #define to_sensor_dev_attr(_dev_attr) \
74553 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
74554
74555 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
74556 struct device_attribute dev_attr;
74557 u8 index;
74558 u8 nr;
74559 -};
74560 +} __do_const;
74561 #define to_sensor_dev_attr_2(_dev_attr) \
74562 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
74563
74564 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
74565 index e988fa9..ff9f17e 100644
74566 --- a/include/linux/i2c.h
74567 +++ b/include/linux/i2c.h
74568 @@ -366,6 +366,7 @@ struct i2c_algorithm {
74569 /* To determine what the adapter supports */
74570 u32 (*functionality) (struct i2c_adapter *);
74571 };
74572 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
74573
74574 /**
74575 * struct i2c_bus_recovery_info - I2C bus recovery information
74576 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
74577 index d23c3c2..eb63c81 100644
74578 --- a/include/linux/i2o.h
74579 +++ b/include/linux/i2o.h
74580 @@ -565,7 +565,7 @@ struct i2o_controller {
74581 struct i2o_device *exec; /* Executive */
74582 #if BITS_PER_LONG == 64
74583 spinlock_t context_list_lock; /* lock for context_list */
74584 - atomic_t context_list_counter; /* needed for unique contexts */
74585 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
74586 struct list_head context_list; /* list of context id's
74587 and pointers */
74588 #endif
74589 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
74590 index aff7ad8..3942bbd 100644
74591 --- a/include/linux/if_pppox.h
74592 +++ b/include/linux/if_pppox.h
74593 @@ -76,7 +76,7 @@ struct pppox_proto {
74594 int (*ioctl)(struct socket *sock, unsigned int cmd,
74595 unsigned long arg);
74596 struct module *owner;
74597 -};
74598 +} __do_const;
74599
74600 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
74601 extern void unregister_pppox_proto(int proto_num);
74602 diff --git a/include/linux/init.h b/include/linux/init.h
74603 index e73f2b7..cc996e0 100644
74604 --- a/include/linux/init.h
74605 +++ b/include/linux/init.h
74606 @@ -39,9 +39,17 @@
74607 * Also note, that this data cannot be "const".
74608 */
74609
74610 +#define add_init_latent_entropy __latent_entropy
74611 +
74612 +#ifdef CONFIG_MEMORY_HOTPLUG
74613 +#define add_meminit_latent_entropy
74614 +#else
74615 +#define add_meminit_latent_entropy __latent_entropy
74616 +#endif
74617 +
74618 /* These are for everybody (although not all archs will actually
74619 discard it in modules) */
74620 -#define __init __section(.init.text) __cold notrace
74621 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
74622 #define __initdata __section(.init.data)
74623 #define __initconst __constsection(.init.rodata)
74624 #define __exitdata __section(.exit.data)
74625 @@ -102,7 +110,7 @@
74626 #define __cpuexitconst
74627
74628 /* Used for MEMORY_HOTPLUG */
74629 -#define __meminit __section(.meminit.text) __cold notrace
74630 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
74631 #define __meminitdata __section(.meminit.data)
74632 #define __meminitconst __constsection(.meminit.rodata)
74633 #define __memexit __section(.memexit.text) __exitused __cold notrace
74634 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
74635 index 5cd0f09..c9f67cc 100644
74636 --- a/include/linux/init_task.h
74637 +++ b/include/linux/init_task.h
74638 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
74639
74640 #define INIT_TASK_COMM "swapper"
74641
74642 +#ifdef CONFIG_X86
74643 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
74644 +#else
74645 +#define INIT_TASK_THREAD_INFO
74646 +#endif
74647 +
74648 /*
74649 * INIT_TASK is used to set up the first task table, touch at
74650 * your own risk!. Base=0, limit=0x1fffff (=2MB)
74651 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
74652 RCU_POINTER_INITIALIZER(cred, &init_cred), \
74653 .comm = INIT_TASK_COMM, \
74654 .thread = INIT_THREAD, \
74655 + INIT_TASK_THREAD_INFO \
74656 .fs = &init_fs, \
74657 .files = &init_files, \
74658 .signal = &init_signals, \
74659 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
74660 index 5fa5afe..ac55b25 100644
74661 --- a/include/linux/interrupt.h
74662 +++ b/include/linux/interrupt.h
74663 @@ -430,7 +430,7 @@ enum
74664 /* map softirq index to softirq name. update 'softirq_to_name' in
74665 * kernel/softirq.c when adding a new softirq.
74666 */
74667 -extern char *softirq_to_name[NR_SOFTIRQS];
74668 +extern const char * const softirq_to_name[NR_SOFTIRQS];
74669
74670 /* softirq mask and active fields moved to irq_cpustat_t in
74671 * asm/hardirq.h to get better cache usage. KAO
74672 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
74673
74674 struct softirq_action
74675 {
74676 - void (*action)(struct softirq_action *);
74677 -};
74678 + void (*action)(void);
74679 +} __no_const;
74680
74681 asmlinkage void do_softirq(void);
74682 asmlinkage void __do_softirq(void);
74683 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
74684 +extern void open_softirq(int nr, void (*action)(void));
74685 extern void softirq_init(void);
74686 extern void __raise_softirq_irqoff(unsigned int nr);
74687
74688 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
74689 index 3aeb730..2177f39 100644
74690 --- a/include/linux/iommu.h
74691 +++ b/include/linux/iommu.h
74692 @@ -113,7 +113,7 @@ struct iommu_ops {
74693 u32 (*domain_get_windows)(struct iommu_domain *domain);
74694
74695 unsigned long pgsize_bitmap;
74696 -};
74697 +} __do_const;
74698
74699 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
74700 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
74701 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
74702 index 89b7c24..382af74 100644
74703 --- a/include/linux/ioport.h
74704 +++ b/include/linux/ioport.h
74705 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
74706 int adjust_resource(struct resource *res, resource_size_t start,
74707 resource_size_t size);
74708 resource_size_t resource_alignment(struct resource *res);
74709 -static inline resource_size_t resource_size(const struct resource *res)
74710 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
74711 {
74712 return res->end - res->start + 1;
74713 }
74714 diff --git a/include/linux/irq.h b/include/linux/irq.h
74715 index f04d3ba..bcf2cfb 100644
74716 --- a/include/linux/irq.h
74717 +++ b/include/linux/irq.h
74718 @@ -333,7 +333,8 @@ struct irq_chip {
74719 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
74720
74721 unsigned long flags;
74722 -};
74723 +} __do_const;
74724 +typedef struct irq_chip __no_const irq_chip_no_const;
74725
74726 /*
74727 * irq_chip specific flags
74728 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
74729 index 3e203eb..3fe68d0 100644
74730 --- a/include/linux/irqchip/arm-gic.h
74731 +++ b/include/linux/irqchip/arm-gic.h
74732 @@ -59,9 +59,11 @@
74733
74734 #ifndef __ASSEMBLY__
74735
74736 +#include <linux/irq.h>
74737 +
74738 struct device_node;
74739
74740 -extern struct irq_chip gic_arch_extn;
74741 +extern irq_chip_no_const gic_arch_extn;
74742
74743 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
74744 u32 offset, struct device_node *);
74745 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
74746 index 6883e19..e854fcb 100644
74747 --- a/include/linux/kallsyms.h
74748 +++ b/include/linux/kallsyms.h
74749 @@ -15,7 +15,8 @@
74750
74751 struct module;
74752
74753 -#ifdef CONFIG_KALLSYMS
74754 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
74755 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
74756 /* Lookup the address for a symbol. Returns 0 if not found. */
74757 unsigned long kallsyms_lookup_name(const char *name);
74758
74759 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
74760 /* Stupid that this does nothing, but I didn't create this mess. */
74761 #define __print_symbol(fmt, addr)
74762 #endif /*CONFIG_KALLSYMS*/
74763 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
74764 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
74765 +extern unsigned long kallsyms_lookup_name(const char *name);
74766 +extern void __print_symbol(const char *fmt, unsigned long address);
74767 +extern int sprint_backtrace(char *buffer, unsigned long address);
74768 +extern int sprint_symbol(char *buffer, unsigned long address);
74769 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
74770 +const char *kallsyms_lookup(unsigned long addr,
74771 + unsigned long *symbolsize,
74772 + unsigned long *offset,
74773 + char **modname, char *namebuf);
74774 +extern int kallsyms_lookup_size_offset(unsigned long addr,
74775 + unsigned long *symbolsize,
74776 + unsigned long *offset);
74777 +#endif
74778
74779 /* This macro allows us to keep printk typechecking */
74780 static __printf(1, 2)
74781 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
74782 index 518a53a..5e28358 100644
74783 --- a/include/linux/key-type.h
74784 +++ b/include/linux/key-type.h
74785 @@ -125,7 +125,7 @@ struct key_type {
74786 /* internal fields */
74787 struct list_head link; /* link in types list */
74788 struct lock_class_key lock_class; /* key->sem lock class */
74789 -};
74790 +} __do_const;
74791
74792 extern struct key_type key_type_keyring;
74793
74794 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
74795 index c6e091b..a940adf 100644
74796 --- a/include/linux/kgdb.h
74797 +++ b/include/linux/kgdb.h
74798 @@ -52,7 +52,7 @@ extern int kgdb_connected;
74799 extern int kgdb_io_module_registered;
74800
74801 extern atomic_t kgdb_setting_breakpoint;
74802 -extern atomic_t kgdb_cpu_doing_single_step;
74803 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
74804
74805 extern struct task_struct *kgdb_usethread;
74806 extern struct task_struct *kgdb_contthread;
74807 @@ -254,7 +254,7 @@ struct kgdb_arch {
74808 void (*correct_hw_break)(void);
74809
74810 void (*enable_nmi)(bool on);
74811 -};
74812 +} __do_const;
74813
74814 /**
74815 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
74816 @@ -279,7 +279,7 @@ struct kgdb_io {
74817 void (*pre_exception) (void);
74818 void (*post_exception) (void);
74819 int is_console;
74820 -};
74821 +} __do_const;
74822
74823 extern struct kgdb_arch arch_kgdb_ops;
74824
74825 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
74826 index 0555cc6..b16a7a4 100644
74827 --- a/include/linux/kmod.h
74828 +++ b/include/linux/kmod.h
74829 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
74830 * usually useless though. */
74831 extern __printf(2, 3)
74832 int __request_module(bool wait, const char *name, ...);
74833 +extern __printf(3, 4)
74834 +int ___request_module(bool wait, char *param_name, const char *name, ...);
74835 #define request_module(mod...) __request_module(true, mod)
74836 #define request_module_nowait(mod...) __request_module(false, mod)
74837 #define try_then_request_module(x, mod...) \
74838 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
74839 index 939b112..ed6ed51 100644
74840 --- a/include/linux/kobject.h
74841 +++ b/include/linux/kobject.h
74842 @@ -111,7 +111,7 @@ struct kobj_type {
74843 struct attribute **default_attrs;
74844 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
74845 const void *(*namespace)(struct kobject *kobj);
74846 -};
74847 +} __do_const;
74848
74849 struct kobj_uevent_env {
74850 char *envp[UEVENT_NUM_ENVP];
74851 @@ -134,6 +134,7 @@ struct kobj_attribute {
74852 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
74853 const char *buf, size_t count);
74854 };
74855 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
74856
74857 extern const struct sysfs_ops kobj_sysfs_ops;
74858
74859 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
74860 index f66b065..c2c29b4 100644
74861 --- a/include/linux/kobject_ns.h
74862 +++ b/include/linux/kobject_ns.h
74863 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
74864 const void *(*netlink_ns)(struct sock *sk);
74865 const void *(*initial_ns)(void);
74866 void (*drop_ns)(void *);
74867 -};
74868 +} __do_const;
74869
74870 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
74871 int kobj_ns_type_registered(enum kobj_ns_type type);
74872 diff --git a/include/linux/kref.h b/include/linux/kref.h
74873 index 484604d..0f6c5b6 100644
74874 --- a/include/linux/kref.h
74875 +++ b/include/linux/kref.h
74876 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
74877 static inline int kref_sub(struct kref *kref, unsigned int count,
74878 void (*release)(struct kref *kref))
74879 {
74880 - WARN_ON(release == NULL);
74881 + BUG_ON(release == NULL);
74882
74883 if (atomic_sub_and_test((int) count, &kref->refcount)) {
74884 release(kref);
74885 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
74886 index a63d83e..77fd685 100644
74887 --- a/include/linux/kvm_host.h
74888 +++ b/include/linux/kvm_host.h
74889 @@ -446,7 +446,7 @@ static inline void kvm_irqfd_exit(void)
74890 {
74891 }
74892 #endif
74893 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74894 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74895 struct module *module);
74896 void kvm_exit(void);
74897
74898 @@ -618,7 +618,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
74899 struct kvm_guest_debug *dbg);
74900 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
74901
74902 -int kvm_arch_init(void *opaque);
74903 +int kvm_arch_init(const void *opaque);
74904 void kvm_arch_exit(void);
74905
74906 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
74907 diff --git a/include/linux/libata.h b/include/linux/libata.h
74908 index 4ea55bb..dcd2601 100644
74909 --- a/include/linux/libata.h
74910 +++ b/include/linux/libata.h
74911 @@ -924,7 +924,7 @@ struct ata_port_operations {
74912 * fields must be pointers.
74913 */
74914 const struct ata_port_operations *inherits;
74915 -};
74916 +} __do_const;
74917
74918 struct ata_port_info {
74919 unsigned long flags;
74920 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
74921 index d3e8ad2..a949f68 100644
74922 --- a/include/linux/linkage.h
74923 +++ b/include/linux/linkage.h
74924 @@ -31,6 +31,7 @@
74925 #endif
74926
74927 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
74928 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
74929 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
74930
74931 /*
74932 diff --git a/include/linux/list.h b/include/linux/list.h
74933 index f4d8a2f..38e6e46 100644
74934 --- a/include/linux/list.h
74935 +++ b/include/linux/list.h
74936 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
74937 extern void list_del(struct list_head *entry);
74938 #endif
74939
74940 +extern void __pax_list_add(struct list_head *new,
74941 + struct list_head *prev,
74942 + struct list_head *next);
74943 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
74944 +{
74945 + __pax_list_add(new, head, head->next);
74946 +}
74947 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
74948 +{
74949 + __pax_list_add(new, head->prev, head);
74950 +}
74951 +extern void pax_list_del(struct list_head *entry);
74952 +
74953 /**
74954 * list_replace - replace old entry by new one
74955 * @old : the element to be replaced
74956 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
74957 INIT_LIST_HEAD(entry);
74958 }
74959
74960 +extern void pax_list_del_init(struct list_head *entry);
74961 +
74962 /**
74963 * list_move - delete from one list and add as another's head
74964 * @list: the entry to move
74965 diff --git a/include/linux/math64.h b/include/linux/math64.h
74966 index 2913b86..8dcbb1e 100644
74967 --- a/include/linux/math64.h
74968 +++ b/include/linux/math64.h
74969 @@ -15,7 +15,7 @@
74970 * This is commonly provided by 32bit archs to provide an optimized 64bit
74971 * divide.
74972 */
74973 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74974 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74975 {
74976 *remainder = dividend % divisor;
74977 return dividend / divisor;
74978 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
74979 /**
74980 * div64_u64 - unsigned 64bit divide with 64bit divisor
74981 */
74982 -static inline u64 div64_u64(u64 dividend, u64 divisor)
74983 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
74984 {
74985 return dividend / divisor;
74986 }
74987 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
74988 #define div64_ul(x, y) div_u64((x), (y))
74989
74990 #ifndef div_u64_rem
74991 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74992 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74993 {
74994 *remainder = do_div(dividend, divisor);
74995 return dividend;
74996 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
74997 * divide.
74998 */
74999 #ifndef div_u64
75000 -static inline u64 div_u64(u64 dividend, u32 divisor)
75001 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
75002 {
75003 u32 remainder;
75004 return div_u64_rem(dividend, divisor, &remainder);
75005 diff --git a/include/linux/mm.h b/include/linux/mm.h
75006 index f022460..6ecf4f9 100644
75007 --- a/include/linux/mm.h
75008 +++ b/include/linux/mm.h
75009 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
75010 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
75011 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
75012 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
75013 +
75014 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
75015 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
75016 +#endif
75017 +
75018 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
75019
75020 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
75021 @@ -208,8 +213,8 @@ struct vm_operations_struct {
75022 /* called by access_process_vm when get_user_pages() fails, typically
75023 * for use by special VMAs that can switch between memory and hardware
75024 */
75025 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
75026 - void *buf, int len, int write);
75027 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
75028 + void *buf, size_t len, int write);
75029 #ifdef CONFIG_NUMA
75030 /*
75031 * set_policy() op must add a reference to any non-NULL @new mempolicy
75032 @@ -239,6 +244,7 @@ struct vm_operations_struct {
75033 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
75034 unsigned long size, pgoff_t pgoff);
75035 };
75036 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
75037
75038 struct mmu_gather;
75039 struct inode;
75040 @@ -983,8 +989,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
75041 unsigned long *pfn);
75042 int follow_phys(struct vm_area_struct *vma, unsigned long address,
75043 unsigned int flags, unsigned long *prot, resource_size_t *phys);
75044 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75045 - void *buf, int len, int write);
75046 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75047 + void *buf, size_t len, int write);
75048
75049 static inline void unmap_shared_mapping_range(struct address_space *mapping,
75050 loff_t const holebegin, loff_t const holelen)
75051 @@ -1023,9 +1029,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
75052 }
75053 #endif
75054
75055 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
75056 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
75057 - void *buf, int len, int write);
75058 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
75059 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
75060 + void *buf, size_t len, int write);
75061
75062 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
75063 unsigned long start, unsigned long nr_pages,
75064 @@ -1057,34 +1063,6 @@ int set_page_dirty(struct page *page);
75065 int set_page_dirty_lock(struct page *page);
75066 int clear_page_dirty_for_io(struct page *page);
75067
75068 -/* Is the vma a continuation of the stack vma above it? */
75069 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
75070 -{
75071 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
75072 -}
75073 -
75074 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
75075 - unsigned long addr)
75076 -{
75077 - return (vma->vm_flags & VM_GROWSDOWN) &&
75078 - (vma->vm_start == addr) &&
75079 - !vma_growsdown(vma->vm_prev, addr);
75080 -}
75081 -
75082 -/* Is the vma a continuation of the stack vma below it? */
75083 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
75084 -{
75085 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
75086 -}
75087 -
75088 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
75089 - unsigned long addr)
75090 -{
75091 - return (vma->vm_flags & VM_GROWSUP) &&
75092 - (vma->vm_end == addr) &&
75093 - !vma_growsup(vma->vm_next, addr);
75094 -}
75095 -
75096 extern pid_t
75097 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
75098
75099 @@ -1184,6 +1162,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
75100 }
75101 #endif
75102
75103 +#ifdef CONFIG_MMU
75104 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
75105 +#else
75106 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
75107 +{
75108 + return __pgprot(0);
75109 +}
75110 +#endif
75111 +
75112 int vma_wants_writenotify(struct vm_area_struct *vma);
75113
75114 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
75115 @@ -1202,8 +1189,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
75116 {
75117 return 0;
75118 }
75119 +
75120 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
75121 + unsigned long address)
75122 +{
75123 + return 0;
75124 +}
75125 #else
75126 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75127 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75128 #endif
75129
75130 #ifdef __PAGETABLE_PMD_FOLDED
75131 @@ -1212,8 +1206,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
75132 {
75133 return 0;
75134 }
75135 +
75136 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
75137 + unsigned long address)
75138 +{
75139 + return 0;
75140 +}
75141 #else
75142 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
75143 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
75144 #endif
75145
75146 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
75147 @@ -1231,11 +1232,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
75148 NULL: pud_offset(pgd, address);
75149 }
75150
75151 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
75152 +{
75153 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
75154 + NULL: pud_offset(pgd, address);
75155 +}
75156 +
75157 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
75158 {
75159 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
75160 NULL: pmd_offset(pud, address);
75161 }
75162 +
75163 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
75164 +{
75165 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
75166 + NULL: pmd_offset(pud, address);
75167 +}
75168 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
75169
75170 #if USE_SPLIT_PTLOCKS
75171 @@ -1531,6 +1544,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
75172 unsigned long len, unsigned long prot, unsigned long flags,
75173 unsigned long pgoff, unsigned long *populate);
75174 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
75175 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
75176
75177 #ifdef CONFIG_MMU
75178 extern int __mm_populate(unsigned long addr, unsigned long len,
75179 @@ -1559,10 +1573,11 @@ struct vm_unmapped_area_info {
75180 unsigned long high_limit;
75181 unsigned long align_mask;
75182 unsigned long align_offset;
75183 + unsigned long threadstack_offset;
75184 };
75185
75186 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
75187 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75188 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
75189 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
75190
75191 /*
75192 * Search for an unmapped address range.
75193 @@ -1574,7 +1589,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75194 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
75195 */
75196 static inline unsigned long
75197 -vm_unmapped_area(struct vm_unmapped_area_info *info)
75198 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
75199 {
75200 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
75201 return unmapped_area(info);
75202 @@ -1637,6 +1652,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
75203 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
75204 struct vm_area_struct **pprev);
75205
75206 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
75207 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
75208 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
75209 +
75210 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
75211 NULL if none. Assume start_addr < end_addr. */
75212 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
75213 @@ -1665,15 +1684,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
75214 return vma;
75215 }
75216
75217 -#ifdef CONFIG_MMU
75218 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
75219 -#else
75220 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
75221 -{
75222 - return __pgprot(0);
75223 -}
75224 -#endif
75225 -
75226 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
75227 unsigned long change_prot_numa(struct vm_area_struct *vma,
75228 unsigned long start, unsigned long end);
75229 @@ -1725,6 +1735,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
75230 static inline void vm_stat_account(struct mm_struct *mm,
75231 unsigned long flags, struct file *file, long pages)
75232 {
75233 +
75234 +#ifdef CONFIG_PAX_RANDMMAP
75235 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
75236 +#endif
75237 +
75238 mm->total_vm += pages;
75239 }
75240 #endif /* CONFIG_PROC_FS */
75241 @@ -1805,7 +1820,7 @@ extern int unpoison_memory(unsigned long pfn);
75242 extern int sysctl_memory_failure_early_kill;
75243 extern int sysctl_memory_failure_recovery;
75244 extern void shake_page(struct page *p, int access);
75245 -extern atomic_long_t num_poisoned_pages;
75246 +extern atomic_long_unchecked_t num_poisoned_pages;
75247 extern int soft_offline_page(struct page *page, int flags);
75248
75249 extern void dump_page(struct page *page);
75250 @@ -1842,5 +1857,11 @@ void __init setup_nr_node_ids(void);
75251 static inline void setup_nr_node_ids(void) {}
75252 #endif
75253
75254 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
75255 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
75256 +#else
75257 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
75258 +#endif
75259 +
75260 #endif /* __KERNEL__ */
75261 #endif /* _LINUX_MM_H */
75262 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
75263 index faf4b7c..1e70c6e 100644
75264 --- a/include/linux/mm_types.h
75265 +++ b/include/linux/mm_types.h
75266 @@ -289,6 +289,8 @@ struct vm_area_struct {
75267 #ifdef CONFIG_NUMA
75268 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
75269 #endif
75270 +
75271 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
75272 };
75273
75274 struct core_thread {
75275 @@ -435,6 +437,24 @@ struct mm_struct {
75276 int first_nid;
75277 #endif
75278 struct uprobes_state uprobes_state;
75279 +
75280 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75281 + unsigned long pax_flags;
75282 +#endif
75283 +
75284 +#ifdef CONFIG_PAX_DLRESOLVE
75285 + unsigned long call_dl_resolve;
75286 +#endif
75287 +
75288 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
75289 + unsigned long call_syscall;
75290 +#endif
75291 +
75292 +#ifdef CONFIG_PAX_ASLR
75293 + unsigned long delta_mmap; /* randomized offset */
75294 + unsigned long delta_stack; /* randomized offset */
75295 +#endif
75296 +
75297 };
75298
75299 /* first nid will either be a valid NID or one of these values */
75300 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
75301 index c5d5278..f0b68c8 100644
75302 --- a/include/linux/mmiotrace.h
75303 +++ b/include/linux/mmiotrace.h
75304 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
75305 /* Called from ioremap.c */
75306 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
75307 void __iomem *addr);
75308 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
75309 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
75310
75311 /* For anyone to insert markers. Remember trailing newline. */
75312 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
75313 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
75314 {
75315 }
75316
75317 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
75318 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
75319 {
75320 }
75321
75322 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
75323 index af4a3b7..9ad8889 100644
75324 --- a/include/linux/mmzone.h
75325 +++ b/include/linux/mmzone.h
75326 @@ -396,7 +396,7 @@ struct zone {
75327 unsigned long flags; /* zone flags, see below */
75328
75329 /* Zone statistics */
75330 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75331 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75332
75333 /*
75334 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
75335 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
75336 index 45e9214..a7227d6 100644
75337 --- a/include/linux/mod_devicetable.h
75338 +++ b/include/linux/mod_devicetable.h
75339 @@ -13,7 +13,7 @@
75340 typedef unsigned long kernel_ulong_t;
75341 #endif
75342
75343 -#define PCI_ANY_ID (~0)
75344 +#define PCI_ANY_ID ((__u16)~0)
75345
75346 struct pci_device_id {
75347 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
75348 @@ -139,7 +139,7 @@ struct usb_device_id {
75349 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
75350 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
75351
75352 -#define HID_ANY_ID (~0)
75353 +#define HID_ANY_ID (~0U)
75354 #define HID_BUS_ANY 0xffff
75355 #define HID_GROUP_ANY 0x0000
75356
75357 @@ -467,7 +467,7 @@ struct dmi_system_id {
75358 const char *ident;
75359 struct dmi_strmatch matches[4];
75360 void *driver_data;
75361 -};
75362 +} __do_const;
75363 /*
75364 * struct dmi_device_id appears during expansion of
75365 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
75366 diff --git a/include/linux/module.h b/include/linux/module.h
75367 index 46f1ea0..a34ca37 100644
75368 --- a/include/linux/module.h
75369 +++ b/include/linux/module.h
75370 @@ -17,9 +17,11 @@
75371 #include <linux/moduleparam.h>
75372 #include <linux/tracepoint.h>
75373 #include <linux/export.h>
75374 +#include <linux/fs.h>
75375
75376 #include <linux/percpu.h>
75377 #include <asm/module.h>
75378 +#include <asm/pgtable.h>
75379
75380 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
75381 #define MODULE_SIG_STRING "~Module signature appended~\n"
75382 @@ -54,12 +56,13 @@ struct module_attribute {
75383 int (*test)(struct module *);
75384 void (*free)(struct module *);
75385 };
75386 +typedef struct module_attribute __no_const module_attribute_no_const;
75387
75388 struct module_version_attribute {
75389 struct module_attribute mattr;
75390 const char *module_name;
75391 const char *version;
75392 -} __attribute__ ((__aligned__(sizeof(void *))));
75393 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
75394
75395 extern ssize_t __modver_version_show(struct module_attribute *,
75396 struct module_kobject *, char *);
75397 @@ -232,7 +235,7 @@ struct module
75398
75399 /* Sysfs stuff. */
75400 struct module_kobject mkobj;
75401 - struct module_attribute *modinfo_attrs;
75402 + module_attribute_no_const *modinfo_attrs;
75403 const char *version;
75404 const char *srcversion;
75405 struct kobject *holders_dir;
75406 @@ -281,19 +284,16 @@ struct module
75407 int (*init)(void);
75408
75409 /* If this is non-NULL, vfree after init() returns */
75410 - void *module_init;
75411 + void *module_init_rx, *module_init_rw;
75412
75413 /* Here is the actual code + data, vfree'd on unload. */
75414 - void *module_core;
75415 + void *module_core_rx, *module_core_rw;
75416
75417 /* Here are the sizes of the init and core sections */
75418 - unsigned int init_size, core_size;
75419 + unsigned int init_size_rw, core_size_rw;
75420
75421 /* The size of the executable code in each section. */
75422 - unsigned int init_text_size, core_text_size;
75423 -
75424 - /* Size of RO sections of the module (text+rodata) */
75425 - unsigned int init_ro_size, core_ro_size;
75426 + unsigned int init_size_rx, core_size_rx;
75427
75428 /* Arch-specific module values */
75429 struct mod_arch_specific arch;
75430 @@ -349,6 +349,10 @@ struct module
75431 #ifdef CONFIG_EVENT_TRACING
75432 struct ftrace_event_call **trace_events;
75433 unsigned int num_trace_events;
75434 + struct file_operations trace_id;
75435 + struct file_operations trace_enable;
75436 + struct file_operations trace_format;
75437 + struct file_operations trace_filter;
75438 #endif
75439 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
75440 unsigned int num_ftrace_callsites;
75441 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
75442 bool is_module_percpu_address(unsigned long addr);
75443 bool is_module_text_address(unsigned long addr);
75444
75445 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
75446 +{
75447 +
75448 +#ifdef CONFIG_PAX_KERNEXEC
75449 + if (ktla_ktva(addr) >= (unsigned long)start &&
75450 + ktla_ktva(addr) < (unsigned long)start + size)
75451 + return 1;
75452 +#endif
75453 +
75454 + return ((void *)addr >= start && (void *)addr < start + size);
75455 +}
75456 +
75457 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
75458 +{
75459 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
75460 +}
75461 +
75462 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
75463 +{
75464 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
75465 +}
75466 +
75467 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
75468 +{
75469 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
75470 +}
75471 +
75472 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
75473 +{
75474 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
75475 +}
75476 +
75477 static inline int within_module_core(unsigned long addr, const struct module *mod)
75478 {
75479 - return (unsigned long)mod->module_core <= addr &&
75480 - addr < (unsigned long)mod->module_core + mod->core_size;
75481 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
75482 }
75483
75484 static inline int within_module_init(unsigned long addr, const struct module *mod)
75485 {
75486 - return (unsigned long)mod->module_init <= addr &&
75487 - addr < (unsigned long)mod->module_init + mod->init_size;
75488 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
75489 }
75490
75491 /* Search for module by name: must hold module_mutex. */
75492 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
75493 index 560ca53..ef621ef 100644
75494 --- a/include/linux/moduleloader.h
75495 +++ b/include/linux/moduleloader.h
75496 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
75497 sections. Returns NULL on failure. */
75498 void *module_alloc(unsigned long size);
75499
75500 +#ifdef CONFIG_PAX_KERNEXEC
75501 +void *module_alloc_exec(unsigned long size);
75502 +#else
75503 +#define module_alloc_exec(x) module_alloc(x)
75504 +#endif
75505 +
75506 /* Free memory returned from module_alloc. */
75507 void module_free(struct module *mod, void *module_region);
75508
75509 +#ifdef CONFIG_PAX_KERNEXEC
75510 +void module_free_exec(struct module *mod, void *module_region);
75511 +#else
75512 +#define module_free_exec(x, y) module_free((x), (y))
75513 +#endif
75514 +
75515 /*
75516 * Apply the given relocation to the (simplified) ELF. Return -error
75517 * or 0.
75518 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
75519 unsigned int relsec,
75520 struct module *me)
75521 {
75522 +#ifdef CONFIG_MODULES
75523 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75524 +#endif
75525 return -ENOEXEC;
75526 }
75527 #endif
75528 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
75529 unsigned int relsec,
75530 struct module *me)
75531 {
75532 +#ifdef CONFIG_MODULES
75533 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75534 +#endif
75535 return -ENOEXEC;
75536 }
75537 #endif
75538 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
75539 index 27d9da3..5d94aa3 100644
75540 --- a/include/linux/moduleparam.h
75541 +++ b/include/linux/moduleparam.h
75542 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
75543 * @len is usually just sizeof(string).
75544 */
75545 #define module_param_string(name, string, len, perm) \
75546 - static const struct kparam_string __param_string_##name \
75547 + static const struct kparam_string __param_string_##name __used \
75548 = { len, string }; \
75549 __module_param_call(MODULE_PARAM_PREFIX, name, \
75550 &param_ops_string, \
75551 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
75552 */
75553 #define module_param_array_named(name, array, type, nump, perm) \
75554 param_check_##type(name, &(array)[0]); \
75555 - static const struct kparam_array __param_arr_##name \
75556 + static const struct kparam_array __param_arr_##name __used \
75557 = { .max = ARRAY_SIZE(array), .num = nump, \
75558 .ops = &param_ops_##type, \
75559 .elemsize = sizeof(array[0]), .elem = array }; \
75560 diff --git a/include/linux/namei.h b/include/linux/namei.h
75561 index 5a5ff57..5ae5070 100644
75562 --- a/include/linux/namei.h
75563 +++ b/include/linux/namei.h
75564 @@ -19,7 +19,7 @@ struct nameidata {
75565 unsigned seq;
75566 int last_type;
75567 unsigned depth;
75568 - char *saved_names[MAX_NESTED_LINKS + 1];
75569 + const char *saved_names[MAX_NESTED_LINKS + 1];
75570 };
75571
75572 /*
75573 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
75574
75575 extern void nd_jump_link(struct nameidata *nd, struct path *path);
75576
75577 -static inline void nd_set_link(struct nameidata *nd, char *path)
75578 +static inline void nd_set_link(struct nameidata *nd, const char *path)
75579 {
75580 nd->saved_names[nd->depth] = path;
75581 }
75582
75583 -static inline char *nd_get_link(struct nameidata *nd)
75584 +static inline const char *nd_get_link(const struct nameidata *nd)
75585 {
75586 return nd->saved_names[nd->depth];
75587 }
75588 diff --git a/include/linux/net.h b/include/linux/net.h
75589 index 4f27575..fc8a65f 100644
75590 --- a/include/linux/net.h
75591 +++ b/include/linux/net.h
75592 @@ -183,7 +183,7 @@ struct net_proto_family {
75593 int (*create)(struct net *net, struct socket *sock,
75594 int protocol, int kern);
75595 struct module *owner;
75596 -};
75597 +} __do_const;
75598
75599 struct iovec;
75600 struct kvec;
75601 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
75602 index 9a41568..203d903 100644
75603 --- a/include/linux/netdevice.h
75604 +++ b/include/linux/netdevice.h
75605 @@ -1061,6 +1061,7 @@ struct net_device_ops {
75606 int (*ndo_change_carrier)(struct net_device *dev,
75607 bool new_carrier);
75608 };
75609 +typedef struct net_device_ops __no_const net_device_ops_no_const;
75610
75611 /*
75612 * The DEVICE structure.
75613 @@ -1131,7 +1132,7 @@ struct net_device {
75614 int iflink;
75615
75616 struct net_device_stats stats;
75617 - atomic_long_t rx_dropped; /* dropped packets by core network
75618 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
75619 * Do not use this in drivers.
75620 */
75621
75622 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
75623 index de70f7b..2675e91 100644
75624 --- a/include/linux/netfilter.h
75625 +++ b/include/linux/netfilter.h
75626 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
75627 #endif
75628 /* Use the module struct to lock set/get code in place */
75629 struct module *owner;
75630 -};
75631 +} __do_const;
75632
75633 /* Function to register/unregister hook points. */
75634 int nf_register_hook(struct nf_hook_ops *reg);
75635 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
75636 index d80e275..c3510b8 100644
75637 --- a/include/linux/netfilter/ipset/ip_set.h
75638 +++ b/include/linux/netfilter/ipset/ip_set.h
75639 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
75640 /* Return true if "b" set is the same as "a"
75641 * according to the create set parameters */
75642 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
75643 -};
75644 +} __do_const;
75645
75646 /* The core set type structure */
75647 struct ip_set_type {
75648 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
75649 index cadb740..d7c37c0 100644
75650 --- a/include/linux/netfilter/nfnetlink.h
75651 +++ b/include/linux/netfilter/nfnetlink.h
75652 @@ -16,7 +16,7 @@ struct nfnl_callback {
75653 const struct nlattr * const cda[]);
75654 const struct nla_policy *policy; /* netlink attribute policy */
75655 const u_int16_t attr_count; /* number of nlattr's */
75656 -};
75657 +} __do_const;
75658
75659 struct nfnetlink_subsystem {
75660 const char *name;
75661 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
75662 new file mode 100644
75663 index 0000000..33f4af8
75664 --- /dev/null
75665 +++ b/include/linux/netfilter/xt_gradm.h
75666 @@ -0,0 +1,9 @@
75667 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
75668 +#define _LINUX_NETFILTER_XT_GRADM_H 1
75669 +
75670 +struct xt_gradm_mtinfo {
75671 + __u16 flags;
75672 + __u16 invflags;
75673 +};
75674 +
75675 +#endif
75676 diff --git a/include/linux/nls.h b/include/linux/nls.h
75677 index 5dc635f..35f5e11 100644
75678 --- a/include/linux/nls.h
75679 +++ b/include/linux/nls.h
75680 @@ -31,7 +31,7 @@ struct nls_table {
75681 const unsigned char *charset2upper;
75682 struct module *owner;
75683 struct nls_table *next;
75684 -};
75685 +} __do_const;
75686
75687 /* this value hold the maximum octet of charset */
75688 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
75689 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
75690 index d14a4c3..a078786 100644
75691 --- a/include/linux/notifier.h
75692 +++ b/include/linux/notifier.h
75693 @@ -54,7 +54,8 @@ struct notifier_block {
75694 notifier_fn_t notifier_call;
75695 struct notifier_block __rcu *next;
75696 int priority;
75697 -};
75698 +} __do_const;
75699 +typedef struct notifier_block __no_const notifier_block_no_const;
75700
75701 struct atomic_notifier_head {
75702 spinlock_t lock;
75703 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
75704 index a4c5624..79d6d88 100644
75705 --- a/include/linux/oprofile.h
75706 +++ b/include/linux/oprofile.h
75707 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
75708 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
75709 char const * name, ulong * val);
75710
75711 -/** Create a file for read-only access to an atomic_t. */
75712 +/** Create a file for read-only access to an atomic_unchecked_t. */
75713 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
75714 - char const * name, atomic_t * val);
75715 + char const * name, atomic_unchecked_t * val);
75716
75717 /** create a directory */
75718 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
75719 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
75720 index 8db71dc..a76bf2c 100644
75721 --- a/include/linux/pci_hotplug.h
75722 +++ b/include/linux/pci_hotplug.h
75723 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
75724 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
75725 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
75726 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
75727 -};
75728 +} __do_const;
75729 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
75730
75731 /**
75732 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
75733 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
75734 index c43f6ea..2d4416f 100644
75735 --- a/include/linux/perf_event.h
75736 +++ b/include/linux/perf_event.h
75737 @@ -328,8 +328,8 @@ struct perf_event {
75738
75739 enum perf_event_active_state state;
75740 unsigned int attach_state;
75741 - local64_t count;
75742 - atomic64_t child_count;
75743 + local64_t count; /* PaX: fix it one day */
75744 + atomic64_unchecked_t child_count;
75745
75746 /*
75747 * These are the total time in nanoseconds that the event
75748 @@ -380,8 +380,8 @@ struct perf_event {
75749 * These accumulate total time (in nanoseconds) that children
75750 * events have been enabled and running, respectively.
75751 */
75752 - atomic64_t child_total_time_enabled;
75753 - atomic64_t child_total_time_running;
75754 + atomic64_unchecked_t child_total_time_enabled;
75755 + atomic64_unchecked_t child_total_time_running;
75756
75757 /*
75758 * Protect attach/detach and child_list:
75759 @@ -703,7 +703,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
75760 entry->ip[entry->nr++] = ip;
75761 }
75762
75763 -extern int sysctl_perf_event_paranoid;
75764 +extern int sysctl_perf_event_legitimately_concerned;
75765 extern int sysctl_perf_event_mlock;
75766 extern int sysctl_perf_event_sample_rate;
75767 extern int sysctl_perf_cpu_time_max_percent;
75768 @@ -718,19 +718,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
75769 loff_t *ppos);
75770
75771
75772 +static inline bool perf_paranoid_any(void)
75773 +{
75774 + return sysctl_perf_event_legitimately_concerned > 2;
75775 +}
75776 +
75777 static inline bool perf_paranoid_tracepoint_raw(void)
75778 {
75779 - return sysctl_perf_event_paranoid > -1;
75780 + return sysctl_perf_event_legitimately_concerned > -1;
75781 }
75782
75783 static inline bool perf_paranoid_cpu(void)
75784 {
75785 - return sysctl_perf_event_paranoid > 0;
75786 + return sysctl_perf_event_legitimately_concerned > 0;
75787 }
75788
75789 static inline bool perf_paranoid_kernel(void)
75790 {
75791 - return sysctl_perf_event_paranoid > 1;
75792 + return sysctl_perf_event_legitimately_concerned > 1;
75793 }
75794
75795 extern void perf_event_init(void);
75796 @@ -846,7 +851,7 @@ struct perf_pmu_events_attr {
75797 struct device_attribute attr;
75798 u64 id;
75799 const char *event_str;
75800 -};
75801 +} __do_const;
75802
75803 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
75804 static struct perf_pmu_events_attr _var = { \
75805 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
75806 index b8809fe..ae4ccd0 100644
75807 --- a/include/linux/pipe_fs_i.h
75808 +++ b/include/linux/pipe_fs_i.h
75809 @@ -47,10 +47,10 @@ struct pipe_inode_info {
75810 struct mutex mutex;
75811 wait_queue_head_t wait;
75812 unsigned int nrbufs, curbuf, buffers;
75813 - unsigned int readers;
75814 - unsigned int writers;
75815 - unsigned int files;
75816 - unsigned int waiting_writers;
75817 + atomic_t readers;
75818 + atomic_t writers;
75819 + atomic_t files;
75820 + atomic_t waiting_writers;
75821 unsigned int r_counter;
75822 unsigned int w_counter;
75823 struct page *tmp_page;
75824 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
75825 index 5f28cae..3d23723 100644
75826 --- a/include/linux/platform_data/usb-ehci-s5p.h
75827 +++ b/include/linux/platform_data/usb-ehci-s5p.h
75828 @@ -14,7 +14,7 @@
75829 struct s5p_ehci_platdata {
75830 int (*phy_init)(struct platform_device *pdev, int type);
75831 int (*phy_exit)(struct platform_device *pdev, int type);
75832 -};
75833 +} __no_const;
75834
75835 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
75836
75837 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
75838 index c256c59..8ea94c7 100644
75839 --- a/include/linux/platform_data/usb-ohci-exynos.h
75840 +++ b/include/linux/platform_data/usb-ohci-exynos.h
75841 @@ -14,7 +14,7 @@
75842 struct exynos4_ohci_platdata {
75843 int (*phy_init)(struct platform_device *pdev, int type);
75844 int (*phy_exit)(struct platform_device *pdev, int type);
75845 -};
75846 +} __no_const;
75847
75848 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
75849
75850 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
75851 index 7c1d252..c5c773e 100644
75852 --- a/include/linux/pm_domain.h
75853 +++ b/include/linux/pm_domain.h
75854 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
75855
75856 struct gpd_cpu_data {
75857 unsigned int saved_exit_latency;
75858 - struct cpuidle_state *idle_state;
75859 + cpuidle_state_no_const *idle_state;
75860 };
75861
75862 struct generic_pm_domain {
75863 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
75864 index 6fa7cea..7bf6415 100644
75865 --- a/include/linux/pm_runtime.h
75866 +++ b/include/linux/pm_runtime.h
75867 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
75868
75869 static inline void pm_runtime_mark_last_busy(struct device *dev)
75870 {
75871 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
75872 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
75873 }
75874
75875 #else /* !CONFIG_PM_RUNTIME */
75876 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
75877 index 195aafc..49a7bc2 100644
75878 --- a/include/linux/pnp.h
75879 +++ b/include/linux/pnp.h
75880 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
75881 struct pnp_fixup {
75882 char id[7];
75883 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
75884 -};
75885 +} __do_const;
75886
75887 /* config parameters */
75888 #define PNP_CONFIG_NORMAL 0x0001
75889 diff --git a/include/linux/poison.h b/include/linux/poison.h
75890 index 2110a81..13a11bb 100644
75891 --- a/include/linux/poison.h
75892 +++ b/include/linux/poison.h
75893 @@ -19,8 +19,8 @@
75894 * under normal circumstances, used to verify that nobody uses
75895 * non-initialized list entries.
75896 */
75897 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
75898 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
75899 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
75900 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
75901
75902 /********** include/linux/timer.h **********/
75903 /*
75904 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
75905 index d8b187c3..9a9257a 100644
75906 --- a/include/linux/power/smartreflex.h
75907 +++ b/include/linux/power/smartreflex.h
75908 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
75909 int (*notify)(struct omap_sr *sr, u32 status);
75910 u8 notify_flags;
75911 u8 class_type;
75912 -};
75913 +} __do_const;
75914
75915 /**
75916 * struct omap_sr_nvalue_table - Smartreflex n-target value info
75917 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
75918 index 4ea1d37..80f4b33 100644
75919 --- a/include/linux/ppp-comp.h
75920 +++ b/include/linux/ppp-comp.h
75921 @@ -84,7 +84,7 @@ struct compressor {
75922 struct module *owner;
75923 /* Extra skb space needed by the compressor algorithm */
75924 unsigned int comp_extra;
75925 -};
75926 +} __do_const;
75927
75928 /*
75929 * The return value from decompress routine is the length of the
75930 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
75931 index f5d4723..a6ea2fa 100644
75932 --- a/include/linux/preempt.h
75933 +++ b/include/linux/preempt.h
75934 @@ -18,8 +18,13 @@
75935 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75936 #endif
75937
75938 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
75939 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75940 +
75941 #define inc_preempt_count() add_preempt_count(1)
75942 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
75943 #define dec_preempt_count() sub_preempt_count(1)
75944 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
75945
75946 #define preempt_count() (current_thread_info()->preempt_count)
75947
75948 @@ -64,6 +69,12 @@ do { \
75949 barrier(); \
75950 } while (0)
75951
75952 +#define raw_preempt_disable() \
75953 +do { \
75954 + raw_inc_preempt_count(); \
75955 + barrier(); \
75956 +} while (0)
75957 +
75958 #define sched_preempt_enable_no_resched() \
75959 do { \
75960 barrier(); \
75961 @@ -72,6 +83,12 @@ do { \
75962
75963 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
75964
75965 +#define raw_preempt_enable_no_resched() \
75966 +do { \
75967 + barrier(); \
75968 + raw_dec_preempt_count(); \
75969 +} while (0)
75970 +
75971 #define preempt_enable() \
75972 do { \
75973 preempt_enable_no_resched(); \
75974 @@ -116,8 +133,10 @@ do { \
75975 * region.
75976 */
75977 #define preempt_disable() barrier()
75978 +#define raw_preempt_disable() barrier()
75979 #define sched_preempt_enable_no_resched() barrier()
75980 #define preempt_enable_no_resched() barrier()
75981 +#define raw_preempt_enable_no_resched() barrier()
75982 #define preempt_enable() barrier()
75983
75984 #define preempt_disable_notrace() barrier()
75985 diff --git a/include/linux/printk.h b/include/linux/printk.h
75986 index 22c7052..ad3fa0a 100644
75987 --- a/include/linux/printk.h
75988 +++ b/include/linux/printk.h
75989 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
75990 void early_printk(const char *s, ...) { }
75991 #endif
75992
75993 +extern int kptr_restrict;
75994 +
75995 #ifdef CONFIG_PRINTK
75996 asmlinkage __printf(5, 0)
75997 int vprintk_emit(int facility, int level,
75998 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
75999
76000 extern int printk_delay_msec;
76001 extern int dmesg_restrict;
76002 -extern int kptr_restrict;
76003
76004 extern void wake_up_klogd(void);
76005
76006 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
76007 index 608e60a..c26f864 100644
76008 --- a/include/linux/proc_fs.h
76009 +++ b/include/linux/proc_fs.h
76010 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
76011 return proc_create_data(name, mode, parent, proc_fops, NULL);
76012 }
76013
76014 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
76015 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
76016 +{
76017 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76018 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
76019 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76020 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
76021 +#else
76022 + return proc_create_data(name, mode, parent, proc_fops, NULL);
76023 +#endif
76024 +}
76025 +
76026 +
76027 extern void proc_set_size(struct proc_dir_entry *, loff_t);
76028 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
76029 extern void *PDE_DATA(const struct inode *);
76030 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
76031 index 34a1e10..03a6d03 100644
76032 --- a/include/linux/proc_ns.h
76033 +++ b/include/linux/proc_ns.h
76034 @@ -14,7 +14,7 @@ struct proc_ns_operations {
76035 void (*put)(void *ns);
76036 int (*install)(struct nsproxy *nsproxy, void *ns);
76037 unsigned int (*inum)(void *ns);
76038 -};
76039 +} __do_const;
76040
76041 struct proc_ns {
76042 void *ns;
76043 diff --git a/include/linux/random.h b/include/linux/random.h
76044 index 6312dd9..2561947 100644
76045 --- a/include/linux/random.h
76046 +++ b/include/linux/random.h
76047 @@ -10,9 +10,19 @@
76048
76049
76050 extern void add_device_randomness(const void *, unsigned int);
76051 +
76052 +static inline void add_latent_entropy(void)
76053 +{
76054 +
76055 +#ifdef LATENT_ENTROPY_PLUGIN
76056 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
76057 +#endif
76058 +
76059 +}
76060 +
76061 extern void add_input_randomness(unsigned int type, unsigned int code,
76062 - unsigned int value);
76063 -extern void add_interrupt_randomness(int irq, int irq_flags);
76064 + unsigned int value) __latent_entropy;
76065 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
76066
76067 extern void get_random_bytes(void *buf, int nbytes);
76068 extern void get_random_bytes_arch(void *buf, int nbytes);
76069 @@ -33,6 +43,11 @@ void prandom_seed(u32 seed);
76070 u32 prandom_u32_state(struct rnd_state *);
76071 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
76072
76073 +static inline unsigned long pax_get_random_long(void)
76074 +{
76075 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
76076 +}
76077 +
76078 /*
76079 * Handle minimum values for seeds
76080 */
76081 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
76082 index 4106721..132d42c 100644
76083 --- a/include/linux/rculist.h
76084 +++ b/include/linux/rculist.h
76085 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
76086 struct list_head *prev, struct list_head *next);
76087 #endif
76088
76089 +extern void __pax_list_add_rcu(struct list_head *new,
76090 + struct list_head *prev, struct list_head *next);
76091 +
76092 /**
76093 * list_add_rcu - add a new entry to rcu-protected list
76094 * @new: new entry to be added
76095 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
76096 __list_add_rcu(new, head, head->next);
76097 }
76098
76099 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
76100 +{
76101 + __pax_list_add_rcu(new, head, head->next);
76102 +}
76103 +
76104 /**
76105 * list_add_tail_rcu - add a new entry to rcu-protected list
76106 * @new: new entry to be added
76107 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
76108 __list_add_rcu(new, head->prev, head);
76109 }
76110
76111 +static inline void pax_list_add_tail_rcu(struct list_head *new,
76112 + struct list_head *head)
76113 +{
76114 + __pax_list_add_rcu(new, head->prev, head);
76115 +}
76116 +
76117 /**
76118 * list_del_rcu - deletes entry from list without re-initialization
76119 * @entry: the element to delete from the list.
76120 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
76121 entry->prev = LIST_POISON2;
76122 }
76123
76124 +extern void pax_list_del_rcu(struct list_head *entry);
76125 +
76126 /**
76127 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
76128 * @n: the element to delete from the hash list.
76129 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
76130 index 8e00f9f..9449b55 100644
76131 --- a/include/linux/reboot.h
76132 +++ b/include/linux/reboot.h
76133 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
76134 * Architecture-specific implementations of sys_reboot commands.
76135 */
76136
76137 -extern void machine_restart(char *cmd);
76138 -extern void machine_halt(void);
76139 -extern void machine_power_off(void);
76140 +extern void machine_restart(char *cmd) __noreturn;
76141 +extern void machine_halt(void) __noreturn;
76142 +extern void machine_power_off(void) __noreturn;
76143
76144 extern void machine_shutdown(void);
76145 struct pt_regs;
76146 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
76147 */
76148
76149 extern void kernel_restart_prepare(char *cmd);
76150 -extern void kernel_restart(char *cmd);
76151 -extern void kernel_halt(void);
76152 -extern void kernel_power_off(void);
76153 +extern void kernel_restart(char *cmd) __noreturn;
76154 +extern void kernel_halt(void) __noreturn;
76155 +extern void kernel_power_off(void) __noreturn;
76156
76157 extern int C_A_D; /* for sysctl */
76158 void ctrl_alt_del(void);
76159 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
76160 * Emergency restart, callable from an interrupt handler.
76161 */
76162
76163 -extern void emergency_restart(void);
76164 +extern void emergency_restart(void) __noreturn;
76165 #include <asm/emergency-restart.h>
76166
76167 #endif /* _LINUX_REBOOT_H */
76168 diff --git a/include/linux/regset.h b/include/linux/regset.h
76169 index 8e0c9fe..ac4d221 100644
76170 --- a/include/linux/regset.h
76171 +++ b/include/linux/regset.h
76172 @@ -161,7 +161,8 @@ struct user_regset {
76173 unsigned int align;
76174 unsigned int bias;
76175 unsigned int core_note_type;
76176 -};
76177 +} __do_const;
76178 +typedef struct user_regset __no_const user_regset_no_const;
76179
76180 /**
76181 * struct user_regset_view - available regsets
76182 diff --git a/include/linux/relay.h b/include/linux/relay.h
76183 index d7c8359..818daf5 100644
76184 --- a/include/linux/relay.h
76185 +++ b/include/linux/relay.h
76186 @@ -157,7 +157,7 @@ struct rchan_callbacks
76187 * The callback should return 0 if successful, negative if not.
76188 */
76189 int (*remove_buf_file)(struct dentry *dentry);
76190 -};
76191 +} __no_const;
76192
76193 /*
76194 * CONFIG_RELAY kernel API, kernel/relay.c
76195 diff --git a/include/linux/rio.h b/include/linux/rio.h
76196 index b71d573..2f940bd 100644
76197 --- a/include/linux/rio.h
76198 +++ b/include/linux/rio.h
76199 @@ -355,7 +355,7 @@ struct rio_ops {
76200 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
76201 u64 rstart, u32 size, u32 flags);
76202 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
76203 -};
76204 +} __no_const;
76205
76206 #define RIO_RESOURCE_MEM 0x00000100
76207 #define RIO_RESOURCE_DOORBELL 0x00000200
76208 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
76209 index 6dacb93..6174423 100644
76210 --- a/include/linux/rmap.h
76211 +++ b/include/linux/rmap.h
76212 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
76213 void anon_vma_init(void); /* create anon_vma_cachep */
76214 int anon_vma_prepare(struct vm_area_struct *);
76215 void unlink_anon_vmas(struct vm_area_struct *);
76216 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
76217 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
76218 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
76219 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
76220
76221 static inline void anon_vma_merge(struct vm_area_struct *vma,
76222 struct vm_area_struct *next)
76223 diff --git a/include/linux/sched.h b/include/linux/sched.h
76224 index 078066d..4090b3b 100644
76225 --- a/include/linux/sched.h
76226 +++ b/include/linux/sched.h
76227 @@ -62,6 +62,7 @@ struct bio_list;
76228 struct fs_struct;
76229 struct perf_event_context;
76230 struct blk_plug;
76231 +struct linux_binprm;
76232
76233 /*
76234 * List of flags we want to share for kernel threads,
76235 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
76236 extern int in_sched_functions(unsigned long addr);
76237
76238 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
76239 -extern signed long schedule_timeout(signed long timeout);
76240 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
76241 extern signed long schedule_timeout_interruptible(signed long timeout);
76242 extern signed long schedule_timeout_killable(signed long timeout);
76243 extern signed long schedule_timeout_uninterruptible(signed long timeout);
76244 @@ -314,6 +315,19 @@ struct nsproxy;
76245 struct user_namespace;
76246
76247 #ifdef CONFIG_MMU
76248 +
76249 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
76250 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
76251 +#else
76252 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
76253 +{
76254 + return 0;
76255 +}
76256 +#endif
76257 +
76258 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
76259 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
76260 +
76261 extern void arch_pick_mmap_layout(struct mm_struct *mm);
76262 extern unsigned long
76263 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
76264 @@ -589,6 +603,17 @@ struct signal_struct {
76265 #ifdef CONFIG_TASKSTATS
76266 struct taskstats *stats;
76267 #endif
76268 +
76269 +#ifdef CONFIG_GRKERNSEC
76270 + u32 curr_ip;
76271 + u32 saved_ip;
76272 + u32 gr_saddr;
76273 + u32 gr_daddr;
76274 + u16 gr_sport;
76275 + u16 gr_dport;
76276 + u8 used_accept:1;
76277 +#endif
76278 +
76279 #ifdef CONFIG_AUDIT
76280 unsigned audit_tty;
76281 unsigned audit_tty_log_passwd;
76282 @@ -669,6 +694,14 @@ struct user_struct {
76283 struct key *session_keyring; /* UID's default session keyring */
76284 #endif
76285
76286 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
76287 + unsigned char kernel_banned;
76288 +#endif
76289 +#ifdef CONFIG_GRKERNSEC_BRUTE
76290 + unsigned char suid_banned;
76291 + unsigned long suid_ban_expires;
76292 +#endif
76293 +
76294 /* Hash table maintenance information */
76295 struct hlist_node uidhash_node;
76296 kuid_t uid;
76297 @@ -1151,8 +1184,8 @@ struct task_struct {
76298 struct list_head thread_group;
76299
76300 struct completion *vfork_done; /* for vfork() */
76301 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
76302 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76303 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
76304 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76305
76306 cputime_t utime, stime, utimescaled, stimescaled;
76307 cputime_t gtime;
76308 @@ -1177,11 +1210,6 @@ struct task_struct {
76309 struct task_cputime cputime_expires;
76310 struct list_head cpu_timers[3];
76311
76312 -/* process credentials */
76313 - const struct cred __rcu *real_cred; /* objective and real subjective task
76314 - * credentials (COW) */
76315 - const struct cred __rcu *cred; /* effective (overridable) subjective task
76316 - * credentials (COW) */
76317 char comm[TASK_COMM_LEN]; /* executable name excluding path
76318 - access with [gs]et_task_comm (which lock
76319 it with task_lock())
76320 @@ -1198,6 +1226,10 @@ struct task_struct {
76321 #endif
76322 /* CPU-specific state of this task */
76323 struct thread_struct thread;
76324 +/* thread_info moved to task_struct */
76325 +#ifdef CONFIG_X86
76326 + struct thread_info tinfo;
76327 +#endif
76328 /* filesystem information */
76329 struct fs_struct *fs;
76330 /* open file information */
76331 @@ -1271,6 +1303,10 @@ struct task_struct {
76332 gfp_t lockdep_reclaim_gfp;
76333 #endif
76334
76335 +/* process credentials */
76336 + const struct cred __rcu *real_cred; /* objective and real subjective task
76337 + * credentials (COW) */
76338 +
76339 /* journalling filesystem info */
76340 void *journal_info;
76341
76342 @@ -1309,6 +1345,10 @@ struct task_struct {
76343 /* cg_list protected by css_set_lock and tsk->alloc_lock */
76344 struct list_head cg_list;
76345 #endif
76346 +
76347 + const struct cred __rcu *cred; /* effective (overridable) subjective task
76348 + * credentials (COW) */
76349 +
76350 #ifdef CONFIG_FUTEX
76351 struct robust_list_head __user *robust_list;
76352 #ifdef CONFIG_COMPAT
76353 @@ -1406,8 +1446,76 @@ struct task_struct {
76354 unsigned int sequential_io;
76355 unsigned int sequential_io_avg;
76356 #endif
76357 +
76358 +#ifdef CONFIG_GRKERNSEC
76359 + /* grsecurity */
76360 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76361 + u64 exec_id;
76362 +#endif
76363 +#ifdef CONFIG_GRKERNSEC_SETXID
76364 + const struct cred *delayed_cred;
76365 +#endif
76366 + struct dentry *gr_chroot_dentry;
76367 + struct acl_subject_label *acl;
76368 + struct acl_role_label *role;
76369 + struct file *exec_file;
76370 + unsigned long brute_expires;
76371 + u16 acl_role_id;
76372 + /* is this the task that authenticated to the special role */
76373 + u8 acl_sp_role;
76374 + u8 is_writable;
76375 + u8 brute;
76376 + u8 gr_is_chrooted;
76377 +#endif
76378 +
76379 };
76380
76381 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
76382 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
76383 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
76384 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
76385 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
76386 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
76387 +
76388 +#ifdef CONFIG_PAX_SOFTMODE
76389 +extern int pax_softmode;
76390 +#endif
76391 +
76392 +extern int pax_check_flags(unsigned long *);
76393 +
76394 +/* if tsk != current then task_lock must be held on it */
76395 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76396 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
76397 +{
76398 + if (likely(tsk->mm))
76399 + return tsk->mm->pax_flags;
76400 + else
76401 + return 0UL;
76402 +}
76403 +
76404 +/* if tsk != current then task_lock must be held on it */
76405 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
76406 +{
76407 + if (likely(tsk->mm)) {
76408 + tsk->mm->pax_flags = flags;
76409 + return 0;
76410 + }
76411 + return -EINVAL;
76412 +}
76413 +#endif
76414 +
76415 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76416 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
76417 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
76418 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76419 +#endif
76420 +
76421 +struct path;
76422 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
76423 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
76424 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
76425 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
76426 +
76427 /* Future-safe accessor for struct task_struct's cpus_allowed. */
76428 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
76429
76430 @@ -1466,7 +1574,7 @@ struct pid_namespace;
76431 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
76432 struct pid_namespace *ns);
76433
76434 -static inline pid_t task_pid_nr(struct task_struct *tsk)
76435 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
76436 {
76437 return tsk->pid;
76438 }
76439 @@ -1916,7 +2024,9 @@ void yield(void);
76440 extern struct exec_domain default_exec_domain;
76441
76442 union thread_union {
76443 +#ifndef CONFIG_X86
76444 struct thread_info thread_info;
76445 +#endif
76446 unsigned long stack[THREAD_SIZE/sizeof(long)];
76447 };
76448
76449 @@ -1949,6 +2059,7 @@ extern struct pid_namespace init_pid_ns;
76450 */
76451
76452 extern struct task_struct *find_task_by_vpid(pid_t nr);
76453 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
76454 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
76455 struct pid_namespace *ns);
76456
76457 @@ -2113,7 +2224,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
76458 extern void exit_itimers(struct signal_struct *);
76459 extern void flush_itimer_signals(void);
76460
76461 -extern void do_group_exit(int);
76462 +extern __noreturn void do_group_exit(int);
76463
76464 extern int allow_signal(int);
76465 extern int disallow_signal(int);
76466 @@ -2304,9 +2415,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
76467
76468 #endif
76469
76470 -static inline int object_is_on_stack(void *obj)
76471 +static inline int object_starts_on_stack(void *obj)
76472 {
76473 - void *stack = task_stack_page(current);
76474 + const void *stack = task_stack_page(current);
76475
76476 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
76477 }
76478 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
76479 index bf8086b..962b035 100644
76480 --- a/include/linux/sched/sysctl.h
76481 +++ b/include/linux/sched/sysctl.h
76482 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
76483 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
76484
76485 extern int sysctl_max_map_count;
76486 +extern unsigned long sysctl_heap_stack_gap;
76487
76488 extern unsigned int sysctl_sched_latency;
76489 extern unsigned int sysctl_sched_min_granularity;
76490 diff --git a/include/linux/security.h b/include/linux/security.h
76491 index 7ce53ae..8ee24a5 100644
76492 --- a/include/linux/security.h
76493 +++ b/include/linux/security.h
76494 @@ -27,6 +27,7 @@
76495 #include <linux/slab.h>
76496 #include <linux/err.h>
76497 #include <linux/string.h>
76498 +#include <linux/grsecurity.h>
76499
76500 struct linux_binprm;
76501 struct cred;
76502 @@ -116,8 +117,6 @@ struct seq_file;
76503
76504 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
76505
76506 -void reset_security_ops(void);
76507 -
76508 #ifdef CONFIG_MMU
76509 extern unsigned long mmap_min_addr;
76510 extern unsigned long dac_mmap_min_addr;
76511 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
76512 index 4e32edc..f8f2d18 100644
76513 --- a/include/linux/seq_file.h
76514 +++ b/include/linux/seq_file.h
76515 @@ -26,6 +26,9 @@ struct seq_file {
76516 struct mutex lock;
76517 const struct seq_operations *op;
76518 int poll_event;
76519 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76520 + u64 exec_id;
76521 +#endif
76522 #ifdef CONFIG_USER_NS
76523 struct user_namespace *user_ns;
76524 #endif
76525 @@ -38,6 +41,7 @@ struct seq_operations {
76526 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
76527 int (*show) (struct seq_file *m, void *v);
76528 };
76529 +typedef struct seq_operations __no_const seq_operations_no_const;
76530
76531 #define SEQ_SKIP 1
76532
76533 diff --git a/include/linux/shm.h b/include/linux/shm.h
76534 index 429c199..4d42e38 100644
76535 --- a/include/linux/shm.h
76536 +++ b/include/linux/shm.h
76537 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
76538
76539 /* The task created the shm object. NULL if the task is dead. */
76540 struct task_struct *shm_creator;
76541 +#ifdef CONFIG_GRKERNSEC
76542 + time_t shm_createtime;
76543 + pid_t shm_lapid;
76544 +#endif
76545 };
76546
76547 /* shm_mode upper byte flags */
76548 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
76549 index 6bd165b..4823435 100644
76550 --- a/include/linux/skbuff.h
76551 +++ b/include/linux/skbuff.h
76552 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
76553 extern struct sk_buff *__alloc_skb(unsigned int size,
76554 gfp_t priority, int flags, int node);
76555 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
76556 -static inline struct sk_buff *alloc_skb(unsigned int size,
76557 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
76558 gfp_t priority)
76559 {
76560 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
76561 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
76562 */
76563 static inline int skb_queue_empty(const struct sk_buff_head *list)
76564 {
76565 - return list->next == (struct sk_buff *)list;
76566 + return list->next == (const struct sk_buff *)list;
76567 }
76568
76569 /**
76570 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
76571 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76572 const struct sk_buff *skb)
76573 {
76574 - return skb->next == (struct sk_buff *)list;
76575 + return skb->next == (const struct sk_buff *)list;
76576 }
76577
76578 /**
76579 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76580 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
76581 const struct sk_buff *skb)
76582 {
76583 - return skb->prev == (struct sk_buff *)list;
76584 + return skb->prev == (const struct sk_buff *)list;
76585 }
76586
76587 /**
76588 @@ -1755,7 +1755,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
76589 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
76590 */
76591 #ifndef NET_SKB_PAD
76592 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
76593 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
76594 #endif
76595
76596 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
76597 @@ -2350,7 +2350,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
76598 int noblock, int *err);
76599 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
76600 struct poll_table_struct *wait);
76601 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
76602 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
76603 int offset, struct iovec *to,
76604 int size);
76605 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
76606 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
76607 nf_bridge_put(skb->nf_bridge);
76608 skb->nf_bridge = NULL;
76609 #endif
76610 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
76611 + skb->nf_trace = 0;
76612 +#endif
76613 }
76614
76615 static inline void nf_reset_trace(struct sk_buff *skb)
76616 diff --git a/include/linux/slab.h b/include/linux/slab.h
76617 index 6c5cc0e..9ca0fd6 100644
76618 --- a/include/linux/slab.h
76619 +++ b/include/linux/slab.h
76620 @@ -12,15 +12,29 @@
76621 #include <linux/gfp.h>
76622 #include <linux/types.h>
76623 #include <linux/workqueue.h>
76624 -
76625 +#include <linux/err.h>
76626
76627 /*
76628 * Flags to pass to kmem_cache_create().
76629 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
76630 */
76631 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
76632 +
76633 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76634 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
76635 +#else
76636 +#define SLAB_USERCOPY 0x00000000UL
76637 +#endif
76638 +
76639 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
76640 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
76641 +
76642 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76643 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
76644 +#else
76645 +#define SLAB_NO_SANITIZE 0x00000000UL
76646 +#endif
76647 +
76648 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
76649 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
76650 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
76651 @@ -89,10 +103,13 @@
76652 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
76653 * Both make kfree a no-op.
76654 */
76655 -#define ZERO_SIZE_PTR ((void *)16)
76656 +#define ZERO_SIZE_PTR \
76657 +({ \
76658 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
76659 + (void *)(-MAX_ERRNO-1L); \
76660 +})
76661
76662 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
76663 - (unsigned long)ZERO_SIZE_PTR)
76664 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
76665
76666
76667 struct mem_cgroup;
76668 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
76669 void kfree(const void *);
76670 void kzfree(const void *);
76671 size_t ksize(const void *);
76672 +const char *check_heap_object(const void *ptr, unsigned long n);
76673 +bool is_usercopy_object(const void *ptr);
76674
76675 /*
76676 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
76677 @@ -164,7 +183,7 @@ struct kmem_cache {
76678 unsigned int align; /* Alignment as calculated */
76679 unsigned long flags; /* Active flags on the slab */
76680 const char *name; /* Slab name for sysfs */
76681 - int refcount; /* Use counter */
76682 + atomic_t refcount; /* Use counter */
76683 void (*ctor)(void *); /* Called on object slot creation */
76684 struct list_head list; /* List of all slab caches on the system */
76685 };
76686 @@ -238,6 +257,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
76687 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76688 #endif
76689
76690 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76691 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
76692 +#endif
76693 +
76694 /*
76695 * Figure out which kmalloc slab an allocation of a certain size
76696 * belongs to.
76697 @@ -246,7 +269,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76698 * 2 = 120 .. 192 bytes
76699 * n = 2^(n-1) .. 2^n -1
76700 */
76701 -static __always_inline int kmalloc_index(size_t size)
76702 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
76703 {
76704 if (!size)
76705 return 0;
76706 @@ -492,7 +515,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
76707 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76708 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76709 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76710 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76711 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
76712 #define kmalloc_track_caller(size, flags) \
76713 __kmalloc_track_caller(size, flags, _RET_IP_)
76714 #else
76715 @@ -512,7 +535,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76716 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76717 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76718 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76719 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
76720 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
76721 #define kmalloc_node_track_caller(size, flags, node) \
76722 __kmalloc_node_track_caller(size, flags, node, \
76723 _RET_IP_)
76724 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
76725 index cd40158..4e2f7af 100644
76726 --- a/include/linux/slab_def.h
76727 +++ b/include/linux/slab_def.h
76728 @@ -50,7 +50,7 @@ struct kmem_cache {
76729 /* 4) cache creation/removal */
76730 const char *name;
76731 struct list_head list;
76732 - int refcount;
76733 + atomic_t refcount;
76734 int object_size;
76735 int align;
76736
76737 @@ -66,10 +66,14 @@ struct kmem_cache {
76738 unsigned long node_allocs;
76739 unsigned long node_frees;
76740 unsigned long node_overflow;
76741 - atomic_t allochit;
76742 - atomic_t allocmiss;
76743 - atomic_t freehit;
76744 - atomic_t freemiss;
76745 + atomic_unchecked_t allochit;
76746 + atomic_unchecked_t allocmiss;
76747 + atomic_unchecked_t freehit;
76748 + atomic_unchecked_t freemiss;
76749 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76750 + atomic_unchecked_t sanitized;
76751 + atomic_unchecked_t not_sanitized;
76752 +#endif
76753
76754 /*
76755 * If debugging is enabled, then the allocator can add additional
76756 @@ -103,7 +107,7 @@ struct kmem_cache {
76757 };
76758
76759 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76760 -void *__kmalloc(size_t size, gfp_t flags);
76761 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
76762
76763 #ifdef CONFIG_TRACING
76764 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
76765 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76766 cachep = kmalloc_dma_caches[i];
76767 else
76768 #endif
76769 +
76770 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76771 + if (flags & GFP_USERCOPY)
76772 + cachep = kmalloc_usercopy_caches[i];
76773 + else
76774 +#endif
76775 +
76776 cachep = kmalloc_caches[i];
76777
76778 ret = kmem_cache_alloc_trace(cachep, flags, size);
76779 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76780 }
76781
76782 #ifdef CONFIG_NUMA
76783 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
76784 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76785 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76786
76787 #ifdef CONFIG_TRACING
76788 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76789 cachep = kmalloc_dma_caches[i];
76790 else
76791 #endif
76792 +
76793 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76794 + if (flags & GFP_USERCOPY)
76795 + cachep = kmalloc_usercopy_caches[i];
76796 + else
76797 +#endif
76798 +
76799 cachep = kmalloc_caches[i];
76800
76801 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
76802 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
76803 index 095a5a4..4b82027 100644
76804 --- a/include/linux/slob_def.h
76805 +++ b/include/linux/slob_def.h
76806 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
76807 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
76808 }
76809
76810 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76811 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76812
76813 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76814 {
76815 @@ -23,7 +23,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76816 return __kmalloc_node(size, flags, NUMA_NO_NODE);
76817 }
76818
76819 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
76820 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
76821 {
76822 return kmalloc(size, flags);
76823 }
76824 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
76825 index 027276f..092bfe8 100644
76826 --- a/include/linux/slub_def.h
76827 +++ b/include/linux/slub_def.h
76828 @@ -80,7 +80,7 @@ struct kmem_cache {
76829 struct kmem_cache_order_objects max;
76830 struct kmem_cache_order_objects min;
76831 gfp_t allocflags; /* gfp flags to use on each alloc */
76832 - int refcount; /* Refcount for slab cache destroy */
76833 + atomic_t refcount; /* Refcount for slab cache destroy */
76834 void (*ctor)(void *);
76835 int inuse; /* Offset to metadata */
76836 int align; /* Alignment */
76837 @@ -105,7 +105,7 @@ struct kmem_cache {
76838 };
76839
76840 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76841 -void *__kmalloc(size_t size, gfp_t flags);
76842 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
76843
76844 static __always_inline void *
76845 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
76846 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
76847 }
76848 #endif
76849
76850 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
76851 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
76852 {
76853 unsigned int order = get_order(size);
76854 return kmalloc_order_trace(size, flags, order);
76855 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76856 }
76857
76858 #ifdef CONFIG_NUMA
76859 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76860 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76861 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76862
76863 #ifdef CONFIG_TRACING
76864 diff --git a/include/linux/smp.h b/include/linux/smp.h
76865 index c181399..09d7b92 100644
76866 --- a/include/linux/smp.h
76867 +++ b/include/linux/smp.h
76868 @@ -217,7 +217,9 @@ static inline void kick_all_cpus_sync(void) { }
76869 #endif
76870
76871 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
76872 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
76873 #define put_cpu() preempt_enable()
76874 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
76875
76876 /*
76877 * Callback to arch code if there's nosmp or maxcpus=0 on the
76878 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
76879 index 54f91d3..be2c379 100644
76880 --- a/include/linux/sock_diag.h
76881 +++ b/include/linux/sock_diag.h
76882 @@ -11,7 +11,7 @@ struct sock;
76883 struct sock_diag_handler {
76884 __u8 family;
76885 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
76886 -};
76887 +} __do_const;
76888
76889 int sock_diag_register(const struct sock_diag_handler *h);
76890 void sock_diag_unregister(const struct sock_diag_handler *h);
76891 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
76892 index 680f9a3..f13aeb0 100644
76893 --- a/include/linux/sonet.h
76894 +++ b/include/linux/sonet.h
76895 @@ -7,7 +7,7 @@
76896 #include <uapi/linux/sonet.h>
76897
76898 struct k_sonet_stats {
76899 -#define __HANDLE_ITEM(i) atomic_t i
76900 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
76901 __SONET_ITEMS
76902 #undef __HANDLE_ITEM
76903 };
76904 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
76905 index 07d8e53..dc934c9 100644
76906 --- a/include/linux/sunrpc/addr.h
76907 +++ b/include/linux/sunrpc/addr.h
76908 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
76909 {
76910 switch (sap->sa_family) {
76911 case AF_INET:
76912 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
76913 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
76914 case AF_INET6:
76915 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
76916 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
76917 }
76918 return 0;
76919 }
76920 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
76921 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
76922 const struct sockaddr *src)
76923 {
76924 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
76925 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
76926 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
76927
76928 dsin->sin_family = ssin->sin_family;
76929 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
76930 if (sa->sa_family != AF_INET6)
76931 return 0;
76932
76933 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
76934 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
76935 }
76936
76937 #endif /* _LINUX_SUNRPC_ADDR_H */
76938 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
76939 index bfe11be..12bc8c4 100644
76940 --- a/include/linux/sunrpc/clnt.h
76941 +++ b/include/linux/sunrpc/clnt.h
76942 @@ -96,7 +96,7 @@ struct rpc_procinfo {
76943 unsigned int p_timer; /* Which RTT timer to use */
76944 u32 p_statidx; /* Which procedure to account */
76945 const char * p_name; /* name of procedure */
76946 -};
76947 +} __do_const;
76948
76949 #ifdef __KERNEL__
76950
76951 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
76952 index 1f0216b..6a4fa50 100644
76953 --- a/include/linux/sunrpc/svc.h
76954 +++ b/include/linux/sunrpc/svc.h
76955 @@ -411,7 +411,7 @@ struct svc_procedure {
76956 unsigned int pc_count; /* call count */
76957 unsigned int pc_cachetype; /* cache info (NFS) */
76958 unsigned int pc_xdrressize; /* maximum size of XDR reply */
76959 -};
76960 +} __do_const;
76961
76962 /*
76963 * Function prototypes.
76964 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
76965 index 0b8e3e6..33e0a01 100644
76966 --- a/include/linux/sunrpc/svc_rdma.h
76967 +++ b/include/linux/sunrpc/svc_rdma.h
76968 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
76969 extern unsigned int svcrdma_max_requests;
76970 extern unsigned int svcrdma_max_req_size;
76971
76972 -extern atomic_t rdma_stat_recv;
76973 -extern atomic_t rdma_stat_read;
76974 -extern atomic_t rdma_stat_write;
76975 -extern atomic_t rdma_stat_sq_starve;
76976 -extern atomic_t rdma_stat_rq_starve;
76977 -extern atomic_t rdma_stat_rq_poll;
76978 -extern atomic_t rdma_stat_rq_prod;
76979 -extern atomic_t rdma_stat_sq_poll;
76980 -extern atomic_t rdma_stat_sq_prod;
76981 +extern atomic_unchecked_t rdma_stat_recv;
76982 +extern atomic_unchecked_t rdma_stat_read;
76983 +extern atomic_unchecked_t rdma_stat_write;
76984 +extern atomic_unchecked_t rdma_stat_sq_starve;
76985 +extern atomic_unchecked_t rdma_stat_rq_starve;
76986 +extern atomic_unchecked_t rdma_stat_rq_poll;
76987 +extern atomic_unchecked_t rdma_stat_rq_prod;
76988 +extern atomic_unchecked_t rdma_stat_sq_poll;
76989 +extern atomic_unchecked_t rdma_stat_sq_prod;
76990
76991 #define RPCRDMA_VERSION 1
76992
76993 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
76994 index 8d71d65..f79586e 100644
76995 --- a/include/linux/sunrpc/svcauth.h
76996 +++ b/include/linux/sunrpc/svcauth.h
76997 @@ -120,7 +120,7 @@ struct auth_ops {
76998 int (*release)(struct svc_rqst *rq);
76999 void (*domain_release)(struct auth_domain *);
77000 int (*set_client)(struct svc_rqst *rq);
77001 -};
77002 +} __do_const;
77003
77004 #define SVC_GARBAGE 1
77005 #define SVC_SYSERR 2
77006 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
77007 index a5ffd32..0935dea 100644
77008 --- a/include/linux/swiotlb.h
77009 +++ b/include/linux/swiotlb.h
77010 @@ -60,7 +60,8 @@ extern void
77011
77012 extern void
77013 swiotlb_free_coherent(struct device *hwdev, size_t size,
77014 - void *vaddr, dma_addr_t dma_handle);
77015 + void *vaddr, dma_addr_t dma_handle,
77016 + struct dma_attrs *attrs);
77017
77018 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
77019 unsigned long offset, size_t size,
77020 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
77021 index 84662ec..5271947 100644
77022 --- a/include/linux/syscalls.h
77023 +++ b/include/linux/syscalls.h
77024 @@ -97,8 +97,14 @@ struct sigaltstack;
77025 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
77026
77027 #define __SC_DECL(t, a) t a
77028 +#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))
77029 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
77030 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
77031 +#define __SC_LONG(t, a) __typeof( \
77032 + __builtin_choose_expr( \
77033 + sizeof(t) > sizeof(int), \
77034 + (t) 0, \
77035 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
77036 + )) a
77037 #define __SC_CAST(t, a) (t) a
77038 #define __SC_ARGS(t, a) a
77039 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
77040 @@ -362,11 +368,11 @@ asmlinkage long sys_sync(void);
77041 asmlinkage long sys_fsync(unsigned int fd);
77042 asmlinkage long sys_fdatasync(unsigned int fd);
77043 asmlinkage long sys_bdflush(int func, long data);
77044 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
77045 - char __user *type, unsigned long flags,
77046 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
77047 + const char __user *type, unsigned long flags,
77048 void __user *data);
77049 -asmlinkage long sys_umount(char __user *name, int flags);
77050 -asmlinkage long sys_oldumount(char __user *name);
77051 +asmlinkage long sys_umount(const char __user *name, int flags);
77052 +asmlinkage long sys_oldumount(const char __user *name);
77053 asmlinkage long sys_truncate(const char __user *path, long length);
77054 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
77055 asmlinkage long sys_stat(const char __user *filename,
77056 @@ -578,7 +584,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
77057 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
77058 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
77059 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
77060 - struct sockaddr __user *, int);
77061 + struct sockaddr __user *, int) __intentional_overflow(0);
77062 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
77063 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
77064 unsigned int vlen, unsigned flags);
77065 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
77066 index 27b3b0b..e093dd9 100644
77067 --- a/include/linux/syscore_ops.h
77068 +++ b/include/linux/syscore_ops.h
77069 @@ -16,7 +16,7 @@ struct syscore_ops {
77070 int (*suspend)(void);
77071 void (*resume)(void);
77072 void (*shutdown)(void);
77073 -};
77074 +} __do_const;
77075
77076 extern void register_syscore_ops(struct syscore_ops *ops);
77077 extern void unregister_syscore_ops(struct syscore_ops *ops);
77078 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
77079 index 14a8ff2..af52bad 100644
77080 --- a/include/linux/sysctl.h
77081 +++ b/include/linux/sysctl.h
77082 @@ -34,13 +34,13 @@ struct ctl_table_root;
77083 struct ctl_table_header;
77084 struct ctl_dir;
77085
77086 -typedef struct ctl_table ctl_table;
77087 -
77088 typedef int proc_handler (struct ctl_table *ctl, int write,
77089 void __user *buffer, size_t *lenp, loff_t *ppos);
77090
77091 extern int proc_dostring(struct ctl_table *, int,
77092 void __user *, size_t *, loff_t *);
77093 +extern int proc_dostring_modpriv(struct ctl_table *, int,
77094 + void __user *, size_t *, loff_t *);
77095 extern int proc_dointvec(struct ctl_table *, int,
77096 void __user *, size_t *, loff_t *);
77097 extern int proc_dointvec_minmax(struct ctl_table *, int,
77098 @@ -115,7 +115,9 @@ struct ctl_table
77099 struct ctl_table_poll *poll;
77100 void *extra1;
77101 void *extra2;
77102 -};
77103 +} __do_const;
77104 +typedef struct ctl_table __no_const ctl_table_no_const;
77105 +typedef struct ctl_table ctl_table;
77106
77107 struct ctl_node {
77108 struct rb_node node;
77109 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
77110 index 9e8a9b5..753de68 100644
77111 --- a/include/linux/sysfs.h
77112 +++ b/include/linux/sysfs.h
77113 @@ -33,7 +33,8 @@ struct attribute {
77114 struct lock_class_key *key;
77115 struct lock_class_key skey;
77116 #endif
77117 -};
77118 +} __do_const;
77119 +typedef struct attribute __no_const attribute_no_const;
77120
77121 /**
77122 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
77123 @@ -62,7 +63,8 @@ struct attribute_group {
77124 struct attribute *, int);
77125 struct attribute **attrs;
77126 struct bin_attribute **bin_attrs;
77127 -};
77128 +} __do_const;
77129 +typedef struct attribute_group __no_const attribute_group_no_const;
77130
77131 /**
77132 * Use these macros to make defining attributes easier. See include/linux/device.h
77133 @@ -123,7 +125,8 @@ struct bin_attribute {
77134 char *, loff_t, size_t);
77135 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
77136 struct vm_area_struct *vma);
77137 -};
77138 +} __do_const;
77139 +typedef struct bin_attribute __no_const bin_attribute_no_const;
77140
77141 /**
77142 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
77143 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
77144 index 7faf933..9b85a0c 100644
77145 --- a/include/linux/sysrq.h
77146 +++ b/include/linux/sysrq.h
77147 @@ -16,6 +16,7 @@
77148
77149 #include <linux/errno.h>
77150 #include <linux/types.h>
77151 +#include <linux/compiler.h>
77152
77153 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
77154 #define SYSRQ_DEFAULT_ENABLE 1
77155 @@ -36,7 +37,7 @@ struct sysrq_key_op {
77156 char *help_msg;
77157 char *action_msg;
77158 int enable_mask;
77159 -};
77160 +} __do_const;
77161
77162 #ifdef CONFIG_MAGIC_SYSRQ
77163
77164 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
77165 index e7e0473..7989295 100644
77166 --- a/include/linux/thread_info.h
77167 +++ b/include/linux/thread_info.h
77168 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
77169 #error "no set_restore_sigmask() provided and default one won't work"
77170 #endif
77171
77172 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
77173 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
77174 +{
77175 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
77176 + if (!__builtin_constant_p(n))
77177 +#endif
77178 + __check_object_size(ptr, n, to_user);
77179 +}
77180 +
77181 #endif /* __KERNEL__ */
77182
77183 #endif /* _LINUX_THREAD_INFO_H */
77184 diff --git a/include/linux/tty.h b/include/linux/tty.h
77185 index 01ac30e..bf18a71 100644
77186 --- a/include/linux/tty.h
77187 +++ b/include/linux/tty.h
77188 @@ -194,7 +194,7 @@ struct tty_port {
77189 const struct tty_port_operations *ops; /* Port operations */
77190 spinlock_t lock; /* Lock protecting tty field */
77191 int blocked_open; /* Waiting to open */
77192 - int count; /* Usage count */
77193 + atomic_t count; /* Usage count */
77194 wait_queue_head_t open_wait; /* Open waiters */
77195 wait_queue_head_t close_wait; /* Close waiters */
77196 wait_queue_head_t delta_msr_wait; /* Modem status change */
77197 @@ -547,7 +547,7 @@ extern int tty_port_open(struct tty_port *port,
77198 struct tty_struct *tty, struct file *filp);
77199 static inline int tty_port_users(struct tty_port *port)
77200 {
77201 - return port->count + port->blocked_open;
77202 + return atomic_read(&port->count) + port->blocked_open;
77203 }
77204
77205 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
77206 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
77207 index 756a609..b302dd6 100644
77208 --- a/include/linux/tty_driver.h
77209 +++ b/include/linux/tty_driver.h
77210 @@ -285,7 +285,7 @@ struct tty_operations {
77211 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
77212 #endif
77213 const struct file_operations *proc_fops;
77214 -};
77215 +} __do_const;
77216
77217 struct tty_driver {
77218 int magic; /* magic number for this structure */
77219 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
77220 index a1b0489..f02e17c 100644
77221 --- a/include/linux/tty_ldisc.h
77222 +++ b/include/linux/tty_ldisc.h
77223 @@ -198,7 +198,7 @@ struct tty_ldisc_ops {
77224
77225 struct module *owner;
77226
77227 - int refcount;
77228 + atomic_t refcount;
77229 };
77230
77231 struct tty_ldisc {
77232 diff --git a/include/linux/types.h b/include/linux/types.h
77233 index 4d118ba..c3ee9bf 100644
77234 --- a/include/linux/types.h
77235 +++ b/include/linux/types.h
77236 @@ -176,10 +176,26 @@ typedef struct {
77237 int counter;
77238 } atomic_t;
77239
77240 +#ifdef CONFIG_PAX_REFCOUNT
77241 +typedef struct {
77242 + int counter;
77243 +} atomic_unchecked_t;
77244 +#else
77245 +typedef atomic_t atomic_unchecked_t;
77246 +#endif
77247 +
77248 #ifdef CONFIG_64BIT
77249 typedef struct {
77250 long counter;
77251 } atomic64_t;
77252 +
77253 +#ifdef CONFIG_PAX_REFCOUNT
77254 +typedef struct {
77255 + long counter;
77256 +} atomic64_unchecked_t;
77257 +#else
77258 +typedef atomic64_t atomic64_unchecked_t;
77259 +#endif
77260 #endif
77261
77262 struct list_head {
77263 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
77264 index 5ca0951..ab496a5 100644
77265 --- a/include/linux/uaccess.h
77266 +++ b/include/linux/uaccess.h
77267 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
77268 long ret; \
77269 mm_segment_t old_fs = get_fs(); \
77270 \
77271 - set_fs(KERNEL_DS); \
77272 pagefault_disable(); \
77273 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
77274 - pagefault_enable(); \
77275 + set_fs(KERNEL_DS); \
77276 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
77277 set_fs(old_fs); \
77278 + pagefault_enable(); \
77279 ret; \
77280 })
77281
77282 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
77283 index 8e522cbc..aa8572d 100644
77284 --- a/include/linux/uidgid.h
77285 +++ b/include/linux/uidgid.h
77286 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
77287
77288 #endif /* CONFIG_USER_NS */
77289
77290 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
77291 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
77292 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
77293 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
77294 +
77295 #endif /* _LINUX_UIDGID_H */
77296 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
77297 index 99c1b4d..562e6f3 100644
77298 --- a/include/linux/unaligned/access_ok.h
77299 +++ b/include/linux/unaligned/access_ok.h
77300 @@ -4,34 +4,34 @@
77301 #include <linux/kernel.h>
77302 #include <asm/byteorder.h>
77303
77304 -static inline u16 get_unaligned_le16(const void *p)
77305 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
77306 {
77307 - return le16_to_cpup((__le16 *)p);
77308 + return le16_to_cpup((const __le16 *)p);
77309 }
77310
77311 -static inline u32 get_unaligned_le32(const void *p)
77312 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
77313 {
77314 - return le32_to_cpup((__le32 *)p);
77315 + return le32_to_cpup((const __le32 *)p);
77316 }
77317
77318 -static inline u64 get_unaligned_le64(const void *p)
77319 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
77320 {
77321 - return le64_to_cpup((__le64 *)p);
77322 + return le64_to_cpup((const __le64 *)p);
77323 }
77324
77325 -static inline u16 get_unaligned_be16(const void *p)
77326 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
77327 {
77328 - return be16_to_cpup((__be16 *)p);
77329 + return be16_to_cpup((const __be16 *)p);
77330 }
77331
77332 -static inline u32 get_unaligned_be32(const void *p)
77333 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
77334 {
77335 - return be32_to_cpup((__be32 *)p);
77336 + return be32_to_cpup((const __be32 *)p);
77337 }
77338
77339 -static inline u64 get_unaligned_be64(const void *p)
77340 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
77341 {
77342 - return be64_to_cpup((__be64 *)p);
77343 + return be64_to_cpup((const __be64 *)p);
77344 }
77345
77346 static inline void put_unaligned_le16(u16 val, void *p)
77347 diff --git a/include/linux/usb.h b/include/linux/usb.h
77348 index 0eec268..4496526 100644
77349 --- a/include/linux/usb.h
77350 +++ b/include/linux/usb.h
77351 @@ -560,7 +560,7 @@ struct usb_device {
77352 int maxchild;
77353
77354 u32 quirks;
77355 - atomic_t urbnum;
77356 + atomic_unchecked_t urbnum;
77357
77358 unsigned long active_duration;
77359
77360 @@ -1617,7 +1617,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
77361
77362 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
77363 __u8 request, __u8 requesttype, __u16 value, __u16 index,
77364 - void *data, __u16 size, int timeout);
77365 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
77366 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
77367 void *data, int len, int *actual_length, int timeout);
77368 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
77369 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
77370 index e452ba6..78f8e80 100644
77371 --- a/include/linux/usb/renesas_usbhs.h
77372 +++ b/include/linux/usb/renesas_usbhs.h
77373 @@ -39,7 +39,7 @@ enum {
77374 */
77375 struct renesas_usbhs_driver_callback {
77376 int (*notify_hotplug)(struct platform_device *pdev);
77377 -};
77378 +} __no_const;
77379
77380 /*
77381 * callback functions for platform
77382 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
77383 index 6f8fbcf..8259001 100644
77384 --- a/include/linux/vermagic.h
77385 +++ b/include/linux/vermagic.h
77386 @@ -25,9 +25,35 @@
77387 #define MODULE_ARCH_VERMAGIC ""
77388 #endif
77389
77390 +#ifdef CONFIG_PAX_REFCOUNT
77391 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
77392 +#else
77393 +#define MODULE_PAX_REFCOUNT ""
77394 +#endif
77395 +
77396 +#ifdef CONSTIFY_PLUGIN
77397 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
77398 +#else
77399 +#define MODULE_CONSTIFY_PLUGIN ""
77400 +#endif
77401 +
77402 +#ifdef STACKLEAK_PLUGIN
77403 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
77404 +#else
77405 +#define MODULE_STACKLEAK_PLUGIN ""
77406 +#endif
77407 +
77408 +#ifdef CONFIG_GRKERNSEC
77409 +#define MODULE_GRSEC "GRSEC "
77410 +#else
77411 +#define MODULE_GRSEC ""
77412 +#endif
77413 +
77414 #define VERMAGIC_STRING \
77415 UTS_RELEASE " " \
77416 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
77417 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
77418 - MODULE_ARCH_VERMAGIC
77419 + MODULE_ARCH_VERMAGIC \
77420 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
77421 + MODULE_GRSEC
77422
77423 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
77424 index 4b8a891..c20e936 100644
77425 --- a/include/linux/vmalloc.h
77426 +++ b/include/linux/vmalloc.h
77427 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
77428 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
77429 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
77430 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
77431 +
77432 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
77433 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
77434 +#endif
77435 +
77436 /* bits [20..32] reserved for arch specific ioremap internals */
77437
77438 /*
77439 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
77440 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
77441 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
77442 unsigned long start, unsigned long end, gfp_t gfp_mask,
77443 - pgprot_t prot, int node, const void *caller);
77444 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
77445 extern void vfree(const void *addr);
77446
77447 extern void *vmap(struct page **pages, unsigned int count,
77448 @@ -141,8 +146,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
77449 extern void free_vm_area(struct vm_struct *area);
77450
77451 /* for /dev/kmem */
77452 -extern long vread(char *buf, char *addr, unsigned long count);
77453 -extern long vwrite(char *buf, char *addr, unsigned long count);
77454 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
77455 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
77456
77457 /*
77458 * Internals. Dont't use..
77459 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
77460 index c586679..f06b389 100644
77461 --- a/include/linux/vmstat.h
77462 +++ b/include/linux/vmstat.h
77463 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
77464 /*
77465 * Zone based page accounting with per cpu differentials.
77466 */
77467 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77468 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77469
77470 static inline void zone_page_state_add(long x, struct zone *zone,
77471 enum zone_stat_item item)
77472 {
77473 - atomic_long_add(x, &zone->vm_stat[item]);
77474 - atomic_long_add(x, &vm_stat[item]);
77475 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
77476 + atomic_long_add_unchecked(x, &vm_stat[item]);
77477 }
77478
77479 static inline unsigned long global_page_state(enum zone_stat_item item)
77480 {
77481 - long x = atomic_long_read(&vm_stat[item]);
77482 + long x = atomic_long_read_unchecked(&vm_stat[item]);
77483 #ifdef CONFIG_SMP
77484 if (x < 0)
77485 x = 0;
77486 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
77487 static inline unsigned long zone_page_state(struct zone *zone,
77488 enum zone_stat_item item)
77489 {
77490 - long x = atomic_long_read(&zone->vm_stat[item]);
77491 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77492 #ifdef CONFIG_SMP
77493 if (x < 0)
77494 x = 0;
77495 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
77496 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
77497 enum zone_stat_item item)
77498 {
77499 - long x = atomic_long_read(&zone->vm_stat[item]);
77500 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77501
77502 #ifdef CONFIG_SMP
77503 int cpu;
77504 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
77505
77506 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
77507 {
77508 - atomic_long_inc(&zone->vm_stat[item]);
77509 - atomic_long_inc(&vm_stat[item]);
77510 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
77511 + atomic_long_inc_unchecked(&vm_stat[item]);
77512 }
77513
77514 static inline void __inc_zone_page_state(struct page *page,
77515 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
77516
77517 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
77518 {
77519 - atomic_long_dec(&zone->vm_stat[item]);
77520 - atomic_long_dec(&vm_stat[item]);
77521 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
77522 + atomic_long_dec_unchecked(&vm_stat[item]);
77523 }
77524
77525 static inline void __dec_zone_page_state(struct page *page,
77526 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
77527 index fdbafc6..49dfe4f 100644
77528 --- a/include/linux/xattr.h
77529 +++ b/include/linux/xattr.h
77530 @@ -28,7 +28,7 @@ struct xattr_handler {
77531 size_t size, int handler_flags);
77532 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
77533 size_t size, int flags, int handler_flags);
77534 -};
77535 +} __do_const;
77536
77537 struct xattr {
77538 char *name;
77539 @@ -37,6 +37,9 @@ struct xattr {
77540 };
77541
77542 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
77543 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
77544 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
77545 +#endif
77546 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
77547 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
77548 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
77549 diff --git a/include/linux/yam.h b/include/linux/yam.h
77550 index 7fe2822..512cdc2 100644
77551 --- a/include/linux/yam.h
77552 +++ b/include/linux/yam.h
77553 @@ -77,6 +77,6 @@ struct yamdrv_ioctl_cfg {
77554
77555 struct yamdrv_ioctl_mcs {
77556 int cmd;
77557 - int bitrate;
77558 + unsigned int bitrate;
77559 unsigned char bits[YAM_FPGA_SIZE];
77560 };
77561 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
77562 index 9c5a6b4..09c9438 100644
77563 --- a/include/linux/zlib.h
77564 +++ b/include/linux/zlib.h
77565 @@ -31,6 +31,7 @@
77566 #define _ZLIB_H
77567
77568 #include <linux/zconf.h>
77569 +#include <linux/compiler.h>
77570
77571 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
77572 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
77573 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
77574
77575 /* basic functions */
77576
77577 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
77578 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
77579 /*
77580 Returns the number of bytes that needs to be allocated for a per-
77581 stream workspace with the specified parameters. A pointer to this
77582 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
77583 index c768c9f..bdcaa5a 100644
77584 --- a/include/media/v4l2-dev.h
77585 +++ b/include/media/v4l2-dev.h
77586 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
77587 int (*mmap) (struct file *, struct vm_area_struct *);
77588 int (*open) (struct file *);
77589 int (*release) (struct file *);
77590 -};
77591 +} __do_const;
77592
77593 /*
77594 * Newer version of video_device, handled by videodev2.c
77595 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
77596 index c9b1593..a572459 100644
77597 --- a/include/media/v4l2-device.h
77598 +++ b/include/media/v4l2-device.h
77599 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
77600 this function returns 0. If the name ends with a digit (e.g. cx18),
77601 then the name will be set to cx18-0 since cx180 looks really odd. */
77602 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
77603 - atomic_t *instance);
77604 + atomic_unchecked_t *instance);
77605
77606 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
77607 Since the parent disappears this ensures that v4l2_dev doesn't have an
77608 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
77609 index d9fa68f..45c88d1 100644
77610 --- a/include/net/9p/transport.h
77611 +++ b/include/net/9p/transport.h
77612 @@ -63,7 +63,7 @@ struct p9_trans_module {
77613 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
77614 int (*zc_request)(struct p9_client *, struct p9_req_t *,
77615 char *, char *, int , int, int, int);
77616 -};
77617 +} __do_const;
77618
77619 void v9fs_register_trans(struct p9_trans_module *m);
77620 void v9fs_unregister_trans(struct p9_trans_module *m);
77621 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
77622 index 1a966af..2767cf6 100644
77623 --- a/include/net/bluetooth/l2cap.h
77624 +++ b/include/net/bluetooth/l2cap.h
77625 @@ -551,7 +551,7 @@ struct l2cap_ops {
77626 void (*defer) (struct l2cap_chan *chan);
77627 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
77628 unsigned long len, int nb);
77629 -};
77630 +} __do_const;
77631
77632 struct l2cap_conn {
77633 struct hci_conn *hcon;
77634 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
77635 index f2ae33d..c457cf0 100644
77636 --- a/include/net/caif/cfctrl.h
77637 +++ b/include/net/caif/cfctrl.h
77638 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
77639 void (*radioset_rsp)(void);
77640 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
77641 struct cflayer *client_layer);
77642 -};
77643 +} __no_const;
77644
77645 /* Link Setup Parameters for CAIF-Links. */
77646 struct cfctrl_link_param {
77647 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
77648 struct cfctrl {
77649 struct cfsrvl serv;
77650 struct cfctrl_rsp res;
77651 - atomic_t req_seq_no;
77652 - atomic_t rsp_seq_no;
77653 + atomic_unchecked_t req_seq_no;
77654 + atomic_unchecked_t rsp_seq_no;
77655 struct list_head list;
77656 /* Protects from simultaneous access to first_req list */
77657 spinlock_t info_list_lock;
77658 diff --git a/include/net/flow.h b/include/net/flow.h
77659 index 628e11b..4c475df 100644
77660 --- a/include/net/flow.h
77661 +++ b/include/net/flow.h
77662 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
77663
77664 extern void flow_cache_flush(void);
77665 extern void flow_cache_flush_deferred(void);
77666 -extern atomic_t flow_cache_genid;
77667 +extern atomic_unchecked_t flow_cache_genid;
77668
77669 #endif
77670 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
77671 index 8e0b6c8..73cf605 100644
77672 --- a/include/net/genetlink.h
77673 +++ b/include/net/genetlink.h
77674 @@ -120,7 +120,7 @@ struct genl_ops {
77675 struct netlink_callback *cb);
77676 int (*done)(struct netlink_callback *cb);
77677 struct list_head ops_list;
77678 -};
77679 +} __do_const;
77680
77681 extern int __genl_register_family(struct genl_family *family);
77682
77683 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
77684 index 734d9b5..48a9a4b 100644
77685 --- a/include/net/gro_cells.h
77686 +++ b/include/net/gro_cells.h
77687 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
77688 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
77689
77690 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
77691 - atomic_long_inc(&dev->rx_dropped);
77692 + atomic_long_inc_unchecked(&dev->rx_dropped);
77693 kfree_skb(skb);
77694 return;
77695 }
77696 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
77697 index de2c785..0588a6b 100644
77698 --- a/include/net/inet_connection_sock.h
77699 +++ b/include/net/inet_connection_sock.h
77700 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
77701 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
77702 int (*bind_conflict)(const struct sock *sk,
77703 const struct inet_bind_bucket *tb, bool relax);
77704 -};
77705 +} __do_const;
77706
77707 /** inet_connection_sock - INET connection oriented sock
77708 *
77709 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
77710 index 53f464d..0bd0b49 100644
77711 --- a/include/net/inetpeer.h
77712 +++ b/include/net/inetpeer.h
77713 @@ -47,8 +47,8 @@ struct inet_peer {
77714 */
77715 union {
77716 struct {
77717 - atomic_t rid; /* Frag reception counter */
77718 - atomic_t ip_id_count; /* IP ID for the next packet */
77719 + atomic_unchecked_t rid; /* Frag reception counter */
77720 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
77721 };
77722 struct rcu_head rcu;
77723 struct inet_peer *gc_next;
77724 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
77725 /* can be called with or without local BH being disabled */
77726 static inline int inet_getid(struct inet_peer *p, int more)
77727 {
77728 - int old, new;
77729 + int id;
77730 more++;
77731 inet_peer_refcheck(p);
77732 - do {
77733 - old = atomic_read(&p->ip_id_count);
77734 - new = old + more;
77735 - if (!new)
77736 - new = 1;
77737 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
77738 - return new;
77739 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
77740 + if (!id)
77741 + id = atomic_inc_return_unchecked(&p->ip_id_count);
77742 + return id;
77743 }
77744
77745 #endif /* _NET_INETPEER_H */
77746 diff --git a/include/net/ip.h b/include/net/ip.h
77747 index edfa591..a643b82 100644
77748 --- a/include/net/ip.h
77749 +++ b/include/net/ip.h
77750 @@ -202,7 +202,7 @@ extern struct local_ports {
77751 } sysctl_local_ports;
77752 extern void inet_get_local_port_range(int *low, int *high);
77753
77754 -extern unsigned long *sysctl_local_reserved_ports;
77755 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
77756 static inline int inet_is_reserved_local_port(int port)
77757 {
77758 return test_bit(port, sysctl_local_reserved_ports);
77759 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
77760 index cbf2be3..3683f6d 100644
77761 --- a/include/net/ip_fib.h
77762 +++ b/include/net/ip_fib.h
77763 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
77764
77765 #define FIB_RES_SADDR(net, res) \
77766 ((FIB_RES_NH(res).nh_saddr_genid == \
77767 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
77768 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
77769 FIB_RES_NH(res).nh_saddr : \
77770 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
77771 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
77772 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
77773 index f0d70f0..185f15b 100644
77774 --- a/include/net/ip_vs.h
77775 +++ b/include/net/ip_vs.h
77776 @@ -588,7 +588,7 @@ struct ip_vs_conn {
77777 struct ip_vs_conn *control; /* Master control connection */
77778 atomic_t n_control; /* Number of controlled ones */
77779 struct ip_vs_dest *dest; /* real server */
77780 - atomic_t in_pkts; /* incoming packet counter */
77781 + atomic_unchecked_t in_pkts; /* incoming packet counter */
77782
77783 /* packet transmitter for different forwarding methods. If it
77784 mangles the packet, it must return NF_DROP or better NF_STOLEN,
77785 @@ -737,7 +737,7 @@ struct ip_vs_dest {
77786 __be16 port; /* port number of the server */
77787 union nf_inet_addr addr; /* IP address of the server */
77788 volatile unsigned int flags; /* dest status flags */
77789 - atomic_t conn_flags; /* flags to copy to conn */
77790 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
77791 atomic_t weight; /* server weight */
77792
77793 atomic_t refcnt; /* reference counter */
77794 @@ -993,11 +993,11 @@ struct netns_ipvs {
77795 /* ip_vs_lblc */
77796 int sysctl_lblc_expiration;
77797 struct ctl_table_header *lblc_ctl_header;
77798 - struct ctl_table *lblc_ctl_table;
77799 + ctl_table_no_const *lblc_ctl_table;
77800 /* ip_vs_lblcr */
77801 int sysctl_lblcr_expiration;
77802 struct ctl_table_header *lblcr_ctl_header;
77803 - struct ctl_table *lblcr_ctl_table;
77804 + ctl_table_no_const *lblcr_ctl_table;
77805 /* ip_vs_est */
77806 struct list_head est_list; /* estimator list */
77807 spinlock_t est_lock;
77808 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
77809 index 80ffde3..968b0f4 100644
77810 --- a/include/net/irda/ircomm_tty.h
77811 +++ b/include/net/irda/ircomm_tty.h
77812 @@ -35,6 +35,7 @@
77813 #include <linux/termios.h>
77814 #include <linux/timer.h>
77815 #include <linux/tty.h> /* struct tty_struct */
77816 +#include <asm/local.h>
77817
77818 #include <net/irda/irias_object.h>
77819 #include <net/irda/ircomm_core.h>
77820 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
77821 index 714cc9a..ea05f3e 100644
77822 --- a/include/net/iucv/af_iucv.h
77823 +++ b/include/net/iucv/af_iucv.h
77824 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
77825 struct iucv_sock_list {
77826 struct hlist_head head;
77827 rwlock_t lock;
77828 - atomic_t autobind_name;
77829 + atomic_unchecked_t autobind_name;
77830 };
77831
77832 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
77833 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
77834 index df83f69..9b640b8 100644
77835 --- a/include/net/llc_c_ac.h
77836 +++ b/include/net/llc_c_ac.h
77837 @@ -87,7 +87,7 @@
77838 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
77839 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
77840
77841 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77842 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77843
77844 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
77845 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
77846 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
77847 index 6ca3113..f8026dd 100644
77848 --- a/include/net/llc_c_ev.h
77849 +++ b/include/net/llc_c_ev.h
77850 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
77851 return (struct llc_conn_state_ev *)skb->cb;
77852 }
77853
77854 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77855 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77856 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77857 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77858
77859 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
77860 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
77861 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
77862 index 0e79cfb..f46db31 100644
77863 --- a/include/net/llc_c_st.h
77864 +++ b/include/net/llc_c_st.h
77865 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
77866 u8 next_state;
77867 llc_conn_ev_qfyr_t *ev_qualifiers;
77868 llc_conn_action_t *ev_actions;
77869 -};
77870 +} __do_const;
77871
77872 struct llc_conn_state {
77873 u8 current_state;
77874 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
77875 index 37a3bbd..55a4241 100644
77876 --- a/include/net/llc_s_ac.h
77877 +++ b/include/net/llc_s_ac.h
77878 @@ -23,7 +23,7 @@
77879 #define SAP_ACT_TEST_IND 9
77880
77881 /* All action functions must look like this */
77882 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77883 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77884
77885 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
77886 struct sk_buff *skb);
77887 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
77888 index 567c681..cd73ac0 100644
77889 --- a/include/net/llc_s_st.h
77890 +++ b/include/net/llc_s_st.h
77891 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
77892 llc_sap_ev_t ev;
77893 u8 next_state;
77894 llc_sap_action_t *ev_actions;
77895 -};
77896 +} __do_const;
77897
77898 struct llc_sap_state {
77899 u8 curr_state;
77900 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
77901 index 551ba6a..11c99c1 100644
77902 --- a/include/net/mac80211.h
77903 +++ b/include/net/mac80211.h
77904 @@ -4221,7 +4221,7 @@ struct rate_control_ops {
77905 void (*add_sta_debugfs)(void *priv, void *priv_sta,
77906 struct dentry *dir);
77907 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
77908 -};
77909 +} __do_const;
77910
77911 static inline int rate_supported(struct ieee80211_sta *sta,
77912 enum ieee80211_band band,
77913 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
77914 index 7e748ad..5c6229b 100644
77915 --- a/include/net/neighbour.h
77916 +++ b/include/net/neighbour.h
77917 @@ -123,7 +123,7 @@ struct neigh_ops {
77918 void (*error_report)(struct neighbour *, struct sk_buff *);
77919 int (*output)(struct neighbour *, struct sk_buff *);
77920 int (*connected_output)(struct neighbour *, struct sk_buff *);
77921 -};
77922 +} __do_const;
77923
77924 struct pneigh_entry {
77925 struct pneigh_entry *next;
77926 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
77927 index 84e37b1..8eba19a 100644
77928 --- a/include/net/net_namespace.h
77929 +++ b/include/net/net_namespace.h
77930 @@ -119,8 +119,8 @@ struct net {
77931 struct netns_ipvs *ipvs;
77932 #endif
77933 struct sock *diag_nlsk;
77934 - atomic_t rt_genid;
77935 - atomic_t fnhe_genid;
77936 + atomic_unchecked_t rt_genid;
77937 + atomic_unchecked_t fnhe_genid;
77938 };
77939
77940 /*
77941 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
77942 #define __net_init __init
77943 #define __net_exit __exit_refok
77944 #define __net_initdata __initdata
77945 +#ifdef CONSTIFY_PLUGIN
77946 #define __net_initconst __initconst
77947 +#else
77948 +#define __net_initconst __initdata
77949 +#endif
77950 #endif
77951
77952 struct pernet_operations {
77953 @@ -287,7 +291,7 @@ struct pernet_operations {
77954 void (*exit_batch)(struct list_head *net_exit_list);
77955 int *id;
77956 size_t size;
77957 -};
77958 +} __do_const;
77959
77960 /*
77961 * Use these carefully. If you implement a network device and it
77962 @@ -335,22 +339,22 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
77963
77964 static inline int rt_genid(struct net *net)
77965 {
77966 - return atomic_read(&net->rt_genid);
77967 + return atomic_read_unchecked(&net->rt_genid);
77968 }
77969
77970 static inline void rt_genid_bump(struct net *net)
77971 {
77972 - atomic_inc(&net->rt_genid);
77973 + atomic_inc_unchecked(&net->rt_genid);
77974 }
77975
77976 static inline int fnhe_genid(struct net *net)
77977 {
77978 - return atomic_read(&net->fnhe_genid);
77979 + return atomic_read_unchecked(&net->fnhe_genid);
77980 }
77981
77982 static inline void fnhe_genid_bump(struct net *net)
77983 {
77984 - atomic_inc(&net->fnhe_genid);
77985 + atomic_inc_unchecked(&net->fnhe_genid);
77986 }
77987
77988 #endif /* __NET_NET_NAMESPACE_H */
77989 diff --git a/include/net/netdma.h b/include/net/netdma.h
77990 index 8ba8ce2..99b7fff 100644
77991 --- a/include/net/netdma.h
77992 +++ b/include/net/netdma.h
77993 @@ -24,7 +24,7 @@
77994 #include <linux/dmaengine.h>
77995 #include <linux/skbuff.h>
77996
77997 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
77998 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
77999 struct sk_buff *skb, int offset, struct iovec *to,
78000 size_t len, struct dma_pinned_list *pinned_list);
78001
78002 diff --git a/include/net/netlink.h b/include/net/netlink.h
78003 index 9690b0f..87aded7 100644
78004 --- a/include/net/netlink.h
78005 +++ b/include/net/netlink.h
78006 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
78007 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
78008 {
78009 if (mark)
78010 - skb_trim(skb, (unsigned char *) mark - skb->data);
78011 + skb_trim(skb, (const unsigned char *) mark - skb->data);
78012 }
78013
78014 /**
78015 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
78016 index c9c0c53..53f24c3 100644
78017 --- a/include/net/netns/conntrack.h
78018 +++ b/include/net/netns/conntrack.h
78019 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
78020 struct nf_proto_net {
78021 #ifdef CONFIG_SYSCTL
78022 struct ctl_table_header *ctl_table_header;
78023 - struct ctl_table *ctl_table;
78024 + ctl_table_no_const *ctl_table;
78025 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
78026 struct ctl_table_header *ctl_compat_header;
78027 - struct ctl_table *ctl_compat_table;
78028 + ctl_table_no_const *ctl_compat_table;
78029 #endif
78030 #endif
78031 unsigned int users;
78032 @@ -58,7 +58,7 @@ struct nf_ip_net {
78033 struct nf_icmp_net icmpv6;
78034 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
78035 struct ctl_table_header *ctl_table_header;
78036 - struct ctl_table *ctl_table;
78037 + ctl_table_no_const *ctl_table;
78038 #endif
78039 };
78040
78041 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
78042 index 2ba9de8..47bd6c7 100644
78043 --- a/include/net/netns/ipv4.h
78044 +++ b/include/net/netns/ipv4.h
78045 @@ -67,7 +67,7 @@ struct netns_ipv4 {
78046 kgid_t sysctl_ping_group_range[2];
78047 long sysctl_tcp_mem[3];
78048
78049 - atomic_t dev_addr_genid;
78050 + atomic_unchecked_t dev_addr_genid;
78051
78052 #ifdef CONFIG_IP_MROUTE
78053 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
78054 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
78055 index 005e2c2..023d340 100644
78056 --- a/include/net/netns/ipv6.h
78057 +++ b/include/net/netns/ipv6.h
78058 @@ -71,7 +71,7 @@ struct netns_ipv6 {
78059 struct fib_rules_ops *mr6_rules_ops;
78060 #endif
78061 #endif
78062 - atomic_t dev_addr_genid;
78063 + atomic_unchecked_t dev_addr_genid;
78064 };
78065
78066 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
78067 diff --git a/include/net/ping.h b/include/net/ping.h
78068 index 5db0224..0d65365 100644
78069 --- a/include/net/ping.h
78070 +++ b/include/net/ping.h
78071 @@ -55,7 +55,7 @@ struct ping_iter_state {
78072 extern struct proto ping_prot;
78073 extern struct ping_table ping_table;
78074 #if IS_ENABLED(CONFIG_IPV6)
78075 -extern struct pingv6_ops pingv6_ops;
78076 +extern struct pingv6_ops *pingv6_ops;
78077 #endif
78078
78079 struct pingfakehdr {
78080 diff --git a/include/net/protocol.h b/include/net/protocol.h
78081 index 047c047..b9dad15 100644
78082 --- a/include/net/protocol.h
78083 +++ b/include/net/protocol.h
78084 @@ -44,7 +44,7 @@ struct net_protocol {
78085 void (*err_handler)(struct sk_buff *skb, u32 info);
78086 unsigned int no_policy:1,
78087 netns_ok:1;
78088 -};
78089 +} __do_const;
78090
78091 #if IS_ENABLED(CONFIG_IPV6)
78092 struct inet6_protocol {
78093 @@ -57,7 +57,7 @@ struct inet6_protocol {
78094 u8 type, u8 code, int offset,
78095 __be32 info);
78096 unsigned int flags; /* INET6_PROTO_xxx */
78097 -};
78098 +} __do_const;
78099
78100 #define INET6_PROTO_NOPOLICY 0x1
78101 #define INET6_PROTO_FINAL 0x2
78102 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
78103 index 7026648..584cc8c 100644
78104 --- a/include/net/rtnetlink.h
78105 +++ b/include/net/rtnetlink.h
78106 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
78107 const struct net_device *dev);
78108 unsigned int (*get_num_tx_queues)(void);
78109 unsigned int (*get_num_rx_queues)(void);
78110 -};
78111 +} __do_const;
78112
78113 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
78114 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
78115 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
78116 index 2a82d13..62a31c2 100644
78117 --- a/include/net/sctp/sm.h
78118 +++ b/include/net/sctp/sm.h
78119 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
78120 typedef struct {
78121 sctp_state_fn_t *fn;
78122 const char *name;
78123 -} sctp_sm_table_entry_t;
78124 +} __do_const sctp_sm_table_entry_t;
78125
78126 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
78127 * currently in use.
78128 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
78129 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
78130
78131 /* Extern declarations for major data structures. */
78132 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78133 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78134
78135
78136 /* Get the size of a DATA chunk payload. */
78137 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
78138 index e745c92..3641448 100644
78139 --- a/include/net/sctp/structs.h
78140 +++ b/include/net/sctp/structs.h
78141 @@ -516,7 +516,7 @@ struct sctp_pf {
78142 struct sctp_association *asoc);
78143 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
78144 struct sctp_af *af;
78145 -};
78146 +} __do_const;
78147
78148
78149 /* Structure to track chunk fragments that have been acked, but peer
78150 diff --git a/include/net/sock.h b/include/net/sock.h
78151 index 04e148f..3b1c7e0 100644
78152 --- a/include/net/sock.h
78153 +++ b/include/net/sock.h
78154 @@ -332,7 +332,7 @@ struct sock {
78155 unsigned int sk_napi_id;
78156 unsigned int sk_ll_usec;
78157 #endif
78158 - atomic_t sk_drops;
78159 + atomic_unchecked_t sk_drops;
78160 int sk_rcvbuf;
78161
78162 struct sk_filter __rcu *sk_filter;
78163 @@ -1805,7 +1805,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
78164 }
78165
78166 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
78167 - char __user *from, char *to,
78168 + char __user *from, unsigned char *to,
78169 int copy, int offset)
78170 {
78171 if (skb->ip_summed == CHECKSUM_NONE) {
78172 @@ -2067,7 +2067,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
78173 }
78174 }
78175
78176 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78177 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78178
78179 /**
78180 * sk_page_frag - return an appropriate page_frag
78181 diff --git a/include/net/tcp.h b/include/net/tcp.h
78182 index 46cb8a4..32b7b4a 100644
78183 --- a/include/net/tcp.h
78184 +++ b/include/net/tcp.h
78185 @@ -522,7 +522,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
78186 extern void tcp_xmit_retransmit_queue(struct sock *);
78187 extern void tcp_simple_retransmit(struct sock *);
78188 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
78189 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78190 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78191
78192 extern void tcp_send_probe0(struct sock *);
78193 extern void tcp_send_partial(struct sock *);
78194 @@ -695,8 +695,8 @@ struct tcp_skb_cb {
78195 struct inet6_skb_parm h6;
78196 #endif
78197 } header; /* For incoming frames */
78198 - __u32 seq; /* Starting sequence number */
78199 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
78200 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
78201 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
78202 __u32 when; /* used to compute rtt's */
78203 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
78204
78205 @@ -710,7 +710,7 @@ struct tcp_skb_cb {
78206
78207 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
78208 /* 1 byte hole */
78209 - __u32 ack_seq; /* Sequence number ACK'd */
78210 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
78211 };
78212
78213 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
78214 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
78215 index e823786..53b0608 100644
78216 --- a/include/net/xfrm.h
78217 +++ b/include/net/xfrm.h
78218 @@ -287,7 +287,6 @@ struct xfrm_dst;
78219 struct xfrm_policy_afinfo {
78220 unsigned short family;
78221 struct dst_ops *dst_ops;
78222 - void (*garbage_collect)(struct net *net);
78223 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
78224 const xfrm_address_t *saddr,
78225 const xfrm_address_t *daddr);
78226 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
78227 struct net_device *dev,
78228 const struct flowi *fl);
78229 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
78230 -};
78231 +} __do_const;
78232
78233 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
78234 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
78235 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
78236 int (*transport_finish)(struct sk_buff *skb,
78237 int async);
78238 void (*local_error)(struct sk_buff *skb, u32 mtu);
78239 -};
78240 +} __do_const;
78241
78242 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
78243 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
78244 @@ -427,7 +426,7 @@ struct xfrm_mode {
78245 struct module *owner;
78246 unsigned int encap;
78247 int flags;
78248 -};
78249 +} __do_const;
78250
78251 /* Flags for xfrm_mode. */
78252 enum {
78253 @@ -524,7 +523,7 @@ struct xfrm_policy {
78254 struct timer_list timer;
78255
78256 struct flow_cache_object flo;
78257 - atomic_t genid;
78258 + atomic_unchecked_t genid;
78259 u32 priority;
78260 u32 index;
78261 struct xfrm_mark mark;
78262 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
78263 }
78264
78265 extern void xfrm_garbage_collect(struct net *net);
78266 +extern void xfrm_garbage_collect_deferred(struct net *net);
78267
78268 #else
78269
78270 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
78271 static inline void xfrm_garbage_collect(struct net *net)
78272 {
78273 }
78274 +static inline void xfrm_garbage_collect_deferred(struct net *net)
78275 +{
78276 +}
78277 #endif
78278
78279 static __inline__
78280 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
78281 index 1a046b1..ee0bef0 100644
78282 --- a/include/rdma/iw_cm.h
78283 +++ b/include/rdma/iw_cm.h
78284 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
78285 int backlog);
78286
78287 int (*destroy_listen)(struct iw_cm_id *cm_id);
78288 -};
78289 +} __no_const;
78290
78291 /**
78292 * iw_create_cm_id - Create an IW CM identifier.
78293 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
78294 index e1379b4..67eafbe 100644
78295 --- a/include/scsi/libfc.h
78296 +++ b/include/scsi/libfc.h
78297 @@ -762,6 +762,7 @@ struct libfc_function_template {
78298 */
78299 void (*disc_stop_final) (struct fc_lport *);
78300 };
78301 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
78302
78303 /**
78304 * struct fc_disc - Discovery context
78305 @@ -866,7 +867,7 @@ struct fc_lport {
78306 struct fc_vport *vport;
78307
78308 /* Operational Information */
78309 - struct libfc_function_template tt;
78310 + libfc_function_template_no_const tt;
78311 u8 link_up;
78312 u8 qfull;
78313 enum fc_lport_state state;
78314 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
78315 index a44954c..5da04b2 100644
78316 --- a/include/scsi/scsi_device.h
78317 +++ b/include/scsi/scsi_device.h
78318 @@ -172,9 +172,9 @@ struct scsi_device {
78319 unsigned int max_device_blocked; /* what device_blocked counts down from */
78320 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
78321
78322 - atomic_t iorequest_cnt;
78323 - atomic_t iodone_cnt;
78324 - atomic_t ioerr_cnt;
78325 + atomic_unchecked_t iorequest_cnt;
78326 + atomic_unchecked_t iodone_cnt;
78327 + atomic_unchecked_t ioerr_cnt;
78328
78329 struct device sdev_gendev,
78330 sdev_dev;
78331 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
78332 index b797e8f..8e2c3aa 100644
78333 --- a/include/scsi/scsi_transport_fc.h
78334 +++ b/include/scsi/scsi_transport_fc.h
78335 @@ -751,7 +751,8 @@ struct fc_function_template {
78336 unsigned long show_host_system_hostname:1;
78337
78338 unsigned long disable_target_scan:1;
78339 -};
78340 +} __do_const;
78341 +typedef struct fc_function_template __no_const fc_function_template_no_const;
78342
78343
78344 /**
78345 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
78346 index 9031a26..750d592 100644
78347 --- a/include/sound/compress_driver.h
78348 +++ b/include/sound/compress_driver.h
78349 @@ -128,7 +128,7 @@ struct snd_compr_ops {
78350 struct snd_compr_caps *caps);
78351 int (*get_codec_caps) (struct snd_compr_stream *stream,
78352 struct snd_compr_codec_caps *codec);
78353 -};
78354 +} __no_const;
78355
78356 /**
78357 * struct snd_compr: Compressed device
78358 diff --git a/include/sound/soc.h b/include/sound/soc.h
78359 index 6eabee7..58afb50 100644
78360 --- a/include/sound/soc.h
78361 +++ b/include/sound/soc.h
78362 @@ -783,7 +783,7 @@ struct snd_soc_codec_driver {
78363 /* probe ordering - for components with runtime dependencies */
78364 int probe_order;
78365 int remove_order;
78366 -};
78367 +} __do_const;
78368
78369 /* SoC platform interface */
78370 struct snd_soc_platform_driver {
78371 @@ -829,7 +829,7 @@ struct snd_soc_platform_driver {
78372 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
78373 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
78374 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
78375 -};
78376 +} __do_const;
78377
78378 struct snd_soc_platform {
78379 const char *name;
78380 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
78381 index e34fc90..ecefa2c 100644
78382 --- a/include/target/target_core_base.h
78383 +++ b/include/target/target_core_base.h
78384 @@ -643,7 +643,7 @@ struct se_device {
78385 spinlock_t stats_lock;
78386 /* Active commands on this virtual SE device */
78387 atomic_t simple_cmds;
78388 - atomic_t dev_ordered_id;
78389 + atomic_unchecked_t dev_ordered_id;
78390 atomic_t dev_ordered_sync;
78391 atomic_t dev_qf_count;
78392 int export_count;
78393 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
78394 new file mode 100644
78395 index 0000000..fb634b7
78396 --- /dev/null
78397 +++ b/include/trace/events/fs.h
78398 @@ -0,0 +1,53 @@
78399 +#undef TRACE_SYSTEM
78400 +#define TRACE_SYSTEM fs
78401 +
78402 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
78403 +#define _TRACE_FS_H
78404 +
78405 +#include <linux/fs.h>
78406 +#include <linux/tracepoint.h>
78407 +
78408 +TRACE_EVENT(do_sys_open,
78409 +
78410 + TP_PROTO(const char *filename, int flags, int mode),
78411 +
78412 + TP_ARGS(filename, flags, mode),
78413 +
78414 + TP_STRUCT__entry(
78415 + __string( filename, filename )
78416 + __field( int, flags )
78417 + __field( int, mode )
78418 + ),
78419 +
78420 + TP_fast_assign(
78421 + __assign_str(filename, filename);
78422 + __entry->flags = flags;
78423 + __entry->mode = mode;
78424 + ),
78425 +
78426 + TP_printk("\"%s\" %x %o",
78427 + __get_str(filename), __entry->flags, __entry->mode)
78428 +);
78429 +
78430 +TRACE_EVENT(open_exec,
78431 +
78432 + TP_PROTO(const char *filename),
78433 +
78434 + TP_ARGS(filename),
78435 +
78436 + TP_STRUCT__entry(
78437 + __string( filename, filename )
78438 + ),
78439 +
78440 + TP_fast_assign(
78441 + __assign_str(filename, filename);
78442 + ),
78443 +
78444 + TP_printk("\"%s\"",
78445 + __get_str(filename))
78446 +);
78447 +
78448 +#endif /* _TRACE_FS_H */
78449 +
78450 +/* This part must be outside protection */
78451 +#include <trace/define_trace.h>
78452 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
78453 index 1c09820..7f5ec79 100644
78454 --- a/include/trace/events/irq.h
78455 +++ b/include/trace/events/irq.h
78456 @@ -36,7 +36,7 @@ struct softirq_action;
78457 */
78458 TRACE_EVENT(irq_handler_entry,
78459
78460 - TP_PROTO(int irq, struct irqaction *action),
78461 + TP_PROTO(int irq, const struct irqaction *action),
78462
78463 TP_ARGS(irq, action),
78464
78465 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
78466 */
78467 TRACE_EVENT(irq_handler_exit,
78468
78469 - TP_PROTO(int irq, struct irqaction *action, int ret),
78470 + TP_PROTO(int irq, const struct irqaction *action, int ret),
78471
78472 TP_ARGS(irq, action, ret),
78473
78474 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
78475 index 7caf44c..23c6f27 100644
78476 --- a/include/uapi/linux/a.out.h
78477 +++ b/include/uapi/linux/a.out.h
78478 @@ -39,6 +39,14 @@ enum machine_type {
78479 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
78480 };
78481
78482 +/* Constants for the N_FLAGS field */
78483 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78484 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
78485 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
78486 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
78487 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78488 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78489 +
78490 #if !defined (N_MAGIC)
78491 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
78492 #endif
78493 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
78494 index d876736..ccce5c0 100644
78495 --- a/include/uapi/linux/byteorder/little_endian.h
78496 +++ b/include/uapi/linux/byteorder/little_endian.h
78497 @@ -42,51 +42,51 @@
78498
78499 static inline __le64 __cpu_to_le64p(const __u64 *p)
78500 {
78501 - return (__force __le64)*p;
78502 + return (__force const __le64)*p;
78503 }
78504 -static inline __u64 __le64_to_cpup(const __le64 *p)
78505 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
78506 {
78507 - return (__force __u64)*p;
78508 + return (__force const __u64)*p;
78509 }
78510 static inline __le32 __cpu_to_le32p(const __u32 *p)
78511 {
78512 - return (__force __le32)*p;
78513 + return (__force const __le32)*p;
78514 }
78515 static inline __u32 __le32_to_cpup(const __le32 *p)
78516 {
78517 - return (__force __u32)*p;
78518 + return (__force const __u32)*p;
78519 }
78520 static inline __le16 __cpu_to_le16p(const __u16 *p)
78521 {
78522 - return (__force __le16)*p;
78523 + return (__force const __le16)*p;
78524 }
78525 static inline __u16 __le16_to_cpup(const __le16 *p)
78526 {
78527 - return (__force __u16)*p;
78528 + return (__force const __u16)*p;
78529 }
78530 static inline __be64 __cpu_to_be64p(const __u64 *p)
78531 {
78532 - return (__force __be64)__swab64p(p);
78533 + return (__force const __be64)__swab64p(p);
78534 }
78535 static inline __u64 __be64_to_cpup(const __be64 *p)
78536 {
78537 - return __swab64p((__u64 *)p);
78538 + return __swab64p((const __u64 *)p);
78539 }
78540 static inline __be32 __cpu_to_be32p(const __u32 *p)
78541 {
78542 - return (__force __be32)__swab32p(p);
78543 + return (__force const __be32)__swab32p(p);
78544 }
78545 -static inline __u32 __be32_to_cpup(const __be32 *p)
78546 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
78547 {
78548 - return __swab32p((__u32 *)p);
78549 + return __swab32p((const __u32 *)p);
78550 }
78551 static inline __be16 __cpu_to_be16p(const __u16 *p)
78552 {
78553 - return (__force __be16)__swab16p(p);
78554 + return (__force const __be16)__swab16p(p);
78555 }
78556 static inline __u16 __be16_to_cpup(const __be16 *p)
78557 {
78558 - return __swab16p((__u16 *)p);
78559 + return __swab16p((const __u16 *)p);
78560 }
78561 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
78562 #define __le64_to_cpus(x) do { (void)(x); } while (0)
78563 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
78564 index ef6103b..d4e65dd 100644
78565 --- a/include/uapi/linux/elf.h
78566 +++ b/include/uapi/linux/elf.h
78567 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
78568 #define PT_GNU_EH_FRAME 0x6474e550
78569
78570 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
78571 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
78572 +
78573 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
78574 +
78575 +/* Constants for the e_flags field */
78576 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78577 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
78578 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
78579 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
78580 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78581 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78582
78583 /*
78584 * Extended Numbering
78585 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
78586 #define DT_DEBUG 21
78587 #define DT_TEXTREL 22
78588 #define DT_JMPREL 23
78589 +#define DT_FLAGS 30
78590 + #define DF_TEXTREL 0x00000004
78591 #define DT_ENCODING 32
78592 #define OLD_DT_LOOS 0x60000000
78593 #define DT_LOOS 0x6000000d
78594 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
78595 #define PF_W 0x2
78596 #define PF_X 0x1
78597
78598 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
78599 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
78600 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
78601 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
78602 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
78603 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
78604 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
78605 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
78606 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
78607 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
78608 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
78609 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
78610 +
78611 typedef struct elf32_phdr{
78612 Elf32_Word p_type;
78613 Elf32_Off p_offset;
78614 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
78615 #define EI_OSABI 7
78616 #define EI_PAD 8
78617
78618 +#define EI_PAX 14
78619 +
78620 #define ELFMAG0 0x7f /* EI_MAG */
78621 #define ELFMAG1 'E'
78622 #define ELFMAG2 'L'
78623 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
78624 index aa169c4..6a2771d 100644
78625 --- a/include/uapi/linux/personality.h
78626 +++ b/include/uapi/linux/personality.h
78627 @@ -30,6 +30,7 @@ enum {
78628 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
78629 ADDR_NO_RANDOMIZE | \
78630 ADDR_COMPAT_LAYOUT | \
78631 + ADDR_LIMIT_3GB | \
78632 MMAP_PAGE_ZERO)
78633
78634 /*
78635 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
78636 index 7530e74..e714828 100644
78637 --- a/include/uapi/linux/screen_info.h
78638 +++ b/include/uapi/linux/screen_info.h
78639 @@ -43,7 +43,8 @@ struct screen_info {
78640 __u16 pages; /* 0x32 */
78641 __u16 vesa_attributes; /* 0x34 */
78642 __u32 capabilities; /* 0x36 */
78643 - __u8 _reserved[6]; /* 0x3a */
78644 + __u16 vesapm_size; /* 0x3a */
78645 + __u8 _reserved[4]; /* 0x3c */
78646 } __attribute__((packed));
78647
78648 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
78649 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
78650 index 0e011eb..82681b1 100644
78651 --- a/include/uapi/linux/swab.h
78652 +++ b/include/uapi/linux/swab.h
78653 @@ -43,7 +43,7 @@
78654 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
78655 */
78656
78657 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
78658 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
78659 {
78660 #ifdef __HAVE_BUILTIN_BSWAP16__
78661 return __builtin_bswap16(val);
78662 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
78663 #endif
78664 }
78665
78666 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
78667 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
78668 {
78669 #ifdef __HAVE_BUILTIN_BSWAP32__
78670 return __builtin_bswap32(val);
78671 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
78672 #endif
78673 }
78674
78675 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
78676 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
78677 {
78678 #ifdef __HAVE_BUILTIN_BSWAP64__
78679 return __builtin_bswap64(val);
78680 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
78681 index 6d67213..8dab561 100644
78682 --- a/include/uapi/linux/sysctl.h
78683 +++ b/include/uapi/linux/sysctl.h
78684 @@ -155,7 +155,11 @@ enum
78685 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
78686 };
78687
78688 -
78689 +#ifdef CONFIG_PAX_SOFTMODE
78690 +enum {
78691 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
78692 +};
78693 +#endif
78694
78695 /* CTL_VM names: */
78696 enum
78697 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
78698 index e4629b9..6958086 100644
78699 --- a/include/uapi/linux/xattr.h
78700 +++ b/include/uapi/linux/xattr.h
78701 @@ -63,5 +63,9 @@
78702 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
78703 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
78704
78705 +/* User namespace */
78706 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
78707 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
78708 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
78709
78710 #endif /* _UAPI_LINUX_XATTR_H */
78711 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
78712 index f9466fa..f4e2b81 100644
78713 --- a/include/video/udlfb.h
78714 +++ b/include/video/udlfb.h
78715 @@ -53,10 +53,10 @@ struct dlfb_data {
78716 u32 pseudo_palette[256];
78717 int blank_mode; /*one of FB_BLANK_ */
78718 /* blit-only rendering path metrics, exposed through sysfs */
78719 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78720 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
78721 - atomic_t bytes_sent; /* to usb, after compression including overhead */
78722 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
78723 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78724 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
78725 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
78726 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
78727 };
78728
78729 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
78730 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
78731 index 30f5362..8ed8ac9 100644
78732 --- a/include/video/uvesafb.h
78733 +++ b/include/video/uvesafb.h
78734 @@ -122,6 +122,7 @@ struct uvesafb_par {
78735 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
78736 u8 pmi_setpal; /* PMI for palette changes */
78737 u16 *pmi_base; /* protected mode interface location */
78738 + u8 *pmi_code; /* protected mode code location */
78739 void *pmi_start;
78740 void *pmi_pal;
78741 u8 *vbe_state_orig; /*
78742 diff --git a/init/Kconfig b/init/Kconfig
78743 index fed81b5..0d3b964 100644
78744 --- a/init/Kconfig
78745 +++ b/init/Kconfig
78746 @@ -1069,6 +1069,7 @@ endif # CGROUPS
78747
78748 config CHECKPOINT_RESTORE
78749 bool "Checkpoint/restore support" if EXPERT
78750 + depends on !GRKERNSEC
78751 default n
78752 help
78753 Enables additional kernel features in a sake of checkpoint/restore.
78754 @@ -1553,7 +1554,7 @@ config SLUB_DEBUG
78755
78756 config COMPAT_BRK
78757 bool "Disable heap randomization"
78758 - default y
78759 + default n
78760 help
78761 Randomizing heap placement makes heap exploits harder, but it
78762 also breaks ancient binaries (including anything libc5 based).
78763 @@ -1827,7 +1828,7 @@ config INIT_ALL_POSSIBLE
78764 config STOP_MACHINE
78765 bool
78766 default y
78767 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
78768 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
78769 help
78770 Need stop_machine() primitive.
78771
78772 diff --git a/init/Makefile b/init/Makefile
78773 index 7bc47ee..6da2dc7 100644
78774 --- a/init/Makefile
78775 +++ b/init/Makefile
78776 @@ -2,6 +2,9 @@
78777 # Makefile for the linux kernel.
78778 #
78779
78780 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
78781 +asflags-y := $(GCC_PLUGINS_AFLAGS)
78782 +
78783 obj-y := main.o version.o mounts.o
78784 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
78785 obj-y += noinitramfs.o
78786 diff --git a/init/do_mounts.c b/init/do_mounts.c
78787 index 816014c..c2054db 100644
78788 --- a/init/do_mounts.c
78789 +++ b/init/do_mounts.c
78790 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
78791 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
78792 {
78793 struct super_block *s;
78794 - int err = sys_mount(name, "/root", fs, flags, data);
78795 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
78796 if (err)
78797 return err;
78798
78799 - sys_chdir("/root");
78800 + sys_chdir((const char __force_user *)"/root");
78801 s = current->fs->pwd.dentry->d_sb;
78802 ROOT_DEV = s->s_dev;
78803 printk(KERN_INFO
78804 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
78805 va_start(args, fmt);
78806 vsprintf(buf, fmt, args);
78807 va_end(args);
78808 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
78809 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
78810 if (fd >= 0) {
78811 sys_ioctl(fd, FDEJECT, 0);
78812 sys_close(fd);
78813 }
78814 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
78815 - fd = sys_open("/dev/console", O_RDWR, 0);
78816 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
78817 if (fd >= 0) {
78818 sys_ioctl(fd, TCGETS, (long)&termios);
78819 termios.c_lflag &= ~ICANON;
78820 sys_ioctl(fd, TCSETSF, (long)&termios);
78821 - sys_read(fd, &c, 1);
78822 + sys_read(fd, (char __user *)&c, 1);
78823 termios.c_lflag |= ICANON;
78824 sys_ioctl(fd, TCSETSF, (long)&termios);
78825 sys_close(fd);
78826 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
78827 mount_root();
78828 out:
78829 devtmpfs_mount("dev");
78830 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78831 - sys_chroot(".");
78832 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78833 + sys_chroot((const char __force_user *)".");
78834 }
78835 diff --git a/init/do_mounts.h b/init/do_mounts.h
78836 index f5b978a..69dbfe8 100644
78837 --- a/init/do_mounts.h
78838 +++ b/init/do_mounts.h
78839 @@ -15,15 +15,15 @@ extern int root_mountflags;
78840
78841 static inline int create_dev(char *name, dev_t dev)
78842 {
78843 - sys_unlink(name);
78844 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
78845 + sys_unlink((char __force_user *)name);
78846 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
78847 }
78848
78849 #if BITS_PER_LONG == 32
78850 static inline u32 bstat(char *name)
78851 {
78852 struct stat64 stat;
78853 - if (sys_stat64(name, &stat) != 0)
78854 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
78855 return 0;
78856 if (!S_ISBLK(stat.st_mode))
78857 return 0;
78858 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
78859 static inline u32 bstat(char *name)
78860 {
78861 struct stat stat;
78862 - if (sys_newstat(name, &stat) != 0)
78863 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
78864 return 0;
78865 if (!S_ISBLK(stat.st_mode))
78866 return 0;
78867 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
78868 index 3e0878e..8a9d7a0 100644
78869 --- a/init/do_mounts_initrd.c
78870 +++ b/init/do_mounts_initrd.c
78871 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
78872 {
78873 sys_unshare(CLONE_FS | CLONE_FILES);
78874 /* stdin/stdout/stderr for /linuxrc */
78875 - sys_open("/dev/console", O_RDWR, 0);
78876 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
78877 sys_dup(0);
78878 sys_dup(0);
78879 /* move initrd over / and chdir/chroot in initrd root */
78880 - sys_chdir("/root");
78881 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78882 - sys_chroot(".");
78883 + sys_chdir((const char __force_user *)"/root");
78884 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78885 + sys_chroot((const char __force_user *)".");
78886 sys_setsid();
78887 return 0;
78888 }
78889 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
78890 create_dev("/dev/root.old", Root_RAM0);
78891 /* mount initrd on rootfs' /root */
78892 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
78893 - sys_mkdir("/old", 0700);
78894 - sys_chdir("/old");
78895 + sys_mkdir((const char __force_user *)"/old", 0700);
78896 + sys_chdir((const char __force_user *)"/old");
78897
78898 /* try loading default modules from initrd */
78899 load_default_modules();
78900 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
78901 current->flags &= ~PF_FREEZER_SKIP;
78902
78903 /* move initrd to rootfs' /old */
78904 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
78905 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
78906 /* switch root and cwd back to / of rootfs */
78907 - sys_chroot("..");
78908 + sys_chroot((const char __force_user *)"..");
78909
78910 if (new_decode_dev(real_root_dev) == Root_RAM0) {
78911 - sys_chdir("/old");
78912 + sys_chdir((const char __force_user *)"/old");
78913 return;
78914 }
78915
78916 - sys_chdir("/");
78917 + sys_chdir((const char __force_user *)"/");
78918 ROOT_DEV = new_decode_dev(real_root_dev);
78919 mount_root();
78920
78921 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
78922 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
78923 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
78924 if (!error)
78925 printk("okay\n");
78926 else {
78927 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
78928 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
78929 if (error == -ENOENT)
78930 printk("/initrd does not exist. Ignored.\n");
78931 else
78932 printk("failed\n");
78933 printk(KERN_NOTICE "Unmounting old root\n");
78934 - sys_umount("/old", MNT_DETACH);
78935 + sys_umount((char __force_user *)"/old", MNT_DETACH);
78936 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
78937 if (fd < 0) {
78938 error = fd;
78939 @@ -127,11 +127,11 @@ int __init initrd_load(void)
78940 * mounted in the normal path.
78941 */
78942 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
78943 - sys_unlink("/initrd.image");
78944 + sys_unlink((const char __force_user *)"/initrd.image");
78945 handle_initrd();
78946 return 1;
78947 }
78948 }
78949 - sys_unlink("/initrd.image");
78950 + sys_unlink((const char __force_user *)"/initrd.image");
78951 return 0;
78952 }
78953 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
78954 index 8cb6db5..d729f50 100644
78955 --- a/init/do_mounts_md.c
78956 +++ b/init/do_mounts_md.c
78957 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
78958 partitioned ? "_d" : "", minor,
78959 md_setup_args[ent].device_names);
78960
78961 - fd = sys_open(name, 0, 0);
78962 + fd = sys_open((char __force_user *)name, 0, 0);
78963 if (fd < 0) {
78964 printk(KERN_ERR "md: open failed - cannot start "
78965 "array %s\n", name);
78966 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
78967 * array without it
78968 */
78969 sys_close(fd);
78970 - fd = sys_open(name, 0, 0);
78971 + fd = sys_open((char __force_user *)name, 0, 0);
78972 sys_ioctl(fd, BLKRRPART, 0);
78973 }
78974 sys_close(fd);
78975 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
78976
78977 wait_for_device_probe();
78978
78979 - fd = sys_open("/dev/md0", 0, 0);
78980 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
78981 if (fd >= 0) {
78982 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
78983 sys_close(fd);
78984 diff --git a/init/init_task.c b/init/init_task.c
78985 index ba0a7f36..2bcf1d5 100644
78986 --- a/init/init_task.c
78987 +++ b/init/init_task.c
78988 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
78989 * Initial thread structure. Alignment of this is handled by a special
78990 * linker map entry.
78991 */
78992 +#ifdef CONFIG_X86
78993 +union thread_union init_thread_union __init_task_data;
78994 +#else
78995 union thread_union init_thread_union __init_task_data =
78996 { INIT_THREAD_INFO(init_task) };
78997 +#endif
78998 diff --git a/init/initramfs.c b/init/initramfs.c
78999 index a67ef9d..2d17ed9 100644
79000 --- a/init/initramfs.c
79001 +++ b/init/initramfs.c
79002 @@ -84,7 +84,7 @@ static void __init free_hash(void)
79003 }
79004 }
79005
79006 -static long __init do_utime(char *filename, time_t mtime)
79007 +static long __init do_utime(char __force_user *filename, time_t mtime)
79008 {
79009 struct timespec t[2];
79010
79011 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
79012 struct dir_entry *de, *tmp;
79013 list_for_each_entry_safe(de, tmp, &dir_list, list) {
79014 list_del(&de->list);
79015 - do_utime(de->name, de->mtime);
79016 + do_utime((char __force_user *)de->name, de->mtime);
79017 kfree(de->name);
79018 kfree(de);
79019 }
79020 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
79021 if (nlink >= 2) {
79022 char *old = find_link(major, minor, ino, mode, collected);
79023 if (old)
79024 - return (sys_link(old, collected) < 0) ? -1 : 1;
79025 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
79026 }
79027 return 0;
79028 }
79029 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
79030 {
79031 struct stat st;
79032
79033 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
79034 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
79035 if (S_ISDIR(st.st_mode))
79036 - sys_rmdir(path);
79037 + sys_rmdir((char __force_user *)path);
79038 else
79039 - sys_unlink(path);
79040 + sys_unlink((char __force_user *)path);
79041 }
79042 }
79043
79044 @@ -315,7 +315,7 @@ static int __init do_name(void)
79045 int openflags = O_WRONLY|O_CREAT;
79046 if (ml != 1)
79047 openflags |= O_TRUNC;
79048 - wfd = sys_open(collected, openflags, mode);
79049 + wfd = sys_open((char __force_user *)collected, openflags, mode);
79050
79051 if (wfd >= 0) {
79052 sys_fchown(wfd, uid, gid);
79053 @@ -327,17 +327,17 @@ static int __init do_name(void)
79054 }
79055 }
79056 } else if (S_ISDIR(mode)) {
79057 - sys_mkdir(collected, mode);
79058 - sys_chown(collected, uid, gid);
79059 - sys_chmod(collected, mode);
79060 + sys_mkdir((char __force_user *)collected, mode);
79061 + sys_chown((char __force_user *)collected, uid, gid);
79062 + sys_chmod((char __force_user *)collected, mode);
79063 dir_add(collected, mtime);
79064 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
79065 S_ISFIFO(mode) || S_ISSOCK(mode)) {
79066 if (maybe_link() == 0) {
79067 - sys_mknod(collected, mode, rdev);
79068 - sys_chown(collected, uid, gid);
79069 - sys_chmod(collected, mode);
79070 - do_utime(collected, mtime);
79071 + sys_mknod((char __force_user *)collected, mode, rdev);
79072 + sys_chown((char __force_user *)collected, uid, gid);
79073 + sys_chmod((char __force_user *)collected, mode);
79074 + do_utime((char __force_user *)collected, mtime);
79075 }
79076 }
79077 return 0;
79078 @@ -346,15 +346,15 @@ static int __init do_name(void)
79079 static int __init do_copy(void)
79080 {
79081 if (count >= body_len) {
79082 - sys_write(wfd, victim, body_len);
79083 + sys_write(wfd, (char __force_user *)victim, body_len);
79084 sys_close(wfd);
79085 - do_utime(vcollected, mtime);
79086 + do_utime((char __force_user *)vcollected, mtime);
79087 kfree(vcollected);
79088 eat(body_len);
79089 state = SkipIt;
79090 return 0;
79091 } else {
79092 - sys_write(wfd, victim, count);
79093 + sys_write(wfd, (char __force_user *)victim, count);
79094 body_len -= count;
79095 eat(count);
79096 return 1;
79097 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
79098 {
79099 collected[N_ALIGN(name_len) + body_len] = '\0';
79100 clean_path(collected, 0);
79101 - sys_symlink(collected + N_ALIGN(name_len), collected);
79102 - sys_lchown(collected, uid, gid);
79103 - do_utime(collected, mtime);
79104 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
79105 + sys_lchown((char __force_user *)collected, uid, gid);
79106 + do_utime((char __force_user *)collected, mtime);
79107 state = SkipIt;
79108 next_state = Reset;
79109 return 0;
79110 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
79111 {
79112 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
79113 if (err)
79114 - panic(err); /* Failed to decompress INTERNAL initramfs */
79115 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
79116 if (initrd_start) {
79117 #ifdef CONFIG_BLK_DEV_RAM
79118 int fd;
79119 diff --git a/init/main.c b/init/main.c
79120 index 586cd33..f1af30f 100644
79121 --- a/init/main.c
79122 +++ b/init/main.c
79123 @@ -102,6 +102,8 @@ static inline void mark_rodata_ro(void) { }
79124 extern void tc_init(void);
79125 #endif
79126
79127 +extern void grsecurity_init(void);
79128 +
79129 /*
79130 * Debug helper: via this flag we know that we are in 'early bootup code'
79131 * where only the boot processor is running with IRQ disabled. This means
79132 @@ -155,6 +157,74 @@ static int __init set_reset_devices(char *str)
79133
79134 __setup("reset_devices", set_reset_devices);
79135
79136 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
79137 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
79138 +static int __init setup_grsec_proc_gid(char *str)
79139 +{
79140 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
79141 + return 1;
79142 +}
79143 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
79144 +#endif
79145 +
79146 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
79147 +unsigned long pax_user_shadow_base __read_only;
79148 +EXPORT_SYMBOL(pax_user_shadow_base);
79149 +extern char pax_enter_kernel_user[];
79150 +extern char pax_exit_kernel_user[];
79151 +#endif
79152 +
79153 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
79154 +static int __init setup_pax_nouderef(char *str)
79155 +{
79156 +#ifdef CONFIG_X86_32
79157 + unsigned int cpu;
79158 + struct desc_struct *gdt;
79159 +
79160 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
79161 + gdt = get_cpu_gdt_table(cpu);
79162 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
79163 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
79164 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
79165 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
79166 + }
79167 + loadsegment(ds, __KERNEL_DS);
79168 + loadsegment(es, __KERNEL_DS);
79169 + loadsegment(ss, __KERNEL_DS);
79170 +#else
79171 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
79172 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
79173 + clone_pgd_mask = ~(pgdval_t)0UL;
79174 + pax_user_shadow_base = 0UL;
79175 + setup_clear_cpu_cap(X86_FEATURE_PCID);
79176 +#endif
79177 +
79178 + return 0;
79179 +}
79180 +early_param("pax_nouderef", setup_pax_nouderef);
79181 +
79182 +#ifdef CONFIG_X86_64
79183 +static int __init setup_pax_weakuderef(char *str)
79184 +{
79185 + if (clone_pgd_mask != ~(pgdval_t)0UL)
79186 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
79187 + return 1;
79188 +}
79189 +__setup("pax_weakuderef", setup_pax_weakuderef);
79190 +#endif
79191 +#endif
79192 +
79193 +#ifdef CONFIG_PAX_SOFTMODE
79194 +int pax_softmode;
79195 +
79196 +static int __init setup_pax_softmode(char *str)
79197 +{
79198 + get_option(&str, &pax_softmode);
79199 + return 1;
79200 +}
79201 +__setup("pax_softmode=", setup_pax_softmode);
79202 +#endif
79203 +
79204 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
79205 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
79206 static const char *panic_later, *panic_param;
79207 @@ -680,25 +750,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
79208 {
79209 int count = preempt_count();
79210 int ret;
79211 - char msgbuf[64];
79212 + const char *msg1 = "", *msg2 = "";
79213
79214 if (initcall_debug)
79215 ret = do_one_initcall_debug(fn);
79216 else
79217 ret = fn();
79218
79219 - msgbuf[0] = 0;
79220 -
79221 if (preempt_count() != count) {
79222 - sprintf(msgbuf, "preemption imbalance ");
79223 + msg1 = " preemption imbalance";
79224 preempt_count() = count;
79225 }
79226 if (irqs_disabled()) {
79227 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
79228 + msg2 = " disabled interrupts";
79229 local_irq_enable();
79230 }
79231 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
79232 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
79233
79234 + add_latent_entropy();
79235 return ret;
79236 }
79237
79238 @@ -805,8 +874,8 @@ static int run_init_process(const char *init_filename)
79239 {
79240 argv_init[0] = init_filename;
79241 return do_execve(init_filename,
79242 - (const char __user *const __user *)argv_init,
79243 - (const char __user *const __user *)envp_init);
79244 + (const char __user *const __force_user *)argv_init,
79245 + (const char __user *const __force_user *)envp_init);
79246 }
79247
79248 static noinline void __init kernel_init_freeable(void);
79249 @@ -883,7 +952,7 @@ static noinline void __init kernel_init_freeable(void)
79250 do_basic_setup();
79251
79252 /* Open the /dev/console on the rootfs, this should never fail */
79253 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
79254 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
79255 pr_err("Warning: unable to open an initial console.\n");
79256
79257 (void) sys_dup(0);
79258 @@ -896,11 +965,13 @@ static noinline void __init kernel_init_freeable(void)
79259 if (!ramdisk_execute_command)
79260 ramdisk_execute_command = "/init";
79261
79262 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
79263 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
79264 ramdisk_execute_command = NULL;
79265 prepare_namespace();
79266 }
79267
79268 + grsecurity_init();
79269 +
79270 /*
79271 * Ok, we have completed the initial bootup, and
79272 * we're essentially up and running. Get rid of the
79273 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
79274 index 130dfec..cc88451 100644
79275 --- a/ipc/ipc_sysctl.c
79276 +++ b/ipc/ipc_sysctl.c
79277 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
79278 static int proc_ipc_dointvec(ctl_table *table, int write,
79279 void __user *buffer, size_t *lenp, loff_t *ppos)
79280 {
79281 - struct ctl_table ipc_table;
79282 + ctl_table_no_const ipc_table;
79283
79284 memcpy(&ipc_table, table, sizeof(ipc_table));
79285 ipc_table.data = get_ipc(table);
79286 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
79287 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
79288 void __user *buffer, size_t *lenp, loff_t *ppos)
79289 {
79290 - struct ctl_table ipc_table;
79291 + ctl_table_no_const ipc_table;
79292
79293 memcpy(&ipc_table, table, sizeof(ipc_table));
79294 ipc_table.data = get_ipc(table);
79295 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
79296 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79297 void __user *buffer, size_t *lenp, loff_t *ppos)
79298 {
79299 - struct ctl_table ipc_table;
79300 + ctl_table_no_const ipc_table;
79301 size_t lenp_bef = *lenp;
79302 int rc;
79303
79304 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79305 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
79306 void __user *buffer, size_t *lenp, loff_t *ppos)
79307 {
79308 - struct ctl_table ipc_table;
79309 + ctl_table_no_const ipc_table;
79310 memcpy(&ipc_table, table, sizeof(ipc_table));
79311 ipc_table.data = get_ipc(table);
79312
79313 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
79314 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
79315 void __user *buffer, size_t *lenp, loff_t *ppos)
79316 {
79317 - struct ctl_table ipc_table;
79318 + ctl_table_no_const ipc_table;
79319 size_t lenp_bef = *lenp;
79320 int oldval;
79321 int rc;
79322 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
79323 index 383d638..943fdbb 100644
79324 --- a/ipc/mq_sysctl.c
79325 +++ b/ipc/mq_sysctl.c
79326 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
79327 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
79328 void __user *buffer, size_t *lenp, loff_t *ppos)
79329 {
79330 - struct ctl_table mq_table;
79331 + ctl_table_no_const mq_table;
79332 memcpy(&mq_table, table, sizeof(mq_table));
79333 mq_table.data = get_mq(table);
79334
79335 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
79336 index ae1996d..a35f2cc 100644
79337 --- a/ipc/mqueue.c
79338 +++ b/ipc/mqueue.c
79339 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
79340 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
79341 info->attr.mq_msgsize);
79342
79343 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
79344 spin_lock(&mq_lock);
79345 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
79346 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
79347 diff --git a/ipc/msg.c b/ipc/msg.c
79348 index 558aa91..359e718 100644
79349 --- a/ipc/msg.c
79350 +++ b/ipc/msg.c
79351 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
79352 return security_msg_queue_associate(msq, msgflg);
79353 }
79354
79355 +static struct ipc_ops msg_ops = {
79356 + .getnew = newque,
79357 + .associate = msg_security,
79358 + .more_checks = NULL
79359 +};
79360 +
79361 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
79362 {
79363 struct ipc_namespace *ns;
79364 - struct ipc_ops msg_ops;
79365 struct ipc_params msg_params;
79366
79367 ns = current->nsproxy->ipc_ns;
79368
79369 - msg_ops.getnew = newque;
79370 - msg_ops.associate = msg_security;
79371 - msg_ops.more_checks = NULL;
79372 -
79373 msg_params.key = key;
79374 msg_params.flg = msgflg;
79375
79376 diff --git a/ipc/sem.c b/ipc/sem.c
79377 index 8e2bf30..a711151 100644
79378 --- a/ipc/sem.c
79379 +++ b/ipc/sem.c
79380 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
79381 return 0;
79382 }
79383
79384 +static struct ipc_ops sem_ops = {
79385 + .getnew = newary,
79386 + .associate = sem_security,
79387 + .more_checks = sem_more_checks
79388 +};
79389 +
79390 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79391 {
79392 struct ipc_namespace *ns;
79393 - struct ipc_ops sem_ops;
79394 struct ipc_params sem_params;
79395
79396 ns = current->nsproxy->ipc_ns;
79397 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79398 if (nsems < 0 || nsems > ns->sc_semmsl)
79399 return -EINVAL;
79400
79401 - sem_ops.getnew = newary;
79402 - sem_ops.associate = sem_security;
79403 - sem_ops.more_checks = sem_more_checks;
79404 -
79405 sem_params.key = key;
79406 sem_params.flg = semflg;
79407 sem_params.u.nsems = nsems;
79408 diff --git a/ipc/shm.c b/ipc/shm.c
79409 index d697396..40e887d 100644
79410 --- a/ipc/shm.c
79411 +++ b/ipc/shm.c
79412 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
79413 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
79414 #endif
79415
79416 +#ifdef CONFIG_GRKERNSEC
79417 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79418 + const time_t shm_createtime, const kuid_t cuid,
79419 + const int shmid);
79420 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79421 + const time_t shm_createtime);
79422 +#endif
79423 +
79424 void shm_init_ns(struct ipc_namespace *ns)
79425 {
79426 ns->shm_ctlmax = SHMMAX;
79427 @@ -551,6 +559,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
79428 shp->shm_lprid = 0;
79429 shp->shm_atim = shp->shm_dtim = 0;
79430 shp->shm_ctim = get_seconds();
79431 +#ifdef CONFIG_GRKERNSEC
79432 + {
79433 + struct timespec timeval;
79434 + do_posix_clock_monotonic_gettime(&timeval);
79435 +
79436 + shp->shm_createtime = timeval.tv_sec;
79437 + }
79438 +#endif
79439 shp->shm_segsz = size;
79440 shp->shm_nattch = 0;
79441 shp->shm_file = file;
79442 @@ -604,18 +620,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
79443 return 0;
79444 }
79445
79446 +static struct ipc_ops shm_ops = {
79447 + .getnew = newseg,
79448 + .associate = shm_security,
79449 + .more_checks = shm_more_checks
79450 +};
79451 +
79452 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
79453 {
79454 struct ipc_namespace *ns;
79455 - struct ipc_ops shm_ops;
79456 struct ipc_params shm_params;
79457
79458 ns = current->nsproxy->ipc_ns;
79459
79460 - shm_ops.getnew = newseg;
79461 - shm_ops.associate = shm_security;
79462 - shm_ops.more_checks = shm_more_checks;
79463 -
79464 shm_params.key = key;
79465 shm_params.flg = shmflg;
79466 shm_params.u.size = size;
79467 @@ -1076,6 +1093,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79468 f_mode = FMODE_READ | FMODE_WRITE;
79469 }
79470 if (shmflg & SHM_EXEC) {
79471 +
79472 +#ifdef CONFIG_PAX_MPROTECT
79473 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
79474 + goto out;
79475 +#endif
79476 +
79477 prot |= PROT_EXEC;
79478 acc_mode |= S_IXUGO;
79479 }
79480 @@ -1100,10 +1123,22 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79481 if (err)
79482 goto out_unlock;
79483
79484 +#ifdef CONFIG_GRKERNSEC
79485 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
79486 + shp->shm_perm.cuid, shmid) ||
79487 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
79488 + err = -EACCES;
79489 + goto out_unlock;
79490 + }
79491 +#endif
79492 +
79493 ipc_lock_object(&shp->shm_perm);
79494 path = shp->shm_file->f_path;
79495 path_get(&path);
79496 shp->shm_nattch++;
79497 +#ifdef CONFIG_GRKERNSEC
79498 + shp->shm_lapid = current->pid;
79499 +#endif
79500 size = i_size_read(path.dentry->d_inode);
79501 ipc_unlock_object(&shp->shm_perm);
79502 rcu_read_unlock();
79503 diff --git a/ipc/util.c b/ipc/util.c
79504 index fdb8ae7..f1cb373 100644
79505 --- a/ipc/util.c
79506 +++ b/ipc/util.c
79507 @@ -56,6 +56,8 @@ struct ipc_proc_iface {
79508 int (*show)(struct seq_file *, void *);
79509 };
79510
79511 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
79512 +
79513 static void ipc_memory_notifier(struct work_struct *work)
79514 {
79515 ipcns_notify(IPCNS_MEMCHANGED);
79516 @@ -545,6 +547,9 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
79517 granted_mode >>= 6;
79518 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
79519 granted_mode >>= 3;
79520 + else if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
79521 + return -1;
79522 +
79523 /* is there some bit set in requested_mode but not in granted_mode? */
79524 if ((requested_mode & ~granted_mode & 0007) &&
79525 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
79526 diff --git a/kernel/acct.c b/kernel/acct.c
79527 index 8d6e145..33e0b1e 100644
79528 --- a/kernel/acct.c
79529 +++ b/kernel/acct.c
79530 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
79531 */
79532 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
79533 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
79534 - file->f_op->write(file, (char *)&ac,
79535 + file->f_op->write(file, (char __force_user *)&ac,
79536 sizeof(acct_t), &file->f_pos);
79537 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
79538 set_fs(fs);
79539 diff --git a/kernel/audit.c b/kernel/audit.c
79540 index 7b0e23a..f4d172f 100644
79541 --- a/kernel/audit.c
79542 +++ b/kernel/audit.c
79543 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
79544 3) suppressed due to audit_rate_limit
79545 4) suppressed due to audit_backlog_limit
79546 */
79547 -static atomic_t audit_lost = ATOMIC_INIT(0);
79548 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
79549
79550 /* The netlink socket. */
79551 static struct sock *audit_sock;
79552 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
79553 unsigned long now;
79554 int print;
79555
79556 - atomic_inc(&audit_lost);
79557 + atomic_inc_unchecked(&audit_lost);
79558
79559 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
79560
79561 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
79562 printk(KERN_WARNING
79563 "audit: audit_lost=%d audit_rate_limit=%d "
79564 "audit_backlog_limit=%d\n",
79565 - atomic_read(&audit_lost),
79566 + atomic_read_unchecked(&audit_lost),
79567 audit_rate_limit,
79568 audit_backlog_limit);
79569 audit_panic(message);
79570 @@ -659,18 +659,19 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79571
79572 switch (msg_type) {
79573 case AUDIT_GET:
79574 + status_set.mask = 0;
79575 status_set.enabled = audit_enabled;
79576 status_set.failure = audit_failure;
79577 status_set.pid = audit_pid;
79578 status_set.rate_limit = audit_rate_limit;
79579 status_set.backlog_limit = audit_backlog_limit;
79580 - status_set.lost = atomic_read(&audit_lost);
79581 + status_set.lost = atomic_read_unchecked(&audit_lost);
79582 status_set.backlog = skb_queue_len(&audit_skb_queue);
79583 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
79584 &status_set, sizeof(status_set));
79585 break;
79586 case AUDIT_SET:
79587 - if (nlh->nlmsg_len < sizeof(struct audit_status))
79588 + if (nlmsg_len(nlh) < sizeof(struct audit_status))
79589 return -EINVAL;
79590 status_get = (struct audit_status *)data;
79591 if (status_get->mask & AUDIT_STATUS_ENABLED) {
79592 @@ -832,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79593
79594 memset(&s, 0, sizeof(s));
79595 /* guard against past and future API changes */
79596 - memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
79597 + memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
79598 if ((s.enabled != 0 && s.enabled != 1) ||
79599 (s.log_passwd != 0 && s.log_passwd != 1))
79600 return -EINVAL;
79601 @@ -1251,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
79602 int i, avail, new_len;
79603 unsigned char *ptr;
79604 struct sk_buff *skb;
79605 - static const unsigned char *hex = "0123456789ABCDEF";
79606 + static const unsigned char hex[] = "0123456789ABCDEF";
79607
79608 if (!ab)
79609 return;
79610 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
79611 index 9845cb3..3ec9369 100644
79612 --- a/kernel/auditsc.c
79613 +++ b/kernel/auditsc.c
79614 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
79615 }
79616
79617 /* global counter which is incremented every time something logs in */
79618 -static atomic_t session_id = ATOMIC_INIT(0);
79619 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
79620
79621 /**
79622 * audit_set_loginuid - set current task's audit_context loginuid
79623 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
79624 return -EPERM;
79625 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
79626
79627 - sessionid = atomic_inc_return(&session_id);
79628 + sessionid = atomic_inc_return_unchecked(&session_id);
79629 if (context && context->in_syscall) {
79630 struct audit_buffer *ab;
79631
79632 diff --git a/kernel/capability.c b/kernel/capability.c
79633 index f6c2ce5..982c0f9 100644
79634 --- a/kernel/capability.c
79635 +++ b/kernel/capability.c
79636 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
79637 * before modification is attempted and the application
79638 * fails.
79639 */
79640 + if (tocopy > ARRAY_SIZE(kdata))
79641 + return -EFAULT;
79642 +
79643 if (copy_to_user(dataptr, kdata, tocopy
79644 * sizeof(struct __user_cap_data_struct))) {
79645 return -EFAULT;
79646 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
79647 int ret;
79648
79649 rcu_read_lock();
79650 - ret = security_capable(__task_cred(t), ns, cap);
79651 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
79652 + gr_task_is_capable(t, __task_cred(t), cap);
79653 rcu_read_unlock();
79654
79655 - return (ret == 0);
79656 + return ret;
79657 }
79658
79659 /**
79660 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
79661 int ret;
79662
79663 rcu_read_lock();
79664 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
79665 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
79666 rcu_read_unlock();
79667
79668 - return (ret == 0);
79669 + return ret;
79670 }
79671
79672 /**
79673 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
79674 BUG();
79675 }
79676
79677 - if (security_capable(current_cred(), ns, cap) == 0) {
79678 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
79679 current->flags |= PF_SUPERPRIV;
79680 return true;
79681 }
79682 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
79683 }
79684 EXPORT_SYMBOL(ns_capable);
79685
79686 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
79687 +{
79688 + if (unlikely(!cap_valid(cap))) {
79689 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
79690 + BUG();
79691 + }
79692 +
79693 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
79694 + current->flags |= PF_SUPERPRIV;
79695 + return true;
79696 + }
79697 + return false;
79698 +}
79699 +EXPORT_SYMBOL(ns_capable_nolog);
79700 +
79701 /**
79702 * file_ns_capable - Determine if the file's opener had a capability in effect
79703 * @file: The file we want to check
79704 @@ -432,6 +451,12 @@ bool capable(int cap)
79705 }
79706 EXPORT_SYMBOL(capable);
79707
79708 +bool capable_nolog(int cap)
79709 +{
79710 + return ns_capable_nolog(&init_user_ns, cap);
79711 +}
79712 +EXPORT_SYMBOL(capable_nolog);
79713 +
79714 /**
79715 * nsown_capable - Check superior capability to one's own user_ns
79716 * @cap: The capability in question
79717 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
79718
79719 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79720 }
79721 +
79722 +bool inode_capable_nolog(const struct inode *inode, int cap)
79723 +{
79724 + struct user_namespace *ns = current_user_ns();
79725 +
79726 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79727 +}
79728 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
79729 index d22f597..35f58e2 100644
79730 --- a/kernel/cgroup.c
79731 +++ b/kernel/cgroup.c
79732 @@ -5623,7 +5623,7 @@ static int cgroup_css_links_read(struct cgroup *cgrp,
79733 struct css_set *cset = link->cset;
79734 struct task_struct *task;
79735 int count = 0;
79736 - seq_printf(seq, "css_set %p\n", cset);
79737 + seq_printf(seq, "css_set %pK\n", cset);
79738 list_for_each_entry(task, &cset->tasks, cg_list) {
79739 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
79740 seq_puts(seq, " ...\n");
79741 diff --git a/kernel/compat.c b/kernel/compat.c
79742 index 0a09e48..f44f3f0 100644
79743 --- a/kernel/compat.c
79744 +++ b/kernel/compat.c
79745 @@ -13,6 +13,7 @@
79746
79747 #include <linux/linkage.h>
79748 #include <linux/compat.h>
79749 +#include <linux/module.h>
79750 #include <linux/errno.h>
79751 #include <linux/time.h>
79752 #include <linux/signal.h>
79753 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
79754 mm_segment_t oldfs;
79755 long ret;
79756
79757 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
79758 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
79759 oldfs = get_fs();
79760 set_fs(KERNEL_DS);
79761 ret = hrtimer_nanosleep_restart(restart);
79762 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
79763 oldfs = get_fs();
79764 set_fs(KERNEL_DS);
79765 ret = hrtimer_nanosleep(&tu,
79766 - rmtp ? (struct timespec __user *)&rmt : NULL,
79767 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
79768 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
79769 set_fs(oldfs);
79770
79771 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
79772 mm_segment_t old_fs = get_fs();
79773
79774 set_fs(KERNEL_DS);
79775 - ret = sys_sigpending((old_sigset_t __user *) &s);
79776 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
79777 set_fs(old_fs);
79778 if (ret == 0)
79779 ret = put_user(s, set);
79780 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
79781 mm_segment_t old_fs = get_fs();
79782
79783 set_fs(KERNEL_DS);
79784 - ret = sys_old_getrlimit(resource, &r);
79785 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
79786 set_fs(old_fs);
79787
79788 if (!ret) {
79789 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
79790 set_fs (KERNEL_DS);
79791 ret = sys_wait4(pid,
79792 (stat_addr ?
79793 - (unsigned int __user *) &status : NULL),
79794 - options, (struct rusage __user *) &r);
79795 + (unsigned int __force_user *) &status : NULL),
79796 + options, (struct rusage __force_user *) &r);
79797 set_fs (old_fs);
79798
79799 if (ret > 0) {
79800 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
79801 memset(&info, 0, sizeof(info));
79802
79803 set_fs(KERNEL_DS);
79804 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
79805 - uru ? (struct rusage __user *)&ru : NULL);
79806 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
79807 + uru ? (struct rusage __force_user *)&ru : NULL);
79808 set_fs(old_fs);
79809
79810 if ((ret < 0) || (info.si_signo == 0))
79811 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
79812 oldfs = get_fs();
79813 set_fs(KERNEL_DS);
79814 err = sys_timer_settime(timer_id, flags,
79815 - (struct itimerspec __user *) &newts,
79816 - (struct itimerspec __user *) &oldts);
79817 + (struct itimerspec __force_user *) &newts,
79818 + (struct itimerspec __force_user *) &oldts);
79819 set_fs(oldfs);
79820 if (!err && old && put_compat_itimerspec(old, &oldts))
79821 return -EFAULT;
79822 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
79823 oldfs = get_fs();
79824 set_fs(KERNEL_DS);
79825 err = sys_timer_gettime(timer_id,
79826 - (struct itimerspec __user *) &ts);
79827 + (struct itimerspec __force_user *) &ts);
79828 set_fs(oldfs);
79829 if (!err && put_compat_itimerspec(setting, &ts))
79830 return -EFAULT;
79831 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
79832 oldfs = get_fs();
79833 set_fs(KERNEL_DS);
79834 err = sys_clock_settime(which_clock,
79835 - (struct timespec __user *) &ts);
79836 + (struct timespec __force_user *) &ts);
79837 set_fs(oldfs);
79838 return err;
79839 }
79840 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
79841 oldfs = get_fs();
79842 set_fs(KERNEL_DS);
79843 err = sys_clock_gettime(which_clock,
79844 - (struct timespec __user *) &ts);
79845 + (struct timespec __force_user *) &ts);
79846 set_fs(oldfs);
79847 if (!err && put_compat_timespec(&ts, tp))
79848 return -EFAULT;
79849 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
79850
79851 oldfs = get_fs();
79852 set_fs(KERNEL_DS);
79853 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
79854 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
79855 set_fs(oldfs);
79856
79857 err = compat_put_timex(utp, &txc);
79858 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
79859 oldfs = get_fs();
79860 set_fs(KERNEL_DS);
79861 err = sys_clock_getres(which_clock,
79862 - (struct timespec __user *) &ts);
79863 + (struct timespec __force_user *) &ts);
79864 set_fs(oldfs);
79865 if (!err && tp && put_compat_timespec(&ts, tp))
79866 return -EFAULT;
79867 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
79868 long err;
79869 mm_segment_t oldfs;
79870 struct timespec tu;
79871 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
79872 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
79873
79874 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
79875 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
79876 oldfs = get_fs();
79877 set_fs(KERNEL_DS);
79878 err = clock_nanosleep_restart(restart);
79879 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
79880 oldfs = get_fs();
79881 set_fs(KERNEL_DS);
79882 err = sys_clock_nanosleep(which_clock, flags,
79883 - (struct timespec __user *) &in,
79884 - (struct timespec __user *) &out);
79885 + (struct timespec __force_user *) &in,
79886 + (struct timespec __force_user *) &out);
79887 set_fs(oldfs);
79888
79889 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
79890 diff --git a/kernel/configs.c b/kernel/configs.c
79891 index c18b1f1..b9a0132 100644
79892 --- a/kernel/configs.c
79893 +++ b/kernel/configs.c
79894 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
79895 struct proc_dir_entry *entry;
79896
79897 /* create the current config file */
79898 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
79899 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
79900 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
79901 + &ikconfig_file_ops);
79902 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
79903 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
79904 + &ikconfig_file_ops);
79905 +#endif
79906 +#else
79907 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
79908 &ikconfig_file_ops);
79909 +#endif
79910 +
79911 if (!entry)
79912 return -ENOMEM;
79913
79914 diff --git a/kernel/cred.c b/kernel/cred.c
79915 index e0573a4..3874e41 100644
79916 --- a/kernel/cred.c
79917 +++ b/kernel/cred.c
79918 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
79919 validate_creds(cred);
79920 alter_cred_subscribers(cred, -1);
79921 put_cred(cred);
79922 +
79923 +#ifdef CONFIG_GRKERNSEC_SETXID
79924 + cred = (struct cred *) tsk->delayed_cred;
79925 + if (cred != NULL) {
79926 + tsk->delayed_cred = NULL;
79927 + validate_creds(cred);
79928 + alter_cred_subscribers(cred, -1);
79929 + put_cred(cred);
79930 + }
79931 +#endif
79932 }
79933
79934 /**
79935 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
79936 * Always returns 0 thus allowing this function to be tail-called at the end
79937 * of, say, sys_setgid().
79938 */
79939 -int commit_creds(struct cred *new)
79940 +static int __commit_creds(struct cred *new)
79941 {
79942 struct task_struct *task = current;
79943 const struct cred *old = task->real_cred;
79944 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
79945
79946 get_cred(new); /* we will require a ref for the subj creds too */
79947
79948 + gr_set_role_label(task, new->uid, new->gid);
79949 +
79950 /* dumpability changes */
79951 if (!uid_eq(old->euid, new->euid) ||
79952 !gid_eq(old->egid, new->egid) ||
79953 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
79954 put_cred(old);
79955 return 0;
79956 }
79957 +#ifdef CONFIG_GRKERNSEC_SETXID
79958 +extern int set_user(struct cred *new);
79959 +
79960 +void gr_delayed_cred_worker(void)
79961 +{
79962 + const struct cred *new = current->delayed_cred;
79963 + struct cred *ncred;
79964 +
79965 + current->delayed_cred = NULL;
79966 +
79967 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
79968 + // from doing get_cred on it when queueing this
79969 + put_cred(new);
79970 + return;
79971 + } else if (new == NULL)
79972 + return;
79973 +
79974 + ncred = prepare_creds();
79975 + if (!ncred)
79976 + goto die;
79977 + // uids
79978 + ncred->uid = new->uid;
79979 + ncred->euid = new->euid;
79980 + ncred->suid = new->suid;
79981 + ncred->fsuid = new->fsuid;
79982 + // gids
79983 + ncred->gid = new->gid;
79984 + ncred->egid = new->egid;
79985 + ncred->sgid = new->sgid;
79986 + ncred->fsgid = new->fsgid;
79987 + // groups
79988 + if (set_groups(ncred, new->group_info) < 0) {
79989 + abort_creds(ncred);
79990 + goto die;
79991 + }
79992 + // caps
79993 + ncred->securebits = new->securebits;
79994 + ncred->cap_inheritable = new->cap_inheritable;
79995 + ncred->cap_permitted = new->cap_permitted;
79996 + ncred->cap_effective = new->cap_effective;
79997 + ncred->cap_bset = new->cap_bset;
79998 +
79999 + if (set_user(ncred)) {
80000 + abort_creds(ncred);
80001 + goto die;
80002 + }
80003 +
80004 + // from doing get_cred on it when queueing this
80005 + put_cred(new);
80006 +
80007 + __commit_creds(ncred);
80008 + return;
80009 +die:
80010 + // from doing get_cred on it when queueing this
80011 + put_cred(new);
80012 + do_group_exit(SIGKILL);
80013 +}
80014 +#endif
80015 +
80016 +int commit_creds(struct cred *new)
80017 +{
80018 +#ifdef CONFIG_GRKERNSEC_SETXID
80019 + int ret;
80020 + int schedule_it = 0;
80021 + struct task_struct *t;
80022 +
80023 + /* we won't get called with tasklist_lock held for writing
80024 + and interrupts disabled as the cred struct in that case is
80025 + init_cred
80026 + */
80027 + if (grsec_enable_setxid && !current_is_single_threaded() &&
80028 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
80029 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
80030 + schedule_it = 1;
80031 + }
80032 + ret = __commit_creds(new);
80033 + if (schedule_it) {
80034 + rcu_read_lock();
80035 + read_lock(&tasklist_lock);
80036 + for (t = next_thread(current); t != current;
80037 + t = next_thread(t)) {
80038 + if (t->delayed_cred == NULL) {
80039 + t->delayed_cred = get_cred(new);
80040 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
80041 + set_tsk_need_resched(t);
80042 + }
80043 + }
80044 + read_unlock(&tasklist_lock);
80045 + rcu_read_unlock();
80046 + }
80047 + return ret;
80048 +#else
80049 + return __commit_creds(new);
80050 +#endif
80051 +}
80052 +
80053 EXPORT_SYMBOL(commit_creds);
80054
80055 /**
80056 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
80057 index 0506d44..2c20034 100644
80058 --- a/kernel/debug/debug_core.c
80059 +++ b/kernel/debug/debug_core.c
80060 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
80061 */
80062 static atomic_t masters_in_kgdb;
80063 static atomic_t slaves_in_kgdb;
80064 -static atomic_t kgdb_break_tasklet_var;
80065 +static atomic_unchecked_t kgdb_break_tasklet_var;
80066 atomic_t kgdb_setting_breakpoint;
80067
80068 struct task_struct *kgdb_usethread;
80069 @@ -133,7 +133,7 @@ int kgdb_single_step;
80070 static pid_t kgdb_sstep_pid;
80071
80072 /* to keep track of the CPU which is doing the single stepping*/
80073 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80074 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80075
80076 /*
80077 * If you are debugging a problem where roundup (the collection of
80078 @@ -541,7 +541,7 @@ return_normal:
80079 * kernel will only try for the value of sstep_tries before
80080 * giving up and continuing on.
80081 */
80082 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
80083 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
80084 (kgdb_info[cpu].task &&
80085 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
80086 atomic_set(&kgdb_active, -1);
80087 @@ -635,8 +635,8 @@ cpu_master_loop:
80088 }
80089
80090 kgdb_restore:
80091 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
80092 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
80093 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
80094 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
80095 if (kgdb_info[sstep_cpu].task)
80096 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
80097 else
80098 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
80099 static void kgdb_tasklet_bpt(unsigned long ing)
80100 {
80101 kgdb_breakpoint();
80102 - atomic_set(&kgdb_break_tasklet_var, 0);
80103 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
80104 }
80105
80106 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
80107
80108 void kgdb_schedule_breakpoint(void)
80109 {
80110 - if (atomic_read(&kgdb_break_tasklet_var) ||
80111 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
80112 atomic_read(&kgdb_active) != -1 ||
80113 atomic_read(&kgdb_setting_breakpoint))
80114 return;
80115 - atomic_inc(&kgdb_break_tasklet_var);
80116 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
80117 tasklet_schedule(&kgdb_tasklet_breakpoint);
80118 }
80119 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
80120 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
80121 index 00eb8f7..d7e3244 100644
80122 --- a/kernel/debug/kdb/kdb_main.c
80123 +++ b/kernel/debug/kdb/kdb_main.c
80124 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
80125 continue;
80126
80127 kdb_printf("%-20s%8u 0x%p ", mod->name,
80128 - mod->core_size, (void *)mod);
80129 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
80130 #ifdef CONFIG_MODULE_UNLOAD
80131 kdb_printf("%4ld ", module_refcount(mod));
80132 #endif
80133 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
80134 kdb_printf(" (Loading)");
80135 else
80136 kdb_printf(" (Live)");
80137 - kdb_printf(" 0x%p", mod->module_core);
80138 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
80139
80140 #ifdef CONFIG_MODULE_UNLOAD
80141 {
80142 diff --git a/kernel/events/core.c b/kernel/events/core.c
80143 index f86599e..b18b180 100644
80144 --- a/kernel/events/core.c
80145 +++ b/kernel/events/core.c
80146 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
80147 * 0 - disallow raw tracepoint access for unpriv
80148 * 1 - disallow cpu events for unpriv
80149 * 2 - disallow kernel profiling for unpriv
80150 + * 3 - disallow all unpriv perf event use
80151 */
80152 -int sysctl_perf_event_paranoid __read_mostly = 1;
80153 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80154 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
80155 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
80156 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
80157 +#else
80158 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
80159 +#endif
80160
80161 /* Minimum for 512 kiB + 1 user control page */
80162 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
80163 @@ -270,7 +277,7 @@ void perf_sample_event_took(u64 sample_len_ns)
80164 update_perf_cpu_limits();
80165 }
80166
80167 -static atomic64_t perf_event_id;
80168 +static atomic64_unchecked_t perf_event_id;
80169
80170 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
80171 enum event_type_t event_type);
80172 @@ -2936,7 +2943,7 @@ static void __perf_event_read(void *info)
80173
80174 static inline u64 perf_event_count(struct perf_event *event)
80175 {
80176 - return local64_read(&event->count) + atomic64_read(&event->child_count);
80177 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
80178 }
80179
80180 static u64 perf_event_read(struct perf_event *event)
80181 @@ -3282,9 +3289,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
80182 mutex_lock(&event->child_mutex);
80183 total += perf_event_read(event);
80184 *enabled += event->total_time_enabled +
80185 - atomic64_read(&event->child_total_time_enabled);
80186 + atomic64_read_unchecked(&event->child_total_time_enabled);
80187 *running += event->total_time_running +
80188 - atomic64_read(&event->child_total_time_running);
80189 + atomic64_read_unchecked(&event->child_total_time_running);
80190
80191 list_for_each_entry(child, &event->child_list, child_list) {
80192 total += perf_event_read(child);
80193 @@ -3670,10 +3677,10 @@ void perf_event_update_userpage(struct perf_event *event)
80194 userpg->offset -= local64_read(&event->hw.prev_count);
80195
80196 userpg->time_enabled = enabled +
80197 - atomic64_read(&event->child_total_time_enabled);
80198 + atomic64_read_unchecked(&event->child_total_time_enabled);
80199
80200 userpg->time_running = running +
80201 - atomic64_read(&event->child_total_time_running);
80202 + atomic64_read_unchecked(&event->child_total_time_running);
80203
80204 arch_perf_update_userpage(userpg, now);
80205
80206 @@ -4223,7 +4230,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
80207
80208 /* Data. */
80209 sp = perf_user_stack_pointer(regs);
80210 - rem = __output_copy_user(handle, (void *) sp, dump_size);
80211 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
80212 dyn_size = dump_size - rem;
80213
80214 perf_output_skip(handle, rem);
80215 @@ -4311,11 +4318,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
80216 values[n++] = perf_event_count(event);
80217 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
80218 values[n++] = enabled +
80219 - atomic64_read(&event->child_total_time_enabled);
80220 + atomic64_read_unchecked(&event->child_total_time_enabled);
80221 }
80222 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
80223 values[n++] = running +
80224 - atomic64_read(&event->child_total_time_running);
80225 + atomic64_read_unchecked(&event->child_total_time_running);
80226 }
80227 if (read_format & PERF_FORMAT_ID)
80228 values[n++] = primary_event_id(event);
80229 @@ -5024,12 +5031,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
80230 * need to add enough zero bytes after the string to handle
80231 * the 64bit alignment we do later.
80232 */
80233 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
80234 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
80235 if (!buf) {
80236 name = strncpy(tmp, "//enomem", sizeof(tmp));
80237 goto got_name;
80238 }
80239 - name = d_path(&file->f_path, buf, PATH_MAX);
80240 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
80241 if (IS_ERR(name)) {
80242 name = strncpy(tmp, "//toolong", sizeof(tmp));
80243 goto got_name;
80244 @@ -6498,7 +6505,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
80245 event->parent = parent_event;
80246
80247 event->ns = get_pid_ns(task_active_pid_ns(current));
80248 - event->id = atomic64_inc_return(&perf_event_id);
80249 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
80250
80251 event->state = PERF_EVENT_STATE_INACTIVE;
80252
80253 @@ -6807,6 +6814,11 @@ SYSCALL_DEFINE5(perf_event_open,
80254 if (flags & ~PERF_FLAG_ALL)
80255 return -EINVAL;
80256
80257 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80258 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
80259 + return -EACCES;
80260 +#endif
80261 +
80262 err = perf_copy_attr(attr_uptr, &attr);
80263 if (err)
80264 return err;
80265 @@ -7139,10 +7151,10 @@ static void sync_child_event(struct perf_event *child_event,
80266 /*
80267 * Add back the child's count to the parent's count:
80268 */
80269 - atomic64_add(child_val, &parent_event->child_count);
80270 - atomic64_add(child_event->total_time_enabled,
80271 + atomic64_add_unchecked(child_val, &parent_event->child_count);
80272 + atomic64_add_unchecked(child_event->total_time_enabled,
80273 &parent_event->child_total_time_enabled);
80274 - atomic64_add(child_event->total_time_running,
80275 + atomic64_add_unchecked(child_event->total_time_running,
80276 &parent_event->child_total_time_running);
80277
80278 /*
80279 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
80280 index ca65997..60df03d 100644
80281 --- a/kernel/events/internal.h
80282 +++ b/kernel/events/internal.h
80283 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
80284 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
80285 }
80286
80287 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
80288 -static inline unsigned int \
80289 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
80290 +static inline unsigned long \
80291 func_name(struct perf_output_handle *handle, \
80292 - const void *buf, unsigned int len) \
80293 + const void user *buf, unsigned long len) \
80294 { \
80295 unsigned long size, written; \
80296 \
80297 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
80298 return n;
80299 }
80300
80301 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
80302 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
80303
80304 #define MEMCPY_SKIP(dst, src, n) (n)
80305
80306 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
80307 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
80308
80309 #ifndef arch_perf_out_copy_user
80310 #define arch_perf_out_copy_user __copy_from_user_inatomic
80311 #endif
80312
80313 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
80314 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
80315
80316 /* Callchain handling */
80317 extern struct perf_callchain_entry *
80318 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
80319 index ad8e1bd..fed7ba9 100644
80320 --- a/kernel/events/uprobes.c
80321 +++ b/kernel/events/uprobes.c
80322 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
80323 {
80324 struct page *page;
80325 uprobe_opcode_t opcode;
80326 - int result;
80327 + long result;
80328
80329 pagefault_disable();
80330 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
80331 diff --git a/kernel/exit.c b/kernel/exit.c
80332 index a949819..a5f127d 100644
80333 --- a/kernel/exit.c
80334 +++ b/kernel/exit.c
80335 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
80336 struct task_struct *leader;
80337 int zap_leader;
80338 repeat:
80339 +#ifdef CONFIG_NET
80340 + gr_del_task_from_ip_table(p);
80341 +#endif
80342 +
80343 /* don't need to get the RCU readlock here - the process is dead and
80344 * can't be modifying its own credentials. But shut RCU-lockdep up */
80345 rcu_read_lock();
80346 @@ -329,7 +333,7 @@ int allow_signal(int sig)
80347 * know it'll be handled, so that they don't get converted to
80348 * SIGKILL or just silently dropped.
80349 */
80350 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
80351 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
80352 recalc_sigpending();
80353 spin_unlock_irq(&current->sighand->siglock);
80354 return 0;
80355 @@ -698,6 +702,8 @@ void do_exit(long code)
80356 struct task_struct *tsk = current;
80357 int group_dead;
80358
80359 + set_fs(USER_DS);
80360 +
80361 profile_task_exit(tsk);
80362
80363 WARN_ON(blk_needs_flush_plug(tsk));
80364 @@ -714,7 +720,6 @@ void do_exit(long code)
80365 * mm_release()->clear_child_tid() from writing to a user-controlled
80366 * kernel address.
80367 */
80368 - set_fs(USER_DS);
80369
80370 ptrace_event(PTRACE_EVENT_EXIT, code);
80371
80372 @@ -773,6 +778,9 @@ void do_exit(long code)
80373 tsk->exit_code = code;
80374 taskstats_exit(tsk, group_dead);
80375
80376 + gr_acl_handle_psacct(tsk, code);
80377 + gr_acl_handle_exit();
80378 +
80379 exit_mm(tsk);
80380
80381 if (group_dead)
80382 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
80383 * Take down every thread in the group. This is called by fatal signals
80384 * as well as by sys_exit_group (below).
80385 */
80386 -void
80387 +__noreturn void
80388 do_group_exit(int exit_code)
80389 {
80390 struct signal_struct *sig = current->signal;
80391 diff --git a/kernel/fork.c b/kernel/fork.c
80392 index 200a7a2..43e52da 100644
80393 --- a/kernel/fork.c
80394 +++ b/kernel/fork.c
80395 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
80396 *stackend = STACK_END_MAGIC; /* for overflow detection */
80397
80398 #ifdef CONFIG_CC_STACKPROTECTOR
80399 - tsk->stack_canary = get_random_int();
80400 + tsk->stack_canary = pax_get_random_long();
80401 #endif
80402
80403 /*
80404 @@ -345,13 +345,81 @@ free_tsk:
80405 }
80406
80407 #ifdef CONFIG_MMU
80408 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80409 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
80410 {
80411 - struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80412 - struct rb_node **rb_link, *rb_parent;
80413 - int retval;
80414 + struct vm_area_struct *tmp;
80415 unsigned long charge;
80416 struct mempolicy *pol;
80417 + struct file *file;
80418 +
80419 + charge = 0;
80420 + if (mpnt->vm_flags & VM_ACCOUNT) {
80421 + unsigned long len = vma_pages(mpnt);
80422 +
80423 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80424 + goto fail_nomem;
80425 + charge = len;
80426 + }
80427 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80428 + if (!tmp)
80429 + goto fail_nomem;
80430 + *tmp = *mpnt;
80431 + tmp->vm_mm = mm;
80432 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
80433 + pol = mpol_dup(vma_policy(mpnt));
80434 + if (IS_ERR(pol))
80435 + goto fail_nomem_policy;
80436 + vma_set_policy(tmp, pol);
80437 + if (anon_vma_fork(tmp, mpnt))
80438 + goto fail_nomem_anon_vma_fork;
80439 + tmp->vm_flags &= ~VM_LOCKED;
80440 + tmp->vm_next = tmp->vm_prev = NULL;
80441 + tmp->vm_mirror = NULL;
80442 + file = tmp->vm_file;
80443 + if (file) {
80444 + struct inode *inode = file_inode(file);
80445 + struct address_space *mapping = file->f_mapping;
80446 +
80447 + get_file(file);
80448 + if (tmp->vm_flags & VM_DENYWRITE)
80449 + atomic_dec(&inode->i_writecount);
80450 + mutex_lock(&mapping->i_mmap_mutex);
80451 + if (tmp->vm_flags & VM_SHARED)
80452 + mapping->i_mmap_writable++;
80453 + flush_dcache_mmap_lock(mapping);
80454 + /* insert tmp into the share list, just after mpnt */
80455 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80456 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
80457 + else
80458 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
80459 + flush_dcache_mmap_unlock(mapping);
80460 + mutex_unlock(&mapping->i_mmap_mutex);
80461 + }
80462 +
80463 + /*
80464 + * Clear hugetlb-related page reserves for children. This only
80465 + * affects MAP_PRIVATE mappings. Faults generated by the child
80466 + * are not guaranteed to succeed, even if read-only
80467 + */
80468 + if (is_vm_hugetlb_page(tmp))
80469 + reset_vma_resv_huge_pages(tmp);
80470 +
80471 + return tmp;
80472 +
80473 +fail_nomem_anon_vma_fork:
80474 + mpol_put(pol);
80475 +fail_nomem_policy:
80476 + kmem_cache_free(vm_area_cachep, tmp);
80477 +fail_nomem:
80478 + vm_unacct_memory(charge);
80479 + return NULL;
80480 +}
80481 +
80482 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80483 +{
80484 + struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80485 + struct rb_node **rb_link, *rb_parent;
80486 + int retval;
80487
80488 uprobe_start_dup_mmap();
80489 down_write(&oldmm->mmap_sem);
80490 @@ -380,57 +448,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80491
80492 prev = NULL;
80493 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
80494 - struct file *file;
80495 -
80496 if (mpnt->vm_flags & VM_DONTCOPY) {
80497 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
80498 -vma_pages(mpnt));
80499 continue;
80500 }
80501 - charge = 0;
80502 - if (mpnt->vm_flags & VM_ACCOUNT) {
80503 - unsigned long len = vma_pages(mpnt);
80504 -
80505 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80506 - goto fail_nomem;
80507 - charge = len;
80508 - }
80509 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80510 - if (!tmp)
80511 - goto fail_nomem;
80512 - *tmp = *mpnt;
80513 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
80514 - pol = mpol_dup(vma_policy(mpnt));
80515 - retval = PTR_ERR(pol);
80516 - if (IS_ERR(pol))
80517 - goto fail_nomem_policy;
80518 - vma_set_policy(tmp, pol);
80519 - tmp->vm_mm = mm;
80520 - if (anon_vma_fork(tmp, mpnt))
80521 - goto fail_nomem_anon_vma_fork;
80522 - tmp->vm_flags &= ~VM_LOCKED;
80523 - tmp->vm_next = tmp->vm_prev = NULL;
80524 - file = tmp->vm_file;
80525 - if (file) {
80526 - struct inode *inode = file_inode(file);
80527 - struct address_space *mapping = file->f_mapping;
80528 -
80529 - get_file(file);
80530 - if (tmp->vm_flags & VM_DENYWRITE)
80531 - atomic_dec(&inode->i_writecount);
80532 - mutex_lock(&mapping->i_mmap_mutex);
80533 - if (tmp->vm_flags & VM_SHARED)
80534 - mapping->i_mmap_writable++;
80535 - flush_dcache_mmap_lock(mapping);
80536 - /* insert tmp into the share list, just after mpnt */
80537 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80538 - vma_nonlinear_insert(tmp,
80539 - &mapping->i_mmap_nonlinear);
80540 - else
80541 - vma_interval_tree_insert_after(tmp, mpnt,
80542 - &mapping->i_mmap);
80543 - flush_dcache_mmap_unlock(mapping);
80544 - mutex_unlock(&mapping->i_mmap_mutex);
80545 + tmp = dup_vma(mm, oldmm, mpnt);
80546 + if (!tmp) {
80547 + retval = -ENOMEM;
80548 + goto out;
80549 }
80550
80551 /*
80552 @@ -462,6 +488,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80553 if (retval)
80554 goto out;
80555 }
80556 +
80557 +#ifdef CONFIG_PAX_SEGMEXEC
80558 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
80559 + struct vm_area_struct *mpnt_m;
80560 +
80561 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
80562 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
80563 +
80564 + if (!mpnt->vm_mirror)
80565 + continue;
80566 +
80567 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
80568 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
80569 + mpnt->vm_mirror = mpnt_m;
80570 + } else {
80571 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
80572 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
80573 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
80574 + mpnt->vm_mirror->vm_mirror = mpnt;
80575 + }
80576 + }
80577 + BUG_ON(mpnt_m);
80578 + }
80579 +#endif
80580 +
80581 /* a new mm has just been created */
80582 arch_dup_mmap(oldmm, mm);
80583 retval = 0;
80584 @@ -471,14 +522,6 @@ out:
80585 up_write(&oldmm->mmap_sem);
80586 uprobe_end_dup_mmap();
80587 return retval;
80588 -fail_nomem_anon_vma_fork:
80589 - mpol_put(pol);
80590 -fail_nomem_policy:
80591 - kmem_cache_free(vm_area_cachep, tmp);
80592 -fail_nomem:
80593 - retval = -ENOMEM;
80594 - vm_unacct_memory(charge);
80595 - goto out;
80596 }
80597
80598 static inline int mm_alloc_pgd(struct mm_struct *mm)
80599 @@ -691,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
80600 return ERR_PTR(err);
80601
80602 mm = get_task_mm(task);
80603 - if (mm && mm != current->mm &&
80604 - !ptrace_may_access(task, mode)) {
80605 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
80606 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
80607 mmput(mm);
80608 mm = ERR_PTR(-EACCES);
80609 }
80610 @@ -914,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
80611 spin_unlock(&fs->lock);
80612 return -EAGAIN;
80613 }
80614 - fs->users++;
80615 + atomic_inc(&fs->users);
80616 spin_unlock(&fs->lock);
80617 return 0;
80618 }
80619 tsk->fs = copy_fs_struct(fs);
80620 if (!tsk->fs)
80621 return -ENOMEM;
80622 + /* Carry through gr_chroot_dentry and is_chrooted instead
80623 + of recomputing it here. Already copied when the task struct
80624 + is duplicated. This allows pivot_root to not be treated as
80625 + a chroot
80626 + */
80627 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
80628 +
80629 return 0;
80630 }
80631
80632 @@ -1131,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
80633 * parts of the process environment (as per the clone
80634 * flags). The actual kick-off is left to the caller.
80635 */
80636 -static struct task_struct *copy_process(unsigned long clone_flags,
80637 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
80638 unsigned long stack_start,
80639 unsigned long stack_size,
80640 int __user *child_tidptr,
80641 @@ -1201,6 +1251,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80642 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
80643 #endif
80644 retval = -EAGAIN;
80645 +
80646 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
80647 +
80648 if (atomic_read(&p->real_cred->user->processes) >=
80649 task_rlimit(p, RLIMIT_NPROC)) {
80650 if (p->real_cred->user != INIT_USER &&
80651 @@ -1450,6 +1503,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80652 goto bad_fork_free_pid;
80653 }
80654
80655 + /* synchronizes with gr_set_acls()
80656 + we need to call this past the point of no return for fork()
80657 + */
80658 + gr_copy_label(p);
80659 +
80660 if (likely(p->pid)) {
80661 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
80662
80663 @@ -1535,6 +1593,8 @@ bad_fork_cleanup_count:
80664 bad_fork_free:
80665 free_task(p);
80666 fork_out:
80667 + gr_log_forkfail(retval);
80668 +
80669 return ERR_PTR(retval);
80670 }
80671
80672 @@ -1605,6 +1665,7 @@ long do_fork(unsigned long clone_flags,
80673
80674 p = copy_process(clone_flags, stack_start, stack_size,
80675 child_tidptr, NULL, trace);
80676 + add_latent_entropy();
80677 /*
80678 * Do this prior waking up the new thread - the thread pointer
80679 * might get invalid after that point, if the thread exits quickly.
80680 @@ -1619,6 +1680,8 @@ long do_fork(unsigned long clone_flags,
80681 if (clone_flags & CLONE_PARENT_SETTID)
80682 put_user(nr, parent_tidptr);
80683
80684 + gr_handle_brute_check();
80685 +
80686 if (clone_flags & CLONE_VFORK) {
80687 p->vfork_done = &vfork;
80688 init_completion(&vfork);
80689 @@ -1735,7 +1798,7 @@ void __init proc_caches_init(void)
80690 mm_cachep = kmem_cache_create("mm_struct",
80691 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
80692 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
80693 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
80694 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
80695 mmap_init();
80696 nsproxy_cache_init();
80697 }
80698 @@ -1775,7 +1838,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
80699 return 0;
80700
80701 /* don't need lock here; in the worst case we'll do useless copy */
80702 - if (fs->users == 1)
80703 + if (atomic_read(&fs->users) == 1)
80704 return 0;
80705
80706 *new_fsp = copy_fs_struct(fs);
80707 @@ -1887,7 +1950,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
80708 fs = current->fs;
80709 spin_lock(&fs->lock);
80710 current->fs = new_fs;
80711 - if (--fs->users)
80712 + gr_set_chroot_entries(current, &current->fs->root);
80713 + if (atomic_dec_return(&fs->users))
80714 new_fs = NULL;
80715 else
80716 new_fs = fs;
80717 diff --git a/kernel/futex.c b/kernel/futex.c
80718 index c3a1a55..e32b4a98 100644
80719 --- a/kernel/futex.c
80720 +++ b/kernel/futex.c
80721 @@ -54,6 +54,7 @@
80722 #include <linux/mount.h>
80723 #include <linux/pagemap.h>
80724 #include <linux/syscalls.h>
80725 +#include <linux/ptrace.h>
80726 #include <linux/signal.h>
80727 #include <linux/export.h>
80728 #include <linux/magic.h>
80729 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
80730 struct page *page, *page_head;
80731 int err, ro = 0;
80732
80733 +#ifdef CONFIG_PAX_SEGMEXEC
80734 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
80735 + return -EFAULT;
80736 +#endif
80737 +
80738 /*
80739 * The futex address must be "naturally" aligned.
80740 */
80741 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
80742
80743 static int get_futex_value_locked(u32 *dest, u32 __user *from)
80744 {
80745 - int ret;
80746 + unsigned long ret;
80747
80748 pagefault_disable();
80749 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
80750 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
80751 {
80752 u32 curval;
80753 int i;
80754 + mm_segment_t oldfs;
80755
80756 /*
80757 * This will fail and we want it. Some arch implementations do
80758 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
80759 * implementation, the non-functional ones will return
80760 * -ENOSYS.
80761 */
80762 + oldfs = get_fs();
80763 + set_fs(USER_DS);
80764 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
80765 futex_cmpxchg_enabled = 1;
80766 + set_fs(oldfs);
80767
80768 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
80769 plist_head_init(&futex_queues[i].chain);
80770 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
80771 index f9f44fd..29885e4 100644
80772 --- a/kernel/futex_compat.c
80773 +++ b/kernel/futex_compat.c
80774 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
80775 return 0;
80776 }
80777
80778 -static void __user *futex_uaddr(struct robust_list __user *entry,
80779 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
80780 compat_long_t futex_offset)
80781 {
80782 compat_uptr_t base = ptr_to_compat(entry);
80783 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
80784 index 9b22d03..6295b62 100644
80785 --- a/kernel/gcov/base.c
80786 +++ b/kernel/gcov/base.c
80787 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
80788 }
80789
80790 #ifdef CONFIG_MODULES
80791 -static inline int within(void *addr, void *start, unsigned long size)
80792 -{
80793 - return ((addr >= start) && (addr < start + size));
80794 -}
80795 -
80796 /* Update list and generate events when modules are unloaded. */
80797 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80798 void *data)
80799 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80800 prev = NULL;
80801 /* Remove entries located in module from linked list. */
80802 for (info = gcov_info_head; info; info = info->next) {
80803 - if (within(info, mod->module_core, mod->core_size)) {
80804 + if (within_module_core_rw((unsigned long)info, mod)) {
80805 if (prev)
80806 prev->next = info->next;
80807 else
80808 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
80809 index 383319b..56ebb13 100644
80810 --- a/kernel/hrtimer.c
80811 +++ b/kernel/hrtimer.c
80812 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
80813 local_irq_restore(flags);
80814 }
80815
80816 -static void run_hrtimer_softirq(struct softirq_action *h)
80817 +static __latent_entropy void run_hrtimer_softirq(void)
80818 {
80819 hrtimer_peek_ahead_timers();
80820 }
80821 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
80822 index 55fcce6..0e4cf34 100644
80823 --- a/kernel/irq_work.c
80824 +++ b/kernel/irq_work.c
80825 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
80826 return NOTIFY_OK;
80827 }
80828
80829 -static struct notifier_block cpu_notify;
80830 +static struct notifier_block cpu_notify = {
80831 + .notifier_call = irq_work_cpu_notify,
80832 + .priority = 0,
80833 +};
80834
80835 static __init int irq_work_init_cpu_notifier(void)
80836 {
80837 - cpu_notify.notifier_call = irq_work_cpu_notify;
80838 - cpu_notify.priority = 0;
80839 register_cpu_notifier(&cpu_notify);
80840 return 0;
80841 }
80842 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
80843 index 60f48fa..7f3a770 100644
80844 --- a/kernel/jump_label.c
80845 +++ b/kernel/jump_label.c
80846 @@ -13,6 +13,7 @@
80847 #include <linux/sort.h>
80848 #include <linux/err.h>
80849 #include <linux/static_key.h>
80850 +#include <linux/mm.h>
80851
80852 #ifdef HAVE_JUMP_LABEL
80853
80854 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
80855
80856 size = (((unsigned long)stop - (unsigned long)start)
80857 / sizeof(struct jump_entry));
80858 + pax_open_kernel();
80859 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
80860 + pax_close_kernel();
80861 }
80862
80863 static void jump_label_update(struct static_key *key, int enable);
80864 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
80865 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
80866 struct jump_entry *iter;
80867
80868 + pax_open_kernel();
80869 for (iter = iter_start; iter < iter_stop; iter++) {
80870 if (within_module_init(iter->code, mod))
80871 iter->code = 0;
80872 }
80873 + pax_close_kernel();
80874 }
80875
80876 static int
80877 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
80878 index 3127ad5..159d880 100644
80879 --- a/kernel/kallsyms.c
80880 +++ b/kernel/kallsyms.c
80881 @@ -11,6 +11,9 @@
80882 * Changed the compression method from stem compression to "table lookup"
80883 * compression (see scripts/kallsyms.c for a more complete description)
80884 */
80885 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80886 +#define __INCLUDED_BY_HIDESYM 1
80887 +#endif
80888 #include <linux/kallsyms.h>
80889 #include <linux/module.h>
80890 #include <linux/init.h>
80891 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
80892
80893 static inline int is_kernel_inittext(unsigned long addr)
80894 {
80895 + if (system_state != SYSTEM_BOOTING)
80896 + return 0;
80897 +
80898 if (addr >= (unsigned long)_sinittext
80899 && addr <= (unsigned long)_einittext)
80900 return 1;
80901 return 0;
80902 }
80903
80904 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80905 +#ifdef CONFIG_MODULES
80906 +static inline int is_module_text(unsigned long addr)
80907 +{
80908 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
80909 + return 1;
80910 +
80911 + addr = ktla_ktva(addr);
80912 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
80913 +}
80914 +#else
80915 +static inline int is_module_text(unsigned long addr)
80916 +{
80917 + return 0;
80918 +}
80919 +#endif
80920 +#endif
80921 +
80922 static inline int is_kernel_text(unsigned long addr)
80923 {
80924 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
80925 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
80926
80927 static inline int is_kernel(unsigned long addr)
80928 {
80929 +
80930 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80931 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
80932 + return 1;
80933 +
80934 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
80935 +#else
80936 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
80937 +#endif
80938 +
80939 return 1;
80940 return in_gate_area_no_mm(addr);
80941 }
80942
80943 static int is_ksym_addr(unsigned long addr)
80944 {
80945 +
80946 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80947 + if (is_module_text(addr))
80948 + return 0;
80949 +#endif
80950 +
80951 if (all_var)
80952 return is_kernel(addr);
80953
80954 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
80955
80956 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
80957 {
80958 - iter->name[0] = '\0';
80959 iter->nameoff = get_symbol_offset(new_pos);
80960 iter->pos = new_pos;
80961 }
80962 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
80963 {
80964 struct kallsym_iter *iter = m->private;
80965
80966 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80967 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
80968 + return 0;
80969 +#endif
80970 +
80971 /* Some debugging symbols have no name. Ignore them. */
80972 if (!iter->name[0])
80973 return 0;
80974 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
80975 */
80976 type = iter->exported ? toupper(iter->type) :
80977 tolower(iter->type);
80978 +
80979 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
80980 type, iter->name, iter->module_name);
80981 } else
80982 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
80983 struct kallsym_iter *iter;
80984 int ret;
80985
80986 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
80987 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
80988 if (!iter)
80989 return -ENOMEM;
80990 reset_iter(iter, 0);
80991 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
80992 index e30ac0f..3528cac 100644
80993 --- a/kernel/kcmp.c
80994 +++ b/kernel/kcmp.c
80995 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
80996 struct task_struct *task1, *task2;
80997 int ret;
80998
80999 +#ifdef CONFIG_GRKERNSEC
81000 + return -ENOSYS;
81001 +#endif
81002 +
81003 rcu_read_lock();
81004
81005 /*
81006 diff --git a/kernel/kexec.c b/kernel/kexec.c
81007 index 59f7b55..4022f65 100644
81008 --- a/kernel/kexec.c
81009 +++ b/kernel/kexec.c
81010 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
81011 unsigned long flags)
81012 {
81013 struct compat_kexec_segment in;
81014 - struct kexec_segment out, __user *ksegments;
81015 + struct kexec_segment out;
81016 + struct kexec_segment __user *ksegments;
81017 unsigned long i, result;
81018
81019 /* Don't allow clients that don't understand the native
81020 diff --git a/kernel/kmod.c b/kernel/kmod.c
81021 index b086006..a27913b 100644
81022 --- a/kernel/kmod.c
81023 +++ b/kernel/kmod.c
81024 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
81025 kfree(info->argv);
81026 }
81027
81028 -static int call_modprobe(char *module_name, int wait)
81029 +static int call_modprobe(char *module_name, char *module_param, int wait)
81030 {
81031 struct subprocess_info *info;
81032 static char *envp[] = {
81033 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
81034 NULL
81035 };
81036
81037 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
81038 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
81039 if (!argv)
81040 goto out;
81041
81042 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
81043 argv[1] = "-q";
81044 argv[2] = "--";
81045 argv[3] = module_name; /* check free_modprobe_argv() */
81046 - argv[4] = NULL;
81047 + argv[4] = module_param;
81048 + argv[5] = NULL;
81049
81050 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
81051 NULL, free_modprobe_argv, NULL);
81052 @@ -129,9 +130,8 @@ out:
81053 * If module auto-loading support is disabled then this function
81054 * becomes a no-operation.
81055 */
81056 -int __request_module(bool wait, const char *fmt, ...)
81057 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
81058 {
81059 - va_list args;
81060 char module_name[MODULE_NAME_LEN];
81061 unsigned int max_modprobes;
81062 int ret;
81063 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
81064 if (!modprobe_path[0])
81065 return 0;
81066
81067 - va_start(args, fmt);
81068 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
81069 - va_end(args);
81070 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
81071 if (ret >= MODULE_NAME_LEN)
81072 return -ENAMETOOLONG;
81073
81074 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
81075 if (ret)
81076 return ret;
81077
81078 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81079 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81080 + /* hack to workaround consolekit/udisks stupidity */
81081 + read_lock(&tasklist_lock);
81082 + if (!strcmp(current->comm, "mount") &&
81083 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
81084 + read_unlock(&tasklist_lock);
81085 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
81086 + return -EPERM;
81087 + }
81088 + read_unlock(&tasklist_lock);
81089 + }
81090 +#endif
81091 +
81092 /* If modprobe needs a service that is in a module, we get a recursive
81093 * loop. Limit the number of running kmod threads to max_threads/2 or
81094 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
81095 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
81096
81097 trace_module_request(module_name, wait, _RET_IP_);
81098
81099 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81100 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81101
81102 atomic_dec(&kmod_concurrent);
81103 return ret;
81104 }
81105 +
81106 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
81107 +{
81108 + va_list args;
81109 + int ret;
81110 +
81111 + va_start(args, fmt);
81112 + ret = ____request_module(wait, module_param, fmt, args);
81113 + va_end(args);
81114 +
81115 + return ret;
81116 +}
81117 +
81118 +int __request_module(bool wait, const char *fmt, ...)
81119 +{
81120 + va_list args;
81121 + int ret;
81122 +
81123 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81124 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81125 + char module_param[MODULE_NAME_LEN];
81126 +
81127 + memset(module_param, 0, sizeof(module_param));
81128 +
81129 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
81130 +
81131 + va_start(args, fmt);
81132 + ret = ____request_module(wait, module_param, fmt, args);
81133 + va_end(args);
81134 +
81135 + return ret;
81136 + }
81137 +#endif
81138 +
81139 + va_start(args, fmt);
81140 + ret = ____request_module(wait, NULL, fmt, args);
81141 + va_end(args);
81142 +
81143 + return ret;
81144 +}
81145 +
81146 EXPORT_SYMBOL(__request_module);
81147 #endif /* CONFIG_MODULES */
81148
81149 @@ -303,7 +356,7 @@ static int wait_for_helper(void *data)
81150 *
81151 * Thus the __user pointer cast is valid here.
81152 */
81153 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
81154 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
81155
81156 /*
81157 * If ret is 0, either ____call_usermodehelper failed and the
81158 @@ -650,7 +703,7 @@ EXPORT_SYMBOL(call_usermodehelper);
81159 static int proc_cap_handler(struct ctl_table *table, int write,
81160 void __user *buffer, size_t *lenp, loff_t *ppos)
81161 {
81162 - struct ctl_table t;
81163 + ctl_table_no_const t;
81164 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
81165 kernel_cap_t new_cap;
81166 int err, i;
81167 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
81168 index 6e33498..3133bd3 100644
81169 --- a/kernel/kprobes.c
81170 +++ b/kernel/kprobes.c
81171 @@ -31,6 +31,9 @@
81172 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
81173 * <prasanna@in.ibm.com> added function-return probes.
81174 */
81175 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81176 +#define __INCLUDED_BY_HIDESYM 1
81177 +#endif
81178 #include <linux/kprobes.h>
81179 #include <linux/hash.h>
81180 #include <linux/init.h>
81181 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
81182 * kernel image and loaded module images reside. This is required
81183 * so x86_64 can correctly handle the %rip-relative fixups.
81184 */
81185 - kip->insns = module_alloc(PAGE_SIZE);
81186 + kip->insns = module_alloc_exec(PAGE_SIZE);
81187 if (!kip->insns) {
81188 kfree(kip);
81189 return NULL;
81190 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
81191 */
81192 if (!list_is_singular(&kip->list)) {
81193 list_del(&kip->list);
81194 - module_free(NULL, kip->insns);
81195 + module_free_exec(NULL, kip->insns);
81196 kfree(kip);
81197 }
81198 return 1;
81199 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
81200 {
81201 int i, err = 0;
81202 unsigned long offset = 0, size = 0;
81203 - char *modname, namebuf[128];
81204 + char *modname, namebuf[KSYM_NAME_LEN];
81205 const char *symbol_name;
81206 void *addr;
81207 struct kprobe_blackpoint *kb;
81208 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
81209 kprobe_type = "k";
81210
81211 if (sym)
81212 - seq_printf(pi, "%p %s %s+0x%x %s ",
81213 + seq_printf(pi, "%pK %s %s+0x%x %s ",
81214 p->addr, kprobe_type, sym, offset,
81215 (modname ? modname : " "));
81216 else
81217 - seq_printf(pi, "%p %s %p ",
81218 + seq_printf(pi, "%pK %s %pK ",
81219 p->addr, kprobe_type, p->addr);
81220
81221 if (!pp)
81222 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
81223 const char *sym = NULL;
81224 unsigned int i = *(loff_t *) v;
81225 unsigned long offset = 0;
81226 - char *modname, namebuf[128];
81227 + char *modname, namebuf[KSYM_NAME_LEN];
81228
81229 head = &kprobe_table[i];
81230 preempt_disable();
81231 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
81232 index 6ada93c..dce7d5d 100644
81233 --- a/kernel/ksysfs.c
81234 +++ b/kernel/ksysfs.c
81235 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
81236 {
81237 if (count+1 > UEVENT_HELPER_PATH_LEN)
81238 return -ENOENT;
81239 + if (!capable(CAP_SYS_ADMIN))
81240 + return -EPERM;
81241 memcpy(uevent_helper, buf, count);
81242 uevent_helper[count] = '\0';
81243 if (count && uevent_helper[count-1] == '\n')
81244 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
81245 return count;
81246 }
81247
81248 -static struct bin_attribute notes_attr = {
81249 +static bin_attribute_no_const notes_attr __read_only = {
81250 .attr = {
81251 .name = "notes",
81252 .mode = S_IRUGO,
81253 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
81254 index e16c45b..6f49c48 100644
81255 --- a/kernel/lockdep.c
81256 +++ b/kernel/lockdep.c
81257 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
81258 end = (unsigned long) &_end,
81259 addr = (unsigned long) obj;
81260
81261 +#ifdef CONFIG_PAX_KERNEXEC
81262 + start = ktla_ktva(start);
81263 +#endif
81264 +
81265 /*
81266 * static variable?
81267 */
81268 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
81269 if (!static_obj(lock->key)) {
81270 debug_locks_off();
81271 printk("INFO: trying to register non-static key.\n");
81272 + printk("lock:%pS key:%pS.\n", lock, lock->key);
81273 printk("the code is fine but needs lockdep annotation.\n");
81274 printk("turning off the locking correctness validator.\n");
81275 dump_stack();
81276 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
81277 if (!class)
81278 return 0;
81279 }
81280 - atomic_inc((atomic_t *)&class->ops);
81281 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
81282 if (very_verbose(class)) {
81283 printk("\nacquire class [%p] %s", class->key, class->name);
81284 if (class->name_version > 1)
81285 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
81286 index b2c71c5..7b88d63 100644
81287 --- a/kernel/lockdep_proc.c
81288 +++ b/kernel/lockdep_proc.c
81289 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
81290 return 0;
81291 }
81292
81293 - seq_printf(m, "%p", class->key);
81294 + seq_printf(m, "%pK", class->key);
81295 #ifdef CONFIG_DEBUG_LOCKDEP
81296 seq_printf(m, " OPS:%8ld", class->ops);
81297 #endif
81298 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
81299
81300 list_for_each_entry(entry, &class->locks_after, entry) {
81301 if (entry->distance == 1) {
81302 - seq_printf(m, " -> [%p] ", entry->class->key);
81303 + seq_printf(m, " -> [%pK] ", entry->class->key);
81304 print_name(m, entry->class);
81305 seq_puts(m, "\n");
81306 }
81307 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
81308 if (!class->key)
81309 continue;
81310
81311 - seq_printf(m, "[%p] ", class->key);
81312 + seq_printf(m, "[%pK] ", class->key);
81313 print_name(m, class);
81314 seq_puts(m, "\n");
81315 }
81316 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81317 if (!i)
81318 seq_line(m, '-', 40-namelen, namelen);
81319
81320 - snprintf(ip, sizeof(ip), "[<%p>]",
81321 + snprintf(ip, sizeof(ip), "[<%pK>]",
81322 (void *)class->contention_point[i]);
81323 seq_printf(m, "%40s %14lu %29s %pS\n",
81324 name, stats->contention_point[i],
81325 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81326 if (!i)
81327 seq_line(m, '-', 40-namelen, namelen);
81328
81329 - snprintf(ip, sizeof(ip), "[<%p>]",
81330 + snprintf(ip, sizeof(ip), "[<%pK>]",
81331 (void *)class->contending_point[i]);
81332 seq_printf(m, "%40s %14lu %29s %pS\n",
81333 name, stats->contending_point[i],
81334 diff --git a/kernel/module.c b/kernel/module.c
81335 index 2069158..71101bb 100644
81336 --- a/kernel/module.c
81337 +++ b/kernel/module.c
81338 @@ -61,6 +61,7 @@
81339 #include <linux/pfn.h>
81340 #include <linux/bsearch.h>
81341 #include <linux/fips.h>
81342 +#include <linux/grsecurity.h>
81343 #include <uapi/linux/module.h>
81344 #include "module-internal.h"
81345
81346 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
81347
81348 /* Bounds of module allocation, for speeding __module_address.
81349 * Protected by module_mutex. */
81350 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
81351 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
81352 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
81353
81354 int register_module_notifier(struct notifier_block * nb)
81355 {
81356 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81357 return true;
81358
81359 list_for_each_entry_rcu(mod, &modules, list) {
81360 - struct symsearch arr[] = {
81361 + struct symsearch modarr[] = {
81362 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
81363 NOT_GPL_ONLY, false },
81364 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
81365 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81366 if (mod->state == MODULE_STATE_UNFORMED)
81367 continue;
81368
81369 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
81370 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
81371 return true;
81372 }
81373 return false;
81374 @@ -490,7 +492,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
81375 if (!pcpusec->sh_size)
81376 return 0;
81377
81378 - if (align > PAGE_SIZE) {
81379 + if (align-1 >= PAGE_SIZE) {
81380 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
81381 mod->name, align, PAGE_SIZE);
81382 align = PAGE_SIZE;
81383 @@ -1096,7 +1098,7 @@ struct module_attribute module_uevent =
81384 static ssize_t show_coresize(struct module_attribute *mattr,
81385 struct module_kobject *mk, char *buffer)
81386 {
81387 - return sprintf(buffer, "%u\n", mk->mod->core_size);
81388 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
81389 }
81390
81391 static struct module_attribute modinfo_coresize =
81392 @@ -1105,7 +1107,7 @@ static struct module_attribute modinfo_coresize =
81393 static ssize_t show_initsize(struct module_attribute *mattr,
81394 struct module_kobject *mk, char *buffer)
81395 {
81396 - return sprintf(buffer, "%u\n", mk->mod->init_size);
81397 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
81398 }
81399
81400 static struct module_attribute modinfo_initsize =
81401 @@ -1320,7 +1322,7 @@ resolve_symbol_wait(struct module *mod,
81402 */
81403 #ifdef CONFIG_SYSFS
81404
81405 -#ifdef CONFIG_KALLSYMS
81406 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81407 static inline bool sect_empty(const Elf_Shdr *sect)
81408 {
81409 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
81410 @@ -1460,7 +1462,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
81411 {
81412 unsigned int notes, loaded, i;
81413 struct module_notes_attrs *notes_attrs;
81414 - struct bin_attribute *nattr;
81415 + bin_attribute_no_const *nattr;
81416
81417 /* failed to create section attributes, so can't create notes */
81418 if (!mod->sect_attrs)
81419 @@ -1572,7 +1574,7 @@ static void del_usage_links(struct module *mod)
81420 static int module_add_modinfo_attrs(struct module *mod)
81421 {
81422 struct module_attribute *attr;
81423 - struct module_attribute *temp_attr;
81424 + module_attribute_no_const *temp_attr;
81425 int error = 0;
81426 int i;
81427
81428 @@ -1786,21 +1788,21 @@ static void set_section_ro_nx(void *base,
81429
81430 static void unset_module_core_ro_nx(struct module *mod)
81431 {
81432 - set_page_attributes(mod->module_core + mod->core_text_size,
81433 - mod->module_core + mod->core_size,
81434 + set_page_attributes(mod->module_core_rw,
81435 + mod->module_core_rw + mod->core_size_rw,
81436 set_memory_x);
81437 - set_page_attributes(mod->module_core,
81438 - mod->module_core + mod->core_ro_size,
81439 + set_page_attributes(mod->module_core_rx,
81440 + mod->module_core_rx + mod->core_size_rx,
81441 set_memory_rw);
81442 }
81443
81444 static void unset_module_init_ro_nx(struct module *mod)
81445 {
81446 - set_page_attributes(mod->module_init + mod->init_text_size,
81447 - mod->module_init + mod->init_size,
81448 + set_page_attributes(mod->module_init_rw,
81449 + mod->module_init_rw + mod->init_size_rw,
81450 set_memory_x);
81451 - set_page_attributes(mod->module_init,
81452 - mod->module_init + mod->init_ro_size,
81453 + set_page_attributes(mod->module_init_rx,
81454 + mod->module_init_rx + mod->init_size_rx,
81455 set_memory_rw);
81456 }
81457
81458 @@ -1813,14 +1815,14 @@ void set_all_modules_text_rw(void)
81459 list_for_each_entry_rcu(mod, &modules, list) {
81460 if (mod->state == MODULE_STATE_UNFORMED)
81461 continue;
81462 - if ((mod->module_core) && (mod->core_text_size)) {
81463 - set_page_attributes(mod->module_core,
81464 - mod->module_core + mod->core_text_size,
81465 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81466 + set_page_attributes(mod->module_core_rx,
81467 + mod->module_core_rx + mod->core_size_rx,
81468 set_memory_rw);
81469 }
81470 - if ((mod->module_init) && (mod->init_text_size)) {
81471 - set_page_attributes(mod->module_init,
81472 - mod->module_init + mod->init_text_size,
81473 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81474 + set_page_attributes(mod->module_init_rx,
81475 + mod->module_init_rx + mod->init_size_rx,
81476 set_memory_rw);
81477 }
81478 }
81479 @@ -1836,14 +1838,14 @@ void set_all_modules_text_ro(void)
81480 list_for_each_entry_rcu(mod, &modules, list) {
81481 if (mod->state == MODULE_STATE_UNFORMED)
81482 continue;
81483 - if ((mod->module_core) && (mod->core_text_size)) {
81484 - set_page_attributes(mod->module_core,
81485 - mod->module_core + mod->core_text_size,
81486 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81487 + set_page_attributes(mod->module_core_rx,
81488 + mod->module_core_rx + mod->core_size_rx,
81489 set_memory_ro);
81490 }
81491 - if ((mod->module_init) && (mod->init_text_size)) {
81492 - set_page_attributes(mod->module_init,
81493 - mod->module_init + mod->init_text_size,
81494 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81495 + set_page_attributes(mod->module_init_rx,
81496 + mod->module_init_rx + mod->init_size_rx,
81497 set_memory_ro);
81498 }
81499 }
81500 @@ -1894,16 +1896,19 @@ static void free_module(struct module *mod)
81501
81502 /* This may be NULL, but that's OK */
81503 unset_module_init_ro_nx(mod);
81504 - module_free(mod, mod->module_init);
81505 + module_free(mod, mod->module_init_rw);
81506 + module_free_exec(mod, mod->module_init_rx);
81507 kfree(mod->args);
81508 percpu_modfree(mod);
81509
81510 /* Free lock-classes: */
81511 - lockdep_free_key_range(mod->module_core, mod->core_size);
81512 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
81513 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
81514
81515 /* Finally, free the core (containing the module structure) */
81516 unset_module_core_ro_nx(mod);
81517 - module_free(mod, mod->module_core);
81518 + module_free_exec(mod, mod->module_core_rx);
81519 + module_free(mod, mod->module_core_rw);
81520
81521 #ifdef CONFIG_MPU
81522 update_protections(current->mm);
81523 @@ -1973,9 +1978,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81524 int ret = 0;
81525 const struct kernel_symbol *ksym;
81526
81527 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81528 + int is_fs_load = 0;
81529 + int register_filesystem_found = 0;
81530 + char *p;
81531 +
81532 + p = strstr(mod->args, "grsec_modharden_fs");
81533 + if (p) {
81534 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
81535 + /* copy \0 as well */
81536 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
81537 + is_fs_load = 1;
81538 + }
81539 +#endif
81540 +
81541 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
81542 const char *name = info->strtab + sym[i].st_name;
81543
81544 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81545 + /* it's a real shame this will never get ripped and copied
81546 + upstream! ;(
81547 + */
81548 + if (is_fs_load && !strcmp(name, "register_filesystem"))
81549 + register_filesystem_found = 1;
81550 +#endif
81551 +
81552 switch (sym[i].st_shndx) {
81553 case SHN_COMMON:
81554 /* We compiled with -fno-common. These are not
81555 @@ -1996,7 +2023,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81556 ksym = resolve_symbol_wait(mod, info, name);
81557 /* Ok if resolved. */
81558 if (ksym && !IS_ERR(ksym)) {
81559 + pax_open_kernel();
81560 sym[i].st_value = ksym->value;
81561 + pax_close_kernel();
81562 break;
81563 }
81564
81565 @@ -2015,11 +2044,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81566 secbase = (unsigned long)mod_percpu(mod);
81567 else
81568 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
81569 + pax_open_kernel();
81570 sym[i].st_value += secbase;
81571 + pax_close_kernel();
81572 break;
81573 }
81574 }
81575
81576 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81577 + if (is_fs_load && !register_filesystem_found) {
81578 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
81579 + ret = -EPERM;
81580 + }
81581 +#endif
81582 +
81583 return ret;
81584 }
81585
81586 @@ -2103,22 +2141,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
81587 || s->sh_entsize != ~0UL
81588 || strstarts(sname, ".init"))
81589 continue;
81590 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
81591 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81592 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
81593 + else
81594 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
81595 pr_debug("\t%s\n", sname);
81596 }
81597 - switch (m) {
81598 - case 0: /* executable */
81599 - mod->core_size = debug_align(mod->core_size);
81600 - mod->core_text_size = mod->core_size;
81601 - break;
81602 - case 1: /* RO: text and ro-data */
81603 - mod->core_size = debug_align(mod->core_size);
81604 - mod->core_ro_size = mod->core_size;
81605 - break;
81606 - case 3: /* whole core */
81607 - mod->core_size = debug_align(mod->core_size);
81608 - break;
81609 - }
81610 }
81611
81612 pr_debug("Init section allocation order:\n");
81613 @@ -2132,23 +2160,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
81614 || s->sh_entsize != ~0UL
81615 || !strstarts(sname, ".init"))
81616 continue;
81617 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
81618 - | INIT_OFFSET_MASK);
81619 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81620 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
81621 + else
81622 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
81623 + s->sh_entsize |= INIT_OFFSET_MASK;
81624 pr_debug("\t%s\n", sname);
81625 }
81626 - switch (m) {
81627 - case 0: /* executable */
81628 - mod->init_size = debug_align(mod->init_size);
81629 - mod->init_text_size = mod->init_size;
81630 - break;
81631 - case 1: /* RO: text and ro-data */
81632 - mod->init_size = debug_align(mod->init_size);
81633 - mod->init_ro_size = mod->init_size;
81634 - break;
81635 - case 3: /* whole init */
81636 - mod->init_size = debug_align(mod->init_size);
81637 - break;
81638 - }
81639 }
81640 }
81641
81642 @@ -2321,7 +2339,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81643
81644 /* Put symbol section at end of init part of module. */
81645 symsect->sh_flags |= SHF_ALLOC;
81646 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
81647 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
81648 info->index.sym) | INIT_OFFSET_MASK;
81649 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
81650
81651 @@ -2338,13 +2356,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81652 }
81653
81654 /* Append room for core symbols at end of core part. */
81655 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
81656 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
81657 - mod->core_size += strtab_size;
81658 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
81659 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
81660 + mod->core_size_rx += strtab_size;
81661
81662 /* Put string table section at end of init part of module. */
81663 strsect->sh_flags |= SHF_ALLOC;
81664 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
81665 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
81666 info->index.str) | INIT_OFFSET_MASK;
81667 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
81668 }
81669 @@ -2362,12 +2380,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81670 /* Make sure we get permanent strtab: don't use info->strtab. */
81671 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
81672
81673 + pax_open_kernel();
81674 +
81675 /* Set types up while we still have access to sections. */
81676 for (i = 0; i < mod->num_symtab; i++)
81677 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
81678
81679 - mod->core_symtab = dst = mod->module_core + info->symoffs;
81680 - mod->core_strtab = s = mod->module_core + info->stroffs;
81681 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
81682 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
81683 src = mod->symtab;
81684 for (ndst = i = 0; i < mod->num_symtab; i++) {
81685 if (i == 0 ||
81686 @@ -2379,6 +2399,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81687 }
81688 }
81689 mod->core_num_syms = ndst;
81690 +
81691 + pax_close_kernel();
81692 }
81693 #else
81694 static inline void layout_symtab(struct module *mod, struct load_info *info)
81695 @@ -2412,17 +2434,33 @@ void * __weak module_alloc(unsigned long size)
81696 return vmalloc_exec(size);
81697 }
81698
81699 -static void *module_alloc_update_bounds(unsigned long size)
81700 +static void *module_alloc_update_bounds_rw(unsigned long size)
81701 {
81702 void *ret = module_alloc(size);
81703
81704 if (ret) {
81705 mutex_lock(&module_mutex);
81706 /* Update module bounds. */
81707 - if ((unsigned long)ret < module_addr_min)
81708 - module_addr_min = (unsigned long)ret;
81709 - if ((unsigned long)ret + size > module_addr_max)
81710 - module_addr_max = (unsigned long)ret + size;
81711 + if ((unsigned long)ret < module_addr_min_rw)
81712 + module_addr_min_rw = (unsigned long)ret;
81713 + if ((unsigned long)ret + size > module_addr_max_rw)
81714 + module_addr_max_rw = (unsigned long)ret + size;
81715 + mutex_unlock(&module_mutex);
81716 + }
81717 + return ret;
81718 +}
81719 +
81720 +static void *module_alloc_update_bounds_rx(unsigned long size)
81721 +{
81722 + void *ret = module_alloc_exec(size);
81723 +
81724 + if (ret) {
81725 + mutex_lock(&module_mutex);
81726 + /* Update module bounds. */
81727 + if ((unsigned long)ret < module_addr_min_rx)
81728 + module_addr_min_rx = (unsigned long)ret;
81729 + if ((unsigned long)ret + size > module_addr_max_rx)
81730 + module_addr_max_rx = (unsigned long)ret + size;
81731 mutex_unlock(&module_mutex);
81732 }
81733 return ret;
81734 @@ -2698,8 +2736,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
81735 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81736 {
81737 const char *modmagic = get_modinfo(info, "vermagic");
81738 + const char *license = get_modinfo(info, "license");
81739 int err;
81740
81741 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
81742 + if (!license || !license_is_gpl_compatible(license))
81743 + return -ENOEXEC;
81744 +#endif
81745 +
81746 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
81747 modmagic = NULL;
81748
81749 @@ -2725,7 +2769,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81750 }
81751
81752 /* Set up license info based on the info section */
81753 - set_license(mod, get_modinfo(info, "license"));
81754 + set_license(mod, license);
81755
81756 return 0;
81757 }
81758 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
81759 void *ptr;
81760
81761 /* Do the allocs. */
81762 - ptr = module_alloc_update_bounds(mod->core_size);
81763 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
81764 /*
81765 * The pointer to this block is stored in the module structure
81766 * which is inside the block. Just mark it as not being a
81767 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
81768 if (!ptr)
81769 return -ENOMEM;
81770
81771 - memset(ptr, 0, mod->core_size);
81772 - mod->module_core = ptr;
81773 + memset(ptr, 0, mod->core_size_rw);
81774 + mod->module_core_rw = ptr;
81775
81776 - if (mod->init_size) {
81777 - ptr = module_alloc_update_bounds(mod->init_size);
81778 + if (mod->init_size_rw) {
81779 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
81780 /*
81781 * The pointer to this block is stored in the module structure
81782 * which is inside the block. This block doesn't need to be
81783 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
81784 */
81785 kmemleak_ignore(ptr);
81786 if (!ptr) {
81787 - module_free(mod, mod->module_core);
81788 + module_free(mod, mod->module_core_rw);
81789 return -ENOMEM;
81790 }
81791 - memset(ptr, 0, mod->init_size);
81792 - mod->module_init = ptr;
81793 + memset(ptr, 0, mod->init_size_rw);
81794 + mod->module_init_rw = ptr;
81795 } else
81796 - mod->module_init = NULL;
81797 + mod->module_init_rw = NULL;
81798 +
81799 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
81800 + kmemleak_not_leak(ptr);
81801 + if (!ptr) {
81802 + if (mod->module_init_rw)
81803 + module_free(mod, mod->module_init_rw);
81804 + module_free(mod, mod->module_core_rw);
81805 + return -ENOMEM;
81806 + }
81807 +
81808 + pax_open_kernel();
81809 + memset(ptr, 0, mod->core_size_rx);
81810 + pax_close_kernel();
81811 + mod->module_core_rx = ptr;
81812 +
81813 + if (mod->init_size_rx) {
81814 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
81815 + kmemleak_ignore(ptr);
81816 + if (!ptr && mod->init_size_rx) {
81817 + module_free_exec(mod, mod->module_core_rx);
81818 + if (mod->module_init_rw)
81819 + module_free(mod, mod->module_init_rw);
81820 + module_free(mod, mod->module_core_rw);
81821 + return -ENOMEM;
81822 + }
81823 +
81824 + pax_open_kernel();
81825 + memset(ptr, 0, mod->init_size_rx);
81826 + pax_close_kernel();
81827 + mod->module_init_rx = ptr;
81828 + } else
81829 + mod->module_init_rx = NULL;
81830
81831 /* Transfer each section which specifies SHF_ALLOC */
81832 pr_debug("final section addresses:\n");
81833 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
81834 if (!(shdr->sh_flags & SHF_ALLOC))
81835 continue;
81836
81837 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
81838 - dest = mod->module_init
81839 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81840 - else
81841 - dest = mod->module_core + shdr->sh_entsize;
81842 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
81843 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81844 + dest = mod->module_init_rw
81845 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81846 + else
81847 + dest = mod->module_init_rx
81848 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81849 + } else {
81850 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81851 + dest = mod->module_core_rw + shdr->sh_entsize;
81852 + else
81853 + dest = mod->module_core_rx + shdr->sh_entsize;
81854 + }
81855 +
81856 + if (shdr->sh_type != SHT_NOBITS) {
81857 +
81858 +#ifdef CONFIG_PAX_KERNEXEC
81859 +#ifdef CONFIG_X86_64
81860 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
81861 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
81862 +#endif
81863 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
81864 + pax_open_kernel();
81865 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81866 + pax_close_kernel();
81867 + } else
81868 +#endif
81869
81870 - if (shdr->sh_type != SHT_NOBITS)
81871 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81872 + }
81873 /* Update sh_addr to point to copy in image. */
81874 - shdr->sh_addr = (unsigned long)dest;
81875 +
81876 +#ifdef CONFIG_PAX_KERNEXEC
81877 + if (shdr->sh_flags & SHF_EXECINSTR)
81878 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
81879 + else
81880 +#endif
81881 +
81882 + shdr->sh_addr = (unsigned long)dest;
81883 pr_debug("\t0x%lx %s\n",
81884 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
81885 }
81886 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
81887 * Do it before processing of module parameters, so the module
81888 * can provide parameter accessor functions of its own.
81889 */
81890 - if (mod->module_init)
81891 - flush_icache_range((unsigned long)mod->module_init,
81892 - (unsigned long)mod->module_init
81893 - + mod->init_size);
81894 - flush_icache_range((unsigned long)mod->module_core,
81895 - (unsigned long)mod->module_core + mod->core_size);
81896 + if (mod->module_init_rx)
81897 + flush_icache_range((unsigned long)mod->module_init_rx,
81898 + (unsigned long)mod->module_init_rx
81899 + + mod->init_size_rx);
81900 + flush_icache_range((unsigned long)mod->module_core_rx,
81901 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
81902
81903 set_fs(old_fs);
81904 }
81905 @@ -2974,8 +3079,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
81906 static void module_deallocate(struct module *mod, struct load_info *info)
81907 {
81908 percpu_modfree(mod);
81909 - module_free(mod, mod->module_init);
81910 - module_free(mod, mod->module_core);
81911 + module_free_exec(mod, mod->module_init_rx);
81912 + module_free_exec(mod, mod->module_core_rx);
81913 + module_free(mod, mod->module_init_rw);
81914 + module_free(mod, mod->module_core_rw);
81915 }
81916
81917 int __weak module_finalize(const Elf_Ehdr *hdr,
81918 @@ -2988,7 +3095,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
81919 static int post_relocation(struct module *mod, const struct load_info *info)
81920 {
81921 /* Sort exception table now relocations are done. */
81922 + pax_open_kernel();
81923 sort_extable(mod->extable, mod->extable + mod->num_exentries);
81924 + pax_close_kernel();
81925
81926 /* Copy relocated percpu area over. */
81927 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
81928 @@ -3042,16 +3151,16 @@ static int do_init_module(struct module *mod)
81929 MODULE_STATE_COMING, mod);
81930
81931 /* Set RO and NX regions for core */
81932 - set_section_ro_nx(mod->module_core,
81933 - mod->core_text_size,
81934 - mod->core_ro_size,
81935 - mod->core_size);
81936 + set_section_ro_nx(mod->module_core_rx,
81937 + mod->core_size_rx,
81938 + mod->core_size_rx,
81939 + mod->core_size_rx);
81940
81941 /* Set RO and NX regions for init */
81942 - set_section_ro_nx(mod->module_init,
81943 - mod->init_text_size,
81944 - mod->init_ro_size,
81945 - mod->init_size);
81946 + set_section_ro_nx(mod->module_init_rx,
81947 + mod->init_size_rx,
81948 + mod->init_size_rx,
81949 + mod->init_size_rx);
81950
81951 do_mod_ctors(mod);
81952 /* Start the module */
81953 @@ -3113,11 +3222,12 @@ static int do_init_module(struct module *mod)
81954 mod->strtab = mod->core_strtab;
81955 #endif
81956 unset_module_init_ro_nx(mod);
81957 - module_free(mod, mod->module_init);
81958 - mod->module_init = NULL;
81959 - mod->init_size = 0;
81960 - mod->init_ro_size = 0;
81961 - mod->init_text_size = 0;
81962 + module_free(mod, mod->module_init_rw);
81963 + module_free_exec(mod, mod->module_init_rx);
81964 + mod->module_init_rw = NULL;
81965 + mod->module_init_rx = NULL;
81966 + mod->init_size_rw = 0;
81967 + mod->init_size_rx = 0;
81968 mutex_unlock(&module_mutex);
81969 wake_up_all(&module_wq);
81970
81971 @@ -3261,9 +3371,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
81972 if (err)
81973 goto free_unload;
81974
81975 + /* Now copy in args */
81976 + mod->args = strndup_user(uargs, ~0UL >> 1);
81977 + if (IS_ERR(mod->args)) {
81978 + err = PTR_ERR(mod->args);
81979 + goto free_unload;
81980 + }
81981 +
81982 /* Set up MODINFO_ATTR fields */
81983 setup_modinfo(mod, info);
81984
81985 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81986 + {
81987 + char *p, *p2;
81988 +
81989 + if (strstr(mod->args, "grsec_modharden_netdev")) {
81990 + 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);
81991 + err = -EPERM;
81992 + goto free_modinfo;
81993 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
81994 + p += sizeof("grsec_modharden_normal") - 1;
81995 + p2 = strstr(p, "_");
81996 + if (p2) {
81997 + *p2 = '\0';
81998 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
81999 + *p2 = '_';
82000 + }
82001 + err = -EPERM;
82002 + goto free_modinfo;
82003 + }
82004 + }
82005 +#endif
82006 +
82007 /* Fix up syms, so that st_value is a pointer to location. */
82008 err = simplify_symbols(mod, info);
82009 if (err < 0)
82010 @@ -3279,13 +3418,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
82011
82012 flush_module_icache(mod);
82013
82014 - /* Now copy in args */
82015 - mod->args = strndup_user(uargs, ~0UL >> 1);
82016 - if (IS_ERR(mod->args)) {
82017 - err = PTR_ERR(mod->args);
82018 - goto free_arch_cleanup;
82019 - }
82020 -
82021 dynamic_debug_setup(info->debug, info->num_debug);
82022
82023 /* Finally it's fully formed, ready to start executing. */
82024 @@ -3320,11 +3452,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
82025 ddebug_cleanup:
82026 dynamic_debug_remove(info->debug);
82027 synchronize_sched();
82028 - kfree(mod->args);
82029 - free_arch_cleanup:
82030 module_arch_cleanup(mod);
82031 free_modinfo:
82032 free_modinfo(mod);
82033 + kfree(mod->args);
82034 free_unload:
82035 module_unload_free(mod);
82036 unlink_mod:
82037 @@ -3407,10 +3538,16 @@ static const char *get_ksymbol(struct module *mod,
82038 unsigned long nextval;
82039
82040 /* At worse, next value is at end of module */
82041 - if (within_module_init(addr, mod))
82042 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
82043 + if (within_module_init_rx(addr, mod))
82044 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
82045 + else if (within_module_init_rw(addr, mod))
82046 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
82047 + else if (within_module_core_rx(addr, mod))
82048 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
82049 + else if (within_module_core_rw(addr, mod))
82050 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
82051 else
82052 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
82053 + return NULL;
82054
82055 /* Scan for closest preceding symbol, and next symbol. (ELF
82056 starts real symbols at 1). */
82057 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
82058 return 0;
82059
82060 seq_printf(m, "%s %u",
82061 - mod->name, mod->init_size + mod->core_size);
82062 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
82063 print_unload_info(m, mod);
82064
82065 /* Informative for users. */
82066 @@ -3670,7 +3807,7 @@ static int m_show(struct seq_file *m, void *p)
82067 mod->state == MODULE_STATE_COMING ? "Loading":
82068 "Live");
82069 /* Used by oprofile and other similar tools. */
82070 - seq_printf(m, " 0x%pK", mod->module_core);
82071 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
82072
82073 /* Taints info */
82074 if (mod->taints)
82075 @@ -3706,7 +3843,17 @@ static const struct file_operations proc_modules_operations = {
82076
82077 static int __init proc_modules_init(void)
82078 {
82079 +#ifndef CONFIG_GRKERNSEC_HIDESYM
82080 +#ifdef CONFIG_GRKERNSEC_PROC_USER
82081 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82082 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82083 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
82084 +#else
82085 proc_create("modules", 0, NULL, &proc_modules_operations);
82086 +#endif
82087 +#else
82088 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82089 +#endif
82090 return 0;
82091 }
82092 module_init(proc_modules_init);
82093 @@ -3767,14 +3914,14 @@ struct module *__module_address(unsigned long addr)
82094 {
82095 struct module *mod;
82096
82097 - if (addr < module_addr_min || addr > module_addr_max)
82098 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
82099 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
82100 return NULL;
82101
82102 list_for_each_entry_rcu(mod, &modules, list) {
82103 if (mod->state == MODULE_STATE_UNFORMED)
82104 continue;
82105 - if (within_module_core(addr, mod)
82106 - || within_module_init(addr, mod))
82107 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
82108 return mod;
82109 }
82110 return NULL;
82111 @@ -3809,11 +3956,20 @@ bool is_module_text_address(unsigned long addr)
82112 */
82113 struct module *__module_text_address(unsigned long addr)
82114 {
82115 - struct module *mod = __module_address(addr);
82116 + struct module *mod;
82117 +
82118 +#ifdef CONFIG_X86_32
82119 + addr = ktla_ktva(addr);
82120 +#endif
82121 +
82122 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
82123 + return NULL;
82124 +
82125 + mod = __module_address(addr);
82126 +
82127 if (mod) {
82128 /* Make sure it's within the text section. */
82129 - if (!within(addr, mod->module_init, mod->init_text_size)
82130 - && !within(addr, mod->module_core, mod->core_text_size))
82131 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
82132 mod = NULL;
82133 }
82134 return mod;
82135 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
82136 index 7e3443f..b2a1e6b 100644
82137 --- a/kernel/mutex-debug.c
82138 +++ b/kernel/mutex-debug.c
82139 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
82140 }
82141
82142 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82143 - struct thread_info *ti)
82144 + struct task_struct *task)
82145 {
82146 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
82147
82148 /* Mark the current thread as blocked on the lock: */
82149 - ti->task->blocked_on = waiter;
82150 + task->blocked_on = waiter;
82151 }
82152
82153 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82154 - struct thread_info *ti)
82155 + struct task_struct *task)
82156 {
82157 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
82158 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
82159 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
82160 - ti->task->blocked_on = NULL;
82161 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
82162 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
82163 + task->blocked_on = NULL;
82164
82165 list_del_init(&waiter->list);
82166 waiter->task = NULL;
82167 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
82168 index 0799fd3..d06ae3b 100644
82169 --- a/kernel/mutex-debug.h
82170 +++ b/kernel/mutex-debug.h
82171 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
82172 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
82173 extern void debug_mutex_add_waiter(struct mutex *lock,
82174 struct mutex_waiter *waiter,
82175 - struct thread_info *ti);
82176 + struct task_struct *task);
82177 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82178 - struct thread_info *ti);
82179 + struct task_struct *task);
82180 extern void debug_mutex_unlock(struct mutex *lock);
82181 extern void debug_mutex_init(struct mutex *lock, const char *name,
82182 struct lock_class_key *key);
82183 diff --git a/kernel/mutex.c b/kernel/mutex.c
82184 index a2b80f1..e91d35c 100644
82185 --- a/kernel/mutex.c
82186 +++ b/kernel/mutex.c
82187 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
82188 node->locked = 1;
82189 return;
82190 }
82191 - ACCESS_ONCE(prev->next) = node;
82192 + ACCESS_ONCE_RW(prev->next) = node;
82193 smp_wmb();
82194 /* Wait until the lock holder passes the lock down */
82195 while (!ACCESS_ONCE(node->locked))
82196 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
82197 while (!(next = ACCESS_ONCE(node->next)))
82198 arch_mutex_cpu_relax();
82199 }
82200 - ACCESS_ONCE(next->locked) = 1;
82201 + ACCESS_ONCE_RW(next->locked) = 1;
82202 smp_wmb();
82203 }
82204
82205 @@ -514,7 +514,7 @@ slowpath:
82206 spin_lock_mutex(&lock->wait_lock, flags);
82207
82208 debug_mutex_lock_common(lock, &waiter);
82209 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
82210 + debug_mutex_add_waiter(lock, &waiter, task);
82211
82212 /* add waiting tasks to the end of the waitqueue (FIFO): */
82213 list_add_tail(&waiter.list, &lock->wait_list);
82214 @@ -565,7 +565,7 @@ slowpath:
82215 done:
82216 lock_acquired(&lock->dep_map, ip);
82217 /* got the lock - rejoice! */
82218 - mutex_remove_waiter(lock, &waiter, current_thread_info());
82219 + mutex_remove_waiter(lock, &waiter, task);
82220 mutex_set_owner(lock);
82221
82222 if (use_ww_ctx) {
82223 @@ -604,7 +604,7 @@ done:
82224 return 0;
82225
82226 err:
82227 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
82228 + mutex_remove_waiter(lock, &waiter, task);
82229 spin_unlock_mutex(&lock->wait_lock, flags);
82230 debug_mutex_free_waiter(&waiter);
82231 mutex_release(&lock->dep_map, 1, ip);
82232 diff --git a/kernel/notifier.c b/kernel/notifier.c
82233 index 2d5cc4c..d9ea600 100644
82234 --- a/kernel/notifier.c
82235 +++ b/kernel/notifier.c
82236 @@ -5,6 +5,7 @@
82237 #include <linux/rcupdate.h>
82238 #include <linux/vmalloc.h>
82239 #include <linux/reboot.h>
82240 +#include <linux/mm.h>
82241
82242 /*
82243 * Notifier list for kernel code which wants to be called
82244 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
82245 while ((*nl) != NULL) {
82246 if (n->priority > (*nl)->priority)
82247 break;
82248 - nl = &((*nl)->next);
82249 + nl = (struct notifier_block **)&((*nl)->next);
82250 }
82251 - n->next = *nl;
82252 + pax_open_kernel();
82253 + *(const void **)&n->next = *nl;
82254 rcu_assign_pointer(*nl, n);
82255 + pax_close_kernel();
82256 return 0;
82257 }
82258
82259 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
82260 return 0;
82261 if (n->priority > (*nl)->priority)
82262 break;
82263 - nl = &((*nl)->next);
82264 + nl = (struct notifier_block **)&((*nl)->next);
82265 }
82266 - n->next = *nl;
82267 + pax_open_kernel();
82268 + *(const void **)&n->next = *nl;
82269 rcu_assign_pointer(*nl, n);
82270 + pax_close_kernel();
82271 return 0;
82272 }
82273
82274 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
82275 {
82276 while ((*nl) != NULL) {
82277 if ((*nl) == n) {
82278 + pax_open_kernel();
82279 rcu_assign_pointer(*nl, n->next);
82280 + pax_close_kernel();
82281 return 0;
82282 }
82283 - nl = &((*nl)->next);
82284 + nl = (struct notifier_block **)&((*nl)->next);
82285 }
82286 return -ENOENT;
82287 }
82288 diff --git a/kernel/panic.c b/kernel/panic.c
82289 index 8018646..b6a5b4f 100644
82290 --- a/kernel/panic.c
82291 +++ b/kernel/panic.c
82292 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
82293 disable_trace_on_warning();
82294
82295 pr_warn("------------[ cut here ]------------\n");
82296 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
82297 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
82298 raw_smp_processor_id(), current->pid, file, line, caller);
82299
82300 if (args)
82301 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
82302 */
82303 void __stack_chk_fail(void)
82304 {
82305 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
82306 + dump_stack();
82307 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
82308 __builtin_return_address(0));
82309 }
82310 EXPORT_SYMBOL(__stack_chk_fail);
82311 diff --git a/kernel/pid.c b/kernel/pid.c
82312 index ebe5e80..5d6d634 100644
82313 --- a/kernel/pid.c
82314 +++ b/kernel/pid.c
82315 @@ -33,6 +33,7 @@
82316 #include <linux/rculist.h>
82317 #include <linux/bootmem.h>
82318 #include <linux/hash.h>
82319 +#include <linux/security.h>
82320 #include <linux/pid_namespace.h>
82321 #include <linux/init_task.h>
82322 #include <linux/syscalls.h>
82323 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
82324
82325 int pid_max = PID_MAX_DEFAULT;
82326
82327 -#define RESERVED_PIDS 300
82328 +#define RESERVED_PIDS 500
82329
82330 int pid_max_min = RESERVED_PIDS + 1;
82331 int pid_max_max = PID_MAX_LIMIT;
82332 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
82333 */
82334 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
82335 {
82336 + struct task_struct *task;
82337 +
82338 rcu_lockdep_assert(rcu_read_lock_held(),
82339 "find_task_by_pid_ns() needs rcu_read_lock()"
82340 " protection");
82341 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82342 +
82343 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82344 +
82345 + if (gr_pid_is_chrooted(task))
82346 + return NULL;
82347 +
82348 + return task;
82349 }
82350
82351 struct task_struct *find_task_by_vpid(pid_t vnr)
82352 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
82353 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
82354 }
82355
82356 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
82357 +{
82358 + rcu_lockdep_assert(rcu_read_lock_held(),
82359 + "find_task_by_pid_ns() needs rcu_read_lock()"
82360 + " protection");
82361 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
82362 +}
82363 +
82364 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
82365 {
82366 struct pid *pid;
82367 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
82368 index 601bb36..f7e6f34 100644
82369 --- a/kernel/pid_namespace.c
82370 +++ b/kernel/pid_namespace.c
82371 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
82372 void __user *buffer, size_t *lenp, loff_t *ppos)
82373 {
82374 struct pid_namespace *pid_ns = task_active_pid_ns(current);
82375 - struct ctl_table tmp = *table;
82376 + ctl_table_no_const tmp = *table;
82377
82378 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
82379 return -EPERM;
82380 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
82381 index c7f31aa..2b44977 100644
82382 --- a/kernel/posix-cpu-timers.c
82383 +++ b/kernel/posix-cpu-timers.c
82384 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
82385
82386 static __init int init_posix_cpu_timers(void)
82387 {
82388 - struct k_clock process = {
82389 + static struct k_clock process = {
82390 .clock_getres = process_cpu_clock_getres,
82391 .clock_get = process_cpu_clock_get,
82392 .timer_create = process_cpu_timer_create,
82393 .nsleep = process_cpu_nsleep,
82394 .nsleep_restart = process_cpu_nsleep_restart,
82395 };
82396 - struct k_clock thread = {
82397 + static struct k_clock thread = {
82398 .clock_getres = thread_cpu_clock_getres,
82399 .clock_get = thread_cpu_clock_get,
82400 .timer_create = thread_cpu_timer_create,
82401 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
82402 index 424c2d4..679242f 100644
82403 --- a/kernel/posix-timers.c
82404 +++ b/kernel/posix-timers.c
82405 @@ -43,6 +43,7 @@
82406 #include <linux/hash.h>
82407 #include <linux/posix-clock.h>
82408 #include <linux/posix-timers.h>
82409 +#include <linux/grsecurity.h>
82410 #include <linux/syscalls.h>
82411 #include <linux/wait.h>
82412 #include <linux/workqueue.h>
82413 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
82414 * which we beg off on and pass to do_sys_settimeofday().
82415 */
82416
82417 -static struct k_clock posix_clocks[MAX_CLOCKS];
82418 +static struct k_clock *posix_clocks[MAX_CLOCKS];
82419
82420 /*
82421 * These ones are defined below.
82422 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
82423 */
82424 static __init int init_posix_timers(void)
82425 {
82426 - struct k_clock clock_realtime = {
82427 + static struct k_clock clock_realtime = {
82428 .clock_getres = hrtimer_get_res,
82429 .clock_get = posix_clock_realtime_get,
82430 .clock_set = posix_clock_realtime_set,
82431 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
82432 .timer_get = common_timer_get,
82433 .timer_del = common_timer_del,
82434 };
82435 - struct k_clock clock_monotonic = {
82436 + static struct k_clock clock_monotonic = {
82437 .clock_getres = hrtimer_get_res,
82438 .clock_get = posix_ktime_get_ts,
82439 .nsleep = common_nsleep,
82440 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
82441 .timer_get = common_timer_get,
82442 .timer_del = common_timer_del,
82443 };
82444 - struct k_clock clock_monotonic_raw = {
82445 + static struct k_clock clock_monotonic_raw = {
82446 .clock_getres = hrtimer_get_res,
82447 .clock_get = posix_get_monotonic_raw,
82448 };
82449 - struct k_clock clock_realtime_coarse = {
82450 + static struct k_clock clock_realtime_coarse = {
82451 .clock_getres = posix_get_coarse_res,
82452 .clock_get = posix_get_realtime_coarse,
82453 };
82454 - struct k_clock clock_monotonic_coarse = {
82455 + static struct k_clock clock_monotonic_coarse = {
82456 .clock_getres = posix_get_coarse_res,
82457 .clock_get = posix_get_monotonic_coarse,
82458 };
82459 - struct k_clock clock_tai = {
82460 + static struct k_clock clock_tai = {
82461 .clock_getres = hrtimer_get_res,
82462 .clock_get = posix_get_tai,
82463 .nsleep = common_nsleep,
82464 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
82465 .timer_get = common_timer_get,
82466 .timer_del = common_timer_del,
82467 };
82468 - struct k_clock clock_boottime = {
82469 + static struct k_clock clock_boottime = {
82470 .clock_getres = hrtimer_get_res,
82471 .clock_get = posix_get_boottime,
82472 .nsleep = common_nsleep,
82473 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
82474 return;
82475 }
82476
82477 - posix_clocks[clock_id] = *new_clock;
82478 + posix_clocks[clock_id] = new_clock;
82479 }
82480 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
82481
82482 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
82483 return (id & CLOCKFD_MASK) == CLOCKFD ?
82484 &clock_posix_dynamic : &clock_posix_cpu;
82485
82486 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
82487 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
82488 return NULL;
82489 - return &posix_clocks[id];
82490 + return posix_clocks[id];
82491 }
82492
82493 static int common_timer_create(struct k_itimer *new_timer)
82494 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
82495 struct k_clock *kc = clockid_to_kclock(which_clock);
82496 struct k_itimer *new_timer;
82497 int error, new_timer_id;
82498 - sigevent_t event;
82499 + sigevent_t event = { };
82500 int it_id_set = IT_ID_NOT_SET;
82501
82502 if (!kc)
82503 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
82504 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
82505 return -EFAULT;
82506
82507 + /* only the CLOCK_REALTIME clock can be set, all other clocks
82508 + have their clock_set fptr set to a nosettime dummy function
82509 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
82510 + call common_clock_set, which calls do_sys_settimeofday, which
82511 + we hook
82512 + */
82513 +
82514 return kc->clock_set(which_clock, &new_tp);
82515 }
82516
82517 diff --git a/kernel/power/process.c b/kernel/power/process.c
82518 index 06ec886..9dba35e 100644
82519 --- a/kernel/power/process.c
82520 +++ b/kernel/power/process.c
82521 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
82522 unsigned int elapsed_msecs;
82523 bool wakeup = false;
82524 int sleep_usecs = USEC_PER_MSEC;
82525 + bool timedout = false;
82526
82527 do_gettimeofday(&start);
82528
82529 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
82530
82531 while (true) {
82532 todo = 0;
82533 + if (time_after(jiffies, end_time))
82534 + timedout = true;
82535 read_lock(&tasklist_lock);
82536 do_each_thread(g, p) {
82537 if (p == current || !freeze_task(p))
82538 continue;
82539
82540 - if (!freezer_should_skip(p))
82541 + if (!freezer_should_skip(p)) {
82542 todo++;
82543 + if (timedout) {
82544 + printk(KERN_ERR "Task refusing to freeze:\n");
82545 + sched_show_task(p);
82546 + }
82547 + }
82548 } while_each_thread(g, p);
82549 read_unlock(&tasklist_lock);
82550
82551 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
82552 todo += wq_busy;
82553 }
82554
82555 - if (!todo || time_after(jiffies, end_time))
82556 + if (!todo || timedout)
82557 break;
82558
82559 if (pm_wakeup_pending()) {
82560 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
82561 index 5b5a708..ec7637e 100644
82562 --- a/kernel/printk/printk.c
82563 +++ b/kernel/printk/printk.c
82564 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
82565 if (from_file && type != SYSLOG_ACTION_OPEN)
82566 return 0;
82567
82568 +#ifdef CONFIG_GRKERNSEC_DMESG
82569 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
82570 + return -EPERM;
82571 +#endif
82572 +
82573 if (syslog_action_restricted(type)) {
82574 if (capable(CAP_SYSLOG))
82575 return 0;
82576 diff --git a/kernel/profile.c b/kernel/profile.c
82577 index 6631e1e..310c266 100644
82578 --- a/kernel/profile.c
82579 +++ b/kernel/profile.c
82580 @@ -37,7 +37,7 @@ struct profile_hit {
82581 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
82582 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
82583
82584 -static atomic_t *prof_buffer;
82585 +static atomic_unchecked_t *prof_buffer;
82586 static unsigned long prof_len, prof_shift;
82587
82588 int prof_on __read_mostly;
82589 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
82590 hits[i].pc = 0;
82591 continue;
82592 }
82593 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82594 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82595 hits[i].hits = hits[i].pc = 0;
82596 }
82597 }
82598 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82599 * Add the current hit(s) and flush the write-queue out
82600 * to the global buffer:
82601 */
82602 - atomic_add(nr_hits, &prof_buffer[pc]);
82603 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
82604 for (i = 0; i < NR_PROFILE_HIT; ++i) {
82605 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82606 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82607 hits[i].pc = hits[i].hits = 0;
82608 }
82609 out:
82610 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82611 {
82612 unsigned long pc;
82613 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
82614 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82615 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82616 }
82617 #endif /* !CONFIG_SMP */
82618
82619 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
82620 return -EFAULT;
82621 buf++; p++; count--; read++;
82622 }
82623 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
82624 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
82625 if (copy_to_user(buf, (void *)pnt, count))
82626 return -EFAULT;
82627 read += count;
82628 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
82629 }
82630 #endif
82631 profile_discard_flip_buffers();
82632 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
82633 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
82634 return count;
82635 }
82636
82637 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
82638 index a146ee3..ffed4c3 100644
82639 --- a/kernel/ptrace.c
82640 +++ b/kernel/ptrace.c
82641 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
82642 if (seize)
82643 flags |= PT_SEIZED;
82644 rcu_read_lock();
82645 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82646 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82647 flags |= PT_PTRACE_CAP;
82648 rcu_read_unlock();
82649 task->ptrace = flags;
82650 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
82651 break;
82652 return -EIO;
82653 }
82654 - if (copy_to_user(dst, buf, retval))
82655 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
82656 return -EFAULT;
82657 copied += retval;
82658 src += retval;
82659 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
82660 bool seized = child->ptrace & PT_SEIZED;
82661 int ret = -EIO;
82662 siginfo_t siginfo, *si;
82663 - void __user *datavp = (void __user *) data;
82664 + void __user *datavp = (__force void __user *) data;
82665 unsigned long __user *datalp = datavp;
82666 unsigned long flags;
82667
82668 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
82669 goto out;
82670 }
82671
82672 + if (gr_handle_ptrace(child, request)) {
82673 + ret = -EPERM;
82674 + goto out_put_task_struct;
82675 + }
82676 +
82677 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82678 ret = ptrace_attach(child, request, addr, data);
82679 /*
82680 * Some architectures need to do book-keeping after
82681 * a ptrace attach.
82682 */
82683 - if (!ret)
82684 + if (!ret) {
82685 arch_ptrace_attach(child);
82686 + gr_audit_ptrace(child);
82687 + }
82688 goto out_put_task_struct;
82689 }
82690
82691 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
82692 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
82693 if (copied != sizeof(tmp))
82694 return -EIO;
82695 - return put_user(tmp, (unsigned long __user *)data);
82696 + return put_user(tmp, (__force unsigned long __user *)data);
82697 }
82698
82699 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
82700 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
82701 }
82702
82703 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82704 - compat_long_t addr, compat_long_t data)
82705 + compat_ulong_t addr, compat_ulong_t data)
82706 {
82707 struct task_struct *child;
82708 long ret;
82709 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82710 goto out;
82711 }
82712
82713 + if (gr_handle_ptrace(child, request)) {
82714 + ret = -EPERM;
82715 + goto out_put_task_struct;
82716 + }
82717 +
82718 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82719 ret = ptrace_attach(child, request, addr, data);
82720 /*
82721 * Some architectures need to do book-keeping after
82722 * a ptrace attach.
82723 */
82724 - if (!ret)
82725 + if (!ret) {
82726 arch_ptrace_attach(child);
82727 + gr_audit_ptrace(child);
82728 + }
82729 goto out_put_task_struct;
82730 }
82731
82732 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
82733 index cce6ba8..7c758b1f 100644
82734 --- a/kernel/rcupdate.c
82735 +++ b/kernel/rcupdate.c
82736 @@ -412,10 +412,10 @@ int rcu_jiffies_till_stall_check(void)
82737 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
82738 */
82739 if (till_stall_check < 3) {
82740 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
82741 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
82742 till_stall_check = 3;
82743 } else if (till_stall_check > 300) {
82744 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
82745 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
82746 till_stall_check = 300;
82747 }
82748 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
82749 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
82750 index aa34411..4832cd4 100644
82751 --- a/kernel/rcutiny.c
82752 +++ b/kernel/rcutiny.c
82753 @@ -45,7 +45,7 @@
82754 /* Forward declarations for rcutiny_plugin.h. */
82755 struct rcu_ctrlblk;
82756 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
82757 -static void rcu_process_callbacks(struct softirq_action *unused);
82758 +static void rcu_process_callbacks(void);
82759 static void __call_rcu(struct rcu_head *head,
82760 void (*func)(struct rcu_head *rcu),
82761 struct rcu_ctrlblk *rcp);
82762 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
82763 false));
82764 }
82765
82766 -static void rcu_process_callbacks(struct softirq_action *unused)
82767 +static __latent_entropy void rcu_process_callbacks(void)
82768 {
82769 __rcu_process_callbacks(&rcu_sched_ctrlblk);
82770 __rcu_process_callbacks(&rcu_bh_ctrlblk);
82771 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
82772 index f4871e5..8ef5741 100644
82773 --- a/kernel/rcutorture.c
82774 +++ b/kernel/rcutorture.c
82775 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
82776 { 0 };
82777 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
82778 { 0 };
82779 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82780 -static atomic_t n_rcu_torture_alloc;
82781 -static atomic_t n_rcu_torture_alloc_fail;
82782 -static atomic_t n_rcu_torture_free;
82783 -static atomic_t n_rcu_torture_mberror;
82784 -static atomic_t n_rcu_torture_error;
82785 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82786 +static atomic_unchecked_t n_rcu_torture_alloc;
82787 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
82788 +static atomic_unchecked_t n_rcu_torture_free;
82789 +static atomic_unchecked_t n_rcu_torture_mberror;
82790 +static atomic_unchecked_t n_rcu_torture_error;
82791 static long n_rcu_torture_barrier_error;
82792 static long n_rcu_torture_boost_ktrerror;
82793 static long n_rcu_torture_boost_rterror;
82794 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
82795
82796 spin_lock_bh(&rcu_torture_lock);
82797 if (list_empty(&rcu_torture_freelist)) {
82798 - atomic_inc(&n_rcu_torture_alloc_fail);
82799 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
82800 spin_unlock_bh(&rcu_torture_lock);
82801 return NULL;
82802 }
82803 - atomic_inc(&n_rcu_torture_alloc);
82804 + atomic_inc_unchecked(&n_rcu_torture_alloc);
82805 p = rcu_torture_freelist.next;
82806 list_del_init(p);
82807 spin_unlock_bh(&rcu_torture_lock);
82808 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
82809 static void
82810 rcu_torture_free(struct rcu_torture *p)
82811 {
82812 - atomic_inc(&n_rcu_torture_free);
82813 + atomic_inc_unchecked(&n_rcu_torture_free);
82814 spin_lock_bh(&rcu_torture_lock);
82815 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
82816 spin_unlock_bh(&rcu_torture_lock);
82817 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
82818 i = rp->rtort_pipe_count;
82819 if (i > RCU_TORTURE_PIPE_LEN)
82820 i = RCU_TORTURE_PIPE_LEN;
82821 - atomic_inc(&rcu_torture_wcount[i]);
82822 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82823 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82824 rp->rtort_mbtest = 0;
82825 rcu_torture_free(rp);
82826 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
82827 i = rp->rtort_pipe_count;
82828 if (i > RCU_TORTURE_PIPE_LEN)
82829 i = RCU_TORTURE_PIPE_LEN;
82830 - atomic_inc(&rcu_torture_wcount[i]);
82831 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82832 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82833 rp->rtort_mbtest = 0;
82834 list_del(&rp->rtort_free);
82835 @@ -952,7 +952,7 @@ rcu_torture_writer(void *arg)
82836 i = old_rp->rtort_pipe_count;
82837 if (i > RCU_TORTURE_PIPE_LEN)
82838 i = RCU_TORTURE_PIPE_LEN;
82839 - atomic_inc(&rcu_torture_wcount[i]);
82840 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82841 old_rp->rtort_pipe_count++;
82842 cur_ops->deferred_free(old_rp);
82843 }
82844 @@ -1038,7 +1038,7 @@ static void rcu_torture_timer(unsigned long unused)
82845 return;
82846 }
82847 if (p->rtort_mbtest == 0)
82848 - atomic_inc(&n_rcu_torture_mberror);
82849 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82850 spin_lock(&rand_lock);
82851 cur_ops->read_delay(&rand);
82852 n_rcu_torture_timers++;
82853 @@ -1108,7 +1108,7 @@ rcu_torture_reader(void *arg)
82854 continue;
82855 }
82856 if (p->rtort_mbtest == 0)
82857 - atomic_inc(&n_rcu_torture_mberror);
82858 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82859 cur_ops->read_delay(&rand);
82860 preempt_disable();
82861 pipe_count = p->rtort_pipe_count;
82862 @@ -1171,11 +1171,11 @@ rcu_torture_printk(char *page)
82863 rcu_torture_current,
82864 rcu_torture_current_version,
82865 list_empty(&rcu_torture_freelist),
82866 - atomic_read(&n_rcu_torture_alloc),
82867 - atomic_read(&n_rcu_torture_alloc_fail),
82868 - atomic_read(&n_rcu_torture_free));
82869 + atomic_read_unchecked(&n_rcu_torture_alloc),
82870 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
82871 + atomic_read_unchecked(&n_rcu_torture_free));
82872 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
82873 - atomic_read(&n_rcu_torture_mberror),
82874 + atomic_read_unchecked(&n_rcu_torture_mberror),
82875 n_rcu_torture_boost_ktrerror,
82876 n_rcu_torture_boost_rterror);
82877 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
82878 @@ -1194,14 +1194,14 @@ rcu_torture_printk(char *page)
82879 n_barrier_attempts,
82880 n_rcu_torture_barrier_error);
82881 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
82882 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
82883 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
82884 n_rcu_torture_barrier_error != 0 ||
82885 n_rcu_torture_boost_ktrerror != 0 ||
82886 n_rcu_torture_boost_rterror != 0 ||
82887 n_rcu_torture_boost_failure != 0 ||
82888 i > 1) {
82889 cnt += sprintf(&page[cnt], "!!! ");
82890 - atomic_inc(&n_rcu_torture_error);
82891 + atomic_inc_unchecked(&n_rcu_torture_error);
82892 WARN_ON_ONCE(1);
82893 }
82894 cnt += sprintf(&page[cnt], "Reader Pipe: ");
82895 @@ -1215,7 +1215,7 @@ rcu_torture_printk(char *page)
82896 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
82897 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82898 cnt += sprintf(&page[cnt], " %d",
82899 - atomic_read(&rcu_torture_wcount[i]));
82900 + atomic_read_unchecked(&rcu_torture_wcount[i]));
82901 }
82902 cnt += sprintf(&page[cnt], "\n");
82903 if (cur_ops->stats)
82904 @@ -1924,7 +1924,7 @@ rcu_torture_cleanup(void)
82905
82906 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
82907
82908 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82909 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82910 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
82911 else if (n_online_successes != n_online_attempts ||
82912 n_offline_successes != n_offline_attempts)
82913 @@ -1992,18 +1992,18 @@ rcu_torture_init(void)
82914
82915 rcu_torture_current = NULL;
82916 rcu_torture_current_version = 0;
82917 - atomic_set(&n_rcu_torture_alloc, 0);
82918 - atomic_set(&n_rcu_torture_alloc_fail, 0);
82919 - atomic_set(&n_rcu_torture_free, 0);
82920 - atomic_set(&n_rcu_torture_mberror, 0);
82921 - atomic_set(&n_rcu_torture_error, 0);
82922 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
82923 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
82924 + atomic_set_unchecked(&n_rcu_torture_free, 0);
82925 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
82926 + atomic_set_unchecked(&n_rcu_torture_error, 0);
82927 n_rcu_torture_barrier_error = 0;
82928 n_rcu_torture_boost_ktrerror = 0;
82929 n_rcu_torture_boost_rterror = 0;
82930 n_rcu_torture_boost_failure = 0;
82931 n_rcu_torture_boosts = 0;
82932 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
82933 - atomic_set(&rcu_torture_wcount[i], 0);
82934 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
82935 for_each_possible_cpu(cpu) {
82936 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82937 per_cpu(rcu_torture_count, cpu)[i] = 0;
82938 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
82939 index 068de3a..5e7db2f 100644
82940 --- a/kernel/rcutree.c
82941 +++ b/kernel/rcutree.c
82942 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
82943 rcu_prepare_for_idle(smp_processor_id());
82944 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82945 smp_mb__before_atomic_inc(); /* See above. */
82946 - atomic_inc(&rdtp->dynticks);
82947 + atomic_inc_unchecked(&rdtp->dynticks);
82948 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
82949 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82950 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82951
82952 /*
82953 * It is illegal to enter an extended quiescent state while
82954 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
82955 int user)
82956 {
82957 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
82958 - atomic_inc(&rdtp->dynticks);
82959 + atomic_inc_unchecked(&rdtp->dynticks);
82960 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82961 smp_mb__after_atomic_inc(); /* See above. */
82962 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82963 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82964 rcu_cleanup_after_idle(smp_processor_id());
82965 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
82966 if (!user && !is_idle_task(current)) {
82967 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
82968 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
82969
82970 if (rdtp->dynticks_nmi_nesting == 0 &&
82971 - (atomic_read(&rdtp->dynticks) & 0x1))
82972 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
82973 return;
82974 rdtp->dynticks_nmi_nesting++;
82975 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
82976 - atomic_inc(&rdtp->dynticks);
82977 + atomic_inc_unchecked(&rdtp->dynticks);
82978 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82979 smp_mb__after_atomic_inc(); /* See above. */
82980 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82981 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82982 }
82983
82984 /**
82985 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
82986 return;
82987 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82988 smp_mb__before_atomic_inc(); /* See above. */
82989 - atomic_inc(&rdtp->dynticks);
82990 + atomic_inc_unchecked(&rdtp->dynticks);
82991 smp_mb__after_atomic_inc(); /* Force delay to next write. */
82992 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82993 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82994 }
82995
82996 /**
82997 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
82998 int ret;
82999
83000 preempt_disable();
83001 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83002 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83003 preempt_enable();
83004 return ret;
83005 }
83006 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
83007 */
83008 static int dyntick_save_progress_counter(struct rcu_data *rdp)
83009 {
83010 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
83011 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83012 return (rdp->dynticks_snap & 0x1) == 0;
83013 }
83014
83015 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
83016 unsigned int curr;
83017 unsigned int snap;
83018
83019 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
83020 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83021 snap = (unsigned int)rdp->dynticks_snap;
83022
83023 /*
83024 @@ -1351,9 +1351,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
83025 rdp = this_cpu_ptr(rsp->rda);
83026 rcu_preempt_check_blocked_tasks(rnp);
83027 rnp->qsmask = rnp->qsmaskinit;
83028 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
83029 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
83030 WARN_ON_ONCE(rnp->completed != rsp->completed);
83031 - ACCESS_ONCE(rnp->completed) = rsp->completed;
83032 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
83033 if (rnp == rdp->mynode)
83034 __note_gp_changes(rsp, rnp, rdp);
83035 rcu_preempt_boost_start_gp(rnp);
83036 @@ -1435,7 +1435,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
83037 */
83038 rcu_for_each_node_breadth_first(rsp, rnp) {
83039 raw_spin_lock_irq(&rnp->lock);
83040 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
83041 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
83042 rdp = this_cpu_ptr(rsp->rda);
83043 if (rnp == rdp->mynode)
83044 __note_gp_changes(rsp, rnp, rdp);
83045 @@ -1765,7 +1765,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
83046 rsp->qlen += rdp->qlen;
83047 rdp->n_cbs_orphaned += rdp->qlen;
83048 rdp->qlen_lazy = 0;
83049 - ACCESS_ONCE(rdp->qlen) = 0;
83050 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83051 }
83052
83053 /*
83054 @@ -2011,7 +2011,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
83055 }
83056 smp_mb(); /* List handling before counting for rcu_barrier(). */
83057 rdp->qlen_lazy -= count_lazy;
83058 - ACCESS_ONCE(rdp->qlen) -= count;
83059 + ACCESS_ONCE_RW(rdp->qlen) -= count;
83060 rdp->n_cbs_invoked += count;
83061
83062 /* Reinstate batch limit if we have worked down the excess. */
83063 @@ -2202,7 +2202,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
83064 /*
83065 * Do RCU core processing for the current CPU.
83066 */
83067 -static void rcu_process_callbacks(struct softirq_action *unused)
83068 +static __latent_entropy void rcu_process_callbacks(void)
83069 {
83070 struct rcu_state *rsp;
83071
83072 @@ -2325,7 +2325,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
83073 local_irq_restore(flags);
83074 return;
83075 }
83076 - ACCESS_ONCE(rdp->qlen)++;
83077 + ACCESS_ONCE_RW(rdp->qlen)++;
83078 if (lazy)
83079 rdp->qlen_lazy++;
83080 else
83081 @@ -2534,11 +2534,11 @@ void synchronize_sched_expedited(void)
83082 * counter wrap on a 32-bit system. Quite a few more CPUs would of
83083 * course be required on a 64-bit system.
83084 */
83085 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
83086 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
83087 (ulong)atomic_long_read(&rsp->expedited_done) +
83088 ULONG_MAX / 8)) {
83089 synchronize_sched();
83090 - atomic_long_inc(&rsp->expedited_wrap);
83091 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
83092 return;
83093 }
83094
83095 @@ -2546,7 +2546,7 @@ void synchronize_sched_expedited(void)
83096 * Take a ticket. Note that atomic_inc_return() implies a
83097 * full memory barrier.
83098 */
83099 - snap = atomic_long_inc_return(&rsp->expedited_start);
83100 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
83101 firstsnap = snap;
83102 get_online_cpus();
83103 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
83104 @@ -2559,14 +2559,14 @@ void synchronize_sched_expedited(void)
83105 synchronize_sched_expedited_cpu_stop,
83106 NULL) == -EAGAIN) {
83107 put_online_cpus();
83108 - atomic_long_inc(&rsp->expedited_tryfail);
83109 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
83110
83111 /* Check to see if someone else did our work for us. */
83112 s = atomic_long_read(&rsp->expedited_done);
83113 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83114 /* ensure test happens before caller kfree */
83115 smp_mb__before_atomic_inc(); /* ^^^ */
83116 - atomic_long_inc(&rsp->expedited_workdone1);
83117 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
83118 return;
83119 }
83120
83121 @@ -2575,7 +2575,7 @@ void synchronize_sched_expedited(void)
83122 udelay(trycount * num_online_cpus());
83123 } else {
83124 wait_rcu_gp(call_rcu_sched);
83125 - atomic_long_inc(&rsp->expedited_normal);
83126 + atomic_long_inc_unchecked(&rsp->expedited_normal);
83127 return;
83128 }
83129
83130 @@ -2584,7 +2584,7 @@ void synchronize_sched_expedited(void)
83131 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83132 /* ensure test happens before caller kfree */
83133 smp_mb__before_atomic_inc(); /* ^^^ */
83134 - atomic_long_inc(&rsp->expedited_workdone2);
83135 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
83136 return;
83137 }
83138
83139 @@ -2596,10 +2596,10 @@ void synchronize_sched_expedited(void)
83140 * period works for us.
83141 */
83142 get_online_cpus();
83143 - snap = atomic_long_read(&rsp->expedited_start);
83144 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
83145 smp_mb(); /* ensure read is before try_stop_cpus(). */
83146 }
83147 - atomic_long_inc(&rsp->expedited_stoppedcpus);
83148 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
83149
83150 /*
83151 * Everyone up to our most recent fetch is covered by our grace
83152 @@ -2608,16 +2608,16 @@ void synchronize_sched_expedited(void)
83153 * than we did already did their update.
83154 */
83155 do {
83156 - atomic_long_inc(&rsp->expedited_done_tries);
83157 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
83158 s = atomic_long_read(&rsp->expedited_done);
83159 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
83160 /* ensure test happens before caller kfree */
83161 smp_mb__before_atomic_inc(); /* ^^^ */
83162 - atomic_long_inc(&rsp->expedited_done_lost);
83163 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
83164 break;
83165 }
83166 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
83167 - atomic_long_inc(&rsp->expedited_done_exit);
83168 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
83169
83170 put_online_cpus();
83171 }
83172 @@ -2799,7 +2799,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83173 * ACCESS_ONCE() to prevent the compiler from speculating
83174 * the increment to precede the early-exit check.
83175 */
83176 - ACCESS_ONCE(rsp->n_barrier_done)++;
83177 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83178 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
83179 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
83180 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
83181 @@ -2849,7 +2849,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83182
83183 /* Increment ->n_barrier_done to prevent duplicate work. */
83184 smp_mb(); /* Keep increment after above mechanism. */
83185 - ACCESS_ONCE(rsp->n_barrier_done)++;
83186 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83187 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
83188 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
83189 smp_mb(); /* Keep increment before caller's subsequent code. */
83190 @@ -2894,10 +2894,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
83191 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
83192 init_callback_list(rdp);
83193 rdp->qlen_lazy = 0;
83194 - ACCESS_ONCE(rdp->qlen) = 0;
83195 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83196 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
83197 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
83198 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
83199 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
83200 rdp->cpu = cpu;
83201 rdp->rsp = rsp;
83202 rcu_boot_init_nocb_percpu_data(rdp);
83203 @@ -2930,8 +2930,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
83204 rdp->blimit = blimit;
83205 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
83206 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
83207 - atomic_set(&rdp->dynticks->dynticks,
83208 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
83209 + atomic_set_unchecked(&rdp->dynticks->dynticks,
83210 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
83211 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
83212
83213 /* Add CPU to rcu_node bitmasks. */
83214 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
83215 index b383258..2440c1e 100644
83216 --- a/kernel/rcutree.h
83217 +++ b/kernel/rcutree.h
83218 @@ -87,7 +87,7 @@ struct rcu_dynticks {
83219 long long dynticks_nesting; /* Track irq/process nesting level. */
83220 /* Process level is worth LLONG_MAX/2. */
83221 int dynticks_nmi_nesting; /* Track NMI nesting level. */
83222 - atomic_t dynticks; /* Even value for idle, else odd. */
83223 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
83224 #ifdef CONFIG_RCU_FAST_NO_HZ
83225 bool all_lazy; /* Are all CPU's CBs lazy? */
83226 unsigned long nonlazy_posted;
83227 @@ -419,17 +419,17 @@ struct rcu_state {
83228 /* _rcu_barrier(). */
83229 /* End of fields guarded by barrier_mutex. */
83230
83231 - atomic_long_t expedited_start; /* Starting ticket. */
83232 - atomic_long_t expedited_done; /* Done ticket. */
83233 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
83234 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
83235 - atomic_long_t expedited_workdone1; /* # done by others #1. */
83236 - atomic_long_t expedited_workdone2; /* # done by others #2. */
83237 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
83238 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
83239 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
83240 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
83241 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
83242 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
83243 + atomic_long_t expedited_done; /* Done ticket. */
83244 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
83245 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
83246 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
83247 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
83248 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
83249 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
83250 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
83251 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
83252 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
83253
83254 unsigned long jiffies_force_qs; /* Time at which to invoke */
83255 /* force_quiescent_state(). */
83256 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
83257 index 769e12e..7b2139b 100644
83258 --- a/kernel/rcutree_plugin.h
83259 +++ b/kernel/rcutree_plugin.h
83260 @@ -902,7 +902,7 @@ void synchronize_rcu_expedited(void)
83261
83262 /* Clean up and exit. */
83263 smp_mb(); /* ensure expedited GP seen before counter increment. */
83264 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
83265 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
83266 unlock_mb_ret:
83267 mutex_unlock(&sync_rcu_preempt_exp_mutex);
83268 mb_ret:
83269 @@ -1476,7 +1476,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
83270 free_cpumask_var(cm);
83271 }
83272
83273 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
83274 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
83275 .store = &rcu_cpu_kthread_task,
83276 .thread_should_run = rcu_cpu_kthread_should_run,
83277 .thread_fn = rcu_cpu_kthread,
83278 @@ -1941,7 +1941,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
83279 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
83280 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
83281 cpu, ticks_value, ticks_title,
83282 - atomic_read(&rdtp->dynticks) & 0xfff,
83283 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
83284 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
83285 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
83286 fast_no_hz);
83287 @@ -2104,7 +2104,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
83288
83289 /* Enqueue the callback on the nocb list and update counts. */
83290 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
83291 - ACCESS_ONCE(*old_rhpp) = rhp;
83292 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
83293 atomic_long_add(rhcount, &rdp->nocb_q_count);
83294 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
83295
83296 @@ -2244,12 +2244,12 @@ static int rcu_nocb_kthread(void *arg)
83297 * Extract queued callbacks, update counts, and wait
83298 * for a grace period to elapse.
83299 */
83300 - ACCESS_ONCE(rdp->nocb_head) = NULL;
83301 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
83302 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
83303 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
83304 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
83305 - ACCESS_ONCE(rdp->nocb_p_count) += c;
83306 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
83307 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
83308 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
83309 rcu_nocb_wait_gp(rdp);
83310
83311 /* Each pass through the following loop invokes a callback. */
83312 @@ -2271,8 +2271,8 @@ static int rcu_nocb_kthread(void *arg)
83313 list = next;
83314 }
83315 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
83316 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
83317 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
83318 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
83319 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
83320 rdp->n_nocbs_invoked += c;
83321 }
83322 return 0;
83323 @@ -2299,7 +2299,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
83324 t = kthread_run(rcu_nocb_kthread, rdp,
83325 "rcuo%c/%d", rsp->abbr, cpu);
83326 BUG_ON(IS_ERR(t));
83327 - ACCESS_ONCE(rdp->nocb_kthread) = t;
83328 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
83329 }
83330 }
83331
83332 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
83333 index cf6c174..a8f4b50 100644
83334 --- a/kernel/rcutree_trace.c
83335 +++ b/kernel/rcutree_trace.c
83336 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
83337 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
83338 rdp->passed_quiesce, rdp->qs_pending);
83339 seq_printf(m, " dt=%d/%llx/%d df=%lu",
83340 - atomic_read(&rdp->dynticks->dynticks),
83341 + atomic_read_unchecked(&rdp->dynticks->dynticks),
83342 rdp->dynticks->dynticks_nesting,
83343 rdp->dynticks->dynticks_nmi_nesting,
83344 rdp->dynticks_fqs);
83345 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
83346 struct rcu_state *rsp = (struct rcu_state *)m->private;
83347
83348 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",
83349 - atomic_long_read(&rsp->expedited_start),
83350 + atomic_long_read_unchecked(&rsp->expedited_start),
83351 atomic_long_read(&rsp->expedited_done),
83352 - atomic_long_read(&rsp->expedited_wrap),
83353 - atomic_long_read(&rsp->expedited_tryfail),
83354 - atomic_long_read(&rsp->expedited_workdone1),
83355 - atomic_long_read(&rsp->expedited_workdone2),
83356 - atomic_long_read(&rsp->expedited_normal),
83357 - atomic_long_read(&rsp->expedited_stoppedcpus),
83358 - atomic_long_read(&rsp->expedited_done_tries),
83359 - atomic_long_read(&rsp->expedited_done_lost),
83360 - atomic_long_read(&rsp->expedited_done_exit));
83361 + atomic_long_read_unchecked(&rsp->expedited_wrap),
83362 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
83363 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
83364 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
83365 + atomic_long_read_unchecked(&rsp->expedited_normal),
83366 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
83367 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
83368 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
83369 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
83370 return 0;
83371 }
83372
83373 diff --git a/kernel/resource.c b/kernel/resource.c
83374 index 3f285dc..5755f62 100644
83375 --- a/kernel/resource.c
83376 +++ b/kernel/resource.c
83377 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
83378
83379 static int __init ioresources_init(void)
83380 {
83381 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
83382 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83383 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
83384 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
83385 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83386 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
83387 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
83388 +#endif
83389 +#else
83390 proc_create("ioports", 0, NULL, &proc_ioports_operations);
83391 proc_create("iomem", 0, NULL, &proc_iomem_operations);
83392 +#endif
83393 return 0;
83394 }
83395 __initcall(ioresources_init);
83396 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
83397 index 1d96dd0..994ff19 100644
83398 --- a/kernel/rtmutex-tester.c
83399 +++ b/kernel/rtmutex-tester.c
83400 @@ -22,7 +22,7 @@
83401 #define MAX_RT_TEST_MUTEXES 8
83402
83403 static spinlock_t rttest_lock;
83404 -static atomic_t rttest_event;
83405 +static atomic_unchecked_t rttest_event;
83406
83407 struct test_thread_data {
83408 int opcode;
83409 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83410
83411 case RTTEST_LOCKCONT:
83412 td->mutexes[td->opdata] = 1;
83413 - td->event = atomic_add_return(1, &rttest_event);
83414 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83415 return 0;
83416
83417 case RTTEST_RESET:
83418 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83419 return 0;
83420
83421 case RTTEST_RESETEVENT:
83422 - atomic_set(&rttest_event, 0);
83423 + atomic_set_unchecked(&rttest_event, 0);
83424 return 0;
83425
83426 default:
83427 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83428 return ret;
83429
83430 td->mutexes[id] = 1;
83431 - td->event = atomic_add_return(1, &rttest_event);
83432 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83433 rt_mutex_lock(&mutexes[id]);
83434 - td->event = atomic_add_return(1, &rttest_event);
83435 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83436 td->mutexes[id] = 4;
83437 return 0;
83438
83439 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83440 return ret;
83441
83442 td->mutexes[id] = 1;
83443 - td->event = atomic_add_return(1, &rttest_event);
83444 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83445 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
83446 - td->event = atomic_add_return(1, &rttest_event);
83447 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83448 td->mutexes[id] = ret ? 0 : 4;
83449 return ret ? -EINTR : 0;
83450
83451 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83452 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
83453 return ret;
83454
83455 - td->event = atomic_add_return(1, &rttest_event);
83456 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83457 rt_mutex_unlock(&mutexes[id]);
83458 - td->event = atomic_add_return(1, &rttest_event);
83459 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83460 td->mutexes[id] = 0;
83461 return 0;
83462
83463 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83464 break;
83465
83466 td->mutexes[dat] = 2;
83467 - td->event = atomic_add_return(1, &rttest_event);
83468 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83469 break;
83470
83471 default:
83472 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83473 return;
83474
83475 td->mutexes[dat] = 3;
83476 - td->event = atomic_add_return(1, &rttest_event);
83477 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83478 break;
83479
83480 case RTTEST_LOCKNOWAIT:
83481 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83482 return;
83483
83484 td->mutexes[dat] = 1;
83485 - td->event = atomic_add_return(1, &rttest_event);
83486 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83487 return;
83488
83489 default:
83490 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
83491 index 4a07353..66b5291 100644
83492 --- a/kernel/sched/auto_group.c
83493 +++ b/kernel/sched/auto_group.c
83494 @@ -11,7 +11,7 @@
83495
83496 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
83497 static struct autogroup autogroup_default;
83498 -static atomic_t autogroup_seq_nr;
83499 +static atomic_unchecked_t autogroup_seq_nr;
83500
83501 void __init autogroup_init(struct task_struct *init_task)
83502 {
83503 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
83504
83505 kref_init(&ag->kref);
83506 init_rwsem(&ag->lock);
83507 - ag->id = atomic_inc_return(&autogroup_seq_nr);
83508 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
83509 ag->tg = tg;
83510 #ifdef CONFIG_RT_GROUP_SCHED
83511 /*
83512 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
83513 index 05c39f0..442e6fe 100644
83514 --- a/kernel/sched/core.c
83515 +++ b/kernel/sched/core.c
83516 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
83517 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83518 * or number of jiffies left till timeout) if completed.
83519 */
83520 -long __sched
83521 +long __sched __intentional_overflow(-1)
83522 wait_for_completion_interruptible_timeout(struct completion *x,
83523 unsigned long timeout)
83524 {
83525 @@ -2902,7 +2902,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
83526 *
83527 * Return: -ERESTARTSYS if interrupted, 0 if completed.
83528 */
83529 -int __sched wait_for_completion_killable(struct completion *x)
83530 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
83531 {
83532 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
83533 if (t == -ERESTARTSYS)
83534 @@ -2923,7 +2923,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
83535 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83536 * or number of jiffies left till timeout) if completed.
83537 */
83538 -long __sched
83539 +long __sched __intentional_overflow(-1)
83540 wait_for_completion_killable_timeout(struct completion *x,
83541 unsigned long timeout)
83542 {
83543 @@ -3149,6 +3149,8 @@ int can_nice(const struct task_struct *p, const int nice)
83544 /* convert nice value [19,-20] to rlimit style value [1,40] */
83545 int nice_rlim = 20 - nice;
83546
83547 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
83548 +
83549 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
83550 capable(CAP_SYS_NICE));
83551 }
83552 @@ -3182,7 +3184,8 @@ SYSCALL_DEFINE1(nice, int, increment)
83553 if (nice > 19)
83554 nice = 19;
83555
83556 - if (increment < 0 && !can_nice(current, nice))
83557 + if (increment < 0 && (!can_nice(current, nice) ||
83558 + gr_handle_chroot_nice()))
83559 return -EPERM;
83560
83561 retval = security_task_setnice(current, nice);
83562 @@ -3344,6 +3347,7 @@ recheck:
83563 unsigned long rlim_rtprio =
83564 task_rlimit(p, RLIMIT_RTPRIO);
83565
83566 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
83567 /* can't set/change the rt policy */
83568 if (policy != p->policy && !rlim_rtprio)
83569 return -EPERM;
83570 @@ -4473,7 +4477,7 @@ static void migrate_tasks(unsigned int dead_cpu)
83571
83572 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
83573
83574 -static struct ctl_table sd_ctl_dir[] = {
83575 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
83576 {
83577 .procname = "sched_domain",
83578 .mode = 0555,
83579 @@ -4490,17 +4494,17 @@ static struct ctl_table sd_ctl_root[] = {
83580 {}
83581 };
83582
83583 -static struct ctl_table *sd_alloc_ctl_entry(int n)
83584 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
83585 {
83586 - struct ctl_table *entry =
83587 + ctl_table_no_const *entry =
83588 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
83589
83590 return entry;
83591 }
83592
83593 -static void sd_free_ctl_entry(struct ctl_table **tablep)
83594 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
83595 {
83596 - struct ctl_table *entry;
83597 + ctl_table_no_const *entry;
83598
83599 /*
83600 * In the intermediate directories, both the child directory and
83601 @@ -4508,22 +4512,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
83602 * will always be set. In the lowest directory the names are
83603 * static strings and all have proc handlers.
83604 */
83605 - for (entry = *tablep; entry->mode; entry++) {
83606 - if (entry->child)
83607 - sd_free_ctl_entry(&entry->child);
83608 + for (entry = tablep; entry->mode; entry++) {
83609 + if (entry->child) {
83610 + sd_free_ctl_entry(entry->child);
83611 + pax_open_kernel();
83612 + entry->child = NULL;
83613 + pax_close_kernel();
83614 + }
83615 if (entry->proc_handler == NULL)
83616 kfree(entry->procname);
83617 }
83618
83619 - kfree(*tablep);
83620 - *tablep = NULL;
83621 + kfree(tablep);
83622 }
83623
83624 static int min_load_idx = 0;
83625 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
83626
83627 static void
83628 -set_table_entry(struct ctl_table *entry,
83629 +set_table_entry(ctl_table_no_const *entry,
83630 const char *procname, void *data, int maxlen,
83631 umode_t mode, proc_handler *proc_handler,
83632 bool load_idx)
83633 @@ -4543,7 +4550,7 @@ set_table_entry(struct ctl_table *entry,
83634 static struct ctl_table *
83635 sd_alloc_ctl_domain_table(struct sched_domain *sd)
83636 {
83637 - struct ctl_table *table = sd_alloc_ctl_entry(13);
83638 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
83639
83640 if (table == NULL)
83641 return NULL;
83642 @@ -4578,9 +4585,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
83643 return table;
83644 }
83645
83646 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
83647 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
83648 {
83649 - struct ctl_table *entry, *table;
83650 + ctl_table_no_const *entry, *table;
83651 struct sched_domain *sd;
83652 int domain_num = 0, i;
83653 char buf[32];
83654 @@ -4607,11 +4614,13 @@ static struct ctl_table_header *sd_sysctl_header;
83655 static void register_sched_domain_sysctl(void)
83656 {
83657 int i, cpu_num = num_possible_cpus();
83658 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
83659 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
83660 char buf[32];
83661
83662 WARN_ON(sd_ctl_dir[0].child);
83663 + pax_open_kernel();
83664 sd_ctl_dir[0].child = entry;
83665 + pax_close_kernel();
83666
83667 if (entry == NULL)
83668 return;
83669 @@ -4634,8 +4643,12 @@ static void unregister_sched_domain_sysctl(void)
83670 if (sd_sysctl_header)
83671 unregister_sysctl_table(sd_sysctl_header);
83672 sd_sysctl_header = NULL;
83673 - if (sd_ctl_dir[0].child)
83674 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
83675 + if (sd_ctl_dir[0].child) {
83676 + sd_free_ctl_entry(sd_ctl_dir[0].child);
83677 + pax_open_kernel();
83678 + sd_ctl_dir[0].child = NULL;
83679 + pax_close_kernel();
83680 + }
83681 }
83682 #else
83683 static void register_sched_domain_sysctl(void)
83684 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
83685 index 31cbc15..ba68c15 100644
83686 --- a/kernel/sched/fair.c
83687 +++ b/kernel/sched/fair.c
83688 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
83689
83690 static void reset_ptenuma_scan(struct task_struct *p)
83691 {
83692 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
83693 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
83694 p->mm->numa_scan_offset = 0;
83695 }
83696
83697 @@ -5727,7 +5727,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
83698 * run_rebalance_domains is triggered when needed from the scheduler tick.
83699 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
83700 */
83701 -static void run_rebalance_domains(struct softirq_action *h)
83702 +static __latent_entropy void run_rebalance_domains(void)
83703 {
83704 int this_cpu = smp_processor_id();
83705 struct rq *this_rq = cpu_rq(this_cpu);
83706 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
83707 index ef0a7b2..1b728c1 100644
83708 --- a/kernel/sched/sched.h
83709 +++ b/kernel/sched/sched.h
83710 @@ -1004,7 +1004,7 @@ struct sched_class {
83711 #ifdef CONFIG_FAIR_GROUP_SCHED
83712 void (*task_move_group) (struct task_struct *p, int on_rq);
83713 #endif
83714 -};
83715 +} __do_const;
83716
83717 #define sched_class_highest (&stop_sched_class)
83718 #define for_each_class(class) \
83719 diff --git a/kernel/signal.c b/kernel/signal.c
83720 index 50e4107..9409983 100644
83721 --- a/kernel/signal.c
83722 +++ b/kernel/signal.c
83723 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
83724
83725 int print_fatal_signals __read_mostly;
83726
83727 -static void __user *sig_handler(struct task_struct *t, int sig)
83728 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
83729 {
83730 return t->sighand->action[sig - 1].sa.sa_handler;
83731 }
83732
83733 -static int sig_handler_ignored(void __user *handler, int sig)
83734 +static int sig_handler_ignored(__sighandler_t handler, int sig)
83735 {
83736 /* Is it explicitly or implicitly ignored? */
83737 return handler == SIG_IGN ||
83738 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
83739
83740 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
83741 {
83742 - void __user *handler;
83743 + __sighandler_t handler;
83744
83745 handler = sig_handler(t, sig);
83746
83747 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
83748 atomic_inc(&user->sigpending);
83749 rcu_read_unlock();
83750
83751 + if (!override_rlimit)
83752 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
83753 +
83754 if (override_rlimit ||
83755 atomic_read(&user->sigpending) <=
83756 task_rlimit(t, RLIMIT_SIGPENDING)) {
83757 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
83758
83759 int unhandled_signal(struct task_struct *tsk, int sig)
83760 {
83761 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
83762 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
83763 if (is_global_init(tsk))
83764 return 1;
83765 if (handler != SIG_IGN && handler != SIG_DFL)
83766 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
83767 }
83768 }
83769
83770 + /* allow glibc communication via tgkill to other threads in our
83771 + thread group */
83772 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
83773 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
83774 + && gr_handle_signal(t, sig))
83775 + return -EPERM;
83776 +
83777 return security_task_kill(t, info, sig, 0);
83778 }
83779
83780 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83781 return send_signal(sig, info, p, 1);
83782 }
83783
83784 -static int
83785 +int
83786 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83787 {
83788 return send_signal(sig, info, t, 0);
83789 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83790 unsigned long int flags;
83791 int ret, blocked, ignored;
83792 struct k_sigaction *action;
83793 + int is_unhandled = 0;
83794
83795 spin_lock_irqsave(&t->sighand->siglock, flags);
83796 action = &t->sighand->action[sig-1];
83797 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83798 }
83799 if (action->sa.sa_handler == SIG_DFL)
83800 t->signal->flags &= ~SIGNAL_UNKILLABLE;
83801 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
83802 + is_unhandled = 1;
83803 ret = specific_send_sig_info(sig, info, t);
83804 spin_unlock_irqrestore(&t->sighand->siglock, flags);
83805
83806 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
83807 + normal operation */
83808 + if (is_unhandled) {
83809 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
83810 + gr_handle_crash(t, sig);
83811 + }
83812 +
83813 return ret;
83814 }
83815
83816 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83817 ret = check_kill_permission(sig, info, p);
83818 rcu_read_unlock();
83819
83820 - if (!ret && sig)
83821 + if (!ret && sig) {
83822 ret = do_send_sig_info(sig, info, p, true);
83823 + if (!ret)
83824 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
83825 + }
83826
83827 return ret;
83828 }
83829 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
83830 int error = -ESRCH;
83831
83832 rcu_read_lock();
83833 - p = find_task_by_vpid(pid);
83834 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
83835 + /* allow glibc communication via tgkill to other threads in our
83836 + thread group */
83837 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
83838 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
83839 + p = find_task_by_vpid_unrestricted(pid);
83840 + else
83841 +#endif
83842 + p = find_task_by_vpid(pid);
83843 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
83844 error = check_kill_permission(sig, info, p);
83845 /*
83846 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
83847 }
83848 seg = get_fs();
83849 set_fs(KERNEL_DS);
83850 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
83851 - (stack_t __force __user *) &uoss,
83852 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
83853 + (stack_t __force_user *) &uoss,
83854 compat_user_stack_pointer());
83855 set_fs(seg);
83856 if (ret >= 0 && uoss_ptr) {
83857 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
83858 index eb89e18..a4e6792 100644
83859 --- a/kernel/smpboot.c
83860 +++ b/kernel/smpboot.c
83861 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
83862 }
83863 smpboot_unpark_thread(plug_thread, cpu);
83864 }
83865 - list_add(&plug_thread->list, &hotplug_threads);
83866 + pax_list_add(&plug_thread->list, &hotplug_threads);
83867 out:
83868 mutex_unlock(&smpboot_threads_lock);
83869 return ret;
83870 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
83871 {
83872 get_online_cpus();
83873 mutex_lock(&smpboot_threads_lock);
83874 - list_del(&plug_thread->list);
83875 + pax_list_del(&plug_thread->list);
83876 smpboot_destroy_threads(plug_thread);
83877 mutex_unlock(&smpboot_threads_lock);
83878 put_online_cpus();
83879 diff --git a/kernel/softirq.c b/kernel/softirq.c
83880 index adf6c00..5d89b73 100644
83881 --- a/kernel/softirq.c
83882 +++ b/kernel/softirq.c
83883 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
83884 EXPORT_SYMBOL(irq_stat);
83885 #endif
83886
83887 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
83888 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
83889
83890 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
83891
83892 -char *softirq_to_name[NR_SOFTIRQS] = {
83893 +const char * const softirq_to_name[NR_SOFTIRQS] = {
83894 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
83895 "TASKLET", "SCHED", "HRTIMER", "RCU"
83896 };
83897 @@ -248,7 +248,7 @@ restart:
83898 kstat_incr_softirqs_this_cpu(vec_nr);
83899
83900 trace_softirq_entry(vec_nr);
83901 - h->action(h);
83902 + h->action();
83903 trace_softirq_exit(vec_nr);
83904 if (unlikely(prev_count != preempt_count())) {
83905 printk(KERN_ERR "huh, entered softirq %u %s %p"
83906 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
83907 or_softirq_pending(1UL << nr);
83908 }
83909
83910 -void open_softirq(int nr, void (*action)(struct softirq_action *))
83911 +void __init open_softirq(int nr, void (*action)(void))
83912 {
83913 softirq_vec[nr].action = action;
83914 }
83915 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
83916
83917 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
83918
83919 -static void tasklet_action(struct softirq_action *a)
83920 +static __latent_entropy void tasklet_action(void)
83921 {
83922 struct tasklet_struct *list;
83923
83924 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
83925 }
83926 }
83927
83928 -static void tasklet_hi_action(struct softirq_action *a)
83929 +static __latent_entropy void tasklet_hi_action(void)
83930 {
83931 struct tasklet_struct *list;
83932
83933 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
83934 .notifier_call = cpu_callback
83935 };
83936
83937 -static struct smp_hotplug_thread softirq_threads = {
83938 +static struct smp_hotplug_thread softirq_threads __read_only = {
83939 .store = &ksoftirqd,
83940 .thread_should_run = ksoftirqd_should_run,
83941 .thread_fn = run_ksoftirqd,
83942 diff --git a/kernel/srcu.c b/kernel/srcu.c
83943 index 01d5ccb..cdcbee6 100644
83944 --- a/kernel/srcu.c
83945 +++ b/kernel/srcu.c
83946 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
83947
83948 idx = ACCESS_ONCE(sp->completed) & 0x1;
83949 preempt_disable();
83950 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83951 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83952 smp_mb(); /* B */ /* Avoid leaking the critical section. */
83953 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83954 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83955 preempt_enable();
83956 return idx;
83957 }
83958 diff --git a/kernel/sys.c b/kernel/sys.c
83959 index 771129b..dc0c7e3 100644
83960 --- a/kernel/sys.c
83961 +++ b/kernel/sys.c
83962 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
83963 error = -EACCES;
83964 goto out;
83965 }
83966 +
83967 + if (gr_handle_chroot_setpriority(p, niceval)) {
83968 + error = -EACCES;
83969 + goto out;
83970 + }
83971 +
83972 no_nice = security_task_setnice(p, niceval);
83973 if (no_nice) {
83974 error = no_nice;
83975 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
83976 goto error;
83977 }
83978
83979 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
83980 + goto error;
83981 +
83982 if (rgid != (gid_t) -1 ||
83983 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
83984 new->sgid = new->egid;
83985 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
83986 old = current_cred();
83987
83988 retval = -EPERM;
83989 +
83990 + if (gr_check_group_change(kgid, kgid, kgid))
83991 + goto error;
83992 +
83993 if (nsown_capable(CAP_SETGID))
83994 new->gid = new->egid = new->sgid = new->fsgid = kgid;
83995 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
83996 @@ -404,7 +417,7 @@ error:
83997 /*
83998 * change the user struct in a credentials set to match the new UID
83999 */
84000 -static int set_user(struct cred *new)
84001 +int set_user(struct cred *new)
84002 {
84003 struct user_struct *new_user;
84004
84005 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
84006 goto error;
84007 }
84008
84009 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
84010 + goto error;
84011 +
84012 if (!uid_eq(new->uid, old->uid)) {
84013 retval = set_user(new);
84014 if (retval < 0)
84015 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
84016 old = current_cred();
84017
84018 retval = -EPERM;
84019 +
84020 + if (gr_check_crash_uid(kuid))
84021 + goto error;
84022 + if (gr_check_user_change(kuid, kuid, kuid))
84023 + goto error;
84024 +
84025 if (nsown_capable(CAP_SETUID)) {
84026 new->suid = new->uid = kuid;
84027 if (!uid_eq(kuid, old->uid)) {
84028 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
84029 goto error;
84030 }
84031
84032 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
84033 + goto error;
84034 +
84035 if (ruid != (uid_t) -1) {
84036 new->uid = kruid;
84037 if (!uid_eq(kruid, old->uid)) {
84038 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
84039 goto error;
84040 }
84041
84042 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
84043 + goto error;
84044 +
84045 if (rgid != (gid_t) -1)
84046 new->gid = krgid;
84047 if (egid != (gid_t) -1)
84048 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
84049 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
84050 nsown_capable(CAP_SETUID)) {
84051 if (!uid_eq(kuid, old->fsuid)) {
84052 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
84053 + goto error;
84054 +
84055 new->fsuid = kuid;
84056 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
84057 goto change_okay;
84058 }
84059 }
84060
84061 +error:
84062 abort_creds(new);
84063 return old_fsuid;
84064
84065 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
84066 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
84067 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
84068 nsown_capable(CAP_SETGID)) {
84069 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
84070 + goto error;
84071 +
84072 if (!gid_eq(kgid, old->fsgid)) {
84073 new->fsgid = kgid;
84074 goto change_okay;
84075 }
84076 }
84077
84078 +error:
84079 abort_creds(new);
84080 return old_fsgid;
84081
84082 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
84083 return -EFAULT;
84084
84085 down_read(&uts_sem);
84086 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
84087 + error = __copy_to_user(name->sysname, &utsname()->sysname,
84088 __OLD_UTS_LEN);
84089 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
84090 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
84091 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
84092 __OLD_UTS_LEN);
84093 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
84094 - error |= __copy_to_user(&name->release, &utsname()->release,
84095 + error |= __copy_to_user(name->release, &utsname()->release,
84096 __OLD_UTS_LEN);
84097 error |= __put_user(0, name->release + __OLD_UTS_LEN);
84098 - error |= __copy_to_user(&name->version, &utsname()->version,
84099 + error |= __copy_to_user(name->version, &utsname()->version,
84100 __OLD_UTS_LEN);
84101 error |= __put_user(0, name->version + __OLD_UTS_LEN);
84102 - error |= __copy_to_user(&name->machine, &utsname()->machine,
84103 + error |= __copy_to_user(name->machine, &utsname()->machine,
84104 __OLD_UTS_LEN);
84105 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
84106 up_read(&uts_sem);
84107 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
84108 */
84109 new_rlim->rlim_cur = 1;
84110 }
84111 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
84112 + is changed to a lower value. Since tasks can be created by the same
84113 + user in between this limit change and an execve by this task, force
84114 + a recheck only for this task by setting PF_NPROC_EXCEEDED
84115 + */
84116 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
84117 + tsk->flags |= PF_NPROC_EXCEEDED;
84118 }
84119 if (!retval) {
84120 if (old_rlim)
84121 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
84122 index 07f6fc4..65fb3d4 100644
84123 --- a/kernel/sysctl.c
84124 +++ b/kernel/sysctl.c
84125 @@ -93,7 +93,6 @@
84126
84127
84128 #if defined(CONFIG_SYSCTL)
84129 -
84130 /* External variables not in a header file. */
84131 extern int sysctl_overcommit_memory;
84132 extern int sysctl_overcommit_ratio;
84133 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
84134
84135 /* Constants used for minimum and maximum */
84136 #ifdef CONFIG_LOCKUP_DETECTOR
84137 -static int sixty = 60;
84138 +static int sixty __read_only = 60;
84139 #endif
84140
84141 -static int zero;
84142 -static int __maybe_unused one = 1;
84143 -static int __maybe_unused two = 2;
84144 -static int __maybe_unused three = 3;
84145 -static unsigned long one_ul = 1;
84146 -static int one_hundred = 100;
84147 +static int neg_one __read_only = -1;
84148 +static int zero __read_only = 0;
84149 +static int __maybe_unused one __read_only = 1;
84150 +static int __maybe_unused two __read_only = 2;
84151 +static int __maybe_unused three __read_only = 3;
84152 +static unsigned long one_ul __read_only = 1;
84153 +static int one_hundred __read_only = 100;
84154 #ifdef CONFIG_PRINTK
84155 -static int ten_thousand = 10000;
84156 +static int ten_thousand __read_only = 10000;
84157 #endif
84158
84159 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
84160 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
84161 void __user *buffer, size_t *lenp, loff_t *ppos);
84162 #endif
84163
84164 -#ifdef CONFIG_PRINTK
84165 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84166 void __user *buffer, size_t *lenp, loff_t *ppos);
84167 -#endif
84168
84169 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
84170 void __user *buffer, size_t *lenp, loff_t *ppos);
84171 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
84172
84173 #endif
84174
84175 +extern struct ctl_table grsecurity_table[];
84176 +
84177 static struct ctl_table kern_table[];
84178 static struct ctl_table vm_table[];
84179 static struct ctl_table fs_table[];
84180 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
84181 int sysctl_legacy_va_layout;
84182 #endif
84183
84184 +#ifdef CONFIG_PAX_SOFTMODE
84185 +static ctl_table pax_table[] = {
84186 + {
84187 + .procname = "softmode",
84188 + .data = &pax_softmode,
84189 + .maxlen = sizeof(unsigned int),
84190 + .mode = 0600,
84191 + .proc_handler = &proc_dointvec,
84192 + },
84193 +
84194 + { }
84195 +};
84196 +#endif
84197 +
84198 /* The default sysctl tables: */
84199
84200 static struct ctl_table sysctl_base_table[] = {
84201 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
84202 #endif
84203
84204 static struct ctl_table kern_table[] = {
84205 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
84206 + {
84207 + .procname = "grsecurity",
84208 + .mode = 0500,
84209 + .child = grsecurity_table,
84210 + },
84211 +#endif
84212 +
84213 +#ifdef CONFIG_PAX_SOFTMODE
84214 + {
84215 + .procname = "pax",
84216 + .mode = 0500,
84217 + .child = pax_table,
84218 + },
84219 +#endif
84220 +
84221 {
84222 .procname = "sched_child_runs_first",
84223 .data = &sysctl_sched_child_runs_first,
84224 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
84225 .data = &modprobe_path,
84226 .maxlen = KMOD_PATH_LEN,
84227 .mode = 0644,
84228 - .proc_handler = proc_dostring,
84229 + .proc_handler = proc_dostring_modpriv,
84230 },
84231 {
84232 .procname = "modules_disabled",
84233 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
84234 .extra1 = &zero,
84235 .extra2 = &one,
84236 },
84237 +#endif
84238 {
84239 .procname = "kptr_restrict",
84240 .data = &kptr_restrict,
84241 .maxlen = sizeof(int),
84242 .mode = 0644,
84243 .proc_handler = proc_dointvec_minmax_sysadmin,
84244 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84245 + .extra1 = &two,
84246 +#else
84247 .extra1 = &zero,
84248 +#endif
84249 .extra2 = &two,
84250 },
84251 -#endif
84252 {
84253 .procname = "ngroups_max",
84254 .data = &ngroups_max,
84255 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
84256 */
84257 {
84258 .procname = "perf_event_paranoid",
84259 - .data = &sysctl_perf_event_paranoid,
84260 - .maxlen = sizeof(sysctl_perf_event_paranoid),
84261 + .data = &sysctl_perf_event_legitimately_concerned,
84262 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
84263 .mode = 0644,
84264 - .proc_handler = proc_dointvec,
84265 + /* go ahead, be a hero */
84266 + .proc_handler = proc_dointvec_minmax_sysadmin,
84267 + .extra1 = &neg_one,
84268 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
84269 + .extra2 = &three,
84270 +#else
84271 + .extra2 = &two,
84272 +#endif
84273 },
84274 {
84275 .procname = "perf_event_mlock_kb",
84276 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
84277 .proc_handler = proc_dointvec_minmax,
84278 .extra1 = &zero,
84279 },
84280 + {
84281 + .procname = "heap_stack_gap",
84282 + .data = &sysctl_heap_stack_gap,
84283 + .maxlen = sizeof(sysctl_heap_stack_gap),
84284 + .mode = 0644,
84285 + .proc_handler = proc_doulongvec_minmax,
84286 + },
84287 #else
84288 {
84289 .procname = "nr_trim_pages",
84290 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
84291 buffer, lenp, ppos);
84292 }
84293
84294 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84295 + void __user *buffer, size_t *lenp, loff_t *ppos)
84296 +{
84297 + if (write && !capable(CAP_SYS_MODULE))
84298 + return -EPERM;
84299 +
84300 + return _proc_do_string(table->data, table->maxlen, write,
84301 + buffer, lenp, ppos);
84302 +}
84303 +
84304 static size_t proc_skip_spaces(char **buf)
84305 {
84306 size_t ret;
84307 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
84308 len = strlen(tmp);
84309 if (len > *size)
84310 len = *size;
84311 + if (len > sizeof(tmp))
84312 + len = sizeof(tmp);
84313 if (copy_to_user(*buf, tmp, len))
84314 return -EFAULT;
84315 *size -= len;
84316 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
84317 static int proc_taint(struct ctl_table *table, int write,
84318 void __user *buffer, size_t *lenp, loff_t *ppos)
84319 {
84320 - struct ctl_table t;
84321 + ctl_table_no_const t;
84322 unsigned long tmptaint = get_taint();
84323 int err;
84324
84325 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
84326 return err;
84327 }
84328
84329 -#ifdef CONFIG_PRINTK
84330 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84331 void __user *buffer, size_t *lenp, loff_t *ppos)
84332 {
84333 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84334
84335 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
84336 }
84337 -#endif
84338
84339 struct do_proc_dointvec_minmax_conv_param {
84340 int *min;
84341 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
84342 *i = val;
84343 } else {
84344 val = convdiv * (*i) / convmul;
84345 - if (!first)
84346 + if (!first) {
84347 err = proc_put_char(&buffer, &left, '\t');
84348 + if (err)
84349 + break;
84350 + }
84351 err = proc_put_long(&buffer, &left, val, false);
84352 if (err)
84353 break;
84354 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
84355 return -ENOSYS;
84356 }
84357
84358 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84359 + void __user *buffer, size_t *lenp, loff_t *ppos)
84360 +{
84361 + return -ENOSYS;
84362 +}
84363 +
84364 int proc_dointvec(struct ctl_table *table, int write,
84365 void __user *buffer, size_t *lenp, loff_t *ppos)
84366 {
84367 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
84368 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
84369 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
84370 EXPORT_SYMBOL(proc_dostring);
84371 +EXPORT_SYMBOL(proc_dostring_modpriv);
84372 EXPORT_SYMBOL(proc_doulongvec_minmax);
84373 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
84374 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
84375 index 145bb4d..b2aa969 100644
84376 --- a/kernel/taskstats.c
84377 +++ b/kernel/taskstats.c
84378 @@ -28,9 +28,12 @@
84379 #include <linux/fs.h>
84380 #include <linux/file.h>
84381 #include <linux/pid_namespace.h>
84382 +#include <linux/grsecurity.h>
84383 #include <net/genetlink.h>
84384 #include <linux/atomic.h>
84385
84386 +extern int gr_is_taskstats_denied(int pid);
84387 +
84388 /*
84389 * Maximum length of a cpumask that can be specified in
84390 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
84391 @@ -570,6 +573,9 @@ err:
84392
84393 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
84394 {
84395 + if (gr_is_taskstats_denied(current->pid))
84396 + return -EACCES;
84397 +
84398 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
84399 return cmd_attr_register_cpumask(info);
84400 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
84401 diff --git a/kernel/time.c b/kernel/time.c
84402 index 7c7964c..784a599 100644
84403 --- a/kernel/time.c
84404 +++ b/kernel/time.c
84405 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
84406 return error;
84407
84408 if (tz) {
84409 + /* we log in do_settimeofday called below, so don't log twice
84410 + */
84411 + if (!tv)
84412 + gr_log_timechange();
84413 +
84414 sys_tz = *tz;
84415 update_vsyscall_tz();
84416 if (firsttime) {
84417 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
84418 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
84419 * value to a scaled second value.
84420 */
84421 -unsigned long
84422 +unsigned long __intentional_overflow(-1)
84423 timespec_to_jiffies(const struct timespec *value)
84424 {
84425 unsigned long sec = value->tv_sec;
84426 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
84427 index eec50fc..65e5df6 100644
84428 --- a/kernel/time/alarmtimer.c
84429 +++ b/kernel/time/alarmtimer.c
84430 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
84431 struct platform_device *pdev;
84432 int error = 0;
84433 int i;
84434 - struct k_clock alarm_clock = {
84435 + static struct k_clock alarm_clock = {
84436 .clock_getres = alarm_clock_getres,
84437 .clock_get = alarm_clock_get,
84438 .timer_create = alarm_timer_create,
84439 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
84440 index 947ba25..20cbade 100644
84441 --- a/kernel/time/timekeeping.c
84442 +++ b/kernel/time/timekeeping.c
84443 @@ -15,6 +15,7 @@
84444 #include <linux/init.h>
84445 #include <linux/mm.h>
84446 #include <linux/sched.h>
84447 +#include <linux/grsecurity.h>
84448 #include <linux/syscore_ops.h>
84449 #include <linux/clocksource.h>
84450 #include <linux/jiffies.h>
84451 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
84452 if (!timespec_valid_strict(tv))
84453 return -EINVAL;
84454
84455 + gr_log_timechange();
84456 +
84457 raw_spin_lock_irqsave(&timekeeper_lock, flags);
84458 write_seqcount_begin(&timekeeper_seq);
84459
84460 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
84461 index 61ed862..3b52c65 100644
84462 --- a/kernel/time/timer_list.c
84463 +++ b/kernel/time/timer_list.c
84464 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
84465
84466 static void print_name_offset(struct seq_file *m, void *sym)
84467 {
84468 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84469 + SEQ_printf(m, "<%p>", NULL);
84470 +#else
84471 char symname[KSYM_NAME_LEN];
84472
84473 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
84474 SEQ_printf(m, "<%pK>", sym);
84475 else
84476 SEQ_printf(m, "%s", symname);
84477 +#endif
84478 }
84479
84480 static void
84481 @@ -119,7 +123,11 @@ next_one:
84482 static void
84483 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
84484 {
84485 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84486 + SEQ_printf(m, " .base: %p\n", NULL);
84487 +#else
84488 SEQ_printf(m, " .base: %pK\n", base);
84489 +#endif
84490 SEQ_printf(m, " .index: %d\n",
84491 base->index);
84492 SEQ_printf(m, " .resolution: %Lu nsecs\n",
84493 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
84494 {
84495 struct proc_dir_entry *pe;
84496
84497 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84498 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
84499 +#else
84500 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
84501 +#endif
84502 if (!pe)
84503 return -ENOMEM;
84504 return 0;
84505 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
84506 index 0b537f2..40d6c20 100644
84507 --- a/kernel/time/timer_stats.c
84508 +++ b/kernel/time/timer_stats.c
84509 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
84510 static unsigned long nr_entries;
84511 static struct entry entries[MAX_ENTRIES];
84512
84513 -static atomic_t overflow_count;
84514 +static atomic_unchecked_t overflow_count;
84515
84516 /*
84517 * The entries are in a hash-table, for fast lookup:
84518 @@ -140,7 +140,7 @@ static void reset_entries(void)
84519 nr_entries = 0;
84520 memset(entries, 0, sizeof(entries));
84521 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
84522 - atomic_set(&overflow_count, 0);
84523 + atomic_set_unchecked(&overflow_count, 0);
84524 }
84525
84526 static struct entry *alloc_entry(void)
84527 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84528 if (likely(entry))
84529 entry->count++;
84530 else
84531 - atomic_inc(&overflow_count);
84532 + atomic_inc_unchecked(&overflow_count);
84533
84534 out_unlock:
84535 raw_spin_unlock_irqrestore(lock, flags);
84536 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84537
84538 static void print_name_offset(struct seq_file *m, unsigned long addr)
84539 {
84540 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84541 + seq_printf(m, "<%p>", NULL);
84542 +#else
84543 char symname[KSYM_NAME_LEN];
84544
84545 if (lookup_symbol_name(addr, symname) < 0)
84546 - seq_printf(m, "<%p>", (void *)addr);
84547 + seq_printf(m, "<%pK>", (void *)addr);
84548 else
84549 seq_printf(m, "%s", symname);
84550 +#endif
84551 }
84552
84553 static int tstats_show(struct seq_file *m, void *v)
84554 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
84555
84556 seq_puts(m, "Timer Stats Version: v0.2\n");
84557 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
84558 - if (atomic_read(&overflow_count))
84559 + if (atomic_read_unchecked(&overflow_count))
84560 seq_printf(m, "Overflow: %d entries\n",
84561 - atomic_read(&overflow_count));
84562 + atomic_read_unchecked(&overflow_count));
84563
84564 for (i = 0; i < nr_entries; i++) {
84565 entry = entries + i;
84566 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
84567 {
84568 struct proc_dir_entry *pe;
84569
84570 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84571 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
84572 +#else
84573 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
84574 +#endif
84575 if (!pe)
84576 return -ENOMEM;
84577 return 0;
84578 diff --git a/kernel/timer.c b/kernel/timer.c
84579 index 4296d13..0164b04 100644
84580 --- a/kernel/timer.c
84581 +++ b/kernel/timer.c
84582 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
84583 /*
84584 * This function runs timers and the timer-tq in bottom half context.
84585 */
84586 -static void run_timer_softirq(struct softirq_action *h)
84587 +static __latent_entropy void run_timer_softirq(void)
84588 {
84589 struct tvec_base *base = __this_cpu_read(tvec_bases);
84590
84591 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
84592 *
84593 * In all cases the return value is guaranteed to be non-negative.
84594 */
84595 -signed long __sched schedule_timeout(signed long timeout)
84596 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
84597 {
84598 struct timer_list timer;
84599 unsigned long expire;
84600 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
84601 index b8b8560..75b1a09 100644
84602 --- a/kernel/trace/blktrace.c
84603 +++ b/kernel/trace/blktrace.c
84604 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
84605 struct blk_trace *bt = filp->private_data;
84606 char buf[16];
84607
84608 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
84609 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
84610
84611 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
84612 }
84613 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
84614 return 1;
84615
84616 bt = buf->chan->private_data;
84617 - atomic_inc(&bt->dropped);
84618 + atomic_inc_unchecked(&bt->dropped);
84619 return 0;
84620 }
84621
84622 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
84623
84624 bt->dir = dir;
84625 bt->dev = dev;
84626 - atomic_set(&bt->dropped, 0);
84627 + atomic_set_unchecked(&bt->dropped, 0);
84628
84629 ret = -EIO;
84630 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
84631 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
84632 index a6d098c..bb8cf65 100644
84633 --- a/kernel/trace/ftrace.c
84634 +++ b/kernel/trace/ftrace.c
84635 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
84636 if (unlikely(ftrace_disabled))
84637 return 0;
84638
84639 + ret = ftrace_arch_code_modify_prepare();
84640 + FTRACE_WARN_ON(ret);
84641 + if (ret)
84642 + return 0;
84643 +
84644 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
84645 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
84646 if (ret) {
84647 ftrace_bug(ret, ip);
84648 - return 0;
84649 }
84650 - return 1;
84651 + return ret ? 0 : 1;
84652 }
84653
84654 /*
84655 @@ -4028,8 +4033,10 @@ static int ftrace_process_locs(struct module *mod,
84656 if (!count)
84657 return 0;
84658
84659 + pax_open_kernel();
84660 sort(start, count, sizeof(*start),
84661 ftrace_cmp_ips, ftrace_swap_ips);
84662 + pax_close_kernel();
84663
84664 start_pg = ftrace_allocate_pages(count);
84665 if (!start_pg)
84666 @@ -4752,8 +4759,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
84667 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
84668
84669 static int ftrace_graph_active;
84670 -static struct notifier_block ftrace_suspend_notifier;
84671 -
84672 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
84673 {
84674 return 0;
84675 @@ -4897,6 +4902,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
84676 return NOTIFY_DONE;
84677 }
84678
84679 +static struct notifier_block ftrace_suspend_notifier = {
84680 + .notifier_call = ftrace_suspend_notifier_call
84681 +};
84682 +
84683 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84684 trace_func_graph_ent_t entryfunc)
84685 {
84686 @@ -4910,7 +4919,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84687 goto out;
84688 }
84689
84690 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
84691 register_pm_notifier(&ftrace_suspend_notifier);
84692
84693 ftrace_graph_active++;
84694 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
84695 index cc2f66f..05edd54 100644
84696 --- a/kernel/trace/ring_buffer.c
84697 +++ b/kernel/trace/ring_buffer.c
84698 @@ -352,9 +352,9 @@ struct buffer_data_page {
84699 */
84700 struct buffer_page {
84701 struct list_head list; /* list of buffer pages */
84702 - local_t write; /* index for next write */
84703 + local_unchecked_t write; /* index for next write */
84704 unsigned read; /* index for next read */
84705 - local_t entries; /* entries on this page */
84706 + local_unchecked_t entries; /* entries on this page */
84707 unsigned long real_end; /* real end of data */
84708 struct buffer_data_page *page; /* Actual data page */
84709 };
84710 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
84711 unsigned long last_overrun;
84712 local_t entries_bytes;
84713 local_t entries;
84714 - local_t overrun;
84715 - local_t commit_overrun;
84716 + local_unchecked_t overrun;
84717 + local_unchecked_t commit_overrun;
84718 local_t dropped_events;
84719 local_t committing;
84720 local_t commits;
84721 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84722 *
84723 * We add a counter to the write field to denote this.
84724 */
84725 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
84726 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
84727 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
84728 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
84729
84730 /*
84731 * Just make sure we have seen our old_write and synchronize
84732 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84733 * cmpxchg to only update if an interrupt did not already
84734 * do it for us. If the cmpxchg fails, we don't care.
84735 */
84736 - (void)local_cmpxchg(&next_page->write, old_write, val);
84737 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
84738 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
84739 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
84740
84741 /*
84742 * No need to worry about races with clearing out the commit.
84743 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
84744
84745 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
84746 {
84747 - return local_read(&bpage->entries) & RB_WRITE_MASK;
84748 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
84749 }
84750
84751 static inline unsigned long rb_page_write(struct buffer_page *bpage)
84752 {
84753 - return local_read(&bpage->write) & RB_WRITE_MASK;
84754 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
84755 }
84756
84757 static int
84758 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
84759 * bytes consumed in ring buffer from here.
84760 * Increment overrun to account for the lost events.
84761 */
84762 - local_add(page_entries, &cpu_buffer->overrun);
84763 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
84764 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84765 }
84766
84767 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
84768 * it is our responsibility to update
84769 * the counters.
84770 */
84771 - local_add(entries, &cpu_buffer->overrun);
84772 + local_add_unchecked(entries, &cpu_buffer->overrun);
84773 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84774
84775 /*
84776 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84777 if (tail == BUF_PAGE_SIZE)
84778 tail_page->real_end = 0;
84779
84780 - local_sub(length, &tail_page->write);
84781 + local_sub_unchecked(length, &tail_page->write);
84782 return;
84783 }
84784
84785 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84786 rb_event_set_padding(event);
84787
84788 /* Set the write back to the previous setting */
84789 - local_sub(length, &tail_page->write);
84790 + local_sub_unchecked(length, &tail_page->write);
84791 return;
84792 }
84793
84794 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84795
84796 /* Set write to end of buffer */
84797 length = (tail + length) - BUF_PAGE_SIZE;
84798 - local_sub(length, &tail_page->write);
84799 + local_sub_unchecked(length, &tail_page->write);
84800 }
84801
84802 /*
84803 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84804 * about it.
84805 */
84806 if (unlikely(next_page == commit_page)) {
84807 - local_inc(&cpu_buffer->commit_overrun);
84808 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84809 goto out_reset;
84810 }
84811
84812 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84813 cpu_buffer->tail_page) &&
84814 (cpu_buffer->commit_page ==
84815 cpu_buffer->reader_page))) {
84816 - local_inc(&cpu_buffer->commit_overrun);
84817 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84818 goto out_reset;
84819 }
84820 }
84821 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84822 length += RB_LEN_TIME_EXTEND;
84823
84824 tail_page = cpu_buffer->tail_page;
84825 - write = local_add_return(length, &tail_page->write);
84826 + write = local_add_return_unchecked(length, &tail_page->write);
84827
84828 /* set write to only the index of the write */
84829 write &= RB_WRITE_MASK;
84830 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84831 kmemcheck_annotate_bitfield(event, bitfield);
84832 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
84833
84834 - local_inc(&tail_page->entries);
84835 + local_inc_unchecked(&tail_page->entries);
84836
84837 /*
84838 * If this is the first commit on the page, then update
84839 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84840
84841 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
84842 unsigned long write_mask =
84843 - local_read(&bpage->write) & ~RB_WRITE_MASK;
84844 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
84845 unsigned long event_length = rb_event_length(event);
84846 /*
84847 * This is on the tail page. It is possible that
84848 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84849 */
84850 old_index += write_mask;
84851 new_index += write_mask;
84852 - index = local_cmpxchg(&bpage->write, old_index, new_index);
84853 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
84854 if (index == old_index) {
84855 /* update counters */
84856 local_sub(event_length, &cpu_buffer->entries_bytes);
84857 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84858
84859 /* Do the likely case first */
84860 if (likely(bpage->page == (void *)addr)) {
84861 - local_dec(&bpage->entries);
84862 + local_dec_unchecked(&bpage->entries);
84863 return;
84864 }
84865
84866 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84867 start = bpage;
84868 do {
84869 if (bpage->page == (void *)addr) {
84870 - local_dec(&bpage->entries);
84871 + local_dec_unchecked(&bpage->entries);
84872 return;
84873 }
84874 rb_inc_page(cpu_buffer, &bpage);
84875 @@ -3139,7 +3139,7 @@ static inline unsigned long
84876 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
84877 {
84878 return local_read(&cpu_buffer->entries) -
84879 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
84880 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
84881 }
84882
84883 /**
84884 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
84885 return 0;
84886
84887 cpu_buffer = buffer->buffers[cpu];
84888 - ret = local_read(&cpu_buffer->overrun);
84889 + ret = local_read_unchecked(&cpu_buffer->overrun);
84890
84891 return ret;
84892 }
84893 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
84894 return 0;
84895
84896 cpu_buffer = buffer->buffers[cpu];
84897 - ret = local_read(&cpu_buffer->commit_overrun);
84898 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
84899
84900 return ret;
84901 }
84902 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
84903 /* if you care about this being correct, lock the buffer */
84904 for_each_buffer_cpu(buffer, cpu) {
84905 cpu_buffer = buffer->buffers[cpu];
84906 - overruns += local_read(&cpu_buffer->overrun);
84907 + overruns += local_read_unchecked(&cpu_buffer->overrun);
84908 }
84909
84910 return overruns;
84911 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84912 /*
84913 * Reset the reader page to size zero.
84914 */
84915 - local_set(&cpu_buffer->reader_page->write, 0);
84916 - local_set(&cpu_buffer->reader_page->entries, 0);
84917 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84918 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84919 local_set(&cpu_buffer->reader_page->page->commit, 0);
84920 cpu_buffer->reader_page->real_end = 0;
84921
84922 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84923 * want to compare with the last_overrun.
84924 */
84925 smp_mb();
84926 - overwrite = local_read(&(cpu_buffer->overrun));
84927 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
84928
84929 /*
84930 * Here's the tricky part.
84931 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84932
84933 cpu_buffer->head_page
84934 = list_entry(cpu_buffer->pages, struct buffer_page, list);
84935 - local_set(&cpu_buffer->head_page->write, 0);
84936 - local_set(&cpu_buffer->head_page->entries, 0);
84937 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
84938 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
84939 local_set(&cpu_buffer->head_page->page->commit, 0);
84940
84941 cpu_buffer->head_page->read = 0;
84942 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84943
84944 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
84945 INIT_LIST_HEAD(&cpu_buffer->new_pages);
84946 - local_set(&cpu_buffer->reader_page->write, 0);
84947 - local_set(&cpu_buffer->reader_page->entries, 0);
84948 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84949 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84950 local_set(&cpu_buffer->reader_page->page->commit, 0);
84951 cpu_buffer->reader_page->read = 0;
84952
84953 local_set(&cpu_buffer->entries_bytes, 0);
84954 - local_set(&cpu_buffer->overrun, 0);
84955 - local_set(&cpu_buffer->commit_overrun, 0);
84956 + local_set_unchecked(&cpu_buffer->overrun, 0);
84957 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
84958 local_set(&cpu_buffer->dropped_events, 0);
84959 local_set(&cpu_buffer->entries, 0);
84960 local_set(&cpu_buffer->committing, 0);
84961 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
84962 rb_init_page(bpage);
84963 bpage = reader->page;
84964 reader->page = *data_page;
84965 - local_set(&reader->write, 0);
84966 - local_set(&reader->entries, 0);
84967 + local_set_unchecked(&reader->write, 0);
84968 + local_set_unchecked(&reader->entries, 0);
84969 reader->read = 0;
84970 *data_page = bpage;
84971
84972 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
84973 index 207f5fc..ff41c9b 100644
84974 --- a/kernel/trace/trace.c
84975 +++ b/kernel/trace/trace.c
84976 @@ -3338,7 +3338,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
84977 return 0;
84978 }
84979
84980 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
84981 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
84982 {
84983 /* do nothing if flag is already set */
84984 if (!!(trace_flags & mask) == !!enabled)
84985 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
84986 index afaae41..64871f8 100644
84987 --- a/kernel/trace/trace.h
84988 +++ b/kernel/trace/trace.h
84989 @@ -1025,7 +1025,7 @@ extern const char *__stop___trace_bprintk_fmt[];
84990 void trace_printk_init_buffers(void);
84991 void trace_printk_start_comm(void);
84992 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
84993 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
84994 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
84995
84996 /*
84997 * Normal trace_printk() and friends allocates special buffers
84998 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
84999 index 26dc348..8708ca7 100644
85000 --- a/kernel/trace/trace_clock.c
85001 +++ b/kernel/trace/trace_clock.c
85002 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
85003 return now;
85004 }
85005
85006 -static atomic64_t trace_counter;
85007 +static atomic64_unchecked_t trace_counter;
85008
85009 /*
85010 * trace_clock_counter(): simply an atomic counter.
85011 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
85012 */
85013 u64 notrace trace_clock_counter(void)
85014 {
85015 - return atomic64_add_return(1, &trace_counter);
85016 + return atomic64_inc_return_unchecked(&trace_counter);
85017 }
85018 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
85019 index 29a7ebc..eb473cf 100644
85020 --- a/kernel/trace/trace_events.c
85021 +++ b/kernel/trace/trace_events.c
85022 @@ -1778,10 +1778,6 @@ static LIST_HEAD(ftrace_module_file_list);
85023 struct ftrace_module_file_ops {
85024 struct list_head list;
85025 struct module *mod;
85026 - struct file_operations id;
85027 - struct file_operations enable;
85028 - struct file_operations format;
85029 - struct file_operations filter;
85030 };
85031
85032 static struct ftrace_module_file_ops *
85033 @@ -1822,17 +1818,12 @@ trace_create_file_ops(struct module *mod)
85034
85035 file_ops->mod = mod;
85036
85037 - file_ops->id = ftrace_event_id_fops;
85038 - file_ops->id.owner = mod;
85039 -
85040 - file_ops->enable = ftrace_enable_fops;
85041 - file_ops->enable.owner = mod;
85042 -
85043 - file_ops->filter = ftrace_event_filter_fops;
85044 - file_ops->filter.owner = mod;
85045 -
85046 - file_ops->format = ftrace_event_format_fops;
85047 - file_ops->format.owner = mod;
85048 + pax_open_kernel();
85049 + mod->trace_id.owner = mod;
85050 + mod->trace_enable.owner = mod;
85051 + mod->trace_filter.owner = mod;
85052 + mod->trace_format.owner = mod;
85053 + pax_close_kernel();
85054
85055 list_add(&file_ops->list, &ftrace_module_file_list);
85056
85057 @@ -1925,8 +1916,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
85058 struct ftrace_module_file_ops *file_ops)
85059 {
85060 return __trace_add_new_event(call, tr,
85061 - &file_ops->id, &file_ops->enable,
85062 - &file_ops->filter, &file_ops->format);
85063 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
85064 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
85065 }
85066
85067 #else
85068 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
85069 index b3dcfb2..ebee344 100644
85070 --- a/kernel/trace/trace_mmiotrace.c
85071 +++ b/kernel/trace/trace_mmiotrace.c
85072 @@ -24,7 +24,7 @@ struct header_iter {
85073 static struct trace_array *mmio_trace_array;
85074 static bool overrun_detected;
85075 static unsigned long prev_overruns;
85076 -static atomic_t dropped_count;
85077 +static atomic_unchecked_t dropped_count;
85078
85079 static void mmio_reset_data(struct trace_array *tr)
85080 {
85081 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
85082
85083 static unsigned long count_overruns(struct trace_iterator *iter)
85084 {
85085 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
85086 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
85087 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
85088
85089 if (over > prev_overruns)
85090 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
85091 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
85092 sizeof(*entry), 0, pc);
85093 if (!event) {
85094 - atomic_inc(&dropped_count);
85095 + atomic_inc_unchecked(&dropped_count);
85096 return;
85097 }
85098 entry = ring_buffer_event_data(event);
85099 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
85100 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
85101 sizeof(*entry), 0, pc);
85102 if (!event) {
85103 - atomic_inc(&dropped_count);
85104 + atomic_inc_unchecked(&dropped_count);
85105 return;
85106 }
85107 entry = ring_buffer_event_data(event);
85108 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
85109 index 34e7cba..6f9a729 100644
85110 --- a/kernel/trace/trace_output.c
85111 +++ b/kernel/trace/trace_output.c
85112 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
85113
85114 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
85115 if (!IS_ERR(p)) {
85116 - p = mangle_path(s->buffer + s->len, p, "\n");
85117 + p = mangle_path(s->buffer + s->len, p, "\n\\");
85118 if (p) {
85119 s->len = p - s->buffer;
85120 return 1;
85121 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
85122 goto out;
85123 }
85124
85125 + pax_open_kernel();
85126 if (event->funcs->trace == NULL)
85127 - event->funcs->trace = trace_nop_print;
85128 + *(void **)&event->funcs->trace = trace_nop_print;
85129 if (event->funcs->raw == NULL)
85130 - event->funcs->raw = trace_nop_print;
85131 + *(void **)&event->funcs->raw = trace_nop_print;
85132 if (event->funcs->hex == NULL)
85133 - event->funcs->hex = trace_nop_print;
85134 + *(void **)&event->funcs->hex = trace_nop_print;
85135 if (event->funcs->binary == NULL)
85136 - event->funcs->binary = trace_nop_print;
85137 + *(void **)&event->funcs->binary = trace_nop_print;
85138 + pax_close_kernel();
85139
85140 key = event->type & (EVENT_HASHSIZE - 1);
85141
85142 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
85143 index b20428c..4845a10 100644
85144 --- a/kernel/trace/trace_stack.c
85145 +++ b/kernel/trace/trace_stack.c
85146 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
85147 return;
85148
85149 /* we do not handle interrupt stacks yet */
85150 - if (!object_is_on_stack(stack))
85151 + if (!object_starts_on_stack(stack))
85152 return;
85153
85154 local_irq_save(flags);
85155 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
85156 index 9064b91..1f5d2f8 100644
85157 --- a/kernel/user_namespace.c
85158 +++ b/kernel/user_namespace.c
85159 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
85160 !kgid_has_mapping(parent_ns, group))
85161 return -EPERM;
85162
85163 +#ifdef CONFIG_GRKERNSEC
85164 + /*
85165 + * This doesn't really inspire confidence:
85166 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
85167 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
85168 + * Increases kernel attack surface in areas developers
85169 + * previously cared little about ("low importance due
85170 + * to requiring "root" capability")
85171 + * To be removed when this code receives *proper* review
85172 + */
85173 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
85174 + !capable(CAP_SETGID))
85175 + return -EPERM;
85176 +#endif
85177 +
85178 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
85179 if (!ns)
85180 return -ENOMEM;
85181 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
85182 if (atomic_read(&current->mm->mm_users) > 1)
85183 return -EINVAL;
85184
85185 - if (current->fs->users != 1)
85186 + if (atomic_read(&current->fs->users) != 1)
85187 return -EINVAL;
85188
85189 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
85190 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
85191 index 4f69f9a..7c6f8f8 100644
85192 --- a/kernel/utsname_sysctl.c
85193 +++ b/kernel/utsname_sysctl.c
85194 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
85195 static int proc_do_uts_string(ctl_table *table, int write,
85196 void __user *buffer, size_t *lenp, loff_t *ppos)
85197 {
85198 - struct ctl_table uts_table;
85199 + ctl_table_no_const uts_table;
85200 int r;
85201 memcpy(&uts_table, table, sizeof(uts_table));
85202 uts_table.data = get_uts(table, write);
85203 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
85204 index 1241d8c..d5cfc28 100644
85205 --- a/kernel/watchdog.c
85206 +++ b/kernel/watchdog.c
85207 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
85208 static void watchdog_nmi_disable(unsigned int cpu) { return; }
85209 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
85210
85211 -static struct smp_hotplug_thread watchdog_threads = {
85212 +static struct smp_hotplug_thread watchdog_threads __read_only = {
85213 .store = &softlockup_watchdog,
85214 .thread_should_run = watchdog_should_run,
85215 .thread_fn = watchdog,
85216 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
85217 index e93f7b9..989fcd7 100644
85218 --- a/kernel/workqueue.c
85219 +++ b/kernel/workqueue.c
85220 @@ -4627,7 +4627,7 @@ static void rebind_workers(struct worker_pool *pool)
85221 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
85222 worker_flags |= WORKER_REBOUND;
85223 worker_flags &= ~WORKER_UNBOUND;
85224 - ACCESS_ONCE(worker->flags) = worker_flags;
85225 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
85226 }
85227
85228 spin_unlock_irq(&pool->lock);
85229 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
85230 index 1501aa5..e771896 100644
85231 --- a/lib/Kconfig.debug
85232 +++ b/lib/Kconfig.debug
85233 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
85234
85235 config DEBUG_WW_MUTEX_SLOWPATH
85236 bool "Wait/wound mutex debugging: Slowpath testing"
85237 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85238 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85239 select DEBUG_LOCK_ALLOC
85240 select DEBUG_SPINLOCK
85241 select DEBUG_MUTEXES
85242 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
85243
85244 config DEBUG_LOCK_ALLOC
85245 bool "Lock debugging: detect incorrect freeing of live locks"
85246 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85247 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85248 select DEBUG_SPINLOCK
85249 select DEBUG_MUTEXES
85250 select LOCKDEP
85251 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
85252
85253 config PROVE_LOCKING
85254 bool "Lock debugging: prove locking correctness"
85255 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85256 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85257 select LOCKDEP
85258 select DEBUG_SPINLOCK
85259 select DEBUG_MUTEXES
85260 @@ -914,7 +914,7 @@ config LOCKDEP
85261
85262 config LOCK_STAT
85263 bool "Lock usage statistics"
85264 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85265 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85266 select LOCKDEP
85267 select DEBUG_SPINLOCK
85268 select DEBUG_MUTEXES
85269 @@ -1357,6 +1357,7 @@ config LATENCYTOP
85270 depends on DEBUG_KERNEL
85271 depends on STACKTRACE_SUPPORT
85272 depends on PROC_FS
85273 + depends on !GRKERNSEC_HIDESYM
85274 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
85275 select KALLSYMS
85276 select KALLSYMS_ALL
85277 @@ -1373,7 +1374,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85278 config DEBUG_STRICT_USER_COPY_CHECKS
85279 bool "Strict user copy size checks"
85280 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85281 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
85282 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
85283 help
85284 Enabling this option turns a certain set of sanity checks for user
85285 copy operations into compile time failures.
85286 @@ -1483,7 +1484,7 @@ endmenu # runtime tests
85287
85288 config PROVIDE_OHCI1394_DMA_INIT
85289 bool "Remote debugging over FireWire early on boot"
85290 - depends on PCI && X86
85291 + depends on PCI && X86 && !GRKERNSEC
85292 help
85293 If you want to debug problems which hang or crash the kernel early
85294 on boot and the crashing machine has a FireWire port, you can use
85295 @@ -1512,7 +1513,7 @@ config PROVIDE_OHCI1394_DMA_INIT
85296
85297 config FIREWIRE_OHCI_REMOTE_DMA
85298 bool "Remote debugging over FireWire with firewire-ohci"
85299 - depends on FIREWIRE_OHCI
85300 + depends on FIREWIRE_OHCI && !GRKERNSEC
85301 help
85302 This option lets you use the FireWire bus for remote debugging
85303 with help of the firewire-ohci driver. It enables unfiltered
85304 diff --git a/lib/Makefile b/lib/Makefile
85305 index 7baccfd..3ceb95f 100644
85306 --- a/lib/Makefile
85307 +++ b/lib/Makefile
85308 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
85309
85310 obj-$(CONFIG_BTREE) += btree.o
85311 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
85312 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
85313 +obj-y += list_debug.o
85314 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
85315
85316 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
85317 diff --git a/lib/bitmap.c b/lib/bitmap.c
85318 index 06f7e4f..f3cf2b0 100644
85319 --- a/lib/bitmap.c
85320 +++ b/lib/bitmap.c
85321 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
85322 {
85323 int c, old_c, totaldigits, ndigits, nchunks, nbits;
85324 u32 chunk;
85325 - const char __user __force *ubuf = (const char __user __force *)buf;
85326 + const char __user *ubuf = (const char __force_user *)buf;
85327
85328 bitmap_zero(maskp, nmaskbits);
85329
85330 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
85331 {
85332 if (!access_ok(VERIFY_READ, ubuf, ulen))
85333 return -EFAULT;
85334 - return __bitmap_parse((const char __force *)ubuf,
85335 + return __bitmap_parse((const char __force_kernel *)ubuf,
85336 ulen, 1, maskp, nmaskbits);
85337
85338 }
85339 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
85340 {
85341 unsigned a, b;
85342 int c, old_c, totaldigits;
85343 - const char __user __force *ubuf = (const char __user __force *)buf;
85344 + const char __user *ubuf = (const char __force_user *)buf;
85345 int exp_digit, in_range;
85346
85347 totaldigits = c = 0;
85348 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
85349 {
85350 if (!access_ok(VERIFY_READ, ubuf, ulen))
85351 return -EFAULT;
85352 - return __bitmap_parselist((const char __force *)ubuf,
85353 + return __bitmap_parselist((const char __force_kernel *)ubuf,
85354 ulen, 1, maskp, nmaskbits);
85355 }
85356 EXPORT_SYMBOL(bitmap_parselist_user);
85357 diff --git a/lib/bug.c b/lib/bug.c
85358 index 1686034..a9c00c8 100644
85359 --- a/lib/bug.c
85360 +++ b/lib/bug.c
85361 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
85362 return BUG_TRAP_TYPE_NONE;
85363
85364 bug = find_bug(bugaddr);
85365 + if (!bug)
85366 + return BUG_TRAP_TYPE_NONE;
85367
85368 file = NULL;
85369 line = 0;
85370 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
85371 index 37061ed..da83f48 100644
85372 --- a/lib/debugobjects.c
85373 +++ b/lib/debugobjects.c
85374 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
85375 if (limit > 4)
85376 return;
85377
85378 - is_on_stack = object_is_on_stack(addr);
85379 + is_on_stack = object_starts_on_stack(addr);
85380 if (is_on_stack == onstack)
85381 return;
85382
85383 diff --git a/lib/devres.c b/lib/devres.c
85384 index 8235331..5881053 100644
85385 --- a/lib/devres.c
85386 +++ b/lib/devres.c
85387 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
85388 void devm_iounmap(struct device *dev, void __iomem *addr)
85389 {
85390 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
85391 - (void *)addr));
85392 + (void __force *)addr));
85393 iounmap(addr);
85394 }
85395 EXPORT_SYMBOL(devm_iounmap);
85396 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
85397 {
85398 ioport_unmap(addr);
85399 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
85400 - devm_ioport_map_match, (void *)addr));
85401 + devm_ioport_map_match, (void __force *)addr));
85402 }
85403 EXPORT_SYMBOL(devm_ioport_unmap);
85404 #endif /* CONFIG_HAS_IOPORT */
85405 diff --git a/lib/div64.c b/lib/div64.c
85406 index a163b6c..9618fa5 100644
85407 --- a/lib/div64.c
85408 +++ b/lib/div64.c
85409 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
85410 EXPORT_SYMBOL(__div64_32);
85411
85412 #ifndef div_s64_rem
85413 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85414 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85415 {
85416 u64 quotient;
85417
85418 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
85419 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
85420 */
85421 #ifndef div64_u64
85422 -u64 div64_u64(u64 dividend, u64 divisor)
85423 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
85424 {
85425 u32 high = divisor >> 32;
85426 u64 quot;
85427 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
85428 index d87a17a..ac0d79a 100644
85429 --- a/lib/dma-debug.c
85430 +++ b/lib/dma-debug.c
85431 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
85432
85433 void dma_debug_add_bus(struct bus_type *bus)
85434 {
85435 - struct notifier_block *nb;
85436 + notifier_block_no_const *nb;
85437
85438 if (global_disable)
85439 return;
85440 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
85441
85442 static void check_for_stack(struct device *dev, void *addr)
85443 {
85444 - if (object_is_on_stack(addr))
85445 + if (object_starts_on_stack(addr))
85446 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
85447 "stack [addr=%p]\n", addr);
85448 }
85449 diff --git a/lib/inflate.c b/lib/inflate.c
85450 index 013a761..c28f3fc 100644
85451 --- a/lib/inflate.c
85452 +++ b/lib/inflate.c
85453 @@ -269,7 +269,7 @@ static void free(void *where)
85454 malloc_ptr = free_mem_ptr;
85455 }
85456 #else
85457 -#define malloc(a) kmalloc(a, GFP_KERNEL)
85458 +#define malloc(a) kmalloc((a), GFP_KERNEL)
85459 #define free(a) kfree(a)
85460 #endif
85461
85462 diff --git a/lib/ioremap.c b/lib/ioremap.c
85463 index 0c9216c..863bd89 100644
85464 --- a/lib/ioremap.c
85465 +++ b/lib/ioremap.c
85466 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
85467 unsigned long next;
85468
85469 phys_addr -= addr;
85470 - pmd = pmd_alloc(&init_mm, pud, addr);
85471 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85472 if (!pmd)
85473 return -ENOMEM;
85474 do {
85475 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
85476 unsigned long next;
85477
85478 phys_addr -= addr;
85479 - pud = pud_alloc(&init_mm, pgd, addr);
85480 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85481 if (!pud)
85482 return -ENOMEM;
85483 do {
85484 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
85485 index bd2bea9..6b3c95e 100644
85486 --- a/lib/is_single_threaded.c
85487 +++ b/lib/is_single_threaded.c
85488 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
85489 struct task_struct *p, *t;
85490 bool ret;
85491
85492 + if (!mm)
85493 + return true;
85494 +
85495 if (atomic_read(&task->signal->live) != 1)
85496 return false;
85497
85498 diff --git a/lib/kobject.c b/lib/kobject.c
85499 index 4a1f33d..2f3ca75 100644
85500 --- a/lib/kobject.c
85501 +++ b/lib/kobject.c
85502 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
85503
85504
85505 static DEFINE_SPINLOCK(kobj_ns_type_lock);
85506 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
85507 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
85508
85509 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85510 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85511 {
85512 enum kobj_ns_type type = ops->type;
85513 int error;
85514 diff --git a/lib/list_debug.c b/lib/list_debug.c
85515 index c24c2f7..f0296f4 100644
85516 --- a/lib/list_debug.c
85517 +++ b/lib/list_debug.c
85518 @@ -11,7 +11,9 @@
85519 #include <linux/bug.h>
85520 #include <linux/kernel.h>
85521 #include <linux/rculist.h>
85522 +#include <linux/mm.h>
85523
85524 +#ifdef CONFIG_DEBUG_LIST
85525 /*
85526 * Insert a new entry between two known consecutive entries.
85527 *
85528 @@ -19,21 +21,40 @@
85529 * the prev/next entries already!
85530 */
85531
85532 +static bool __list_add_debug(struct list_head *new,
85533 + struct list_head *prev,
85534 + struct list_head *next)
85535 +{
85536 + if (unlikely(next->prev != prev)) {
85537 + printk(KERN_ERR "list_add corruption. next->prev should be "
85538 + "prev (%p), but was %p. (next=%p).\n",
85539 + prev, next->prev, next);
85540 + BUG();
85541 + return false;
85542 + }
85543 + if (unlikely(prev->next != next)) {
85544 + printk(KERN_ERR "list_add corruption. prev->next should be "
85545 + "next (%p), but was %p. (prev=%p).\n",
85546 + next, prev->next, prev);
85547 + BUG();
85548 + return false;
85549 + }
85550 + if (unlikely(new == prev || new == next)) {
85551 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
85552 + new, prev, next);
85553 + BUG();
85554 + return false;
85555 + }
85556 + return true;
85557 +}
85558 +
85559 void __list_add(struct list_head *new,
85560 - struct list_head *prev,
85561 - struct list_head *next)
85562 + struct list_head *prev,
85563 + struct list_head *next)
85564 {
85565 - WARN(next->prev != prev,
85566 - "list_add corruption. next->prev should be "
85567 - "prev (%p), but was %p. (next=%p).\n",
85568 - prev, next->prev, next);
85569 - WARN(prev->next != next,
85570 - "list_add corruption. prev->next should be "
85571 - "next (%p), but was %p. (prev=%p).\n",
85572 - next, prev->next, prev);
85573 - WARN(new == prev || new == next,
85574 - "list_add double add: new=%p, prev=%p, next=%p.\n",
85575 - new, prev, next);
85576 + if (!__list_add_debug(new, prev, next))
85577 + return;
85578 +
85579 next->prev = new;
85580 new->next = next;
85581 new->prev = prev;
85582 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
85583 }
85584 EXPORT_SYMBOL(__list_add);
85585
85586 -void __list_del_entry(struct list_head *entry)
85587 +static bool __list_del_entry_debug(struct list_head *entry)
85588 {
85589 struct list_head *prev, *next;
85590
85591 prev = entry->prev;
85592 next = entry->next;
85593
85594 - if (WARN(next == LIST_POISON1,
85595 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
85596 - entry, LIST_POISON1) ||
85597 - WARN(prev == LIST_POISON2,
85598 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
85599 - entry, LIST_POISON2) ||
85600 - WARN(prev->next != entry,
85601 - "list_del corruption. prev->next should be %p, "
85602 - "but was %p\n", entry, prev->next) ||
85603 - WARN(next->prev != entry,
85604 - "list_del corruption. next->prev should be %p, "
85605 - "but was %p\n", entry, next->prev))
85606 + if (unlikely(next == LIST_POISON1)) {
85607 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
85608 + entry, LIST_POISON1);
85609 + BUG();
85610 + return false;
85611 + }
85612 + if (unlikely(prev == LIST_POISON2)) {
85613 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
85614 + entry, LIST_POISON2);
85615 + BUG();
85616 + return false;
85617 + }
85618 + if (unlikely(entry->prev->next != entry)) {
85619 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
85620 + "but was %p\n", entry, prev->next);
85621 + BUG();
85622 + return false;
85623 + }
85624 + if (unlikely(entry->next->prev != entry)) {
85625 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
85626 + "but was %p\n", entry, next->prev);
85627 + BUG();
85628 + return false;
85629 + }
85630 + return true;
85631 +}
85632 +
85633 +void __list_del_entry(struct list_head *entry)
85634 +{
85635 + if (!__list_del_entry_debug(entry))
85636 return;
85637
85638 - __list_del(prev, next);
85639 + __list_del(entry->prev, entry->next);
85640 }
85641 EXPORT_SYMBOL(__list_del_entry);
85642
85643 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
85644 void __list_add_rcu(struct list_head *new,
85645 struct list_head *prev, struct list_head *next)
85646 {
85647 - WARN(next->prev != prev,
85648 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
85649 - prev, next->prev, next);
85650 - WARN(prev->next != next,
85651 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
85652 - next, prev->next, prev);
85653 + if (!__list_add_debug(new, prev, next))
85654 + return;
85655 +
85656 new->next = next;
85657 new->prev = prev;
85658 rcu_assign_pointer(list_next_rcu(prev), new);
85659 next->prev = new;
85660 }
85661 EXPORT_SYMBOL(__list_add_rcu);
85662 +#endif
85663 +
85664 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
85665 +{
85666 +#ifdef CONFIG_DEBUG_LIST
85667 + if (!__list_add_debug(new, prev, next))
85668 + return;
85669 +#endif
85670 +
85671 + pax_open_kernel();
85672 + next->prev = new;
85673 + new->next = next;
85674 + new->prev = prev;
85675 + prev->next = new;
85676 + pax_close_kernel();
85677 +}
85678 +EXPORT_SYMBOL(__pax_list_add);
85679 +
85680 +void pax_list_del(struct list_head *entry)
85681 +{
85682 +#ifdef CONFIG_DEBUG_LIST
85683 + if (!__list_del_entry_debug(entry))
85684 + return;
85685 +#endif
85686 +
85687 + pax_open_kernel();
85688 + __list_del(entry->prev, entry->next);
85689 + entry->next = LIST_POISON1;
85690 + entry->prev = LIST_POISON2;
85691 + pax_close_kernel();
85692 +}
85693 +EXPORT_SYMBOL(pax_list_del);
85694 +
85695 +void pax_list_del_init(struct list_head *entry)
85696 +{
85697 + pax_open_kernel();
85698 + __list_del(entry->prev, entry->next);
85699 + INIT_LIST_HEAD(entry);
85700 + pax_close_kernel();
85701 +}
85702 +EXPORT_SYMBOL(pax_list_del_init);
85703 +
85704 +void __pax_list_add_rcu(struct list_head *new,
85705 + struct list_head *prev, struct list_head *next)
85706 +{
85707 +#ifdef CONFIG_DEBUG_LIST
85708 + if (!__list_add_debug(new, prev, next))
85709 + return;
85710 +#endif
85711 +
85712 + pax_open_kernel();
85713 + new->next = next;
85714 + new->prev = prev;
85715 + rcu_assign_pointer(list_next_rcu(prev), new);
85716 + next->prev = new;
85717 + pax_close_kernel();
85718 +}
85719 +EXPORT_SYMBOL(__pax_list_add_rcu);
85720 +
85721 +void pax_list_del_rcu(struct list_head *entry)
85722 +{
85723 +#ifdef CONFIG_DEBUG_LIST
85724 + if (!__list_del_entry_debug(entry))
85725 + return;
85726 +#endif
85727 +
85728 + pax_open_kernel();
85729 + __list_del(entry->prev, entry->next);
85730 + entry->next = LIST_POISON1;
85731 + entry->prev = LIST_POISON2;
85732 + pax_close_kernel();
85733 +}
85734 +EXPORT_SYMBOL(pax_list_del_rcu);
85735 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
85736 index 7deeb62..144eb47 100644
85737 --- a/lib/percpu-refcount.c
85738 +++ b/lib/percpu-refcount.c
85739 @@ -29,7 +29,7 @@
85740 * can't hit 0 before we've added up all the percpu refs.
85741 */
85742
85743 -#define PCPU_COUNT_BIAS (1U << 31)
85744 +#define PCPU_COUNT_BIAS (1U << 30)
85745
85746 /**
85747 * percpu_ref_init - initialize a percpu refcount
85748 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
85749 index e796429..6e38f9f 100644
85750 --- a/lib/radix-tree.c
85751 +++ b/lib/radix-tree.c
85752 @@ -92,7 +92,7 @@ struct radix_tree_preload {
85753 int nr;
85754 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
85755 };
85756 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
85757 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
85758
85759 static inline void *ptr_to_indirect(void *ptr)
85760 {
85761 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
85762 index bb2b201..46abaf9 100644
85763 --- a/lib/strncpy_from_user.c
85764 +++ b/lib/strncpy_from_user.c
85765 @@ -21,7 +21,7 @@
85766 */
85767 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
85768 {
85769 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85770 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85771 long res = 0;
85772
85773 /*
85774 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
85775 index a28df52..3d55877 100644
85776 --- a/lib/strnlen_user.c
85777 +++ b/lib/strnlen_user.c
85778 @@ -26,7 +26,7 @@
85779 */
85780 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
85781 {
85782 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85783 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85784 long align, res = 0;
85785 unsigned long c;
85786
85787 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
85788 index d23762e..e21eab2 100644
85789 --- a/lib/swiotlb.c
85790 +++ b/lib/swiotlb.c
85791 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
85792
85793 void
85794 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
85795 - dma_addr_t dev_addr)
85796 + dma_addr_t dev_addr, struct dma_attrs *attrs)
85797 {
85798 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
85799
85800 diff --git a/lib/usercopy.c b/lib/usercopy.c
85801 index 4f5b1dd..7cab418 100644
85802 --- a/lib/usercopy.c
85803 +++ b/lib/usercopy.c
85804 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
85805 WARN(1, "Buffer overflow detected!\n");
85806 }
85807 EXPORT_SYMBOL(copy_from_user_overflow);
85808 +
85809 +void copy_to_user_overflow(void)
85810 +{
85811 + WARN(1, "Buffer overflow detected!\n");
85812 +}
85813 +EXPORT_SYMBOL(copy_to_user_overflow);
85814 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
85815 index 739a363..aa668d7 100644
85816 --- a/lib/vsprintf.c
85817 +++ b/lib/vsprintf.c
85818 @@ -16,6 +16,9 @@
85819 * - scnprintf and vscnprintf
85820 */
85821
85822 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85823 +#define __INCLUDED_BY_HIDESYM 1
85824 +#endif
85825 #include <stdarg.h>
85826 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
85827 #include <linux/types.h>
85828 @@ -1078,7 +1081,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
85829 return number(buf, end, *(const netdev_features_t *)addr, spec);
85830 }
85831
85832 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85833 +int kptr_restrict __read_mostly = 2;
85834 +#else
85835 int kptr_restrict __read_mostly;
85836 +#endif
85837
85838 /*
85839 * Show a '%p' thing. A kernel extension is that the '%p' is followed
85840 @@ -1091,6 +1098,7 @@ int kptr_restrict __read_mostly;
85841 * - 'f' For simple symbolic function names without offset
85842 * - 'S' For symbolic direct pointers with offset
85843 * - 's' For symbolic direct pointers without offset
85844 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
85845 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
85846 * - 'B' For backtraced symbolic direct pointers with offset
85847 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
85848 @@ -1155,12 +1163,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85849
85850 if (!ptr && *fmt != 'K') {
85851 /*
85852 - * Print (null) with the same width as a pointer so it makes
85853 + * Print (nil) with the same width as a pointer so it makes
85854 * tabular output look nice.
85855 */
85856 if (spec.field_width == -1)
85857 spec.field_width = default_width;
85858 - return string(buf, end, "(null)", spec);
85859 + return string(buf, end, "(nil)", spec);
85860 }
85861
85862 switch (*fmt) {
85863 @@ -1170,6 +1178,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85864 /* Fallthrough */
85865 case 'S':
85866 case 's':
85867 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85868 + break;
85869 +#else
85870 + return symbol_string(buf, end, ptr, spec, fmt);
85871 +#endif
85872 + case 'A':
85873 case 'B':
85874 return symbol_string(buf, end, ptr, spec, fmt);
85875 case 'R':
85876 @@ -1225,6 +1239,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85877 va_end(va);
85878 return buf;
85879 }
85880 + case 'P':
85881 + break;
85882 case 'K':
85883 /*
85884 * %pK cannot be used in IRQ context because its test
85885 @@ -1254,6 +1270,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85886 return number(buf, end,
85887 (unsigned long long) *((phys_addr_t *)ptr), spec);
85888 }
85889 +
85890 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85891 + /* 'P' = approved pointers to copy to userland,
85892 + as in the /proc/kallsyms case, as we make it display nothing
85893 + for non-root users, and the real contents for root users
85894 + Also ignore 'K' pointers, since we force their NULLing for non-root users
85895 + above
85896 + */
85897 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
85898 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
85899 + dump_stack();
85900 + ptr = NULL;
85901 + }
85902 +#endif
85903 +
85904 spec.flags |= SMALL;
85905 if (spec.field_width == -1) {
85906 spec.field_width = default_width;
85907 @@ -1977,11 +2008,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85908 typeof(type) value; \
85909 if (sizeof(type) == 8) { \
85910 args = PTR_ALIGN(args, sizeof(u32)); \
85911 - *(u32 *)&value = *(u32 *)args; \
85912 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
85913 + *(u32 *)&value = *(const u32 *)args; \
85914 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
85915 } else { \
85916 args = PTR_ALIGN(args, sizeof(type)); \
85917 - value = *(typeof(type) *)args; \
85918 + value = *(const typeof(type) *)args; \
85919 } \
85920 args += sizeof(type); \
85921 value; \
85922 @@ -2044,7 +2075,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85923 case FORMAT_TYPE_STR: {
85924 const char *str_arg = args;
85925 args += strlen(str_arg) + 1;
85926 - str = string(str, end, (char *)str_arg, spec);
85927 + str = string(str, end, str_arg, spec);
85928 break;
85929 }
85930
85931 diff --git a/localversion-grsec b/localversion-grsec
85932 new file mode 100644
85933 index 0000000..7cd6065
85934 --- /dev/null
85935 +++ b/localversion-grsec
85936 @@ -0,0 +1 @@
85937 +-grsec
85938 diff --git a/mm/Kconfig b/mm/Kconfig
85939 index 6509d27..3c15063 100644
85940 --- a/mm/Kconfig
85941 +++ b/mm/Kconfig
85942 @@ -317,10 +317,11 @@ config KSM
85943 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
85944
85945 config DEFAULT_MMAP_MIN_ADDR
85946 - int "Low address space to protect from user allocation"
85947 + int "Low address space to protect from user allocation"
85948 depends on MMU
85949 - default 4096
85950 - help
85951 + default 32768 if ALPHA || ARM || PARISC || SPARC32
85952 + default 65536
85953 + help
85954 This is the portion of low virtual memory which should be protected
85955 from userspace allocation. Keeping a user from writing to low pages
85956 can help reduce the impact of kernel NULL pointer bugs.
85957 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
85958
85959 config HWPOISON_INJECT
85960 tristate "HWPoison pages injector"
85961 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
85962 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
85963 select PROC_PAGE_MONITOR
85964
85965 config NOMMU_INITIAL_TRIM_EXCESS
85966 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
85967 index e04454c..ca5be3e 100644
85968 --- a/mm/backing-dev.c
85969 +++ b/mm/backing-dev.c
85970 @@ -12,7 +12,7 @@
85971 #include <linux/device.h>
85972 #include <trace/events/writeback.h>
85973
85974 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
85975 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
85976
85977 struct backing_dev_info default_backing_dev_info = {
85978 .name = "default",
85979 @@ -522,7 +522,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
85980 return err;
85981
85982 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
85983 - atomic_long_inc_return(&bdi_seq));
85984 + atomic_long_inc_return_unchecked(&bdi_seq));
85985 if (err) {
85986 bdi_destroy(bdi);
85987 return err;
85988 diff --git a/mm/filemap.c b/mm/filemap.c
85989 index 4b51ac1..5aa90ff 100644
85990 --- a/mm/filemap.c
85991 +++ b/mm/filemap.c
85992 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
85993 struct address_space *mapping = file->f_mapping;
85994
85995 if (!mapping->a_ops->readpage)
85996 - return -ENOEXEC;
85997 + return -ENODEV;
85998 file_accessed(file);
85999 vma->vm_ops = &generic_file_vm_ops;
86000 return 0;
86001 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
86002
86003 while (bytes) {
86004 char __user *buf = iov->iov_base + base;
86005 - int copy = min(bytes, iov->iov_len - base);
86006 + size_t copy = min(bytes, iov->iov_len - base);
86007
86008 base = 0;
86009 left = __copy_from_user_inatomic(vaddr, buf, copy);
86010 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
86011 BUG_ON(!in_atomic());
86012 kaddr = kmap_atomic(page);
86013 if (likely(i->nr_segs == 1)) {
86014 - int left;
86015 + size_t left;
86016 char __user *buf = i->iov->iov_base + i->iov_offset;
86017 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
86018 copied = bytes - left;
86019 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
86020
86021 kaddr = kmap(page);
86022 if (likely(i->nr_segs == 1)) {
86023 - int left;
86024 + size_t left;
86025 char __user *buf = i->iov->iov_base + i->iov_offset;
86026 left = __copy_from_user(kaddr + offset, buf, bytes);
86027 copied = bytes - left;
86028 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
86029 * zero-length segments (without overruning the iovec).
86030 */
86031 while (bytes || unlikely(i->count && !iov->iov_len)) {
86032 - int copy;
86033 + size_t copy;
86034
86035 copy = min(bytes, iov->iov_len - base);
86036 BUG_ON(!i->count || i->count < copy);
86037 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
86038 *pos = i_size_read(inode);
86039
86040 if (limit != RLIM_INFINITY) {
86041 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
86042 if (*pos >= limit) {
86043 send_sig(SIGXFSZ, current, 0);
86044 return -EFBIG;
86045 diff --git a/mm/fremap.c b/mm/fremap.c
86046 index 5bff081..d8189a9 100644
86047 --- a/mm/fremap.c
86048 +++ b/mm/fremap.c
86049 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
86050 retry:
86051 vma = find_vma(mm, start);
86052
86053 +#ifdef CONFIG_PAX_SEGMEXEC
86054 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
86055 + goto out;
86056 +#endif
86057 +
86058 /*
86059 * Make sure the vma is shared, that it supports prefaulting,
86060 * and that the remapped range is valid and fully within
86061 diff --git a/mm/highmem.c b/mm/highmem.c
86062 index b32b70c..e512eb0 100644
86063 --- a/mm/highmem.c
86064 +++ b/mm/highmem.c
86065 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
86066 * So no dangers, even with speculative execution.
86067 */
86068 page = pte_page(pkmap_page_table[i]);
86069 + pax_open_kernel();
86070 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
86071 -
86072 + pax_close_kernel();
86073 set_page_address(page, NULL);
86074 need_flush = 1;
86075 }
86076 @@ -198,9 +199,11 @@ start:
86077 }
86078 }
86079 vaddr = PKMAP_ADDR(last_pkmap_nr);
86080 +
86081 + pax_open_kernel();
86082 set_pte_at(&init_mm, vaddr,
86083 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
86084 -
86085 + pax_close_kernel();
86086 pkmap_count[last_pkmap_nr] = 1;
86087 set_page_address(page, (void *)vaddr);
86088
86089 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
86090 index b60f330..ee7de7e 100644
86091 --- a/mm/hugetlb.c
86092 +++ b/mm/hugetlb.c
86093 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
86094 struct hstate *h = &default_hstate;
86095 unsigned long tmp;
86096 int ret;
86097 + ctl_table_no_const hugetlb_table;
86098
86099 tmp = h->max_huge_pages;
86100
86101 if (write && h->order >= MAX_ORDER)
86102 return -EINVAL;
86103
86104 - table->data = &tmp;
86105 - table->maxlen = sizeof(unsigned long);
86106 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86107 + hugetlb_table = *table;
86108 + hugetlb_table.data = &tmp;
86109 + hugetlb_table.maxlen = sizeof(unsigned long);
86110 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86111 if (ret)
86112 goto out;
86113
86114 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
86115 struct hstate *h = &default_hstate;
86116 unsigned long tmp;
86117 int ret;
86118 + ctl_table_no_const hugetlb_table;
86119
86120 tmp = h->nr_overcommit_huge_pages;
86121
86122 if (write && h->order >= MAX_ORDER)
86123 return -EINVAL;
86124
86125 - table->data = &tmp;
86126 - table->maxlen = sizeof(unsigned long);
86127 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86128 + hugetlb_table = *table;
86129 + hugetlb_table.data = &tmp;
86130 + hugetlb_table.maxlen = sizeof(unsigned long);
86131 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86132 if (ret)
86133 goto out;
86134
86135 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
86136 return 1;
86137 }
86138
86139 +#ifdef CONFIG_PAX_SEGMEXEC
86140 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
86141 +{
86142 + struct mm_struct *mm = vma->vm_mm;
86143 + struct vm_area_struct *vma_m;
86144 + unsigned long address_m;
86145 + pte_t *ptep_m;
86146 +
86147 + vma_m = pax_find_mirror_vma(vma);
86148 + if (!vma_m)
86149 + return;
86150 +
86151 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86152 + address_m = address + SEGMEXEC_TASK_SIZE;
86153 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
86154 + get_page(page_m);
86155 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
86156 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
86157 +}
86158 +#endif
86159 +
86160 /*
86161 * Hugetlb_cow() should be called with page lock of the original hugepage held.
86162 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
86163 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
86164 make_huge_pte(vma, new_page, 1));
86165 page_remove_rmap(old_page);
86166 hugepage_add_new_anon_rmap(new_page, vma, address);
86167 +
86168 +#ifdef CONFIG_PAX_SEGMEXEC
86169 + pax_mirror_huge_pte(vma, address, new_page);
86170 +#endif
86171 +
86172 /* Make the old page be freed below */
86173 new_page = old_page;
86174 }
86175 @@ -2821,6 +2851,10 @@ retry:
86176 && (vma->vm_flags & VM_SHARED)));
86177 set_huge_pte_at(mm, address, ptep, new_pte);
86178
86179 +#ifdef CONFIG_PAX_SEGMEXEC
86180 + pax_mirror_huge_pte(vma, address, page);
86181 +#endif
86182 +
86183 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
86184 /* Optimization, do the COW without a second fault */
86185 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
86186 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86187 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
86188 struct hstate *h = hstate_vma(vma);
86189
86190 +#ifdef CONFIG_PAX_SEGMEXEC
86191 + struct vm_area_struct *vma_m;
86192 +#endif
86193 +
86194 address &= huge_page_mask(h);
86195
86196 ptep = huge_pte_offset(mm, address);
86197 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86198 VM_FAULT_SET_HINDEX(hstate_index(h));
86199 }
86200
86201 +#ifdef CONFIG_PAX_SEGMEXEC
86202 + vma_m = pax_find_mirror_vma(vma);
86203 + if (vma_m) {
86204 + unsigned long address_m;
86205 +
86206 + if (vma->vm_start > vma_m->vm_start) {
86207 + address_m = address;
86208 + address -= SEGMEXEC_TASK_SIZE;
86209 + vma = vma_m;
86210 + h = hstate_vma(vma);
86211 + } else
86212 + address_m = address + SEGMEXEC_TASK_SIZE;
86213 +
86214 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
86215 + return VM_FAULT_OOM;
86216 + address_m &= HPAGE_MASK;
86217 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
86218 + }
86219 +#endif
86220 +
86221 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
86222 if (!ptep)
86223 return VM_FAULT_OOM;
86224 diff --git a/mm/internal.h b/mm/internal.h
86225 index 4390ac6..fc60373c 100644
86226 --- a/mm/internal.h
86227 +++ b/mm/internal.h
86228 @@ -95,6 +95,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
86229 * in mm/page_alloc.c
86230 */
86231 extern void __free_pages_bootmem(struct page *page, unsigned int order);
86232 +extern void free_compound_page(struct page *page);
86233 extern void prep_compound_page(struct page *page, unsigned long order);
86234 #ifdef CONFIG_MEMORY_FAILURE
86235 extern bool is_free_buddy_page(struct page *page);
86236 @@ -350,7 +351,7 @@ extern u32 hwpoison_filter_enable;
86237
86238 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
86239 unsigned long, unsigned long,
86240 - unsigned long, unsigned long);
86241 + unsigned long, unsigned long) __intentional_overflow(-1);
86242
86243 extern void set_pageblock_order(void);
86244 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
86245 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
86246 index c8d7f31..2dbeffd 100644
86247 --- a/mm/kmemleak.c
86248 +++ b/mm/kmemleak.c
86249 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
86250
86251 for (i = 0; i < object->trace_len; i++) {
86252 void *ptr = (void *)object->trace[i];
86253 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
86254 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
86255 }
86256 }
86257
86258 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
86259 return -ENOMEM;
86260 }
86261
86262 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
86263 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
86264 &kmemleak_fops);
86265 if (!dentry)
86266 pr_warning("Failed to create the debugfs kmemleak file\n");
86267 diff --git a/mm/maccess.c b/mm/maccess.c
86268 index d53adf9..03a24bf 100644
86269 --- a/mm/maccess.c
86270 +++ b/mm/maccess.c
86271 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
86272 set_fs(KERNEL_DS);
86273 pagefault_disable();
86274 ret = __copy_from_user_inatomic(dst,
86275 - (__force const void __user *)src, size);
86276 + (const void __force_user *)src, size);
86277 pagefault_enable();
86278 set_fs(old_fs);
86279
86280 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
86281
86282 set_fs(KERNEL_DS);
86283 pagefault_disable();
86284 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
86285 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
86286 pagefault_enable();
86287 set_fs(old_fs);
86288
86289 diff --git a/mm/madvise.c b/mm/madvise.c
86290 index 7055883..aafb1ed 100644
86291 --- a/mm/madvise.c
86292 +++ b/mm/madvise.c
86293 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
86294 pgoff_t pgoff;
86295 unsigned long new_flags = vma->vm_flags;
86296
86297 +#ifdef CONFIG_PAX_SEGMEXEC
86298 + struct vm_area_struct *vma_m;
86299 +#endif
86300 +
86301 switch (behavior) {
86302 case MADV_NORMAL:
86303 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
86304 @@ -126,6 +130,13 @@ success:
86305 /*
86306 * vm_flags is protected by the mmap_sem held in write mode.
86307 */
86308 +
86309 +#ifdef CONFIG_PAX_SEGMEXEC
86310 + vma_m = pax_find_mirror_vma(vma);
86311 + if (vma_m)
86312 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
86313 +#endif
86314 +
86315 vma->vm_flags = new_flags;
86316
86317 out:
86318 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86319 struct vm_area_struct ** prev,
86320 unsigned long start, unsigned long end)
86321 {
86322 +
86323 +#ifdef CONFIG_PAX_SEGMEXEC
86324 + struct vm_area_struct *vma_m;
86325 +#endif
86326 +
86327 *prev = vma;
86328 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
86329 return -EINVAL;
86330 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86331 zap_page_range(vma, start, end - start, &details);
86332 } else
86333 zap_page_range(vma, start, end - start, NULL);
86334 +
86335 +#ifdef CONFIG_PAX_SEGMEXEC
86336 + vma_m = pax_find_mirror_vma(vma);
86337 + if (vma_m) {
86338 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
86339 + struct zap_details details = {
86340 + .nonlinear_vma = vma_m,
86341 + .last_index = ULONG_MAX,
86342 + };
86343 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
86344 + } else
86345 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
86346 + }
86347 +#endif
86348 +
86349 return 0;
86350 }
86351
86352 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
86353 if (end < start)
86354 return error;
86355
86356 +#ifdef CONFIG_PAX_SEGMEXEC
86357 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
86358 + if (end > SEGMEXEC_TASK_SIZE)
86359 + return error;
86360 + } else
86361 +#endif
86362 +
86363 + if (end > TASK_SIZE)
86364 + return error;
86365 +
86366 error = 0;
86367 if (end == start)
86368 return error;
86369 diff --git a/mm/memcontrol.c b/mm/memcontrol.c
86370 index aa44621..99011b3 100644
86371 --- a/mm/memcontrol.c
86372 +++ b/mm/memcontrol.c
86373 @@ -2772,6 +2772,8 @@ done:
86374 return 0;
86375 nomem:
86376 *ptr = NULL;
86377 + if (gfp_mask & __GFP_NOFAIL)
86378 + return 0;
86379 return -ENOMEM;
86380 bypass:
86381 *ptr = root_mem_cgroup;
86382 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
86383 index 2c13aa7..64cbc3f 100644
86384 --- a/mm/memory-failure.c
86385 +++ b/mm/memory-failure.c
86386 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
86387
86388 int sysctl_memory_failure_recovery __read_mostly = 1;
86389
86390 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86391 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86392
86393 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
86394
86395 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
86396 pfn, t->comm, t->pid);
86397 si.si_signo = SIGBUS;
86398 si.si_errno = 0;
86399 - si.si_addr = (void *)addr;
86400 + si.si_addr = (void __user *)addr;
86401 #ifdef __ARCH_SI_TRAPNO
86402 si.si_trapno = trapno;
86403 #endif
86404 @@ -760,7 +760,7 @@ static struct page_state {
86405 unsigned long res;
86406 char *msg;
86407 int (*action)(struct page *p, unsigned long pfn);
86408 -} error_states[] = {
86409 +} __do_const error_states[] = {
86410 { reserved, reserved, "reserved kernel", me_kernel },
86411 /*
86412 * free pages are specially detected outside this table:
86413 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86414 nr_pages = 1 << compound_order(hpage);
86415 else /* normal page or thp */
86416 nr_pages = 1;
86417 - atomic_long_add(nr_pages, &num_poisoned_pages);
86418 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
86419
86420 /*
86421 * We need/can do nothing about count=0 pages.
86422 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86423 if (!PageHWPoison(hpage)
86424 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
86425 || (p != hpage && TestSetPageHWPoison(hpage))) {
86426 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86427 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86428 return 0;
86429 }
86430 set_page_hwpoison_huge_page(hpage);
86431 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86432 }
86433 if (hwpoison_filter(p)) {
86434 if (TestClearPageHWPoison(p))
86435 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86436 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86437 unlock_page(hpage);
86438 put_page(hpage);
86439 return 0;
86440 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
86441 return 0;
86442 }
86443 if (TestClearPageHWPoison(p))
86444 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86445 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86446 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
86447 return 0;
86448 }
86449 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
86450 */
86451 if (TestClearPageHWPoison(page)) {
86452 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
86453 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86454 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86455 freeit = 1;
86456 if (PageHuge(page))
86457 clear_page_hwpoison_huge_page(page);
86458 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
86459 } else {
86460 set_page_hwpoison_huge_page(hpage);
86461 dequeue_hwpoisoned_huge_page(hpage);
86462 - atomic_long_add(1 << compound_trans_order(hpage),
86463 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86464 &num_poisoned_pages);
86465 }
86466 return ret;
86467 @@ -1551,11 +1551,11 @@ int soft_offline_page(struct page *page, int flags)
86468 if (PageHuge(page)) {
86469 set_page_hwpoison_huge_page(hpage);
86470 dequeue_hwpoisoned_huge_page(hpage);
86471 - atomic_long_add(1 << compound_trans_order(hpage),
86472 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86473 &num_poisoned_pages);
86474 } else {
86475 SetPageHWPoison(page);
86476 - atomic_long_inc(&num_poisoned_pages);
86477 + atomic_long_inc_unchecked(&num_poisoned_pages);
86478 }
86479 }
86480 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
86481 @@ -1595,7 +1595,7 @@ static int __soft_offline_page(struct page *page, int flags)
86482 put_page(page);
86483 pr_info("soft_offline: %#lx: invalidated\n", pfn);
86484 SetPageHWPoison(page);
86485 - atomic_long_inc(&num_poisoned_pages);
86486 + atomic_long_inc_unchecked(&num_poisoned_pages);
86487 return 0;
86488 }
86489
86490 @@ -1640,7 +1640,7 @@ static int __soft_offline_page(struct page *page, int flags)
86491 if (!is_free_buddy_page(page))
86492 pr_info("soft offline: %#lx: page leaked\n",
86493 pfn);
86494 - atomic_long_inc(&num_poisoned_pages);
86495 + atomic_long_inc_unchecked(&num_poisoned_pages);
86496 }
86497 } else {
86498 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
86499 diff --git a/mm/memory.c b/mm/memory.c
86500 index 168a090..bfa069a 100644
86501 --- a/mm/memory.c
86502 +++ b/mm/memory.c
86503 @@ -426,6 +426,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86504 free_pte_range(tlb, pmd, addr);
86505 } while (pmd++, addr = next, addr != end);
86506
86507 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
86508 start &= PUD_MASK;
86509 if (start < floor)
86510 return;
86511 @@ -440,6 +441,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86512 pmd = pmd_offset(pud, start);
86513 pud_clear(pud);
86514 pmd_free_tlb(tlb, pmd, start);
86515 +#endif
86516 +
86517 }
86518
86519 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86520 @@ -459,6 +462,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86521 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
86522 } while (pud++, addr = next, addr != end);
86523
86524 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
86525 start &= PGDIR_MASK;
86526 if (start < floor)
86527 return;
86528 @@ -473,6 +477,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86529 pud = pud_offset(pgd, start);
86530 pgd_clear(pgd);
86531 pud_free_tlb(tlb, pud, start);
86532 +#endif
86533 +
86534 }
86535
86536 /*
86537 @@ -1647,12 +1653,6 @@ no_page_table:
86538 return page;
86539 }
86540
86541 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
86542 -{
86543 - return stack_guard_page_start(vma, addr) ||
86544 - stack_guard_page_end(vma, addr+PAGE_SIZE);
86545 -}
86546 -
86547 /**
86548 * __get_user_pages() - pin user pages in memory
86549 * @tsk: task_struct of target task
86550 @@ -1739,10 +1739,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86551
86552 i = 0;
86553
86554 - do {
86555 + while (nr_pages) {
86556 struct vm_area_struct *vma;
86557
86558 - vma = find_extend_vma(mm, start);
86559 + vma = find_vma(mm, start);
86560 if (!vma && in_gate_area(mm, start)) {
86561 unsigned long pg = start & PAGE_MASK;
86562 pgd_t *pgd;
86563 @@ -1791,7 +1791,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86564 goto next_page;
86565 }
86566
86567 - if (!vma ||
86568 + if (!vma || start < vma->vm_start ||
86569 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
86570 !(vm_flags & vma->vm_flags))
86571 return i ? : -EFAULT;
86572 @@ -1820,11 +1820,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86573 int ret;
86574 unsigned int fault_flags = 0;
86575
86576 - /* For mlock, just skip the stack guard page. */
86577 - if (foll_flags & FOLL_MLOCK) {
86578 - if (stack_guard_page(vma, start))
86579 - goto next_page;
86580 - }
86581 if (foll_flags & FOLL_WRITE)
86582 fault_flags |= FAULT_FLAG_WRITE;
86583 if (nonblocking)
86584 @@ -1904,7 +1899,7 @@ next_page:
86585 start += page_increm * PAGE_SIZE;
86586 nr_pages -= page_increm;
86587 } while (nr_pages && start < vma->vm_end);
86588 - } while (nr_pages);
86589 + }
86590 return i;
86591 }
86592 EXPORT_SYMBOL(__get_user_pages);
86593 @@ -2111,6 +2106,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
86594 page_add_file_rmap(page);
86595 set_pte_at(mm, addr, pte, mk_pte(page, prot));
86596
86597 +#ifdef CONFIG_PAX_SEGMEXEC
86598 + pax_mirror_file_pte(vma, addr, page, ptl);
86599 +#endif
86600 +
86601 retval = 0;
86602 pte_unmap_unlock(pte, ptl);
86603 return retval;
86604 @@ -2155,9 +2154,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
86605 if (!page_count(page))
86606 return -EINVAL;
86607 if (!(vma->vm_flags & VM_MIXEDMAP)) {
86608 +
86609 +#ifdef CONFIG_PAX_SEGMEXEC
86610 + struct vm_area_struct *vma_m;
86611 +#endif
86612 +
86613 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
86614 BUG_ON(vma->vm_flags & VM_PFNMAP);
86615 vma->vm_flags |= VM_MIXEDMAP;
86616 +
86617 +#ifdef CONFIG_PAX_SEGMEXEC
86618 + vma_m = pax_find_mirror_vma(vma);
86619 + if (vma_m)
86620 + vma_m->vm_flags |= VM_MIXEDMAP;
86621 +#endif
86622 +
86623 }
86624 return insert_page(vma, addr, page, vma->vm_page_prot);
86625 }
86626 @@ -2240,6 +2251,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
86627 unsigned long pfn)
86628 {
86629 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
86630 + BUG_ON(vma->vm_mirror);
86631
86632 if (addr < vma->vm_start || addr >= vma->vm_end)
86633 return -EFAULT;
86634 @@ -2487,7 +2499,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
86635
86636 BUG_ON(pud_huge(*pud));
86637
86638 - pmd = pmd_alloc(mm, pud, addr);
86639 + pmd = (mm == &init_mm) ?
86640 + pmd_alloc_kernel(mm, pud, addr) :
86641 + pmd_alloc(mm, pud, addr);
86642 if (!pmd)
86643 return -ENOMEM;
86644 do {
86645 @@ -2507,7 +2521,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
86646 unsigned long next;
86647 int err;
86648
86649 - pud = pud_alloc(mm, pgd, addr);
86650 + pud = (mm == &init_mm) ?
86651 + pud_alloc_kernel(mm, pgd, addr) :
86652 + pud_alloc(mm, pgd, addr);
86653 if (!pud)
86654 return -ENOMEM;
86655 do {
86656 @@ -2595,6 +2611,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
86657 copy_user_highpage(dst, src, va, vma);
86658 }
86659
86660 +#ifdef CONFIG_PAX_SEGMEXEC
86661 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
86662 +{
86663 + struct mm_struct *mm = vma->vm_mm;
86664 + spinlock_t *ptl;
86665 + pte_t *pte, entry;
86666 +
86667 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
86668 + entry = *pte;
86669 + if (!pte_present(entry)) {
86670 + if (!pte_none(entry)) {
86671 + BUG_ON(pte_file(entry));
86672 + free_swap_and_cache(pte_to_swp_entry(entry));
86673 + pte_clear_not_present_full(mm, address, pte, 0);
86674 + }
86675 + } else {
86676 + struct page *page;
86677 +
86678 + flush_cache_page(vma, address, pte_pfn(entry));
86679 + entry = ptep_clear_flush(vma, address, pte);
86680 + BUG_ON(pte_dirty(entry));
86681 + page = vm_normal_page(vma, address, entry);
86682 + if (page) {
86683 + update_hiwater_rss(mm);
86684 + if (PageAnon(page))
86685 + dec_mm_counter_fast(mm, MM_ANONPAGES);
86686 + else
86687 + dec_mm_counter_fast(mm, MM_FILEPAGES);
86688 + page_remove_rmap(page);
86689 + page_cache_release(page);
86690 + }
86691 + }
86692 + pte_unmap_unlock(pte, ptl);
86693 +}
86694 +
86695 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
86696 + *
86697 + * the ptl of the lower mapped page is held on entry and is not released on exit
86698 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
86699 + */
86700 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86701 +{
86702 + struct mm_struct *mm = vma->vm_mm;
86703 + unsigned long address_m;
86704 + spinlock_t *ptl_m;
86705 + struct vm_area_struct *vma_m;
86706 + pmd_t *pmd_m;
86707 + pte_t *pte_m, entry_m;
86708 +
86709 + BUG_ON(!page_m || !PageAnon(page_m));
86710 +
86711 + vma_m = pax_find_mirror_vma(vma);
86712 + if (!vma_m)
86713 + return;
86714 +
86715 + BUG_ON(!PageLocked(page_m));
86716 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86717 + address_m = address + SEGMEXEC_TASK_SIZE;
86718 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86719 + pte_m = pte_offset_map(pmd_m, address_m);
86720 + ptl_m = pte_lockptr(mm, pmd_m);
86721 + if (ptl != ptl_m) {
86722 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86723 + if (!pte_none(*pte_m))
86724 + goto out;
86725 + }
86726 +
86727 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86728 + page_cache_get(page_m);
86729 + page_add_anon_rmap(page_m, vma_m, address_m);
86730 + inc_mm_counter_fast(mm, MM_ANONPAGES);
86731 + set_pte_at(mm, address_m, pte_m, entry_m);
86732 + update_mmu_cache(vma_m, address_m, pte_m);
86733 +out:
86734 + if (ptl != ptl_m)
86735 + spin_unlock(ptl_m);
86736 + pte_unmap(pte_m);
86737 + unlock_page(page_m);
86738 +}
86739 +
86740 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86741 +{
86742 + struct mm_struct *mm = vma->vm_mm;
86743 + unsigned long address_m;
86744 + spinlock_t *ptl_m;
86745 + struct vm_area_struct *vma_m;
86746 + pmd_t *pmd_m;
86747 + pte_t *pte_m, entry_m;
86748 +
86749 + BUG_ON(!page_m || PageAnon(page_m));
86750 +
86751 + vma_m = pax_find_mirror_vma(vma);
86752 + if (!vma_m)
86753 + return;
86754 +
86755 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86756 + address_m = address + SEGMEXEC_TASK_SIZE;
86757 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86758 + pte_m = pte_offset_map(pmd_m, address_m);
86759 + ptl_m = pte_lockptr(mm, pmd_m);
86760 + if (ptl != ptl_m) {
86761 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86762 + if (!pte_none(*pte_m))
86763 + goto out;
86764 + }
86765 +
86766 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86767 + page_cache_get(page_m);
86768 + page_add_file_rmap(page_m);
86769 + inc_mm_counter_fast(mm, MM_FILEPAGES);
86770 + set_pte_at(mm, address_m, pte_m, entry_m);
86771 + update_mmu_cache(vma_m, address_m, pte_m);
86772 +out:
86773 + if (ptl != ptl_m)
86774 + spin_unlock(ptl_m);
86775 + pte_unmap(pte_m);
86776 +}
86777 +
86778 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
86779 +{
86780 + struct mm_struct *mm = vma->vm_mm;
86781 + unsigned long address_m;
86782 + spinlock_t *ptl_m;
86783 + struct vm_area_struct *vma_m;
86784 + pmd_t *pmd_m;
86785 + pte_t *pte_m, entry_m;
86786 +
86787 + vma_m = pax_find_mirror_vma(vma);
86788 + if (!vma_m)
86789 + return;
86790 +
86791 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86792 + address_m = address + SEGMEXEC_TASK_SIZE;
86793 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86794 + pte_m = pte_offset_map(pmd_m, address_m);
86795 + ptl_m = pte_lockptr(mm, pmd_m);
86796 + if (ptl != ptl_m) {
86797 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86798 + if (!pte_none(*pte_m))
86799 + goto out;
86800 + }
86801 +
86802 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
86803 + set_pte_at(mm, address_m, pte_m, entry_m);
86804 +out:
86805 + if (ptl != ptl_m)
86806 + spin_unlock(ptl_m);
86807 + pte_unmap(pte_m);
86808 +}
86809 +
86810 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
86811 +{
86812 + struct page *page_m;
86813 + pte_t entry;
86814 +
86815 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
86816 + goto out;
86817 +
86818 + entry = *pte;
86819 + page_m = vm_normal_page(vma, address, entry);
86820 + if (!page_m)
86821 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
86822 + else if (PageAnon(page_m)) {
86823 + if (pax_find_mirror_vma(vma)) {
86824 + pte_unmap_unlock(pte, ptl);
86825 + lock_page(page_m);
86826 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
86827 + if (pte_same(entry, *pte))
86828 + pax_mirror_anon_pte(vma, address, page_m, ptl);
86829 + else
86830 + unlock_page(page_m);
86831 + }
86832 + } else
86833 + pax_mirror_file_pte(vma, address, page_m, ptl);
86834 +
86835 +out:
86836 + pte_unmap_unlock(pte, ptl);
86837 +}
86838 +#endif
86839 +
86840 /*
86841 * This routine handles present pages, when users try to write
86842 * to a shared page. It is done by copying the page to a new address
86843 @@ -2811,6 +3007,12 @@ gotten:
86844 */
86845 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86846 if (likely(pte_same(*page_table, orig_pte))) {
86847 +
86848 +#ifdef CONFIG_PAX_SEGMEXEC
86849 + if (pax_find_mirror_vma(vma))
86850 + BUG_ON(!trylock_page(new_page));
86851 +#endif
86852 +
86853 if (old_page) {
86854 if (!PageAnon(old_page)) {
86855 dec_mm_counter_fast(mm, MM_FILEPAGES);
86856 @@ -2862,6 +3064,10 @@ gotten:
86857 page_remove_rmap(old_page);
86858 }
86859
86860 +#ifdef CONFIG_PAX_SEGMEXEC
86861 + pax_mirror_anon_pte(vma, address, new_page, ptl);
86862 +#endif
86863 +
86864 /* Free the old page.. */
86865 new_page = old_page;
86866 ret |= VM_FAULT_WRITE;
86867 @@ -3139,6 +3345,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86868 swap_free(entry);
86869 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
86870 try_to_free_swap(page);
86871 +
86872 +#ifdef CONFIG_PAX_SEGMEXEC
86873 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
86874 +#endif
86875 +
86876 unlock_page(page);
86877 if (page != swapcache) {
86878 /*
86879 @@ -3162,6 +3373,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86880
86881 /* No need to invalidate - it was non-present before */
86882 update_mmu_cache(vma, address, page_table);
86883 +
86884 +#ifdef CONFIG_PAX_SEGMEXEC
86885 + pax_mirror_anon_pte(vma, address, page, ptl);
86886 +#endif
86887 +
86888 unlock:
86889 pte_unmap_unlock(page_table, ptl);
86890 out:
86891 @@ -3181,40 +3397,6 @@ out_release:
86892 }
86893
86894 /*
86895 - * This is like a special single-page "expand_{down|up}wards()",
86896 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
86897 - * doesn't hit another vma.
86898 - */
86899 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
86900 -{
86901 - address &= PAGE_MASK;
86902 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
86903 - struct vm_area_struct *prev = vma->vm_prev;
86904 -
86905 - /*
86906 - * Is there a mapping abutting this one below?
86907 - *
86908 - * That's only ok if it's the same stack mapping
86909 - * that has gotten split..
86910 - */
86911 - if (prev && prev->vm_end == address)
86912 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
86913 -
86914 - expand_downwards(vma, address - PAGE_SIZE);
86915 - }
86916 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
86917 - struct vm_area_struct *next = vma->vm_next;
86918 -
86919 - /* As VM_GROWSDOWN but s/below/above/ */
86920 - if (next && next->vm_start == address + PAGE_SIZE)
86921 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
86922 -
86923 - expand_upwards(vma, address + PAGE_SIZE);
86924 - }
86925 - return 0;
86926 -}
86927 -
86928 -/*
86929 * We enter with non-exclusive mmap_sem (to exclude vma changes,
86930 * but allow concurrent faults), and pte mapped but not yet locked.
86931 * We return with mmap_sem still held, but pte unmapped and unlocked.
86932 @@ -3223,27 +3405,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86933 unsigned long address, pte_t *page_table, pmd_t *pmd,
86934 unsigned int flags)
86935 {
86936 - struct page *page;
86937 + struct page *page = NULL;
86938 spinlock_t *ptl;
86939 pte_t entry;
86940
86941 - pte_unmap(page_table);
86942 -
86943 - /* Check if we need to add a guard page to the stack */
86944 - if (check_stack_guard_page(vma, address) < 0)
86945 - return VM_FAULT_SIGBUS;
86946 -
86947 - /* Use the zero-page for reads */
86948 if (!(flags & FAULT_FLAG_WRITE)) {
86949 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
86950 vma->vm_page_prot));
86951 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86952 + ptl = pte_lockptr(mm, pmd);
86953 + spin_lock(ptl);
86954 if (!pte_none(*page_table))
86955 goto unlock;
86956 goto setpte;
86957 }
86958
86959 /* Allocate our own private page. */
86960 + pte_unmap(page_table);
86961 +
86962 if (unlikely(anon_vma_prepare(vma)))
86963 goto oom;
86964 page = alloc_zeroed_user_highpage_movable(vma, address);
86965 @@ -3267,6 +3445,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86966 if (!pte_none(*page_table))
86967 goto release;
86968
86969 +#ifdef CONFIG_PAX_SEGMEXEC
86970 + if (pax_find_mirror_vma(vma))
86971 + BUG_ON(!trylock_page(page));
86972 +#endif
86973 +
86974 inc_mm_counter_fast(mm, MM_ANONPAGES);
86975 page_add_new_anon_rmap(page, vma, address);
86976 setpte:
86977 @@ -3274,6 +3457,12 @@ setpte:
86978
86979 /* No need to invalidate - it was non-present before */
86980 update_mmu_cache(vma, address, page_table);
86981 +
86982 +#ifdef CONFIG_PAX_SEGMEXEC
86983 + if (page)
86984 + pax_mirror_anon_pte(vma, address, page, ptl);
86985 +#endif
86986 +
86987 unlock:
86988 pte_unmap_unlock(page_table, ptl);
86989 return 0;
86990 @@ -3417,6 +3606,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86991 */
86992 /* Only go through if we didn't race with anybody else... */
86993 if (likely(pte_same(*page_table, orig_pte))) {
86994 +
86995 +#ifdef CONFIG_PAX_SEGMEXEC
86996 + if (anon && pax_find_mirror_vma(vma))
86997 + BUG_ON(!trylock_page(page));
86998 +#endif
86999 +
87000 flush_icache_page(vma, page);
87001 entry = mk_pte(page, vma->vm_page_prot);
87002 if (flags & FAULT_FLAG_WRITE)
87003 @@ -3438,6 +3633,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87004
87005 /* no need to invalidate: a not-present page won't be cached */
87006 update_mmu_cache(vma, address, page_table);
87007 +
87008 +#ifdef CONFIG_PAX_SEGMEXEC
87009 + if (anon)
87010 + pax_mirror_anon_pte(vma, address, page, ptl);
87011 + else
87012 + pax_mirror_file_pte(vma, address, page, ptl);
87013 +#endif
87014 +
87015 } else {
87016 if (cow_page)
87017 mem_cgroup_uncharge_page(cow_page);
87018 @@ -3748,6 +3951,12 @@ int handle_pte_fault(struct mm_struct *mm,
87019 if (flags & FAULT_FLAG_WRITE)
87020 flush_tlb_fix_spurious_fault(vma, address);
87021 }
87022 +
87023 +#ifdef CONFIG_PAX_SEGMEXEC
87024 + pax_mirror_pte(vma, address, pte, pmd, ptl);
87025 + return 0;
87026 +#endif
87027 +
87028 unlock:
87029 pte_unmap_unlock(pte, ptl);
87030 return 0;
87031 @@ -3764,6 +3973,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87032 pmd_t *pmd;
87033 pte_t *pte;
87034
87035 +#ifdef CONFIG_PAX_SEGMEXEC
87036 + struct vm_area_struct *vma_m;
87037 +#endif
87038 +
87039 __set_current_state(TASK_RUNNING);
87040
87041 count_vm_event(PGFAULT);
87042 @@ -3775,6 +3988,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87043 if (unlikely(is_vm_hugetlb_page(vma)))
87044 return hugetlb_fault(mm, vma, address, flags);
87045
87046 +#ifdef CONFIG_PAX_SEGMEXEC
87047 + vma_m = pax_find_mirror_vma(vma);
87048 + if (vma_m) {
87049 + unsigned long address_m;
87050 + pgd_t *pgd_m;
87051 + pud_t *pud_m;
87052 + pmd_t *pmd_m;
87053 +
87054 + if (vma->vm_start > vma_m->vm_start) {
87055 + address_m = address;
87056 + address -= SEGMEXEC_TASK_SIZE;
87057 + vma = vma_m;
87058 + } else
87059 + address_m = address + SEGMEXEC_TASK_SIZE;
87060 +
87061 + pgd_m = pgd_offset(mm, address_m);
87062 + pud_m = pud_alloc(mm, pgd_m, address_m);
87063 + if (!pud_m)
87064 + return VM_FAULT_OOM;
87065 + pmd_m = pmd_alloc(mm, pud_m, address_m);
87066 + if (!pmd_m)
87067 + return VM_FAULT_OOM;
87068 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
87069 + return VM_FAULT_OOM;
87070 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
87071 + }
87072 +#endif
87073 +
87074 retry:
87075 pgd = pgd_offset(mm, address);
87076 pud = pud_alloc(mm, pgd, address);
87077 @@ -3873,6 +4114,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87078 spin_unlock(&mm->page_table_lock);
87079 return 0;
87080 }
87081 +
87082 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87083 +{
87084 + pud_t *new = pud_alloc_one(mm, address);
87085 + if (!new)
87086 + return -ENOMEM;
87087 +
87088 + smp_wmb(); /* See comment in __pte_alloc */
87089 +
87090 + spin_lock(&mm->page_table_lock);
87091 + if (pgd_present(*pgd)) /* Another has populated it */
87092 + pud_free(mm, new);
87093 + else
87094 + pgd_populate_kernel(mm, pgd, new);
87095 + spin_unlock(&mm->page_table_lock);
87096 + return 0;
87097 +}
87098 #endif /* __PAGETABLE_PUD_FOLDED */
87099
87100 #ifndef __PAGETABLE_PMD_FOLDED
87101 @@ -3903,6 +4161,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
87102 spin_unlock(&mm->page_table_lock);
87103 return 0;
87104 }
87105 +
87106 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
87107 +{
87108 + pmd_t *new = pmd_alloc_one(mm, address);
87109 + if (!new)
87110 + return -ENOMEM;
87111 +
87112 + smp_wmb(); /* See comment in __pte_alloc */
87113 +
87114 + spin_lock(&mm->page_table_lock);
87115 +#ifndef __ARCH_HAS_4LEVEL_HACK
87116 + if (pud_present(*pud)) /* Another has populated it */
87117 + pmd_free(mm, new);
87118 + else
87119 + pud_populate_kernel(mm, pud, new);
87120 +#else
87121 + if (pgd_present(*pud)) /* Another has populated it */
87122 + pmd_free(mm, new);
87123 + else
87124 + pgd_populate_kernel(mm, pud, new);
87125 +#endif /* __ARCH_HAS_4LEVEL_HACK */
87126 + spin_unlock(&mm->page_table_lock);
87127 + return 0;
87128 +}
87129 #endif /* __PAGETABLE_PMD_FOLDED */
87130
87131 #if !defined(__HAVE_ARCH_GATE_AREA)
87132 @@ -3916,7 +4198,7 @@ static int __init gate_vma_init(void)
87133 gate_vma.vm_start = FIXADDR_USER_START;
87134 gate_vma.vm_end = FIXADDR_USER_END;
87135 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
87136 - gate_vma.vm_page_prot = __P101;
87137 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
87138
87139 return 0;
87140 }
87141 @@ -4050,8 +4332,8 @@ out:
87142 return ret;
87143 }
87144
87145 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87146 - void *buf, int len, int write)
87147 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87148 + void *buf, size_t len, int write)
87149 {
87150 resource_size_t phys_addr;
87151 unsigned long prot = 0;
87152 @@ -4077,8 +4359,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
87153 * Access another process' address space as given in mm. If non-NULL, use the
87154 * given task for page fault accounting.
87155 */
87156 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87157 - unsigned long addr, void *buf, int len, int write)
87158 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87159 + unsigned long addr, void *buf, size_t len, int write)
87160 {
87161 struct vm_area_struct *vma;
87162 void *old_buf = buf;
87163 @@ -4086,7 +4368,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87164 down_read(&mm->mmap_sem);
87165 /* ignore errors, just check how much was successfully transferred */
87166 while (len) {
87167 - int bytes, ret, offset;
87168 + ssize_t bytes, ret, offset;
87169 void *maddr;
87170 struct page *page = NULL;
87171
87172 @@ -4145,8 +4427,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87173 *
87174 * The caller must hold a reference on @mm.
87175 */
87176 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87177 - void *buf, int len, int write)
87178 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
87179 + void *buf, size_t len, int write)
87180 {
87181 return __access_remote_vm(NULL, mm, addr, buf, len, write);
87182 }
87183 @@ -4156,11 +4438,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87184 * Source/target buffer must be kernel space,
87185 * Do not walk the page table directly, use get_user_pages
87186 */
87187 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
87188 - void *buf, int len, int write)
87189 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
87190 + void *buf, size_t len, int write)
87191 {
87192 struct mm_struct *mm;
87193 - int ret;
87194 + ssize_t ret;
87195
87196 mm = get_task_mm(tsk);
87197 if (!mm)
87198 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
87199 index 4baf12e..5497066 100644
87200 --- a/mm/mempolicy.c
87201 +++ b/mm/mempolicy.c
87202 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87203 unsigned long vmstart;
87204 unsigned long vmend;
87205
87206 +#ifdef CONFIG_PAX_SEGMEXEC
87207 + struct vm_area_struct *vma_m;
87208 +#endif
87209 +
87210 vma = find_vma(mm, start);
87211 if (!vma || vma->vm_start > start)
87212 return -EFAULT;
87213 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87214 err = vma_replace_policy(vma, new_pol);
87215 if (err)
87216 goto out;
87217 +
87218 +#ifdef CONFIG_PAX_SEGMEXEC
87219 + vma_m = pax_find_mirror_vma(vma);
87220 + if (vma_m) {
87221 + err = vma_replace_policy(vma_m, new_pol);
87222 + if (err)
87223 + goto out;
87224 + }
87225 +#endif
87226 +
87227 }
87228
87229 out:
87230 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
87231
87232 if (end < start)
87233 return -EINVAL;
87234 +
87235 +#ifdef CONFIG_PAX_SEGMEXEC
87236 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
87237 + if (end > SEGMEXEC_TASK_SIZE)
87238 + return -EINVAL;
87239 + } else
87240 +#endif
87241 +
87242 + if (end > TASK_SIZE)
87243 + return -EINVAL;
87244 +
87245 if (end == start)
87246 return 0;
87247
87248 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87249 */
87250 tcred = __task_cred(task);
87251 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87252 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87253 - !capable(CAP_SYS_NICE)) {
87254 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87255 rcu_read_unlock();
87256 err = -EPERM;
87257 goto out_put;
87258 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87259 goto out;
87260 }
87261
87262 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
87263 + if (mm != current->mm &&
87264 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
87265 + mmput(mm);
87266 + err = -EPERM;
87267 + goto out;
87268 + }
87269 +#endif
87270 +
87271 err = do_migrate_pages(mm, old, new,
87272 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
87273
87274 diff --git a/mm/migrate.c b/mm/migrate.c
87275 index d22f6f0..f12a8d0 100644
87276 --- a/mm/migrate.c
87277 +++ b/mm/migrate.c
87278 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
87279 */
87280 tcred = __task_cred(task);
87281 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87282 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87283 - !capable(CAP_SYS_NICE)) {
87284 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87285 rcu_read_unlock();
87286 err = -EPERM;
87287 goto out;
87288 diff --git a/mm/mlock.c b/mm/mlock.c
87289 index 79b7cf7..37472bf 100644
87290 --- a/mm/mlock.c
87291 +++ b/mm/mlock.c
87292 @@ -13,6 +13,7 @@
87293 #include <linux/pagemap.h>
87294 #include <linux/mempolicy.h>
87295 #include <linux/syscalls.h>
87296 +#include <linux/security.h>
87297 #include <linux/sched.h>
87298 #include <linux/export.h>
87299 #include <linux/rmap.h>
87300 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
87301 {
87302 unsigned long nstart, end, tmp;
87303 struct vm_area_struct * vma, * prev;
87304 - int error;
87305 + int error = 0;
87306
87307 VM_BUG_ON(start & ~PAGE_MASK);
87308 VM_BUG_ON(len != PAGE_ALIGN(len));
87309 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
87310 return -EINVAL;
87311 if (end == start)
87312 return 0;
87313 + if (end > TASK_SIZE)
87314 + return -EINVAL;
87315 +
87316 vma = find_vma(current->mm, start);
87317 if (!vma || vma->vm_start > start)
87318 return -ENOMEM;
87319 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
87320 for (nstart = start ; ; ) {
87321 vm_flags_t newflags;
87322
87323 +#ifdef CONFIG_PAX_SEGMEXEC
87324 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87325 + break;
87326 +#endif
87327 +
87328 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
87329
87330 newflags = vma->vm_flags & ~VM_LOCKED;
87331 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
87332 lock_limit >>= PAGE_SHIFT;
87333
87334 /* check against resource limits */
87335 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
87336 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
87337 error = do_mlock(start, len, 1);
87338 up_write(&current->mm->mmap_sem);
87339 @@ -500,12 +510,18 @@ static int do_mlockall(int flags)
87340 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
87341 vm_flags_t newflags;
87342
87343 +#ifdef CONFIG_PAX_SEGMEXEC
87344 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87345 + break;
87346 +#endif
87347 +
87348 newflags = vma->vm_flags & ~VM_LOCKED;
87349 if (flags & MCL_CURRENT)
87350 newflags |= VM_LOCKED;
87351
87352 /* Ignore errors */
87353 mlock_fixup(vma, &prev, vma->vm_start, vma->vm_end, newflags);
87354 + cond_resched();
87355 }
87356 out:
87357 return 0;
87358 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
87359 lock_limit >>= PAGE_SHIFT;
87360
87361 ret = -ENOMEM;
87362 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
87363 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
87364 capable(CAP_IPC_LOCK))
87365 ret = do_mlockall(flags);
87366 diff --git a/mm/mmap.c b/mm/mmap.c
87367 index f9c97d1..3468d3b 100644
87368 --- a/mm/mmap.c
87369 +++ b/mm/mmap.c
87370 @@ -36,6 +36,7 @@
87371 #include <linux/sched/sysctl.h>
87372 #include <linux/notifier.h>
87373 #include <linux/memory.h>
87374 +#include <linux/random.h>
87375
87376 #include <asm/uaccess.h>
87377 #include <asm/cacheflush.h>
87378 @@ -52,6 +53,16 @@
87379 #define arch_rebalance_pgtables(addr, len) (addr)
87380 #endif
87381
87382 +static inline void verify_mm_writelocked(struct mm_struct *mm)
87383 +{
87384 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
87385 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
87386 + up_read(&mm->mmap_sem);
87387 + BUG();
87388 + }
87389 +#endif
87390 +}
87391 +
87392 static void unmap_region(struct mm_struct *mm,
87393 struct vm_area_struct *vma, struct vm_area_struct *prev,
87394 unsigned long start, unsigned long end);
87395 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
87396 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
87397 *
87398 */
87399 -pgprot_t protection_map[16] = {
87400 +pgprot_t protection_map[16] __read_only = {
87401 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
87402 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
87403 };
87404
87405 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
87406 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
87407 {
87408 - return __pgprot(pgprot_val(protection_map[vm_flags &
87409 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
87410 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
87411 pgprot_val(arch_vm_get_page_prot(vm_flags)));
87412 +
87413 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87414 + if (!(__supported_pte_mask & _PAGE_NX) &&
87415 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
87416 + (vm_flags & (VM_READ | VM_WRITE)))
87417 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
87418 +#endif
87419 +
87420 + return prot;
87421 }
87422 EXPORT_SYMBOL(vm_get_page_prot);
87423
87424 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
87425 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
87426 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
87427 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
87428 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
87429 /*
87430 * Make sure vm_committed_as in one cacheline and not cacheline shared with
87431 * other variables. It can be updated by several CPUs frequently.
87432 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
87433 struct vm_area_struct *next = vma->vm_next;
87434
87435 might_sleep();
87436 + BUG_ON(vma->vm_mirror);
87437 if (vma->vm_ops && vma->vm_ops->close)
87438 vma->vm_ops->close(vma);
87439 if (vma->vm_file)
87440 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
87441 * not page aligned -Ram Gupta
87442 */
87443 rlim = rlimit(RLIMIT_DATA);
87444 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
87445 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
87446 (mm->end_data - mm->start_data) > rlim)
87447 goto out;
87448 @@ -933,6 +956,12 @@ static int
87449 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
87450 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87451 {
87452 +
87453 +#ifdef CONFIG_PAX_SEGMEXEC
87454 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
87455 + return 0;
87456 +#endif
87457 +
87458 if (is_mergeable_vma(vma, file, vm_flags) &&
87459 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87460 if (vma->vm_pgoff == vm_pgoff)
87461 @@ -952,6 +981,12 @@ static int
87462 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87463 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87464 {
87465 +
87466 +#ifdef CONFIG_PAX_SEGMEXEC
87467 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
87468 + return 0;
87469 +#endif
87470 +
87471 if (is_mergeable_vma(vma, file, vm_flags) &&
87472 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87473 pgoff_t vm_pglen;
87474 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87475 struct vm_area_struct *vma_merge(struct mm_struct *mm,
87476 struct vm_area_struct *prev, unsigned long addr,
87477 unsigned long end, unsigned long vm_flags,
87478 - struct anon_vma *anon_vma, struct file *file,
87479 + struct anon_vma *anon_vma, struct file *file,
87480 pgoff_t pgoff, struct mempolicy *policy)
87481 {
87482 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
87483 struct vm_area_struct *area, *next;
87484 int err;
87485
87486 +#ifdef CONFIG_PAX_SEGMEXEC
87487 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
87488 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
87489 +
87490 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
87491 +#endif
87492 +
87493 /*
87494 * We later require that vma->vm_flags == vm_flags,
87495 * so this tests vma->vm_flags & VM_SPECIAL, too.
87496 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87497 if (next && next->vm_end == end) /* cases 6, 7, 8 */
87498 next = next->vm_next;
87499
87500 +#ifdef CONFIG_PAX_SEGMEXEC
87501 + if (prev)
87502 + prev_m = pax_find_mirror_vma(prev);
87503 + if (area)
87504 + area_m = pax_find_mirror_vma(area);
87505 + if (next)
87506 + next_m = pax_find_mirror_vma(next);
87507 +#endif
87508 +
87509 /*
87510 * Can it merge with the predecessor?
87511 */
87512 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87513 /* cases 1, 6 */
87514 err = vma_adjust(prev, prev->vm_start,
87515 next->vm_end, prev->vm_pgoff, NULL);
87516 - } else /* cases 2, 5, 7 */
87517 +
87518 +#ifdef CONFIG_PAX_SEGMEXEC
87519 + if (!err && prev_m)
87520 + err = vma_adjust(prev_m, prev_m->vm_start,
87521 + next_m->vm_end, prev_m->vm_pgoff, NULL);
87522 +#endif
87523 +
87524 + } else { /* cases 2, 5, 7 */
87525 err = vma_adjust(prev, prev->vm_start,
87526 end, prev->vm_pgoff, NULL);
87527 +
87528 +#ifdef CONFIG_PAX_SEGMEXEC
87529 + if (!err && prev_m)
87530 + err = vma_adjust(prev_m, prev_m->vm_start,
87531 + end_m, prev_m->vm_pgoff, NULL);
87532 +#endif
87533 +
87534 + }
87535 if (err)
87536 return NULL;
87537 khugepaged_enter_vma_merge(prev);
87538 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87539 mpol_equal(policy, vma_policy(next)) &&
87540 can_vma_merge_before(next, vm_flags,
87541 anon_vma, file, pgoff+pglen)) {
87542 - if (prev && addr < prev->vm_end) /* case 4 */
87543 + if (prev && addr < prev->vm_end) { /* case 4 */
87544 err = vma_adjust(prev, prev->vm_start,
87545 addr, prev->vm_pgoff, NULL);
87546 - else /* cases 3, 8 */
87547 +
87548 +#ifdef CONFIG_PAX_SEGMEXEC
87549 + if (!err && prev_m)
87550 + err = vma_adjust(prev_m, prev_m->vm_start,
87551 + addr_m, prev_m->vm_pgoff, NULL);
87552 +#endif
87553 +
87554 + } else { /* cases 3, 8 */
87555 err = vma_adjust(area, addr, next->vm_end,
87556 next->vm_pgoff - pglen, NULL);
87557 +
87558 +#ifdef CONFIG_PAX_SEGMEXEC
87559 + if (!err && area_m)
87560 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
87561 + next_m->vm_pgoff - pglen, NULL);
87562 +#endif
87563 +
87564 + }
87565 if (err)
87566 return NULL;
87567 khugepaged_enter_vma_merge(area);
87568 @@ -1165,8 +1246,10 @@ none:
87569 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87570 struct file *file, long pages)
87571 {
87572 - const unsigned long stack_flags
87573 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
87574 +
87575 +#ifdef CONFIG_PAX_RANDMMAP
87576 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87577 +#endif
87578
87579 mm->total_vm += pages;
87580
87581 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87582 mm->shared_vm += pages;
87583 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
87584 mm->exec_vm += pages;
87585 - } else if (flags & stack_flags)
87586 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
87587 mm->stack_vm += pages;
87588 }
87589 #endif /* CONFIG_PROC_FS */
87590 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87591 * (the exception is when the underlying filesystem is noexec
87592 * mounted, in which case we dont add PROT_EXEC.)
87593 */
87594 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87595 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87596 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
87597 prot |= PROT_EXEC;
87598
87599 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87600 /* Obtain the address to map to. we verify (or select) it and ensure
87601 * that it represents a valid section of the address space.
87602 */
87603 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
87604 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
87605 if (addr & ~PAGE_MASK)
87606 return addr;
87607
87608 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87609 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
87610 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
87611
87612 +#ifdef CONFIG_PAX_MPROTECT
87613 + if (mm->pax_flags & MF_PAX_MPROTECT) {
87614 +
87615 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
87616 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
87617 + mm->binfmt->handle_mmap)
87618 + mm->binfmt->handle_mmap(file);
87619 +#endif
87620 +
87621 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
87622 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
87623 + gr_log_rwxmmap(file);
87624 +
87625 +#ifdef CONFIG_PAX_EMUPLT
87626 + vm_flags &= ~VM_EXEC;
87627 +#else
87628 + return -EPERM;
87629 +#endif
87630 +
87631 + }
87632 +
87633 + if (!(vm_flags & VM_EXEC))
87634 + vm_flags &= ~VM_MAYEXEC;
87635 +#else
87636 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
87637 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
87638 +#endif
87639 + else
87640 + vm_flags &= ~VM_MAYWRITE;
87641 + }
87642 +#endif
87643 +
87644 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87645 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
87646 + vm_flags &= ~VM_PAGEEXEC;
87647 +#endif
87648 +
87649 if (flags & MAP_LOCKED)
87650 if (!can_do_mlock())
87651 return -EPERM;
87652 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87653 locked += mm->locked_vm;
87654 lock_limit = rlimit(RLIMIT_MEMLOCK);
87655 lock_limit >>= PAGE_SHIFT;
87656 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87657 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
87658 return -EAGAIN;
87659 }
87660 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87661 vm_flags |= VM_NORESERVE;
87662 }
87663
87664 + if (!gr_acl_handle_mmap(file, prot))
87665 + return -EACCES;
87666 +
87667 addr = mmap_region(file, addr, len, vm_flags, pgoff);
87668 if (!IS_ERR_VALUE(addr) &&
87669 ((vm_flags & VM_LOCKED) ||
87670 @@ -1434,7 +1558,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
87671 vm_flags_t vm_flags = vma->vm_flags;
87672
87673 /* If it was private or non-writable, the write bit is already clear */
87674 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
87675 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
87676 return 0;
87677
87678 /* The backer wishes to know when pages are first written to? */
87679 @@ -1482,7 +1606,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87680 unsigned long charged = 0;
87681 struct inode *inode = file ? file_inode(file) : NULL;
87682
87683 +#ifdef CONFIG_PAX_SEGMEXEC
87684 + struct vm_area_struct *vma_m = NULL;
87685 +#endif
87686 +
87687 + /*
87688 + * mm->mmap_sem is required to protect against another thread
87689 + * changing the mappings in case we sleep.
87690 + */
87691 + verify_mm_writelocked(mm);
87692 +
87693 /* Check against address space limit. */
87694 +
87695 +#ifdef CONFIG_PAX_RANDMMAP
87696 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87697 +#endif
87698 +
87699 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
87700 unsigned long nr_pages;
87701
87702 @@ -1501,11 +1640,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87703
87704 /* Clear old maps */
87705 error = -ENOMEM;
87706 -munmap_back:
87707 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
87708 if (do_munmap(mm, addr, len))
87709 return -ENOMEM;
87710 - goto munmap_back;
87711 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
87712 }
87713
87714 /*
87715 @@ -1536,6 +1674,16 @@ munmap_back:
87716 goto unacct_error;
87717 }
87718
87719 +#ifdef CONFIG_PAX_SEGMEXEC
87720 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
87721 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87722 + if (!vma_m) {
87723 + error = -ENOMEM;
87724 + goto free_vma;
87725 + }
87726 + }
87727 +#endif
87728 +
87729 vma->vm_mm = mm;
87730 vma->vm_start = addr;
87731 vma->vm_end = addr + len;
87732 @@ -1560,6 +1708,13 @@ munmap_back:
87733 if (error)
87734 goto unmap_and_free_vma;
87735
87736 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87737 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
87738 + vma->vm_flags |= VM_PAGEEXEC;
87739 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
87740 + }
87741 +#endif
87742 +
87743 /* Can addr have changed??
87744 *
87745 * Answer: Yes, several device drivers can do it in their
87746 @@ -1598,6 +1753,11 @@ munmap_back:
87747 vma_link(mm, vma, prev, rb_link, rb_parent);
87748 file = vma->vm_file;
87749
87750 +#ifdef CONFIG_PAX_SEGMEXEC
87751 + if (vma_m)
87752 + BUG_ON(pax_mirror_vma(vma_m, vma));
87753 +#endif
87754 +
87755 /* Once vma denies write, undo our temporary denial count */
87756 if (correct_wcount)
87757 atomic_inc(&inode->i_writecount);
87758 @@ -1605,6 +1765,7 @@ out:
87759 perf_event_mmap(vma);
87760
87761 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
87762 + track_exec_limit(mm, addr, addr + len, vm_flags);
87763 if (vm_flags & VM_LOCKED) {
87764 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
87765 vma == get_gate_vma(current->mm)))
87766 @@ -1628,6 +1789,12 @@ unmap_and_free_vma:
87767 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
87768 charged = 0;
87769 free_vma:
87770 +
87771 +#ifdef CONFIG_PAX_SEGMEXEC
87772 + if (vma_m)
87773 + kmem_cache_free(vm_area_cachep, vma_m);
87774 +#endif
87775 +
87776 kmem_cache_free(vm_area_cachep, vma);
87777 unacct_error:
87778 if (charged)
87779 @@ -1635,7 +1802,63 @@ unacct_error:
87780 return error;
87781 }
87782
87783 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87784 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
87785 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
87786 +{
87787 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
87788 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
87789 +
87790 + return 0;
87791 +}
87792 +#endif
87793 +
87794 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
87795 +{
87796 + if (!vma) {
87797 +#ifdef CONFIG_STACK_GROWSUP
87798 + if (addr > sysctl_heap_stack_gap)
87799 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
87800 + else
87801 + vma = find_vma(current->mm, 0);
87802 + if (vma && (vma->vm_flags & VM_GROWSUP))
87803 + return false;
87804 +#endif
87805 + return true;
87806 + }
87807 +
87808 + if (addr + len > vma->vm_start)
87809 + return false;
87810 +
87811 + if (vma->vm_flags & VM_GROWSDOWN)
87812 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
87813 +#ifdef CONFIG_STACK_GROWSUP
87814 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
87815 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
87816 +#endif
87817 + else if (offset)
87818 + return offset <= vma->vm_start - addr - len;
87819 +
87820 + return true;
87821 +}
87822 +
87823 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
87824 +{
87825 + if (vma->vm_start < len)
87826 + return -ENOMEM;
87827 +
87828 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
87829 + if (offset <= vma->vm_start - len)
87830 + return vma->vm_start - len - offset;
87831 + else
87832 + return -ENOMEM;
87833 + }
87834 +
87835 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
87836 + return vma->vm_start - len - sysctl_heap_stack_gap;
87837 + return -ENOMEM;
87838 +}
87839 +
87840 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
87841 {
87842 /*
87843 * We implement the search by looking for an rbtree node that
87844 @@ -1683,11 +1906,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87845 }
87846 }
87847
87848 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
87849 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
87850 check_current:
87851 /* Check if current node has a suitable gap */
87852 if (gap_start > high_limit)
87853 return -ENOMEM;
87854 +
87855 + if (gap_end - gap_start > info->threadstack_offset)
87856 + gap_start += info->threadstack_offset;
87857 + else
87858 + gap_start = gap_end;
87859 +
87860 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87861 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87862 + gap_start += sysctl_heap_stack_gap;
87863 + else
87864 + gap_start = gap_end;
87865 + }
87866 + if (vma->vm_flags & VM_GROWSDOWN) {
87867 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87868 + gap_end -= sysctl_heap_stack_gap;
87869 + else
87870 + gap_end = gap_start;
87871 + }
87872 if (gap_end >= low_limit && gap_end - gap_start >= length)
87873 goto found;
87874
87875 @@ -1737,7 +1978,7 @@ found:
87876 return gap_start;
87877 }
87878
87879 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
87880 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
87881 {
87882 struct mm_struct *mm = current->mm;
87883 struct vm_area_struct *vma;
87884 @@ -1791,6 +2032,24 @@ check_current:
87885 gap_end = vma->vm_start;
87886 if (gap_end < low_limit)
87887 return -ENOMEM;
87888 +
87889 + if (gap_end - gap_start > info->threadstack_offset)
87890 + gap_end -= info->threadstack_offset;
87891 + else
87892 + gap_end = gap_start;
87893 +
87894 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87895 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87896 + gap_start += sysctl_heap_stack_gap;
87897 + else
87898 + gap_start = gap_end;
87899 + }
87900 + if (vma->vm_flags & VM_GROWSDOWN) {
87901 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87902 + gap_end -= sysctl_heap_stack_gap;
87903 + else
87904 + gap_end = gap_start;
87905 + }
87906 if (gap_start <= high_limit && gap_end - gap_start >= length)
87907 goto found;
87908
87909 @@ -1854,6 +2113,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87910 struct mm_struct *mm = current->mm;
87911 struct vm_area_struct *vma;
87912 struct vm_unmapped_area_info info;
87913 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87914
87915 if (len > TASK_SIZE)
87916 return -ENOMEM;
87917 @@ -1861,19 +2121,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87918 if (flags & MAP_FIXED)
87919 return addr;
87920
87921 +#ifdef CONFIG_PAX_RANDMMAP
87922 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87923 +#endif
87924 +
87925 if (addr) {
87926 addr = PAGE_ALIGN(addr);
87927 vma = find_vma(mm, addr);
87928 - if (TASK_SIZE - len >= addr &&
87929 - (!vma || addr + len <= vma->vm_start))
87930 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87931 return addr;
87932 }
87933
87934 info.flags = 0;
87935 info.length = len;
87936 info.low_limit = TASK_UNMAPPED_BASE;
87937 +
87938 +#ifdef CONFIG_PAX_RANDMMAP
87939 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87940 + info.low_limit += mm->delta_mmap;
87941 +#endif
87942 +
87943 info.high_limit = TASK_SIZE;
87944 info.align_mask = 0;
87945 + info.threadstack_offset = offset;
87946 return vm_unmapped_area(&info);
87947 }
87948 #endif
87949 @@ -1892,6 +2162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87950 struct mm_struct *mm = current->mm;
87951 unsigned long addr = addr0;
87952 struct vm_unmapped_area_info info;
87953 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87954
87955 /* requested length too big for entire address space */
87956 if (len > TASK_SIZE)
87957 @@ -1900,12 +2171,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87958 if (flags & MAP_FIXED)
87959 return addr;
87960
87961 +#ifdef CONFIG_PAX_RANDMMAP
87962 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87963 +#endif
87964 +
87965 /* requesting a specific address */
87966 if (addr) {
87967 addr = PAGE_ALIGN(addr);
87968 vma = find_vma(mm, addr);
87969 - if (TASK_SIZE - len >= addr &&
87970 - (!vma || addr + len <= vma->vm_start))
87971 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87972 return addr;
87973 }
87974
87975 @@ -1914,6 +2188,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87976 info.low_limit = PAGE_SIZE;
87977 info.high_limit = mm->mmap_base;
87978 info.align_mask = 0;
87979 + info.threadstack_offset = offset;
87980 addr = vm_unmapped_area(&info);
87981
87982 /*
87983 @@ -1926,6 +2201,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87984 VM_BUG_ON(addr != -ENOMEM);
87985 info.flags = 0;
87986 info.low_limit = TASK_UNMAPPED_BASE;
87987 +
87988 +#ifdef CONFIG_PAX_RANDMMAP
87989 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87990 + info.low_limit += mm->delta_mmap;
87991 +#endif
87992 +
87993 info.high_limit = TASK_SIZE;
87994 addr = vm_unmapped_area(&info);
87995 }
87996 @@ -2027,6 +2308,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
87997 return vma;
87998 }
87999
88000 +#ifdef CONFIG_PAX_SEGMEXEC
88001 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
88002 +{
88003 + struct vm_area_struct *vma_m;
88004 +
88005 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
88006 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
88007 + BUG_ON(vma->vm_mirror);
88008 + return NULL;
88009 + }
88010 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
88011 + vma_m = vma->vm_mirror;
88012 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
88013 + BUG_ON(vma->vm_file != vma_m->vm_file);
88014 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
88015 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
88016 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
88017 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
88018 + return vma_m;
88019 +}
88020 +#endif
88021 +
88022 /*
88023 * Verify that the stack growth is acceptable and
88024 * update accounting. This is shared with both the
88025 @@ -2043,6 +2346,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88026 return -ENOMEM;
88027
88028 /* Stack limit test */
88029 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
88030 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
88031 return -ENOMEM;
88032
88033 @@ -2053,6 +2357,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88034 locked = mm->locked_vm + grow;
88035 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
88036 limit >>= PAGE_SHIFT;
88037 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88038 if (locked > limit && !capable(CAP_IPC_LOCK))
88039 return -ENOMEM;
88040 }
88041 @@ -2082,37 +2387,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88042 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
88043 * vma is the last one with address > vma->vm_end. Have to extend vma.
88044 */
88045 +#ifndef CONFIG_IA64
88046 +static
88047 +#endif
88048 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88049 {
88050 int error;
88051 + bool locknext;
88052
88053 if (!(vma->vm_flags & VM_GROWSUP))
88054 return -EFAULT;
88055
88056 + /* Also guard against wrapping around to address 0. */
88057 + if (address < PAGE_ALIGN(address+1))
88058 + address = PAGE_ALIGN(address+1);
88059 + else
88060 + return -ENOMEM;
88061 +
88062 /*
88063 * We must make sure the anon_vma is allocated
88064 * so that the anon_vma locking is not a noop.
88065 */
88066 if (unlikely(anon_vma_prepare(vma)))
88067 return -ENOMEM;
88068 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
88069 + if (locknext && anon_vma_prepare(vma->vm_next))
88070 + return -ENOMEM;
88071 vma_lock_anon_vma(vma);
88072 + if (locknext)
88073 + vma_lock_anon_vma(vma->vm_next);
88074
88075 /*
88076 * vma->vm_start/vm_end cannot change under us because the caller
88077 * is required to hold the mmap_sem in read mode. We need the
88078 - * anon_vma lock to serialize against concurrent expand_stacks.
88079 - * Also guard against wrapping around to address 0.
88080 + * anon_vma locks to serialize against concurrent expand_stacks
88081 + * and expand_upwards.
88082 */
88083 - if (address < PAGE_ALIGN(address+4))
88084 - address = PAGE_ALIGN(address+4);
88085 - else {
88086 - vma_unlock_anon_vma(vma);
88087 - return -ENOMEM;
88088 - }
88089 error = 0;
88090
88091 /* Somebody else might have raced and expanded it already */
88092 - if (address > vma->vm_end) {
88093 + 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)
88094 + error = -ENOMEM;
88095 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
88096 unsigned long size, grow;
88097
88098 size = address - vma->vm_start;
88099 @@ -2147,6 +2463,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88100 }
88101 }
88102 }
88103 + if (locknext)
88104 + vma_unlock_anon_vma(vma->vm_next);
88105 vma_unlock_anon_vma(vma);
88106 khugepaged_enter_vma_merge(vma);
88107 validate_mm(vma->vm_mm);
88108 @@ -2161,6 +2479,8 @@ int expand_downwards(struct vm_area_struct *vma,
88109 unsigned long address)
88110 {
88111 int error;
88112 + bool lockprev = false;
88113 + struct vm_area_struct *prev;
88114
88115 /*
88116 * We must make sure the anon_vma is allocated
88117 @@ -2174,6 +2494,15 @@ int expand_downwards(struct vm_area_struct *vma,
88118 if (error)
88119 return error;
88120
88121 + prev = vma->vm_prev;
88122 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
88123 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
88124 +#endif
88125 + if (lockprev && anon_vma_prepare(prev))
88126 + return -ENOMEM;
88127 + if (lockprev)
88128 + vma_lock_anon_vma(prev);
88129 +
88130 vma_lock_anon_vma(vma);
88131
88132 /*
88133 @@ -2183,9 +2512,17 @@ int expand_downwards(struct vm_area_struct *vma,
88134 */
88135
88136 /* Somebody else might have raced and expanded it already */
88137 - if (address < vma->vm_start) {
88138 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
88139 + error = -ENOMEM;
88140 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
88141 unsigned long size, grow;
88142
88143 +#ifdef CONFIG_PAX_SEGMEXEC
88144 + struct vm_area_struct *vma_m;
88145 +
88146 + vma_m = pax_find_mirror_vma(vma);
88147 +#endif
88148 +
88149 size = vma->vm_end - address;
88150 grow = (vma->vm_start - address) >> PAGE_SHIFT;
88151
88152 @@ -2210,13 +2547,27 @@ int expand_downwards(struct vm_area_struct *vma,
88153 vma->vm_pgoff -= grow;
88154 anon_vma_interval_tree_post_update_vma(vma);
88155 vma_gap_update(vma);
88156 +
88157 +#ifdef CONFIG_PAX_SEGMEXEC
88158 + if (vma_m) {
88159 + anon_vma_interval_tree_pre_update_vma(vma_m);
88160 + vma_m->vm_start -= grow << PAGE_SHIFT;
88161 + vma_m->vm_pgoff -= grow;
88162 + anon_vma_interval_tree_post_update_vma(vma_m);
88163 + vma_gap_update(vma_m);
88164 + }
88165 +#endif
88166 +
88167 spin_unlock(&vma->vm_mm->page_table_lock);
88168
88169 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
88170 perf_event_mmap(vma);
88171 }
88172 }
88173 }
88174 vma_unlock_anon_vma(vma);
88175 + if (lockprev)
88176 + vma_unlock_anon_vma(prev);
88177 khugepaged_enter_vma_merge(vma);
88178 validate_mm(vma->vm_mm);
88179 return error;
88180 @@ -2314,6 +2665,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
88181 do {
88182 long nrpages = vma_pages(vma);
88183
88184 +#ifdef CONFIG_PAX_SEGMEXEC
88185 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
88186 + vma = remove_vma(vma);
88187 + continue;
88188 + }
88189 +#endif
88190 +
88191 if (vma->vm_flags & VM_ACCOUNT)
88192 nr_accounted += nrpages;
88193 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
88194 @@ -2358,6 +2716,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
88195 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
88196 vma->vm_prev = NULL;
88197 do {
88198 +
88199 +#ifdef CONFIG_PAX_SEGMEXEC
88200 + if (vma->vm_mirror) {
88201 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
88202 + vma->vm_mirror->vm_mirror = NULL;
88203 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
88204 + vma->vm_mirror = NULL;
88205 + }
88206 +#endif
88207 +
88208 vma_rb_erase(vma, &mm->mm_rb);
88209 mm->map_count--;
88210 tail_vma = vma;
88211 @@ -2384,14 +2752,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88212 struct vm_area_struct *new;
88213 int err = -ENOMEM;
88214
88215 +#ifdef CONFIG_PAX_SEGMEXEC
88216 + struct vm_area_struct *vma_m, *new_m = NULL;
88217 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
88218 +#endif
88219 +
88220 if (is_vm_hugetlb_page(vma) && (addr &
88221 ~(huge_page_mask(hstate_vma(vma)))))
88222 return -EINVAL;
88223
88224 +#ifdef CONFIG_PAX_SEGMEXEC
88225 + vma_m = pax_find_mirror_vma(vma);
88226 +#endif
88227 +
88228 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88229 if (!new)
88230 goto out_err;
88231
88232 +#ifdef CONFIG_PAX_SEGMEXEC
88233 + if (vma_m) {
88234 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88235 + if (!new_m) {
88236 + kmem_cache_free(vm_area_cachep, new);
88237 + goto out_err;
88238 + }
88239 + }
88240 +#endif
88241 +
88242 /* most fields are the same, copy all, and then fixup */
88243 *new = *vma;
88244
88245 @@ -2404,6 +2791,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88246 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
88247 }
88248
88249 +#ifdef CONFIG_PAX_SEGMEXEC
88250 + if (vma_m) {
88251 + *new_m = *vma_m;
88252 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
88253 + new_m->vm_mirror = new;
88254 + new->vm_mirror = new_m;
88255 +
88256 + if (new_below)
88257 + new_m->vm_end = addr_m;
88258 + else {
88259 + new_m->vm_start = addr_m;
88260 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
88261 + }
88262 + }
88263 +#endif
88264 +
88265 pol = mpol_dup(vma_policy(vma));
88266 if (IS_ERR(pol)) {
88267 err = PTR_ERR(pol);
88268 @@ -2426,6 +2829,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88269 else
88270 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
88271
88272 +#ifdef CONFIG_PAX_SEGMEXEC
88273 + if (!err && vma_m) {
88274 + if (anon_vma_clone(new_m, vma_m))
88275 + goto out_free_mpol;
88276 +
88277 + mpol_get(pol);
88278 + vma_set_policy(new_m, pol);
88279 +
88280 + if (new_m->vm_file)
88281 + get_file(new_m->vm_file);
88282 +
88283 + if (new_m->vm_ops && new_m->vm_ops->open)
88284 + new_m->vm_ops->open(new_m);
88285 +
88286 + if (new_below)
88287 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
88288 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
88289 + else
88290 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
88291 +
88292 + if (err) {
88293 + if (new_m->vm_ops && new_m->vm_ops->close)
88294 + new_m->vm_ops->close(new_m);
88295 + if (new_m->vm_file)
88296 + fput(new_m->vm_file);
88297 + mpol_put(pol);
88298 + }
88299 + }
88300 +#endif
88301 +
88302 /* Success. */
88303 if (!err)
88304 return 0;
88305 @@ -2435,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88306 new->vm_ops->close(new);
88307 if (new->vm_file)
88308 fput(new->vm_file);
88309 - unlink_anon_vmas(new);
88310 out_free_mpol:
88311 mpol_put(pol);
88312 out_free_vma:
88313 +
88314 +#ifdef CONFIG_PAX_SEGMEXEC
88315 + if (new_m) {
88316 + unlink_anon_vmas(new_m);
88317 + kmem_cache_free(vm_area_cachep, new_m);
88318 + }
88319 +#endif
88320 +
88321 + unlink_anon_vmas(new);
88322 kmem_cache_free(vm_area_cachep, new);
88323 out_err:
88324 return err;
88325 @@ -2451,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88326 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88327 unsigned long addr, int new_below)
88328 {
88329 +
88330 +#ifdef CONFIG_PAX_SEGMEXEC
88331 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88332 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
88333 + if (mm->map_count >= sysctl_max_map_count-1)
88334 + return -ENOMEM;
88335 + } else
88336 +#endif
88337 +
88338 if (mm->map_count >= sysctl_max_map_count)
88339 return -ENOMEM;
88340
88341 @@ -2462,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88342 * work. This now handles partial unmappings.
88343 * Jeremy Fitzhardinge <jeremy@goop.org>
88344 */
88345 +#ifdef CONFIG_PAX_SEGMEXEC
88346 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88347 {
88348 + int ret = __do_munmap(mm, start, len);
88349 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
88350 + return ret;
88351 +
88352 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
88353 +}
88354 +
88355 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88356 +#else
88357 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88358 +#endif
88359 +{
88360 unsigned long end;
88361 struct vm_area_struct *vma, *prev, *last;
88362
88363 + /*
88364 + * mm->mmap_sem is required to protect against another thread
88365 + * changing the mappings in case we sleep.
88366 + */
88367 + verify_mm_writelocked(mm);
88368 +
88369 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
88370 return -EINVAL;
88371
88372 @@ -2541,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88373 /* Fix up all other VM information */
88374 remove_vma_list(mm, vma);
88375
88376 + track_exec_limit(mm, start, end, 0UL);
88377 +
88378 return 0;
88379 }
88380
88381 @@ -2549,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
88382 int ret;
88383 struct mm_struct *mm = current->mm;
88384
88385 +
88386 +#ifdef CONFIG_PAX_SEGMEXEC
88387 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
88388 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
88389 + return -EINVAL;
88390 +#endif
88391 +
88392 down_write(&mm->mmap_sem);
88393 ret = do_munmap(mm, start, len);
88394 up_write(&mm->mmap_sem);
88395 @@ -2562,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
88396 return vm_munmap(addr, len);
88397 }
88398
88399 -static inline void verify_mm_writelocked(struct mm_struct *mm)
88400 -{
88401 -#ifdef CONFIG_DEBUG_VM
88402 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88403 - WARN_ON(1);
88404 - up_read(&mm->mmap_sem);
88405 - }
88406 -#endif
88407 -}
88408 -
88409 /*
88410 * this is really a simplified "do_mmap". it only handles
88411 * anonymous maps. eventually we may be able to do some
88412 @@ -2585,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88413 struct rb_node ** rb_link, * rb_parent;
88414 pgoff_t pgoff = addr >> PAGE_SHIFT;
88415 int error;
88416 + unsigned long charged;
88417
88418 len = PAGE_ALIGN(len);
88419 if (!len)
88420 @@ -2592,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88421
88422 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
88423
88424 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
88425 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
88426 + flags &= ~VM_EXEC;
88427 +
88428 +#ifdef CONFIG_PAX_MPROTECT
88429 + if (mm->pax_flags & MF_PAX_MPROTECT)
88430 + flags &= ~VM_MAYEXEC;
88431 +#endif
88432 +
88433 + }
88434 +#endif
88435 +
88436 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
88437 if (error & ~PAGE_MASK)
88438 return error;
88439
88440 + charged = len >> PAGE_SHIFT;
88441 +
88442 /*
88443 * mlock MCL_FUTURE?
88444 */
88445 if (mm->def_flags & VM_LOCKED) {
88446 unsigned long locked, lock_limit;
88447 - locked = len >> PAGE_SHIFT;
88448 + locked = charged;
88449 locked += mm->locked_vm;
88450 lock_limit = rlimit(RLIMIT_MEMLOCK);
88451 lock_limit >>= PAGE_SHIFT;
88452 @@ -2618,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88453 /*
88454 * Clear old maps. this also does some error checking for us
88455 */
88456 - munmap_back:
88457 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88458 if (do_munmap(mm, addr, len))
88459 return -ENOMEM;
88460 - goto munmap_back;
88461 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88462 }
88463
88464 /* Check against address space limits *after* clearing old maps... */
88465 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
88466 + if (!may_expand_vm(mm, charged))
88467 return -ENOMEM;
88468
88469 if (mm->map_count > sysctl_max_map_count)
88470 return -ENOMEM;
88471
88472 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
88473 + if (security_vm_enough_memory_mm(mm, charged))
88474 return -ENOMEM;
88475
88476 /* Can we just expand an old private anonymous mapping? */
88477 @@ -2646,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88478 */
88479 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88480 if (!vma) {
88481 - vm_unacct_memory(len >> PAGE_SHIFT);
88482 + vm_unacct_memory(charged);
88483 return -ENOMEM;
88484 }
88485
88486 @@ -2660,9 +3142,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88487 vma_link(mm, vma, prev, rb_link, rb_parent);
88488 out:
88489 perf_event_mmap(vma);
88490 - mm->total_vm += len >> PAGE_SHIFT;
88491 + mm->total_vm += charged;
88492 if (flags & VM_LOCKED)
88493 - mm->locked_vm += (len >> PAGE_SHIFT);
88494 + mm->locked_vm += charged;
88495 + track_exec_limit(mm, addr, addr + len, flags);
88496 return addr;
88497 }
88498
88499 @@ -2724,6 +3207,7 @@ void exit_mmap(struct mm_struct *mm)
88500 while (vma) {
88501 if (vma->vm_flags & VM_ACCOUNT)
88502 nr_accounted += vma_pages(vma);
88503 + vma->vm_mirror = NULL;
88504 vma = remove_vma(vma);
88505 }
88506 vm_unacct_memory(nr_accounted);
88507 @@ -2740,6 +3224,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88508 struct vm_area_struct *prev;
88509 struct rb_node **rb_link, *rb_parent;
88510
88511 +#ifdef CONFIG_PAX_SEGMEXEC
88512 + struct vm_area_struct *vma_m = NULL;
88513 +#endif
88514 +
88515 + if (security_mmap_addr(vma->vm_start))
88516 + return -EPERM;
88517 +
88518 /*
88519 * The vm_pgoff of a purely anonymous vma should be irrelevant
88520 * until its first write fault, when page's anon_vma and index
88521 @@ -2763,7 +3254,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88522 security_vm_enough_memory_mm(mm, vma_pages(vma)))
88523 return -ENOMEM;
88524
88525 +#ifdef CONFIG_PAX_SEGMEXEC
88526 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
88527 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88528 + if (!vma_m)
88529 + return -ENOMEM;
88530 + }
88531 +#endif
88532 +
88533 vma_link(mm, vma, prev, rb_link, rb_parent);
88534 +
88535 +#ifdef CONFIG_PAX_SEGMEXEC
88536 + if (vma_m)
88537 + BUG_ON(pax_mirror_vma(vma_m, vma));
88538 +#endif
88539 +
88540 return 0;
88541 }
88542
88543 @@ -2783,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88544 struct mempolicy *pol;
88545 bool faulted_in_anon_vma = true;
88546
88547 + BUG_ON(vma->vm_mirror);
88548 +
88549 /*
88550 * If anonymous vma has not yet been faulted, update new pgoff
88551 * to match new location, to increase its chance of merging.
88552 @@ -2849,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88553 return NULL;
88554 }
88555
88556 +#ifdef CONFIG_PAX_SEGMEXEC
88557 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
88558 +{
88559 + struct vm_area_struct *prev_m;
88560 + struct rb_node **rb_link_m, *rb_parent_m;
88561 + struct mempolicy *pol_m;
88562 +
88563 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
88564 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
88565 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
88566 + *vma_m = *vma;
88567 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
88568 + if (anon_vma_clone(vma_m, vma))
88569 + return -ENOMEM;
88570 + pol_m = vma_policy(vma_m);
88571 + mpol_get(pol_m);
88572 + vma_set_policy(vma_m, pol_m);
88573 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
88574 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
88575 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
88576 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
88577 + if (vma_m->vm_file)
88578 + get_file(vma_m->vm_file);
88579 + if (vma_m->vm_ops && vma_m->vm_ops->open)
88580 + vma_m->vm_ops->open(vma_m);
88581 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
88582 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
88583 + vma_m->vm_mirror = vma;
88584 + vma->vm_mirror = vma_m;
88585 + return 0;
88586 +}
88587 +#endif
88588 +
88589 /*
88590 * Return true if the calling process may expand its vm space by the passed
88591 * number of pages
88592 @@ -2860,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
88593
88594 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
88595
88596 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
88597 if (cur + npages > lim)
88598 return 0;
88599 return 1;
88600 @@ -2930,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
88601 vma->vm_start = addr;
88602 vma->vm_end = addr + len;
88603
88604 +#ifdef CONFIG_PAX_MPROTECT
88605 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88606 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88607 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
88608 + return -EPERM;
88609 + if (!(vm_flags & VM_EXEC))
88610 + vm_flags &= ~VM_MAYEXEC;
88611 +#else
88612 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88613 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88614 +#endif
88615 + else
88616 + vm_flags &= ~VM_MAYWRITE;
88617 + }
88618 +#endif
88619 +
88620 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
88621 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88622
88623 diff --git a/mm/mprotect.c b/mm/mprotect.c
88624 index 412ba2b..cb41d42 100644
88625 --- a/mm/mprotect.c
88626 +++ b/mm/mprotect.c
88627 @@ -23,10 +23,18 @@
88628 #include <linux/mmu_notifier.h>
88629 #include <linux/migrate.h>
88630 #include <linux/perf_event.h>
88631 +#include <linux/sched/sysctl.h>
88632 +
88633 +#ifdef CONFIG_PAX_MPROTECT
88634 +#include <linux/elf.h>
88635 +#include <linux/binfmts.h>
88636 +#endif
88637 +
88638 #include <asm/uaccess.h>
88639 #include <asm/pgtable.h>
88640 #include <asm/cacheflush.h>
88641 #include <asm/tlbflush.h>
88642 +#include <asm/mmu_context.h>
88643
88644 #ifndef pgprot_modify
88645 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
88646 @@ -236,6 +244,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
88647 return pages;
88648 }
88649
88650 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88651 +/* called while holding the mmap semaphor for writing except stack expansion */
88652 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
88653 +{
88654 + unsigned long oldlimit, newlimit = 0UL;
88655 +
88656 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
88657 + return;
88658 +
88659 + spin_lock(&mm->page_table_lock);
88660 + oldlimit = mm->context.user_cs_limit;
88661 + if ((prot & VM_EXEC) && oldlimit < end)
88662 + /* USER_CS limit moved up */
88663 + newlimit = end;
88664 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
88665 + /* USER_CS limit moved down */
88666 + newlimit = start;
88667 +
88668 + if (newlimit) {
88669 + mm->context.user_cs_limit = newlimit;
88670 +
88671 +#ifdef CONFIG_SMP
88672 + wmb();
88673 + cpus_clear(mm->context.cpu_user_cs_mask);
88674 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
88675 +#endif
88676 +
88677 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
88678 + }
88679 + spin_unlock(&mm->page_table_lock);
88680 + if (newlimit == end) {
88681 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
88682 +
88683 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
88684 + if (is_vm_hugetlb_page(vma))
88685 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
88686 + else
88687 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
88688 + }
88689 +}
88690 +#endif
88691 +
88692 int
88693 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88694 unsigned long start, unsigned long end, unsigned long newflags)
88695 @@ -248,11 +298,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88696 int error;
88697 int dirty_accountable = 0;
88698
88699 +#ifdef CONFIG_PAX_SEGMEXEC
88700 + struct vm_area_struct *vma_m = NULL;
88701 + unsigned long start_m, end_m;
88702 +
88703 + start_m = start + SEGMEXEC_TASK_SIZE;
88704 + end_m = end + SEGMEXEC_TASK_SIZE;
88705 +#endif
88706 +
88707 if (newflags == oldflags) {
88708 *pprev = vma;
88709 return 0;
88710 }
88711
88712 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
88713 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
88714 +
88715 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
88716 + return -ENOMEM;
88717 +
88718 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
88719 + return -ENOMEM;
88720 + }
88721 +
88722 /*
88723 * If we make a private mapping writable we increase our commit;
88724 * but (without finer accounting) cannot reduce our commit if we
88725 @@ -269,6 +337,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88726 }
88727 }
88728
88729 +#ifdef CONFIG_PAX_SEGMEXEC
88730 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
88731 + if (start != vma->vm_start) {
88732 + error = split_vma(mm, vma, start, 1);
88733 + if (error)
88734 + goto fail;
88735 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
88736 + *pprev = (*pprev)->vm_next;
88737 + }
88738 +
88739 + if (end != vma->vm_end) {
88740 + error = split_vma(mm, vma, end, 0);
88741 + if (error)
88742 + goto fail;
88743 + }
88744 +
88745 + if (pax_find_mirror_vma(vma)) {
88746 + error = __do_munmap(mm, start_m, end_m - start_m);
88747 + if (error)
88748 + goto fail;
88749 + } else {
88750 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88751 + if (!vma_m) {
88752 + error = -ENOMEM;
88753 + goto fail;
88754 + }
88755 + vma->vm_flags = newflags;
88756 + error = pax_mirror_vma(vma_m, vma);
88757 + if (error) {
88758 + vma->vm_flags = oldflags;
88759 + goto fail;
88760 + }
88761 + }
88762 + }
88763 +#endif
88764 +
88765 /*
88766 * First try to merge with previous and/or next vma.
88767 */
88768 @@ -299,9 +403,21 @@ success:
88769 * vm_flags and vm_page_prot are protected by the mmap_sem
88770 * held in write mode.
88771 */
88772 +
88773 +#ifdef CONFIG_PAX_SEGMEXEC
88774 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
88775 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
88776 +#endif
88777 +
88778 vma->vm_flags = newflags;
88779 +
88780 +#ifdef CONFIG_PAX_MPROTECT
88781 + if (mm->binfmt && mm->binfmt->handle_mprotect)
88782 + mm->binfmt->handle_mprotect(vma, newflags);
88783 +#endif
88784 +
88785 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
88786 - vm_get_page_prot(newflags));
88787 + vm_get_page_prot(vma->vm_flags));
88788
88789 if (vma_wants_writenotify(vma)) {
88790 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
88791 @@ -340,6 +456,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88792 end = start + len;
88793 if (end <= start)
88794 return -ENOMEM;
88795 +
88796 +#ifdef CONFIG_PAX_SEGMEXEC
88797 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88798 + if (end > SEGMEXEC_TASK_SIZE)
88799 + return -EINVAL;
88800 + } else
88801 +#endif
88802 +
88803 + if (end > TASK_SIZE)
88804 + return -EINVAL;
88805 +
88806 if (!arch_validate_prot(prot))
88807 return -EINVAL;
88808
88809 @@ -347,7 +474,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88810 /*
88811 * Does the application expect PROT_READ to imply PROT_EXEC:
88812 */
88813 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88814 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88815 prot |= PROT_EXEC;
88816
88817 vm_flags = calc_vm_prot_bits(prot);
88818 @@ -379,6 +506,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88819 if (start > vma->vm_start)
88820 prev = vma;
88821
88822 +#ifdef CONFIG_PAX_MPROTECT
88823 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
88824 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
88825 +#endif
88826 +
88827 for (nstart = start ; ; ) {
88828 unsigned long newflags;
88829
88830 @@ -389,6 +521,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88831
88832 /* newflags >> 4 shift VM_MAY% in place of VM_% */
88833 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
88834 + if (prot & (PROT_WRITE | PROT_EXEC))
88835 + gr_log_rwxmprotect(vma);
88836 +
88837 + error = -EACCES;
88838 + goto out;
88839 + }
88840 +
88841 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
88842 error = -EACCES;
88843 goto out;
88844 }
88845 @@ -403,6 +543,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88846 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
88847 if (error)
88848 goto out;
88849 +
88850 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
88851 +
88852 nstart = tmp;
88853
88854 if (nstart < prev->vm_end)
88855 diff --git a/mm/mremap.c b/mm/mremap.c
88856 index 0843feb..4f5b2e6 100644
88857 --- a/mm/mremap.c
88858 +++ b/mm/mremap.c
88859 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
88860 continue;
88861 pte = ptep_get_and_clear(mm, old_addr, old_pte);
88862 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
88863 +
88864 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88865 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
88866 + pte = pte_exprotect(pte);
88867 +#endif
88868 +
88869 pte = move_soft_dirty_pte(pte);
88870 set_pte_at(mm, new_addr, new_pte, pte);
88871 }
88872 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
88873 if (is_vm_hugetlb_page(vma))
88874 goto Einval;
88875
88876 +#ifdef CONFIG_PAX_SEGMEXEC
88877 + if (pax_find_mirror_vma(vma))
88878 + goto Einval;
88879 +#endif
88880 +
88881 /* We can't remap across vm area boundaries */
88882 if (old_len > vma->vm_end - addr)
88883 goto Efault;
88884 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
88885 unsigned long ret = -EINVAL;
88886 unsigned long charged = 0;
88887 unsigned long map_flags;
88888 + unsigned long pax_task_size = TASK_SIZE;
88889
88890 if (new_addr & ~PAGE_MASK)
88891 goto out;
88892
88893 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
88894 +#ifdef CONFIG_PAX_SEGMEXEC
88895 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88896 + pax_task_size = SEGMEXEC_TASK_SIZE;
88897 +#endif
88898 +
88899 + pax_task_size -= PAGE_SIZE;
88900 +
88901 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
88902 goto out;
88903
88904 /* Check if the location we're moving into overlaps the
88905 * old location at all, and fail if it does.
88906 */
88907 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
88908 - goto out;
88909 -
88910 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
88911 + if (addr + old_len > new_addr && new_addr + new_len > addr)
88912 goto out;
88913
88914 ret = do_munmap(mm, new_addr, new_len);
88915 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88916 unsigned long ret = -EINVAL;
88917 unsigned long charged = 0;
88918 bool locked = false;
88919 + unsigned long pax_task_size = TASK_SIZE;
88920
88921 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
88922 return ret;
88923 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88924 if (!new_len)
88925 return ret;
88926
88927 +#ifdef CONFIG_PAX_SEGMEXEC
88928 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88929 + pax_task_size = SEGMEXEC_TASK_SIZE;
88930 +#endif
88931 +
88932 + pax_task_size -= PAGE_SIZE;
88933 +
88934 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
88935 + old_len > pax_task_size || addr > pax_task_size-old_len)
88936 + return ret;
88937 +
88938 down_write(&current->mm->mmap_sem);
88939
88940 if (flags & MREMAP_FIXED) {
88941 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88942 new_addr = addr;
88943 }
88944 ret = addr;
88945 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
88946 goto out;
88947 }
88948 }
88949 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88950 goto out;
88951 }
88952
88953 + map_flags = vma->vm_flags;
88954 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
88955 + if (!(ret & ~PAGE_MASK)) {
88956 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
88957 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
88958 + }
88959 }
88960 out:
88961 if (ret & ~PAGE_MASK)
88962 diff --git a/mm/nommu.c b/mm/nommu.c
88963 index ecd1f15..77039bd 100644
88964 --- a/mm/nommu.c
88965 +++ b/mm/nommu.c
88966 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
88967 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
88968 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88969 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88970 -int heap_stack_gap = 0;
88971
88972 atomic_long_t mmap_pages_allocated;
88973
88974 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
88975 EXPORT_SYMBOL(find_vma);
88976
88977 /*
88978 - * find a VMA
88979 - * - we don't extend stack VMAs under NOMMU conditions
88980 - */
88981 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
88982 -{
88983 - return find_vma(mm, addr);
88984 -}
88985 -
88986 -/*
88987 * expand a stack to a given address
88988 * - not supported under NOMMU conditions
88989 */
88990 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88991
88992 /* most fields are the same, copy all, and then fixup */
88993 *new = *vma;
88994 + INIT_LIST_HEAD(&new->anon_vma_chain);
88995 *region = *vma->vm_region;
88996 new->vm_region = region;
88997
88998 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
88999 }
89000 EXPORT_SYMBOL(generic_file_remap_pages);
89001
89002 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89003 - unsigned long addr, void *buf, int len, int write)
89004 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89005 + unsigned long addr, void *buf, size_t len, int write)
89006 {
89007 struct vm_area_struct *vma;
89008
89009 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89010 *
89011 * The caller must hold a reference on @mm.
89012 */
89013 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89014 - void *buf, int len, int write)
89015 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
89016 + void *buf, size_t len, int write)
89017 {
89018 return __access_remote_vm(NULL, mm, addr, buf, len, write);
89019 }
89020 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89021 * Access another process' address space.
89022 * - source/target buffer must be kernel space
89023 */
89024 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
89025 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
89026 {
89027 struct mm_struct *mm;
89028
89029 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
89030 index 241a746..41cd05d 100644
89031 --- a/mm/page-writeback.c
89032 +++ b/mm/page-writeback.c
89033 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
89034 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
89035 * - the bdi dirty thresh drops quickly due to change of JBOD workload
89036 */
89037 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
89038 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
89039 unsigned long thresh,
89040 unsigned long bg_thresh,
89041 unsigned long dirty,
89042 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
89043 index b100255..54b13c5 100644
89044 --- a/mm/page_alloc.c
89045 +++ b/mm/page_alloc.c
89046 @@ -60,6 +60,7 @@
89047 #include <linux/page-debug-flags.h>
89048 #include <linux/hugetlb.h>
89049 #include <linux/sched/rt.h>
89050 +#include <linux/random.h>
89051
89052 #include <asm/sections.h>
89053 #include <asm/tlbflush.h>
89054 @@ -353,7 +354,7 @@ out:
89055 * This usage means that zero-order pages may not be compound.
89056 */
89057
89058 -static void free_compound_page(struct page *page)
89059 +void free_compound_page(struct page *page)
89060 {
89061 __free_pages_ok(page, compound_order(page));
89062 }
89063 @@ -710,6 +711,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89064 int i;
89065 int bad = 0;
89066
89067 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89068 + unsigned long index = 1UL << order;
89069 +#endif
89070 +
89071 trace_mm_page_free(page, order);
89072 kmemcheck_free_shadow(page, order);
89073
89074 @@ -725,6 +730,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89075 debug_check_no_obj_freed(page_address(page),
89076 PAGE_SIZE << order);
89077 }
89078 +
89079 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89080 + for (; index; --index)
89081 + sanitize_highpage(page + index - 1);
89082 +#endif
89083 +
89084 arch_free_page(page, order);
89085 kernel_map_pages(page, 1 << order, 0);
89086
89087 @@ -747,6 +758,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
89088 local_irq_restore(flags);
89089 }
89090
89091 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89092 +bool __meminitdata extra_latent_entropy;
89093 +
89094 +static int __init setup_pax_extra_latent_entropy(char *str)
89095 +{
89096 + extra_latent_entropy = true;
89097 + return 0;
89098 +}
89099 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
89100 +
89101 +volatile u64 latent_entropy __latent_entropy;
89102 +EXPORT_SYMBOL(latent_entropy);
89103 +#endif
89104 +
89105 void __init __free_pages_bootmem(struct page *page, unsigned int order)
89106 {
89107 unsigned int nr_pages = 1 << order;
89108 @@ -762,6 +787,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
89109 set_page_count(p, 0);
89110 }
89111
89112 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89113 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
89114 + u64 hash = 0;
89115 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
89116 + const u64 *data = lowmem_page_address(page);
89117 +
89118 + for (index = 0; index < end; index++)
89119 + hash ^= hash + data[index];
89120 + latent_entropy ^= hash;
89121 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
89122 + }
89123 +#endif
89124 +
89125 page_zone(page)->managed_pages += 1 << order;
89126 set_page_refcounted(page);
89127 __free_pages(page, order);
89128 @@ -867,8 +905,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
89129 arch_alloc_page(page, order);
89130 kernel_map_pages(page, 1 << order, 1);
89131
89132 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
89133 if (gfp_flags & __GFP_ZERO)
89134 prep_zero_page(page, order, gfp_flags);
89135 +#endif
89136
89137 if (order && (gfp_flags & __GFP_COMP))
89138 prep_compound_page(page, order);
89139 diff --git a/mm/page_io.c b/mm/page_io.c
89140 index ba05b64..ef2f314 100644
89141 --- a/mm/page_io.c
89142 +++ b/mm/page_io.c
89143 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
89144 struct file *swap_file = sis->swap_file;
89145 struct address_space *mapping = swap_file->f_mapping;
89146 struct iovec iov = {
89147 - .iov_base = kmap(page),
89148 + .iov_base = (void __force_user *)kmap(page),
89149 .iov_len = PAGE_SIZE,
89150 };
89151
89152 diff --git a/mm/percpu.c b/mm/percpu.c
89153 index 8c8e08f..73a5cda 100644
89154 --- a/mm/percpu.c
89155 +++ b/mm/percpu.c
89156 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
89157 static unsigned int pcpu_high_unit_cpu __read_mostly;
89158
89159 /* the address of the first chunk which starts with the kernel static area */
89160 -void *pcpu_base_addr __read_mostly;
89161 +void *pcpu_base_addr __read_only;
89162 EXPORT_SYMBOL_GPL(pcpu_base_addr);
89163
89164 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
89165 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
89166 index fd26d04..0cea1b0 100644
89167 --- a/mm/process_vm_access.c
89168 +++ b/mm/process_vm_access.c
89169 @@ -13,6 +13,7 @@
89170 #include <linux/uio.h>
89171 #include <linux/sched.h>
89172 #include <linux/highmem.h>
89173 +#include <linux/security.h>
89174 #include <linux/ptrace.h>
89175 #include <linux/slab.h>
89176 #include <linux/syscalls.h>
89177 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89178 size_t iov_l_curr_offset = 0;
89179 ssize_t iov_len;
89180
89181 + return -ENOSYS; // PaX: until properly audited
89182 +
89183 /*
89184 * Work out how many pages of struct pages we're going to need
89185 * when eventually calling get_user_pages
89186 */
89187 for (i = 0; i < riovcnt; i++) {
89188 iov_len = rvec[i].iov_len;
89189 - if (iov_len > 0) {
89190 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
89191 - + iov_len)
89192 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
89193 - / PAGE_SIZE + 1;
89194 - nr_pages = max(nr_pages, nr_pages_iov);
89195 - }
89196 + if (iov_len <= 0)
89197 + continue;
89198 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
89199 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
89200 + nr_pages = max(nr_pages, nr_pages_iov);
89201 }
89202
89203 if (nr_pages == 0)
89204 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89205 goto free_proc_pages;
89206 }
89207
89208 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
89209 + rc = -EPERM;
89210 + goto put_task_struct;
89211 + }
89212 +
89213 mm = mm_access(task, PTRACE_MODE_ATTACH);
89214 if (!mm || IS_ERR(mm)) {
89215 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
89216 diff --git a/mm/rmap.c b/mm/rmap.c
89217 index b2e29ac..4168491 100644
89218 --- a/mm/rmap.c
89219 +++ b/mm/rmap.c
89220 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89221 struct anon_vma *anon_vma = vma->anon_vma;
89222 struct anon_vma_chain *avc;
89223
89224 +#ifdef CONFIG_PAX_SEGMEXEC
89225 + struct anon_vma_chain *avc_m = NULL;
89226 +#endif
89227 +
89228 might_sleep();
89229 if (unlikely(!anon_vma)) {
89230 struct mm_struct *mm = vma->vm_mm;
89231 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89232 if (!avc)
89233 goto out_enomem;
89234
89235 +#ifdef CONFIG_PAX_SEGMEXEC
89236 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
89237 + if (!avc_m)
89238 + goto out_enomem_free_avc;
89239 +#endif
89240 +
89241 anon_vma = find_mergeable_anon_vma(vma);
89242 allocated = NULL;
89243 if (!anon_vma) {
89244 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89245 /* page_table_lock to protect against threads */
89246 spin_lock(&mm->page_table_lock);
89247 if (likely(!vma->anon_vma)) {
89248 +
89249 +#ifdef CONFIG_PAX_SEGMEXEC
89250 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
89251 +
89252 + if (vma_m) {
89253 + BUG_ON(vma_m->anon_vma);
89254 + vma_m->anon_vma = anon_vma;
89255 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
89256 + avc_m = NULL;
89257 + }
89258 +#endif
89259 +
89260 vma->anon_vma = anon_vma;
89261 anon_vma_chain_link(vma, avc, anon_vma);
89262 allocated = NULL;
89263 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89264
89265 if (unlikely(allocated))
89266 put_anon_vma(allocated);
89267 +
89268 +#ifdef CONFIG_PAX_SEGMEXEC
89269 + if (unlikely(avc_m))
89270 + anon_vma_chain_free(avc_m);
89271 +#endif
89272 +
89273 if (unlikely(avc))
89274 anon_vma_chain_free(avc);
89275 }
89276 return 0;
89277
89278 out_enomem_free_avc:
89279 +
89280 +#ifdef CONFIG_PAX_SEGMEXEC
89281 + if (avc_m)
89282 + anon_vma_chain_free(avc_m);
89283 +#endif
89284 +
89285 anon_vma_chain_free(avc);
89286 out_enomem:
89287 return -ENOMEM;
89288 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
89289 * Attach the anon_vmas from src to dst.
89290 * Returns 0 on success, -ENOMEM on failure.
89291 */
89292 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89293 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
89294 {
89295 struct anon_vma_chain *avc, *pavc;
89296 struct anon_vma *root = NULL;
89297 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89298 * the corresponding VMA in the parent process is attached to.
89299 * Returns 0 on success, non-zero on failure.
89300 */
89301 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
89302 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
89303 {
89304 struct anon_vma_chain *avc;
89305 struct anon_vma *anon_vma;
89306 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
89307 void __init anon_vma_init(void)
89308 {
89309 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
89310 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
89311 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
89312 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
89313 + anon_vma_ctor);
89314 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
89315 + SLAB_PANIC|SLAB_NO_SANITIZE);
89316 }
89317
89318 /*
89319 diff --git a/mm/shmem.c b/mm/shmem.c
89320 index e43dc55..930e3a2 100644
89321 --- a/mm/shmem.c
89322 +++ b/mm/shmem.c
89323 @@ -33,7 +33,7 @@
89324 #include <linux/swap.h>
89325 #include <linux/aio.h>
89326
89327 -static struct vfsmount *shm_mnt;
89328 +struct vfsmount *shm_mnt;
89329
89330 #ifdef CONFIG_SHMEM
89331 /*
89332 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
89333 #define BOGO_DIRENT_SIZE 20
89334
89335 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
89336 -#define SHORT_SYMLINK_LEN 128
89337 +#define SHORT_SYMLINK_LEN 64
89338
89339 /*
89340 * shmem_fallocate and shmem_writepage communicate via inode->i_private
89341 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
89342 static int shmem_xattr_validate(const char *name)
89343 {
89344 struct { const char *prefix; size_t len; } arr[] = {
89345 +
89346 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89347 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
89348 +#endif
89349 +
89350 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
89351 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
89352 };
89353 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
89354 if (err)
89355 return err;
89356
89357 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89358 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
89359 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
89360 + return -EOPNOTSUPP;
89361 + if (size > 8)
89362 + return -EINVAL;
89363 + }
89364 +#endif
89365 +
89366 return simple_xattr_set(&info->xattrs, name, value, size, flags);
89367 }
89368
89369 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
89370 int err = -ENOMEM;
89371
89372 /* Round up to L1_CACHE_BYTES to resist false sharing */
89373 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
89374 - L1_CACHE_BYTES), GFP_KERNEL);
89375 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
89376 if (!sbinfo)
89377 return -ENOMEM;
89378
89379 diff --git a/mm/slab.c b/mm/slab.c
89380 index 2580db0..0523956 100644
89381 --- a/mm/slab.c
89382 +++ b/mm/slab.c
89383 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89384 if ((x)->max_freeable < i) \
89385 (x)->max_freeable = i; \
89386 } while (0)
89387 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
89388 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
89389 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
89390 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
89391 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
89392 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
89393 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
89394 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
89395 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
89396 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
89397 #else
89398 #define STATS_INC_ACTIVE(x) do { } while (0)
89399 #define STATS_DEC_ACTIVE(x) do { } while (0)
89400 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89401 #define STATS_INC_ALLOCMISS(x) do { } while (0)
89402 #define STATS_INC_FREEHIT(x) do { } while (0)
89403 #define STATS_INC_FREEMISS(x) do { } while (0)
89404 +#define STATS_INC_SANITIZED(x) do { } while (0)
89405 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
89406 #endif
89407
89408 #if DEBUG
89409 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
89410 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
89411 */
89412 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
89413 - const struct slab *slab, void *obj)
89414 + const struct slab *slab, const void *obj)
89415 {
89416 u32 offset = (obj - slab->s_mem);
89417 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
89418 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
89419 */
89420
89421 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
89422 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
89423 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89424
89425 if (INDEX_AC != INDEX_NODE)
89426 kmalloc_caches[INDEX_NODE] =
89427 create_kmalloc_cache("kmalloc-node",
89428 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
89429 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89430
89431 slab_early_init = 0;
89432
89433 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
89434 struct array_cache *ac = cpu_cache_get(cachep);
89435
89436 check_irq_off();
89437 +
89438 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89439 + if (pax_sanitize_slab) {
89440 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
89441 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
89442 +
89443 + if (cachep->ctor)
89444 + cachep->ctor(objp);
89445 +
89446 + STATS_INC_SANITIZED(cachep);
89447 + } else
89448 + STATS_INC_NOT_SANITIZED(cachep);
89449 + }
89450 +#endif
89451 +
89452 kmemleak_free_recursive(objp, cachep->flags);
89453 objp = cache_free_debugcheck(cachep, objp, caller);
89454
89455 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
89456
89457 if (unlikely(ZERO_OR_NULL_PTR(objp)))
89458 return;
89459 + VM_BUG_ON(!virt_addr_valid(objp));
89460 local_irq_save(flags);
89461 kfree_debugcheck(objp);
89462 c = virt_to_cache(objp);
89463 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
89464 }
89465 /* cpu stats */
89466 {
89467 - unsigned long allochit = atomic_read(&cachep->allochit);
89468 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
89469 - unsigned long freehit = atomic_read(&cachep->freehit);
89470 - unsigned long freemiss = atomic_read(&cachep->freemiss);
89471 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
89472 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
89473 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
89474 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
89475
89476 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
89477 allochit, allocmiss, freehit, freemiss);
89478 }
89479 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89480 + {
89481 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
89482 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
89483 +
89484 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
89485 + }
89486 +#endif
89487 #endif
89488 }
89489
89490 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
89491 static int __init slab_proc_init(void)
89492 {
89493 #ifdef CONFIG_DEBUG_SLAB_LEAK
89494 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
89495 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
89496 #endif
89497 return 0;
89498 }
89499 module_init(slab_proc_init);
89500 #endif
89501
89502 +bool is_usercopy_object(const void *ptr)
89503 +{
89504 + struct page *page;
89505 + struct kmem_cache *cachep;
89506 +
89507 + if (ZERO_OR_NULL_PTR(ptr))
89508 + return false;
89509 +
89510 + if (!slab_is_available())
89511 + return false;
89512 +
89513 + if (!virt_addr_valid(ptr))
89514 + return false;
89515 +
89516 + page = virt_to_head_page(ptr);
89517 +
89518 + if (!PageSlab(page))
89519 + return false;
89520 +
89521 + cachep = page->slab_cache;
89522 + return cachep->flags & SLAB_USERCOPY;
89523 +}
89524 +
89525 +#ifdef CONFIG_PAX_USERCOPY
89526 +const char *check_heap_object(const void *ptr, unsigned long n)
89527 +{
89528 + struct page *page;
89529 + struct kmem_cache *cachep;
89530 + struct slab *slabp;
89531 + unsigned int objnr;
89532 + unsigned long offset;
89533 +
89534 + if (ZERO_OR_NULL_PTR(ptr))
89535 + return "<null>";
89536 +
89537 + if (!virt_addr_valid(ptr))
89538 + return NULL;
89539 +
89540 + page = virt_to_head_page(ptr);
89541 +
89542 + if (!PageSlab(page))
89543 + return NULL;
89544 +
89545 + cachep = page->slab_cache;
89546 + if (!(cachep->flags & SLAB_USERCOPY))
89547 + return cachep->name;
89548 +
89549 + slabp = page->slab_page;
89550 + objnr = obj_to_index(cachep, slabp, ptr);
89551 + BUG_ON(objnr >= cachep->num);
89552 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
89553 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
89554 + return NULL;
89555 +
89556 + return cachep->name;
89557 +}
89558 +#endif
89559 +
89560 /**
89561 * ksize - get the actual amount of memory allocated for a given object
89562 * @objp: Pointer to the object
89563 diff --git a/mm/slab.h b/mm/slab.h
89564 index a535033..2f98fe5 100644
89565 --- a/mm/slab.h
89566 +++ b/mm/slab.h
89567 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
89568 /* The slab cache that manages slab cache information */
89569 extern struct kmem_cache *kmem_cache;
89570
89571 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89572 +#ifdef CONFIG_X86_64
89573 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
89574 +#else
89575 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
89576 +#endif
89577 +extern bool pax_sanitize_slab;
89578 +#endif
89579 +
89580 unsigned long calculate_alignment(unsigned long flags,
89581 unsigned long align, unsigned long size);
89582
89583 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89584
89585 /* Legal flag mask for kmem_cache_create(), for various configurations */
89586 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
89587 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
89588 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
89589 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
89590
89591 #if defined(CONFIG_DEBUG_SLAB)
89592 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
89593 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
89594 return s;
89595
89596 page = virt_to_head_page(x);
89597 +
89598 + BUG_ON(!PageSlab(page));
89599 +
89600 cachep = page->slab_cache;
89601 if (slab_equal_or_root(cachep, s))
89602 return cachep;
89603 diff --git a/mm/slab_common.c b/mm/slab_common.c
89604 index 538bade..36fed99 100644
89605 --- a/mm/slab_common.c
89606 +++ b/mm/slab_common.c
89607 @@ -22,11 +22,22 @@
89608
89609 #include "slab.h"
89610
89611 -enum slab_state slab_state;
89612 +enum slab_state slab_state __read_only;
89613 LIST_HEAD(slab_caches);
89614 DEFINE_MUTEX(slab_mutex);
89615 struct kmem_cache *kmem_cache;
89616
89617 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89618 +bool pax_sanitize_slab __read_only = true;
89619 +static int __init pax_sanitize_slab_setup(char *str)
89620 +{
89621 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
89622 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
89623 + return 1;
89624 +}
89625 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
89626 +#endif
89627 +
89628 #ifdef CONFIG_DEBUG_VM
89629 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
89630 size_t size)
89631 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
89632
89633 err = __kmem_cache_create(s, flags);
89634 if (!err) {
89635 - s->refcount = 1;
89636 + atomic_set(&s->refcount, 1);
89637 list_add(&s->list, &slab_caches);
89638 memcg_cache_list_add(memcg, s);
89639 } else {
89640 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
89641
89642 get_online_cpus();
89643 mutex_lock(&slab_mutex);
89644 - s->refcount--;
89645 - if (!s->refcount) {
89646 + if (atomic_dec_and_test(&s->refcount)) {
89647 list_del(&s->list);
89648
89649 if (!__kmem_cache_shutdown(s)) {
89650 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
89651 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
89652 name, size, err);
89653
89654 - s->refcount = -1; /* Exempt from merging for now */
89655 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
89656 }
89657
89658 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89659 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89660
89661 create_boot_cache(s, name, size, flags);
89662 list_add(&s->list, &slab_caches);
89663 - s->refcount = 1;
89664 + atomic_set(&s->refcount, 1);
89665 return s;
89666 }
89667
89668 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
89669 EXPORT_SYMBOL(kmalloc_dma_caches);
89670 #endif
89671
89672 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89673 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
89674 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
89675 +#endif
89676 +
89677 /*
89678 * Conversion table for small slabs sizes / 8 to the index in the
89679 * kmalloc array. This is necessary for slabs < 192 since we have non power
89680 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
89681 return kmalloc_dma_caches[index];
89682
89683 #endif
89684 +
89685 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89686 + if (unlikely((flags & GFP_USERCOPY)))
89687 + return kmalloc_usercopy_caches[index];
89688 +
89689 +#endif
89690 +
89691 return kmalloc_caches[index];
89692 }
89693
89694 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
89695 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
89696 if (!kmalloc_caches[i]) {
89697 kmalloc_caches[i] = create_kmalloc_cache(NULL,
89698 - 1 << i, flags);
89699 + 1 << i, SLAB_USERCOPY | flags);
89700 }
89701
89702 /*
89703 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
89704 * earlier power of two caches
89705 */
89706 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
89707 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
89708 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
89709
89710 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
89711 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
89712 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
89713 }
89714
89715 /* Kmalloc array is now usable */
89716 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
89717 }
89718 }
89719 #endif
89720 +
89721 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89722 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
89723 + struct kmem_cache *s = kmalloc_caches[i];
89724 +
89725 + if (s) {
89726 + int size = kmalloc_size(i);
89727 + char *n = kasprintf(GFP_NOWAIT,
89728 + "usercopy-kmalloc-%d", size);
89729 +
89730 + BUG_ON(!n);
89731 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
89732 + size, SLAB_USERCOPY | flags);
89733 + }
89734 + }
89735 +#endif
89736 +
89737 }
89738 #endif /* !CONFIG_SLOB */
89739
89740 @@ -523,6 +562,9 @@ void print_slabinfo_header(struct seq_file *m)
89741 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
89742 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
89743 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
89744 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89745 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
89746 +#endif
89747 #endif
89748 seq_putc(m, '\n');
89749 }
89750 diff --git a/mm/slob.c b/mm/slob.c
89751 index 91bd3f2..e2f549e 100644
89752 --- a/mm/slob.c
89753 +++ b/mm/slob.c
89754 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
89755 /*
89756 * Return the size of a slob block.
89757 */
89758 -static slobidx_t slob_units(slob_t *s)
89759 +static slobidx_t slob_units(const slob_t *s)
89760 {
89761 if (s->units > 0)
89762 return s->units;
89763 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
89764 /*
89765 * Return the next free slob block pointer after this one.
89766 */
89767 -static slob_t *slob_next(slob_t *s)
89768 +static slob_t *slob_next(const slob_t *s)
89769 {
89770 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
89771 slobidx_t next;
89772 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
89773 /*
89774 * Returns true if s is the last free block in its page.
89775 */
89776 -static int slob_last(slob_t *s)
89777 +static int slob_last(const slob_t *s)
89778 {
89779 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
89780 }
89781
89782 -static void *slob_new_pages(gfp_t gfp, int order, int node)
89783 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
89784 {
89785 - void *page;
89786 + struct page *page;
89787
89788 #ifdef CONFIG_NUMA
89789 if (node != NUMA_NO_NODE)
89790 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
89791 if (!page)
89792 return NULL;
89793
89794 - return page_address(page);
89795 + __SetPageSlab(page);
89796 + return page;
89797 }
89798
89799 -static void slob_free_pages(void *b, int order)
89800 +static void slob_free_pages(struct page *sp, int order)
89801 {
89802 if (current->reclaim_state)
89803 current->reclaim_state->reclaimed_slab += 1 << order;
89804 - free_pages((unsigned long)b, order);
89805 + __ClearPageSlab(sp);
89806 + page_mapcount_reset(sp);
89807 + sp->private = 0;
89808 + __free_pages(sp, order);
89809 }
89810
89811 /*
89812 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
89813
89814 /* Not enough space: must allocate a new page */
89815 if (!b) {
89816 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89817 - if (!b)
89818 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89819 + if (!sp)
89820 return NULL;
89821 - sp = virt_to_page(b);
89822 - __SetPageSlab(sp);
89823 + b = page_address(sp);
89824
89825 spin_lock_irqsave(&slob_lock, flags);
89826 sp->units = SLOB_UNITS(PAGE_SIZE);
89827 sp->freelist = b;
89828 + sp->private = 0;
89829 INIT_LIST_HEAD(&sp->list);
89830 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
89831 set_slob_page_free(sp, slob_list);
89832 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
89833 if (slob_page_free(sp))
89834 clear_slob_page_free(sp);
89835 spin_unlock_irqrestore(&slob_lock, flags);
89836 - __ClearPageSlab(sp);
89837 - page_mapcount_reset(sp);
89838 - slob_free_pages(b, 0);
89839 + slob_free_pages(sp, 0);
89840 return;
89841 }
89842
89843 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89844 + if (pax_sanitize_slab)
89845 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
89846 +#endif
89847 +
89848 if (!slob_page_free(sp)) {
89849 /* This slob page is about to become partially free. Easy! */
89850 sp->units = units;
89851 @@ -424,11 +431,10 @@ out:
89852 */
89853
89854 static __always_inline void *
89855 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89856 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
89857 {
89858 - unsigned int *m;
89859 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89860 - void *ret;
89861 + slob_t *m;
89862 + void *ret = NULL;
89863
89864 gfp &= gfp_allowed_mask;
89865
89866 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89867
89868 if (!m)
89869 return NULL;
89870 - *m = size;
89871 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
89872 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
89873 + m[0].units = size;
89874 + m[1].units = align;
89875 ret = (void *)m + align;
89876
89877 trace_kmalloc_node(caller, ret,
89878 size, size + align, gfp, node);
89879 } else {
89880 unsigned int order = get_order(size);
89881 + struct page *page;
89882
89883 if (likely(order))
89884 gfp |= __GFP_COMP;
89885 - ret = slob_new_pages(gfp, order, node);
89886 + page = slob_new_pages(gfp, order, node);
89887 + if (page) {
89888 + ret = page_address(page);
89889 + page->private = size;
89890 + }
89891
89892 trace_kmalloc_node(caller, ret,
89893 size, PAGE_SIZE << order, gfp, node);
89894 }
89895
89896 - kmemleak_alloc(ret, size, 1, gfp);
89897 + return ret;
89898 +}
89899 +
89900 +static __always_inline void *
89901 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89902 +{
89903 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89904 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
89905 +
89906 + if (!ZERO_OR_NULL_PTR(ret))
89907 + kmemleak_alloc(ret, size, 1, gfp);
89908 return ret;
89909 }
89910
89911 @@ -493,34 +517,112 @@ void kfree(const void *block)
89912 return;
89913 kmemleak_free(block);
89914
89915 + VM_BUG_ON(!virt_addr_valid(block));
89916 sp = virt_to_page(block);
89917 - if (PageSlab(sp)) {
89918 + VM_BUG_ON(!PageSlab(sp));
89919 + if (!sp->private) {
89920 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89921 - unsigned int *m = (unsigned int *)(block - align);
89922 - slob_free(m, *m + align);
89923 - } else
89924 + slob_t *m = (slob_t *)(block - align);
89925 + slob_free(m, m[0].units + align);
89926 + } else {
89927 + __ClearPageSlab(sp);
89928 + page_mapcount_reset(sp);
89929 + sp->private = 0;
89930 __free_pages(sp, compound_order(sp));
89931 + }
89932 }
89933 EXPORT_SYMBOL(kfree);
89934
89935 +bool is_usercopy_object(const void *ptr)
89936 +{
89937 + if (!slab_is_available())
89938 + return false;
89939 +
89940 + // PAX: TODO
89941 +
89942 + return false;
89943 +}
89944 +
89945 +#ifdef CONFIG_PAX_USERCOPY
89946 +const char *check_heap_object(const void *ptr, unsigned long n)
89947 +{
89948 + struct page *page;
89949 + const slob_t *free;
89950 + const void *base;
89951 + unsigned long flags;
89952 +
89953 + if (ZERO_OR_NULL_PTR(ptr))
89954 + return "<null>";
89955 +
89956 + if (!virt_addr_valid(ptr))
89957 + return NULL;
89958 +
89959 + page = virt_to_head_page(ptr);
89960 + if (!PageSlab(page))
89961 + return NULL;
89962 +
89963 + if (page->private) {
89964 + base = page;
89965 + if (base <= ptr && n <= page->private - (ptr - base))
89966 + return NULL;
89967 + return "<slob>";
89968 + }
89969 +
89970 + /* some tricky double walking to find the chunk */
89971 + spin_lock_irqsave(&slob_lock, flags);
89972 + base = (void *)((unsigned long)ptr & PAGE_MASK);
89973 + free = page->freelist;
89974 +
89975 + while (!slob_last(free) && (void *)free <= ptr) {
89976 + base = free + slob_units(free);
89977 + free = slob_next(free);
89978 + }
89979 +
89980 + while (base < (void *)free) {
89981 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
89982 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
89983 + int offset;
89984 +
89985 + if (ptr < base + align)
89986 + break;
89987 +
89988 + offset = ptr - base - align;
89989 + if (offset >= m) {
89990 + base += size;
89991 + continue;
89992 + }
89993 +
89994 + if (n > m - offset)
89995 + break;
89996 +
89997 + spin_unlock_irqrestore(&slob_lock, flags);
89998 + return NULL;
89999 + }
90000 +
90001 + spin_unlock_irqrestore(&slob_lock, flags);
90002 + return "<slob>";
90003 +}
90004 +#endif
90005 +
90006 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
90007 size_t ksize(const void *block)
90008 {
90009 struct page *sp;
90010 int align;
90011 - unsigned int *m;
90012 + slob_t *m;
90013
90014 BUG_ON(!block);
90015 if (unlikely(block == ZERO_SIZE_PTR))
90016 return 0;
90017
90018 sp = virt_to_page(block);
90019 - if (unlikely(!PageSlab(sp)))
90020 - return PAGE_SIZE << compound_order(sp);
90021 + VM_BUG_ON(!PageSlab(sp));
90022 + if (sp->private)
90023 + return sp->private;
90024
90025 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90026 - m = (unsigned int *)(block - align);
90027 - return SLOB_UNITS(*m) * SLOB_UNIT;
90028 + m = (slob_t *)(block - align);
90029 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
90030 }
90031 EXPORT_SYMBOL(ksize);
90032
90033 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
90034
90035 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
90036 {
90037 - void *b;
90038 + void *b = NULL;
90039
90040 flags &= gfp_allowed_mask;
90041
90042 lockdep_trace_alloc(flags);
90043
90044 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90045 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
90046 +#else
90047 if (c->size < PAGE_SIZE) {
90048 b = slob_alloc(c->size, flags, c->align, node);
90049 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90050 SLOB_UNITS(c->size) * SLOB_UNIT,
90051 flags, node);
90052 } else {
90053 - b = slob_new_pages(flags, get_order(c->size), node);
90054 + struct page *sp;
90055 +
90056 + sp = slob_new_pages(flags, get_order(c->size), node);
90057 + if (sp) {
90058 + b = page_address(sp);
90059 + sp->private = c->size;
90060 + }
90061 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90062 PAGE_SIZE << get_order(c->size),
90063 flags, node);
90064 }
90065 +#endif
90066
90067 if (b && c->ctor)
90068 c->ctor(b);
90069 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
90070
90071 static void __kmem_cache_free(void *b, int size)
90072 {
90073 - if (size < PAGE_SIZE)
90074 + struct page *sp;
90075 +
90076 + sp = virt_to_page(b);
90077 + BUG_ON(!PageSlab(sp));
90078 + if (!sp->private)
90079 slob_free(b, size);
90080 else
90081 - slob_free_pages(b, get_order(size));
90082 + slob_free_pages(sp, get_order(size));
90083 }
90084
90085 static void kmem_rcu_free(struct rcu_head *head)
90086 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
90087
90088 void kmem_cache_free(struct kmem_cache *c, void *b)
90089 {
90090 + int size = c->size;
90091 +
90092 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90093 + if (size + c->align < PAGE_SIZE) {
90094 + size += c->align;
90095 + b -= c->align;
90096 + }
90097 +#endif
90098 +
90099 kmemleak_free_recursive(b, c->flags);
90100 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
90101 struct slob_rcu *slob_rcu;
90102 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
90103 - slob_rcu->size = c->size;
90104 + slob_rcu = b + (size - sizeof(struct slob_rcu));
90105 + slob_rcu->size = size;
90106 call_rcu(&slob_rcu->head, kmem_rcu_free);
90107 } else {
90108 - __kmem_cache_free(b, c->size);
90109 + __kmem_cache_free(b, size);
90110 }
90111
90112 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90113 + trace_kfree(_RET_IP_, b);
90114 +#else
90115 trace_kmem_cache_free(_RET_IP_, b);
90116 +#endif
90117 +
90118 }
90119 EXPORT_SYMBOL(kmem_cache_free);
90120
90121 diff --git a/mm/slub.c b/mm/slub.c
90122 index e3ba1f2..bd45dac 100644
90123 --- a/mm/slub.c
90124 +++ b/mm/slub.c
90125 @@ -207,7 +207,7 @@ struct track {
90126
90127 enum track_item { TRACK_ALLOC, TRACK_FREE };
90128
90129 -#ifdef CONFIG_SYSFS
90130 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90131 static int sysfs_slab_add(struct kmem_cache *);
90132 static int sysfs_slab_alias(struct kmem_cache *, const char *);
90133 static void sysfs_slab_remove(struct kmem_cache *);
90134 @@ -528,7 +528,7 @@ static void print_track(const char *s, struct track *t)
90135 if (!t->addr)
90136 return;
90137
90138 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
90139 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
90140 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
90141 #ifdef CONFIG_STACKTRACE
90142 {
90143 @@ -2609,6 +2609,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
90144
90145 slab_free_hook(s, x);
90146
90147 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90148 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
90149 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
90150 + if (s->ctor)
90151 + s->ctor(x);
90152 + }
90153 +#endif
90154 +
90155 redo:
90156 /*
90157 * Determine the currently cpus per cpu slab.
90158 @@ -2676,7 +2684,7 @@ static int slub_min_objects;
90159 * Merge control. If this is set then no merging of slab caches will occur.
90160 * (Could be removed. This was introduced to pacify the merge skeptics.)
90161 */
90162 -static int slub_nomerge;
90163 +static int slub_nomerge = 1;
90164
90165 /*
90166 * Calculate the order of allocation given an slab object size.
90167 @@ -2953,6 +2961,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
90168 s->inuse = size;
90169
90170 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
90171 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90172 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
90173 +#endif
90174 s->ctor)) {
90175 /*
90176 * Relocate free pointer after the object if it is not
90177 @@ -3298,6 +3309,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
90178 EXPORT_SYMBOL(__kmalloc_node);
90179 #endif
90180
90181 +bool is_usercopy_object(const void *ptr)
90182 +{
90183 + struct page *page;
90184 + struct kmem_cache *s;
90185 +
90186 + if (ZERO_OR_NULL_PTR(ptr))
90187 + return false;
90188 +
90189 + if (!slab_is_available())
90190 + return false;
90191 +
90192 + if (!virt_addr_valid(ptr))
90193 + return false;
90194 +
90195 + page = virt_to_head_page(ptr);
90196 +
90197 + if (!PageSlab(page))
90198 + return false;
90199 +
90200 + s = page->slab_cache;
90201 + return s->flags & SLAB_USERCOPY;
90202 +}
90203 +
90204 +#ifdef CONFIG_PAX_USERCOPY
90205 +const char *check_heap_object(const void *ptr, unsigned long n)
90206 +{
90207 + struct page *page;
90208 + struct kmem_cache *s;
90209 + unsigned long offset;
90210 +
90211 + if (ZERO_OR_NULL_PTR(ptr))
90212 + return "<null>";
90213 +
90214 + if (!virt_addr_valid(ptr))
90215 + return NULL;
90216 +
90217 + page = virt_to_head_page(ptr);
90218 +
90219 + if (!PageSlab(page))
90220 + return NULL;
90221 +
90222 + s = page->slab_cache;
90223 + if (!(s->flags & SLAB_USERCOPY))
90224 + return s->name;
90225 +
90226 + offset = (ptr - page_address(page)) % s->size;
90227 + if (offset <= s->object_size && n <= s->object_size - offset)
90228 + return NULL;
90229 +
90230 + return s->name;
90231 +}
90232 +#endif
90233 +
90234 size_t ksize(const void *object)
90235 {
90236 struct page *page;
90237 @@ -3362,6 +3426,7 @@ void kfree(const void *x)
90238 if (unlikely(ZERO_OR_NULL_PTR(x)))
90239 return;
90240
90241 + VM_BUG_ON(!virt_addr_valid(x));
90242 page = virt_to_head_page(x);
90243 if (unlikely(!PageSlab(page))) {
90244 BUG_ON(!PageCompound(page));
90245 @@ -3667,7 +3732,7 @@ static int slab_unmergeable(struct kmem_cache *s)
90246 /*
90247 * We may have set a slab to be unmergeable during bootstrap.
90248 */
90249 - if (s->refcount < 0)
90250 + if (atomic_read(&s->refcount) < 0)
90251 return 1;
90252
90253 return 0;
90254 @@ -3725,7 +3790,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90255
90256 s = find_mergeable(memcg, size, align, flags, name, ctor);
90257 if (s) {
90258 - s->refcount++;
90259 + atomic_inc(&s->refcount);
90260 /*
90261 * Adjust the object sizes so that we clear
90262 * the complete object on kzalloc.
90263 @@ -3734,7 +3799,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90264 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
90265
90266 if (sysfs_slab_alias(s, name)) {
90267 - s->refcount--;
90268 + atomic_dec(&s->refcount);
90269 s = NULL;
90270 }
90271 }
90272 @@ -3854,7 +3919,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
90273 }
90274 #endif
90275
90276 -#ifdef CONFIG_SYSFS
90277 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90278 static int count_inuse(struct page *page)
90279 {
90280 return page->inuse;
90281 @@ -4241,12 +4306,12 @@ static void resiliency_test(void)
90282 validate_slab_cache(kmalloc_caches[9]);
90283 }
90284 #else
90285 -#ifdef CONFIG_SYSFS
90286 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90287 static void resiliency_test(void) {};
90288 #endif
90289 #endif
90290
90291 -#ifdef CONFIG_SYSFS
90292 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90293 enum slab_stat_type {
90294 SL_ALL, /* All slabs */
90295 SL_PARTIAL, /* Only partially allocated slabs */
90296 @@ -4490,7 +4555,7 @@ SLAB_ATTR_RO(ctor);
90297
90298 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
90299 {
90300 - return sprintf(buf, "%d\n", s->refcount - 1);
90301 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
90302 }
90303 SLAB_ATTR_RO(aliases);
90304
90305 @@ -4578,6 +4643,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
90306 SLAB_ATTR_RO(cache_dma);
90307 #endif
90308
90309 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90310 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
90311 +{
90312 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
90313 +}
90314 +SLAB_ATTR_RO(usercopy);
90315 +#endif
90316 +
90317 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
90318 {
90319 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
90320 @@ -4912,6 +4985,9 @@ static struct attribute *slab_attrs[] = {
90321 #ifdef CONFIG_ZONE_DMA
90322 &cache_dma_attr.attr,
90323 #endif
90324 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90325 + &usercopy_attr.attr,
90326 +#endif
90327 #ifdef CONFIG_NUMA
90328 &remote_node_defrag_ratio_attr.attr,
90329 #endif
90330 @@ -5143,6 +5219,7 @@ static char *create_unique_id(struct kmem_cache *s)
90331 return name;
90332 }
90333
90334 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90335 static int sysfs_slab_add(struct kmem_cache *s)
90336 {
90337 int err;
90338 @@ -5166,7 +5243,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
90339 }
90340
90341 s->kobj.kset = slab_kset;
90342 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
90343 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
90344 if (err) {
90345 kobject_put(&s->kobj);
90346 return err;
90347 @@ -5200,6 +5277,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
90348 kobject_del(&s->kobj);
90349 kobject_put(&s->kobj);
90350 }
90351 +#endif
90352
90353 /*
90354 * Need to buffer aliases during bootup until sysfs becomes
90355 @@ -5213,6 +5291,7 @@ struct saved_alias {
90356
90357 static struct saved_alias *alias_list;
90358
90359 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90360 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90361 {
90362 struct saved_alias *al;
90363 @@ -5235,6 +5314,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90364 alias_list = al;
90365 return 0;
90366 }
90367 +#endif
90368
90369 static int __init slab_sysfs_init(void)
90370 {
90371 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
90372 index 27eeab3..7c3f7f2 100644
90373 --- a/mm/sparse-vmemmap.c
90374 +++ b/mm/sparse-vmemmap.c
90375 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
90376 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90377 if (!p)
90378 return NULL;
90379 - pud_populate(&init_mm, pud, p);
90380 + pud_populate_kernel(&init_mm, pud, p);
90381 }
90382 return pud;
90383 }
90384 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
90385 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90386 if (!p)
90387 return NULL;
90388 - pgd_populate(&init_mm, pgd, p);
90389 + pgd_populate_kernel(&init_mm, pgd, p);
90390 }
90391 return pgd;
90392 }
90393 diff --git a/mm/sparse.c b/mm/sparse.c
90394 index 308d503..3dbbd04 100644
90395 --- a/mm/sparse.c
90396 +++ b/mm/sparse.c
90397 @@ -764,7 +764,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
90398
90399 for (i = 0; i < PAGES_PER_SECTION; i++) {
90400 if (PageHWPoison(&memmap[i])) {
90401 - atomic_long_sub(1, &num_poisoned_pages);
90402 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
90403 ClearPageHWPoison(&memmap[i]);
90404 }
90405 }
90406 diff --git a/mm/swap.c b/mm/swap.c
90407 index c899502..d4dc2cd 100644
90408 --- a/mm/swap.c
90409 +++ b/mm/swap.c
90410 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
90411
90412 __page_cache_release(page);
90413 dtor = get_compound_page_dtor(page);
90414 + if (!PageHuge(page))
90415 + BUG_ON(dtor != free_compound_page);
90416 (*dtor)(page);
90417 }
90418
90419 diff --git a/mm/swapfile.c b/mm/swapfile.c
90420 index 6cf2e60..d204b3e 100644
90421 --- a/mm/swapfile.c
90422 +++ b/mm/swapfile.c
90423 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
90424
90425 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
90426 /* Activity counter to indicate that a swapon or swapoff has occurred */
90427 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
90428 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
90429
90430 static inline unsigned char swap_count(unsigned char ent)
90431 {
90432 @@ -1699,7 +1699,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
90433 }
90434 filp_close(swap_file, NULL);
90435 err = 0;
90436 - atomic_inc(&proc_poll_event);
90437 + atomic_inc_unchecked(&proc_poll_event);
90438 wake_up_interruptible(&proc_poll_wait);
90439
90440 out_dput:
90441 @@ -1716,8 +1716,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
90442
90443 poll_wait(file, &proc_poll_wait, wait);
90444
90445 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
90446 - seq->poll_event = atomic_read(&proc_poll_event);
90447 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
90448 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90449 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
90450 }
90451
90452 @@ -1815,7 +1815,7 @@ static int swaps_open(struct inode *inode, struct file *file)
90453 return ret;
90454
90455 seq = file->private_data;
90456 - seq->poll_event = atomic_read(&proc_poll_event);
90457 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90458 return 0;
90459 }
90460
90461 @@ -2203,7 +2203,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
90462 (frontswap_map) ? "FS" : "");
90463
90464 mutex_unlock(&swapon_mutex);
90465 - atomic_inc(&proc_poll_event);
90466 + atomic_inc_unchecked(&proc_poll_event);
90467 wake_up_interruptible(&proc_poll_wait);
90468
90469 if (S_ISREG(inode->i_mode))
90470 diff --git a/mm/util.c b/mm/util.c
90471 index 7441c41..c3de793 100644
90472 --- a/mm/util.c
90473 +++ b/mm/util.c
90474 @@ -294,6 +294,12 @@ done:
90475 void arch_pick_mmap_layout(struct mm_struct *mm)
90476 {
90477 mm->mmap_base = TASK_UNMAPPED_BASE;
90478 +
90479 +#ifdef CONFIG_PAX_RANDMMAP
90480 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90481 + mm->mmap_base += mm->delta_mmap;
90482 +#endif
90483 +
90484 mm->get_unmapped_area = arch_get_unmapped_area;
90485 }
90486 #endif
90487 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
90488 index 13a5495..6707d97 100644
90489 --- a/mm/vmalloc.c
90490 +++ b/mm/vmalloc.c
90491 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
90492
90493 pte = pte_offset_kernel(pmd, addr);
90494 do {
90495 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90496 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90497 +
90498 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90499 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
90500 + BUG_ON(!pte_exec(*pte));
90501 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
90502 + continue;
90503 + }
90504 +#endif
90505 +
90506 + {
90507 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90508 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90509 + }
90510 } while (pte++, addr += PAGE_SIZE, addr != end);
90511 }
90512
90513 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
90514 pte = pte_alloc_kernel(pmd, addr);
90515 if (!pte)
90516 return -ENOMEM;
90517 +
90518 + pax_open_kernel();
90519 do {
90520 struct page *page = pages[*nr];
90521
90522 - if (WARN_ON(!pte_none(*pte)))
90523 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90524 + if (pgprot_val(prot) & _PAGE_NX)
90525 +#endif
90526 +
90527 + if (!pte_none(*pte)) {
90528 + pax_close_kernel();
90529 + WARN_ON(1);
90530 return -EBUSY;
90531 - if (WARN_ON(!page))
90532 + }
90533 + if (!page) {
90534 + pax_close_kernel();
90535 + WARN_ON(1);
90536 return -ENOMEM;
90537 + }
90538 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
90539 (*nr)++;
90540 } while (pte++, addr += PAGE_SIZE, addr != end);
90541 + pax_close_kernel();
90542 return 0;
90543 }
90544
90545 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
90546 pmd_t *pmd;
90547 unsigned long next;
90548
90549 - pmd = pmd_alloc(&init_mm, pud, addr);
90550 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
90551 if (!pmd)
90552 return -ENOMEM;
90553 do {
90554 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
90555 pud_t *pud;
90556 unsigned long next;
90557
90558 - pud = pud_alloc(&init_mm, pgd, addr);
90559 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
90560 if (!pud)
90561 return -ENOMEM;
90562 do {
90563 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
90564 if (addr >= MODULES_VADDR && addr < MODULES_END)
90565 return 1;
90566 #endif
90567 +
90568 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90569 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
90570 + return 1;
90571 +#endif
90572 +
90573 return is_vmalloc_addr(x);
90574 }
90575
90576 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
90577
90578 if (!pgd_none(*pgd)) {
90579 pud_t *pud = pud_offset(pgd, addr);
90580 +#ifdef CONFIG_X86
90581 + if (!pud_large(*pud))
90582 +#endif
90583 if (!pud_none(*pud)) {
90584 pmd_t *pmd = pmd_offset(pud, addr);
90585 +#ifdef CONFIG_X86
90586 + if (!pmd_large(*pmd))
90587 +#endif
90588 if (!pmd_none(*pmd)) {
90589 pte_t *ptep, pte;
90590
90591 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
90592 * Allocate a region of KVA of the specified size and alignment, within the
90593 * vstart and vend.
90594 */
90595 -static struct vmap_area *alloc_vmap_area(unsigned long size,
90596 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
90597 unsigned long align,
90598 unsigned long vstart, unsigned long vend,
90599 int node, gfp_t gfp_mask)
90600 @@ -1308,6 +1344,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
90601 struct vm_struct *area;
90602
90603 BUG_ON(in_interrupt());
90604 +
90605 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90606 + if (flags & VM_KERNEXEC) {
90607 + if (start != VMALLOC_START || end != VMALLOC_END)
90608 + return NULL;
90609 + start = (unsigned long)MODULES_EXEC_VADDR;
90610 + end = (unsigned long)MODULES_EXEC_END;
90611 + }
90612 +#endif
90613 +
90614 if (flags & VM_IOREMAP)
90615 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
90616
90617 @@ -1533,6 +1579,11 @@ void *vmap(struct page **pages, unsigned int count,
90618 if (count > totalram_pages)
90619 return NULL;
90620
90621 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90622 + if (!(pgprot_val(prot) & _PAGE_NX))
90623 + flags |= VM_KERNEXEC;
90624 +#endif
90625 +
90626 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
90627 __builtin_return_address(0));
90628 if (!area)
90629 @@ -1634,6 +1685,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
90630 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
90631 goto fail;
90632
90633 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90634 + if (!(pgprot_val(prot) & _PAGE_NX))
90635 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
90636 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
90637 + else
90638 +#endif
90639 +
90640 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
90641 start, end, node, gfp_mask, caller);
90642 if (!area)
90643 @@ -1810,10 +1868,9 @@ EXPORT_SYMBOL(vzalloc_node);
90644 * For tight control over page level allocator and protection flags
90645 * use __vmalloc() instead.
90646 */
90647 -
90648 void *vmalloc_exec(unsigned long size)
90649 {
90650 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
90651 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
90652 NUMA_NO_NODE, __builtin_return_address(0));
90653 }
90654
90655 @@ -2120,6 +2177,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
90656 {
90657 struct vm_struct *area;
90658
90659 + BUG_ON(vma->vm_mirror);
90660 +
90661 size = PAGE_ALIGN(size);
90662
90663 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
90664 @@ -2605,7 +2664,11 @@ static int s_show(struct seq_file *m, void *p)
90665 v->addr, v->addr + v->size, v->size);
90666
90667 if (v->caller)
90668 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90669 + seq_printf(m, " %pK", v->caller);
90670 +#else
90671 seq_printf(m, " %pS", v->caller);
90672 +#endif
90673
90674 if (v->nr_pages)
90675 seq_printf(m, " pages=%d", v->nr_pages);
90676 diff --git a/mm/vmstat.c b/mm/vmstat.c
90677 index 20c2ef4..15e7ab7 100644
90678 --- a/mm/vmstat.c
90679 +++ b/mm/vmstat.c
90680 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
90681 *
90682 * vm_stat contains the global counters
90683 */
90684 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90685 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90686 EXPORT_SYMBOL(vm_stat);
90687
90688 #ifdef CONFIG_SMP
90689 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
90690 v = p->vm_stat_diff[i];
90691 p->vm_stat_diff[i] = 0;
90692 local_irq_restore(flags);
90693 - atomic_long_add(v, &zone->vm_stat[i]);
90694 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90695 global_diff[i] += v;
90696 #ifdef CONFIG_NUMA
90697 /* 3 seconds idle till flush */
90698 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
90699
90700 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
90701 if (global_diff[i])
90702 - atomic_long_add(global_diff[i], &vm_stat[i]);
90703 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
90704 }
90705
90706 /*
90707 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
90708 if (pset->vm_stat_diff[i]) {
90709 int v = pset->vm_stat_diff[i];
90710 pset->vm_stat_diff[i] = 0;
90711 - atomic_long_add(v, &zone->vm_stat[i]);
90712 - atomic_long_add(v, &vm_stat[i]);
90713 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90714 + atomic_long_add_unchecked(v, &vm_stat[i]);
90715 }
90716 }
90717 #endif
90718 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
90719 start_cpu_timer(cpu);
90720 #endif
90721 #ifdef CONFIG_PROC_FS
90722 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
90723 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
90724 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
90725 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
90726 + {
90727 + mode_t gr_mode = S_IRUGO;
90728 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
90729 + gr_mode = S_IRUSR;
90730 +#endif
90731 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
90732 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
90733 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
90734 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
90735 +#else
90736 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
90737 +#endif
90738 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
90739 + }
90740 #endif
90741 return 0;
90742 }
90743 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
90744 index 2fb2d88..8c06e40 100644
90745 --- a/net/8021q/vlan.c
90746 +++ b/net/8021q/vlan.c
90747 @@ -469,7 +469,7 @@ out:
90748 return NOTIFY_DONE;
90749 }
90750
90751 -static struct notifier_block vlan_notifier_block __read_mostly = {
90752 +static struct notifier_block vlan_notifier_block = {
90753 .notifier_call = vlan_device_event,
90754 };
90755
90756 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
90757 err = -EPERM;
90758 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
90759 break;
90760 - if ((args.u.name_type >= 0) &&
90761 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
90762 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
90763 struct vlan_net *vn;
90764
90765 vn = net_generic(net, vlan_net_id);
90766 diff --git a/net/9p/mod.c b/net/9p/mod.c
90767 index 6ab36ae..6f1841b 100644
90768 --- a/net/9p/mod.c
90769 +++ b/net/9p/mod.c
90770 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
90771 void v9fs_register_trans(struct p9_trans_module *m)
90772 {
90773 spin_lock(&v9fs_trans_lock);
90774 - list_add_tail(&m->list, &v9fs_trans_list);
90775 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
90776 spin_unlock(&v9fs_trans_lock);
90777 }
90778 EXPORT_SYMBOL(v9fs_register_trans);
90779 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
90780 void v9fs_unregister_trans(struct p9_trans_module *m)
90781 {
90782 spin_lock(&v9fs_trans_lock);
90783 - list_del_init(&m->list);
90784 + pax_list_del_init((struct list_head *)&m->list);
90785 spin_unlock(&v9fs_trans_lock);
90786 }
90787 EXPORT_SYMBOL(v9fs_unregister_trans);
90788 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
90789 index 3ffda1b..fceac96 100644
90790 --- a/net/9p/trans_fd.c
90791 +++ b/net/9p/trans_fd.c
90792 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
90793 oldfs = get_fs();
90794 set_fs(get_ds());
90795 /* The cast to a user pointer is valid due to the set_fs() */
90796 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
90797 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
90798 set_fs(oldfs);
90799
90800 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
90801 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
90802 index 876fbe8..8bbea9f 100644
90803 --- a/net/atm/atm_misc.c
90804 +++ b/net/atm/atm_misc.c
90805 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
90806 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
90807 return 1;
90808 atm_return(vcc, truesize);
90809 - atomic_inc(&vcc->stats->rx_drop);
90810 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90811 return 0;
90812 }
90813 EXPORT_SYMBOL(atm_charge);
90814 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
90815 }
90816 }
90817 atm_return(vcc, guess);
90818 - atomic_inc(&vcc->stats->rx_drop);
90819 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90820 return NULL;
90821 }
90822 EXPORT_SYMBOL(atm_alloc_charge);
90823 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
90824
90825 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90826 {
90827 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90828 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90829 __SONET_ITEMS
90830 #undef __HANDLE_ITEM
90831 }
90832 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
90833
90834 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90835 {
90836 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90837 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
90838 __SONET_ITEMS
90839 #undef __HANDLE_ITEM
90840 }
90841 diff --git a/net/atm/lec.h b/net/atm/lec.h
90842 index 4149db1..f2ab682 100644
90843 --- a/net/atm/lec.h
90844 +++ b/net/atm/lec.h
90845 @@ -48,7 +48,7 @@ struct lane2_ops {
90846 const u8 *tlvs, u32 sizeoftlvs);
90847 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
90848 const u8 *tlvs, u32 sizeoftlvs);
90849 -};
90850 +} __no_const;
90851
90852 /*
90853 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
90854 diff --git a/net/atm/proc.c b/net/atm/proc.c
90855 index bbb6461..cf04016 100644
90856 --- a/net/atm/proc.c
90857 +++ b/net/atm/proc.c
90858 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
90859 const struct k_atm_aal_stats *stats)
90860 {
90861 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
90862 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
90863 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
90864 - atomic_read(&stats->rx_drop));
90865 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
90866 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
90867 + atomic_read_unchecked(&stats->rx_drop));
90868 }
90869
90870 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
90871 diff --git a/net/atm/resources.c b/net/atm/resources.c
90872 index 0447d5d..3cf4728 100644
90873 --- a/net/atm/resources.c
90874 +++ b/net/atm/resources.c
90875 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
90876 static void copy_aal_stats(struct k_atm_aal_stats *from,
90877 struct atm_aal_stats *to)
90878 {
90879 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90880 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90881 __AAL_STAT_ITEMS
90882 #undef __HANDLE_ITEM
90883 }
90884 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
90885 static void subtract_aal_stats(struct k_atm_aal_stats *from,
90886 struct atm_aal_stats *to)
90887 {
90888 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90889 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
90890 __AAL_STAT_ITEMS
90891 #undef __HANDLE_ITEM
90892 }
90893 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
90894 index 919a5ce..cc6b444 100644
90895 --- a/net/ax25/sysctl_net_ax25.c
90896 +++ b/net/ax25/sysctl_net_ax25.c
90897 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
90898 {
90899 char path[sizeof("net/ax25/") + IFNAMSIZ];
90900 int k;
90901 - struct ctl_table *table;
90902 + ctl_table_no_const *table;
90903
90904 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
90905 if (!table)
90906 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
90907 index 62da527..aa27535 100644
90908 --- a/net/batman-adv/bat_iv_ogm.c
90909 +++ b/net/batman-adv/bat_iv_ogm.c
90910 @@ -120,7 +120,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
90911
90912 /* randomize initial seqno to avoid collision */
90913 get_random_bytes(&random_seqno, sizeof(random_seqno));
90914 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90915 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90916
90917 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
90918 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
90919 @@ -701,9 +701,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
90920 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
90921
90922 /* change sequence number to network order */
90923 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
90924 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
90925 batadv_ogm_packet->seqno = htonl(seqno);
90926 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
90927 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
90928
90929 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
90930 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
90931 @@ -1109,7 +1109,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
90932 return;
90933
90934 /* could be changed by schedule_own_packet() */
90935 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
90936 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
90937
90938 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
90939 has_directlink_flag = 1;
90940 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
90941 index c478e6b..469fd2f 100644
90942 --- a/net/batman-adv/hard-interface.c
90943 +++ b/net/batman-adv/hard-interface.c
90944 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
90945 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
90946 dev_add_pack(&hard_iface->batman_adv_ptype);
90947
90948 - atomic_set(&hard_iface->frag_seqno, 1);
90949 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
90950 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
90951 hard_iface->net_dev->name);
90952
90953 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
90954 index 33b6144..3212ac5 100644
90955 --- a/net/batman-adv/soft-interface.c
90956 +++ b/net/batman-adv/soft-interface.c
90957 @@ -261,7 +261,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
90958 primary_if->net_dev->dev_addr, ETH_ALEN);
90959
90960 /* set broadcast sequence number */
90961 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
90962 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
90963 bcast_packet->seqno = htonl(seqno);
90964
90965 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
90966 @@ -481,7 +481,7 @@ static int batadv_softif_init_late(struct net_device *dev)
90967 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
90968
90969 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
90970 - atomic_set(&bat_priv->bcast_seqno, 1);
90971 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
90972 atomic_set(&bat_priv->tt.vn, 0);
90973 atomic_set(&bat_priv->tt.local_changes, 0);
90974 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
90975 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
90976 index b2c94e1..3d47e07 100644
90977 --- a/net/batman-adv/types.h
90978 +++ b/net/batman-adv/types.h
90979 @@ -51,7 +51,7 @@
90980 struct batadv_hard_iface_bat_iv {
90981 unsigned char *ogm_buff;
90982 int ogm_buff_len;
90983 - atomic_t ogm_seqno;
90984 + atomic_unchecked_t ogm_seqno;
90985 };
90986
90987 /**
90988 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
90989 int16_t if_num;
90990 char if_status;
90991 struct net_device *net_dev;
90992 - atomic_t frag_seqno;
90993 + atomic_unchecked_t frag_seqno;
90994 uint8_t num_bcasts;
90995 struct kobject *hardif_obj;
90996 atomic_t refcount;
90997 @@ -560,7 +560,7 @@ struct batadv_priv {
90998 #ifdef CONFIG_BATMAN_ADV_DEBUG
90999 atomic_t log_level;
91000 #endif
91001 - atomic_t bcast_seqno;
91002 + atomic_unchecked_t bcast_seqno;
91003 atomic_t bcast_queue_left;
91004 atomic_t batman_queue_left;
91005 char num_ifaces;
91006 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
91007 index 857e1b8..5ad07b2 100644
91008 --- a/net/batman-adv/unicast.c
91009 +++ b/net/batman-adv/unicast.c
91010 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
91011 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
91012 frag2->flags = large_tail;
91013
91014 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
91015 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
91016 frag1->seqno = htons(seqno - 1);
91017 frag2->seqno = htons(seqno);
91018
91019 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
91020 index 9bd7d95..6c4884f 100644
91021 --- a/net/bluetooth/hci_sock.c
91022 +++ b/net/bluetooth/hci_sock.c
91023 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
91024 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
91025 }
91026
91027 - len = min_t(unsigned int, len, sizeof(uf));
91028 + len = min((size_t)len, sizeof(uf));
91029 if (copy_from_user(&uf, optval, len)) {
91030 err = -EFAULT;
91031 break;
91032 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
91033 index 8c3499b..2661c6a 100644
91034 --- a/net/bluetooth/l2cap_core.c
91035 +++ b/net/bluetooth/l2cap_core.c
91036 @@ -3510,8 +3510,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
91037 break;
91038
91039 case L2CAP_CONF_RFC:
91040 - if (olen == sizeof(rfc))
91041 - memcpy(&rfc, (void *)val, olen);
91042 + if (olen != sizeof(rfc))
91043 + break;
91044 +
91045 + memcpy(&rfc, (void *)val, olen);
91046
91047 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
91048 rfc.mode != chan->mode)
91049 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
91050 index 0098af8..fb5a31f 100644
91051 --- a/net/bluetooth/l2cap_sock.c
91052 +++ b/net/bluetooth/l2cap_sock.c
91053 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91054 struct sock *sk = sock->sk;
91055 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
91056 struct l2cap_options opts;
91057 - int len, err = 0;
91058 + int err = 0;
91059 + size_t len = optlen;
91060 u32 opt;
91061
91062 BT_DBG("sk %p", sk);
91063 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91064 opts.max_tx = chan->max_tx;
91065 opts.txwin_size = chan->tx_win;
91066
91067 - len = min_t(unsigned int, sizeof(opts), optlen);
91068 + len = min(sizeof(opts), len);
91069 if (copy_from_user((char *) &opts, optval, len)) {
91070 err = -EFAULT;
91071 break;
91072 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91073 struct bt_security sec;
91074 struct bt_power pwr;
91075 struct l2cap_conn *conn;
91076 - int len, err = 0;
91077 + int err = 0;
91078 + size_t len = optlen;
91079 u32 opt;
91080
91081 BT_DBG("sk %p", sk);
91082 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91083
91084 sec.level = BT_SECURITY_LOW;
91085
91086 - len = min_t(unsigned int, sizeof(sec), optlen);
91087 + len = min(sizeof(sec), len);
91088 if (copy_from_user((char *) &sec, optval, len)) {
91089 err = -EFAULT;
91090 break;
91091 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91092
91093 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
91094
91095 - len = min_t(unsigned int, sizeof(pwr), optlen);
91096 + len = min(sizeof(pwr), len);
91097 if (copy_from_user((char *) &pwr, optval, len)) {
91098 err = -EFAULT;
91099 break;
91100 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
91101 index 30b3721..c1bd0a0 100644
91102 --- a/net/bluetooth/rfcomm/sock.c
91103 +++ b/net/bluetooth/rfcomm/sock.c
91104 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91105 struct sock *sk = sock->sk;
91106 struct bt_security sec;
91107 int err = 0;
91108 - size_t len;
91109 + size_t len = optlen;
91110 u32 opt;
91111
91112 BT_DBG("sk %p", sk);
91113 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91114
91115 sec.level = BT_SECURITY_LOW;
91116
91117 - len = min_t(unsigned int, sizeof(sec), optlen);
91118 + len = min(sizeof(sec), len);
91119 if (copy_from_user((char *) &sec, optval, len)) {
91120 err = -EFAULT;
91121 break;
91122 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
91123 index b6e44ad..5b0d514 100644
91124 --- a/net/bluetooth/rfcomm/tty.c
91125 +++ b/net/bluetooth/rfcomm/tty.c
91126 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
91127 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
91128
91129 spin_lock_irqsave(&dev->port.lock, flags);
91130 - if (dev->port.count > 0) {
91131 + if (atomic_read(&dev->port.count) > 0) {
91132 spin_unlock_irqrestore(&dev->port.lock, flags);
91133 return;
91134 }
91135 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
91136 return -ENODEV;
91137
91138 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
91139 - dev->channel, dev->port.count);
91140 + dev->channel, atomic_read(&dev->port.count));
91141
91142 spin_lock_irqsave(&dev->port.lock, flags);
91143 - if (++dev->port.count > 1) {
91144 + if (atomic_inc_return(&dev->port.count) > 1) {
91145 spin_unlock_irqrestore(&dev->port.lock, flags);
91146 return 0;
91147 }
91148 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
91149 return;
91150
91151 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
91152 - dev->port.count);
91153 + atomic_read(&dev->port.count));
91154
91155 spin_lock_irqsave(&dev->port.lock, flags);
91156 - if (!--dev->port.count) {
91157 + if (!atomic_dec_return(&dev->port.count)) {
91158 spin_unlock_irqrestore(&dev->port.lock, flags);
91159 if (dev->tty_dev->parent)
91160 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
91161 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
91162 index 5180938..7c470c3 100644
91163 --- a/net/bridge/netfilter/ebt_ulog.c
91164 +++ b/net/bridge/netfilter/ebt_ulog.c
91165 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91166 ub->qlen++;
91167
91168 pm = nlmsg_data(nlh);
91169 + memset(pm, 0, sizeof(*pm));
91170
91171 /* Fill in the ulog data */
91172 pm->version = EBT_ULOG_VERSION;
91173 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91174 pm->hook = hooknr;
91175 if (uloginfo->prefix != NULL)
91176 strcpy(pm->prefix, uloginfo->prefix);
91177 - else
91178 - *(pm->prefix) = '\0';
91179
91180 if (in) {
91181 strcpy(pm->physindev, in->name);
91182 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91183 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
91184 else
91185 strcpy(pm->indev, in->name);
91186 - } else
91187 - pm->indev[0] = pm->physindev[0] = '\0';
91188 + }
91189
91190 if (out) {
91191 /* If out exists, then out is a bridge port */
91192 strcpy(pm->physoutdev, out->name);
91193 /* rcu_read_lock()ed by nf_hook_slow */
91194 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
91195 - } else
91196 - pm->outdev[0] = pm->physoutdev[0] = '\0';
91197 + }
91198
91199 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
91200 BUG();
91201 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
91202 index ac78024..161a80c 100644
91203 --- a/net/bridge/netfilter/ebtables.c
91204 +++ b/net/bridge/netfilter/ebtables.c
91205 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91206 tmp.valid_hooks = t->table->valid_hooks;
91207 }
91208 mutex_unlock(&ebt_mutex);
91209 - if (copy_to_user(user, &tmp, *len) != 0){
91210 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
91211 BUGPRINT("c2u Didn't work\n");
91212 ret = -EFAULT;
91213 break;
91214 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91215 goto out;
91216 tmp.valid_hooks = t->valid_hooks;
91217
91218 - if (copy_to_user(user, &tmp, *len) != 0) {
91219 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91220 ret = -EFAULT;
91221 break;
91222 }
91223 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91224 tmp.entries_size = t->table->entries_size;
91225 tmp.valid_hooks = t->table->valid_hooks;
91226
91227 - if (copy_to_user(user, &tmp, *len) != 0) {
91228 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91229 ret = -EFAULT;
91230 break;
91231 }
91232 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
91233 index 0f45522..dab651f 100644
91234 --- a/net/caif/cfctrl.c
91235 +++ b/net/caif/cfctrl.c
91236 @@ -10,6 +10,7 @@
91237 #include <linux/spinlock.h>
91238 #include <linux/slab.h>
91239 #include <linux/pkt_sched.h>
91240 +#include <linux/sched.h>
91241 #include <net/caif/caif_layer.h>
91242 #include <net/caif/cfpkt.h>
91243 #include <net/caif/cfctrl.h>
91244 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
91245 memset(&dev_info, 0, sizeof(dev_info));
91246 dev_info.id = 0xff;
91247 cfsrvl_init(&this->serv, 0, &dev_info, false);
91248 - atomic_set(&this->req_seq_no, 1);
91249 - atomic_set(&this->rsp_seq_no, 1);
91250 + atomic_set_unchecked(&this->req_seq_no, 1);
91251 + atomic_set_unchecked(&this->rsp_seq_no, 1);
91252 this->serv.layer.receive = cfctrl_recv;
91253 sprintf(this->serv.layer.name, "ctrl");
91254 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
91255 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
91256 struct cfctrl_request_info *req)
91257 {
91258 spin_lock_bh(&ctrl->info_list_lock);
91259 - atomic_inc(&ctrl->req_seq_no);
91260 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
91261 + atomic_inc_unchecked(&ctrl->req_seq_no);
91262 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
91263 list_add_tail(&req->list, &ctrl->list);
91264 spin_unlock_bh(&ctrl->info_list_lock);
91265 }
91266 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
91267 if (p != first)
91268 pr_warn("Requests are not received in order\n");
91269
91270 - atomic_set(&ctrl->rsp_seq_no,
91271 + atomic_set_unchecked(&ctrl->rsp_seq_no,
91272 p->sequence_no);
91273 list_del(&p->list);
91274 goto out;
91275 diff --git a/net/can/af_can.c b/net/can/af_can.c
91276 index 3ab8dd2..b9aef13 100644
91277 --- a/net/can/af_can.c
91278 +++ b/net/can/af_can.c
91279 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
91280 };
91281
91282 /* notifier block for netdevice event */
91283 -static struct notifier_block can_netdev_notifier __read_mostly = {
91284 +static struct notifier_block can_netdev_notifier = {
91285 .notifier_call = can_notifier,
91286 };
91287
91288 diff --git a/net/can/gw.c b/net/can/gw.c
91289 index 2f291f9..98c986a 100644
91290 --- a/net/can/gw.c
91291 +++ b/net/can/gw.c
91292 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
91293 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
91294
91295 static HLIST_HEAD(cgw_list);
91296 -static struct notifier_block notifier;
91297
91298 static struct kmem_cache *cgw_cache __read_mostly;
91299
91300 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
91301 return err;
91302 }
91303
91304 +static struct notifier_block notifier = {
91305 + .notifier_call = cgw_notifier
91306 +};
91307 +
91308 static __init int cgw_module_init(void)
91309 {
91310 /* sanitize given module parameter */
91311 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
91312 return -ENOMEM;
91313
91314 /* set notifier */
91315 - notifier.notifier_call = cgw_notifier;
91316 register_netdevice_notifier(&notifier);
91317
91318 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
91319 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
91320 index eb0a46a..5f3bae8 100644
91321 --- a/net/ceph/messenger.c
91322 +++ b/net/ceph/messenger.c
91323 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
91324 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
91325
91326 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
91327 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
91328 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
91329
91330 static struct page *zero_page; /* used in certain error cases */
91331
91332 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
91333 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
91334 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
91335
91336 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91337 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91338 s = addr_str[i];
91339
91340 switch (ss->ss_family) {
91341 diff --git a/net/compat.c b/net/compat.c
91342 index 8903258..24e30e5 100644
91343 --- a/net/compat.c
91344 +++ b/net/compat.c
91345 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
91346 return -EFAULT;
91347 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
91348 return -EINVAL;
91349 - kmsg->msg_name = compat_ptr(tmp1);
91350 - kmsg->msg_iov = compat_ptr(tmp2);
91351 - kmsg->msg_control = compat_ptr(tmp3);
91352 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
91353 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
91354 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
91355 return 0;
91356 }
91357
91358 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91359
91360 if (kern_msg->msg_namelen) {
91361 if (mode == VERIFY_READ) {
91362 - int err = move_addr_to_kernel(kern_msg->msg_name,
91363 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
91364 kern_msg->msg_namelen,
91365 kern_address);
91366 if (err < 0)
91367 @@ -98,7 +98,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91368 kern_msg->msg_name = NULL;
91369
91370 tot_len = iov_from_user_compat_to_kern(kern_iov,
91371 - (struct compat_iovec __user *)kern_msg->msg_iov,
91372 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
91373 kern_msg->msg_iovlen);
91374 if (tot_len >= 0)
91375 kern_msg->msg_iov = kern_iov;
91376 @@ -118,20 +118,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91377
91378 #define CMSG_COMPAT_FIRSTHDR(msg) \
91379 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
91380 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
91381 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
91382 (struct compat_cmsghdr __user *)NULL)
91383
91384 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
91385 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
91386 (ucmlen) <= (unsigned long) \
91387 ((mhdr)->msg_controllen - \
91388 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
91389 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
91390
91391 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
91392 struct compat_cmsghdr __user *cmsg, int cmsg_len)
91393 {
91394 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
91395 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
91396 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
91397 msg->msg_controllen)
91398 return NULL;
91399 return (struct compat_cmsghdr __user *)ptr;
91400 @@ -221,7 +221,7 @@ Efault:
91401
91402 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
91403 {
91404 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91405 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91406 struct compat_cmsghdr cmhdr;
91407 struct compat_timeval ctv;
91408 struct compat_timespec cts[3];
91409 @@ -277,7 +277,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
91410
91411 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
91412 {
91413 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91414 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91415 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
91416 int fdnum = scm->fp->count;
91417 struct file **fp = scm->fp->fp;
91418 @@ -365,7 +365,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
91419 return -EFAULT;
91420 old_fs = get_fs();
91421 set_fs(KERNEL_DS);
91422 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
91423 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
91424 set_fs(old_fs);
91425
91426 return err;
91427 @@ -426,7 +426,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
91428 len = sizeof(ktime);
91429 old_fs = get_fs();
91430 set_fs(KERNEL_DS);
91431 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
91432 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
91433 set_fs(old_fs);
91434
91435 if (!err) {
91436 @@ -569,7 +569,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91437 case MCAST_JOIN_GROUP:
91438 case MCAST_LEAVE_GROUP:
91439 {
91440 - struct compat_group_req __user *gr32 = (void *)optval;
91441 + struct compat_group_req __user *gr32 = (void __user *)optval;
91442 struct group_req __user *kgr =
91443 compat_alloc_user_space(sizeof(struct group_req));
91444 u32 interface;
91445 @@ -590,7 +590,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91446 case MCAST_BLOCK_SOURCE:
91447 case MCAST_UNBLOCK_SOURCE:
91448 {
91449 - struct compat_group_source_req __user *gsr32 = (void *)optval;
91450 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
91451 struct group_source_req __user *kgsr = compat_alloc_user_space(
91452 sizeof(struct group_source_req));
91453 u32 interface;
91454 @@ -611,7 +611,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91455 }
91456 case MCAST_MSFILTER:
91457 {
91458 - struct compat_group_filter __user *gf32 = (void *)optval;
91459 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91460 struct group_filter __user *kgf;
91461 u32 interface, fmode, numsrc;
91462
91463 @@ -649,7 +649,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
91464 char __user *optval, int __user *optlen,
91465 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
91466 {
91467 - struct compat_group_filter __user *gf32 = (void *)optval;
91468 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91469 struct group_filter __user *kgf;
91470 int __user *koptlen;
91471 u32 interface, fmode, numsrc;
91472 @@ -807,7 +807,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
91473
91474 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
91475 return -EINVAL;
91476 - if (copy_from_user(a, args, nas[call]))
91477 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
91478 return -EFAULT;
91479 a0 = a[0];
91480 a1 = a[1];
91481 diff --git a/net/core/datagram.c b/net/core/datagram.c
91482 index 8ab48cd..57b1a80 100644
91483 --- a/net/core/datagram.c
91484 +++ b/net/core/datagram.c
91485 @@ -300,7 +300,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
91486 }
91487
91488 kfree_skb(skb);
91489 - atomic_inc(&sk->sk_drops);
91490 + atomic_inc_unchecked(&sk->sk_drops);
91491 sk_mem_reclaim_partial(sk);
91492
91493 return err;
91494 diff --git a/net/core/dev.c b/net/core/dev.c
91495 index 26755dd..2a232de 100644
91496 --- a/net/core/dev.c
91497 +++ b/net/core/dev.c
91498 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
91499 {
91500 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
91501 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
91502 - atomic_long_inc(&dev->rx_dropped);
91503 + atomic_long_inc_unchecked(&dev->rx_dropped);
91504 kfree_skb(skb);
91505 return NET_RX_DROP;
91506 }
91507 }
91508
91509 if (unlikely(!is_skb_forwardable(dev, skb))) {
91510 - atomic_long_inc(&dev->rx_dropped);
91511 + atomic_long_inc_unchecked(&dev->rx_dropped);
91512 kfree_skb(skb);
91513 return NET_RX_DROP;
91514 }
91515 @@ -2431,7 +2431,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
91516
91517 struct dev_gso_cb {
91518 void (*destructor)(struct sk_buff *skb);
91519 -};
91520 +} __no_const;
91521
91522 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
91523
91524 @@ -3206,7 +3206,7 @@ enqueue:
91525
91526 local_irq_restore(flags);
91527
91528 - atomic_long_inc(&skb->dev->rx_dropped);
91529 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91530 kfree_skb(skb);
91531 return NET_RX_DROP;
91532 }
91533 @@ -3278,7 +3278,7 @@ int netif_rx_ni(struct sk_buff *skb)
91534 }
91535 EXPORT_SYMBOL(netif_rx_ni);
91536
91537 -static void net_tx_action(struct softirq_action *h)
91538 +static __latent_entropy void net_tx_action(void)
91539 {
91540 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91541
91542 @@ -3612,7 +3612,7 @@ ncls:
91543 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
91544 } else {
91545 drop:
91546 - atomic_long_inc(&skb->dev->rx_dropped);
91547 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91548 kfree_skb(skb);
91549 /* Jamal, now you will not able to escape explaining
91550 * me how you were going to use this. :-)
91551 @@ -4272,7 +4272,7 @@ void netif_napi_del(struct napi_struct *napi)
91552 }
91553 EXPORT_SYMBOL(netif_napi_del);
91554
91555 -static void net_rx_action(struct softirq_action *h)
91556 +static __latent_entropy void net_rx_action(void)
91557 {
91558 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91559 unsigned long time_limit = jiffies + 2;
91560 @@ -5730,7 +5730,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
91561 } else {
91562 netdev_stats_to_stats64(storage, &dev->stats);
91563 }
91564 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
91565 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
91566 return storage;
91567 }
91568 EXPORT_SYMBOL(dev_get_stats);
91569 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
91570 index 5b7d0e1..cb960fc 100644
91571 --- a/net/core/dev_ioctl.c
91572 +++ b/net/core/dev_ioctl.c
91573 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
91574 if (no_module && capable(CAP_NET_ADMIN))
91575 no_module = request_module("netdev-%s", name);
91576 if (no_module && capable(CAP_SYS_MODULE)) {
91577 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
91578 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
91579 +#else
91580 if (!request_module("%s", name))
91581 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
91582 name);
91583 +#endif
91584 }
91585 }
91586 EXPORT_SYMBOL(dev_load);
91587 diff --git a/net/core/flow.c b/net/core/flow.c
91588 index dfa602c..3103d88 100644
91589 --- a/net/core/flow.c
91590 +++ b/net/core/flow.c
91591 @@ -61,7 +61,7 @@ struct flow_cache {
91592 struct timer_list rnd_timer;
91593 };
91594
91595 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
91596 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
91597 EXPORT_SYMBOL(flow_cache_genid);
91598 static struct flow_cache flow_cache_global;
91599 static struct kmem_cache *flow_cachep __read_mostly;
91600 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
91601
91602 static int flow_entry_valid(struct flow_cache_entry *fle)
91603 {
91604 - if (atomic_read(&flow_cache_genid) != fle->genid)
91605 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
91606 return 0;
91607 if (fle->object && !fle->object->ops->check(fle->object))
91608 return 0;
91609 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
91610 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
91611 fcp->hash_count++;
91612 }
91613 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
91614 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
91615 flo = fle->object;
91616 if (!flo)
91617 goto ret_object;
91618 @@ -279,7 +279,7 @@ nocache:
91619 }
91620 flo = resolver(net, key, family, dir, flo, ctx);
91621 if (fle) {
91622 - fle->genid = atomic_read(&flow_cache_genid);
91623 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
91624 if (!IS_ERR(flo))
91625 fle->object = flo;
91626 else
91627 diff --git a/net/core/iovec.c b/net/core/iovec.c
91628 index de178e4..1dabd8b 100644
91629 --- a/net/core/iovec.c
91630 +++ b/net/core/iovec.c
91631 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91632 if (m->msg_namelen) {
91633 if (mode == VERIFY_READ) {
91634 void __user *namep;
91635 - namep = (void __user __force *) m->msg_name;
91636 + namep = (void __force_user *) m->msg_name;
91637 err = move_addr_to_kernel(namep, m->msg_namelen,
91638 address);
91639 if (err < 0)
91640 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91641 }
91642
91643 size = m->msg_iovlen * sizeof(struct iovec);
91644 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
91645 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
91646 return -EFAULT;
91647
91648 m->msg_iov = iov;
91649 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
91650 index 60533db..14842cc 100644
91651 --- a/net/core/neighbour.c
91652 +++ b/net/core/neighbour.c
91653 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
91654 void __user *buffer, size_t *lenp, loff_t *ppos)
91655 {
91656 int size, ret;
91657 - struct ctl_table tmp = *ctl;
91658 + ctl_table_no_const tmp = *ctl;
91659
91660 tmp.extra1 = &zero;
91661 tmp.extra2 = &unres_qlen_max;
91662 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
91663 index 2bf8329..7960607 100644
91664 --- a/net/core/net-procfs.c
91665 +++ b/net/core/net-procfs.c
91666 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
91667 else
91668 seq_printf(seq, "%04x", ntohs(pt->type));
91669
91670 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91671 + seq_printf(seq, " %-8s %pf\n",
91672 + pt->dev ? pt->dev->name : "", NULL);
91673 +#else
91674 seq_printf(seq, " %-8s %pf\n",
91675 pt->dev ? pt->dev->name : "", pt->func);
91676 +#endif
91677 }
91678
91679 return 0;
91680 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
91681 index 981fed3..536af34 100644
91682 --- a/net/core/net-sysfs.c
91683 +++ b/net/core/net-sysfs.c
91684 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
91685 }
91686 EXPORT_SYMBOL(netdev_class_remove_file);
91687
91688 -int netdev_kobject_init(void)
91689 +int __init netdev_kobject_init(void)
91690 {
91691 kobj_ns_type_register(&net_ns_type_operations);
91692 return class_register(&net_class);
91693 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
91694 index f9765203..9feaef8 100644
91695 --- a/net/core/net_namespace.c
91696 +++ b/net/core/net_namespace.c
91697 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
91698 int error;
91699 LIST_HEAD(net_exit_list);
91700
91701 - list_add_tail(&ops->list, list);
91702 + pax_list_add_tail((struct list_head *)&ops->list, list);
91703 if (ops->init || (ops->id && ops->size)) {
91704 for_each_net(net) {
91705 error = ops_init(ops, net);
91706 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
91707
91708 out_undo:
91709 /* If I have an error cleanup all namespaces I initialized */
91710 - list_del(&ops->list);
91711 + pax_list_del((struct list_head *)&ops->list);
91712 ops_exit_list(ops, &net_exit_list);
91713 ops_free_list(ops, &net_exit_list);
91714 return error;
91715 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
91716 struct net *net;
91717 LIST_HEAD(net_exit_list);
91718
91719 - list_del(&ops->list);
91720 + pax_list_del((struct list_head *)&ops->list);
91721 for_each_net(net)
91722 list_add_tail(&net->exit_list, &net_exit_list);
91723 ops_exit_list(ops, &net_exit_list);
91724 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
91725 mutex_lock(&net_mutex);
91726 error = register_pernet_operations(&pernet_list, ops);
91727 if (!error && (first_device == &pernet_list))
91728 - first_device = &ops->list;
91729 + first_device = (struct list_head *)&ops->list;
91730 mutex_unlock(&net_mutex);
91731 return error;
91732 }
91733 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
91734 index fc75c9e..8c8e9be 100644
91735 --- a/net/core/netpoll.c
91736 +++ b/net/core/netpoll.c
91737 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91738 struct udphdr *udph;
91739 struct iphdr *iph;
91740 struct ethhdr *eth;
91741 - static atomic_t ip_ident;
91742 + static atomic_unchecked_t ip_ident;
91743 struct ipv6hdr *ip6h;
91744
91745 udp_len = len + sizeof(*udph);
91746 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91747 put_unaligned(0x45, (unsigned char *)iph);
91748 iph->tos = 0;
91749 put_unaligned(htons(ip_len), &(iph->tot_len));
91750 - iph->id = htons(atomic_inc_return(&ip_ident));
91751 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
91752 iph->frag_off = 0;
91753 iph->ttl = 64;
91754 iph->protocol = IPPROTO_UDP;
91755 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
91756 index ca198c1d1..125372f 100644
91757 --- a/net/core/rtnetlink.c
91758 +++ b/net/core/rtnetlink.c
91759 @@ -58,7 +58,7 @@ struct rtnl_link {
91760 rtnl_doit_func doit;
91761 rtnl_dumpit_func dumpit;
91762 rtnl_calcit_func calcit;
91763 -};
91764 +} __no_const;
91765
91766 static DEFINE_MUTEX(rtnl_mutex);
91767
91768 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
91769 if (rtnl_link_ops_get(ops->kind))
91770 return -EEXIST;
91771
91772 - if (!ops->dellink)
91773 - ops->dellink = unregister_netdevice_queue;
91774 + if (!ops->dellink) {
91775 + pax_open_kernel();
91776 + *(void **)&ops->dellink = unregister_netdevice_queue;
91777 + pax_close_kernel();
91778 + }
91779
91780 - list_add_tail(&ops->list, &link_ops);
91781 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
91782 return 0;
91783 }
91784 EXPORT_SYMBOL_GPL(__rtnl_link_register);
91785 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
91786 for_each_net(net) {
91787 __rtnl_kill_links(net, ops);
91788 }
91789 - list_del(&ops->list);
91790 + pax_list_del((struct list_head *)&ops->list);
91791 }
91792 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
91793
91794 diff --git a/net/core/scm.c b/net/core/scm.c
91795 index b4da80b..98d6bdb 100644
91796 --- a/net/core/scm.c
91797 +++ b/net/core/scm.c
91798 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
91799 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91800 {
91801 struct cmsghdr __user *cm
91802 - = (__force struct cmsghdr __user *)msg->msg_control;
91803 + = (struct cmsghdr __force_user *)msg->msg_control;
91804 struct cmsghdr cmhdr;
91805 int cmlen = CMSG_LEN(len);
91806 int err;
91807 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91808 err = -EFAULT;
91809 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
91810 goto out;
91811 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
91812 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
91813 goto out;
91814 cmlen = CMSG_SPACE(len);
91815 if (msg->msg_controllen < cmlen)
91816 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
91817 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91818 {
91819 struct cmsghdr __user *cm
91820 - = (__force struct cmsghdr __user*)msg->msg_control;
91821 + = (struct cmsghdr __force_user *)msg->msg_control;
91822
91823 int fdmax = 0;
91824 int fdnum = scm->fp->count;
91825 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91826 if (fdnum < fdmax)
91827 fdmax = fdnum;
91828
91829 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
91830 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
91831 i++, cmfptr++)
91832 {
91833 struct socket *sock;
91834 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
91835 index 2c3d0f5..f5a326f 100644
91836 --- a/net/core/skbuff.c
91837 +++ b/net/core/skbuff.c
91838 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
91839 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
91840 sizeof(struct sk_buff),
91841 0,
91842 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91843 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91844 + SLAB_NO_SANITIZE,
91845 NULL);
91846 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
91847 (2*sizeof(struct sk_buff)) +
91848 sizeof(atomic_t),
91849 0,
91850 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91851 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91852 + SLAB_NO_SANITIZE,
91853 NULL);
91854 }
91855
91856 diff --git a/net/core/sock.c b/net/core/sock.c
91857 index 8729d91..4a20427 100644
91858 --- a/net/core/sock.c
91859 +++ b/net/core/sock.c
91860 @@ -392,7 +392,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91861 struct sk_buff_head *list = &sk->sk_receive_queue;
91862
91863 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
91864 - atomic_inc(&sk->sk_drops);
91865 + atomic_inc_unchecked(&sk->sk_drops);
91866 trace_sock_rcvqueue_full(sk, skb);
91867 return -ENOMEM;
91868 }
91869 @@ -402,7 +402,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91870 return err;
91871
91872 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
91873 - atomic_inc(&sk->sk_drops);
91874 + atomic_inc_unchecked(&sk->sk_drops);
91875 return -ENOBUFS;
91876 }
91877
91878 @@ -422,7 +422,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91879 skb_dst_force(skb);
91880
91881 spin_lock_irqsave(&list->lock, flags);
91882 - skb->dropcount = atomic_read(&sk->sk_drops);
91883 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
91884 __skb_queue_tail(list, skb);
91885 spin_unlock_irqrestore(&list->lock, flags);
91886
91887 @@ -442,7 +442,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91888 skb->dev = NULL;
91889
91890 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
91891 - atomic_inc(&sk->sk_drops);
91892 + atomic_inc_unchecked(&sk->sk_drops);
91893 goto discard_and_relse;
91894 }
91895 if (nested)
91896 @@ -460,7 +460,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91897 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
91898 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
91899 bh_unlock_sock(sk);
91900 - atomic_inc(&sk->sk_drops);
91901 + atomic_inc_unchecked(&sk->sk_drops);
91902 goto discard_and_relse;
91903 }
91904
91905 @@ -948,12 +948,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91906 struct timeval tm;
91907 } v;
91908
91909 - int lv = sizeof(int);
91910 - int len;
91911 + unsigned int lv = sizeof(int);
91912 + unsigned int len;
91913
91914 if (get_user(len, optlen))
91915 return -EFAULT;
91916 - if (len < 0)
91917 + if (len > INT_MAX)
91918 return -EINVAL;
91919
91920 memset(&v, 0, sizeof(v));
91921 @@ -1105,11 +1105,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91922
91923 case SO_PEERNAME:
91924 {
91925 - char address[128];
91926 + char address[_K_SS_MAXSIZE];
91927
91928 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
91929 return -ENOTCONN;
91930 - if (lv < len)
91931 + if (lv < len || sizeof address < len)
91932 return -EINVAL;
91933 if (copy_to_user(optval, address, len))
91934 return -EFAULT;
91935 @@ -1182,7 +1182,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91936
91937 if (len > lv)
91938 len = lv;
91939 - if (copy_to_user(optval, &v, len))
91940 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
91941 return -EFAULT;
91942 lenout:
91943 if (put_user(len, optlen))
91944 @@ -2304,7 +2304,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
91945 */
91946 smp_wmb();
91947 atomic_set(&sk->sk_refcnt, 1);
91948 - atomic_set(&sk->sk_drops, 0);
91949 + atomic_set_unchecked(&sk->sk_drops, 0);
91950 }
91951 EXPORT_SYMBOL(sock_init_data);
91952
91953 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
91954 index a0e9cf6..ef7f9ed 100644
91955 --- a/net/core/sock_diag.c
91956 +++ b/net/core/sock_diag.c
91957 @@ -9,26 +9,33 @@
91958 #include <linux/inet_diag.h>
91959 #include <linux/sock_diag.h>
91960
91961 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
91962 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
91963 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
91964 static DEFINE_MUTEX(sock_diag_table_mutex);
91965
91966 int sock_diag_check_cookie(void *sk, __u32 *cookie)
91967 {
91968 +#ifndef CONFIG_GRKERNSEC_HIDESYM
91969 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
91970 cookie[1] != INET_DIAG_NOCOOKIE) &&
91971 ((u32)(unsigned long)sk != cookie[0] ||
91972 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
91973 return -ESTALE;
91974 else
91975 +#endif
91976 return 0;
91977 }
91978 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
91979
91980 void sock_diag_save_cookie(void *sk, __u32 *cookie)
91981 {
91982 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91983 + cookie[0] = 0;
91984 + cookie[1] = 0;
91985 +#else
91986 cookie[0] = (u32)(unsigned long)sk;
91987 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
91988 +#endif
91989 }
91990 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
91991
91992 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
91993 mutex_lock(&sock_diag_table_mutex);
91994 if (sock_diag_handlers[hndl->family])
91995 err = -EBUSY;
91996 - else
91997 + else {
91998 + pax_open_kernel();
91999 sock_diag_handlers[hndl->family] = hndl;
92000 + pax_close_kernel();
92001 + }
92002 mutex_unlock(&sock_diag_table_mutex);
92003
92004 return err;
92005 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
92006
92007 mutex_lock(&sock_diag_table_mutex);
92008 BUG_ON(sock_diag_handlers[family] != hnld);
92009 + pax_open_kernel();
92010 sock_diag_handlers[family] = NULL;
92011 + pax_close_kernel();
92012 mutex_unlock(&sock_diag_table_mutex);
92013 }
92014 EXPORT_SYMBOL_GPL(sock_diag_unregister);
92015 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
92016 index 31107ab..ae03d5a 100644
92017 --- a/net/core/sysctl_net_core.c
92018 +++ b/net/core/sysctl_net_core.c
92019 @@ -31,7 +31,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
92020 {
92021 unsigned int orig_size, size;
92022 int ret, i;
92023 - struct ctl_table tmp = {
92024 + ctl_table_no_const tmp = {
92025 .data = &size,
92026 .maxlen = sizeof(size),
92027 .mode = table->mode
92028 @@ -350,13 +350,12 @@ static struct ctl_table netns_core_table[] = {
92029
92030 static __net_init int sysctl_core_net_init(struct net *net)
92031 {
92032 - struct ctl_table *tbl;
92033 + ctl_table_no_const *tbl = NULL;
92034
92035 net->core.sysctl_somaxconn = SOMAXCONN;
92036
92037 - tbl = netns_core_table;
92038 if (!net_eq(net, &init_net)) {
92039 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
92040 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
92041 if (tbl == NULL)
92042 goto err_dup;
92043
92044 @@ -366,17 +365,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
92045 if (net->user_ns != &init_user_ns) {
92046 tbl[0].procname = NULL;
92047 }
92048 - }
92049 -
92050 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92051 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92052 + } else
92053 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
92054 if (net->core.sysctl_hdr == NULL)
92055 goto err_reg;
92056
92057 return 0;
92058
92059 err_reg:
92060 - if (tbl != netns_core_table)
92061 - kfree(tbl);
92062 + kfree(tbl);
92063 err_dup:
92064 return -ENOMEM;
92065 }
92066 @@ -391,7 +389,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
92067 kfree(tbl);
92068 }
92069
92070 -static __net_initdata struct pernet_operations sysctl_core_ops = {
92071 +static __net_initconst struct pernet_operations sysctl_core_ops = {
92072 .init = sysctl_core_net_init,
92073 .exit = sysctl_core_net_exit,
92074 };
92075 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
92076 index dd4d506..fb2fb87 100644
92077 --- a/net/decnet/af_decnet.c
92078 +++ b/net/decnet/af_decnet.c
92079 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
92080 .sysctl_rmem = sysctl_decnet_rmem,
92081 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
92082 .obj_size = sizeof(struct dn_sock),
92083 + .slab_flags = SLAB_USERCOPY,
92084 };
92085
92086 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
92087 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
92088 index 5325b54..a0d4d69 100644
92089 --- a/net/decnet/sysctl_net_decnet.c
92090 +++ b/net/decnet/sysctl_net_decnet.c
92091 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
92092
92093 if (len > *lenp) len = *lenp;
92094
92095 - if (copy_to_user(buffer, addr, len))
92096 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
92097 return -EFAULT;
92098
92099 *lenp = len;
92100 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
92101
92102 if (len > *lenp) len = *lenp;
92103
92104 - if (copy_to_user(buffer, devname, len))
92105 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
92106 return -EFAULT;
92107
92108 *lenp = len;
92109 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
92110 index 3b9d5f2..d7015c6 100644
92111 --- a/net/ieee802154/6lowpan.c
92112 +++ b/net/ieee802154/6lowpan.c
92113 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
92114 hc06_ptr += 3;
92115 } else {
92116 /* compress nothing */
92117 - memcpy(hc06_ptr, &hdr, 4);
92118 + memcpy(hc06_ptr, hdr, 4);
92119 /* replace the top byte with new ECN | DSCP format */
92120 *hc06_ptr = tmp;
92121 hc06_ptr += 4;
92122 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
92123 index dd6b523..dfe558f 100644
92124 --- a/net/ipv4/af_inet.c
92125 +++ b/net/ipv4/af_inet.c
92126 @@ -1687,13 +1687,9 @@ static int __init inet_init(void)
92127
92128 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
92129
92130 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
92131 - if (!sysctl_local_reserved_ports)
92132 - goto out;
92133 -
92134 rc = proto_register(&tcp_prot, 1);
92135 if (rc)
92136 - goto out_free_reserved_ports;
92137 + goto out;
92138
92139 rc = proto_register(&udp_prot, 1);
92140 if (rc)
92141 @@ -1802,8 +1798,6 @@ out_unregister_udp_proto:
92142 proto_unregister(&udp_prot);
92143 out_unregister_tcp_proto:
92144 proto_unregister(&tcp_prot);
92145 -out_free_reserved_ports:
92146 - kfree(sysctl_local_reserved_ports);
92147 goto out;
92148 }
92149
92150 diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
92151 index b28e863..19e3637 100644
92152 --- a/net/ipv4/datagram.c
92153 +++ b/net/ipv4/datagram.c
92154 @@ -57,7 +57,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
92155 if (IS_ERR(rt)) {
92156 err = PTR_ERR(rt);
92157 if (err == -ENETUNREACH)
92158 - IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
92159 + IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
92160 goto out;
92161 }
92162
92163 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
92164 index 34ca6d5..b6421e8 100644
92165 --- a/net/ipv4/devinet.c
92166 +++ b/net/ipv4/devinet.c
92167 @@ -1532,7 +1532,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
92168 idx = 0;
92169 head = &net->dev_index_head[h];
92170 rcu_read_lock();
92171 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92172 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92173 net->dev_base_seq;
92174 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92175 if (idx < s_idx)
92176 @@ -1843,7 +1843,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
92177 idx = 0;
92178 head = &net->dev_index_head[h];
92179 rcu_read_lock();
92180 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92181 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92182 net->dev_base_seq;
92183 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92184 if (idx < s_idx)
92185 @@ -2068,7 +2068,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
92186 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
92187 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
92188
92189 -static struct devinet_sysctl_table {
92190 +static const struct devinet_sysctl_table {
92191 struct ctl_table_header *sysctl_header;
92192 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
92193 } devinet_sysctl = {
92194 @@ -2186,7 +2186,7 @@ static __net_init int devinet_init_net(struct net *net)
92195 int err;
92196 struct ipv4_devconf *all, *dflt;
92197 #ifdef CONFIG_SYSCTL
92198 - struct ctl_table *tbl = ctl_forward_entry;
92199 + ctl_table_no_const *tbl = NULL;
92200 struct ctl_table_header *forw_hdr;
92201 #endif
92202
92203 @@ -2204,7 +2204,7 @@ static __net_init int devinet_init_net(struct net *net)
92204 goto err_alloc_dflt;
92205
92206 #ifdef CONFIG_SYSCTL
92207 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
92208 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
92209 if (tbl == NULL)
92210 goto err_alloc_ctl;
92211
92212 @@ -2224,7 +2224,10 @@ static __net_init int devinet_init_net(struct net *net)
92213 goto err_reg_dflt;
92214
92215 err = -ENOMEM;
92216 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92217 + if (!net_eq(net, &init_net))
92218 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92219 + else
92220 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
92221 if (forw_hdr == NULL)
92222 goto err_reg_ctl;
92223 net->ipv4.forw_hdr = forw_hdr;
92224 @@ -2240,8 +2243,7 @@ err_reg_ctl:
92225 err_reg_dflt:
92226 __devinet_sysctl_unregister(all);
92227 err_reg_all:
92228 - if (tbl != ctl_forward_entry)
92229 - kfree(tbl);
92230 + kfree(tbl);
92231 err_alloc_ctl:
92232 #endif
92233 if (dflt != &ipv4_devconf_dflt)
92234 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
92235 index b3f627a..b0f3e99 100644
92236 --- a/net/ipv4/fib_frontend.c
92237 +++ b/net/ipv4/fib_frontend.c
92238 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
92239 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92240 fib_sync_up(dev);
92241 #endif
92242 - atomic_inc(&net->ipv4.dev_addr_genid);
92243 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92244 rt_cache_flush(dev_net(dev));
92245 break;
92246 case NETDEV_DOWN:
92247 fib_del_ifaddr(ifa, NULL);
92248 - atomic_inc(&net->ipv4.dev_addr_genid);
92249 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92250 if (ifa->ifa_dev->ifa_list == NULL) {
92251 /* Last address was deleted from this interface.
92252 * Disable IP.
92253 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
92254 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92255 fib_sync_up(dev);
92256 #endif
92257 - atomic_inc(&net->ipv4.dev_addr_genid);
92258 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92259 rt_cache_flush(net);
92260 break;
92261 case NETDEV_DOWN:
92262 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
92263 index d5dbca5..6251d5f 100644
92264 --- a/net/ipv4/fib_semantics.c
92265 +++ b/net/ipv4/fib_semantics.c
92266 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
92267 nh->nh_saddr = inet_select_addr(nh->nh_dev,
92268 nh->nh_gw,
92269 nh->nh_parent->fib_scope);
92270 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
92271 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
92272
92273 return nh->nh_saddr;
92274 }
92275 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
92276 index 6acb541..9ea617d 100644
92277 --- a/net/ipv4/inet_connection_sock.c
92278 +++ b/net/ipv4/inet_connection_sock.c
92279 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
92280 .range = { 32768, 61000 },
92281 };
92282
92283 -unsigned long *sysctl_local_reserved_ports;
92284 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
92285 EXPORT_SYMBOL(sysctl_local_reserved_ports);
92286
92287 void inet_get_local_port_range(int *low, int *high)
92288 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
92289 index 96da9c7..b956690 100644
92290 --- a/net/ipv4/inet_hashtables.c
92291 +++ b/net/ipv4/inet_hashtables.c
92292 @@ -18,12 +18,15 @@
92293 #include <linux/sched.h>
92294 #include <linux/slab.h>
92295 #include <linux/wait.h>
92296 +#include <linux/security.h>
92297
92298 #include <net/inet_connection_sock.h>
92299 #include <net/inet_hashtables.h>
92300 #include <net/secure_seq.h>
92301 #include <net/ip.h>
92302
92303 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
92304 +
92305 /*
92306 * Allocate and initialize a new local port bind bucket.
92307 * The bindhash mutex for snum's hash chain must be held here.
92308 @@ -554,6 +557,8 @@ ok:
92309 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
92310 spin_unlock(&head->lock);
92311
92312 + gr_update_task_in_ip_table(current, inet_sk(sk));
92313 +
92314 if (tw) {
92315 inet_twsk_deschedule(tw, death_row);
92316 while (twrefcnt) {
92317 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
92318 index 33d5537..da337a4 100644
92319 --- a/net/ipv4/inetpeer.c
92320 +++ b/net/ipv4/inetpeer.c
92321 @@ -503,8 +503,8 @@ relookup:
92322 if (p) {
92323 p->daddr = *daddr;
92324 atomic_set(&p->refcnt, 1);
92325 - atomic_set(&p->rid, 0);
92326 - atomic_set(&p->ip_id_count,
92327 + atomic_set_unchecked(&p->rid, 0);
92328 + atomic_set_unchecked(&p->ip_id_count,
92329 (daddr->family == AF_INET) ?
92330 secure_ip_id(daddr->addr.a4) :
92331 secure_ipv6_id(daddr->addr.a6));
92332 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
92333 index b66910a..cfe416e 100644
92334 --- a/net/ipv4/ip_fragment.c
92335 +++ b/net/ipv4/ip_fragment.c
92336 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
92337 return 0;
92338
92339 start = qp->rid;
92340 - end = atomic_inc_return(&peer->rid);
92341 + end = atomic_inc_return_unchecked(&peer->rid);
92342 qp->rid = end;
92343
92344 rc = qp->q.fragments && (end - start) > max;
92345 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
92346
92347 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92348 {
92349 - struct ctl_table *table;
92350 + ctl_table_no_const *table = NULL;
92351 struct ctl_table_header *hdr;
92352
92353 - table = ip4_frags_ns_ctl_table;
92354 if (!net_eq(net, &init_net)) {
92355 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92356 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92357 if (table == NULL)
92358 goto err_alloc;
92359
92360 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92361 /* Don't export sysctls to unprivileged users */
92362 if (net->user_ns != &init_user_ns)
92363 table[0].procname = NULL;
92364 - }
92365 + hdr = register_net_sysctl(net, "net/ipv4", table);
92366 + } else
92367 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
92368
92369 - hdr = register_net_sysctl(net, "net/ipv4", table);
92370 if (hdr == NULL)
92371 goto err_reg;
92372
92373 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92374 return 0;
92375
92376 err_reg:
92377 - if (!net_eq(net, &init_net))
92378 - kfree(table);
92379 + kfree(table);
92380 err_alloc:
92381 return -ENOMEM;
92382 }
92383 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
92384 index 8d6939e..19d0a95 100644
92385 --- a/net/ipv4/ip_gre.c
92386 +++ b/net/ipv4/ip_gre.c
92387 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
92388 module_param(log_ecn_error, bool, 0644);
92389 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92390
92391 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
92392 +static struct rtnl_link_ops ipgre_link_ops;
92393 static int ipgre_tunnel_init(struct net_device *dev);
92394
92395 static int ipgre_net_id __read_mostly;
92396 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
92397 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
92398 };
92399
92400 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92401 +static struct rtnl_link_ops ipgre_link_ops = {
92402 .kind = "gre",
92403 .maxtype = IFLA_GRE_MAX,
92404 .policy = ipgre_policy,
92405 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92406 .fill_info = ipgre_fill_info,
92407 };
92408
92409 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
92410 +static struct rtnl_link_ops ipgre_tap_ops = {
92411 .kind = "gretap",
92412 .maxtype = IFLA_GRE_MAX,
92413 .policy = ipgre_policy,
92414 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
92415 index d9c4f11..02b82dbc 100644
92416 --- a/net/ipv4/ip_sockglue.c
92417 +++ b/net/ipv4/ip_sockglue.c
92418 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92419 len = min_t(unsigned int, len, opt->optlen);
92420 if (put_user(len, optlen))
92421 return -EFAULT;
92422 - if (copy_to_user(optval, opt->__data, len))
92423 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
92424 + copy_to_user(optval, opt->__data, len))
92425 return -EFAULT;
92426 return 0;
92427 }
92428 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92429 if (sk->sk_type != SOCK_STREAM)
92430 return -ENOPROTOOPT;
92431
92432 - msg.msg_control = optval;
92433 + msg.msg_control = (void __force_kernel *)optval;
92434 msg.msg_controllen = len;
92435 msg.msg_flags = flags;
92436
92437 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
92438 index 0656041..d6ecb60 100644
92439 --- a/net/ipv4/ip_vti.c
92440 +++ b/net/ipv4/ip_vti.c
92441 @@ -47,7 +47,7 @@
92442 #define HASH_SIZE 16
92443 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
92444
92445 -static struct rtnl_link_ops vti_link_ops __read_mostly;
92446 +static struct rtnl_link_ops vti_link_ops;
92447
92448 static int vti_net_id __read_mostly;
92449 struct vti_net {
92450 @@ -848,7 +848,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
92451 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
92452 };
92453
92454 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
92455 +static struct rtnl_link_ops vti_link_ops = {
92456 .kind = "vti",
92457 .maxtype = IFLA_VTI_MAX,
92458 .policy = vti_policy,
92459 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
92460 index efa1138..20dbba0 100644
92461 --- a/net/ipv4/ipconfig.c
92462 +++ b/net/ipv4/ipconfig.c
92463 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
92464
92465 mm_segment_t oldfs = get_fs();
92466 set_fs(get_ds());
92467 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92468 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92469 set_fs(oldfs);
92470 return res;
92471 }
92472 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
92473
92474 mm_segment_t oldfs = get_fs();
92475 set_fs(get_ds());
92476 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92477 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92478 set_fs(oldfs);
92479 return res;
92480 }
92481 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
92482
92483 mm_segment_t oldfs = get_fs();
92484 set_fs(get_ds());
92485 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
92486 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
92487 set_fs(oldfs);
92488 return res;
92489 }
92490 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
92491 index b3ac3c3..ec6bd95 100644
92492 --- a/net/ipv4/ipip.c
92493 +++ b/net/ipv4/ipip.c
92494 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92495 static int ipip_net_id __read_mostly;
92496
92497 static int ipip_tunnel_init(struct net_device *dev);
92498 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
92499 +static struct rtnl_link_ops ipip_link_ops;
92500
92501 static int ipip_err(struct sk_buff *skb, u32 info)
92502 {
92503 @@ -409,7 +409,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
92504 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
92505 };
92506
92507 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
92508 +static struct rtnl_link_ops ipip_link_ops = {
92509 .kind = "ipip",
92510 .maxtype = IFLA_IPTUN_MAX,
92511 .policy = ipip_policy,
92512 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
92513 index 85a4f21..1beb1f5 100644
92514 --- a/net/ipv4/netfilter/arp_tables.c
92515 +++ b/net/ipv4/netfilter/arp_tables.c
92516 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
92517 #endif
92518
92519 static int get_info(struct net *net, void __user *user,
92520 - const int *len, int compat)
92521 + int len, int compat)
92522 {
92523 char name[XT_TABLE_MAXNAMELEN];
92524 struct xt_table *t;
92525 int ret;
92526
92527 - if (*len != sizeof(struct arpt_getinfo)) {
92528 - duprintf("length %u != %Zu\n", *len,
92529 + if (len != sizeof(struct arpt_getinfo)) {
92530 + duprintf("length %u != %Zu\n", len,
92531 sizeof(struct arpt_getinfo));
92532 return -EINVAL;
92533 }
92534 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
92535 info.size = private->size;
92536 strcpy(info.name, name);
92537
92538 - if (copy_to_user(user, &info, *len) != 0)
92539 + if (copy_to_user(user, &info, len) != 0)
92540 ret = -EFAULT;
92541 else
92542 ret = 0;
92543 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
92544
92545 switch (cmd) {
92546 case ARPT_SO_GET_INFO:
92547 - ret = get_info(sock_net(sk), user, len, 1);
92548 + ret = get_info(sock_net(sk), user, *len, 1);
92549 break;
92550 case ARPT_SO_GET_ENTRIES:
92551 ret = compat_get_entries(sock_net(sk), user, len);
92552 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
92553
92554 switch (cmd) {
92555 case ARPT_SO_GET_INFO:
92556 - ret = get_info(sock_net(sk), user, len, 0);
92557 + ret = get_info(sock_net(sk), user, *len, 0);
92558 break;
92559
92560 case ARPT_SO_GET_ENTRIES:
92561 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
92562 index d23118d..6ad7277 100644
92563 --- a/net/ipv4/netfilter/ip_tables.c
92564 +++ b/net/ipv4/netfilter/ip_tables.c
92565 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
92566 #endif
92567
92568 static int get_info(struct net *net, void __user *user,
92569 - const int *len, int compat)
92570 + int len, int compat)
92571 {
92572 char name[XT_TABLE_MAXNAMELEN];
92573 struct xt_table *t;
92574 int ret;
92575
92576 - if (*len != sizeof(struct ipt_getinfo)) {
92577 - duprintf("length %u != %zu\n", *len,
92578 + if (len != sizeof(struct ipt_getinfo)) {
92579 + duprintf("length %u != %zu\n", len,
92580 sizeof(struct ipt_getinfo));
92581 return -EINVAL;
92582 }
92583 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
92584 info.size = private->size;
92585 strcpy(info.name, name);
92586
92587 - if (copy_to_user(user, &info, *len) != 0)
92588 + if (copy_to_user(user, &info, len) != 0)
92589 ret = -EFAULT;
92590 else
92591 ret = 0;
92592 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92593
92594 switch (cmd) {
92595 case IPT_SO_GET_INFO:
92596 - ret = get_info(sock_net(sk), user, len, 1);
92597 + ret = get_info(sock_net(sk), user, *len, 1);
92598 break;
92599 case IPT_SO_GET_ENTRIES:
92600 ret = compat_get_entries(sock_net(sk), user, len);
92601 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92602
92603 switch (cmd) {
92604 case IPT_SO_GET_INFO:
92605 - ret = get_info(sock_net(sk), user, len, 0);
92606 + ret = get_info(sock_net(sk), user, *len, 0);
92607 break;
92608
92609 case IPT_SO_GET_ENTRIES:
92610 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
92611 index cbc2215..9cb993c 100644
92612 --- a/net/ipv4/netfilter/ipt_ULOG.c
92613 +++ b/net/ipv4/netfilter/ipt_ULOG.c
92614 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
92615 ub->qlen++;
92616
92617 pm = nlmsg_data(nlh);
92618 + memset(pm, 0, sizeof(*pm));
92619
92620 /* We might not have a timestamp, get one */
92621 if (skb->tstamp.tv64 == 0)
92622 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
92623 }
92624 else if (loginfo->prefix[0] != '\0')
92625 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
92626 - else
92627 - *(pm->prefix) = '\0';
92628
92629 if (in && in->hard_header_len > 0 &&
92630 skb->mac_header != skb->network_header &&
92631 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
92632
92633 if (in)
92634 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
92635 - else
92636 - pm->indev_name[0] = '\0';
92637
92638 if (out)
92639 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
92640 - else
92641 - pm->outdev_name[0] = '\0';
92642
92643 /* copy_len <= skb->len, so can't fail. */
92644 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
92645 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
92646 index 746427c..a73be71 100644
92647 --- a/net/ipv4/ping.c
92648 +++ b/net/ipv4/ping.c
92649 @@ -55,7 +55,7 @@
92650
92651
92652 struct ping_table ping_table;
92653 -struct pingv6_ops pingv6_ops;
92654 +struct pingv6_ops *pingv6_ops;
92655 EXPORT_SYMBOL_GPL(pingv6_ops);
92656
92657 static u16 ping_port_rover;
92658 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
92659 return -ENODEV;
92660 }
92661 }
92662 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
92663 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
92664 scoped);
92665 rcu_read_unlock();
92666
92667 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92668 }
92669 #if IS_ENABLED(CONFIG_IPV6)
92670 } else if (skb->protocol == htons(ETH_P_IPV6)) {
92671 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
92672 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
92673 #endif
92674 }
92675
92676 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92677 info, (u8 *)icmph);
92678 #if IS_ENABLED(CONFIG_IPV6)
92679 } else if (family == AF_INET6) {
92680 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
92681 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
92682 info, (u8 *)icmph);
92683 #endif
92684 }
92685 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92686 return ip_recv_error(sk, msg, len);
92687 #if IS_ENABLED(CONFIG_IPV6)
92688 } else if (family == AF_INET6) {
92689 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
92690 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
92691 #endif
92692 }
92693 }
92694 @@ -874,11 +874,14 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92695
92696 /* Copy the address and add cmsg data. */
92697 if (family == AF_INET) {
92698 - sin = (struct sockaddr_in *) msg->msg_name;
92699 - sin->sin_family = AF_INET;
92700 - sin->sin_port = 0 /* skb->h.uh->source */;
92701 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
92702 - memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
92703 + struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
92704 +
92705 + if (sin) {
92706 + sin->sin_family = AF_INET;
92707 + sin->sin_port = 0 /* skb->h.uh->source */;
92708 + sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
92709 + memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
92710 + }
92711
92712 if (isk->cmsg_flags)
92713 ip_cmsg_recv(msg, skb);
92714 @@ -887,20 +890,23 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92715 } else if (family == AF_INET6) {
92716 struct ipv6_pinfo *np = inet6_sk(sk);
92717 struct ipv6hdr *ip6 = ipv6_hdr(skb);
92718 - sin6 = (struct sockaddr_in6 *) msg->msg_name;
92719 - sin6->sin6_family = AF_INET6;
92720 - sin6->sin6_port = 0;
92721 - sin6->sin6_addr = ip6->saddr;
92722 + struct sockaddr_in6 *sin6 =
92723 + (struct sockaddr_in6 *)msg->msg_name;
92724
92725 - sin6->sin6_flowinfo = 0;
92726 - if (np->sndflow)
92727 - sin6->sin6_flowinfo = ip6_flowinfo(ip6);
92728 -
92729 - sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr,
92730 - IP6CB(skb)->iif);
92731 + if (sin6) {
92732 + sin6->sin6_family = AF_INET6;
92733 + sin6->sin6_port = 0;
92734 + sin6->sin6_addr = ip6->saddr;
92735 + sin6->sin6_flowinfo = 0;
92736 + if (np->sndflow)
92737 + sin6->sin6_flowinfo = ip6_flowinfo(ip6);
92738 + sin6->sin6_scope_id =
92739 + ipv6_iface_scope_id(&sin6->sin6_addr,
92740 + IP6CB(skb)->iif);
92741 + }
92742
92743 if (inet6_sk(sk)->rxopt.all)
92744 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
92745 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
92746 #endif
92747 } else {
92748 BUG();
92749 @@ -1090,7 +1096,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
92750 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
92751 0, sock_i_ino(sp),
92752 atomic_read(&sp->sk_refcnt), sp,
92753 - atomic_read(&sp->sk_drops), len);
92754 + atomic_read_unchecked(&sp->sk_drops), len);
92755 }
92756
92757 static int ping_v4_seq_show(struct seq_file *seq, void *v)
92758 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
92759 index 6fb2337..9cd6b20 100644
92760 --- a/net/ipv4/raw.c
92761 +++ b/net/ipv4/raw.c
92762 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
92763 int raw_rcv(struct sock *sk, struct sk_buff *skb)
92764 {
92765 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
92766 - atomic_inc(&sk->sk_drops);
92767 + atomic_inc_unchecked(&sk->sk_drops);
92768 kfree_skb(skb);
92769 return NET_RX_DROP;
92770 }
92771 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
92772
92773 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
92774 {
92775 + struct icmp_filter filter;
92776 +
92777 if (optlen > sizeof(struct icmp_filter))
92778 optlen = sizeof(struct icmp_filter);
92779 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
92780 + if (copy_from_user(&filter, optval, optlen))
92781 return -EFAULT;
92782 + raw_sk(sk)->filter = filter;
92783 return 0;
92784 }
92785
92786 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
92787 {
92788 int len, ret = -EFAULT;
92789 + struct icmp_filter filter;
92790
92791 if (get_user(len, optlen))
92792 goto out;
92793 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
92794 if (len > sizeof(struct icmp_filter))
92795 len = sizeof(struct icmp_filter);
92796 ret = -EFAULT;
92797 - if (put_user(len, optlen) ||
92798 - copy_to_user(optval, &raw_sk(sk)->filter, len))
92799 + filter = raw_sk(sk)->filter;
92800 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
92801 goto out;
92802 ret = 0;
92803 out: return ret;
92804 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
92805 0, 0L, 0,
92806 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
92807 0, sock_i_ino(sp),
92808 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
92809 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
92810 }
92811
92812 static int raw_seq_show(struct seq_file *seq, void *v)
92813 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
92814 index 2de16d9..da558c7 100644
92815 --- a/net/ipv4/route.c
92816 +++ b/net/ipv4/route.c
92817 @@ -2615,34 +2615,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
92818 .maxlen = sizeof(int),
92819 .mode = 0200,
92820 .proc_handler = ipv4_sysctl_rtcache_flush,
92821 + .extra1 = &init_net,
92822 },
92823 { },
92824 };
92825
92826 static __net_init int sysctl_route_net_init(struct net *net)
92827 {
92828 - struct ctl_table *tbl;
92829 + ctl_table_no_const *tbl = NULL;
92830
92831 - tbl = ipv4_route_flush_table;
92832 if (!net_eq(net, &init_net)) {
92833 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92834 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92835 if (tbl == NULL)
92836 goto err_dup;
92837
92838 /* Don't export sysctls to unprivileged users */
92839 if (net->user_ns != &init_user_ns)
92840 tbl[0].procname = NULL;
92841 - }
92842 - tbl[0].extra1 = net;
92843 + tbl[0].extra1 = net;
92844 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92845 + } else
92846 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
92847
92848 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92849 if (net->ipv4.route_hdr == NULL)
92850 goto err_reg;
92851 return 0;
92852
92853 err_reg:
92854 - if (tbl != ipv4_route_flush_table)
92855 - kfree(tbl);
92856 + kfree(tbl);
92857 err_dup:
92858 return -ENOMEM;
92859 }
92860 @@ -2665,8 +2665,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
92861
92862 static __net_init int rt_genid_init(struct net *net)
92863 {
92864 - atomic_set(&net->rt_genid, 0);
92865 - atomic_set(&net->fnhe_genid, 0);
92866 + atomic_set_unchecked(&net->rt_genid, 0);
92867 + atomic_set_unchecked(&net->fnhe_genid, 0);
92868 get_random_bytes(&net->ipv4.dev_addr_genid,
92869 sizeof(net->ipv4.dev_addr_genid));
92870 return 0;
92871 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
92872 index 6900b8b..7832c6b 100644
92873 --- a/net/ipv4/sysctl_net_ipv4.c
92874 +++ b/net/ipv4/sysctl_net_ipv4.c
92875 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
92876 {
92877 int ret;
92878 int range[2];
92879 - struct ctl_table tmp = {
92880 + ctl_table_no_const tmp = {
92881 .data = &range,
92882 .maxlen = sizeof(range),
92883 .mode = table->mode,
92884 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
92885 int ret;
92886 gid_t urange[2];
92887 kgid_t low, high;
92888 - struct ctl_table tmp = {
92889 + ctl_table_no_const tmp = {
92890 .data = &urange,
92891 .maxlen = sizeof(urange),
92892 .mode = table->mode,
92893 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
92894 void __user *buffer, size_t *lenp, loff_t *ppos)
92895 {
92896 char val[TCP_CA_NAME_MAX];
92897 - struct ctl_table tbl = {
92898 + ctl_table_no_const tbl = {
92899 .data = val,
92900 .maxlen = TCP_CA_NAME_MAX,
92901 };
92902 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
92903 void __user *buffer, size_t *lenp,
92904 loff_t *ppos)
92905 {
92906 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
92907 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
92908 int ret;
92909
92910 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92911 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
92912 void __user *buffer, size_t *lenp,
92913 loff_t *ppos)
92914 {
92915 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
92916 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
92917 int ret;
92918
92919 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92920 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
92921 struct mem_cgroup *memcg;
92922 #endif
92923
92924 - struct ctl_table tmp = {
92925 + ctl_table_no_const tmp = {
92926 .data = &vec,
92927 .maxlen = sizeof(vec),
92928 .mode = ctl->mode,
92929 };
92930
92931 if (!write) {
92932 - ctl->data = &net->ipv4.sysctl_tcp_mem;
92933 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
92934 + ctl_table_no_const tcp_mem = *ctl;
92935 +
92936 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
92937 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
92938 }
92939
92940 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
92941 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
92942 void __user *buffer, size_t *lenp,
92943 loff_t *ppos)
92944 {
92945 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92946 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92947 struct tcp_fastopen_context *ctxt;
92948 int ret;
92949 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
92950 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
92951 },
92952 {
92953 .procname = "ip_local_reserved_ports",
92954 - .data = NULL, /* initialized in sysctl_ipv4_init */
92955 + .data = sysctl_local_reserved_ports,
92956 .maxlen = 65536,
92957 .mode = 0644,
92958 .proc_handler = proc_do_large_bitmap,
92959 @@ -857,11 +859,10 @@ static struct ctl_table ipv4_net_table[] = {
92960
92961 static __net_init int ipv4_sysctl_init_net(struct net *net)
92962 {
92963 - struct ctl_table *table;
92964 + ctl_table_no_const *table = NULL;
92965
92966 - table = ipv4_net_table;
92967 if (!net_eq(net, &init_net)) {
92968 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
92969 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
92970 if (table == NULL)
92971 goto err_alloc;
92972
92973 @@ -896,15 +897,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
92974
92975 tcp_init_mem(net);
92976
92977 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92978 + if (!net_eq(net, &init_net))
92979 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92980 + else
92981 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
92982 if (net->ipv4.ipv4_hdr == NULL)
92983 goto err_reg;
92984
92985 return 0;
92986
92987 err_reg:
92988 - if (!net_eq(net, &init_net))
92989 - kfree(table);
92990 + kfree(table);
92991 err_alloc:
92992 return -ENOMEM;
92993 }
92994 @@ -926,16 +929,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
92995 static __init int sysctl_ipv4_init(void)
92996 {
92997 struct ctl_table_header *hdr;
92998 - struct ctl_table *i;
92999 -
93000 - for (i = ipv4_table; i->procname; i++) {
93001 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
93002 - i->data = sysctl_local_reserved_ports;
93003 - break;
93004 - }
93005 - }
93006 - if (!i->procname)
93007 - return -EINVAL;
93008
93009 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
93010 if (hdr == NULL)
93011 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
93012 index 723951a..61cf1cc 100644
93013 --- a/net/ipv4/tcp_input.c
93014 +++ b/net/ipv4/tcp_input.c
93015 @@ -4412,7 +4412,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
93016 * simplifies code)
93017 */
93018 static void
93019 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93020 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93021 struct sk_buff *head, struct sk_buff *tail,
93022 u32 start, u32 end)
93023 {
93024 @@ -5498,6 +5498,7 @@ discard:
93025 tcp_paws_reject(&tp->rx_opt, 0))
93026 goto discard_and_undo;
93027
93028 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
93029 if (th->syn) {
93030 /* We see SYN without ACK. It is attempt of
93031 * simultaneous connect with crossed SYNs.
93032 @@ -5548,6 +5549,7 @@ discard:
93033 goto discard;
93034 #endif
93035 }
93036 +#endif
93037 /* "fifth, if neither of the SYN or RST bits is set then
93038 * drop the segment and return."
93039 */
93040 @@ -5593,7 +5595,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
93041 goto discard;
93042
93043 if (th->syn) {
93044 - if (th->fin)
93045 + if (th->fin || th->urg || th->psh)
93046 goto discard;
93047 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
93048 return 1;
93049 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
93050 index b299da5..097db06 100644
93051 --- a/net/ipv4/tcp_ipv4.c
93052 +++ b/net/ipv4/tcp_ipv4.c
93053 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
93054 EXPORT_SYMBOL(sysctl_tcp_low_latency);
93055
93056
93057 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93058 +extern int grsec_enable_blackhole;
93059 +#endif
93060 +
93061 #ifdef CONFIG_TCP_MD5SIG
93062 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
93063 __be32 daddr, __be32 saddr, const struct tcphdr *th);
93064 @@ -1830,6 +1834,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
93065 return 0;
93066
93067 reset:
93068 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93069 + if (!grsec_enable_blackhole)
93070 +#endif
93071 tcp_v4_send_reset(rsk, skb);
93072 discard:
93073 kfree_skb(skb);
93074 @@ -1975,12 +1982,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
93075 TCP_SKB_CB(skb)->sacked = 0;
93076
93077 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93078 - if (!sk)
93079 + if (!sk) {
93080 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93081 + ret = 1;
93082 +#endif
93083 goto no_tcp_socket;
93084 -
93085 + }
93086 process:
93087 - if (sk->sk_state == TCP_TIME_WAIT)
93088 + if (sk->sk_state == TCP_TIME_WAIT) {
93089 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93090 + ret = 2;
93091 +#endif
93092 goto do_time_wait;
93093 + }
93094
93095 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
93096 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93097 @@ -2034,6 +2048,10 @@ csum_error:
93098 bad_packet:
93099 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93100 } else {
93101 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93102 + if (!grsec_enable_blackhole || (ret == 1 &&
93103 + (skb->dev->flags & IFF_LOOPBACK)))
93104 +#endif
93105 tcp_v4_send_reset(NULL, skb);
93106 }
93107
93108 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
93109 index ab1c086..2a8d76b 100644
93110 --- a/net/ipv4/tcp_minisocks.c
93111 +++ b/net/ipv4/tcp_minisocks.c
93112 @@ -27,6 +27,10 @@
93113 #include <net/inet_common.h>
93114 #include <net/xfrm.h>
93115
93116 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93117 +extern int grsec_enable_blackhole;
93118 +#endif
93119 +
93120 int sysctl_tcp_syncookies __read_mostly = 1;
93121 EXPORT_SYMBOL(sysctl_tcp_syncookies);
93122
93123 @@ -715,7 +719,10 @@ embryonic_reset:
93124 * avoid becoming vulnerable to outside attack aiming at
93125 * resetting legit local connections.
93126 */
93127 - req->rsk_ops->send_reset(sk, skb);
93128 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93129 + if (!grsec_enable_blackhole)
93130 +#endif
93131 + req->rsk_ops->send_reset(sk, skb);
93132 } else if (fastopen) { /* received a valid RST pkt */
93133 reqsk_fastopen_remove(sk, req, true);
93134 tcp_reset(sk);
93135 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
93136 index d4943f6..e7a74a5 100644
93137 --- a/net/ipv4/tcp_probe.c
93138 +++ b/net/ipv4/tcp_probe.c
93139 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
93140 if (cnt + width >= len)
93141 break;
93142
93143 - if (copy_to_user(buf + cnt, tbuf, width))
93144 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
93145 return -EFAULT;
93146 cnt += width;
93147 }
93148 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
93149 index 4b85e6f..22f9ac9 100644
93150 --- a/net/ipv4/tcp_timer.c
93151 +++ b/net/ipv4/tcp_timer.c
93152 @@ -22,6 +22,10 @@
93153 #include <linux/gfp.h>
93154 #include <net/tcp.h>
93155
93156 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93157 +extern int grsec_lastack_retries;
93158 +#endif
93159 +
93160 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
93161 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
93162 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
93163 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
93164 }
93165 }
93166
93167 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93168 + if ((sk->sk_state == TCP_LAST_ACK) &&
93169 + (grsec_lastack_retries > 0) &&
93170 + (grsec_lastack_retries < retry_until))
93171 + retry_until = grsec_lastack_retries;
93172 +#endif
93173 +
93174 if (retransmits_timed_out(sk, retry_until,
93175 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
93176 /* Has it gone just too far? */
93177 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
93178 index 766e6ba..aff2f8d 100644
93179 --- a/net/ipv4/udp.c
93180 +++ b/net/ipv4/udp.c
93181 @@ -87,6 +87,7 @@
93182 #include <linux/types.h>
93183 #include <linux/fcntl.h>
93184 #include <linux/module.h>
93185 +#include <linux/security.h>
93186 #include <linux/socket.h>
93187 #include <linux/sockios.h>
93188 #include <linux/igmp.h>
93189 @@ -112,6 +113,10 @@
93190 #include <net/busy_poll.h>
93191 #include "udp_impl.h"
93192
93193 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93194 +extern int grsec_enable_blackhole;
93195 +#endif
93196 +
93197 struct udp_table udp_table __read_mostly;
93198 EXPORT_SYMBOL(udp_table);
93199
93200 @@ -595,6 +600,9 @@ found:
93201 return s;
93202 }
93203
93204 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
93205 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
93206 +
93207 /*
93208 * This routine is called by the ICMP module when it gets some
93209 * sort of error condition. If err < 0 then the socket should
93210 @@ -891,9 +899,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93211 dport = usin->sin_port;
93212 if (dport == 0)
93213 return -EINVAL;
93214 +
93215 + err = gr_search_udp_sendmsg(sk, usin);
93216 + if (err)
93217 + return err;
93218 } else {
93219 if (sk->sk_state != TCP_ESTABLISHED)
93220 return -EDESTADDRREQ;
93221 +
93222 + err = gr_search_udp_sendmsg(sk, NULL);
93223 + if (err)
93224 + return err;
93225 +
93226 daddr = inet->inet_daddr;
93227 dport = inet->inet_dport;
93228 /* Open fast path for connected socket.
93229 @@ -1137,7 +1154,7 @@ static unsigned int first_packet_length(struct sock *sk)
93230 IS_UDPLITE(sk));
93231 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93232 IS_UDPLITE(sk));
93233 - atomic_inc(&sk->sk_drops);
93234 + atomic_inc_unchecked(&sk->sk_drops);
93235 __skb_unlink(skb, rcvq);
93236 __skb_queue_tail(&list_kill, skb);
93237 }
93238 @@ -1223,6 +1240,10 @@ try_again:
93239 if (!skb)
93240 goto out;
93241
93242 + err = gr_search_udp_recvmsg(sk, skb);
93243 + if (err)
93244 + goto out_free;
93245 +
93246 ulen = skb->len - sizeof(struct udphdr);
93247 copied = len;
93248 if (copied > ulen)
93249 @@ -1256,7 +1277,7 @@ try_again:
93250 if (unlikely(err)) {
93251 trace_kfree_skb(skb, udp_recvmsg);
93252 if (!peeked) {
93253 - atomic_inc(&sk->sk_drops);
93254 + atomic_inc_unchecked(&sk->sk_drops);
93255 UDP_INC_STATS_USER(sock_net(sk),
93256 UDP_MIB_INERRORS, is_udplite);
93257 }
93258 @@ -1543,7 +1564,7 @@ csum_error:
93259 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93260 drop:
93261 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93262 - atomic_inc(&sk->sk_drops);
93263 + atomic_inc_unchecked(&sk->sk_drops);
93264 kfree_skb(skb);
93265 return -1;
93266 }
93267 @@ -1562,7 +1583,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93268 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93269
93270 if (!skb1) {
93271 - atomic_inc(&sk->sk_drops);
93272 + atomic_inc_unchecked(&sk->sk_drops);
93273 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93274 IS_UDPLITE(sk));
93275 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93276 @@ -1734,6 +1755,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93277 goto csum_error;
93278
93279 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93280 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93281 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93282 +#endif
93283 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
93284
93285 /*
93286 @@ -2166,7 +2190,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
93287 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93288 0, sock_i_ino(sp),
93289 atomic_read(&sp->sk_refcnt), sp,
93290 - atomic_read(&sp->sk_drops), len);
93291 + atomic_read_unchecked(&sp->sk_drops), len);
93292 }
93293
93294 int udp4_seq_show(struct seq_file *seq, void *v)
93295 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
93296 index 9a459be..c7bc04c 100644
93297 --- a/net/ipv4/xfrm4_policy.c
93298 +++ b/net/ipv4/xfrm4_policy.c
93299 @@ -181,11 +181,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
93300 fl4->flowi4_tos = iph->tos;
93301 }
93302
93303 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
93304 +static int xfrm4_garbage_collect(struct dst_ops *ops)
93305 {
93306 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
93307
93308 - xfrm4_policy_afinfo.garbage_collect(net);
93309 + xfrm_garbage_collect_deferred(net);
93310 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
93311 }
93312
93313 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
93314
93315 static int __net_init xfrm4_net_init(struct net *net)
93316 {
93317 - struct ctl_table *table;
93318 + ctl_table_no_const *table = NULL;
93319 struct ctl_table_header *hdr;
93320
93321 - table = xfrm4_policy_table;
93322 if (!net_eq(net, &init_net)) {
93323 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93324 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93325 if (!table)
93326 goto err_alloc;
93327
93328 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
93329 - }
93330 -
93331 - hdr = register_net_sysctl(net, "net/ipv4", table);
93332 + hdr = register_net_sysctl(net, "net/ipv4", table);
93333 + } else
93334 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
93335 if (!hdr)
93336 goto err_reg;
93337
93338 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
93339 return 0;
93340
93341 err_reg:
93342 - if (!net_eq(net, &init_net))
93343 - kfree(table);
93344 + kfree(table);
93345 err_alloc:
93346 return -ENOMEM;
93347 }
93348 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
93349 index 0f99f7b..9375cf5 100644
93350 --- a/net/ipv6/addrconf.c
93351 +++ b/net/ipv6/addrconf.c
93352 @@ -618,7 +618,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
93353 idx = 0;
93354 head = &net->dev_index_head[h];
93355 rcu_read_lock();
93356 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
93357 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
93358 net->dev_base_seq;
93359 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93360 if (idx < s_idx)
93361 @@ -2408,7 +2408,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
93362 p.iph.ihl = 5;
93363 p.iph.protocol = IPPROTO_IPV6;
93364 p.iph.ttl = 64;
93365 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
93366 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
93367
93368 if (ops->ndo_do_ioctl) {
93369 mm_segment_t oldfs = get_fs();
93370 @@ -4057,7 +4057,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
93371 s_ip_idx = ip_idx = cb->args[2];
93372
93373 rcu_read_lock();
93374 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93375 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93376 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
93377 idx = 0;
93378 head = &net->dev_index_head[h];
93379 @@ -4678,7 +4678,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93380 dst_free(&ifp->rt->dst);
93381 break;
93382 }
93383 - atomic_inc(&net->ipv6.dev_addr_genid);
93384 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
93385 }
93386
93387 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93388 @@ -4698,7 +4698,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
93389 int *valp = ctl->data;
93390 int val = *valp;
93391 loff_t pos = *ppos;
93392 - struct ctl_table lctl;
93393 + ctl_table_no_const lctl;
93394 int ret;
93395
93396 /*
93397 @@ -4783,7 +4783,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
93398 int *valp = ctl->data;
93399 int val = *valp;
93400 loff_t pos = *ppos;
93401 - struct ctl_table lctl;
93402 + ctl_table_no_const lctl;
93403 int ret;
93404
93405 /*
93406 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
93407 index 197e6f4..16d8396 100644
93408 --- a/net/ipv6/datagram.c
93409 +++ b/net/ipv6/datagram.c
93410 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
93411 0,
93412 sock_i_ino(sp),
93413 atomic_read(&sp->sk_refcnt), sp,
93414 - atomic_read(&sp->sk_drops));
93415 + atomic_read_unchecked(&sp->sk_drops));
93416 }
93417 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
93418 index 7cfc8d2..c5394b6 100644
93419 --- a/net/ipv6/icmp.c
93420 +++ b/net/ipv6/icmp.c
93421 @@ -989,7 +989,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
93422
93423 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
93424 {
93425 - struct ctl_table *table;
93426 + ctl_table_no_const *table;
93427
93428 table = kmemdup(ipv6_icmp_table_template,
93429 sizeof(ipv6_icmp_table_template),
93430 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
93431 index 8bc717b..76fbb5d 100644
93432 --- a/net/ipv6/ip6_gre.c
93433 +++ b/net/ipv6/ip6_gre.c
93434 @@ -74,7 +74,7 @@ struct ip6gre_net {
93435 struct net_device *fb_tunnel_dev;
93436 };
93437
93438 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
93439 +static struct rtnl_link_ops ip6gre_link_ops;
93440 static int ip6gre_tunnel_init(struct net_device *dev);
93441 static void ip6gre_tunnel_setup(struct net_device *dev);
93442 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
93443 @@ -1288,7 +1288,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
93444 }
93445
93446
93447 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
93448 +static struct inet6_protocol ip6gre_protocol = {
93449 .handler = ip6gre_rcv,
93450 .err_handler = ip6gre_err,
93451 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
93452 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
93453 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
93454 };
93455
93456 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93457 +static struct rtnl_link_ops ip6gre_link_ops = {
93458 .kind = "ip6gre",
93459 .maxtype = IFLA_GRE_MAX,
93460 .policy = ip6gre_policy,
93461 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93462 .fill_info = ip6gre_fill_info,
93463 };
93464
93465 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
93466 +static struct rtnl_link_ops ip6gre_tap_ops = {
93467 .kind = "ip6gretap",
93468 .maxtype = IFLA_GRE_MAX,
93469 .policy = ip6gre_policy,
93470 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
93471 index cf5d490..30946f0 100644
93472 --- a/net/ipv6/ip6_tunnel.c
93473 +++ b/net/ipv6/ip6_tunnel.c
93474 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
93475
93476 static int ip6_tnl_dev_init(struct net_device *dev);
93477 static void ip6_tnl_dev_setup(struct net_device *dev);
93478 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
93479 +static struct rtnl_link_ops ip6_link_ops;
93480
93481 static int ip6_tnl_net_id __read_mostly;
93482 struct ip6_tnl_net {
93483 @@ -1678,7 +1678,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
93484 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
93485 };
93486
93487 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
93488 +static struct rtnl_link_ops ip6_link_ops = {
93489 .kind = "ip6tnl",
93490 .maxtype = IFLA_IPTUN_MAX,
93491 .policy = ip6_tnl_policy,
93492 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
93493 index d1e2e8e..51c19ae 100644
93494 --- a/net/ipv6/ipv6_sockglue.c
93495 +++ b/net/ipv6/ipv6_sockglue.c
93496 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
93497 if (sk->sk_type != SOCK_STREAM)
93498 return -ENOPROTOOPT;
93499
93500 - msg.msg_control = optval;
93501 + msg.msg_control = (void __force_kernel *)optval;
93502 msg.msg_controllen = len;
93503 msg.msg_flags = flags;
93504
93505 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
93506 index 44400c2..8e11f52 100644
93507 --- a/net/ipv6/netfilter/ip6_tables.c
93508 +++ b/net/ipv6/netfilter/ip6_tables.c
93509 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
93510 #endif
93511
93512 static int get_info(struct net *net, void __user *user,
93513 - const int *len, int compat)
93514 + int len, int compat)
93515 {
93516 char name[XT_TABLE_MAXNAMELEN];
93517 struct xt_table *t;
93518 int ret;
93519
93520 - if (*len != sizeof(struct ip6t_getinfo)) {
93521 - duprintf("length %u != %zu\n", *len,
93522 + if (len != sizeof(struct ip6t_getinfo)) {
93523 + duprintf("length %u != %zu\n", len,
93524 sizeof(struct ip6t_getinfo));
93525 return -EINVAL;
93526 }
93527 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
93528 info.size = private->size;
93529 strcpy(info.name, name);
93530
93531 - if (copy_to_user(user, &info, *len) != 0)
93532 + if (copy_to_user(user, &info, len) != 0)
93533 ret = -EFAULT;
93534 else
93535 ret = 0;
93536 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93537
93538 switch (cmd) {
93539 case IP6T_SO_GET_INFO:
93540 - ret = get_info(sock_net(sk), user, len, 1);
93541 + ret = get_info(sock_net(sk), user, *len, 1);
93542 break;
93543 case IP6T_SO_GET_ENTRIES:
93544 ret = compat_get_entries(sock_net(sk), user, len);
93545 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93546
93547 switch (cmd) {
93548 case IP6T_SO_GET_INFO:
93549 - ret = get_info(sock_net(sk), user, len, 0);
93550 + ret = get_info(sock_net(sk), user, *len, 0);
93551 break;
93552
93553 case IP6T_SO_GET_ENTRIES:
93554 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
93555 index dffdc1a..ccc6678 100644
93556 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
93557 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
93558 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
93559
93560 static int nf_ct_frag6_sysctl_register(struct net *net)
93561 {
93562 - struct ctl_table *table;
93563 + ctl_table_no_const *table = NULL;
93564 struct ctl_table_header *hdr;
93565
93566 - table = nf_ct_frag6_sysctl_table;
93567 if (!net_eq(net, &init_net)) {
93568 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
93569 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
93570 GFP_KERNEL);
93571 if (table == NULL)
93572 goto err_alloc;
93573 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93574 table[0].data = &net->nf_frag.frags.timeout;
93575 table[1].data = &net->nf_frag.frags.low_thresh;
93576 table[2].data = &net->nf_frag.frags.high_thresh;
93577 - }
93578 -
93579 - hdr = register_net_sysctl(net, "net/netfilter", table);
93580 + hdr = register_net_sysctl(net, "net/netfilter", table);
93581 + } else
93582 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
93583 if (hdr == NULL)
93584 goto err_reg;
93585
93586 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93587 return 0;
93588
93589 err_reg:
93590 - if (!net_eq(net, &init_net))
93591 - kfree(table);
93592 + kfree(table);
93593 err_alloc:
93594 return -ENOMEM;
93595 }
93596 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
93597 index ab92a36..bb4a528 100644
93598 --- a/net/ipv6/output_core.c
93599 +++ b/net/ipv6/output_core.c
93600 @@ -8,8 +8,8 @@
93601
93602 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93603 {
93604 - static atomic_t ipv6_fragmentation_id;
93605 - int old, new;
93606 + static atomic_unchecked_t ipv6_fragmentation_id;
93607 + int id;
93608
93609 #if IS_ENABLED(CONFIG_IPV6)
93610 if (rt && !(rt->dst.flags & DST_NOPEER)) {
93611 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93612 }
93613 }
93614 #endif
93615 - do {
93616 - old = atomic_read(&ipv6_fragmentation_id);
93617 - new = old + 1;
93618 - if (!new)
93619 - new = 1;
93620 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
93621 - fhdr->identification = htonl(new);
93622 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93623 + if (!id)
93624 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93625 + fhdr->identification = htonl(id);
93626 }
93627 EXPORT_SYMBOL(ipv6_select_ident);
93628
93629 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
93630 index 18f19df..b46ada1 100644
93631 --- a/net/ipv6/ping.c
93632 +++ b/net/ipv6/ping.c
93633 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
93634 };
93635 #endif
93636
93637 +static struct pingv6_ops real_pingv6_ops = {
93638 + .ipv6_recv_error = ipv6_recv_error,
93639 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
93640 + .icmpv6_err_convert = icmpv6_err_convert,
93641 + .ipv6_icmp_error = ipv6_icmp_error,
93642 + .ipv6_chk_addr = ipv6_chk_addr,
93643 +};
93644 +
93645 +static struct pingv6_ops dummy_pingv6_ops = {
93646 + .ipv6_recv_error = dummy_ipv6_recv_error,
93647 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
93648 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
93649 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
93650 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
93651 +};
93652 +
93653 int __init pingv6_init(void)
93654 {
93655 #ifdef CONFIG_PROC_FS
93656 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
93657 if (ret)
93658 return ret;
93659 #endif
93660 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
93661 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
93662 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
93663 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
93664 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
93665 + pingv6_ops = &real_pingv6_ops;
93666 return inet6_register_protosw(&pingv6_protosw);
93667 }
93668
93669 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
93670 */
93671 void pingv6_exit(void)
93672 {
93673 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
93674 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
93675 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
93676 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
93677 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
93678 + pingv6_ops = &dummy_pingv6_ops;
93679 #ifdef CONFIG_PROC_FS
93680 unregister_pernet_subsys(&ping_v6_net_ops);
93681 #endif
93682 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
93683 index cdaed47..515edde9 100644
93684 --- a/net/ipv6/raw.c
93685 +++ b/net/ipv6/raw.c
93686 @@ -108,7 +108,7 @@ found:
93687 */
93688 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
93689 {
93690 - struct icmp6hdr *_hdr;
93691 + struct icmp6hdr _hdr;
93692 const struct icmp6hdr *hdr;
93693
93694 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
93695 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
93696 {
93697 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
93698 skb_checksum_complete(skb)) {
93699 - atomic_inc(&sk->sk_drops);
93700 + atomic_inc_unchecked(&sk->sk_drops);
93701 kfree_skb(skb);
93702 return NET_RX_DROP;
93703 }
93704 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93705 struct raw6_sock *rp = raw6_sk(sk);
93706
93707 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
93708 - atomic_inc(&sk->sk_drops);
93709 + atomic_inc_unchecked(&sk->sk_drops);
93710 kfree_skb(skb);
93711 return NET_RX_DROP;
93712 }
93713 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93714
93715 if (inet->hdrincl) {
93716 if (skb_checksum_complete(skb)) {
93717 - atomic_inc(&sk->sk_drops);
93718 + atomic_inc_unchecked(&sk->sk_drops);
93719 kfree_skb(skb);
93720 return NET_RX_DROP;
93721 }
93722 @@ -602,7 +602,7 @@ out:
93723 return err;
93724 }
93725
93726 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
93727 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
93728 struct flowi6 *fl6, struct dst_entry **dstp,
93729 unsigned int flags)
93730 {
93731 @@ -915,12 +915,15 @@ do_confirm:
93732 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
93733 char __user *optval, int optlen)
93734 {
93735 + struct icmp6_filter filter;
93736 +
93737 switch (optname) {
93738 case ICMPV6_FILTER:
93739 if (optlen > sizeof(struct icmp6_filter))
93740 optlen = sizeof(struct icmp6_filter);
93741 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
93742 + if (copy_from_user(&filter, optval, optlen))
93743 return -EFAULT;
93744 + raw6_sk(sk)->filter = filter;
93745 return 0;
93746 default:
93747 return -ENOPROTOOPT;
93748 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93749 char __user *optval, int __user *optlen)
93750 {
93751 int len;
93752 + struct icmp6_filter filter;
93753
93754 switch (optname) {
93755 case ICMPV6_FILTER:
93756 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93757 len = sizeof(struct icmp6_filter);
93758 if (put_user(len, optlen))
93759 return -EFAULT;
93760 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
93761 + filter = raw6_sk(sk)->filter;
93762 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
93763 return -EFAULT;
93764 return 0;
93765 default:
93766 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
93767 index 1aeb473..bea761c 100644
93768 --- a/net/ipv6/reassembly.c
93769 +++ b/net/ipv6/reassembly.c
93770 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
93771
93772 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93773 {
93774 - struct ctl_table *table;
93775 + ctl_table_no_const *table = NULL;
93776 struct ctl_table_header *hdr;
93777
93778 - table = ip6_frags_ns_ctl_table;
93779 if (!net_eq(net, &init_net)) {
93780 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93781 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93782 if (table == NULL)
93783 goto err_alloc;
93784
93785 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93786 /* Don't export sysctls to unprivileged users */
93787 if (net->user_ns != &init_user_ns)
93788 table[0].procname = NULL;
93789 - }
93790 + hdr = register_net_sysctl(net, "net/ipv6", table);
93791 + } else
93792 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
93793
93794 - hdr = register_net_sysctl(net, "net/ipv6", table);
93795 if (hdr == NULL)
93796 goto err_reg;
93797
93798 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93799 return 0;
93800
93801 err_reg:
93802 - if (!net_eq(net, &init_net))
93803 - kfree(table);
93804 + kfree(table);
93805 err_alloc:
93806 return -ENOMEM;
93807 }
93808 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
93809 index c9bd97b..a15506e 100644
93810 --- a/net/ipv6/route.c
93811 +++ b/net/ipv6/route.c
93812 @@ -2957,7 +2957,7 @@ struct ctl_table ipv6_route_table_template[] = {
93813
93814 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
93815 {
93816 - struct ctl_table *table;
93817 + ctl_table_no_const *table;
93818
93819 table = kmemdup(ipv6_route_table_template,
93820 sizeof(ipv6_route_table_template),
93821 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
93822 index a51ad07..a90bc19 100644
93823 --- a/net/ipv6/sit.c
93824 +++ b/net/ipv6/sit.c
93825 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
93826 static void ipip6_dev_free(struct net_device *dev);
93827 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
93828 __be32 *v4dst);
93829 -static struct rtnl_link_ops sit_link_ops __read_mostly;
93830 +static struct rtnl_link_ops sit_link_ops;
93831
93832 static int sit_net_id __read_mostly;
93833 struct sit_net {
93834 @@ -1601,7 +1601,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
93835 #endif
93836 };
93837
93838 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
93839 +static struct rtnl_link_ops sit_link_ops = {
93840 .kind = "sit",
93841 .maxtype = IFLA_IPTUN_MAX,
93842 .policy = ipip6_policy,
93843 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
93844 index 107b2f1..72741a9 100644
93845 --- a/net/ipv6/sysctl_net_ipv6.c
93846 +++ b/net/ipv6/sysctl_net_ipv6.c
93847 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
93848
93849 static int __net_init ipv6_sysctl_net_init(struct net *net)
93850 {
93851 - struct ctl_table *ipv6_table;
93852 + ctl_table_no_const *ipv6_table;
93853 struct ctl_table *ipv6_route_table;
93854 struct ctl_table *ipv6_icmp_table;
93855 int err;
93856 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
93857 index 6e1649d..75ddb4c 100644
93858 --- a/net/ipv6/tcp_ipv6.c
93859 +++ b/net/ipv6/tcp_ipv6.c
93860 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
93861 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
93862 }
93863
93864 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93865 +extern int grsec_enable_blackhole;
93866 +#endif
93867 +
93868 static void tcp_v6_hash(struct sock *sk)
93869 {
93870 if (sk->sk_state != TCP_CLOSE) {
93871 @@ -1399,6 +1403,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
93872 return 0;
93873
93874 reset:
93875 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93876 + if (!grsec_enable_blackhole)
93877 +#endif
93878 tcp_v6_send_reset(sk, skb);
93879 discard:
93880 if (opt_skb)
93881 @@ -1427,7 +1434,7 @@ ipv6_pktoptions:
93882 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
93883 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
93884 if (np->rxopt.bits.rxtclass)
93885 - np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
93886 + np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
93887 if (ipv6_opt_accepted(sk, opt_skb)) {
93888 skb_set_owner_r(opt_skb, sk);
93889 opt_skb = xchg(&np->pktoptions, opt_skb);
93890 @@ -1481,12 +1488,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
93891 TCP_SKB_CB(skb)->sacked = 0;
93892
93893 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93894 - if (!sk)
93895 + if (!sk) {
93896 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93897 + ret = 1;
93898 +#endif
93899 goto no_tcp_socket;
93900 + }
93901
93902 process:
93903 - if (sk->sk_state == TCP_TIME_WAIT)
93904 + if (sk->sk_state == TCP_TIME_WAIT) {
93905 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93906 + ret = 2;
93907 +#endif
93908 goto do_time_wait;
93909 + }
93910
93911 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
93912 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93913 @@ -1538,6 +1553,10 @@ csum_error:
93914 bad_packet:
93915 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93916 } else {
93917 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93918 + if (!grsec_enable_blackhole || (ret == 1 &&
93919 + (skb->dev->flags & IFF_LOOPBACK)))
93920 +#endif
93921 tcp_v6_send_reset(NULL, skb);
93922 }
93923
93924 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
93925 index f405815..45a68a6 100644
93926 --- a/net/ipv6/udp.c
93927 +++ b/net/ipv6/udp.c
93928 @@ -53,6 +53,10 @@
93929 #include <trace/events/skb.h>
93930 #include "udp_impl.h"
93931
93932 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93933 +extern int grsec_enable_blackhole;
93934 +#endif
93935 +
93936 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
93937 {
93938 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
93939 @@ -420,7 +424,7 @@ try_again:
93940 if (unlikely(err)) {
93941 trace_kfree_skb(skb, udpv6_recvmsg);
93942 if (!peeked) {
93943 - atomic_inc(&sk->sk_drops);
93944 + atomic_inc_unchecked(&sk->sk_drops);
93945 if (is_udp4)
93946 UDP_INC_STATS_USER(sock_net(sk),
93947 UDP_MIB_INERRORS,
93948 @@ -666,7 +670,7 @@ csum_error:
93949 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93950 drop:
93951 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93952 - atomic_inc(&sk->sk_drops);
93953 + atomic_inc_unchecked(&sk->sk_drops);
93954 kfree_skb(skb);
93955 return -1;
93956 }
93957 @@ -724,7 +728,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93958 if (likely(skb1 == NULL))
93959 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93960 if (!skb1) {
93961 - atomic_inc(&sk->sk_drops);
93962 + atomic_inc_unchecked(&sk->sk_drops);
93963 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93964 IS_UDPLITE(sk));
93965 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93966 @@ -864,6 +868,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93967 goto csum_error;
93968
93969 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93970 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93971 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93972 +#endif
93973 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
93974
93975 kfree_skb(skb);
93976 diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
93977 index 5d1b8d7..657914b 100644
93978 --- a/net/ipv6/udp_offload.c
93979 +++ b/net/ipv6/udp_offload.c
93980 @@ -86,7 +86,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
93981
93982 /* Check if there is enough headroom to insert fragment header. */
93983 tnl_hlen = skb_tnl_header_len(skb);
93984 - if (skb_headroom(skb) < (tnl_hlen + frag_hdr_sz)) {
93985 + if (skb->mac_header < (tnl_hlen + frag_hdr_sz)) {
93986 if (gso_pskb_expand_head(skb, tnl_hlen + frag_hdr_sz))
93987 goto out;
93988 }
93989 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
93990 index 23ed03d..6532e67 100644
93991 --- a/net/ipv6/xfrm6_policy.c
93992 +++ b/net/ipv6/xfrm6_policy.c
93993 @@ -207,11 +207,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
93994 }
93995 }
93996
93997 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
93998 +static int xfrm6_garbage_collect(struct dst_ops *ops)
93999 {
94000 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
94001
94002 - xfrm6_policy_afinfo.garbage_collect(net);
94003 + xfrm_garbage_collect_deferred(net);
94004 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
94005 }
94006
94007 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
94008
94009 static int __net_init xfrm6_net_init(struct net *net)
94010 {
94011 - struct ctl_table *table;
94012 + ctl_table_no_const *table = NULL;
94013 struct ctl_table_header *hdr;
94014
94015 - table = xfrm6_policy_table;
94016 if (!net_eq(net, &init_net)) {
94017 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94018 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94019 if (!table)
94020 goto err_alloc;
94021
94022 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
94023 - }
94024 + hdr = register_net_sysctl(net, "net/ipv6", table);
94025 + } else
94026 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
94027
94028 - hdr = register_net_sysctl(net, "net/ipv6", table);
94029 if (!hdr)
94030 goto err_reg;
94031
94032 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
94033 return 0;
94034
94035 err_reg:
94036 - if (!net_eq(net, &init_net))
94037 - kfree(table);
94038 + kfree(table);
94039 err_alloc:
94040 return -ENOMEM;
94041 }
94042 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
94043 index 41ac7938..75e3bb1 100644
94044 --- a/net/irda/ircomm/ircomm_tty.c
94045 +++ b/net/irda/ircomm/ircomm_tty.c
94046 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94047 add_wait_queue(&port->open_wait, &wait);
94048
94049 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
94050 - __FILE__, __LINE__, tty->driver->name, port->count);
94051 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94052
94053 spin_lock_irqsave(&port->lock, flags);
94054 if (!tty_hung_up_p(filp))
94055 - port->count--;
94056 + atomic_dec(&port->count);
94057 port->blocked_open++;
94058 spin_unlock_irqrestore(&port->lock, flags);
94059
94060 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94061 }
94062
94063 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
94064 - __FILE__, __LINE__, tty->driver->name, port->count);
94065 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94066
94067 schedule();
94068 }
94069 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94070
94071 spin_lock_irqsave(&port->lock, flags);
94072 if (!tty_hung_up_p(filp))
94073 - port->count++;
94074 + atomic_inc(&port->count);
94075 port->blocked_open--;
94076 spin_unlock_irqrestore(&port->lock, flags);
94077
94078 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
94079 - __FILE__, __LINE__, tty->driver->name, port->count);
94080 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94081
94082 if (!retval)
94083 port->flags |= ASYNC_NORMAL_ACTIVE;
94084 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
94085
94086 /* ++ is not atomic, so this should be protected - Jean II */
94087 spin_lock_irqsave(&self->port.lock, flags);
94088 - self->port.count++;
94089 + atomic_inc(&self->port.count);
94090 spin_unlock_irqrestore(&self->port.lock, flags);
94091 tty_port_tty_set(&self->port, tty);
94092
94093 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
94094 - self->line, self->port.count);
94095 + self->line, atomic_read(&self->port.count));
94096
94097 /* Not really used by us, but lets do it anyway */
94098 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
94099 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
94100 tty_kref_put(port->tty);
94101 }
94102 port->tty = NULL;
94103 - port->count = 0;
94104 + atomic_set(&port->count, 0);
94105 spin_unlock_irqrestore(&port->lock, flags);
94106
94107 wake_up_interruptible(&port->open_wait);
94108 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
94109 seq_putc(m, '\n');
94110
94111 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
94112 - seq_printf(m, "Open count: %d\n", self->port.count);
94113 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
94114 seq_printf(m, "Max data size: %d\n", self->max_data_size);
94115 seq_printf(m, "Max header size: %d\n", self->max_header_size);
94116
94117 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
94118 index 168aff5..9d43132 100644
94119 --- a/net/iucv/af_iucv.c
94120 +++ b/net/iucv/af_iucv.c
94121 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
94122
94123 write_lock_bh(&iucv_sk_list.lock);
94124
94125 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
94126 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94127 while (__iucv_get_sock_by_name(name)) {
94128 sprintf(name, "%08x",
94129 - atomic_inc_return(&iucv_sk_list.autobind_name));
94130 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94131 }
94132
94133 write_unlock_bh(&iucv_sk_list.lock);
94134 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
94135 index cd5b8ec..f205e6b 100644
94136 --- a/net/iucv/iucv.c
94137 +++ b/net/iucv/iucv.c
94138 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
94139 return NOTIFY_OK;
94140 }
94141
94142 -static struct notifier_block __refdata iucv_cpu_notifier = {
94143 +static struct notifier_block iucv_cpu_notifier = {
94144 .notifier_call = iucv_cpu_notify,
94145 };
94146
94147 diff --git a/net/key/af_key.c b/net/key/af_key.c
94148 index ab8bd2c..3a3eb81 100644
94149 --- a/net/key/af_key.c
94150 +++ b/net/key/af_key.c
94151 @@ -1098,7 +1098,8 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
94152
94153 x->id.proto = proto;
94154 x->id.spi = sa->sadb_sa_spi;
94155 - x->props.replay_window = sa->sadb_sa_replay;
94156 + x->props.replay_window = min_t(unsigned int, sa->sadb_sa_replay,
94157 + (sizeof(x->replay.bitmap) * 8));
94158 if (sa->sadb_sa_flags & SADB_SAFLAGS_NOECN)
94159 x->props.flags |= XFRM_STATE_NOECN;
94160 if (sa->sadb_sa_flags & SADB_SAFLAGS_DECAP_DSCP)
94161 @@ -3048,10 +3049,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
94162 static u32 get_acqseq(void)
94163 {
94164 u32 res;
94165 - static atomic_t acqseq;
94166 + static atomic_unchecked_t acqseq;
94167
94168 do {
94169 - res = atomic_inc_return(&acqseq);
94170 + res = atomic_inc_return_unchecked(&acqseq);
94171 } while (!res);
94172 return res;
94173 }
94174 diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
94175 index b076e83..793e6ff 100644
94176 --- a/net/l2tp/l2tp_core.c
94177 +++ b/net/l2tp/l2tp_core.c
94178 @@ -501,6 +501,7 @@ out:
94179 static inline int l2tp_verify_udp_checksum(struct sock *sk,
94180 struct sk_buff *skb)
94181 {
94182 + struct l2tp_tunnel *tunnel = (struct l2tp_tunnel *)sk->sk_user_data;
94183 struct udphdr *uh = udp_hdr(skb);
94184 u16 ulen = ntohs(uh->len);
94185 __wsum psum;
94186 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
94187 index a4b2154..b2fef6f 100644
94188 --- a/net/mac80211/cfg.c
94189 +++ b/net/mac80211/cfg.c
94190 @@ -820,7 +820,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
94191 ret = ieee80211_vif_use_channel(sdata, chandef,
94192 IEEE80211_CHANCTX_EXCLUSIVE);
94193 }
94194 - } else if (local->open_count == local->monitors) {
94195 + } else if (local_read(&local->open_count) == local->monitors) {
94196 local->_oper_chandef = *chandef;
94197 ieee80211_hw_config(local, 0);
94198 }
94199 @@ -2941,7 +2941,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
94200 else
94201 local->probe_req_reg--;
94202
94203 - if (!local->open_count)
94204 + if (!local_read(&local->open_count))
94205 break;
94206
94207 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
94208 @@ -3404,8 +3404,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
94209 if (chanctx_conf) {
94210 *chandef = chanctx_conf->def;
94211 ret = 0;
94212 - } else if (local->open_count > 0 &&
94213 - local->open_count == local->monitors &&
94214 + } else if (local_read(&local->open_count) > 0 &&
94215 + local_read(&local->open_count) == local->monitors &&
94216 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
94217 if (local->use_chanctx)
94218 *chandef = local->monitor_chandef;
94219 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
94220 index 8c0f8e6..438e580 100644
94221 --- a/net/mac80211/ieee80211_i.h
94222 +++ b/net/mac80211/ieee80211_i.h
94223 @@ -28,6 +28,7 @@
94224 #include <net/ieee80211_radiotap.h>
94225 #include <net/cfg80211.h>
94226 #include <net/mac80211.h>
94227 +#include <asm/local.h>
94228 #include "key.h"
94229 #include "sta_info.h"
94230 #include "debug.h"
94231 @@ -910,7 +911,7 @@ struct ieee80211_local {
94232 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
94233 spinlock_t queue_stop_reason_lock;
94234
94235 - int open_count;
94236 + local_t open_count;
94237 int monitors, cooked_mntrs;
94238 /* number of interfaces with corresponding FIF_ flags */
94239 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
94240 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
94241 index cc11759..11d5541 100644
94242 --- a/net/mac80211/iface.c
94243 +++ b/net/mac80211/iface.c
94244 @@ -511,7 +511,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94245 break;
94246 }
94247
94248 - if (local->open_count == 0) {
94249 + if (local_read(&local->open_count) == 0) {
94250 res = drv_start(local);
94251 if (res)
94252 goto err_del_bss;
94253 @@ -558,7 +558,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94254 res = drv_add_interface(local, sdata);
94255 if (res)
94256 goto err_stop;
94257 - } else if (local->monitors == 0 && local->open_count == 0) {
94258 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
94259 res = ieee80211_add_virtual_monitor(local);
94260 if (res)
94261 goto err_stop;
94262 @@ -666,7 +666,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94263 atomic_inc(&local->iff_promiscs);
94264
94265 if (coming_up)
94266 - local->open_count++;
94267 + local_inc(&local->open_count);
94268
94269 if (hw_reconf_flags)
94270 ieee80211_hw_config(local, hw_reconf_flags);
94271 @@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94272 err_del_interface:
94273 drv_remove_interface(local, sdata);
94274 err_stop:
94275 - if (!local->open_count)
94276 + if (!local_read(&local->open_count))
94277 drv_stop(local);
94278 err_del_bss:
94279 sdata->bss = NULL;
94280 @@ -841,7 +841,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94281 }
94282
94283 if (going_down)
94284 - local->open_count--;
94285 + local_dec(&local->open_count);
94286
94287 switch (sdata->vif.type) {
94288 case NL80211_IFTYPE_AP_VLAN:
94289 @@ -908,7 +908,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94290 }
94291 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
94292
94293 - if (local->open_count == 0)
94294 + if (local_read(&local->open_count) == 0)
94295 ieee80211_clear_tx_pending(local);
94296
94297 /*
94298 @@ -948,7 +948,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94299
94300 ieee80211_recalc_ps(local, -1);
94301
94302 - if (local->open_count == 0) {
94303 + if (local_read(&local->open_count) == 0) {
94304 ieee80211_stop_device(local);
94305
94306 /* no reconfiguring after stop! */
94307 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94308 ieee80211_configure_filter(local);
94309 ieee80211_hw_config(local, hw_reconf_flags);
94310
94311 - if (local->monitors == local->open_count)
94312 + if (local->monitors == local_read(&local->open_count))
94313 ieee80211_add_virtual_monitor(local);
94314 }
94315
94316 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
94317 index 091088a..daf43c7 100644
94318 --- a/net/mac80211/main.c
94319 +++ b/net/mac80211/main.c
94320 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
94321 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
94322 IEEE80211_CONF_CHANGE_POWER);
94323
94324 - if (changed && local->open_count) {
94325 + if (changed && local_read(&local->open_count)) {
94326 ret = drv_config(local, changed);
94327 /*
94328 * Goal:
94329 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
94330 index 3401262..d5cd68d 100644
94331 --- a/net/mac80211/pm.c
94332 +++ b/net/mac80211/pm.c
94333 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94334 struct ieee80211_sub_if_data *sdata;
94335 struct sta_info *sta;
94336
94337 - if (!local->open_count)
94338 + if (!local_read(&local->open_count))
94339 goto suspend;
94340
94341 ieee80211_scan_cancel(local);
94342 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94343 cancel_work_sync(&local->dynamic_ps_enable_work);
94344 del_timer_sync(&local->dynamic_ps_timer);
94345
94346 - local->wowlan = wowlan && local->open_count;
94347 + local->wowlan = wowlan && local_read(&local->open_count);
94348 if (local->wowlan) {
94349 int err = drv_suspend(local, wowlan);
94350 if (err < 0) {
94351 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94352 WARN_ON(!list_empty(&local->chanctx_list));
94353
94354 /* stop hardware - this must stop RX */
94355 - if (local->open_count)
94356 + if (local_read(&local->open_count))
94357 ieee80211_stop_device(local);
94358
94359 suspend:
94360 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
94361 index 30d58d2..449ac8e 100644
94362 --- a/net/mac80211/rate.c
94363 +++ b/net/mac80211/rate.c
94364 @@ -718,7 +718,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
94365
94366 ASSERT_RTNL();
94367
94368 - if (local->open_count)
94369 + if (local_read(&local->open_count))
94370 return -EBUSY;
94371
94372 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
94373 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
94374 index c97a065..ff61928 100644
94375 --- a/net/mac80211/rc80211_pid_debugfs.c
94376 +++ b/net/mac80211/rc80211_pid_debugfs.c
94377 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
94378
94379 spin_unlock_irqrestore(&events->lock, status);
94380
94381 - if (copy_to_user(buf, pb, p))
94382 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
94383 return -EFAULT;
94384
94385 return p;
94386 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
94387 index 31e78ae..f2a7381 100644
94388 --- a/net/mac80211/util.c
94389 +++ b/net/mac80211/util.c
94390 @@ -1452,7 +1452,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94391 }
94392 #endif
94393 /* everything else happens only if HW was up & running */
94394 - if (!local->open_count)
94395 + if (!local_read(&local->open_count))
94396 goto wake_up;
94397
94398 /*
94399 @@ -1677,7 +1677,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94400 local->in_reconfig = false;
94401 barrier();
94402
94403 - if (local->monitors == local->open_count && local->monitors > 0)
94404 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
94405 ieee80211_add_virtual_monitor(local);
94406
94407 /*
94408 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
94409 index 56d22ca..87c778f 100644
94410 --- a/net/netfilter/Kconfig
94411 +++ b/net/netfilter/Kconfig
94412 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
94413
94414 To compile it as a module, choose M here. If unsure, say N.
94415
94416 +config NETFILTER_XT_MATCH_GRADM
94417 + tristate '"gradm" match support'
94418 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
94419 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
94420 + ---help---
94421 + The gradm match allows to match on grsecurity RBAC being enabled.
94422 + It is useful when iptables rules are applied early on bootup to
94423 + prevent connections to the machine (except from a trusted host)
94424 + while the RBAC system is disabled.
94425 +
94426 config NETFILTER_XT_MATCH_HASHLIMIT
94427 tristate '"hashlimit" match support'
94428 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
94429 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
94430 index a1abf87..dbcb7ee 100644
94431 --- a/net/netfilter/Makefile
94432 +++ b/net/netfilter/Makefile
94433 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
94434 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
94435 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
94436 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
94437 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
94438 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
94439 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
94440 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
94441 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
94442 index f771390..145b765 100644
94443 --- a/net/netfilter/ipset/ip_set_core.c
94444 +++ b/net/netfilter/ipset/ip_set_core.c
94445 @@ -1820,7 +1820,7 @@ done:
94446 return ret;
94447 }
94448
94449 -static struct nf_sockopt_ops so_set __read_mostly = {
94450 +static struct nf_sockopt_ops so_set = {
94451 .pf = PF_INET,
94452 .get_optmin = SO_IP_SET,
94453 .get_optmax = SO_IP_SET + 1,
94454 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
94455 index 4c8e5c0..5a79b4d 100644
94456 --- a/net/netfilter/ipvs/ip_vs_conn.c
94457 +++ b/net/netfilter/ipvs/ip_vs_conn.c
94458 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
94459 /* Increase the refcnt counter of the dest */
94460 ip_vs_dest_hold(dest);
94461
94462 - conn_flags = atomic_read(&dest->conn_flags);
94463 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
94464 if (cp->protocol != IPPROTO_UDP)
94465 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
94466 flags = cp->flags;
94467 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
94468
94469 cp->control = NULL;
94470 atomic_set(&cp->n_control, 0);
94471 - atomic_set(&cp->in_pkts, 0);
94472 + atomic_set_unchecked(&cp->in_pkts, 0);
94473
94474 cp->packet_xmit = NULL;
94475 cp->app = NULL;
94476 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
94477
94478 /* Don't drop the entry if its number of incoming packets is not
94479 located in [0, 8] */
94480 - i = atomic_read(&cp->in_pkts);
94481 + i = atomic_read_unchecked(&cp->in_pkts);
94482 if (i > 8 || i < 0) return 0;
94483
94484 if (!todrop_rate[i]) return 0;
94485 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
94486 index 4f69e83..da2d8bf 100644
94487 --- a/net/netfilter/ipvs/ip_vs_core.c
94488 +++ b/net/netfilter/ipvs/ip_vs_core.c
94489 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
94490 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
94491 /* do not touch skb anymore */
94492
94493 - atomic_inc(&cp->in_pkts);
94494 + atomic_inc_unchecked(&cp->in_pkts);
94495 ip_vs_conn_put(cp);
94496 return ret;
94497 }
94498 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
94499 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
94500 pkts = sysctl_sync_threshold(ipvs);
94501 else
94502 - pkts = atomic_add_return(1, &cp->in_pkts);
94503 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94504
94505 if (ipvs->sync_state & IP_VS_STATE_MASTER)
94506 ip_vs_sync_conn(net, cp, pkts);
94507 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
94508 index c8148e4..eff604f 100644
94509 --- a/net/netfilter/ipvs/ip_vs_ctl.c
94510 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
94511 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
94512 */
94513 ip_vs_rs_hash(ipvs, dest);
94514 }
94515 - atomic_set(&dest->conn_flags, conn_flags);
94516 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
94517
94518 /* bind the service */
94519 if (!dest->svc) {
94520 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
94521 * align with netns init in ip_vs_control_net_init()
94522 */
94523
94524 -static struct ctl_table vs_vars[] = {
94525 +static ctl_table_no_const vs_vars[] __read_only = {
94526 {
94527 .procname = "amemthresh",
94528 .maxlen = sizeof(int),
94529 @@ -2078,7 +2078,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94530 " %-7s %-6d %-10d %-10d\n",
94531 &dest->addr.in6,
94532 ntohs(dest->port),
94533 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94534 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94535 atomic_read(&dest->weight),
94536 atomic_read(&dest->activeconns),
94537 atomic_read(&dest->inactconns));
94538 @@ -2089,7 +2089,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94539 "%-7s %-6d %-10d %-10d\n",
94540 ntohl(dest->addr.ip),
94541 ntohs(dest->port),
94542 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94543 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94544 atomic_read(&dest->weight),
94545 atomic_read(&dest->activeconns),
94546 atomic_read(&dest->inactconns));
94547 @@ -2567,7 +2567,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
94548
94549 entry.addr = dest->addr.ip;
94550 entry.port = dest->port;
94551 - entry.conn_flags = atomic_read(&dest->conn_flags);
94552 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
94553 entry.weight = atomic_read(&dest->weight);
94554 entry.u_threshold = dest->u_threshold;
94555 entry.l_threshold = dest->l_threshold;
94556 @@ -3110,7 +3110,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
94557 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
94558 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
94559 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
94560 - (atomic_read(&dest->conn_flags) &
94561 + (atomic_read_unchecked(&dest->conn_flags) &
94562 IP_VS_CONN_F_FWD_MASK)) ||
94563 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
94564 atomic_read(&dest->weight)) ||
94565 @@ -3700,7 +3700,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
94566 {
94567 int idx;
94568 struct netns_ipvs *ipvs = net_ipvs(net);
94569 - struct ctl_table *tbl;
94570 + ctl_table_no_const *tbl;
94571
94572 atomic_set(&ipvs->dropentry, 0);
94573 spin_lock_init(&ipvs->dropentry_lock);
94574 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
94575 index 1383b0e..a486da1 100644
94576 --- a/net/netfilter/ipvs/ip_vs_lblc.c
94577 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
94578 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
94579 * IPVS LBLC sysctl table
94580 */
94581 #ifdef CONFIG_SYSCTL
94582 -static struct ctl_table vs_vars_table[] = {
94583 +static ctl_table_no_const vs_vars_table[] __read_only = {
94584 {
94585 .procname = "lblc_expiration",
94586 .data = NULL,
94587 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
94588 index 3cd85b2..dfab2b8 100644
94589 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
94590 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
94591 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
94592 * IPVS LBLCR sysctl table
94593 */
94594
94595 -static struct ctl_table vs_vars_table[] = {
94596 +static ctl_table_no_const vs_vars_table[] __read_only = {
94597 {
94598 .procname = "lblcr_expiration",
94599 .data = NULL,
94600 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
94601 index f448471..995f131 100644
94602 --- a/net/netfilter/ipvs/ip_vs_sync.c
94603 +++ b/net/netfilter/ipvs/ip_vs_sync.c
94604 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
94605 cp = cp->control;
94606 if (cp) {
94607 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94608 - pkts = atomic_add_return(1, &cp->in_pkts);
94609 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94610 else
94611 pkts = sysctl_sync_threshold(ipvs);
94612 ip_vs_sync_conn(net, cp->control, pkts);
94613 @@ -771,7 +771,7 @@ control:
94614 if (!cp)
94615 return;
94616 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94617 - pkts = atomic_add_return(1, &cp->in_pkts);
94618 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94619 else
94620 pkts = sysctl_sync_threshold(ipvs);
94621 goto sloop;
94622 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
94623
94624 if (opt)
94625 memcpy(&cp->in_seq, opt, sizeof(*opt));
94626 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94627 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94628 cp->state = state;
94629 cp->old_state = cp->state;
94630 /*
94631 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
94632 index c47444e..b0961c6 100644
94633 --- a/net/netfilter/ipvs/ip_vs_xmit.c
94634 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
94635 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
94636 else
94637 rc = NF_ACCEPT;
94638 /* do not touch skb anymore */
94639 - atomic_inc(&cp->in_pkts);
94640 + atomic_inc_unchecked(&cp->in_pkts);
94641 goto out;
94642 }
94643
94644 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
94645 else
94646 rc = NF_ACCEPT;
94647 /* do not touch skb anymore */
94648 - atomic_inc(&cp->in_pkts);
94649 + atomic_inc_unchecked(&cp->in_pkts);
94650 goto out;
94651 }
94652
94653 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
94654 index 2d3030a..7ba1c0a 100644
94655 --- a/net/netfilter/nf_conntrack_acct.c
94656 +++ b/net/netfilter/nf_conntrack_acct.c
94657 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
94658 #ifdef CONFIG_SYSCTL
94659 static int nf_conntrack_acct_init_sysctl(struct net *net)
94660 {
94661 - struct ctl_table *table;
94662 + ctl_table_no_const *table;
94663
94664 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
94665 GFP_KERNEL);
94666 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
94667 index 0283bae..5febcb0 100644
94668 --- a/net/netfilter/nf_conntrack_core.c
94669 +++ b/net/netfilter/nf_conntrack_core.c
94670 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
94671 #define DYING_NULLS_VAL ((1<<30)+1)
94672 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
94673
94674 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94675 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
94676 +#endif
94677 +
94678 int nf_conntrack_init_net(struct net *net)
94679 {
94680 int ret;
94681 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
94682 goto err_stat;
94683 }
94684
94685 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94686 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
94687 +#else
94688 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
94689 +#endif
94690 if (!net->ct.slabname) {
94691 ret = -ENOMEM;
94692 goto err_slabname;
94693 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
94694 index 1df1761..ce8b88a 100644
94695 --- a/net/netfilter/nf_conntrack_ecache.c
94696 +++ b/net/netfilter/nf_conntrack_ecache.c
94697 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
94698 #ifdef CONFIG_SYSCTL
94699 static int nf_conntrack_event_init_sysctl(struct net *net)
94700 {
94701 - struct ctl_table *table;
94702 + ctl_table_no_const *table;
94703
94704 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
94705 GFP_KERNEL);
94706 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
94707 index 974a2a4..52cc6ff 100644
94708 --- a/net/netfilter/nf_conntrack_helper.c
94709 +++ b/net/netfilter/nf_conntrack_helper.c
94710 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
94711
94712 static int nf_conntrack_helper_init_sysctl(struct net *net)
94713 {
94714 - struct ctl_table *table;
94715 + ctl_table_no_const *table;
94716
94717 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
94718 GFP_KERNEL);
94719 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
94720 index 0ab9636..cea3c6a 100644
94721 --- a/net/netfilter/nf_conntrack_proto.c
94722 +++ b/net/netfilter/nf_conntrack_proto.c
94723 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
94724
94725 static void
94726 nf_ct_unregister_sysctl(struct ctl_table_header **header,
94727 - struct ctl_table **table,
94728 + ctl_table_no_const **table,
94729 unsigned int users)
94730 {
94731 if (users > 0)
94732 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
94733 index a99b6c3..cb372f9 100644
94734 --- a/net/netfilter/nf_conntrack_proto_dccp.c
94735 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
94736 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94737 const char *msg;
94738 u_int8_t state;
94739
94740 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94741 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94742 BUG_ON(dh == NULL);
94743
94744 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
94745 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94746 out_invalid:
94747 if (LOG_INVALID(net, IPPROTO_DCCP))
94748 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
94749 - NULL, msg);
94750 + NULL, "%s", msg);
94751 return false;
94752 }
94753
94754 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
94755 u_int8_t type, old_state, new_state;
94756 enum ct_dccp_roles role;
94757
94758 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94759 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94760 BUG_ON(dh == NULL);
94761 type = dh->dccph_type;
94762
94763 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94764 unsigned int cscov;
94765 const char *msg;
94766
94767 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94768 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94769 if (dh == NULL) {
94770 msg = "nf_ct_dccp: short packet ";
94771 goto out_invalid;
94772 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94773
94774 out_invalid:
94775 if (LOG_INVALID(net, IPPROTO_DCCP))
94776 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
94777 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
94778 return -NF_ACCEPT;
94779 }
94780
94781 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
94782 index f641751..d3c5b51 100644
94783 --- a/net/netfilter/nf_conntrack_standalone.c
94784 +++ b/net/netfilter/nf_conntrack_standalone.c
94785 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
94786
94787 static int nf_conntrack_standalone_init_sysctl(struct net *net)
94788 {
94789 - struct ctl_table *table;
94790 + ctl_table_no_const *table;
94791
94792 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
94793 GFP_KERNEL);
94794 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
94795 index 902fb0a..87f7fdb 100644
94796 --- a/net/netfilter/nf_conntrack_timestamp.c
94797 +++ b/net/netfilter/nf_conntrack_timestamp.c
94798 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
94799 #ifdef CONFIG_SYSCTL
94800 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
94801 {
94802 - struct ctl_table *table;
94803 + ctl_table_no_const *table;
94804
94805 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
94806 GFP_KERNEL);
94807 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
94808 index 85296d4..8becdec 100644
94809 --- a/net/netfilter/nf_log.c
94810 +++ b/net/netfilter/nf_log.c
94811 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
94812
94813 #ifdef CONFIG_SYSCTL
94814 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
94815 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
94816 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
94817
94818 static int nf_log_proc_dostring(struct ctl_table *table, int write,
94819 void __user *buffer, size_t *lenp, loff_t *ppos)
94820 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
94821 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
94822 mutex_unlock(&nf_log_mutex);
94823 } else {
94824 + ctl_table_no_const nf_log_table = *table;
94825 +
94826 mutex_lock(&nf_log_mutex);
94827 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
94828 lockdep_is_held(&nf_log_mutex));
94829 if (!logger)
94830 - table->data = "NONE";
94831 + nf_log_table.data = "NONE";
94832 else
94833 - table->data = logger->name;
94834 - r = proc_dostring(table, write, buffer, lenp, ppos);
94835 + nf_log_table.data = logger->name;
94836 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
94837 mutex_unlock(&nf_log_mutex);
94838 }
94839
94840 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
94841 index f042ae5..30ea486 100644
94842 --- a/net/netfilter/nf_sockopt.c
94843 +++ b/net/netfilter/nf_sockopt.c
94844 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
94845 }
94846 }
94847
94848 - list_add(&reg->list, &nf_sockopts);
94849 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
94850 out:
94851 mutex_unlock(&nf_sockopt_mutex);
94852 return ret;
94853 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
94854 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
94855 {
94856 mutex_lock(&nf_sockopt_mutex);
94857 - list_del(&reg->list);
94858 + pax_list_del((struct list_head *)&reg->list);
94859 mutex_unlock(&nf_sockopt_mutex);
94860 }
94861 EXPORT_SYMBOL(nf_unregister_sockopt);
94862 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
94863 index d92cc31..e46f350 100644
94864 --- a/net/netfilter/nfnetlink_log.c
94865 +++ b/net/netfilter/nfnetlink_log.c
94866 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
94867 struct nfnl_log_net {
94868 spinlock_t instances_lock;
94869 struct hlist_head instance_table[INSTANCE_BUCKETS];
94870 - atomic_t global_seq;
94871 + atomic_unchecked_t global_seq;
94872 };
94873
94874 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
94875 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
94876 /* global sequence number */
94877 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
94878 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
94879 - htonl(atomic_inc_return(&log->global_seq))))
94880 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
94881 goto nla_put_failure;
94882
94883 if (data_len) {
94884 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
94885 new file mode 100644
94886 index 0000000..c566332
94887 --- /dev/null
94888 +++ b/net/netfilter/xt_gradm.c
94889 @@ -0,0 +1,51 @@
94890 +/*
94891 + * gradm match for netfilter
94892 + * Copyright © Zbigniew Krzystolik, 2010
94893 + *
94894 + * This program is free software; you can redistribute it and/or modify
94895 + * it under the terms of the GNU General Public License; either version
94896 + * 2 or 3 as published by the Free Software Foundation.
94897 + */
94898 +#include <linux/module.h>
94899 +#include <linux/moduleparam.h>
94900 +#include <linux/skbuff.h>
94901 +#include <linux/netfilter/x_tables.h>
94902 +#include <linux/grsecurity.h>
94903 +#include <linux/netfilter/xt_gradm.h>
94904 +
94905 +static bool
94906 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
94907 +{
94908 + const struct xt_gradm_mtinfo *info = par->matchinfo;
94909 + bool retval = false;
94910 + if (gr_acl_is_enabled())
94911 + retval = true;
94912 + return retval ^ info->invflags;
94913 +}
94914 +
94915 +static struct xt_match gradm_mt_reg __read_mostly = {
94916 + .name = "gradm",
94917 + .revision = 0,
94918 + .family = NFPROTO_UNSPEC,
94919 + .match = gradm_mt,
94920 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
94921 + .me = THIS_MODULE,
94922 +};
94923 +
94924 +static int __init gradm_mt_init(void)
94925 +{
94926 + return xt_register_match(&gradm_mt_reg);
94927 +}
94928 +
94929 +static void __exit gradm_mt_exit(void)
94930 +{
94931 + xt_unregister_match(&gradm_mt_reg);
94932 +}
94933 +
94934 +module_init(gradm_mt_init);
94935 +module_exit(gradm_mt_exit);
94936 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
94937 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
94938 +MODULE_LICENSE("GPL");
94939 +MODULE_ALIAS("ipt_gradm");
94940 +MODULE_ALIAS("ip6t_gradm");
94941 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
94942 index 4fe4fb4..87a89e5 100644
94943 --- a/net/netfilter/xt_statistic.c
94944 +++ b/net/netfilter/xt_statistic.c
94945 @@ -19,7 +19,7 @@
94946 #include <linux/module.h>
94947
94948 struct xt_statistic_priv {
94949 - atomic_t count;
94950 + atomic_unchecked_t count;
94951 } ____cacheline_aligned_in_smp;
94952
94953 MODULE_LICENSE("GPL");
94954 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
94955 break;
94956 case XT_STATISTIC_MODE_NTH:
94957 do {
94958 - oval = atomic_read(&info->master->count);
94959 + oval = atomic_read_unchecked(&info->master->count);
94960 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
94961 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
94962 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
94963 if (nval == 0)
94964 ret = !ret;
94965 break;
94966 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
94967 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
94968 if (info->master == NULL)
94969 return -ENOMEM;
94970 - atomic_set(&info->master->count, info->u.nth.count);
94971 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
94972
94973 return 0;
94974 }
94975 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
94976 index 0c61b59..941bddd 100644
94977 --- a/net/netlink/af_netlink.c
94978 +++ b/net/netlink/af_netlink.c
94979 @@ -219,7 +219,7 @@ static void netlink_overrun(struct sock *sk)
94980 sk->sk_error_report(sk);
94981 }
94982 }
94983 - atomic_inc(&sk->sk_drops);
94984 + atomic_inc_unchecked(&sk->sk_drops);
94985 }
94986
94987 static void netlink_rcv_wake(struct sock *sk)
94988 @@ -2925,7 +2925,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
94989 sk_wmem_alloc_get(s),
94990 nlk->cb,
94991 atomic_read(&s->sk_refcnt),
94992 - atomic_read(&s->sk_drops),
94993 + atomic_read_unchecked(&s->sk_drops),
94994 sock_i_ino(s)
94995 );
94996
94997 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
94998 index 0c741ce..f8c8ca7 100644
94999 --- a/net/netlink/genetlink.c
95000 +++ b/net/netlink/genetlink.c
95001 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
95002 goto errout;
95003 }
95004
95005 + pax_open_kernel();
95006 if (ops->dumpit)
95007 - ops->flags |= GENL_CMD_CAP_DUMP;
95008 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
95009 if (ops->doit)
95010 - ops->flags |= GENL_CMD_CAP_DO;
95011 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
95012 if (ops->policy)
95013 - ops->flags |= GENL_CMD_CAP_HASPOL;
95014 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
95015 + pax_close_kernel();
95016
95017 genl_lock_all();
95018 - list_add_tail(&ops->ops_list, &family->ops_list);
95019 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
95020 genl_unlock_all();
95021
95022 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
95023 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
95024 err = 0;
95025 errout:
95026 return err;
95027 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
95028 genl_lock_all();
95029 list_for_each_entry(rc, &family->ops_list, ops_list) {
95030 if (rc == ops) {
95031 - list_del(&ops->ops_list);
95032 + pax_list_del((struct list_head *)&ops->ops_list);
95033 genl_unlock_all();
95034 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
95035 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
95036 return 0;
95037 }
95038 }
95039 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
95040 index 698814b..7cfde4e 100644
95041 --- a/net/netrom/af_netrom.c
95042 +++ b/net/netrom/af_netrom.c
95043 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
95044 *uaddr_len = sizeof(struct full_sockaddr_ax25);
95045 } else {
95046 sax->fsa_ax25.sax25_family = AF_NETROM;
95047 - sax->fsa_ax25.sax25_ndigis = 0;
95048 sax->fsa_ax25.sax25_call = nr->source_addr;
95049 *uaddr_len = sizeof(struct sockaddr_ax25);
95050 }
95051 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
95052 index 75c8bbf..ee9be59 100644
95053 --- a/net/packet/af_packet.c
95054 +++ b/net/packet/af_packet.c
95055 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95056
95057 spin_lock(&sk->sk_receive_queue.lock);
95058 po->stats.stats1.tp_packets++;
95059 - skb->dropcount = atomic_read(&sk->sk_drops);
95060 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
95061 __skb_queue_tail(&sk->sk_receive_queue, skb);
95062 spin_unlock(&sk->sk_receive_queue.lock);
95063 sk->sk_data_ready(sk, skb->len);
95064 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95065 drop_n_acct:
95066 spin_lock(&sk->sk_receive_queue.lock);
95067 po->stats.stats1.tp_drops++;
95068 - atomic_inc(&sk->sk_drops);
95069 + atomic_inc_unchecked(&sk->sk_drops);
95070 spin_unlock(&sk->sk_receive_queue.lock);
95071
95072 drop_n_restore:
95073 @@ -2640,6 +2640,7 @@ out:
95074
95075 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95076 {
95077 + struct sock_extended_err ee;
95078 struct sock_exterr_skb *serr;
95079 struct sk_buff *skb, *skb2;
95080 int copied, err;
95081 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95082 sock_recv_timestamp(msg, sk, skb);
95083
95084 serr = SKB_EXT_ERR(skb);
95085 + ee = serr->ee;
95086 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
95087 - sizeof(serr->ee), &serr->ee);
95088 + sizeof ee, &ee);
95089
95090 msg->msg_flags |= MSG_ERRQUEUE;
95091 err = copied;
95092 @@ -3283,7 +3285,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95093 case PACKET_HDRLEN:
95094 if (len > sizeof(int))
95095 len = sizeof(int);
95096 - if (copy_from_user(&val, optval, len))
95097 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
95098 return -EFAULT;
95099 switch (val) {
95100 case TPACKET_V1:
95101 @@ -3326,7 +3328,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95102 len = lv;
95103 if (put_user(len, optlen))
95104 return -EFAULT;
95105 - if (copy_to_user(optval, data, len))
95106 + if (len > sizeof(st) || copy_to_user(optval, data, len))
95107 return -EFAULT;
95108 return 0;
95109 }
95110 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
95111 index e774117..900b8b7 100644
95112 --- a/net/phonet/pep.c
95113 +++ b/net/phonet/pep.c
95114 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95115
95116 case PNS_PEP_CTRL_REQ:
95117 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
95118 - atomic_inc(&sk->sk_drops);
95119 + atomic_inc_unchecked(&sk->sk_drops);
95120 break;
95121 }
95122 __skb_pull(skb, 4);
95123 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95124 }
95125
95126 if (pn->rx_credits == 0) {
95127 - atomic_inc(&sk->sk_drops);
95128 + atomic_inc_unchecked(&sk->sk_drops);
95129 err = -ENOBUFS;
95130 break;
95131 }
95132 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
95133 }
95134
95135 if (pn->rx_credits == 0) {
95136 - atomic_inc(&sk->sk_drops);
95137 + atomic_inc_unchecked(&sk->sk_drops);
95138 err = NET_RX_DROP;
95139 break;
95140 }
95141 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
95142 index 1afd138..0b42453 100644
95143 --- a/net/phonet/socket.c
95144 +++ b/net/phonet/socket.c
95145 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
95146 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
95147 sock_i_ino(sk),
95148 atomic_read(&sk->sk_refcnt), sk,
95149 - atomic_read(&sk->sk_drops), &len);
95150 + atomic_read_unchecked(&sk->sk_drops), &len);
95151 }
95152 seq_printf(seq, "%*s\n", 127 - len, "");
95153 return 0;
95154 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
95155 index c02a8c4..3c5b600 100644
95156 --- a/net/phonet/sysctl.c
95157 +++ b/net/phonet/sysctl.c
95158 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
95159 {
95160 int ret;
95161 int range[2] = {local_port_range[0], local_port_range[1]};
95162 - struct ctl_table tmp = {
95163 + ctl_table_no_const tmp = {
95164 .data = &range,
95165 .maxlen = sizeof(range),
95166 .mode = table->mode,
95167 diff --git a/net/rds/cong.c b/net/rds/cong.c
95168 index e5b65ac..f3b6fb7 100644
95169 --- a/net/rds/cong.c
95170 +++ b/net/rds/cong.c
95171 @@ -78,7 +78,7 @@
95172 * finds that the saved generation number is smaller than the global generation
95173 * number, it wakes up the process.
95174 */
95175 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
95176 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
95177
95178 /*
95179 * Congestion monitoring
95180 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
95181 rdsdebug("waking map %p for %pI4\n",
95182 map, &map->m_addr);
95183 rds_stats_inc(s_cong_update_received);
95184 - atomic_inc(&rds_cong_generation);
95185 + atomic_inc_unchecked(&rds_cong_generation);
95186 if (waitqueue_active(&map->m_waitq))
95187 wake_up(&map->m_waitq);
95188 if (waitqueue_active(&rds_poll_waitq))
95189 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
95190
95191 int rds_cong_updated_since(unsigned long *recent)
95192 {
95193 - unsigned long gen = atomic_read(&rds_cong_generation);
95194 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
95195
95196 if (likely(*recent == gen))
95197 return 0;
95198 diff --git a/net/rds/ib.h b/net/rds/ib.h
95199 index 7280ab8..e04f4ea 100644
95200 --- a/net/rds/ib.h
95201 +++ b/net/rds/ib.h
95202 @@ -128,7 +128,7 @@ struct rds_ib_connection {
95203 /* sending acks */
95204 unsigned long i_ack_flags;
95205 #ifdef KERNEL_HAS_ATOMIC64
95206 - atomic64_t i_ack_next; /* next ACK to send */
95207 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95208 #else
95209 spinlock_t i_ack_lock; /* protect i_ack_next */
95210 u64 i_ack_next; /* next ACK to send */
95211 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
95212 index 31b74f5..dc1fbfa 100644
95213 --- a/net/rds/ib_cm.c
95214 +++ b/net/rds/ib_cm.c
95215 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
95216 /* Clear the ACK state */
95217 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95218 #ifdef KERNEL_HAS_ATOMIC64
95219 - atomic64_set(&ic->i_ack_next, 0);
95220 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95221 #else
95222 ic->i_ack_next = 0;
95223 #endif
95224 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
95225 index 8eb9501..0c386ff 100644
95226 --- a/net/rds/ib_recv.c
95227 +++ b/net/rds/ib_recv.c
95228 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95229 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
95230 int ack_required)
95231 {
95232 - atomic64_set(&ic->i_ack_next, seq);
95233 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95234 if (ack_required) {
95235 smp_mb__before_clear_bit();
95236 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95237 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95238 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95239 smp_mb__after_clear_bit();
95240
95241 - return atomic64_read(&ic->i_ack_next);
95242 + return atomic64_read_unchecked(&ic->i_ack_next);
95243 }
95244 #endif
95245
95246 diff --git a/net/rds/iw.h b/net/rds/iw.h
95247 index 04ce3b1..48119a6 100644
95248 --- a/net/rds/iw.h
95249 +++ b/net/rds/iw.h
95250 @@ -134,7 +134,7 @@ struct rds_iw_connection {
95251 /* sending acks */
95252 unsigned long i_ack_flags;
95253 #ifdef KERNEL_HAS_ATOMIC64
95254 - atomic64_t i_ack_next; /* next ACK to send */
95255 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95256 #else
95257 spinlock_t i_ack_lock; /* protect i_ack_next */
95258 u64 i_ack_next; /* next ACK to send */
95259 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
95260 index a91e1db..cf3053f 100644
95261 --- a/net/rds/iw_cm.c
95262 +++ b/net/rds/iw_cm.c
95263 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
95264 /* Clear the ACK state */
95265 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95266 #ifdef KERNEL_HAS_ATOMIC64
95267 - atomic64_set(&ic->i_ack_next, 0);
95268 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95269 #else
95270 ic->i_ack_next = 0;
95271 #endif
95272 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
95273 index 4503335..db566b4 100644
95274 --- a/net/rds/iw_recv.c
95275 +++ b/net/rds/iw_recv.c
95276 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95277 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
95278 int ack_required)
95279 {
95280 - atomic64_set(&ic->i_ack_next, seq);
95281 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95282 if (ack_required) {
95283 smp_mb__before_clear_bit();
95284 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95285 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95286 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95287 smp_mb__after_clear_bit();
95288
95289 - return atomic64_read(&ic->i_ack_next);
95290 + return atomic64_read_unchecked(&ic->i_ack_next);
95291 }
95292 #endif
95293
95294 diff --git a/net/rds/rds.h b/net/rds/rds.h
95295 index ec1d731..90a3a8d 100644
95296 --- a/net/rds/rds.h
95297 +++ b/net/rds/rds.h
95298 @@ -449,7 +449,7 @@ struct rds_transport {
95299 void (*sync_mr)(void *trans_private, int direction);
95300 void (*free_mr)(void *trans_private, int invalidate);
95301 void (*flush_mrs)(void);
95302 -};
95303 +} __do_const;
95304
95305 struct rds_sock {
95306 struct sock rs_sk;
95307 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
95308 index edac9ef..16bcb98 100644
95309 --- a/net/rds/tcp.c
95310 +++ b/net/rds/tcp.c
95311 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
95312 int val = 1;
95313
95314 set_fs(KERNEL_DS);
95315 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
95316 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
95317 sizeof(val));
95318 set_fs(oldfs);
95319 }
95320 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
95321 index 81cf5a4..b5826ff 100644
95322 --- a/net/rds/tcp_send.c
95323 +++ b/net/rds/tcp_send.c
95324 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
95325
95326 oldfs = get_fs();
95327 set_fs(KERNEL_DS);
95328 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
95329 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
95330 sizeof(val));
95331 set_fs(oldfs);
95332 }
95333 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
95334 index e61aa60..f07cc89 100644
95335 --- a/net/rxrpc/af_rxrpc.c
95336 +++ b/net/rxrpc/af_rxrpc.c
95337 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
95338 __be32 rxrpc_epoch;
95339
95340 /* current debugging ID */
95341 -atomic_t rxrpc_debug_id;
95342 +atomic_unchecked_t rxrpc_debug_id;
95343
95344 /* count of skbs currently in use */
95345 atomic_t rxrpc_n_skbs;
95346 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
95347 index e4d9cbc..b229649 100644
95348 --- a/net/rxrpc/ar-ack.c
95349 +++ b/net/rxrpc/ar-ack.c
95350 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95351
95352 _enter("{%d,%d,%d,%d},",
95353 call->acks_hard, call->acks_unacked,
95354 - atomic_read(&call->sequence),
95355 + atomic_read_unchecked(&call->sequence),
95356 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
95357
95358 stop = 0;
95359 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95360
95361 /* each Tx packet has a new serial number */
95362 sp->hdr.serial =
95363 - htonl(atomic_inc_return(&call->conn->serial));
95364 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
95365
95366 hdr = (struct rxrpc_header *) txb->head;
95367 hdr->serial = sp->hdr.serial;
95368 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
95369 */
95370 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
95371 {
95372 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
95373 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
95374 }
95375
95376 /*
95377 @@ -629,7 +629,7 @@ process_further:
95378
95379 latest = ntohl(sp->hdr.serial);
95380 hard = ntohl(ack.firstPacket);
95381 - tx = atomic_read(&call->sequence);
95382 + tx = atomic_read_unchecked(&call->sequence);
95383
95384 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95385 latest,
95386 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
95387 goto maybe_reschedule;
95388
95389 send_ACK_with_skew:
95390 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
95391 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
95392 ntohl(ack.serial));
95393 send_ACK:
95394 mtu = call->conn->trans->peer->if_mtu;
95395 @@ -1173,7 +1173,7 @@ send_ACK:
95396 ackinfo.rxMTU = htonl(5692);
95397 ackinfo.jumbo_max = htonl(4);
95398
95399 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95400 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95401 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95402 ntohl(hdr.serial),
95403 ntohs(ack.maxSkew),
95404 @@ -1191,7 +1191,7 @@ send_ACK:
95405 send_message:
95406 _debug("send message");
95407
95408 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95409 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95410 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
95411 send_message_2:
95412
95413 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
95414 index a3bbb36..3341fb9 100644
95415 --- a/net/rxrpc/ar-call.c
95416 +++ b/net/rxrpc/ar-call.c
95417 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
95418 spin_lock_init(&call->lock);
95419 rwlock_init(&call->state_lock);
95420 atomic_set(&call->usage, 1);
95421 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
95422 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95423 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
95424
95425 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
95426 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
95427 index 4106ca9..a338d7a 100644
95428 --- a/net/rxrpc/ar-connection.c
95429 +++ b/net/rxrpc/ar-connection.c
95430 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
95431 rwlock_init(&conn->lock);
95432 spin_lock_init(&conn->state_lock);
95433 atomic_set(&conn->usage, 1);
95434 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
95435 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95436 conn->avail_calls = RXRPC_MAXCALLS;
95437 conn->size_align = 4;
95438 conn->header_size = sizeof(struct rxrpc_header);
95439 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
95440 index e7ed43a..6afa140 100644
95441 --- a/net/rxrpc/ar-connevent.c
95442 +++ b/net/rxrpc/ar-connevent.c
95443 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
95444
95445 len = iov[0].iov_len + iov[1].iov_len;
95446
95447 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95448 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95449 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
95450
95451 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95452 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
95453 index 529572f..c758ca7 100644
95454 --- a/net/rxrpc/ar-input.c
95455 +++ b/net/rxrpc/ar-input.c
95456 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
95457 /* track the latest serial number on this connection for ACK packet
95458 * information */
95459 serial = ntohl(sp->hdr.serial);
95460 - hi_serial = atomic_read(&call->conn->hi_serial);
95461 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
95462 while (serial > hi_serial)
95463 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
95464 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
95465 serial);
95466
95467 /* request ACK generation for any ACK or DATA packet that requests
95468 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
95469 index a693aca..81e7293 100644
95470 --- a/net/rxrpc/ar-internal.h
95471 +++ b/net/rxrpc/ar-internal.h
95472 @@ -272,8 +272,8 @@ struct rxrpc_connection {
95473 int error; /* error code for local abort */
95474 int debug_id; /* debug ID for printks */
95475 unsigned int call_counter; /* call ID counter */
95476 - atomic_t serial; /* packet serial number counter */
95477 - atomic_t hi_serial; /* highest serial number received */
95478 + atomic_unchecked_t serial; /* packet serial number counter */
95479 + atomic_unchecked_t hi_serial; /* highest serial number received */
95480 u8 avail_calls; /* number of calls available */
95481 u8 size_align; /* data size alignment (for security) */
95482 u8 header_size; /* rxrpc + security header size */
95483 @@ -346,7 +346,7 @@ struct rxrpc_call {
95484 spinlock_t lock;
95485 rwlock_t state_lock; /* lock for state transition */
95486 atomic_t usage;
95487 - atomic_t sequence; /* Tx data packet sequence counter */
95488 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
95489 u32 abort_code; /* local/remote abort code */
95490 enum { /* current state of call */
95491 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
95492 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
95493 */
95494 extern atomic_t rxrpc_n_skbs;
95495 extern __be32 rxrpc_epoch;
95496 -extern atomic_t rxrpc_debug_id;
95497 +extern atomic_unchecked_t rxrpc_debug_id;
95498 extern struct workqueue_struct *rxrpc_workqueue;
95499
95500 /*
95501 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
95502 index 87f7135..74d3703 100644
95503 --- a/net/rxrpc/ar-local.c
95504 +++ b/net/rxrpc/ar-local.c
95505 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
95506 spin_lock_init(&local->lock);
95507 rwlock_init(&local->services_lock);
95508 atomic_set(&local->usage, 1);
95509 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
95510 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95511 memcpy(&local->srx, srx, sizeof(*srx));
95512 }
95513
95514 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
95515 index e1ac183..b43e10e 100644
95516 --- a/net/rxrpc/ar-output.c
95517 +++ b/net/rxrpc/ar-output.c
95518 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
95519 sp->hdr.cid = call->cid;
95520 sp->hdr.callNumber = call->call_id;
95521 sp->hdr.seq =
95522 - htonl(atomic_inc_return(&call->sequence));
95523 + htonl(atomic_inc_return_unchecked(&call->sequence));
95524 sp->hdr.serial =
95525 - htonl(atomic_inc_return(&conn->serial));
95526 + htonl(atomic_inc_return_unchecked(&conn->serial));
95527 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
95528 sp->hdr.userStatus = 0;
95529 sp->hdr.securityIndex = conn->security_ix;
95530 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
95531 index bebaa43..2644591 100644
95532 --- a/net/rxrpc/ar-peer.c
95533 +++ b/net/rxrpc/ar-peer.c
95534 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
95535 INIT_LIST_HEAD(&peer->error_targets);
95536 spin_lock_init(&peer->lock);
95537 atomic_set(&peer->usage, 1);
95538 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
95539 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95540 memcpy(&peer->srx, srx, sizeof(*srx));
95541
95542 rxrpc_assess_MTU_size(peer);
95543 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
95544 index 38047f7..9f48511 100644
95545 --- a/net/rxrpc/ar-proc.c
95546 +++ b/net/rxrpc/ar-proc.c
95547 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
95548 atomic_read(&conn->usage),
95549 rxrpc_conn_states[conn->state],
95550 key_serial(conn->key),
95551 - atomic_read(&conn->serial),
95552 - atomic_read(&conn->hi_serial));
95553 + atomic_read_unchecked(&conn->serial),
95554 + atomic_read_unchecked(&conn->hi_serial));
95555
95556 return 0;
95557 }
95558 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
95559 index 92df566..87ec1bf 100644
95560 --- a/net/rxrpc/ar-transport.c
95561 +++ b/net/rxrpc/ar-transport.c
95562 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
95563 spin_lock_init(&trans->client_lock);
95564 rwlock_init(&trans->conn_lock);
95565 atomic_set(&trans->usage, 1);
95566 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
95567 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95568
95569 if (peer->srx.transport.family == AF_INET) {
95570 switch (peer->srx.transport_type) {
95571 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
95572 index f226709..0e735a8 100644
95573 --- a/net/rxrpc/rxkad.c
95574 +++ b/net/rxrpc/rxkad.c
95575 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
95576
95577 len = iov[0].iov_len + iov[1].iov_len;
95578
95579 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95580 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95581 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
95582
95583 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95584 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
95585
95586 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
95587
95588 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
95589 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95590 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
95591
95592 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
95593 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
95594 index 547a461e..ea606e3 100644
95595 --- a/net/sctp/ipv6.c
95596 +++ b/net/sctp/ipv6.c
95597 @@ -968,7 +968,7 @@ static const struct inet6_protocol sctpv6_protocol = {
95598 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
95599 };
95600
95601 -static struct sctp_af sctp_af_inet6 = {
95602 +static struct sctp_af sctp_af_inet6 __read_only = {
95603 .sa_family = AF_INET6,
95604 .sctp_xmit = sctp_v6_xmit,
95605 .setsockopt = ipv6_setsockopt,
95606 @@ -1000,7 +1000,7 @@ static struct sctp_af sctp_af_inet6 = {
95607 #endif
95608 };
95609
95610 -static struct sctp_pf sctp_pf_inet6 = {
95611 +static struct sctp_pf sctp_pf_inet6 __read_only = {
95612 .event_msgname = sctp_inet6_event_msgname,
95613 .skb_msgname = sctp_inet6_skb_msgname,
95614 .af_supported = sctp_inet6_af_supported,
95615 @@ -1025,7 +1025,7 @@ void sctp_v6_pf_init(void)
95616
95617 void sctp_v6_pf_exit(void)
95618 {
95619 - list_del(&sctp_af_inet6.list);
95620 + pax_list_del(&sctp_af_inet6.list);
95621 }
95622
95623 /* Initialize IPv6 support and register with socket layer. */
95624 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
95625 index 62526c4..36a13c5 100644
95626 --- a/net/sctp/proc.c
95627 +++ b/net/sctp/proc.c
95628 @@ -343,7 +343,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
95629 seq_printf(seq,
95630 "%8pK %8pK %-3d %-3d %-2d %-4d "
95631 "%4d %8d %8d %7d %5lu %-5d %5d ",
95632 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
95633 + assoc, sk,
95634 + sctp_sk(sk)->type, sk->sk_state,
95635 assoc->state, hash,
95636 assoc->assoc_id,
95637 assoc->sndbuf_used,
95638 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
95639 index 4a17494d..f7e3fa0 100644
95640 --- a/net/sctp/protocol.c
95641 +++ b/net/sctp/protocol.c
95642 @@ -838,8 +838,10 @@ int sctp_register_af(struct sctp_af *af)
95643 return 0;
95644 }
95645
95646 + pax_open_kernel();
95647 INIT_LIST_HEAD(&af->list);
95648 - list_add_tail(&af->list, &sctp_address_families);
95649 + pax_close_kernel();
95650 + pax_list_add_tail(&af->list, &sctp_address_families);
95651 return 1;
95652 }
95653
95654 @@ -969,7 +971,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
95655
95656 static struct sctp_af sctp_af_inet;
95657
95658 -static struct sctp_pf sctp_pf_inet = {
95659 +static struct sctp_pf sctp_pf_inet __read_only = {
95660 .event_msgname = sctp_inet_event_msgname,
95661 .skb_msgname = sctp_inet_skb_msgname,
95662 .af_supported = sctp_inet_af_supported,
95663 @@ -1040,7 +1042,7 @@ static const struct net_protocol sctp_protocol = {
95664 };
95665
95666 /* IPv4 address related functions. */
95667 -static struct sctp_af sctp_af_inet = {
95668 +static struct sctp_af sctp_af_inet __read_only = {
95669 .sa_family = AF_INET,
95670 .sctp_xmit = sctp_v4_xmit,
95671 .setsockopt = ip_setsockopt,
95672 @@ -1125,7 +1127,7 @@ static void sctp_v4_pf_init(void)
95673
95674 static void sctp_v4_pf_exit(void)
95675 {
95676 - list_del(&sctp_af_inet.list);
95677 + pax_list_del(&sctp_af_inet.list);
95678 }
95679
95680 static int sctp_v4_protosw_init(void)
95681 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
95682 index 8b5b4b7..2636327 100644
95683 --- a/net/sctp/sm_sideeffect.c
95684 +++ b/net/sctp/sm_sideeffect.c
95685 @@ -446,7 +446,7 @@ static void sctp_generate_sack_event(unsigned long data)
95686 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
95687 }
95688
95689 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95690 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95691 NULL,
95692 sctp_generate_t1_cookie_event,
95693 sctp_generate_t1_init_event,
95694 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
95695 index cf6c6b0..b978b65 100644
95696 --- a/net/sctp/socket.c
95697 +++ b/net/sctp/socket.c
95698 @@ -2159,11 +2159,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
95699 {
95700 struct sctp_association *asoc;
95701 struct sctp_ulpevent *event;
95702 + struct sctp_event_subscribe subscribe;
95703
95704 if (optlen > sizeof(struct sctp_event_subscribe))
95705 return -EINVAL;
95706 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
95707 + if (copy_from_user(&subscribe, optval, optlen))
95708 return -EFAULT;
95709 + sctp_sk(sk)->subscribe = subscribe;
95710
95711 /*
95712 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
95713 @@ -4219,13 +4221,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
95714 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95715 int __user *optlen)
95716 {
95717 + struct sctp_event_subscribe subscribe;
95718 +
95719 if (len <= 0)
95720 return -EINVAL;
95721 if (len > sizeof(struct sctp_event_subscribe))
95722 len = sizeof(struct sctp_event_subscribe);
95723 if (put_user(len, optlen))
95724 return -EFAULT;
95725 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
95726 + subscribe = sctp_sk(sk)->subscribe;
95727 + if (copy_to_user(optval, &subscribe, len))
95728 return -EFAULT;
95729 return 0;
95730 }
95731 @@ -4243,6 +4248,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95732 */
95733 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
95734 {
95735 + __u32 autoclose;
95736 +
95737 /* Applicable to UDP-style socket only */
95738 if (sctp_style(sk, TCP))
95739 return -EOPNOTSUPP;
95740 @@ -4251,7 +4258,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
95741 len = sizeof(int);
95742 if (put_user(len, optlen))
95743 return -EFAULT;
95744 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
95745 + autoclose = sctp_sk(sk)->autoclose;
95746 + if (copy_to_user(optval, &autoclose, sizeof(int)))
95747 return -EFAULT;
95748 return 0;
95749 }
95750 @@ -4623,12 +4631,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
95751 */
95752 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
95753 {
95754 + struct sctp_initmsg initmsg;
95755 +
95756 if (len < sizeof(struct sctp_initmsg))
95757 return -EINVAL;
95758 len = sizeof(struct sctp_initmsg);
95759 if (put_user(len, optlen))
95760 return -EFAULT;
95761 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
95762 + initmsg = sctp_sk(sk)->initmsg;
95763 + if (copy_to_user(optval, &initmsg, len))
95764 return -EFAULT;
95765 return 0;
95766 }
95767 @@ -4669,6 +4680,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
95768 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
95769 if (space_left < addrlen)
95770 return -ENOMEM;
95771 + if (addrlen > sizeof(temp) || addrlen < 0)
95772 + return -EFAULT;
95773 if (copy_to_user(to, &temp, addrlen))
95774 return -EFAULT;
95775 to += addrlen;
95776 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
95777 index 9a5c4c9..46e4b29 100644
95778 --- a/net/sctp/sysctl.c
95779 +++ b/net/sctp/sysctl.c
95780 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95781 {
95782 struct net *net = current->nsproxy->net_ns;
95783 char tmp[8];
95784 - struct ctl_table tbl;
95785 + ctl_table_no_const tbl;
95786 int ret;
95787 int changed = 0;
95788 char *none = "none";
95789 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95790
95791 int sctp_sysctl_net_register(struct net *net)
95792 {
95793 - struct ctl_table *table;
95794 + ctl_table_no_const *table;
95795 int i;
95796
95797 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
95798 diff --git a/net/socket.c b/net/socket.c
95799 index 4b94643..f703b02 100644
95800 --- a/net/socket.c
95801 +++ b/net/socket.c
95802 @@ -88,6 +88,7 @@
95803 #include <linux/magic.h>
95804 #include <linux/slab.h>
95805 #include <linux/xattr.h>
95806 +#include <linux/in.h>
95807
95808 #include <asm/uaccess.h>
95809 #include <asm/unistd.h>
95810 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
95811 unsigned int sysctl_net_busy_poll __read_mostly;
95812 #endif
95813
95814 +#include <linux/grsock.h>
95815 +
95816 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
95817 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
95818 unsigned long nr_segs, loff_t pos);
95819 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
95820 */
95821
95822 static DEFINE_SPINLOCK(net_family_lock);
95823 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95824 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95825
95826 /*
95827 * Statistics counters of the socket lists
95828 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
95829 &sockfs_dentry_operations, SOCKFS_MAGIC);
95830 }
95831
95832 -static struct vfsmount *sock_mnt __read_mostly;
95833 +struct vfsmount *sock_mnt __read_mostly;
95834
95835 static struct file_system_type sock_fs_type = {
95836 .name = "sockfs",
95837 @@ -1263,6 +1266,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95838 return -EAFNOSUPPORT;
95839 if (type < 0 || type >= SOCK_MAX)
95840 return -EINVAL;
95841 + if (protocol < 0)
95842 + return -EINVAL;
95843
95844 /* Compatibility.
95845
95846 @@ -1283,6 +1288,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95847 if (err)
95848 return err;
95849
95850 + if(!kern && !gr_search_socket(family, type, protocol)) {
95851 + if (rcu_access_pointer(net_families[family]) == NULL)
95852 + return -EAFNOSUPPORT;
95853 + else
95854 + return -EACCES;
95855 + }
95856 +
95857 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
95858 + if (rcu_access_pointer(net_families[family]) == NULL)
95859 + return -EAFNOSUPPORT;
95860 + else
95861 + return -EACCES;
95862 + }
95863 +
95864 /*
95865 * Allocate the socket and allow the family to set things up. if
95866 * the protocol is 0, the family is instructed to select an appropriate
95867 @@ -1521,6 +1540,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95868 if (sock) {
95869 err = move_addr_to_kernel(umyaddr, addrlen, &address);
95870 if (err >= 0) {
95871 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
95872 + err = -EACCES;
95873 + goto error;
95874 + }
95875 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
95876 + if (err)
95877 + goto error;
95878 +
95879 err = security_socket_bind(sock,
95880 (struct sockaddr *)&address,
95881 addrlen);
95882 @@ -1529,6 +1556,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95883 (struct sockaddr *)
95884 &address, addrlen);
95885 }
95886 +error:
95887 fput_light(sock->file, fput_needed);
95888 }
95889 return err;
95890 @@ -1552,10 +1580,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
95891 if ((unsigned int)backlog > somaxconn)
95892 backlog = somaxconn;
95893
95894 + if (gr_handle_sock_server_other(sock->sk)) {
95895 + err = -EPERM;
95896 + goto error;
95897 + }
95898 +
95899 + err = gr_search_listen(sock);
95900 + if (err)
95901 + goto error;
95902 +
95903 err = security_socket_listen(sock, backlog);
95904 if (!err)
95905 err = sock->ops->listen(sock, backlog);
95906
95907 +error:
95908 fput_light(sock->file, fput_needed);
95909 }
95910 return err;
95911 @@ -1599,6 +1637,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95912 newsock->type = sock->type;
95913 newsock->ops = sock->ops;
95914
95915 + if (gr_handle_sock_server_other(sock->sk)) {
95916 + err = -EPERM;
95917 + sock_release(newsock);
95918 + goto out_put;
95919 + }
95920 +
95921 + err = gr_search_accept(sock);
95922 + if (err) {
95923 + sock_release(newsock);
95924 + goto out_put;
95925 + }
95926 +
95927 /*
95928 * We don't need try_module_get here, as the listening socket (sock)
95929 * has the protocol module (sock->ops->owner) held.
95930 @@ -1644,6 +1694,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95931 fd_install(newfd, newfile);
95932 err = newfd;
95933
95934 + gr_attach_curr_ip(newsock->sk);
95935 +
95936 out_put:
95937 fput_light(sock->file, fput_needed);
95938 out:
95939 @@ -1676,6 +1728,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95940 int, addrlen)
95941 {
95942 struct socket *sock;
95943 + struct sockaddr *sck;
95944 struct sockaddr_storage address;
95945 int err, fput_needed;
95946
95947 @@ -1686,6 +1739,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95948 if (err < 0)
95949 goto out_put;
95950
95951 + sck = (struct sockaddr *)&address;
95952 +
95953 + if (gr_handle_sock_client(sck)) {
95954 + err = -EACCES;
95955 + goto out_put;
95956 + }
95957 +
95958 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
95959 + if (err)
95960 + goto out_put;
95961 +
95962 err =
95963 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
95964 if (err)
95965 @@ -1767,6 +1831,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
95966 * the protocol.
95967 */
95968
95969 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
95970 +
95971 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
95972 unsigned int, flags, struct sockaddr __user *, addr,
95973 int, addr_len)
95974 @@ -1833,7 +1899,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
95975 struct socket *sock;
95976 struct iovec iov;
95977 struct msghdr msg;
95978 - struct sockaddr_storage address;
95979 + struct sockaddr_storage address = { };
95980 int err, err2;
95981 int fput_needed;
95982
95983 @@ -2053,7 +2119,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
95984 * checking falls down on this.
95985 */
95986 if (copy_from_user(ctl_buf,
95987 - (void __user __force *)msg_sys->msg_control,
95988 + (void __force_user *)msg_sys->msg_control,
95989 ctl_len))
95990 goto out_freectl;
95991 msg_sys->msg_control = ctl_buf;
95992 @@ -2204,7 +2270,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
95993 int err, total_len, len;
95994
95995 /* kernel mode address */
95996 - struct sockaddr_storage addr;
95997 + struct sockaddr_storage addr = { };
95998
95999 /* user mode address pointers */
96000 struct sockaddr __user *uaddr;
96001 @@ -2235,7 +2301,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96002 * kernel msghdr to use the kernel address space)
96003 */
96004
96005 - uaddr = (__force void __user *)msg_sys->msg_name;
96006 + uaddr = (void __force_user *)msg_sys->msg_name;
96007 uaddr_len = COMPAT_NAMELEN(msg);
96008 if (MSG_CMSG_COMPAT & flags) {
96009 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
96010 @@ -2990,7 +3056,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
96011 old_fs = get_fs();
96012 set_fs(KERNEL_DS);
96013 err = dev_ioctl(net, cmd,
96014 - (struct ifreq __user __force *) &kifr);
96015 + (struct ifreq __force_user *) &kifr);
96016 set_fs(old_fs);
96017
96018 return err;
96019 @@ -3099,7 +3165,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
96020
96021 old_fs = get_fs();
96022 set_fs(KERNEL_DS);
96023 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
96024 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
96025 set_fs(old_fs);
96026
96027 if (cmd == SIOCGIFMAP && !err) {
96028 @@ -3204,7 +3270,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
96029 ret |= __get_user(rtdev, &(ur4->rt_dev));
96030 if (rtdev) {
96031 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
96032 - r4.rt_dev = (char __user __force *)devname;
96033 + r4.rt_dev = (char __force_user *)devname;
96034 devname[15] = 0;
96035 } else
96036 r4.rt_dev = NULL;
96037 @@ -3430,8 +3496,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
96038 int __user *uoptlen;
96039 int err;
96040
96041 - uoptval = (char __user __force *) optval;
96042 - uoptlen = (int __user __force *) optlen;
96043 + uoptval = (char __force_user *) optval;
96044 + uoptlen = (int __force_user *) optlen;
96045
96046 set_fs(KERNEL_DS);
96047 if (level == SOL_SOCKET)
96048 @@ -3451,7 +3517,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
96049 char __user *uoptval;
96050 int err;
96051
96052 - uoptval = (char __user __force *) optval;
96053 + uoptval = (char __force_user *) optval;
96054
96055 set_fs(KERNEL_DS);
96056 if (level == SOL_SOCKET)
96057 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
96058 index 09fb638..2e6a5c5 100644
96059 --- a/net/sunrpc/auth_gss/svcauth_gss.c
96060 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
96061 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96062 uint64_t *handle)
96063 {
96064 struct rsc rsci, *rscp = NULL;
96065 - static atomic64_t ctxhctr;
96066 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
96067 long long ctxh;
96068 struct gss_api_mech *gm = NULL;
96069 time_t expiry;
96070 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96071 status = -ENOMEM;
96072 /* the handle needs to be just a unique id,
96073 * use a static counter */
96074 - ctxh = atomic64_inc_return(&ctxhctr);
96075 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
96076
96077 /* make a copy for the caller */
96078 *handle = ctxh;
96079 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
96080 index ecbc4e3..098e564 100644
96081 --- a/net/sunrpc/clnt.c
96082 +++ b/net/sunrpc/clnt.c
96083 @@ -645,14 +645,16 @@ EXPORT_SYMBOL_GPL(rpc_shutdown_client);
96084 /*
96085 * Free an RPC client
96086 */
96087 -static void
96088 +static struct rpc_clnt *
96089 rpc_free_client(struct rpc_clnt *clnt)
96090 {
96091 + struct rpc_clnt *parent = NULL;
96092 +
96093 dprintk_rcu("RPC: destroying %s client for %s\n",
96094 clnt->cl_protname,
96095 rcu_dereference(clnt->cl_xprt)->servername);
96096 if (clnt->cl_parent != clnt)
96097 - rpc_release_client(clnt->cl_parent);
96098 + parent = clnt->cl_parent;
96099 rpc_clnt_remove_pipedir(clnt);
96100 rpc_unregister_client(clnt);
96101 rpc_free_iostats(clnt->cl_metrics);
96102 @@ -661,18 +663,17 @@ rpc_free_client(struct rpc_clnt *clnt)
96103 xprt_put(rcu_dereference_raw(clnt->cl_xprt));
96104 rpciod_down();
96105 kfree(clnt);
96106 + return parent;
96107 }
96108
96109 /*
96110 * Free an RPC client
96111 */
96112 -static void
96113 +static struct rpc_clnt *
96114 rpc_free_auth(struct rpc_clnt *clnt)
96115 {
96116 - if (clnt->cl_auth == NULL) {
96117 - rpc_free_client(clnt);
96118 - return;
96119 - }
96120 + if (clnt->cl_auth == NULL)
96121 + return rpc_free_client(clnt);
96122
96123 /*
96124 * Note: RPCSEC_GSS may need to send NULL RPC calls in order to
96125 @@ -683,7 +684,8 @@ rpc_free_auth(struct rpc_clnt *clnt)
96126 rpcauth_release(clnt->cl_auth);
96127 clnt->cl_auth = NULL;
96128 if (atomic_dec_and_test(&clnt->cl_count))
96129 - rpc_free_client(clnt);
96130 + return rpc_free_client(clnt);
96131 + return NULL;
96132 }
96133
96134 /*
96135 @@ -694,10 +696,13 @@ rpc_release_client(struct rpc_clnt *clnt)
96136 {
96137 dprintk("RPC: rpc_release_client(%p)\n", clnt);
96138
96139 - if (list_empty(&clnt->cl_tasks))
96140 - wake_up(&destroy_wait);
96141 - if (atomic_dec_and_test(&clnt->cl_count))
96142 - rpc_free_auth(clnt);
96143 + do {
96144 + if (list_empty(&clnt->cl_tasks))
96145 + wake_up(&destroy_wait);
96146 + if (!atomic_dec_and_test(&clnt->cl_count))
96147 + break;
96148 + clnt = rpc_free_auth(clnt);
96149 + } while (clnt != NULL);
96150 }
96151 EXPORT_SYMBOL_GPL(rpc_release_client);
96152
96153 @@ -1304,7 +1309,9 @@ call_start(struct rpc_task *task)
96154 (RPC_IS_ASYNC(task) ? "async" : "sync"));
96155
96156 /* Increment call count */
96157 - task->tk_msg.rpc_proc->p_count++;
96158 + pax_open_kernel();
96159 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
96160 + pax_close_kernel();
96161 clnt->cl_stats->rpccnt++;
96162 task->tk_action = call_reserve;
96163 }
96164 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
96165 index 93a7a4e..3b98b9f 100644
96166 --- a/net/sunrpc/sched.c
96167 +++ b/net/sunrpc/sched.c
96168 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
96169 #ifdef RPC_DEBUG
96170 static void rpc_task_set_debuginfo(struct rpc_task *task)
96171 {
96172 - static atomic_t rpc_pid;
96173 + static atomic_unchecked_t rpc_pid;
96174
96175 - task->tk_pid = atomic_inc_return(&rpc_pid);
96176 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
96177 }
96178 #else
96179 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
96180 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
96181 index b974571..678ed90 100644
96182 --- a/net/sunrpc/svc.c
96183 +++ b/net/sunrpc/svc.c
96184 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
96185 svc_putnl(resv, RPC_SUCCESS);
96186
96187 /* Bump per-procedure stats counter */
96188 - procp->pc_count++;
96189 + pax_open_kernel();
96190 + (*(unsigned int *)&procp->pc_count)++;
96191 + pax_close_kernel();
96192
96193 /* Initialize storage for argp and resp */
96194 memset(rqstp->rq_argp, 0, procp->pc_argsize);
96195 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
96196 index c1b6270..05089c1 100644
96197 --- a/net/sunrpc/xprtrdma/svc_rdma.c
96198 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
96199 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
96200 static unsigned int min_max_inline = 4096;
96201 static unsigned int max_max_inline = 65536;
96202
96203 -atomic_t rdma_stat_recv;
96204 -atomic_t rdma_stat_read;
96205 -atomic_t rdma_stat_write;
96206 -atomic_t rdma_stat_sq_starve;
96207 -atomic_t rdma_stat_rq_starve;
96208 -atomic_t rdma_stat_rq_poll;
96209 -atomic_t rdma_stat_rq_prod;
96210 -atomic_t rdma_stat_sq_poll;
96211 -atomic_t rdma_stat_sq_prod;
96212 +atomic_unchecked_t rdma_stat_recv;
96213 +atomic_unchecked_t rdma_stat_read;
96214 +atomic_unchecked_t rdma_stat_write;
96215 +atomic_unchecked_t rdma_stat_sq_starve;
96216 +atomic_unchecked_t rdma_stat_rq_starve;
96217 +atomic_unchecked_t rdma_stat_rq_poll;
96218 +atomic_unchecked_t rdma_stat_rq_prod;
96219 +atomic_unchecked_t rdma_stat_sq_poll;
96220 +atomic_unchecked_t rdma_stat_sq_prod;
96221
96222 /* Temporary NFS request map and context caches */
96223 struct kmem_cache *svc_rdma_map_cachep;
96224 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
96225 len -= *ppos;
96226 if (len > *lenp)
96227 len = *lenp;
96228 - if (len && copy_to_user(buffer, str_buf, len))
96229 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
96230 return -EFAULT;
96231 *lenp = len;
96232 *ppos += len;
96233 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
96234 {
96235 .procname = "rdma_stat_read",
96236 .data = &rdma_stat_read,
96237 - .maxlen = sizeof(atomic_t),
96238 + .maxlen = sizeof(atomic_unchecked_t),
96239 .mode = 0644,
96240 .proc_handler = read_reset_stat,
96241 },
96242 {
96243 .procname = "rdma_stat_recv",
96244 .data = &rdma_stat_recv,
96245 - .maxlen = sizeof(atomic_t),
96246 + .maxlen = sizeof(atomic_unchecked_t),
96247 .mode = 0644,
96248 .proc_handler = read_reset_stat,
96249 },
96250 {
96251 .procname = "rdma_stat_write",
96252 .data = &rdma_stat_write,
96253 - .maxlen = sizeof(atomic_t),
96254 + .maxlen = sizeof(atomic_unchecked_t),
96255 .mode = 0644,
96256 .proc_handler = read_reset_stat,
96257 },
96258 {
96259 .procname = "rdma_stat_sq_starve",
96260 .data = &rdma_stat_sq_starve,
96261 - .maxlen = sizeof(atomic_t),
96262 + .maxlen = sizeof(atomic_unchecked_t),
96263 .mode = 0644,
96264 .proc_handler = read_reset_stat,
96265 },
96266 {
96267 .procname = "rdma_stat_rq_starve",
96268 .data = &rdma_stat_rq_starve,
96269 - .maxlen = sizeof(atomic_t),
96270 + .maxlen = sizeof(atomic_unchecked_t),
96271 .mode = 0644,
96272 .proc_handler = read_reset_stat,
96273 },
96274 {
96275 .procname = "rdma_stat_rq_poll",
96276 .data = &rdma_stat_rq_poll,
96277 - .maxlen = sizeof(atomic_t),
96278 + .maxlen = sizeof(atomic_unchecked_t),
96279 .mode = 0644,
96280 .proc_handler = read_reset_stat,
96281 },
96282 {
96283 .procname = "rdma_stat_rq_prod",
96284 .data = &rdma_stat_rq_prod,
96285 - .maxlen = sizeof(atomic_t),
96286 + .maxlen = sizeof(atomic_unchecked_t),
96287 .mode = 0644,
96288 .proc_handler = read_reset_stat,
96289 },
96290 {
96291 .procname = "rdma_stat_sq_poll",
96292 .data = &rdma_stat_sq_poll,
96293 - .maxlen = sizeof(atomic_t),
96294 + .maxlen = sizeof(atomic_unchecked_t),
96295 .mode = 0644,
96296 .proc_handler = read_reset_stat,
96297 },
96298 {
96299 .procname = "rdma_stat_sq_prod",
96300 .data = &rdma_stat_sq_prod,
96301 - .maxlen = sizeof(atomic_t),
96302 + .maxlen = sizeof(atomic_unchecked_t),
96303 .mode = 0644,
96304 .proc_handler = read_reset_stat,
96305 },
96306 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96307 index 0ce7552..d074459 100644
96308 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96309 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96310 @@ -501,7 +501,7 @@ next_sge:
96311 svc_rdma_put_context(ctxt, 0);
96312 goto out;
96313 }
96314 - atomic_inc(&rdma_stat_read);
96315 + atomic_inc_unchecked(&rdma_stat_read);
96316
96317 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
96318 chl_map->ch[ch_no].count -= read_wr.num_sge;
96319 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96320 dto_q);
96321 list_del_init(&ctxt->dto_q);
96322 } else {
96323 - atomic_inc(&rdma_stat_rq_starve);
96324 + atomic_inc_unchecked(&rdma_stat_rq_starve);
96325 clear_bit(XPT_DATA, &xprt->xpt_flags);
96326 ctxt = NULL;
96327 }
96328 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96329 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
96330 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
96331 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
96332 - atomic_inc(&rdma_stat_recv);
96333 + atomic_inc_unchecked(&rdma_stat_recv);
96334
96335 /* Build up the XDR from the receive buffers. */
96336 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
96337 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96338 index c1d124d..acfc59e 100644
96339 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96340 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96341 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
96342 write_wr.wr.rdma.remote_addr = to;
96343
96344 /* Post It */
96345 - atomic_inc(&rdma_stat_write);
96346 + atomic_inc_unchecked(&rdma_stat_write);
96347 if (svc_rdma_send(xprt, &write_wr))
96348 goto err;
96349 return 0;
96350 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96351 index 62e4f9b..dd3f2d7 100644
96352 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
96353 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96354 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96355 return;
96356
96357 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
96358 - atomic_inc(&rdma_stat_rq_poll);
96359 + atomic_inc_unchecked(&rdma_stat_rq_poll);
96360
96361 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
96362 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
96363 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96364 }
96365
96366 if (ctxt)
96367 - atomic_inc(&rdma_stat_rq_prod);
96368 + atomic_inc_unchecked(&rdma_stat_rq_prod);
96369
96370 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
96371 /*
96372 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96373 return;
96374
96375 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
96376 - atomic_inc(&rdma_stat_sq_poll);
96377 + atomic_inc_unchecked(&rdma_stat_sq_poll);
96378 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
96379 if (wc.status != IB_WC_SUCCESS)
96380 /* Close the transport */
96381 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96382 }
96383
96384 if (ctxt)
96385 - atomic_inc(&rdma_stat_sq_prod);
96386 + atomic_inc_unchecked(&rdma_stat_sq_prod);
96387 }
96388
96389 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
96390 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
96391 spin_lock_bh(&xprt->sc_lock);
96392 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
96393 spin_unlock_bh(&xprt->sc_lock);
96394 - atomic_inc(&rdma_stat_sq_starve);
96395 + atomic_inc_unchecked(&rdma_stat_sq_starve);
96396
96397 /* See if we can opportunistically reap SQ WR to make room */
96398 sq_cq_reap(xprt);
96399 diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
96400 index ddf0602..e865e08 100644
96401 --- a/net/sunrpc/xprtsock.c
96402 +++ b/net/sunrpc/xprtsock.c
96403 @@ -391,8 +391,10 @@ static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen,
96404 return kernel_sendmsg(sock, &msg, NULL, 0, 0);
96405 }
96406
96407 -static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more)
96408 +static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more, bool zerocopy)
96409 {
96410 + ssize_t (*do_sendpage)(struct socket *sock, struct page *page,
96411 + int offset, size_t size, int flags);
96412 struct page **ppage;
96413 unsigned int remainder;
96414 int err, sent = 0;
96415 @@ -401,6 +403,9 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
96416 base += xdr->page_base;
96417 ppage = xdr->pages + (base >> PAGE_SHIFT);
96418 base &= ~PAGE_MASK;
96419 + do_sendpage = sock->ops->sendpage;
96420 + if (!zerocopy)
96421 + do_sendpage = sock_no_sendpage;
96422 for(;;) {
96423 unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);
96424 int flags = XS_SENDMSG_FLAGS;
96425 @@ -408,7 +413,7 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
96426 remainder -= len;
96427 if (remainder != 0 || more)
96428 flags |= MSG_MORE;
96429 - err = sock->ops->sendpage(sock, *ppage, base, len, flags);
96430 + err = do_sendpage(sock, *ppage, base, len, flags);
96431 if (remainder == 0 || err != len)
96432 break;
96433 sent += err;
96434 @@ -429,9 +434,10 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
96435 * @addrlen: UDP only -- length of destination address
96436 * @xdr: buffer containing this request
96437 * @base: starting position in the buffer
96438 + * @zerocopy: true if it is safe to use sendpage()
96439 *
96440 */
96441 -static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base)
96442 +static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, bool zerocopy)
96443 {
96444 unsigned int remainder = xdr->len - base;
96445 int err, sent = 0;
96446 @@ -459,7 +465,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
96447 if (base < xdr->page_len) {
96448 unsigned int len = xdr->page_len - base;
96449 remainder -= len;
96450 - err = xs_send_pagedata(sock, xdr, base, remainder != 0);
96451 + err = xs_send_pagedata(sock, xdr, base, remainder != 0, zerocopy);
96452 if (remainder == 0 || err != len)
96453 goto out;
96454 sent += err;
96455 @@ -562,7 +568,7 @@ static int xs_local_send_request(struct rpc_task *task)
96456 req->rq_svec->iov_base, req->rq_svec->iov_len);
96457
96458 status = xs_sendpages(transport->sock, NULL, 0,
96459 - xdr, req->rq_bytes_sent);
96460 + xdr, req->rq_bytes_sent, true);
96461 dprintk("RPC: %s(%u) = %d\n",
96462 __func__, xdr->len - req->rq_bytes_sent, status);
96463 if (likely(status >= 0)) {
96464 @@ -618,7 +624,7 @@ static int xs_udp_send_request(struct rpc_task *task)
96465 status = xs_sendpages(transport->sock,
96466 xs_addr(xprt),
96467 xprt->addrlen, xdr,
96468 - req->rq_bytes_sent);
96469 + req->rq_bytes_sent, true);
96470
96471 dprintk("RPC: xs_udp_send_request(%u) = %d\n",
96472 xdr->len - req->rq_bytes_sent, status);
96473 @@ -689,6 +695,7 @@ static int xs_tcp_send_request(struct rpc_task *task)
96474 struct rpc_xprt *xprt = req->rq_xprt;
96475 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
96476 struct xdr_buf *xdr = &req->rq_snd_buf;
96477 + bool zerocopy = true;
96478 int status;
96479
96480 xs_encode_stream_record_marker(&req->rq_snd_buf);
96481 @@ -696,13 +703,20 @@ static int xs_tcp_send_request(struct rpc_task *task)
96482 xs_pktdump("packet data:",
96483 req->rq_svec->iov_base,
96484 req->rq_svec->iov_len);
96485 + /* Don't use zero copy if this is a resend. If the RPC call
96486 + * completes while the socket holds a reference to the pages,
96487 + * then we may end up resending corrupted data.
96488 + */
96489 + if (task->tk_flags & RPC_TASK_SENT)
96490 + zerocopy = false;
96491
96492 /* Continue transmitting the packet/record. We must be careful
96493 * to cope with writespace callbacks arriving _after_ we have
96494 * called sendmsg(). */
96495 while (1) {
96496 status = xs_sendpages(transport->sock,
96497 - NULL, 0, xdr, req->rq_bytes_sent);
96498 + NULL, 0, xdr, req->rq_bytes_sent,
96499 + zerocopy);
96500
96501 dprintk("RPC: xs_tcp_send_request(%u) = %d\n",
96502 xdr->len - req->rq_bytes_sent, status);
96503 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
96504 index e7000be..e3b0ba7 100644
96505 --- a/net/sysctl_net.c
96506 +++ b/net/sysctl_net.c
96507 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
96508 kgid_t root_gid = make_kgid(net->user_ns, 0);
96509
96510 /* Allow network administrator to have same access as root. */
96511 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
96512 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
96513 uid_eq(root_uid, current_euid())) {
96514 int mode = (table->mode >> 6) & 7;
96515 return (mode << 6) | (mode << 3) | mode;
96516 diff --git a/net/tipc/link.c b/net/tipc/link.c
96517 index 0cc3d90..cc42021 100644
96518 --- a/net/tipc/link.c
96519 +++ b/net/tipc/link.c
96520 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
96521 struct tipc_msg fragm_hdr;
96522 struct sk_buff *buf, *buf_chain, *prev;
96523 u32 fragm_crs, fragm_rest, hsz, sect_rest;
96524 - const unchar *sect_crs;
96525 + const unchar __user *sect_crs;
96526 int curr_sect;
96527 u32 fragm_no;
96528 int res = 0;
96529 @@ -1207,7 +1207,7 @@ again:
96530
96531 if (!sect_rest) {
96532 sect_rest = msg_sect[++curr_sect].iov_len;
96533 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
96534 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
96535 }
96536
96537 if (sect_rest < fragm_rest)
96538 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
96539 index ced60e2..54eab6c 100644
96540 --- a/net/tipc/msg.c
96541 +++ b/net/tipc/msg.c
96542 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
96543 skb_copy_to_linear_data(*buf, hdr, hsz);
96544 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
96545 skb_copy_to_linear_data_offset(*buf, pos,
96546 - msg_sect[cnt].iov_base,
96547 + (const void __force_kernel *)msg_sect[cnt].iov_base,
96548 msg_sect[cnt].iov_len);
96549 pos += msg_sect[cnt].iov_len;
96550 }
96551 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
96552 index d38bb45..4fd6ac6 100644
96553 --- a/net/tipc/subscr.c
96554 +++ b/net/tipc/subscr.c
96555 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
96556 struct kvec msg_sect;
96557 int ret;
96558
96559 - msg_sect.iov_base = (void *)&sub->evt;
96560 + msg_sect.iov_base = (void __force_user *)&sub->evt;
96561 msg_sect.iov_len = sizeof(struct tipc_event);
96562
96563 sub->evt.event = htohl(event, sub->swap);
96564 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
96565 index e64bbcf..9c3ba79 100644
96566 --- a/net/unix/af_unix.c
96567 +++ b/net/unix/af_unix.c
96568 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
96569 err = -ECONNREFUSED;
96570 if (!S_ISSOCK(inode->i_mode))
96571 goto put_fail;
96572 +
96573 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
96574 + err = -EACCES;
96575 + goto put_fail;
96576 + }
96577 +
96578 u = unix_find_socket_byinode(inode);
96579 if (!u)
96580 goto put_fail;
96581 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
96582 if (u) {
96583 struct dentry *dentry;
96584 dentry = unix_sk(u)->path.dentry;
96585 +
96586 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
96587 + err = -EPERM;
96588 + sock_put(u);
96589 + goto fail;
96590 + }
96591 +
96592 if (dentry)
96593 touch_atime(&unix_sk(u)->path);
96594 } else
96595 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
96596 */
96597 err = security_path_mknod(&path, dentry, mode, 0);
96598 if (!err) {
96599 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
96600 + err = -EACCES;
96601 + goto out;
96602 + }
96603 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
96604 if (!err) {
96605 res->mnt = mntget(path.mnt);
96606 res->dentry = dget(dentry);
96607 + gr_handle_create(dentry, path.mnt);
96608 }
96609 }
96610 +out:
96611 done_path_create(&path, dentry);
96612 return err;
96613 }
96614 @@ -2335,9 +2354,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96615 seq_puts(seq, "Num RefCount Protocol Flags Type St "
96616 "Inode Path\n");
96617 else {
96618 - struct sock *s = v;
96619 + struct sock *s = v, *peer;
96620 struct unix_sock *u = unix_sk(s);
96621 unix_state_lock(s);
96622 + peer = unix_peer(s);
96623 + unix_state_unlock(s);
96624 +
96625 + unix_state_double_lock(s, peer);
96626
96627 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
96628 s,
96629 @@ -2364,8 +2387,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96630 }
96631 for ( ; i < len; i++)
96632 seq_putc(seq, u->addr->name->sun_path[i]);
96633 - }
96634 - unix_state_unlock(s);
96635 + } else if (peer)
96636 + seq_printf(seq, " P%lu", sock_i_ino(peer));
96637 +
96638 + unix_state_double_unlock(s, peer);
96639 seq_putc(seq, '\n');
96640 }
96641
96642 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
96643 index b3d5150..ff3a837 100644
96644 --- a/net/unix/sysctl_net_unix.c
96645 +++ b/net/unix/sysctl_net_unix.c
96646 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
96647
96648 int __net_init unix_sysctl_register(struct net *net)
96649 {
96650 - struct ctl_table *table;
96651 + ctl_table_no_const *table;
96652
96653 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
96654 if (table == NULL)
96655 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
96656 index c8717c1..08539f5 100644
96657 --- a/net/wireless/wext-core.c
96658 +++ b/net/wireless/wext-core.c
96659 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96660 */
96661
96662 /* Support for very large requests */
96663 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
96664 - (user_length > descr->max_tokens)) {
96665 + if (user_length > descr->max_tokens) {
96666 /* Allow userspace to GET more than max so
96667 * we can support any size GET requests.
96668 * There is still a limit : -ENOMEM.
96669 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96670 }
96671 }
96672
96673 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
96674 - /*
96675 - * If this is a GET, but not NOMAX, it means that the extra
96676 - * data is not bounded by userspace, but by max_tokens. Thus
96677 - * set the length to max_tokens. This matches the extra data
96678 - * allocation.
96679 - * The driver should fill it with the number of tokens it
96680 - * provided, and it may check iwp->length rather than having
96681 - * knowledge of max_tokens. If the driver doesn't change the
96682 - * iwp->length, this ioctl just copies back max_token tokens
96683 - * filled with zeroes. Hopefully the driver isn't claiming
96684 - * them to be valid data.
96685 - */
96686 - iwp->length = descr->max_tokens;
96687 - }
96688 -
96689 err = handler(dev, info, (union iwreq_data *) iwp, extra);
96690
96691 iwp->length += essid_compat;
96692 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
96693 index f77c371..b0cb010 100644
96694 --- a/net/xfrm/xfrm_policy.c
96695 +++ b/net/xfrm/xfrm_policy.c
96696 @@ -332,9 +332,10 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
96697 {
96698 policy->walk.dead = 1;
96699
96700 - atomic_inc(&policy->genid);
96701 + atomic_inc_unchecked(&policy->genid);
96702
96703 - del_timer(&policy->polq.hold_timer);
96704 + if (del_timer(&policy->polq.hold_timer))
96705 + xfrm_pol_put(policy);
96706 xfrm_queue_purge(&policy->polq.hold_queue);
96707
96708 if (del_timer(&policy->timer))
96709 @@ -589,7 +590,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96710
96711 spin_lock_bh(&pq->hold_queue.lock);
96712 skb_queue_splice_init(&pq->hold_queue, &list);
96713 - del_timer(&pq->hold_timer);
96714 + if (del_timer(&pq->hold_timer))
96715 + xfrm_pol_put(old);
96716 spin_unlock_bh(&pq->hold_queue.lock);
96717
96718 if (skb_queue_empty(&list))
96719 @@ -600,7 +602,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96720 spin_lock_bh(&pq->hold_queue.lock);
96721 skb_queue_splice(&list, &pq->hold_queue);
96722 pq->timeout = XFRM_QUEUE_TMO_MIN;
96723 - mod_timer(&pq->hold_timer, jiffies);
96724 + if (!mod_timer(&pq->hold_timer, jiffies))
96725 + xfrm_pol_hold(new);
96726 spin_unlock_bh(&pq->hold_queue.lock);
96727 }
96728
96729 @@ -657,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
96730 hlist_add_head(&policy->bydst, chain);
96731 xfrm_pol_hold(policy);
96732 net->xfrm.policy_count[dir]++;
96733 - atomic_inc(&flow_cache_genid);
96734 + atomic_inc_unchecked(&flow_cache_genid);
96735 rt_genid_bump(net);
96736 if (delpol) {
96737 xfrm_policy_requeue(delpol, policy);
96738 @@ -1627,7 +1630,7 @@ free_dst:
96739 goto out;
96740 }
96741
96742 -static int inline
96743 +static inline int
96744 xfrm_dst_alloc_copy(void **target, const void *src, int size)
96745 {
96746 if (!*target) {
96747 @@ -1639,7 +1642,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
96748 return 0;
96749 }
96750
96751 -static int inline
96752 +static inline int
96753 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96754 {
96755 #ifdef CONFIG_XFRM_SUB_POLICY
96756 @@ -1651,7 +1654,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96757 #endif
96758 }
96759
96760 -static int inline
96761 +static inline int
96762 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
96763 {
96764 #ifdef CONFIG_XFRM_SUB_POLICY
96765 @@ -1745,7 +1748,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
96766
96767 xdst->num_pols = num_pols;
96768 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
96769 - xdst->policy_genid = atomic_read(&pols[0]->genid);
96770 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
96771
96772 return xdst;
96773 }
96774 @@ -1763,6 +1766,10 @@ static void xfrm_policy_queue_process(unsigned long arg)
96775
96776 spin_lock(&pq->hold_queue.lock);
96777 skb = skb_peek(&pq->hold_queue);
96778 + if (!skb) {
96779 + spin_unlock(&pq->hold_queue.lock);
96780 + goto out;
96781 + }
96782 dst = skb_dst(skb);
96783 sk = skb->sk;
96784 xfrm_decode_session(skb, &fl, dst->ops->family);
96785 @@ -1781,8 +1788,9 @@ static void xfrm_policy_queue_process(unsigned long arg)
96786 goto purge_queue;
96787
96788 pq->timeout = pq->timeout << 1;
96789 - mod_timer(&pq->hold_timer, jiffies + pq->timeout);
96790 - return;
96791 + if (!mod_timer(&pq->hold_timer, jiffies + pq->timeout))
96792 + xfrm_pol_hold(pol);
96793 + goto out;
96794 }
96795
96796 dst_release(dst);
96797 @@ -1813,11 +1821,14 @@ static void xfrm_policy_queue_process(unsigned long arg)
96798 err = dst_output(skb);
96799 }
96800
96801 +out:
96802 + xfrm_pol_put(pol);
96803 return;
96804
96805 purge_queue:
96806 pq->timeout = 0;
96807 xfrm_queue_purge(&pq->hold_queue);
96808 + xfrm_pol_put(pol);
96809 }
96810
96811 static int xdst_queue_output(struct sk_buff *skb)
96812 @@ -1825,7 +1836,8 @@ static int xdst_queue_output(struct sk_buff *skb)
96813 unsigned long sched_next;
96814 struct dst_entry *dst = skb_dst(skb);
96815 struct xfrm_dst *xdst = (struct xfrm_dst *) dst;
96816 - struct xfrm_policy_queue *pq = &xdst->pols[0]->polq;
96817 + struct xfrm_policy *pol = xdst->pols[0];
96818 + struct xfrm_policy_queue *pq = &pol->polq;
96819
96820 if (pq->hold_queue.qlen > XFRM_MAX_QUEUE_LEN) {
96821 kfree_skb(skb);
96822 @@ -1844,10 +1856,12 @@ static int xdst_queue_output(struct sk_buff *skb)
96823 if (del_timer(&pq->hold_timer)) {
96824 if (time_before(pq->hold_timer.expires, sched_next))
96825 sched_next = pq->hold_timer.expires;
96826 + xfrm_pol_put(pol);
96827 }
96828
96829 __skb_queue_tail(&pq->hold_queue, skb);
96830 - mod_timer(&pq->hold_timer, sched_next);
96831 + if (!mod_timer(&pq->hold_timer, sched_next))
96832 + xfrm_pol_hold(pol);
96833
96834 spin_unlock_bh(&pq->hold_queue.lock);
96835
96836 @@ -2557,11 +2571,12 @@ void xfrm_garbage_collect(struct net *net)
96837 }
96838 EXPORT_SYMBOL(xfrm_garbage_collect);
96839
96840 -static void xfrm_garbage_collect_deferred(struct net *net)
96841 +void xfrm_garbage_collect_deferred(struct net *net)
96842 {
96843 flow_cache_flush_deferred();
96844 __xfrm_garbage_collect(net);
96845 }
96846 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
96847
96848 static void xfrm_init_pmtu(struct dst_entry *dst)
96849 {
96850 @@ -2611,7 +2626,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
96851 if (xdst->xfrm_genid != dst->xfrm->genid)
96852 return 0;
96853 if (xdst->num_pols > 0 &&
96854 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
96855 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
96856 return 0;
96857
96858 mtu = dst_mtu(dst->child);
96859 @@ -2699,8 +2714,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
96860 dst_ops->link_failure = xfrm_link_failure;
96861 if (likely(dst_ops->neigh_lookup == NULL))
96862 dst_ops->neigh_lookup = xfrm_neigh_lookup;
96863 - if (likely(afinfo->garbage_collect == NULL))
96864 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
96865 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
96866 }
96867 spin_unlock(&xfrm_policy_afinfo_lock);
96868 @@ -2754,7 +2767,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
96869 dst_ops->check = NULL;
96870 dst_ops->negative_advice = NULL;
96871 dst_ops->link_failure = NULL;
96872 - afinfo->garbage_collect = NULL;
96873 }
96874 return err;
96875 }
96876 @@ -3137,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
96877 sizeof(pol->xfrm_vec[i].saddr));
96878 pol->xfrm_vec[i].encap_family = mp->new_family;
96879 /* flush bundles */
96880 - atomic_inc(&pol->genid);
96881 + atomic_inc_unchecked(&pol->genid);
96882 }
96883 }
96884
96885 diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c
96886 index 8dafe6d3..dab57da 100644
96887 --- a/net/xfrm/xfrm_replay.c
96888 +++ b/net/xfrm/xfrm_replay.c
96889 @@ -61,9 +61,9 @@ static void xfrm_replay_notify(struct xfrm_state *x, int event)
96890
96891 switch (event) {
96892 case XFRM_REPLAY_UPDATE:
96893 - if (x->replay_maxdiff &&
96894 - (x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
96895 - (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff)) {
96896 + if (!x->replay_maxdiff ||
96897 + ((x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
96898 + (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff))) {
96899 if (x->xflags & XFRM_TIME_DEFER)
96900 event = XFRM_REPLAY_TIMEOUT;
96901 else
96902 @@ -129,8 +129,7 @@ static int xfrm_replay_check(struct xfrm_state *x,
96903 return 0;
96904
96905 diff = x->replay.seq - seq;
96906 - if (diff >= min_t(unsigned int, x->props.replay_window,
96907 - sizeof(x->replay.bitmap) * 8)) {
96908 + if (diff >= x->props.replay_window) {
96909 x->stats.replay_window++;
96910 goto err;
96911 }
96912 @@ -302,9 +301,10 @@ static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event)
96913
96914 switch (event) {
96915 case XFRM_REPLAY_UPDATE:
96916 - if (x->replay_maxdiff &&
96917 - (replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
96918 - (replay_esn->oseq - preplay_esn->oseq < x->replay_maxdiff)) {
96919 + if (!x->replay_maxdiff ||
96920 + ((replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
96921 + (replay_esn->oseq - preplay_esn->oseq
96922 + < x->replay_maxdiff))) {
96923 if (x->xflags & XFRM_TIME_DEFER)
96924 event = XFRM_REPLAY_TIMEOUT;
96925 else
96926 @@ -353,28 +353,30 @@ static void xfrm_replay_notify_esn(struct xfrm_state *x, int event)
96927
96928 switch (event) {
96929 case XFRM_REPLAY_UPDATE:
96930 - if (!x->replay_maxdiff)
96931 - break;
96932 -
96933 - if (replay_esn->seq_hi == preplay_esn->seq_hi)
96934 - seq_diff = replay_esn->seq - preplay_esn->seq;
96935 - else
96936 - seq_diff = ~preplay_esn->seq + replay_esn->seq + 1;
96937 -
96938 - if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
96939 - oseq_diff = replay_esn->oseq - preplay_esn->oseq;
96940 - else
96941 - oseq_diff = ~preplay_esn->oseq + replay_esn->oseq + 1;
96942 -
96943 - if (seq_diff < x->replay_maxdiff &&
96944 - oseq_diff < x->replay_maxdiff) {
96945 + if (x->replay_maxdiff) {
96946 + if (replay_esn->seq_hi == preplay_esn->seq_hi)
96947 + seq_diff = replay_esn->seq - preplay_esn->seq;
96948 + else
96949 + seq_diff = ~preplay_esn->seq + replay_esn->seq
96950 + + 1;
96951
96952 - if (x->xflags & XFRM_TIME_DEFER)
96953 - event = XFRM_REPLAY_TIMEOUT;
96954 + if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
96955 + oseq_diff = replay_esn->oseq
96956 + - preplay_esn->oseq;
96957 else
96958 - return;
96959 + oseq_diff = ~preplay_esn->oseq
96960 + + replay_esn->oseq + 1;
96961 +
96962 + if (seq_diff >= x->replay_maxdiff ||
96963 + oseq_diff >= x->replay_maxdiff)
96964 + break;
96965 }
96966
96967 + if (x->xflags & XFRM_TIME_DEFER)
96968 + event = XFRM_REPLAY_TIMEOUT;
96969 + else
96970 + return;
96971 +
96972 break;
96973
96974 case XFRM_REPLAY_TIMEOUT:
96975 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
96976 index 54c0acd..56814bd 100644
96977 --- a/net/xfrm/xfrm_state.c
96978 +++ b/net/xfrm/xfrm_state.c
96979 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
96980
96981 if (unlikely(afinfo == NULL))
96982 return -EAFNOSUPPORT;
96983 - typemap = afinfo->type_map;
96984 + typemap = (const struct xfrm_type **)afinfo->type_map;
96985 spin_lock_bh(&xfrm_type_lock);
96986
96987 - if (likely(typemap[type->proto] == NULL))
96988 + if (likely(typemap[type->proto] == NULL)) {
96989 + pax_open_kernel();
96990 typemap[type->proto] = type;
96991 - else
96992 + pax_close_kernel();
96993 + } else
96994 err = -EEXIST;
96995 spin_unlock_bh(&xfrm_type_lock);
96996 xfrm_state_put_afinfo(afinfo);
96997 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
96998
96999 if (unlikely(afinfo == NULL))
97000 return -EAFNOSUPPORT;
97001 - typemap = afinfo->type_map;
97002 + typemap = (const struct xfrm_type **)afinfo->type_map;
97003 spin_lock_bh(&xfrm_type_lock);
97004
97005 if (unlikely(typemap[type->proto] != type))
97006 err = -ENOENT;
97007 - else
97008 + else {
97009 + pax_open_kernel();
97010 typemap[type->proto] = NULL;
97011 + pax_close_kernel();
97012 + }
97013 spin_unlock_bh(&xfrm_type_lock);
97014 xfrm_state_put_afinfo(afinfo);
97015 return err;
97016 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
97017 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
97018 {
97019 struct xfrm_state_afinfo *afinfo;
97020 - const struct xfrm_type **typemap;
97021 const struct xfrm_type *type;
97022 int modload_attempted = 0;
97023
97024 @@ -219,9 +223,8 @@ retry:
97025 afinfo = xfrm_state_get_afinfo(family);
97026 if (unlikely(afinfo == NULL))
97027 return NULL;
97028 - typemap = afinfo->type_map;
97029
97030 - type = typemap[proto];
97031 + type = afinfo->type_map[proto];
97032 if (unlikely(type && !try_module_get(type->owner)))
97033 type = NULL;
97034 if (!type && !modload_attempted) {
97035 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97036 return -EAFNOSUPPORT;
97037
97038 err = -EEXIST;
97039 - modemap = afinfo->mode_map;
97040 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97041 spin_lock_bh(&xfrm_mode_lock);
97042 if (modemap[mode->encap])
97043 goto out;
97044 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97045 if (!try_module_get(afinfo->owner))
97046 goto out;
97047
97048 - mode->afinfo = afinfo;
97049 + pax_open_kernel();
97050 + *(const void **)&mode->afinfo = afinfo;
97051 modemap[mode->encap] = mode;
97052 + pax_close_kernel();
97053 err = 0;
97054
97055 out:
97056 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
97057 return -EAFNOSUPPORT;
97058
97059 err = -ENOENT;
97060 - modemap = afinfo->mode_map;
97061 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97062 spin_lock_bh(&xfrm_mode_lock);
97063 if (likely(modemap[mode->encap] == mode)) {
97064 + pax_open_kernel();
97065 modemap[mode->encap] = NULL;
97066 + pax_close_kernel();
97067 module_put(mode->afinfo->owner);
97068 err = 0;
97069 }
97070 @@ -1483,10 +1490,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
97071 u32 xfrm_get_acqseq(void)
97072 {
97073 u32 res;
97074 - static atomic_t acqseq;
97075 + static atomic_unchecked_t acqseq;
97076
97077 do {
97078 - res = atomic_inc_return(&acqseq);
97079 + res = atomic_inc_return_unchecked(&acqseq);
97080 } while (!res);
97081
97082 return res;
97083 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
97084 index 05a6e3d..6716ec9 100644
97085 --- a/net/xfrm/xfrm_sysctl.c
97086 +++ b/net/xfrm/xfrm_sysctl.c
97087 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
97088
97089 int __net_init xfrm_sysctl_init(struct net *net)
97090 {
97091 - struct ctl_table *table;
97092 + ctl_table_no_const *table;
97093
97094 __xfrm_sysctl_init(net);
97095
97096 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
97097 index 3f565e4..f964d4c 100644
97098 --- a/net/xfrm/xfrm_user.c
97099 +++ b/net/xfrm/xfrm_user.c
97100 @@ -446,7 +446,8 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *
97101 memcpy(&x->sel, &p->sel, sizeof(x->sel));
97102 memcpy(&x->lft, &p->lft, sizeof(x->lft));
97103 x->props.mode = p->mode;
97104 - x->props.replay_window = p->replay_window;
97105 + x->props.replay_window = min_t(unsigned int, p->replay_window,
97106 + sizeof(x->replay.bitmap) * 8);
97107 x->props.reqid = p->reqid;
97108 x->props.family = p->family;
97109 memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr));
97110 @@ -1856,7 +1857,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
97111 if (x->km.state != XFRM_STATE_VALID)
97112 goto out;
97113
97114 - err = xfrm_replay_verify_len(x->replay_esn, rp);
97115 + err = xfrm_replay_verify_len(x->replay_esn, re);
97116 if (err)
97117 goto out;
97118
97119 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
97120 index d5d859c..781cbcb 100644
97121 --- a/scripts/Makefile.build
97122 +++ b/scripts/Makefile.build
97123 @@ -111,7 +111,7 @@ endif
97124 endif
97125
97126 # Do not include host rules unless needed
97127 -ifneq ($(hostprogs-y)$(hostprogs-m),)
97128 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
97129 include scripts/Makefile.host
97130 endif
97131
97132 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
97133 index 686cb0d..9d653bf 100644
97134 --- a/scripts/Makefile.clean
97135 +++ b/scripts/Makefile.clean
97136 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
97137 __clean-files := $(extra-y) $(always) \
97138 $(targets) $(clean-files) \
97139 $(host-progs) \
97140 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
97141 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
97142 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
97143
97144 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
97145
97146 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
97147 index 1ac414f..38575f7 100644
97148 --- a/scripts/Makefile.host
97149 +++ b/scripts/Makefile.host
97150 @@ -31,6 +31,8 @@
97151 # Note: Shared libraries consisting of C++ files are not supported
97152
97153 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
97154 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
97155 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
97156
97157 # C code
97158 # Executables compiled from a single .c file
97159 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
97160 # Shared libaries (only .c supported)
97161 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
97162 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
97163 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
97164 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
97165 # Remove .so files from "xxx-objs"
97166 host-cobjs := $(filter-out %.so,$(host-cobjs))
97167 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
97168
97169 -#Object (.o) files used by the shared libaries
97170 +# Object (.o) files used by the shared libaries
97171 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
97172 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
97173
97174 # output directory for programs/.o files
97175 # hostprogs-y := tools/build may have been specified. Retrieve directory
97176 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
97177 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
97178 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
97179 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
97180 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
97181 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
97182 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
97183 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
97184
97185 obj-dirs += $(host-objdirs)
97186 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
97187 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
97188 $(call if_changed_dep,host-cshobjs)
97189
97190 +# Compile .c file, create position independent .o file
97191 +# host-cxxshobjs -> .o
97192 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
97193 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
97194 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
97195 + $(call if_changed_dep,host-cxxshobjs)
97196 +
97197 # Link a shared library, based on position independent .o files
97198 # *.o -> .so shared library (host-cshlib)
97199 quiet_cmd_host-cshlib = HOSTLLD -shared $@
97200 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
97201 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
97202 $(call if_changed,host-cshlib)
97203
97204 +# Link a shared library, based on position independent .o files
97205 +# *.o -> .so shared library (host-cxxshlib)
97206 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
97207 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
97208 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
97209 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
97210 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
97211 + $(call if_changed,host-cxxshlib)
97212 +
97213 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
97214 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
97215 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
97216
97217 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
97218 index 078fe1d..fbdb363 100644
97219 --- a/scripts/basic/fixdep.c
97220 +++ b/scripts/basic/fixdep.c
97221 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
97222 /*
97223 * Lookup a value in the configuration string.
97224 */
97225 -static int is_defined_config(const char *name, int len, unsigned int hash)
97226 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
97227 {
97228 struct item *aux;
97229
97230 @@ -211,10 +211,10 @@ static void clear_config(void)
97231 /*
97232 * Record the use of a CONFIG_* word.
97233 */
97234 -static void use_config(const char *m, int slen)
97235 +static void use_config(const char *m, unsigned int slen)
97236 {
97237 unsigned int hash = strhash(m, slen);
97238 - int c, i;
97239 + unsigned int c, i;
97240
97241 if (is_defined_config(m, slen, hash))
97242 return;
97243 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
97244
97245 static void parse_config_file(const char *map, size_t len)
97246 {
97247 - const int *end = (const int *) (map + len);
97248 + const unsigned int *end = (const unsigned int *) (map + len);
97249 /* start at +1, so that p can never be < map */
97250 - const int *m = (const int *) map + 1;
97251 + const unsigned int *m = (const unsigned int *) map + 1;
97252 const char *p, *q;
97253
97254 for (; m < end; m++) {
97255 @@ -435,7 +435,7 @@ static void print_deps(void)
97256 static void traps(void)
97257 {
97258 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
97259 - int *p = (int *)test;
97260 + unsigned int *p = (unsigned int *)test;
97261
97262 if (*p != INT_CONF) {
97263 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
97264 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
97265 new file mode 100644
97266 index 0000000..5e0222d
97267 --- /dev/null
97268 +++ b/scripts/gcc-plugin.sh
97269 @@ -0,0 +1,17 @@
97270 +#!/bin/bash
97271 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
97272 +#include "gcc-plugin.h"
97273 +#include "tree.h"
97274 +#include "tm.h"
97275 +#include "rtl.h"
97276 +#ifdef ENABLE_BUILD_WITH_CXX
97277 +#warning $2
97278 +#else
97279 +#warning $1
97280 +#endif
97281 +EOF`
97282 +if [ $? -eq 0 ]
97283 +then
97284 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
97285 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
97286 +fi
97287 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
97288 index 5de5660..d3deb89 100644
97289 --- a/scripts/headers_install.sh
97290 +++ b/scripts/headers_install.sh
97291 @@ -32,6 +32,7 @@ do
97292 FILE="$(basename "$i")"
97293 sed -r \
97294 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
97295 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
97296 -e 's/__attribute_const__([ \t]|$)/\1/g' \
97297 -e 's@^#include <linux/compiler.h>@@' \
97298 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
97299 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
97300 index 32b10f5..0d8d2ee 100644
97301 --- a/scripts/link-vmlinux.sh
97302 +++ b/scripts/link-vmlinux.sh
97303 @@ -160,7 +160,7 @@ else
97304 fi;
97305
97306 # final build of init/
97307 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
97308 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
97309
97310 kallsymso=""
97311 kallsyms_vmlinux=""
97312 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
97313 index 2370863..212fbca 100644
97314 --- a/scripts/mod/file2alias.c
97315 +++ b/scripts/mod/file2alias.c
97316 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
97317 unsigned long size, unsigned long id_size,
97318 void *symval)
97319 {
97320 - int i;
97321 + unsigned int i;
97322
97323 if (size % id_size || size < id_size) {
97324 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
97325 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
97326 /* USB is special because the bcdDevice can be matched against a numeric range */
97327 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
97328 static void do_usb_entry(void *symval,
97329 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
97330 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
97331 unsigned char range_lo, unsigned char range_hi,
97332 unsigned char max, struct module *mod)
97333 {
97334 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
97335 {
97336 unsigned int devlo, devhi;
97337 unsigned char chi, clo, max;
97338 - int ndigits;
97339 + unsigned int ndigits;
97340
97341 DEF_FIELD(symval, usb_device_id, match_flags);
97342 DEF_FIELD(symval, usb_device_id, idVendor);
97343 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
97344 for (i = 0; i < count; i++) {
97345 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
97346 char acpi_id[sizeof(*id)];
97347 - int j;
97348 + unsigned int j;
97349
97350 buf_printf(&mod->dev_table_buf,
97351 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
97352 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97353
97354 for (j = 0; j < PNP_MAX_DEVICES; j++) {
97355 const char *id = (char *)(*devs)[j].id;
97356 - int i2, j2;
97357 + unsigned int i2, j2;
97358 int dup = 0;
97359
97360 if (!id[0])
97361 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97362 /* add an individual alias for every device entry */
97363 if (!dup) {
97364 char acpi_id[PNP_ID_LEN];
97365 - int k;
97366 + unsigned int k;
97367
97368 buf_printf(&mod->dev_table_buf,
97369 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
97370 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
97371 static int do_dmi_entry(const char *filename, void *symval,
97372 char *alias)
97373 {
97374 - int i, j;
97375 + unsigned int i, j;
97376 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
97377 sprintf(alias, "dmi*");
97378
97379 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
97380 index 6216434..050cf89 100644
97381 --- a/scripts/mod/modpost.c
97382 +++ b/scripts/mod/modpost.c
97383 @@ -930,6 +930,7 @@ enum mismatch {
97384 ANY_INIT_TO_ANY_EXIT,
97385 ANY_EXIT_TO_ANY_INIT,
97386 EXPORT_TO_INIT_EXIT,
97387 + DATA_TO_TEXT
97388 };
97389
97390 struct sectioncheck {
97391 @@ -1016,6 +1017,12 @@ const struct sectioncheck sectioncheck[] = {
97392 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
97393 .mismatch = EXPORT_TO_INIT_EXIT,
97394 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
97395 +},
97396 +/* Do not reference code from writable data */
97397 +{
97398 + .fromsec = { DATA_SECTIONS, NULL },
97399 + .tosec = { TEXT_SECTIONS, NULL },
97400 + .mismatch = DATA_TO_TEXT
97401 }
97402 };
97403
97404 @@ -1136,10 +1143,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
97405 continue;
97406 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
97407 continue;
97408 - if (sym->st_value == addr)
97409 - return sym;
97410 /* Find a symbol nearby - addr are maybe negative */
97411 d = sym->st_value - addr;
97412 + if (d == 0)
97413 + return sym;
97414 if (d < 0)
97415 d = addr - sym->st_value;
97416 if (d < distance) {
97417 @@ -1417,6 +1424,14 @@ static void report_sec_mismatch(const char *modname,
97418 tosym, prl_to, prl_to, tosym);
97419 free(prl_to);
97420 break;
97421 + case DATA_TO_TEXT:
97422 +#if 0
97423 + fprintf(stderr,
97424 + "The %s %s:%s references\n"
97425 + "the %s %s:%s%s\n",
97426 + from, fromsec, fromsym, to, tosec, tosym, to_p);
97427 +#endif
97428 + break;
97429 }
97430 fprintf(stderr, "\n");
97431 }
97432 @@ -1651,7 +1666,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
97433 static void check_sec_ref(struct module *mod, const char *modname,
97434 struct elf_info *elf)
97435 {
97436 - int i;
97437 + unsigned int i;
97438 Elf_Shdr *sechdrs = elf->sechdrs;
97439
97440 /* Walk through all sections */
97441 @@ -1770,7 +1785,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
97442 va_end(ap);
97443 }
97444
97445 -void buf_write(struct buffer *buf, const char *s, int len)
97446 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
97447 {
97448 if (buf->size - buf->pos < len) {
97449 buf->size += len + SZ;
97450 @@ -1989,7 +2004,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
97451 if (fstat(fileno(file), &st) < 0)
97452 goto close_write;
97453
97454 - if (st.st_size != b->pos)
97455 + if (st.st_size != (off_t)b->pos)
97456 goto close_write;
97457
97458 tmp = NOFAIL(malloc(b->pos));
97459 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
97460 index 51207e4..f7d603d 100644
97461 --- a/scripts/mod/modpost.h
97462 +++ b/scripts/mod/modpost.h
97463 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
97464
97465 struct buffer {
97466 char *p;
97467 - int pos;
97468 - int size;
97469 + unsigned int pos;
97470 + unsigned int size;
97471 };
97472
97473 void __attribute__((format(printf, 2, 3)))
97474 buf_printf(struct buffer *buf, const char *fmt, ...);
97475
97476 void
97477 -buf_write(struct buffer *buf, const char *s, int len);
97478 +buf_write(struct buffer *buf, const char *s, unsigned int len);
97479
97480 struct module {
97481 struct module *next;
97482 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
97483 index 9dfcd6d..099068e 100644
97484 --- a/scripts/mod/sumversion.c
97485 +++ b/scripts/mod/sumversion.c
97486 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
97487 goto out;
97488 }
97489
97490 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
97491 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
97492 warn("writing sum in %s failed: %s\n",
97493 filename, strerror(errno));
97494 goto out;
97495 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
97496 index 0865b3e..7235dd4 100644
97497 --- a/scripts/module-common.lds
97498 +++ b/scripts/module-common.lds
97499 @@ -6,6 +6,10 @@
97500 SECTIONS {
97501 /DISCARD/ : { *(.discard) }
97502
97503 + .rodata : {
97504 + *(.rodata) *(.rodata.*)
97505 + *(.data..read_only)
97506 + }
97507 __ksymtab : { *(SORT(___ksymtab+*)) }
97508 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
97509 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
97510 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
97511 index acb8650..b8c5f02 100644
97512 --- a/scripts/package/builddeb
97513 +++ b/scripts/package/builddeb
97514 @@ -246,6 +246,7 @@ fi
97515 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
97516 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
97517 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
97518 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
97519 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
97520 mkdir -p "$destdir"
97521 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
97522 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
97523 index 68bb4ef..2f419e1 100644
97524 --- a/scripts/pnmtologo.c
97525 +++ b/scripts/pnmtologo.c
97526 @@ -244,14 +244,14 @@ static void write_header(void)
97527 fprintf(out, " * Linux logo %s\n", logoname);
97528 fputs(" */\n\n", out);
97529 fputs("#include <linux/linux_logo.h>\n\n", out);
97530 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
97531 + fprintf(out, "static unsigned char %s_data[] = {\n",
97532 logoname);
97533 }
97534
97535 static void write_footer(void)
97536 {
97537 fputs("\n};\n\n", out);
97538 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
97539 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
97540 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
97541 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
97542 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
97543 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
97544 fputs("\n};\n\n", out);
97545
97546 /* write logo clut */
97547 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
97548 + fprintf(out, "static unsigned char %s_clut[] = {\n",
97549 logoname);
97550 write_hex_cnt = 0;
97551 for (i = 0; i < logo_clutsize; i++) {
97552 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
97553 index f5eb43d..1814de8 100644
97554 --- a/scripts/sortextable.h
97555 +++ b/scripts/sortextable.h
97556 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
97557 const char *secstrtab;
97558 const char *strtab;
97559 char *extab_image;
97560 - int extab_index = 0;
97561 - int i;
97562 - int idx;
97563 + unsigned int extab_index = 0;
97564 + unsigned int i;
97565 + unsigned int idx;
97566
97567 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
97568 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
97569 diff --git a/security/Kconfig b/security/Kconfig
97570 index e9c6ac7..031a726 100644
97571 --- a/security/Kconfig
97572 +++ b/security/Kconfig
97573 @@ -4,6 +4,960 @@
97574
97575 menu "Security options"
97576
97577 +menu "Grsecurity"
97578 +
97579 + config ARCH_TRACK_EXEC_LIMIT
97580 + bool
97581 +
97582 + config PAX_KERNEXEC_PLUGIN
97583 + bool
97584 +
97585 + config PAX_PER_CPU_PGD
97586 + bool
97587 +
97588 + config TASK_SIZE_MAX_SHIFT
97589 + int
97590 + depends on X86_64
97591 + default 47 if !PAX_PER_CPU_PGD
97592 + default 42 if PAX_PER_CPU_PGD
97593 +
97594 + config PAX_ENABLE_PAE
97595 + bool
97596 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
97597 +
97598 + config PAX_USERCOPY_SLABS
97599 + bool
97600 +
97601 +config GRKERNSEC
97602 + bool "Grsecurity"
97603 + select CRYPTO
97604 + select CRYPTO_SHA256
97605 + select PROC_FS
97606 + select STOP_MACHINE
97607 + select TTY
97608 + select DEBUG_LIST
97609 + help
97610 + If you say Y here, you will be able to configure many features
97611 + that will enhance the security of your system. It is highly
97612 + recommended that you say Y here and read through the help
97613 + for each option so that you fully understand the features and
97614 + can evaluate their usefulness for your machine.
97615 +
97616 +choice
97617 + prompt "Configuration Method"
97618 + depends on GRKERNSEC
97619 + default GRKERNSEC_CONFIG_CUSTOM
97620 + help
97621 +
97622 +config GRKERNSEC_CONFIG_AUTO
97623 + bool "Automatic"
97624 + help
97625 + If you choose this configuration method, you'll be able to answer a small
97626 + number of simple questions about how you plan to use this kernel.
97627 + The settings of grsecurity and PaX will be automatically configured for
97628 + the highest commonly-used settings within the provided constraints.
97629 +
97630 + If you require additional configuration, custom changes can still be made
97631 + from the "custom configuration" menu.
97632 +
97633 +config GRKERNSEC_CONFIG_CUSTOM
97634 + bool "Custom"
97635 + help
97636 + If you choose this configuration method, you'll be able to configure all
97637 + grsecurity and PaX settings manually. Via this method, no options are
97638 + automatically enabled.
97639 +
97640 +endchoice
97641 +
97642 +choice
97643 + prompt "Usage Type"
97644 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97645 + default GRKERNSEC_CONFIG_SERVER
97646 + help
97647 +
97648 +config GRKERNSEC_CONFIG_SERVER
97649 + bool "Server"
97650 + help
97651 + Choose this option if you plan to use this kernel on a server.
97652 +
97653 +config GRKERNSEC_CONFIG_DESKTOP
97654 + bool "Desktop"
97655 + help
97656 + Choose this option if you plan to use this kernel on a desktop.
97657 +
97658 +endchoice
97659 +
97660 +choice
97661 + prompt "Virtualization Type"
97662 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
97663 + default GRKERNSEC_CONFIG_VIRT_NONE
97664 + help
97665 +
97666 +config GRKERNSEC_CONFIG_VIRT_NONE
97667 + bool "None"
97668 + help
97669 + Choose this option if this kernel will be run on bare metal.
97670 +
97671 +config GRKERNSEC_CONFIG_VIRT_GUEST
97672 + bool "Guest"
97673 + help
97674 + Choose this option if this kernel will be run as a VM guest.
97675 +
97676 +config GRKERNSEC_CONFIG_VIRT_HOST
97677 + bool "Host"
97678 + help
97679 + Choose this option if this kernel will be run as a VM host.
97680 +
97681 +endchoice
97682 +
97683 +choice
97684 + prompt "Virtualization Hardware"
97685 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97686 + help
97687 +
97688 +config GRKERNSEC_CONFIG_VIRT_EPT
97689 + bool "EPT/RVI Processor Support"
97690 + depends on X86
97691 + help
97692 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
97693 + hardware virtualization. This allows for additional kernel hardening protections
97694 + to operate without additional performance impact.
97695 +
97696 + To see if your Intel processor supports EPT, see:
97697 + http://ark.intel.com/Products/VirtualizationTechnology
97698 + (Most Core i3/5/7 support EPT)
97699 +
97700 + To see if your AMD processor supports RVI, see:
97701 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
97702 +
97703 +config GRKERNSEC_CONFIG_VIRT_SOFT
97704 + bool "First-gen/No Hardware Virtualization"
97705 + help
97706 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
97707 + support hardware virtualization or doesn't support the EPT/RVI extensions.
97708 +
97709 +endchoice
97710 +
97711 +choice
97712 + prompt "Virtualization Software"
97713 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97714 + help
97715 +
97716 +config GRKERNSEC_CONFIG_VIRT_XEN
97717 + bool "Xen"
97718 + help
97719 + Choose this option if this kernel is running as a Xen guest or host.
97720 +
97721 +config GRKERNSEC_CONFIG_VIRT_VMWARE
97722 + bool "VMWare"
97723 + help
97724 + Choose this option if this kernel is running as a VMWare guest or host.
97725 +
97726 +config GRKERNSEC_CONFIG_VIRT_KVM
97727 + bool "KVM"
97728 + help
97729 + Choose this option if this kernel is running as a KVM guest or host.
97730 +
97731 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
97732 + bool "VirtualBox"
97733 + help
97734 + Choose this option if this kernel is running as a VirtualBox guest or host.
97735 +
97736 +endchoice
97737 +
97738 +choice
97739 + prompt "Required Priorities"
97740 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97741 + default GRKERNSEC_CONFIG_PRIORITY_PERF
97742 + help
97743 +
97744 +config GRKERNSEC_CONFIG_PRIORITY_PERF
97745 + bool "Performance"
97746 + help
97747 + Choose this option if performance is of highest priority for this deployment
97748 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
97749 + clearing of structures intended for userland, and freed memory sanitizing will
97750 + be disabled.
97751 +
97752 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
97753 + bool "Security"
97754 + help
97755 + Choose this option if security is of highest priority for this deployment of
97756 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
97757 + for userland, and freed memory sanitizing will be enabled for this kernel.
97758 + In a worst-case scenario, these features can introduce a 20% performance hit
97759 + (UDEREF on x64 contributing half of this hit).
97760 +
97761 +endchoice
97762 +
97763 +menu "Default Special Groups"
97764 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97765 +
97766 +config GRKERNSEC_PROC_GID
97767 + int "GID exempted from /proc restrictions"
97768 + default 1001
97769 + help
97770 + Setting this GID determines which group will be exempted from
97771 + grsecurity's /proc restrictions, allowing users of the specified
97772 + group to view network statistics and the existence of other users'
97773 + processes on the system. This GID may also be chosen at boot time
97774 + via "grsec_proc_gid=" on the kernel commandline.
97775 +
97776 +config GRKERNSEC_TPE_UNTRUSTED_GID
97777 + int "GID for TPE-untrusted users"
97778 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
97779 + default 1005
97780 + help
97781 + Setting this GID determines which group untrusted users should
97782 + be added to. These users will be placed under grsecurity's Trusted Path
97783 + Execution mechanism, preventing them from executing their own binaries.
97784 + The users will only be able to execute binaries in directories owned and
97785 + writable only by the root user. If the sysctl option is enabled, a sysctl
97786 + option with name "tpe_gid" is created.
97787 +
97788 +config GRKERNSEC_TPE_TRUSTED_GID
97789 + int "GID for TPE-trusted users"
97790 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
97791 + default 1005
97792 + help
97793 + Setting this GID determines what group TPE restrictions will be
97794 + *disabled* for. If the sysctl option is enabled, a sysctl option
97795 + with name "tpe_gid" is created.
97796 +
97797 +config GRKERNSEC_SYMLINKOWN_GID
97798 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
97799 + depends on GRKERNSEC_CONFIG_SERVER
97800 + default 1006
97801 + help
97802 + Setting this GID determines what group kernel-enforced
97803 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
97804 + is enabled, a sysctl option with name "symlinkown_gid" is created.
97805 +
97806 +
97807 +endmenu
97808 +
97809 +menu "Customize Configuration"
97810 +depends on GRKERNSEC
97811 +
97812 +menu "PaX"
97813 +
97814 +config PAX
97815 + bool "Enable various PaX features"
97816 + default y if GRKERNSEC_CONFIG_AUTO
97817 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
97818 + help
97819 + This allows you to enable various PaX features. PaX adds
97820 + intrusion prevention mechanisms to the kernel that reduce
97821 + the risks posed by exploitable memory corruption bugs.
97822 +
97823 +menu "PaX Control"
97824 + depends on PAX
97825 +
97826 +config PAX_SOFTMODE
97827 + bool 'Support soft mode'
97828 + help
97829 + Enabling this option will allow you to run PaX in soft mode, that
97830 + is, PaX features will not be enforced by default, only on executables
97831 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
97832 + support as they are the only way to mark executables for soft mode use.
97833 +
97834 + Soft mode can be activated by using the "pax_softmode=1" kernel command
97835 + line option on boot. Furthermore you can control various PaX features
97836 + at runtime via the entries in /proc/sys/kernel/pax.
97837 +
97838 +config PAX_EI_PAX
97839 + bool 'Use legacy ELF header marking'
97840 + default y if GRKERNSEC_CONFIG_AUTO
97841 + help
97842 + Enabling this option will allow you to control PaX features on
97843 + a per executable basis via the 'chpax' utility available at
97844 + http://pax.grsecurity.net/. The control flags will be read from
97845 + an otherwise reserved part of the ELF header. This marking has
97846 + numerous drawbacks (no support for soft-mode, toolchain does not
97847 + know about the non-standard use of the ELF header) therefore it
97848 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
97849 + support.
97850 +
97851 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
97852 + support as well, they will override the legacy EI_PAX marks.
97853 +
97854 + If you enable none of the marking options then all applications
97855 + will run with PaX enabled on them by default.
97856 +
97857 +config PAX_PT_PAX_FLAGS
97858 + bool 'Use ELF program header marking'
97859 + default y if GRKERNSEC_CONFIG_AUTO
97860 + help
97861 + Enabling this option will allow you to control PaX features on
97862 + a per executable basis via the 'paxctl' utility available at
97863 + http://pax.grsecurity.net/. The control flags will be read from
97864 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
97865 + has the benefits of supporting both soft mode and being fully
97866 + integrated into the toolchain (the binutils patch is available
97867 + from http://pax.grsecurity.net).
97868 +
97869 + Note that if you enable the legacy EI_PAX marking support as well,
97870 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
97871 +
97872 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97873 + must make sure that the marks are the same if a binary has both marks.
97874 +
97875 + If you enable none of the marking options then all applications
97876 + will run with PaX enabled on them by default.
97877 +
97878 +config PAX_XATTR_PAX_FLAGS
97879 + bool 'Use filesystem extended attributes marking'
97880 + default y if GRKERNSEC_CONFIG_AUTO
97881 + select CIFS_XATTR if CIFS
97882 + select EXT2_FS_XATTR if EXT2_FS
97883 + select EXT3_FS_XATTR if EXT3_FS
97884 + select EXT4_FS_XATTR if EXT4_FS
97885 + select JFFS2_FS_XATTR if JFFS2_FS
97886 + select REISERFS_FS_XATTR if REISERFS_FS
97887 + select SQUASHFS_XATTR if SQUASHFS
97888 + select TMPFS_XATTR if TMPFS
97889 + select UBIFS_FS_XATTR if UBIFS_FS
97890 + help
97891 + Enabling this option will allow you to control PaX features on
97892 + a per executable basis via the 'setfattr' utility. The control
97893 + flags will be read from the user.pax.flags extended attribute of
97894 + the file. This marking has the benefit of supporting binary-only
97895 + applications that self-check themselves (e.g., skype) and would
97896 + not tolerate chpax/paxctl changes. The main drawback is that
97897 + extended attributes are not supported by some filesystems (e.g.,
97898 + isofs, udf, vfat) so copying files through such filesystems will
97899 + lose the extended attributes and these PaX markings.
97900 +
97901 + Note that if you enable the legacy EI_PAX marking support as well,
97902 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
97903 +
97904 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97905 + must make sure that the marks are the same if a binary has both marks.
97906 +
97907 + If you enable none of the marking options then all applications
97908 + will run with PaX enabled on them by default.
97909 +
97910 +choice
97911 + prompt 'MAC system integration'
97912 + default PAX_HAVE_ACL_FLAGS
97913 + help
97914 + Mandatory Access Control systems have the option of controlling
97915 + PaX flags on a per executable basis, choose the method supported
97916 + by your particular system.
97917 +
97918 + - "none": if your MAC system does not interact with PaX,
97919 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
97920 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
97921 +
97922 + NOTE: this option is for developers/integrators only.
97923 +
97924 + config PAX_NO_ACL_FLAGS
97925 + bool 'none'
97926 +
97927 + config PAX_HAVE_ACL_FLAGS
97928 + bool 'direct'
97929 +
97930 + config PAX_HOOK_ACL_FLAGS
97931 + bool 'hook'
97932 +endchoice
97933 +
97934 +endmenu
97935 +
97936 +menu "Non-executable pages"
97937 + depends on PAX
97938 +
97939 +config PAX_NOEXEC
97940 + bool "Enforce non-executable pages"
97941 + default y if GRKERNSEC_CONFIG_AUTO
97942 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
97943 + help
97944 + By design some architectures do not allow for protecting memory
97945 + pages against execution or even if they do, Linux does not make
97946 + use of this feature. In practice this means that if a page is
97947 + readable (such as the stack or heap) it is also executable.
97948 +
97949 + There is a well known exploit technique that makes use of this
97950 + fact and a common programming mistake where an attacker can
97951 + introduce code of his choice somewhere in the attacked program's
97952 + memory (typically the stack or the heap) and then execute it.
97953 +
97954 + If the attacked program was running with different (typically
97955 + higher) privileges than that of the attacker, then he can elevate
97956 + his own privilege level (e.g. get a root shell, write to files for
97957 + which he does not have write access to, etc).
97958 +
97959 + Enabling this option will let you choose from various features
97960 + that prevent the injection and execution of 'foreign' code in
97961 + a program.
97962 +
97963 + This will also break programs that rely on the old behaviour and
97964 + expect that dynamically allocated memory via the malloc() family
97965 + of functions is executable (which it is not). Notable examples
97966 + are the XFree86 4.x server, the java runtime and wine.
97967 +
97968 +config PAX_PAGEEXEC
97969 + bool "Paging based non-executable pages"
97970 + default y if GRKERNSEC_CONFIG_AUTO
97971 + 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)
97972 + select ARCH_TRACK_EXEC_LIMIT if X86_32
97973 + help
97974 + This implementation is based on the paging feature of the CPU.
97975 + On i386 without hardware non-executable bit support there is a
97976 + variable but usually low performance impact, however on Intel's
97977 + P4 core based CPUs it is very high so you should not enable this
97978 + for kernels meant to be used on such CPUs.
97979 +
97980 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
97981 + with hardware non-executable bit support there is no performance
97982 + impact, on ppc the impact is negligible.
97983 +
97984 + Note that several architectures require various emulations due to
97985 + badly designed userland ABIs, this will cause a performance impact
97986 + but will disappear as soon as userland is fixed. For example, ppc
97987 + userland MUST have been built with secure-plt by a recent toolchain.
97988 +
97989 +config PAX_SEGMEXEC
97990 + bool "Segmentation based non-executable pages"
97991 + default y if GRKERNSEC_CONFIG_AUTO
97992 + depends on PAX_NOEXEC && X86_32
97993 + help
97994 + This implementation is based on the segmentation feature of the
97995 + CPU and has a very small performance impact, however applications
97996 + will be limited to a 1.5 GB address space instead of the normal
97997 + 3 GB.
97998 +
97999 +config PAX_EMUTRAMP
98000 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
98001 + default y if PARISC
98002 + help
98003 + There are some programs and libraries that for one reason or
98004 + another attempt to execute special small code snippets from
98005 + non-executable memory pages. Most notable examples are the
98006 + signal handler return code generated by the kernel itself and
98007 + the GCC trampolines.
98008 +
98009 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
98010 + such programs will no longer work under your kernel.
98011 +
98012 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
98013 + utilities to enable trampoline emulation for the affected programs
98014 + yet still have the protection provided by the non-executable pages.
98015 +
98016 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
98017 + your system will not even boot.
98018 +
98019 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
98020 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
98021 + for the affected files.
98022 +
98023 + NOTE: enabling this feature *may* open up a loophole in the
98024 + protection provided by non-executable pages that an attacker
98025 + could abuse. Therefore the best solution is to not have any
98026 + files on your system that would require this option. This can
98027 + be achieved by not using libc5 (which relies on the kernel
98028 + signal handler return code) and not using or rewriting programs
98029 + that make use of the nested function implementation of GCC.
98030 + Skilled users can just fix GCC itself so that it implements
98031 + nested function calls in a way that does not interfere with PaX.
98032 +
98033 +config PAX_EMUSIGRT
98034 + bool "Automatically emulate sigreturn trampolines"
98035 + depends on PAX_EMUTRAMP && PARISC
98036 + default y
98037 + help
98038 + Enabling this option will have the kernel automatically detect
98039 + and emulate signal return trampolines executing on the stack
98040 + that would otherwise lead to task termination.
98041 +
98042 + This solution is intended as a temporary one for users with
98043 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
98044 + Modula-3 runtime, etc) or executables linked to such, basically
98045 + everything that does not specify its own SA_RESTORER function in
98046 + normal executable memory like glibc 2.1+ does.
98047 +
98048 + On parisc you MUST enable this option, otherwise your system will
98049 + not even boot.
98050 +
98051 + NOTE: this feature cannot be disabled on a per executable basis
98052 + and since it *does* open up a loophole in the protection provided
98053 + by non-executable pages, the best solution is to not have any
98054 + files on your system that would require this option.
98055 +
98056 +config PAX_MPROTECT
98057 + bool "Restrict mprotect()"
98058 + default y if GRKERNSEC_CONFIG_AUTO
98059 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
98060 + help
98061 + Enabling this option will prevent programs from
98062 + - changing the executable status of memory pages that were
98063 + not originally created as executable,
98064 + - making read-only executable pages writable again,
98065 + - creating executable pages from anonymous memory,
98066 + - making read-only-after-relocations (RELRO) data pages writable again.
98067 +
98068 + You should say Y here to complete the protection provided by
98069 + the enforcement of non-executable pages.
98070 +
98071 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98072 + this feature on a per file basis.
98073 +
98074 +config PAX_MPROTECT_COMPAT
98075 + bool "Use legacy/compat protection demoting (read help)"
98076 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98077 + depends on PAX_MPROTECT
98078 + help
98079 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
98080 + by sending the proper error code to the application. For some broken
98081 + userland, this can cause problems with Python or other applications. The
98082 + current implementation however allows for applications like clamav to
98083 + detect if JIT compilation/execution is allowed and to fall back gracefully
98084 + to an interpreter-based mode if it does not. While we encourage everyone
98085 + to use the current implementation as-is and push upstream to fix broken
98086 + userland (note that the RWX logging option can assist with this), in some
98087 + environments this may not be possible. Having to disable MPROTECT
98088 + completely on certain binaries reduces the security benefit of PaX,
98089 + so this option is provided for those environments to revert to the old
98090 + behavior.
98091 +
98092 +config PAX_ELFRELOCS
98093 + bool "Allow ELF text relocations (read help)"
98094 + depends on PAX_MPROTECT
98095 + default n
98096 + help
98097 + Non-executable pages and mprotect() restrictions are effective
98098 + in preventing the introduction of new executable code into an
98099 + attacked task's address space. There remain only two venues
98100 + for this kind of attack: if the attacker can execute already
98101 + existing code in the attacked task then he can either have it
98102 + create and mmap() a file containing his code or have it mmap()
98103 + an already existing ELF library that does not have position
98104 + independent code in it and use mprotect() on it to make it
98105 + writable and copy his code there. While protecting against
98106 + the former approach is beyond PaX, the latter can be prevented
98107 + by having only PIC ELF libraries on one's system (which do not
98108 + need to relocate their code). If you are sure this is your case,
98109 + as is the case with all modern Linux distributions, then leave
98110 + this option disabled. You should say 'n' here.
98111 +
98112 +config PAX_ETEXECRELOCS
98113 + bool "Allow ELF ET_EXEC text relocations"
98114 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
98115 + select PAX_ELFRELOCS
98116 + default y
98117 + help
98118 + On some architectures there are incorrectly created applications
98119 + that require text relocations and would not work without enabling
98120 + this option. If you are an alpha, ia64 or parisc user, you should
98121 + enable this option and disable it once you have made sure that
98122 + none of your applications need it.
98123 +
98124 +config PAX_EMUPLT
98125 + bool "Automatically emulate ELF PLT"
98126 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
98127 + default y
98128 + help
98129 + Enabling this option will have the kernel automatically detect
98130 + and emulate the Procedure Linkage Table entries in ELF files.
98131 + On some architectures such entries are in writable memory, and
98132 + become non-executable leading to task termination. Therefore
98133 + it is mandatory that you enable this option on alpha, parisc,
98134 + sparc and sparc64, otherwise your system would not even boot.
98135 +
98136 + NOTE: this feature *does* open up a loophole in the protection
98137 + provided by the non-executable pages, therefore the proper
98138 + solution is to modify the toolchain to produce a PLT that does
98139 + not need to be writable.
98140 +
98141 +config PAX_DLRESOLVE
98142 + bool 'Emulate old glibc resolver stub'
98143 + depends on PAX_EMUPLT && SPARC
98144 + default n
98145 + help
98146 + This option is needed if userland has an old glibc (before 2.4)
98147 + that puts a 'save' instruction into the runtime generated resolver
98148 + stub that needs special emulation.
98149 +
98150 +config PAX_KERNEXEC
98151 + bool "Enforce non-executable kernel pages"
98152 + 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))
98153 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
98154 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
98155 + select PAX_KERNEXEC_PLUGIN if X86_64
98156 + help
98157 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
98158 + that is, enabling this option will make it harder to inject
98159 + and execute 'foreign' code in kernel memory itself.
98160 +
98161 +choice
98162 + prompt "Return Address Instrumentation Method"
98163 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
98164 + depends on PAX_KERNEXEC_PLUGIN
98165 + help
98166 + Select the method used to instrument function pointer dereferences.
98167 + Note that binary modules cannot be instrumented by this approach.
98168 +
98169 + Note that the implementation requires a gcc with plugin support,
98170 + i.e., gcc 4.5 or newer. You may need to install the supporting
98171 + headers explicitly in addition to the normal gcc package.
98172 +
98173 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
98174 + bool "bts"
98175 + help
98176 + This method is compatible with binary only modules but has
98177 + a higher runtime overhead.
98178 +
98179 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
98180 + bool "or"
98181 + depends on !PARAVIRT
98182 + help
98183 + This method is incompatible with binary only modules but has
98184 + a lower runtime overhead.
98185 +endchoice
98186 +
98187 +config PAX_KERNEXEC_PLUGIN_METHOD
98188 + string
98189 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
98190 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
98191 + default ""
98192 +
98193 +config PAX_KERNEXEC_MODULE_TEXT
98194 + int "Minimum amount of memory reserved for module code"
98195 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
98196 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98197 + depends on PAX_KERNEXEC && X86_32
98198 + help
98199 + Due to implementation details the kernel must reserve a fixed
98200 + amount of memory for runtime allocated code (such as modules)
98201 + at compile time that cannot be changed at runtime. Here you
98202 + can specify the minimum amount in MB that will be reserved.
98203 + Due to the same implementation details this size will always
98204 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
98205 + the actually available memory for runtime allocated code will
98206 + usually be more than this minimum.
98207 +
98208 + The default 4 MB should be enough for most users but if you have
98209 + an excessive number of modules (e.g., most distribution configs
98210 + compile many drivers as modules) or use huge modules such as
98211 + nvidia's kernel driver, you will need to adjust this amount.
98212 + A good rule of thumb is to look at your currently loaded kernel
98213 + modules and add up their sizes.
98214 +
98215 +endmenu
98216 +
98217 +menu "Address Space Layout Randomization"
98218 + depends on PAX
98219 +
98220 +config PAX_ASLR
98221 + bool "Address Space Layout Randomization"
98222 + default y if GRKERNSEC_CONFIG_AUTO
98223 + help
98224 + Many if not most exploit techniques rely on the knowledge of
98225 + certain addresses in the attacked program. The following options
98226 + will allow the kernel to apply a certain amount of randomization
98227 + to specific parts of the program thereby forcing an attacker to
98228 + guess them in most cases. Any failed guess will most likely crash
98229 + the attacked program which allows the kernel to detect such attempts
98230 + and react on them. PaX itself provides no reaction mechanisms,
98231 + instead it is strongly encouraged that you make use of Nergal's
98232 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
98233 + (http://www.grsecurity.net/) built-in crash detection features or
98234 + develop one yourself.
98235 +
98236 + By saying Y here you can choose to randomize the following areas:
98237 + - top of the task's kernel stack
98238 + - top of the task's userland stack
98239 + - base address for mmap() requests that do not specify one
98240 + (this includes all libraries)
98241 + - base address of the main executable
98242 +
98243 + It is strongly recommended to say Y here as address space layout
98244 + randomization has negligible impact on performance yet it provides
98245 + a very effective protection.
98246 +
98247 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98248 + this feature on a per file basis.
98249 +
98250 +config PAX_RANDKSTACK
98251 + bool "Randomize kernel stack base"
98252 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
98253 + depends on X86_TSC && X86
98254 + help
98255 + By saying Y here the kernel will randomize every task's kernel
98256 + stack on every system call. This will not only force an attacker
98257 + to guess it but also prevent him from making use of possible
98258 + leaked information about it.
98259 +
98260 + Since the kernel stack is a rather scarce resource, randomization
98261 + may cause unexpected stack overflows, therefore you should very
98262 + carefully test your system. Note that once enabled in the kernel
98263 + configuration, this feature cannot be disabled on a per file basis.
98264 +
98265 +config PAX_RANDUSTACK
98266 + bool "Randomize user stack base"
98267 + default y if GRKERNSEC_CONFIG_AUTO
98268 + depends on PAX_ASLR
98269 + help
98270 + By saying Y here the kernel will randomize every task's userland
98271 + stack. The randomization is done in two steps where the second
98272 + one may apply a big amount of shift to the top of the stack and
98273 + cause problems for programs that want to use lots of memory (more
98274 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
98275 + For this reason the second step can be controlled by 'chpax' or
98276 + 'paxctl' on a per file basis.
98277 +
98278 +config PAX_RANDMMAP
98279 + bool "Randomize mmap() base"
98280 + default y if GRKERNSEC_CONFIG_AUTO
98281 + depends on PAX_ASLR
98282 + help
98283 + By saying Y here the kernel will use a randomized base address for
98284 + mmap() requests that do not specify one themselves. As a result
98285 + all dynamically loaded libraries will appear at random addresses
98286 + and therefore be harder to exploit by a technique where an attacker
98287 + attempts to execute library code for his purposes (e.g. spawn a
98288 + shell from an exploited program that is running at an elevated
98289 + privilege level).
98290 +
98291 + Furthermore, if a program is relinked as a dynamic ELF file, its
98292 + base address will be randomized as well, completing the full
98293 + randomization of the address space layout. Attacking such programs
98294 + becomes a guess game. You can find an example of doing this at
98295 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
98296 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
98297 +
98298 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
98299 + feature on a per file basis.
98300 +
98301 +endmenu
98302 +
98303 +menu "Miscellaneous hardening features"
98304 +
98305 +config PAX_MEMORY_SANITIZE
98306 + bool "Sanitize all freed memory"
98307 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98308 + depends on !HIBERNATION
98309 + help
98310 + By saying Y here the kernel will erase memory pages and slab objects
98311 + as soon as they are freed. This in turn reduces the lifetime of data
98312 + stored in them, making it less likely that sensitive information such
98313 + as passwords, cryptographic secrets, etc stay in memory for too long.
98314 +
98315 + This is especially useful for programs whose runtime is short, long
98316 + lived processes and the kernel itself benefit from this as long as
98317 + they ensure timely freeing of memory that may hold sensitive
98318 + information.
98319 +
98320 + A nice side effect of the sanitization of slab objects is the
98321 + reduction of possible info leaks caused by padding bytes within the
98322 + leaky structures. Use-after-free bugs for structures containing
98323 + pointers can also be detected as dereferencing the sanitized pointer
98324 + will generate an access violation.
98325 +
98326 + The tradeoff is performance impact, on a single CPU system kernel
98327 + compilation sees a 3% slowdown, other systems and workloads may vary
98328 + and you are advised to test this feature on your expected workload
98329 + before deploying it.
98330 +
98331 + To reduce the performance penalty by sanitizing pages only, albeit
98332 + limiting the effectiveness of this feature at the same time, slab
98333 + sanitization can be disabled with the kernel commandline parameter
98334 + "pax_sanitize_slab=0".
98335 +
98336 + Note that this feature does not protect data stored in live pages,
98337 + e.g., process memory swapped to disk may stay there for a long time.
98338 +
98339 +config PAX_MEMORY_STACKLEAK
98340 + bool "Sanitize kernel stack"
98341 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98342 + depends on X86
98343 + help
98344 + By saying Y here the kernel will erase the kernel stack before it
98345 + returns from a system call. This in turn reduces the information
98346 + that a kernel stack leak bug can reveal.
98347 +
98348 + Note that such a bug can still leak information that was put on
98349 + the stack by the current system call (the one eventually triggering
98350 + the bug) but traces of earlier system calls on the kernel stack
98351 + cannot leak anymore.
98352 +
98353 + The tradeoff is performance impact: on a single CPU system kernel
98354 + compilation sees a 1% slowdown, other systems and workloads may vary
98355 + and you are advised to test this feature on your expected workload
98356 + before deploying it.
98357 +
98358 + Note that the full feature requires a gcc with plugin support,
98359 + i.e., gcc 4.5 or newer. You may need to install the supporting
98360 + headers explicitly in addition to the normal gcc package. Using
98361 + older gcc versions means that functions with large enough stack
98362 + frames may leave uninitialized memory behind that may be exposed
98363 + to a later syscall leaking the stack.
98364 +
98365 +config PAX_MEMORY_STRUCTLEAK
98366 + bool "Forcibly initialize local variables copied to userland"
98367 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98368 + help
98369 + By saying Y here the kernel will zero initialize some local
98370 + variables that are going to be copied to userland. This in
98371 + turn prevents unintended information leakage from the kernel
98372 + stack should later code forget to explicitly set all parts of
98373 + the copied variable.
98374 +
98375 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
98376 + at a much smaller coverage.
98377 +
98378 + Note that the implementation requires a gcc with plugin support,
98379 + i.e., gcc 4.5 or newer. You may need to install the supporting
98380 + headers explicitly in addition to the normal gcc package.
98381 +
98382 +config PAX_MEMORY_UDEREF
98383 + bool "Prevent invalid userland pointer dereference"
98384 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
98385 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
98386 + select PAX_PER_CPU_PGD if X86_64
98387 + help
98388 + By saying Y here the kernel will be prevented from dereferencing
98389 + userland pointers in contexts where the kernel expects only kernel
98390 + pointers. This is both a useful runtime debugging feature and a
98391 + security measure that prevents exploiting a class of kernel bugs.
98392 +
98393 + The tradeoff is that some virtualization solutions may experience
98394 + a huge slowdown and therefore you should not enable this feature
98395 + for kernels meant to run in such environments. Whether a given VM
98396 + solution is affected or not is best determined by simply trying it
98397 + out, the performance impact will be obvious right on boot as this
98398 + mechanism engages from very early on. A good rule of thumb is that
98399 + VMs running on CPUs without hardware virtualization support (i.e.,
98400 + the majority of IA-32 CPUs) will likely experience the slowdown.
98401 +
98402 + On X86_64 the kernel will make use of PCID support when available
98403 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
98404 + or performance impact. Pass pax_weakuderef on the kernel command
98405 + line to choose the latter.
98406 +
98407 +config PAX_REFCOUNT
98408 + bool "Prevent various kernel object reference counter overflows"
98409 + default y if GRKERNSEC_CONFIG_AUTO
98410 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
98411 + help
98412 + By saying Y here the kernel will detect and prevent overflowing
98413 + various (but not all) kinds of object reference counters. Such
98414 + overflows can normally occur due to bugs only and are often, if
98415 + not always, exploitable.
98416 +
98417 + The tradeoff is that data structures protected by an overflowed
98418 + refcount will never be freed and therefore will leak memory. Note
98419 + that this leak also happens even without this protection but in
98420 + that case the overflow can eventually trigger the freeing of the
98421 + data structure while it is still being used elsewhere, resulting
98422 + in the exploitable situation that this feature prevents.
98423 +
98424 + Since this has a negligible performance impact, you should enable
98425 + this feature.
98426 +
98427 +config PAX_CONSTIFY_PLUGIN
98428 + bool "Automatically constify eligible structures"
98429 + default y
98430 + depends on !UML && PAX_KERNEXEC
98431 + help
98432 + By saying Y here the compiler will automatically constify a class
98433 + of types that contain only function pointers. This reduces the
98434 + kernel's attack surface and also produces a better memory layout.
98435 +
98436 + Note that the implementation requires a gcc with plugin support,
98437 + i.e., gcc 4.5 or newer. You may need to install the supporting
98438 + headers explicitly in addition to the normal gcc package.
98439 +
98440 + Note that if some code really has to modify constified variables
98441 + then the source code will have to be patched to allow it. Examples
98442 + can be found in PaX itself (the no_const attribute) and for some
98443 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
98444 +
98445 +config PAX_USERCOPY
98446 + bool "Harden heap object copies between kernel and userland"
98447 + default y if GRKERNSEC_CONFIG_AUTO
98448 + depends on ARM || IA64 || PPC || SPARC || X86
98449 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
98450 + select PAX_USERCOPY_SLABS
98451 + help
98452 + By saying Y here the kernel will enforce the size of heap objects
98453 + when they are copied in either direction between the kernel and
98454 + userland, even if only a part of the heap object is copied.
98455 +
98456 + Specifically, this checking prevents information leaking from the
98457 + kernel heap during kernel to userland copies (if the kernel heap
98458 + object is otherwise fully initialized) and prevents kernel heap
98459 + overflows during userland to kernel copies.
98460 +
98461 + Note that the current implementation provides the strictest bounds
98462 + checks for the SLUB allocator.
98463 +
98464 + Enabling this option also enables per-slab cache protection against
98465 + data in a given cache being copied into/out of via userland
98466 + accessors. Though the whitelist of regions will be reduced over
98467 + time, it notably protects important data structures like task structs.
98468 +
98469 + If frame pointers are enabled on x86, this option will also restrict
98470 + copies into and out of the kernel stack to local variables within a
98471 + single frame.
98472 +
98473 + Since this has a negligible performance impact, you should enable
98474 + this feature.
98475 +
98476 +config PAX_USERCOPY_DEBUG
98477 + bool
98478 + depends on X86 && PAX_USERCOPY
98479 + default n
98480 +
98481 +config PAX_SIZE_OVERFLOW
98482 + bool "Prevent various integer overflows in function size parameters"
98483 + default y if GRKERNSEC_CONFIG_AUTO
98484 + depends on X86
98485 + help
98486 + By saying Y here the kernel recomputes expressions of function
98487 + arguments marked by a size_overflow attribute with double integer
98488 + precision (DImode/TImode for 32/64 bit integer types).
98489 +
98490 + The recomputed argument is checked against TYPE_MAX and an event
98491 + is logged on overflow and the triggering process is killed.
98492 +
98493 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
98494 +
98495 + Note that the implementation requires a gcc with plugin support,
98496 + i.e., gcc 4.5 or newer. You may need to install the supporting
98497 + headers explicitly in addition to the normal gcc package.
98498 +
98499 +config PAX_LATENT_ENTROPY
98500 + bool "Generate some entropy during boot and runtime"
98501 + default y if GRKERNSEC_CONFIG_AUTO
98502 + help
98503 + By saying Y here the kernel will instrument some kernel code to
98504 + extract some entropy from both original and artificially created
98505 + program state. This will help especially embedded systems where
98506 + there is little 'natural' source of entropy normally. The cost
98507 + is some slowdown of the boot process and fork and irq processing.
98508 +
98509 + When pax_extra_latent_entropy is passed on the kernel command line,
98510 + entropy will be extracted from up to the first 4GB of RAM while the
98511 + runtime memory allocator is being initialized. This costs even more
98512 + slowdown of the boot process.
98513 +
98514 + Note that the implementation requires a gcc with plugin support,
98515 + i.e., gcc 4.5 or newer. You may need to install the supporting
98516 + headers explicitly in addition to the normal gcc package.
98517 +
98518 + Note that entropy extracted this way is not cryptographically
98519 + secure!
98520 +
98521 +endmenu
98522 +
98523 +endmenu
98524 +
98525 +source grsecurity/Kconfig
98526 +
98527 +endmenu
98528 +
98529 +endmenu
98530 +
98531 source security/keys/Kconfig
98532
98533 config SECURITY_DMESG_RESTRICT
98534 @@ -103,7 +1057,7 @@ config INTEL_TXT
98535 config LSM_MMAP_MIN_ADDR
98536 int "Low address space for LSM to protect from user allocation"
98537 depends on SECURITY && SECURITY_SELINUX
98538 - default 32768 if ARM
98539 + default 32768 if ALPHA || ARM || PARISC || SPARC32
98540 default 65536
98541 help
98542 This is the portion of low virtual memory which should be protected
98543 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
98544 index 9b9013b..51ebf96 100644
98545 --- a/security/apparmor/Kconfig
98546 +++ b/security/apparmor/Kconfig
98547 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
98548 boot.
98549
98550 If you are unsure how to answer this question, answer 1.
98551 +
98552 +config SECURITY_APPARMOR_COMPAT_24
98553 + bool "Enable AppArmor 2.4 compatability"
98554 + depends on SECURITY_APPARMOR
98555 + default y
98556 + help
98557 + This option enables compatability with AppArmor 2.4. It is
98558 + recommended if compatability with older versions of AppArmor
98559 + is desired.
98560 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
98561 index 16c15ec..42b7c9f 100644
98562 --- a/security/apparmor/apparmorfs.c
98563 +++ b/security/apparmor/apparmorfs.c
98564 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
98565 .release = single_release,
98566 };
98567
98568 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98569 +/**
98570 + * __next_namespace - find the next namespace to list
98571 + * @root: root namespace to stop search at (NOT NULL)
98572 + * @ns: current ns position (NOT NULL)
98573 + *
98574 + * Find the next namespace from @ns under @root and handle all locking needed
98575 + * while switching current namespace.
98576 + *
98577 + * Returns: next namespace or NULL if at last namespace under @root
98578 + * NOTE: will not unlock root->lock
98579 + */
98580 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
98581 + struct aa_namespace *ns)
98582 +{
98583 + struct aa_namespace *parent;
98584 +
98585 + /* is next namespace a child */
98586 + if (!list_empty(&ns->sub_ns)) {
98587 + struct aa_namespace *next;
98588 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
98589 + read_lock(&next->lock);
98590 + return next;
98591 + }
98592 +
98593 + /* check if the next ns is a sibling, parent, gp, .. */
98594 + parent = ns->parent;
98595 + while (parent) {
98596 + read_unlock(&ns->lock);
98597 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
98598 + read_lock(&ns->lock);
98599 + return ns;
98600 + }
98601 + if (parent == root)
98602 + return NULL;
98603 + ns = parent;
98604 + parent = parent->parent;
98605 + }
98606 +
98607 + return NULL;
98608 +}
98609 +
98610 +/**
98611 + * __first_profile - find the first profile in a namespace
98612 + * @root: namespace that is root of profiles being displayed (NOT NULL)
98613 + * @ns: namespace to start in (NOT NULL)
98614 + *
98615 + * Returns: unrefcounted profile or NULL if no profile
98616 + */
98617 +static struct aa_profile *__first_profile(struct aa_namespace *root,
98618 + struct aa_namespace *ns)
98619 +{
98620 + for ( ; ns; ns = __next_namespace(root, ns)) {
98621 + if (!list_empty(&ns->base.profiles))
98622 + return list_first_entry(&ns->base.profiles,
98623 + struct aa_profile, base.list);
98624 + }
98625 + return NULL;
98626 +}
98627 +
98628 +/**
98629 + * __next_profile - step to the next profile in a profile tree
98630 + * @profile: current profile in tree (NOT NULL)
98631 + *
98632 + * Perform a depth first taversal on the profile tree in a namespace
98633 + *
98634 + * Returns: next profile or NULL if done
98635 + * Requires: profile->ns.lock to be held
98636 + */
98637 +static struct aa_profile *__next_profile(struct aa_profile *p)
98638 +{
98639 + struct aa_profile *parent;
98640 + struct aa_namespace *ns = p->ns;
98641 +
98642 + /* is next profile a child */
98643 + if (!list_empty(&p->base.profiles))
98644 + return list_first_entry(&p->base.profiles, typeof(*p),
98645 + base.list);
98646 +
98647 + /* is next profile a sibling, parent sibling, gp, subling, .. */
98648 + parent = p->parent;
98649 + while (parent) {
98650 + list_for_each_entry_continue(p, &parent->base.profiles,
98651 + base.list)
98652 + return p;
98653 + p = parent;
98654 + parent = parent->parent;
98655 + }
98656 +
98657 + /* is next another profile in the namespace */
98658 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
98659 + return p;
98660 +
98661 + return NULL;
98662 +}
98663 +
98664 +/**
98665 + * next_profile - step to the next profile in where ever it may be
98666 + * @root: root namespace (NOT NULL)
98667 + * @profile: current profile (NOT NULL)
98668 + *
98669 + * Returns: next profile or NULL if there isn't one
98670 + */
98671 +static struct aa_profile *next_profile(struct aa_namespace *root,
98672 + struct aa_profile *profile)
98673 +{
98674 + struct aa_profile *next = __next_profile(profile);
98675 + if (next)
98676 + return next;
98677 +
98678 + /* finished all profiles in namespace move to next namespace */
98679 + return __first_profile(root, __next_namespace(root, profile->ns));
98680 +}
98681 +
98682 +/**
98683 + * p_start - start a depth first traversal of profile tree
98684 + * @f: seq_file to fill
98685 + * @pos: current position
98686 + *
98687 + * Returns: first profile under current namespace or NULL if none found
98688 + *
98689 + * acquires first ns->lock
98690 + */
98691 +static void *p_start(struct seq_file *f, loff_t *pos)
98692 + __acquires(root->lock)
98693 +{
98694 + struct aa_profile *profile = NULL;
98695 + struct aa_namespace *root = aa_current_profile()->ns;
98696 + loff_t l = *pos;
98697 + f->private = aa_get_namespace(root);
98698 +
98699 +
98700 + /* find the first profile */
98701 + read_lock(&root->lock);
98702 + profile = __first_profile(root, root);
98703 +
98704 + /* skip to position */
98705 + for (; profile && l > 0; l--)
98706 + profile = next_profile(root, profile);
98707 +
98708 + return profile;
98709 +}
98710 +
98711 +/**
98712 + * p_next - read the next profile entry
98713 + * @f: seq_file to fill
98714 + * @p: profile previously returned
98715 + * @pos: current position
98716 + *
98717 + * Returns: next profile after @p or NULL if none
98718 + *
98719 + * may acquire/release locks in namespace tree as necessary
98720 + */
98721 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
98722 +{
98723 + struct aa_profile *profile = p;
98724 + struct aa_namespace *root = f->private;
98725 + (*pos)++;
98726 +
98727 + return next_profile(root, profile);
98728 +}
98729 +
98730 +/**
98731 + * p_stop - stop depth first traversal
98732 + * @f: seq_file we are filling
98733 + * @p: the last profile writen
98734 + *
98735 + * Release all locking done by p_start/p_next on namespace tree
98736 + */
98737 +static void p_stop(struct seq_file *f, void *p)
98738 + __releases(root->lock)
98739 +{
98740 + struct aa_profile *profile = p;
98741 + struct aa_namespace *root = f->private, *ns;
98742 +
98743 + if (profile) {
98744 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
98745 + read_unlock(&ns->lock);
98746 + }
98747 + read_unlock(&root->lock);
98748 + aa_put_namespace(root);
98749 +}
98750 +
98751 +/**
98752 + * seq_show_profile - show a profile entry
98753 + * @f: seq_file to file
98754 + * @p: current position (profile) (NOT NULL)
98755 + *
98756 + * Returns: error on failure
98757 + */
98758 +static int seq_show_profile(struct seq_file *f, void *p)
98759 +{
98760 + struct aa_profile *profile = (struct aa_profile *)p;
98761 + struct aa_namespace *root = f->private;
98762 +
98763 + if (profile->ns != root)
98764 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
98765 + seq_printf(f, "%s (%s)\n", profile->base.hname,
98766 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
98767 +
98768 + return 0;
98769 +}
98770 +
98771 +static const struct seq_operations aa_fs_profiles_op = {
98772 + .start = p_start,
98773 + .next = p_next,
98774 + .stop = p_stop,
98775 + .show = seq_show_profile,
98776 +};
98777 +
98778 +static int profiles_open(struct inode *inode, struct file *file)
98779 +{
98780 + return seq_open(file, &aa_fs_profiles_op);
98781 +}
98782 +
98783 +static int profiles_release(struct inode *inode, struct file *file)
98784 +{
98785 + return seq_release(inode, file);
98786 +}
98787 +
98788 +const struct file_operations aa_fs_profiles_fops = {
98789 + .open = profiles_open,
98790 + .read = seq_read,
98791 + .llseek = seq_lseek,
98792 + .release = profiles_release,
98793 +};
98794 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
98795 +
98796 /** Base file system setup **/
98797
98798 static struct aa_fs_entry aa_fs_entry_file[] = {
98799 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
98800 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
98801 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
98802 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
98803 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98804 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
98805 +#endif
98806 AA_FS_DIR("features", aa_fs_entry_features),
98807 { }
98808 };
98809 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
98810 index 2e2a0dd..a0cbc44 100644
98811 --- a/security/apparmor/lsm.c
98812 +++ b/security/apparmor/lsm.c
98813 @@ -613,7 +613,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
98814 return error;
98815 }
98816
98817 -static struct security_operations apparmor_ops = {
98818 +static struct security_operations apparmor_ops __read_only = {
98819 .name = "apparmor",
98820
98821 .ptrace_access_check = apparmor_ptrace_access_check,
98822 diff --git a/security/commoncap.c b/security/commoncap.c
98823 index c44b6fe..932df30 100644
98824 --- a/security/commoncap.c
98825 +++ b/security/commoncap.c
98826 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
98827 return 0;
98828 }
98829
98830 +/* returns:
98831 + 1 for suid privilege
98832 + 2 for sgid privilege
98833 + 3 for fscap privilege
98834 +*/
98835 +int is_privileged_binary(const struct dentry *dentry)
98836 +{
98837 + struct cpu_vfs_cap_data capdata;
98838 + struct inode *inode = dentry->d_inode;
98839 +
98840 + if (!inode || S_ISDIR(inode->i_mode))
98841 + return 0;
98842 +
98843 + if (inode->i_mode & S_ISUID)
98844 + return 1;
98845 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
98846 + return 2;
98847 +
98848 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
98849 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
98850 + return 3;
98851 + }
98852 +
98853 + return 0;
98854 +}
98855 +
98856 /*
98857 * Attempt to get the on-exec apply capability sets for an executable file from
98858 * its xattrs and, if present, apply them to the proposed credentials being
98859 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
98860 const struct cred *cred = current_cred();
98861 kuid_t root_uid = make_kuid(cred->user_ns, 0);
98862
98863 + if (gr_acl_enable_at_secure())
98864 + return 1;
98865 +
98866 if (!uid_eq(cred->uid, root_uid)) {
98867 if (bprm->cap_effective)
98868 return 1;
98869 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
98870 index b3dd616..4bb17f3 100644
98871 --- a/security/integrity/ima/ima.h
98872 +++ b/security/integrity/ima/ima.h
98873 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
98874 extern spinlock_t ima_queue_lock;
98875
98876 struct ima_h_table {
98877 - atomic_long_t len; /* number of stored measurements in the list */
98878 - atomic_long_t violations;
98879 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
98880 + atomic_long_unchecked_t violations;
98881 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
98882 };
98883 extern struct ima_h_table ima_htable;
98884 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
98885 index 1c03e8f1..398a941 100644
98886 --- a/security/integrity/ima/ima_api.c
98887 +++ b/security/integrity/ima/ima_api.c
98888 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
98889 int result;
98890
98891 /* can overflow, only indicator */
98892 - atomic_long_inc(&ima_htable.violations);
98893 + atomic_long_inc_unchecked(&ima_htable.violations);
98894
98895 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
98896 if (!entry) {
98897 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
98898 index 38477c9..87a60c7 100644
98899 --- a/security/integrity/ima/ima_fs.c
98900 +++ b/security/integrity/ima/ima_fs.c
98901 @@ -28,12 +28,12 @@
98902 static int valid_policy = 1;
98903 #define TMPBUFLEN 12
98904 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
98905 - loff_t *ppos, atomic_long_t *val)
98906 + loff_t *ppos, atomic_long_unchecked_t *val)
98907 {
98908 char tmpbuf[TMPBUFLEN];
98909 ssize_t len;
98910
98911 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
98912 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
98913 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
98914 }
98915
98916 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
98917 index ff63fe0..809cd96 100644
98918 --- a/security/integrity/ima/ima_queue.c
98919 +++ b/security/integrity/ima/ima_queue.c
98920 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
98921 INIT_LIST_HEAD(&qe->later);
98922 list_add_tail_rcu(&qe->later, &ima_measurements);
98923
98924 - atomic_long_inc(&ima_htable.len);
98925 + atomic_long_inc_unchecked(&ima_htable.len);
98926 key = ima_hash_key(entry->digest);
98927 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
98928 return 0;
98929 diff --git a/security/keys/compat.c b/security/keys/compat.c
98930 index d65fa7f..cbfe366 100644
98931 --- a/security/keys/compat.c
98932 +++ b/security/keys/compat.c
98933 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
98934 if (ret == 0)
98935 goto no_payload_free;
98936
98937 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98938 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98939 err:
98940 if (iov != iovstack)
98941 kfree(iov);
98942 diff --git a/security/keys/internal.h b/security/keys/internal.h
98943 index d4f1468..cc52f92 100644
98944 --- a/security/keys/internal.h
98945 +++ b/security/keys/internal.h
98946 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
98947 extern long keyctl_invalidate_key(key_serial_t);
98948
98949 extern long keyctl_instantiate_key_common(key_serial_t,
98950 - const struct iovec *,
98951 + const struct iovec __user *,
98952 unsigned, size_t, key_serial_t);
98953
98954 /*
98955 diff --git a/security/keys/key.c b/security/keys/key.c
98956 index 8fb7c7b..ba3610d 100644
98957 --- a/security/keys/key.c
98958 +++ b/security/keys/key.c
98959 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
98960
98961 atomic_set(&key->usage, 1);
98962 init_rwsem(&key->sem);
98963 - lockdep_set_class(&key->sem, &type->lock_class);
98964 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
98965 key->type = type;
98966 key->user = user;
98967 key->quotalen = quotalen;
98968 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
98969 struct key_type *p;
98970 int ret;
98971
98972 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
98973 + pax_open_kernel();
98974 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
98975 + pax_close_kernel();
98976
98977 ret = -EEXIST;
98978 down_write(&key_types_sem);
98979 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
98980 }
98981
98982 /* store the type */
98983 - list_add(&ktype->link, &key_types_list);
98984 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
98985
98986 pr_notice("Key type %s registered\n", ktype->name);
98987 ret = 0;
98988 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
98989 void unregister_key_type(struct key_type *ktype)
98990 {
98991 down_write(&key_types_sem);
98992 - list_del_init(&ktype->link);
98993 + pax_list_del_init((struct list_head *)&ktype->link);
98994 downgrade_write(&key_types_sem);
98995 key_gc_keytype(ktype);
98996 pr_notice("Key type %s unregistered\n", ktype->name);
98997 @@ -1084,10 +1086,10 @@ void __init key_init(void)
98998 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
98999
99000 /* add the special key types */
99001 - list_add_tail(&key_type_keyring.link, &key_types_list);
99002 - list_add_tail(&key_type_dead.link, &key_types_list);
99003 - list_add_tail(&key_type_user.link, &key_types_list);
99004 - list_add_tail(&key_type_logon.link, &key_types_list);
99005 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
99006 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
99007 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
99008 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
99009
99010 /* record the root user tracking */
99011 rb_link_node(&root_key_user.node,
99012 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
99013 index 33cfd27..842fc5a 100644
99014 --- a/security/keys/keyctl.c
99015 +++ b/security/keys/keyctl.c
99016 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
99017 /*
99018 * Copy the iovec data from userspace
99019 */
99020 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99021 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
99022 unsigned ioc)
99023 {
99024 for (; ioc > 0; ioc--) {
99025 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99026 * If successful, 0 will be returned.
99027 */
99028 long keyctl_instantiate_key_common(key_serial_t id,
99029 - const struct iovec *payload_iov,
99030 + const struct iovec __user *payload_iov,
99031 unsigned ioc,
99032 size_t plen,
99033 key_serial_t ringid)
99034 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
99035 [0].iov_len = plen
99036 };
99037
99038 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
99039 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
99040 }
99041
99042 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
99043 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
99044 if (ret == 0)
99045 goto no_payload_free;
99046
99047 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99048 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99049 err:
99050 if (iov != iovstack)
99051 kfree(iov);
99052 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
99053 index 6ece7f2..ecdb55c 100644
99054 --- a/security/keys/keyring.c
99055 +++ b/security/keys/keyring.c
99056 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
99057 ret = -EFAULT;
99058
99059 for (loop = 0; loop < klist->nkeys; loop++) {
99060 + key_serial_t serial;
99061 key = rcu_deref_link_locked(klist, loop,
99062 keyring);
99063 + serial = key->serial;
99064
99065 tmp = sizeof(key_serial_t);
99066 if (tmp > buflen)
99067 tmp = buflen;
99068
99069 - if (copy_to_user(buffer,
99070 - &key->serial,
99071 - tmp) != 0)
99072 + if (copy_to_user(buffer, &serial, tmp))
99073 goto error;
99074
99075 buflen -= tmp;
99076 diff --git a/security/min_addr.c b/security/min_addr.c
99077 index f728728..6457a0c 100644
99078 --- a/security/min_addr.c
99079 +++ b/security/min_addr.c
99080 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
99081 */
99082 static void update_mmap_min_addr(void)
99083 {
99084 +#ifndef SPARC
99085 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
99086 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
99087 mmap_min_addr = dac_mmap_min_addr;
99088 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
99089 #else
99090 mmap_min_addr = dac_mmap_min_addr;
99091 #endif
99092 +#endif
99093 }
99094
99095 /*
99096 diff --git a/security/security.c b/security/security.c
99097 index 94b35ae..f4e7751 100644
99098 --- a/security/security.c
99099 +++ b/security/security.c
99100 @@ -33,8 +33,8 @@
99101 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
99102 CONFIG_DEFAULT_SECURITY;
99103
99104 -static struct security_operations *security_ops;
99105 -static struct security_operations default_security_ops = {
99106 +struct security_operations *security_ops __read_only;
99107 +struct security_operations default_security_ops __read_only = {
99108 .name = "default",
99109 };
99110
99111 @@ -73,11 +73,6 @@ int __init security_init(void)
99112 return 0;
99113 }
99114
99115 -void reset_security_ops(void)
99116 -{
99117 - security_ops = &default_security_ops;
99118 -}
99119 -
99120 /* Save user chosen LSM */
99121 static int __init choose_lsm(char *str)
99122 {
99123 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
99124 index dad36a6..7e5ffbf 100644
99125 --- a/security/selinux/avc.c
99126 +++ b/security/selinux/avc.c
99127 @@ -59,7 +59,7 @@ struct avc_node {
99128 struct avc_cache {
99129 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
99130 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
99131 - atomic_t lru_hint; /* LRU hint for reclaim scan */
99132 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
99133 atomic_t active_nodes;
99134 u32 latest_notif; /* latest revocation notification */
99135 };
99136 @@ -167,7 +167,7 @@ void __init avc_init(void)
99137 spin_lock_init(&avc_cache.slots_lock[i]);
99138 }
99139 atomic_set(&avc_cache.active_nodes, 0);
99140 - atomic_set(&avc_cache.lru_hint, 0);
99141 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
99142
99143 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
99144 0, SLAB_PANIC, NULL);
99145 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
99146 spinlock_t *lock;
99147
99148 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
99149 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99150 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99151 head = &avc_cache.slots[hvalue];
99152 lock = &avc_cache.slots_lock[hvalue];
99153
99154 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
99155 index c956390..1899f06 100644
99156 --- a/security/selinux/hooks.c
99157 +++ b/security/selinux/hooks.c
99158 @@ -97,8 +97,6 @@
99159
99160 #define NUM_SEL_MNT_OPTS 5
99161
99162 -extern struct security_operations *security_ops;
99163 -
99164 /* SECMARK reference count */
99165 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
99166
99167 @@ -5609,7 +5607,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
99168
99169 #endif
99170
99171 -static struct security_operations selinux_ops = {
99172 +static struct security_operations selinux_ops __read_only = {
99173 .name = "selinux",
99174
99175 .ptrace_access_check = selinux_ptrace_access_check,
99176 @@ -5961,6 +5959,9 @@ static void selinux_nf_ip_exit(void)
99177 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
99178 static int selinux_disabled;
99179
99180 +extern struct security_operations *security_ops;
99181 +extern struct security_operations default_security_ops;
99182 +
99183 int selinux_disable(void)
99184 {
99185 if (ss_initialized) {
99186 @@ -5978,7 +5979,9 @@ int selinux_disable(void)
99187 selinux_disabled = 1;
99188 selinux_enabled = 0;
99189
99190 - reset_security_ops();
99191 + pax_open_kernel();
99192 + security_ops = &default_security_ops;
99193 + pax_close_kernel();
99194
99195 /* Try to destroy the avc node cache */
99196 avc_disable();
99197 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
99198 index 65f67cb..3f141ef 100644
99199 --- a/security/selinux/include/xfrm.h
99200 +++ b/security/selinux/include/xfrm.h
99201 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
99202
99203 static inline void selinux_xfrm_notify_policyload(void)
99204 {
99205 - atomic_inc(&flow_cache_genid);
99206 + atomic_inc_unchecked(&flow_cache_genid);
99207 rt_genid_bump(&init_net);
99208 }
99209 #else
99210 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
99211 index eefbd10..9f10ddb 100644
99212 --- a/security/smack/smack_lsm.c
99213 +++ b/security/smack/smack_lsm.c
99214 @@ -3711,7 +3711,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
99215 return 0;
99216 }
99217
99218 -struct security_operations smack_ops = {
99219 +struct security_operations smack_ops __read_only = {
99220 .name = "smack",
99221
99222 .ptrace_access_check = smack_ptrace_access_check,
99223 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
99224 index 390c646..f2f8db3 100644
99225 --- a/security/tomoyo/mount.c
99226 +++ b/security/tomoyo/mount.c
99227 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
99228 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
99229 need_dev = -1; /* dev_name is a directory */
99230 } else {
99231 + if (!capable(CAP_SYS_ADMIN)) {
99232 + error = -EPERM;
99233 + goto out;
99234 + }
99235 fstype = get_fs_type(type);
99236 if (!fstype) {
99237 error = -ENODEV;
99238 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
99239 index f0b756e..b129202 100644
99240 --- a/security/tomoyo/tomoyo.c
99241 +++ b/security/tomoyo/tomoyo.c
99242 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
99243 * tomoyo_security_ops is a "struct security_operations" which is used for
99244 * registering TOMOYO.
99245 */
99246 -static struct security_operations tomoyo_security_ops = {
99247 +static struct security_operations tomoyo_security_ops __read_only = {
99248 .name = "tomoyo",
99249 .cred_alloc_blank = tomoyo_cred_alloc_blank,
99250 .cred_prepare = tomoyo_cred_prepare,
99251 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
99252 index 20ef514..4182bed 100644
99253 --- a/security/yama/Kconfig
99254 +++ b/security/yama/Kconfig
99255 @@ -1,6 +1,6 @@
99256 config SECURITY_YAMA
99257 bool "Yama support"
99258 - depends on SECURITY
99259 + depends on SECURITY && !GRKERNSEC
99260 select SECURITYFS
99261 select SECURITY_PATH
99262 default n
99263 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
99264 index 13c88fbc..f8c115e 100644
99265 --- a/security/yama/yama_lsm.c
99266 +++ b/security/yama/yama_lsm.c
99267 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
99268 }
99269
99270 #ifndef CONFIG_SECURITY_YAMA_STACKED
99271 -static struct security_operations yama_ops = {
99272 +static struct security_operations yama_ops __read_only = {
99273 .name = "yama",
99274
99275 .ptrace_access_check = yama_ptrace_access_check,
99276 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
99277 #endif
99278
99279 #ifdef CONFIG_SYSCTL
99280 +static int zero __read_only;
99281 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
99282 +
99283 static int yama_dointvec_minmax(struct ctl_table *table, int write,
99284 void __user *buffer, size_t *lenp, loff_t *ppos)
99285 {
99286 - int rc;
99287 + ctl_table_no_const yama_table;
99288
99289 if (write && !capable(CAP_SYS_PTRACE))
99290 return -EPERM;
99291
99292 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
99293 - if (rc)
99294 - return rc;
99295 -
99296 + yama_table = *table;
99297 /* Lock the max value if it ever gets set. */
99298 - if (write && *(int *)table->data == *(int *)table->extra2)
99299 - table->extra1 = table->extra2;
99300 -
99301 - return rc;
99302 + if (ptrace_scope == max_scope)
99303 + yama_table.extra1 = &max_scope;
99304 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
99305 }
99306
99307 -static int zero;
99308 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
99309 -
99310 struct ctl_path yama_sysctl_path[] = {
99311 { .procname = "kernel", },
99312 { .procname = "yama", },
99313 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
99314 index 4cedc69..e59d8a3 100644
99315 --- a/sound/aoa/codecs/onyx.c
99316 +++ b/sound/aoa/codecs/onyx.c
99317 @@ -54,7 +54,7 @@ struct onyx {
99318 spdif_locked:1,
99319 analog_locked:1,
99320 original_mute:2;
99321 - int open_count;
99322 + local_t open_count;
99323 struct codec_info *codec_info;
99324
99325 /* mutex serializes concurrent access to the device
99326 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
99327 struct onyx *onyx = cii->codec_data;
99328
99329 mutex_lock(&onyx->mutex);
99330 - onyx->open_count++;
99331 + local_inc(&onyx->open_count);
99332 mutex_unlock(&onyx->mutex);
99333
99334 return 0;
99335 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
99336 struct onyx *onyx = cii->codec_data;
99337
99338 mutex_lock(&onyx->mutex);
99339 - onyx->open_count--;
99340 - if (!onyx->open_count)
99341 + if (local_dec_and_test(&onyx->open_count))
99342 onyx->spdif_locked = onyx->analog_locked = 0;
99343 mutex_unlock(&onyx->mutex);
99344
99345 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
99346 index ffd2025..df062c9 100644
99347 --- a/sound/aoa/codecs/onyx.h
99348 +++ b/sound/aoa/codecs/onyx.h
99349 @@ -11,6 +11,7 @@
99350 #include <linux/i2c.h>
99351 #include <asm/pmac_low_i2c.h>
99352 #include <asm/prom.h>
99353 +#include <asm/local.h>
99354
99355 /* PCM3052 register definitions */
99356
99357 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
99358 index 4c1cc51..16040040 100644
99359 --- a/sound/core/oss/pcm_oss.c
99360 +++ b/sound/core/oss/pcm_oss.c
99361 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
99362 if (in_kernel) {
99363 mm_segment_t fs;
99364 fs = snd_enter_user();
99365 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99366 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99367 snd_leave_user(fs);
99368 } else {
99369 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99370 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99371 }
99372 if (ret != -EPIPE && ret != -ESTRPIPE)
99373 break;
99374 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
99375 if (in_kernel) {
99376 mm_segment_t fs;
99377 fs = snd_enter_user();
99378 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99379 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99380 snd_leave_user(fs);
99381 } else {
99382 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99383 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99384 }
99385 if (ret == -EPIPE) {
99386 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
99387 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
99388 struct snd_pcm_plugin_channel *channels;
99389 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
99390 if (!in_kernel) {
99391 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
99392 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
99393 return -EFAULT;
99394 buf = runtime->oss.buffer;
99395 }
99396 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
99397 }
99398 } else {
99399 tmp = snd_pcm_oss_write2(substream,
99400 - (const char __force *)buf,
99401 + (const char __force_kernel *)buf,
99402 runtime->oss.period_bytes, 0);
99403 if (tmp <= 0)
99404 goto err;
99405 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
99406 struct snd_pcm_runtime *runtime = substream->runtime;
99407 snd_pcm_sframes_t frames, frames1;
99408 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
99409 - char __user *final_dst = (char __force __user *)buf;
99410 + char __user *final_dst = (char __force_user *)buf;
99411 if (runtime->oss.plugin_first) {
99412 struct snd_pcm_plugin_channel *channels;
99413 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
99414 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
99415 xfer += tmp;
99416 runtime->oss.buffer_used -= tmp;
99417 } else {
99418 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
99419 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
99420 runtime->oss.period_bytes, 0);
99421 if (tmp <= 0)
99422 goto err;
99423 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
99424 size1);
99425 size1 /= runtime->channels; /* frames */
99426 fs = snd_enter_user();
99427 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
99428 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
99429 snd_leave_user(fs);
99430 }
99431 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
99432 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
99433 index af49721..e85058e 100644
99434 --- a/sound/core/pcm_compat.c
99435 +++ b/sound/core/pcm_compat.c
99436 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
99437 int err;
99438
99439 fs = snd_enter_user();
99440 - err = snd_pcm_delay(substream, &delay);
99441 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
99442 snd_leave_user(fs);
99443 if (err < 0)
99444 return err;
99445 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
99446 index a68d4c6..72af3cf 100644
99447 --- a/sound/core/pcm_native.c
99448 +++ b/sound/core/pcm_native.c
99449 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
99450 switch (substream->stream) {
99451 case SNDRV_PCM_STREAM_PLAYBACK:
99452 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
99453 - (void __user *)arg);
99454 + (void __force_user *)arg);
99455 break;
99456 case SNDRV_PCM_STREAM_CAPTURE:
99457 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
99458 - (void __user *)arg);
99459 + (void __force_user *)arg);
99460 break;
99461 default:
99462 result = -EINVAL;
99463 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
99464 index 040c60e..989a19a 100644
99465 --- a/sound/core/seq/seq_device.c
99466 +++ b/sound/core/seq/seq_device.c
99467 @@ -64,7 +64,7 @@ struct ops_list {
99468 int argsize; /* argument size */
99469
99470 /* operators */
99471 - struct snd_seq_dev_ops ops;
99472 + struct snd_seq_dev_ops *ops;
99473
99474 /* registered devices */
99475 struct list_head dev_list; /* list of devices */
99476 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
99477
99478 mutex_lock(&ops->reg_mutex);
99479 /* copy driver operators */
99480 - ops->ops = *entry;
99481 + ops->ops = entry;
99482 ops->driver |= DRIVER_LOADED;
99483 ops->argsize = argsize;
99484
99485 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99486 dev->name, ops->id, ops->argsize, dev->argsize);
99487 return -EINVAL;
99488 }
99489 - if (ops->ops.init_device(dev) >= 0) {
99490 + if (ops->ops->init_device(dev) >= 0) {
99491 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99492 ops->num_init_devices++;
99493 } else {
99494 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99495 dev->name, ops->id, ops->argsize, dev->argsize);
99496 return -EINVAL;
99497 }
99498 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99499 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99500 dev->status = SNDRV_SEQ_DEVICE_FREE;
99501 dev->driver_data = NULL;
99502 ops->num_init_devices--;
99503 diff --git a/sound/core/sound.c b/sound/core/sound.c
99504 index f002bd9..c462985 100644
99505 --- a/sound/core/sound.c
99506 +++ b/sound/core/sound.c
99507 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99508 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99509 default: return;
99510 }
99511 - request_module(str);
99512 + request_module("%s", str);
99513 }
99514
99515 #endif /* modular kernel */
99516 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99517 index 4e0dd22..7a1f32c 100644
99518 --- a/sound/drivers/mts64.c
99519 +++ b/sound/drivers/mts64.c
99520 @@ -29,6 +29,7 @@
99521 #include <sound/initval.h>
99522 #include <sound/rawmidi.h>
99523 #include <sound/control.h>
99524 +#include <asm/local.h>
99525
99526 #define CARD_NAME "Miditerminal 4140"
99527 #define DRIVER_NAME "MTS64"
99528 @@ -67,7 +68,7 @@ struct mts64 {
99529 struct pardevice *pardev;
99530 int pardev_claimed;
99531
99532 - int open_count;
99533 + local_t open_count;
99534 int current_midi_output_port;
99535 int current_midi_input_port;
99536 u8 mode[MTS64_NUM_INPUT_PORTS];
99537 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99538 {
99539 struct mts64 *mts = substream->rmidi->private_data;
99540
99541 - if (mts->open_count == 0) {
99542 + if (local_read(&mts->open_count) == 0) {
99543 /* We don't need a spinlock here, because this is just called
99544 if the device has not been opened before.
99545 So there aren't any IRQs from the device */
99546 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99547
99548 msleep(50);
99549 }
99550 - ++(mts->open_count);
99551 + local_inc(&mts->open_count);
99552
99553 return 0;
99554 }
99555 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99556 struct mts64 *mts = substream->rmidi->private_data;
99557 unsigned long flags;
99558
99559 - --(mts->open_count);
99560 - if (mts->open_count == 0) {
99561 + if (local_dec_return(&mts->open_count) == 0) {
99562 /* We need the spinlock_irqsave here because we can still
99563 have IRQs at this point */
99564 spin_lock_irqsave(&mts->lock, flags);
99565 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99566
99567 msleep(500);
99568
99569 - } else if (mts->open_count < 0)
99570 - mts->open_count = 0;
99571 + } else if (local_read(&mts->open_count) < 0)
99572 + local_set(&mts->open_count, 0);
99573
99574 return 0;
99575 }
99576 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
99577 index b953fb4..1999c01 100644
99578 --- a/sound/drivers/opl4/opl4_lib.c
99579 +++ b/sound/drivers/opl4/opl4_lib.c
99580 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
99581 MODULE_DESCRIPTION("OPL4 driver");
99582 MODULE_LICENSE("GPL");
99583
99584 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
99585 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
99586 {
99587 int timeout = 10;
99588 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
99589 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
99590 index 991018d..8984740 100644
99591 --- a/sound/drivers/portman2x4.c
99592 +++ b/sound/drivers/portman2x4.c
99593 @@ -48,6 +48,7 @@
99594 #include <sound/initval.h>
99595 #include <sound/rawmidi.h>
99596 #include <sound/control.h>
99597 +#include <asm/local.h>
99598
99599 #define CARD_NAME "Portman 2x4"
99600 #define DRIVER_NAME "portman"
99601 @@ -85,7 +86,7 @@ struct portman {
99602 struct pardevice *pardev;
99603 int pardev_claimed;
99604
99605 - int open_count;
99606 + local_t open_count;
99607 int mode[PORTMAN_NUM_INPUT_PORTS];
99608 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
99609 };
99610 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
99611 index ea995af..f1bfa37 100644
99612 --- a/sound/firewire/amdtp.c
99613 +++ b/sound/firewire/amdtp.c
99614 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
99615 ptr = s->pcm_buffer_pointer + data_blocks;
99616 if (ptr >= pcm->runtime->buffer_size)
99617 ptr -= pcm->runtime->buffer_size;
99618 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
99619 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
99620
99621 s->pcm_period_pointer += data_blocks;
99622 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
99623 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
99624 */
99625 void amdtp_out_stream_update(struct amdtp_out_stream *s)
99626 {
99627 - ACCESS_ONCE(s->source_node_id_field) =
99628 + ACCESS_ONCE_RW(s->source_node_id_field) =
99629 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
99630 }
99631 EXPORT_SYMBOL(amdtp_out_stream_update);
99632 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
99633 index f6103d6..4843fbf 100644
99634 --- a/sound/firewire/amdtp.h
99635 +++ b/sound/firewire/amdtp.h
99636 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
99637 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
99638 struct snd_pcm_substream *pcm)
99639 {
99640 - ACCESS_ONCE(s->pcm) = pcm;
99641 + ACCESS_ONCE_RW(s->pcm) = pcm;
99642 }
99643
99644 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
99645 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
99646 index 58a5afe..af5bd64 100644
99647 --- a/sound/firewire/isight.c
99648 +++ b/sound/firewire/isight.c
99649 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
99650 ptr += count;
99651 if (ptr >= runtime->buffer_size)
99652 ptr -= runtime->buffer_size;
99653 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
99654 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
99655
99656 isight->period_counter += count;
99657 if (isight->period_counter >= runtime->period_size) {
99658 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
99659 if (err < 0)
99660 return err;
99661
99662 - ACCESS_ONCE(isight->pcm_active) = true;
99663 + ACCESS_ONCE_RW(isight->pcm_active) = true;
99664
99665 return 0;
99666 }
99667 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
99668 {
99669 struct isight *isight = substream->private_data;
99670
99671 - ACCESS_ONCE(isight->pcm_active) = false;
99672 + ACCESS_ONCE_RW(isight->pcm_active) = false;
99673
99674 mutex_lock(&isight->mutex);
99675 isight_stop_streaming(isight);
99676 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
99677
99678 switch (cmd) {
99679 case SNDRV_PCM_TRIGGER_START:
99680 - ACCESS_ONCE(isight->pcm_running) = true;
99681 + ACCESS_ONCE_RW(isight->pcm_running) = true;
99682 break;
99683 case SNDRV_PCM_TRIGGER_STOP:
99684 - ACCESS_ONCE(isight->pcm_running) = false;
99685 + ACCESS_ONCE_RW(isight->pcm_running) = false;
99686 break;
99687 default:
99688 return -EINVAL;
99689 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
99690 index 505fc81..62e569e 100644
99691 --- a/sound/firewire/scs1x.c
99692 +++ b/sound/firewire/scs1x.c
99693 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
99694 {
99695 struct scs *scs = stream->rmidi->private_data;
99696
99697 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
99698 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
99699 if (up) {
99700 scs->output_idle = false;
99701 tasklet_schedule(&scs->tasklet);
99702 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
99703 {
99704 struct scs *scs = stream->rmidi->private_data;
99705
99706 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
99707 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
99708 }
99709
99710 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
99711 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
99712
99713 snd_card_disconnect(scs->card);
99714
99715 - ACCESS_ONCE(scs->output) = NULL;
99716 - ACCESS_ONCE(scs->input) = NULL;
99717 + ACCESS_ONCE_RW(scs->output) = NULL;
99718 + ACCESS_ONCE_RW(scs->input) = NULL;
99719
99720 wait_event(scs->idle_wait, scs->output_idle);
99721
99722 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
99723 index 048439a..3be9f6f 100644
99724 --- a/sound/oss/sb_audio.c
99725 +++ b/sound/oss/sb_audio.c
99726 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
99727 buf16 = (signed short *)(localbuf + localoffs);
99728 while (c)
99729 {
99730 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99731 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99732 if (copy_from_user(lbuf8,
99733 userbuf+useroffs + p,
99734 locallen))
99735 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
99736 index 7d8803a..559f8d0 100644
99737 --- a/sound/oss/swarm_cs4297a.c
99738 +++ b/sound/oss/swarm_cs4297a.c
99739 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
99740 {
99741 struct cs4297a_state *s;
99742 u32 pwr, id;
99743 - mm_segment_t fs;
99744 int rval;
99745 #ifndef CONFIG_BCM_CS4297A_CSWARM
99746 u64 cfg;
99747 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
99748 if (!rval) {
99749 char *sb1250_duart_present;
99750
99751 +#if 0
99752 + mm_segment_t fs;
99753 fs = get_fs();
99754 set_fs(KERNEL_DS);
99755 -#if 0
99756 val = SOUND_MASK_LINE;
99757 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
99758 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
99759 val = initvol[i].vol;
99760 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
99761 }
99762 + set_fs(fs);
99763 // cs4297a_write_ac97(s, 0x18, 0x0808);
99764 #else
99765 // cs4297a_write_ac97(s, 0x5e, 0x180);
99766 cs4297a_write_ac97(s, 0x02, 0x0808);
99767 cs4297a_write_ac97(s, 0x18, 0x0808);
99768 #endif
99769 - set_fs(fs);
99770
99771 list_add(&s->list, &cs4297a_devs);
99772
99773 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
99774 index 7c9e7dc..3b2bd95 100644
99775 --- a/sound/pci/hda/hda_codec.c
99776 +++ b/sound/pci/hda/hda_codec.c
99777 @@ -918,14 +918,10 @@ find_codec_preset(struct hda_codec *codec)
99778 mutex_unlock(&preset_mutex);
99779
99780 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
99781 - char name[32];
99782 if (!mod_requested)
99783 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
99784 - codec->vendor_id);
99785 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
99786 else
99787 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
99788 - (codec->vendor_id >> 16) & 0xffff);
99789 - request_module(name);
99790 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
99791 mod_requested++;
99792 goto again;
99793 }
99794 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
99795 index 4631a23..001ae57 100644
99796 --- a/sound/pci/ymfpci/ymfpci.h
99797 +++ b/sound/pci/ymfpci/ymfpci.h
99798 @@ -358,7 +358,7 @@ struct snd_ymfpci {
99799 spinlock_t reg_lock;
99800 spinlock_t voice_lock;
99801 wait_queue_head_t interrupt_sleep;
99802 - atomic_t interrupt_sleep_count;
99803 + atomic_unchecked_t interrupt_sleep_count;
99804 struct snd_info_entry *proc_entry;
99805 const struct firmware *dsp_microcode;
99806 const struct firmware *controller_microcode;
99807 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
99808 index d591c15..8cb8f94 100644
99809 --- a/sound/pci/ymfpci/ymfpci_main.c
99810 +++ b/sound/pci/ymfpci/ymfpci_main.c
99811 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
99812 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
99813 break;
99814 }
99815 - if (atomic_read(&chip->interrupt_sleep_count)) {
99816 - atomic_set(&chip->interrupt_sleep_count, 0);
99817 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99818 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99819 wake_up(&chip->interrupt_sleep);
99820 }
99821 __end:
99822 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
99823 continue;
99824 init_waitqueue_entry(&wait, current);
99825 add_wait_queue(&chip->interrupt_sleep, &wait);
99826 - atomic_inc(&chip->interrupt_sleep_count);
99827 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
99828 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
99829 remove_wait_queue(&chip->interrupt_sleep, &wait);
99830 }
99831 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
99832 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
99833 spin_unlock(&chip->reg_lock);
99834
99835 - if (atomic_read(&chip->interrupt_sleep_count)) {
99836 - atomic_set(&chip->interrupt_sleep_count, 0);
99837 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99838 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99839 wake_up(&chip->interrupt_sleep);
99840 }
99841 }
99842 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
99843 spin_lock_init(&chip->reg_lock);
99844 spin_lock_init(&chip->voice_lock);
99845 init_waitqueue_head(&chip->interrupt_sleep);
99846 - atomic_set(&chip->interrupt_sleep_count, 0);
99847 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99848 chip->card = card;
99849 chip->pci = pci;
99850 chip->irq = -1;
99851 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
99852 index 2f2d837..3e3f1f6 100644
99853 --- a/sound/soc/fsl/fsl_ssi.c
99854 +++ b/sound/soc/fsl/fsl_ssi.c
99855 @@ -656,7 +656,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
99856 {
99857 struct fsl_ssi_private *ssi_private;
99858 int ret = 0;
99859 - struct device_attribute *dev_attr = NULL;
99860 + device_attribute_no_const *dev_attr = NULL;
99861 struct device_node *np = pdev->dev.of_node;
99862 const char *p, *sprop;
99863 const uint32_t *iprop;
99864 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
99865 new file mode 100644
99866 index 0000000..50f2f2f
99867 --- /dev/null
99868 +++ b/tools/gcc/.gitignore
99869 @@ -0,0 +1 @@
99870 +size_overflow_hash.h
99871 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
99872 new file mode 100644
99873 index 0000000..144dbee
99874 --- /dev/null
99875 +++ b/tools/gcc/Makefile
99876 @@ -0,0 +1,45 @@
99877 +#CC := gcc
99878 +#PLUGIN_SOURCE_FILES := pax_plugin.c
99879 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
99880 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
99881 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
99882 +
99883 +ifeq ($(PLUGINCC),$(HOSTCC))
99884 +HOSTLIBS := hostlibs
99885 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
99886 +else
99887 +HOSTLIBS := hostcxxlibs
99888 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
99889 +endif
99890 +
99891 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
99892 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
99893 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
99894 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
99895 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
99896 +$(HOSTLIBS)-y += colorize_plugin.so
99897 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
99898 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
99899 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
99900 +
99901 +always := $($(HOSTLIBS)-y)
99902 +
99903 +constify_plugin-objs := constify_plugin.o
99904 +stackleak_plugin-objs := stackleak_plugin.o
99905 +kallocstat_plugin-objs := kallocstat_plugin.o
99906 +kernexec_plugin-objs := kernexec_plugin.o
99907 +checker_plugin-objs := checker_plugin.o
99908 +colorize_plugin-objs := colorize_plugin.o
99909 +size_overflow_plugin-objs := size_overflow_plugin.o
99910 +latent_entropy_plugin-objs := latent_entropy_plugin.o
99911 +structleak_plugin-objs := structleak_plugin.o
99912 +
99913 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
99914 +
99915 +quiet_cmd_build_size_overflow_hash = GENHASH $@
99916 + cmd_build_size_overflow_hash = \
99917 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
99918 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
99919 + $(call if_changed,build_size_overflow_hash)
99920 +
99921 +targets += size_overflow_hash.h
99922 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
99923 new file mode 100644
99924 index 0000000..22f03c0
99925 --- /dev/null
99926 +++ b/tools/gcc/checker_plugin.c
99927 @@ -0,0 +1,172 @@
99928 +/*
99929 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
99930 + * Licensed under the GPL v2
99931 + *
99932 + * Note: the choice of the license means that the compilation process is
99933 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99934 + * but for the kernel it doesn't matter since it doesn't link against
99935 + * any of the gcc libraries
99936 + *
99937 + * gcc plugin to implement various sparse (source code checker) features
99938 + *
99939 + * TODO:
99940 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
99941 + *
99942 + * BUGS:
99943 + * - none known
99944 + */
99945 +#include "gcc-plugin.h"
99946 +#include "config.h"
99947 +#include "system.h"
99948 +#include "coretypes.h"
99949 +#include "tree.h"
99950 +#include "tree-pass.h"
99951 +#include "flags.h"
99952 +#include "intl.h"
99953 +#include "toplev.h"
99954 +#include "plugin.h"
99955 +//#include "expr.h" where are you...
99956 +#include "diagnostic.h"
99957 +#include "plugin-version.h"
99958 +#include "tm.h"
99959 +#include "function.h"
99960 +#include "basic-block.h"
99961 +#include "gimple.h"
99962 +#include "rtl.h"
99963 +#include "emit-rtl.h"
99964 +#include "tree-flow.h"
99965 +#include "target.h"
99966 +
99967 +extern void c_register_addr_space (const char *str, addr_space_t as);
99968 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
99969 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
99970 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
99971 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
99972 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
99973 +
99974 +extern void print_gimple_stmt(FILE *, gimple, int, int);
99975 +extern rtx emit_move_insn(rtx x, rtx y);
99976 +
99977 +int plugin_is_GPL_compatible;
99978 +
99979 +static struct plugin_info checker_plugin_info = {
99980 + .version = "201111150100",
99981 + .help = NULL,
99982 +};
99983 +
99984 +#define ADDR_SPACE_KERNEL 0
99985 +#define ADDR_SPACE_FORCE_KERNEL 1
99986 +#define ADDR_SPACE_USER 2
99987 +#define ADDR_SPACE_FORCE_USER 3
99988 +#define ADDR_SPACE_IOMEM 0
99989 +#define ADDR_SPACE_FORCE_IOMEM 0
99990 +#define ADDR_SPACE_PERCPU 0
99991 +#define ADDR_SPACE_FORCE_PERCPU 0
99992 +#define ADDR_SPACE_RCU 0
99993 +#define ADDR_SPACE_FORCE_RCU 0
99994 +
99995 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
99996 +{
99997 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
99998 +}
99999 +
100000 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
100001 +{
100002 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
100003 +}
100004 +
100005 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
100006 +{
100007 + return default_addr_space_valid_pointer_mode(mode, as);
100008 +}
100009 +
100010 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
100011 +{
100012 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
100013 +}
100014 +
100015 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
100016 +{
100017 + return default_addr_space_legitimize_address(x, oldx, mode, as);
100018 +}
100019 +
100020 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
100021 +{
100022 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
100023 + return true;
100024 +
100025 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
100026 + return true;
100027 +
100028 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
100029 + return true;
100030 +
100031 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
100032 + return true;
100033 +
100034 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
100035 + return true;
100036 +
100037 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
100038 + return true;
100039 +
100040 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
100041 + return true;
100042 +
100043 + return subset == superset;
100044 +}
100045 +
100046 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
100047 +{
100048 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
100049 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
100050 +
100051 + return op;
100052 +}
100053 +
100054 +static void register_checker_address_spaces(void *event_data, void *data)
100055 +{
100056 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
100057 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
100058 + c_register_addr_space("__user", ADDR_SPACE_USER);
100059 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
100060 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
100061 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
100062 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
100063 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
100064 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
100065 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
100066 +
100067 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
100068 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
100069 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
100070 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
100071 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
100072 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
100073 + targetm.addr_space.convert = checker_addr_space_convert;
100074 +}
100075 +
100076 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100077 +{
100078 + const char * const plugin_name = plugin_info->base_name;
100079 + const int argc = plugin_info->argc;
100080 + const struct plugin_argument * const argv = plugin_info->argv;
100081 + int i;
100082 +
100083 + if (!plugin_default_version_check(version, &gcc_version)) {
100084 + error(G_("incompatible gcc/plugin versions"));
100085 + return 1;
100086 + }
100087 +
100088 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
100089 +
100090 + for (i = 0; i < argc; ++i)
100091 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100092 +
100093 + if (TARGET_64BIT == 0)
100094 + return 0;
100095 +
100096 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
100097 +
100098 + return 0;
100099 +}
100100 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
100101 new file mode 100644
100102 index 0000000..414fe5e
100103 --- /dev/null
100104 +++ b/tools/gcc/colorize_plugin.c
100105 @@ -0,0 +1,151 @@
100106 +/*
100107 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
100108 + * Licensed under the GPL v2
100109 + *
100110 + * Note: the choice of the license means that the compilation process is
100111 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100112 + * but for the kernel it doesn't matter since it doesn't link against
100113 + * any of the gcc libraries
100114 + *
100115 + * gcc plugin to colorize diagnostic output
100116 + *
100117 + */
100118 +
100119 +#include "gcc-plugin.h"
100120 +#include "config.h"
100121 +#include "system.h"
100122 +#include "coretypes.h"
100123 +#include "tree.h"
100124 +#include "tree-pass.h"
100125 +#include "flags.h"
100126 +#include "intl.h"
100127 +#include "toplev.h"
100128 +#include "plugin.h"
100129 +#include "diagnostic.h"
100130 +#include "plugin-version.h"
100131 +#include "tm.h"
100132 +
100133 +int plugin_is_GPL_compatible;
100134 +
100135 +static struct plugin_info colorize_plugin_info = {
100136 + .version = "201302112000",
100137 + .help = NULL,
100138 +};
100139 +
100140 +#define GREEN "\033[32m\033[2m"
100141 +#define LIGHTGREEN "\033[32m\033[1m"
100142 +#define YELLOW "\033[33m\033[2m"
100143 +#define LIGHTYELLOW "\033[33m\033[1m"
100144 +#define RED "\033[31m\033[2m"
100145 +#define LIGHTRED "\033[31m\033[1m"
100146 +#define BLUE "\033[34m\033[2m"
100147 +#define LIGHTBLUE "\033[34m\033[1m"
100148 +#define BRIGHT "\033[m\033[1m"
100149 +#define NORMAL "\033[m"
100150 +
100151 +static diagnostic_starter_fn old_starter;
100152 +static diagnostic_finalizer_fn old_finalizer;
100153 +
100154 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100155 +{
100156 + const char *color;
100157 + char *newprefix;
100158 +
100159 + switch (diagnostic->kind) {
100160 + case DK_NOTE:
100161 + color = LIGHTBLUE;
100162 + break;
100163 +
100164 + case DK_PEDWARN:
100165 + case DK_WARNING:
100166 + color = LIGHTYELLOW;
100167 + break;
100168 +
100169 + case DK_ERROR:
100170 + case DK_FATAL:
100171 + case DK_ICE:
100172 + case DK_PERMERROR:
100173 + case DK_SORRY:
100174 + color = LIGHTRED;
100175 + break;
100176 +
100177 + default:
100178 + color = NORMAL;
100179 + }
100180 +
100181 + old_starter(context, diagnostic);
100182 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
100183 + return;
100184 + pp_destroy_prefix(context->printer);
100185 + pp_set_prefix(context->printer, newprefix);
100186 +}
100187 +
100188 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100189 +{
100190 + old_finalizer(context, diagnostic);
100191 +}
100192 +
100193 +static void colorize_arm(void)
100194 +{
100195 + old_starter = diagnostic_starter(global_dc);
100196 + old_finalizer = diagnostic_finalizer(global_dc);
100197 +
100198 + diagnostic_starter(global_dc) = start_colorize;
100199 + diagnostic_finalizer(global_dc) = finalize_colorize;
100200 +}
100201 +
100202 +static unsigned int execute_colorize_rearm(void)
100203 +{
100204 + if (diagnostic_starter(global_dc) == start_colorize)
100205 + return 0;
100206 +
100207 + colorize_arm();
100208 + return 0;
100209 +}
100210 +
100211 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
100212 + .pass = {
100213 + .type = SIMPLE_IPA_PASS,
100214 + .name = "colorize_rearm",
100215 +#if BUILDING_GCC_VERSION >= 4008
100216 + .optinfo_flags = OPTGROUP_NONE,
100217 +#endif
100218 + .gate = NULL,
100219 + .execute = execute_colorize_rearm,
100220 + .sub = NULL,
100221 + .next = NULL,
100222 + .static_pass_number = 0,
100223 + .tv_id = TV_NONE,
100224 + .properties_required = 0,
100225 + .properties_provided = 0,
100226 + .properties_destroyed = 0,
100227 + .todo_flags_start = 0,
100228 + .todo_flags_finish = 0
100229 + }
100230 +};
100231 +
100232 +static void colorize_start_unit(void *gcc_data, void *user_data)
100233 +{
100234 + colorize_arm();
100235 +}
100236 +
100237 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100238 +{
100239 + const char * const plugin_name = plugin_info->base_name;
100240 + struct register_pass_info colorize_rearm_pass_info = {
100241 + .pass = &pass_ipa_colorize_rearm.pass,
100242 + .reference_pass_name = "*free_lang_data",
100243 + .ref_pass_instance_number = 1,
100244 + .pos_op = PASS_POS_INSERT_AFTER
100245 + };
100246 +
100247 + if (!plugin_default_version_check(version, &gcc_version)) {
100248 + error(G_("incompatible gcc/plugin versions"));
100249 + return 1;
100250 + }
100251 +
100252 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
100253 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
100254 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
100255 + return 0;
100256 +}
100257 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
100258 new file mode 100644
100259 index 0000000..c17312d
100260 --- /dev/null
100261 +++ b/tools/gcc/constify_plugin.c
100262 @@ -0,0 +1,560 @@
100263 +/*
100264 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
100265 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
100266 + * Licensed under the GPL v2, or (at your option) v3
100267 + *
100268 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
100269 + *
100270 + * Homepage:
100271 + * http://www.grsecurity.net/~ephox/const_plugin/
100272 + *
100273 + * Usage:
100274 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
100275 + * $ gcc -fplugin=constify_plugin.so test.c -O2
100276 + */
100277 +
100278 +#include "gcc-plugin.h"
100279 +#include "config.h"
100280 +#include "system.h"
100281 +#include "coretypes.h"
100282 +#include "tree.h"
100283 +#include "tree-pass.h"
100284 +#include "flags.h"
100285 +#include "intl.h"
100286 +#include "toplev.h"
100287 +#include "plugin.h"
100288 +#include "diagnostic.h"
100289 +#include "plugin-version.h"
100290 +#include "tm.h"
100291 +#include "function.h"
100292 +#include "basic-block.h"
100293 +#include "gimple.h"
100294 +#include "rtl.h"
100295 +#include "emit-rtl.h"
100296 +#include "tree-flow.h"
100297 +#include "target.h"
100298 +#include "langhooks.h"
100299 +
100300 +// should come from c-tree.h if only it were installed for gcc 4.5...
100301 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
100302 +
100303 +// unused type flag in all versions 4.5-4.8
100304 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
100305 +
100306 +int plugin_is_GPL_compatible;
100307 +
100308 +static struct plugin_info const_plugin_info = {
100309 + .version = "201305231310",
100310 + .help = "no-constify\tturn off constification\n",
100311 +};
100312 +
100313 +typedef struct {
100314 + bool has_fptr_field;
100315 + bool has_writable_field;
100316 + bool has_do_const_field;
100317 + bool has_no_const_field;
100318 +} constify_info;
100319 +
100320 +static const_tree get_field_type(const_tree field)
100321 +{
100322 + return strip_array_types(TREE_TYPE(field));
100323 +}
100324 +
100325 +static bool is_fptr(const_tree field)
100326 +{
100327 + const_tree ptr = get_field_type(field);
100328 +
100329 + if (TREE_CODE(ptr) != POINTER_TYPE)
100330 + return false;
100331 +
100332 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
100333 +}
100334 +
100335 +/*
100336 + * determine whether the given structure type meets the requirements for automatic constification,
100337 + * including the constification attributes on nested structure types
100338 + */
100339 +static void constifiable(const_tree node, constify_info *cinfo)
100340 +{
100341 + const_tree field;
100342 +
100343 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100344 +
100345 + // e.g., pointer to structure fields while still constructing the structure type
100346 + if (TYPE_FIELDS(node) == NULL_TREE)
100347 + return;
100348 +
100349 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
100350 + const_tree type = get_field_type(field);
100351 + enum tree_code code = TREE_CODE(type);
100352 +
100353 + if (node == type)
100354 + continue;
100355 +
100356 + if (is_fptr(field))
100357 + cinfo->has_fptr_field = true;
100358 + else if (!TREE_READONLY(field))
100359 + cinfo->has_writable_field = true;
100360 +
100361 + if (code == RECORD_TYPE || code == UNION_TYPE) {
100362 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100363 + cinfo->has_do_const_field = true;
100364 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
100365 + cinfo->has_no_const_field = true;
100366 + else
100367 + constifiable(type, cinfo);
100368 + }
100369 + }
100370 +}
100371 +
100372 +static bool constified(const_tree node)
100373 +{
100374 + constify_info cinfo = {
100375 + .has_fptr_field = false,
100376 + .has_writable_field = false,
100377 + .has_do_const_field = false,
100378 + .has_no_const_field = false
100379 + };
100380 +
100381 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100382 +
100383 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
100384 + gcc_assert(!TYPE_READONLY(node));
100385 + return false;
100386 + }
100387 +
100388 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
100389 + gcc_assert(TYPE_READONLY(node));
100390 + return true;
100391 + }
100392 +
100393 + constifiable(node, &cinfo);
100394 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
100395 + return false;
100396 +
100397 + return TYPE_READONLY(node);
100398 +}
100399 +
100400 +static void deconstify_tree(tree node);
100401 +
100402 +static void deconstify_type(tree type)
100403 +{
100404 + tree field;
100405 +
100406 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
100407 +
100408 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
100409 + const_tree fieldtype = get_field_type(field);
100410 +
100411 + // special case handling of simple ptr-to-same-array-type members
100412 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
100413 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
100414 +
100415 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
100416 + continue;
100417 + if (TREE_TYPE(TREE_TYPE(field)) == type)
100418 + continue;
100419 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
100420 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
100421 + TREE_TYPE(TREE_TYPE(field)) = type;
100422 + }
100423 + continue;
100424 + }
100425 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
100426 + continue;
100427 + if (!constified(fieldtype))
100428 + continue;
100429 +
100430 + deconstify_tree(field);
100431 + TREE_READONLY(field) = 0;
100432 + }
100433 + TYPE_READONLY(type) = 0;
100434 + C_TYPE_FIELDS_READONLY(type) = 0;
100435 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100436 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
100437 +}
100438 +
100439 +static void deconstify_tree(tree node)
100440 +{
100441 + tree old_type, new_type, field;
100442 +
100443 + old_type = TREE_TYPE(node);
100444 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
100445 + node = TREE_TYPE(node) = copy_node(old_type);
100446 + old_type = TREE_TYPE(old_type);
100447 + }
100448 +
100449 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
100450 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
100451 +
100452 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
100453 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
100454 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
100455 + DECL_FIELD_CONTEXT(field) = new_type;
100456 +
100457 + deconstify_type(new_type);
100458 +
100459 + TREE_TYPE(node) = new_type;
100460 +}
100461 +
100462 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100463 +{
100464 + tree type;
100465 + constify_info cinfo = {
100466 + .has_fptr_field = false,
100467 + .has_writable_field = false,
100468 + .has_do_const_field = false,
100469 + .has_no_const_field = false
100470 + };
100471 +
100472 + *no_add_attrs = true;
100473 + if (TREE_CODE(*node) == FUNCTION_DECL) {
100474 + error("%qE attribute does not apply to functions", name);
100475 + return NULL_TREE;
100476 + }
100477 +
100478 + if (TREE_CODE(*node) == PARM_DECL) {
100479 + error("%qE attribute does not apply to function parameters", name);
100480 + return NULL_TREE;
100481 + }
100482 +
100483 + if (TREE_CODE(*node) == VAR_DECL) {
100484 + error("%qE attribute does not apply to variables", name);
100485 + return NULL_TREE;
100486 + }
100487 +
100488 + if (TYPE_P(*node)) {
100489 + *no_add_attrs = false;
100490 + type = *node;
100491 + } else {
100492 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100493 + type = TREE_TYPE(*node);
100494 + }
100495 +
100496 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100497 + error("%qE attribute applies to struct and union types only", name);
100498 + return NULL_TREE;
100499 + }
100500 +
100501 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100502 + error("%qE attribute is already applied to the type", name);
100503 + return NULL_TREE;
100504 + }
100505 +
100506 + if (TYPE_P(*node)) {
100507 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100508 + error("%qE attribute is incompatible with 'do_const'", name);
100509 + return NULL_TREE;
100510 + }
100511 +
100512 + constifiable(type, &cinfo);
100513 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100514 + deconstify_tree(*node);
100515 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100516 + return NULL_TREE;
100517 + }
100518 +
100519 + error("%qE attribute used on type that is not constified", name);
100520 + return NULL_TREE;
100521 +}
100522 +
100523 +static void constify_type(tree type)
100524 +{
100525 + TYPE_READONLY(type) = 1;
100526 + C_TYPE_FIELDS_READONLY(type) = 1;
100527 + TYPE_CONSTIFY_VISITED(type) = 1;
100528 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100529 +}
100530 +
100531 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100532 +{
100533 + *no_add_attrs = true;
100534 + if (!TYPE_P(*node)) {
100535 + error("%qE attribute applies to types only", name);
100536 + return NULL_TREE;
100537 + }
100538 +
100539 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
100540 + error("%qE attribute applies to struct and union types only", name);
100541 + return NULL_TREE;
100542 + }
100543 +
100544 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
100545 + error("%qE attribute is already applied to the type", name);
100546 + return NULL_TREE;
100547 + }
100548 +
100549 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
100550 + error("%qE attribute is incompatible with 'no_const'", name);
100551 + return NULL_TREE;
100552 + }
100553 +
100554 + *no_add_attrs = false;
100555 + return NULL_TREE;
100556 +}
100557 +
100558 +static struct attribute_spec no_const_attr = {
100559 + .name = "no_const",
100560 + .min_length = 0,
100561 + .max_length = 0,
100562 + .decl_required = false,
100563 + .type_required = false,
100564 + .function_type_required = false,
100565 + .handler = handle_no_const_attribute,
100566 +#if BUILDING_GCC_VERSION >= 4007
100567 + .affects_type_identity = true
100568 +#endif
100569 +};
100570 +
100571 +static struct attribute_spec do_const_attr = {
100572 + .name = "do_const",
100573 + .min_length = 0,
100574 + .max_length = 0,
100575 + .decl_required = false,
100576 + .type_required = false,
100577 + .function_type_required = false,
100578 + .handler = handle_do_const_attribute,
100579 +#if BUILDING_GCC_VERSION >= 4007
100580 + .affects_type_identity = true
100581 +#endif
100582 +};
100583 +
100584 +static void register_attributes(void *event_data, void *data)
100585 +{
100586 + register_attribute(&no_const_attr);
100587 + register_attribute(&do_const_attr);
100588 +}
100589 +
100590 +static void finish_type(void *event_data, void *data)
100591 +{
100592 + tree type = (tree)event_data;
100593 + constify_info cinfo = {
100594 + .has_fptr_field = false,
100595 + .has_writable_field = false,
100596 + .has_do_const_field = false,
100597 + .has_no_const_field = false
100598 + };
100599 +
100600 + if (type == NULL_TREE || type == error_mark_node)
100601 + return;
100602 +
100603 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
100604 + return;
100605 +
100606 + constifiable(type, &cinfo);
100607 +
100608 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
100609 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100610 + return;
100611 + if (cinfo.has_writable_field)
100612 + return;
100613 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
100614 + return;
100615 + }
100616 +
100617 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
100618 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
100619 + deconstify_type(type);
100620 + TYPE_CONSTIFY_VISITED(type) = 1;
100621 + } else
100622 + error("'no_const' attribute used on type that is not constified");
100623 + return;
100624 + }
100625 +
100626 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100627 + constify_type(type);
100628 + return;
100629 + }
100630 +
100631 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
100632 + constify_type(type);
100633 + return;
100634 + }
100635 +
100636 + deconstify_type(type);
100637 + TYPE_CONSTIFY_VISITED(type) = 1;
100638 +}
100639 +
100640 +static void check_global_variables(void)
100641 +{
100642 + struct varpool_node *node;
100643 +
100644 +#if BUILDING_GCC_VERSION <= 4007
100645 + for (node = varpool_nodes; node; node = node->next) {
100646 + tree var = node->decl;
100647 +#else
100648 + FOR_EACH_VARIABLE(node) {
100649 + tree var = node->symbol.decl;
100650 +#endif
100651 + tree type = TREE_TYPE(var);
100652 +
100653 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100654 + continue;
100655 +
100656 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100657 + continue;
100658 +
100659 + if (!TYPE_CONSTIFY_VISITED(type))
100660 + continue;
100661 +
100662 + if (DECL_EXTERNAL(var))
100663 + continue;
100664 +
100665 + if (DECL_INITIAL(var))
100666 + continue;
100667 +
100668 + // this works around a gcc bug/feature where uninitialized globals
100669 + // are moved into the .bss section regardless of any constification
100670 + DECL_INITIAL(var) = build_constructor(type, NULL);
100671 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
100672 + }
100673 +}
100674 +
100675 +static unsigned int check_local_variables(void)
100676 +{
100677 + unsigned int ret = 0;
100678 + tree var;
100679 +
100680 +#if BUILDING_GCC_VERSION == 4005
100681 + tree vars;
100682 +#else
100683 + unsigned int i;
100684 +#endif
100685 +
100686 +#if BUILDING_GCC_VERSION == 4005
100687 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
100688 + var = TREE_VALUE(vars);
100689 +#else
100690 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
100691 +#endif
100692 + tree type = TREE_TYPE(var);
100693 +
100694 + gcc_assert(DECL_P(var));
100695 + if (is_global_var(var))
100696 + continue;
100697 +
100698 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100699 + continue;
100700 +
100701 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100702 + continue;
100703 +
100704 + if (!TYPE_CONSTIFY_VISITED(type))
100705 + continue;
100706 +
100707 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
100708 + ret = 1;
100709 + }
100710 + return ret;
100711 +}
100712 +
100713 +static unsigned int check_variables(void)
100714 +{
100715 + check_global_variables();
100716 + return check_local_variables();
100717 +}
100718 +
100719 + unsigned int ret = 0;
100720 +static struct gimple_opt_pass pass_local_variable = {
100721 + {
100722 + .type = GIMPLE_PASS,
100723 + .name = "check_variables",
100724 +#if BUILDING_GCC_VERSION >= 4008
100725 + .optinfo_flags = OPTGROUP_NONE,
100726 +#endif
100727 + .gate = NULL,
100728 + .execute = check_variables,
100729 + .sub = NULL,
100730 + .next = NULL,
100731 + .static_pass_number = 0,
100732 + .tv_id = TV_NONE,
100733 + .properties_required = 0,
100734 + .properties_provided = 0,
100735 + .properties_destroyed = 0,
100736 + .todo_flags_start = 0,
100737 + .todo_flags_finish = 0
100738 + }
100739 +};
100740 +
100741 +static struct {
100742 + const char *name;
100743 + const char *asm_op;
100744 +} sections[] = {
100745 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
100746 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
100747 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
100748 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
100749 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
100750 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
100751 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
100752 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
100753 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
100754 +};
100755 +
100756 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
100757 +
100758 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
100759 +{
100760 + size_t i;
100761 +
100762 + for (i = 0; i < ARRAY_SIZE(sections); i++)
100763 + if (!strcmp(sections[i].name, name))
100764 + return 0;
100765 + return old_section_type_flags(decl, name, reloc);
100766 +}
100767 +
100768 +static void constify_start_unit(void *gcc_data, void *user_data)
100769 +{
100770 +// size_t i;
100771 +
100772 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
100773 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
100774 +// sections[i].section = get_section(sections[i].name, 0, NULL);
100775 +
100776 + old_section_type_flags = targetm.section_type_flags;
100777 + targetm.section_type_flags = constify_section_type_flags;
100778 +}
100779 +
100780 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100781 +{
100782 + const char * const plugin_name = plugin_info->base_name;
100783 + const int argc = plugin_info->argc;
100784 + const struct plugin_argument * const argv = plugin_info->argv;
100785 + int i;
100786 + bool constify = true;
100787 +
100788 + struct register_pass_info local_variable_pass_info = {
100789 + .pass = &pass_local_variable.pass,
100790 + .reference_pass_name = "ssa",
100791 + .ref_pass_instance_number = 1,
100792 + .pos_op = PASS_POS_INSERT_BEFORE
100793 + };
100794 +
100795 + if (!plugin_default_version_check(version, &gcc_version)) {
100796 + error(G_("incompatible gcc/plugin versions"));
100797 + return 1;
100798 + }
100799 +
100800 + for (i = 0; i < argc; ++i) {
100801 + if (!(strcmp(argv[i].key, "no-constify"))) {
100802 + constify = false;
100803 + continue;
100804 + }
100805 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100806 + }
100807 +
100808 + if (strcmp(lang_hooks.name, "GNU C")) {
100809 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
100810 + constify = false;
100811 + }
100812 +
100813 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
100814 + if (constify) {
100815 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
100816 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
100817 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
100818 + }
100819 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
100820 +
100821 + return 0;
100822 +}
100823 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
100824 new file mode 100644
100825 index 0000000..e518932
100826 --- /dev/null
100827 +++ b/tools/gcc/generate_size_overflow_hash.sh
100828 @@ -0,0 +1,94 @@
100829 +#!/bin/bash
100830 +
100831 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
100832 +
100833 +header1="size_overflow_hash.h"
100834 +database="size_overflow_hash.data"
100835 +n=65536
100836 +
100837 +usage() {
100838 +cat <<EOF
100839 +usage: $0 options
100840 +OPTIONS:
100841 + -h|--help help
100842 + -o header file
100843 + -d database file
100844 + -n hash array size
100845 +EOF
100846 + return 0
100847 +}
100848 +
100849 +while true
100850 +do
100851 + case "$1" in
100852 + -h|--help) usage && exit 0;;
100853 + -n) n=$2; shift 2;;
100854 + -o) header1="$2"; shift 2;;
100855 + -d) database="$2"; shift 2;;
100856 + --) shift 1; break ;;
100857 + *) break ;;
100858 + esac
100859 +done
100860 +
100861 +create_defines() {
100862 + for i in `seq 0 31`
100863 + do
100864 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
100865 + done
100866 + echo >> "$header1"
100867 +}
100868 +
100869 +create_structs() {
100870 + rm -f "$header1"
100871 +
100872 + create_defines
100873 +
100874 + cat "$database" | while read data
100875 + do
100876 + data_array=($data)
100877 + struct_hash_name="${data_array[0]}"
100878 + funcn="${data_array[1]}"
100879 + params="${data_array[2]}"
100880 + next="${data_array[4]}"
100881 +
100882 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
100883 +
100884 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
100885 + echo -en "\t.param\t= " >> "$header1"
100886 + line=
100887 + for param_num in ${params//-/ };
100888 + do
100889 + line="${line}PARAM"$param_num"|"
100890 + done
100891 +
100892 + echo -e "${line%?},\n};\n" >> "$header1"
100893 + done
100894 +}
100895 +
100896 +create_headers() {
100897 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
100898 +}
100899 +
100900 +create_array_elements() {
100901 + index=0
100902 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
100903 + do
100904 + data_array=($data)
100905 + i="${data_array[3]}"
100906 + hash="${data_array[0]}"
100907 + while [[ $index -lt $i ]]
100908 + do
100909 + echo -e "\t["$index"]\t= NULL," >> "$header1"
100910 + index=$(($index + 1))
100911 + done
100912 + index=$(($index + 1))
100913 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
100914 + done
100915 + echo '};' >> $header1
100916 +}
100917 +
100918 +create_structs
100919 +create_headers
100920 +create_array_elements
100921 +
100922 +exit 0
100923 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
100924 new file mode 100644
100925 index 0000000..568b360
100926 --- /dev/null
100927 +++ b/tools/gcc/kallocstat_plugin.c
100928 @@ -0,0 +1,170 @@
100929 +/*
100930 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100931 + * Licensed under the GPL v2
100932 + *
100933 + * Note: the choice of the license means that the compilation process is
100934 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100935 + * but for the kernel it doesn't matter since it doesn't link against
100936 + * any of the gcc libraries
100937 + *
100938 + * gcc plugin to find the distribution of k*alloc sizes
100939 + *
100940 + * TODO:
100941 + *
100942 + * BUGS:
100943 + * - none known
100944 + */
100945 +#include "gcc-plugin.h"
100946 +#include "config.h"
100947 +#include "system.h"
100948 +#include "coretypes.h"
100949 +#include "tree.h"
100950 +#include "tree-pass.h"
100951 +#include "flags.h"
100952 +#include "intl.h"
100953 +#include "toplev.h"
100954 +#include "plugin.h"
100955 +//#include "expr.h" where are you...
100956 +#include "diagnostic.h"
100957 +#include "plugin-version.h"
100958 +#include "tm.h"
100959 +#include "function.h"
100960 +#include "basic-block.h"
100961 +#include "gimple.h"
100962 +#include "rtl.h"
100963 +#include "emit-rtl.h"
100964 +
100965 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100966 +
100967 +int plugin_is_GPL_compatible;
100968 +
100969 +static const char * const kalloc_functions[] = {
100970 + "__kmalloc",
100971 + "kmalloc",
100972 + "kmalloc_large",
100973 + "kmalloc_node",
100974 + "kmalloc_order",
100975 + "kmalloc_order_trace",
100976 + "kmalloc_slab",
100977 + "kzalloc",
100978 + "kzalloc_node",
100979 +};
100980 +
100981 +static struct plugin_info kallocstat_plugin_info = {
100982 + .version = "201302112000",
100983 +};
100984 +
100985 +static unsigned int execute_kallocstat(void);
100986 +
100987 +static struct gimple_opt_pass kallocstat_pass = {
100988 + .pass = {
100989 + .type = GIMPLE_PASS,
100990 + .name = "kallocstat",
100991 +#if BUILDING_GCC_VERSION >= 4008
100992 + .optinfo_flags = OPTGROUP_NONE,
100993 +#endif
100994 + .gate = NULL,
100995 + .execute = execute_kallocstat,
100996 + .sub = NULL,
100997 + .next = NULL,
100998 + .static_pass_number = 0,
100999 + .tv_id = TV_NONE,
101000 + .properties_required = 0,
101001 + .properties_provided = 0,
101002 + .properties_destroyed = 0,
101003 + .todo_flags_start = 0,
101004 + .todo_flags_finish = 0
101005 + }
101006 +};
101007 +
101008 +static bool is_kalloc(const char *fnname)
101009 +{
101010 + size_t i;
101011 +
101012 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
101013 + if (!strcmp(fnname, kalloc_functions[i]))
101014 + return true;
101015 + return false;
101016 +}
101017 +
101018 +static unsigned int execute_kallocstat(void)
101019 +{
101020 + basic_block bb;
101021 +
101022 + // 1. loop through BBs and GIMPLE statements
101023 + FOR_EACH_BB(bb) {
101024 + gimple_stmt_iterator gsi;
101025 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101026 + // gimple match:
101027 + tree fndecl, size;
101028 + gimple call_stmt;
101029 + const char *fnname;
101030 +
101031 + // is it a call
101032 + call_stmt = gsi_stmt(gsi);
101033 + if (!is_gimple_call(call_stmt))
101034 + continue;
101035 + fndecl = gimple_call_fndecl(call_stmt);
101036 + if (fndecl == NULL_TREE)
101037 + continue;
101038 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
101039 + continue;
101040 +
101041 + // is it a call to k*alloc
101042 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
101043 + if (!is_kalloc(fnname))
101044 + continue;
101045 +
101046 + // is the size arg the result of a simple const assignment
101047 + size = gimple_call_arg(call_stmt, 0);
101048 + while (true) {
101049 + gimple def_stmt;
101050 + expanded_location xloc;
101051 + size_t size_val;
101052 +
101053 + if (TREE_CODE(size) != SSA_NAME)
101054 + break;
101055 + def_stmt = SSA_NAME_DEF_STMT(size);
101056 + if (!def_stmt || !is_gimple_assign(def_stmt))
101057 + break;
101058 + if (gimple_num_ops(def_stmt) != 2)
101059 + break;
101060 + size = gimple_assign_rhs1(def_stmt);
101061 + if (!TREE_CONSTANT(size))
101062 + continue;
101063 + xloc = expand_location(gimple_location(def_stmt));
101064 + if (!xloc.file)
101065 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101066 + size_val = TREE_INT_CST_LOW(size);
101067 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
101068 + break;
101069 + }
101070 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101071 +//debug_tree(gimple_call_fn(call_stmt));
101072 +//print_node(stderr, "pax", fndecl, 4);
101073 + }
101074 + }
101075 +
101076 + return 0;
101077 +}
101078 +
101079 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101080 +{
101081 + const char * const plugin_name = plugin_info->base_name;
101082 + struct register_pass_info kallocstat_pass_info = {
101083 + .pass = &kallocstat_pass.pass,
101084 + .reference_pass_name = "ssa",
101085 + .ref_pass_instance_number = 1,
101086 + .pos_op = PASS_POS_INSERT_AFTER
101087 + };
101088 +
101089 + if (!plugin_default_version_check(version, &gcc_version)) {
101090 + error(G_("incompatible gcc/plugin versions"));
101091 + return 1;
101092 + }
101093 +
101094 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
101095 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
101096 +
101097 + return 0;
101098 +}
101099 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
101100 new file mode 100644
101101 index 0000000..698da67
101102 --- /dev/null
101103 +++ b/tools/gcc/kernexec_plugin.c
101104 @@ -0,0 +1,471 @@
101105 +/*
101106 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101107 + * Licensed under the GPL v2
101108 + *
101109 + * Note: the choice of the license means that the compilation process is
101110 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101111 + * but for the kernel it doesn't matter since it doesn't link against
101112 + * any of the gcc libraries
101113 + *
101114 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
101115 + *
101116 + * TODO:
101117 + *
101118 + * BUGS:
101119 + * - none known
101120 + */
101121 +#include "gcc-plugin.h"
101122 +#include "config.h"
101123 +#include "system.h"
101124 +#include "coretypes.h"
101125 +#include "tree.h"
101126 +#include "tree-pass.h"
101127 +#include "flags.h"
101128 +#include "intl.h"
101129 +#include "toplev.h"
101130 +#include "plugin.h"
101131 +//#include "expr.h" where are you...
101132 +#include "diagnostic.h"
101133 +#include "plugin-version.h"
101134 +#include "tm.h"
101135 +#include "function.h"
101136 +#include "basic-block.h"
101137 +#include "gimple.h"
101138 +#include "rtl.h"
101139 +#include "emit-rtl.h"
101140 +#include "tree-flow.h"
101141 +
101142 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101143 +extern rtx emit_move_insn(rtx x, rtx y);
101144 +
101145 +#if BUILDING_GCC_VERSION <= 4006
101146 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
101147 +#endif
101148 +
101149 +#if BUILDING_GCC_VERSION >= 4008
101150 +#define TODO_dump_func 0
101151 +#endif
101152 +
101153 +int plugin_is_GPL_compatible;
101154 +
101155 +static struct plugin_info kernexec_plugin_info = {
101156 + .version = "201308230150",
101157 + .help = "method=[bts|or]\tinstrumentation method\n"
101158 +};
101159 +
101160 +static unsigned int execute_kernexec_reload(void);
101161 +static unsigned int execute_kernexec_fptr(void);
101162 +static unsigned int execute_kernexec_retaddr(void);
101163 +static bool kernexec_cmodel_check(void);
101164 +
101165 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
101166 +static void (*kernexec_instrument_retaddr)(rtx);
101167 +
101168 +static struct gimple_opt_pass kernexec_reload_pass = {
101169 + .pass = {
101170 + .type = GIMPLE_PASS,
101171 + .name = "kernexec_reload",
101172 +#if BUILDING_GCC_VERSION >= 4008
101173 + .optinfo_flags = OPTGROUP_NONE,
101174 +#endif
101175 + .gate = kernexec_cmodel_check,
101176 + .execute = execute_kernexec_reload,
101177 + .sub = NULL,
101178 + .next = NULL,
101179 + .static_pass_number = 0,
101180 + .tv_id = TV_NONE,
101181 + .properties_required = 0,
101182 + .properties_provided = 0,
101183 + .properties_destroyed = 0,
101184 + .todo_flags_start = 0,
101185 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101186 + }
101187 +};
101188 +
101189 +static struct gimple_opt_pass kernexec_fptr_pass = {
101190 + .pass = {
101191 + .type = GIMPLE_PASS,
101192 + .name = "kernexec_fptr",
101193 +#if BUILDING_GCC_VERSION >= 4008
101194 + .optinfo_flags = OPTGROUP_NONE,
101195 +#endif
101196 + .gate = kernexec_cmodel_check,
101197 + .execute = execute_kernexec_fptr,
101198 + .sub = NULL,
101199 + .next = NULL,
101200 + .static_pass_number = 0,
101201 + .tv_id = TV_NONE,
101202 + .properties_required = 0,
101203 + .properties_provided = 0,
101204 + .properties_destroyed = 0,
101205 + .todo_flags_start = 0,
101206 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101207 + }
101208 +};
101209 +
101210 +static struct rtl_opt_pass kernexec_retaddr_pass = {
101211 + .pass = {
101212 + .type = RTL_PASS,
101213 + .name = "kernexec_retaddr",
101214 +#if BUILDING_GCC_VERSION >= 4008
101215 + .optinfo_flags = OPTGROUP_NONE,
101216 +#endif
101217 + .gate = kernexec_cmodel_check,
101218 + .execute = execute_kernexec_retaddr,
101219 + .sub = NULL,
101220 + .next = NULL,
101221 + .static_pass_number = 0,
101222 + .tv_id = TV_NONE,
101223 + .properties_required = 0,
101224 + .properties_provided = 0,
101225 + .properties_destroyed = 0,
101226 + .todo_flags_start = 0,
101227 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
101228 + }
101229 +};
101230 +
101231 +static bool kernexec_cmodel_check(void)
101232 +{
101233 + tree section;
101234 +
101235 + if (ix86_cmodel != CM_KERNEL)
101236 + return false;
101237 +
101238 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
101239 + if (!section || !TREE_VALUE(section))
101240 + return true;
101241 +
101242 + section = TREE_VALUE(TREE_VALUE(section));
101243 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
101244 + return true;
101245 +
101246 + return false;
101247 +}
101248 +
101249 +/*
101250 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
101251 + */
101252 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
101253 +{
101254 + gimple asm_movabs_stmt;
101255 +
101256 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
101257 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
101258 + gimple_asm_set_volatile(asm_movabs_stmt, true);
101259 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
101260 + update_stmt(asm_movabs_stmt);
101261 +}
101262 +
101263 +/*
101264 + * find all asm() stmts that clobber r10 and add a reload of r10
101265 + */
101266 +static unsigned int execute_kernexec_reload(void)
101267 +{
101268 + basic_block bb;
101269 +
101270 + // 1. loop through BBs and GIMPLE statements
101271 + FOR_EACH_BB(bb) {
101272 + gimple_stmt_iterator gsi;
101273 +
101274 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101275 + // gimple match: __asm__ ("" : : : "r10");
101276 + gimple asm_stmt;
101277 + size_t nclobbers;
101278 +
101279 + // is it an asm ...
101280 + asm_stmt = gsi_stmt(gsi);
101281 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
101282 + continue;
101283 +
101284 + // ... clobbering r10
101285 + nclobbers = gimple_asm_nclobbers(asm_stmt);
101286 + while (nclobbers--) {
101287 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
101288 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
101289 + continue;
101290 + kernexec_reload_fptr_mask(&gsi);
101291 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
101292 + break;
101293 + }
101294 + }
101295 + }
101296 +
101297 + return 0;
101298 +}
101299 +
101300 +/*
101301 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
101302 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
101303 + */
101304 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
101305 +{
101306 + gimple assign_intptr, assign_new_fptr, call_stmt;
101307 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
101308 +
101309 + call_stmt = gsi_stmt(*gsi);
101310 + old_fptr = gimple_call_fn(call_stmt);
101311 +
101312 + // create temporary unsigned long variable used for bitops and cast fptr to it
101313 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
101314 +#if BUILDING_GCC_VERSION <= 4007
101315 + add_referenced_var(intptr);
101316 +#endif
101317 + intptr = make_ssa_name(intptr, NULL);
101318 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
101319 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101320 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101321 + update_stmt(assign_intptr);
101322 +
101323 + // apply logical or to temporary unsigned long and bitmask
101324 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
101325 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
101326 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
101327 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
101328 + assign_intptr = gimple_build_assign(intptr, orptr);
101329 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101330 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101331 + update_stmt(assign_intptr);
101332 +
101333 + // cast temporary unsigned long back to a temporary fptr variable
101334 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
101335 +#if BUILDING_GCC_VERSION <= 4007
101336 + add_referenced_var(new_fptr);
101337 +#endif
101338 + new_fptr = make_ssa_name(new_fptr, NULL);
101339 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
101340 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
101341 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
101342 + update_stmt(assign_new_fptr);
101343 +
101344 + // replace call stmt fn with the new fptr
101345 + gimple_call_set_fn(call_stmt, new_fptr);
101346 + update_stmt(call_stmt);
101347 +}
101348 +
101349 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
101350 +{
101351 + gimple asm_or_stmt, call_stmt;
101352 + tree old_fptr, new_fptr, input, output;
101353 +#if BUILDING_GCC_VERSION <= 4007
101354 + VEC(tree, gc) *inputs = NULL;
101355 + VEC(tree, gc) *outputs = NULL;
101356 +#else
101357 + vec<tree, va_gc> *inputs = NULL;
101358 + vec<tree, va_gc> *outputs = NULL;
101359 +#endif
101360 +
101361 + call_stmt = gsi_stmt(*gsi);
101362 + old_fptr = gimple_call_fn(call_stmt);
101363 +
101364 + // create temporary fptr variable
101365 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
101366 +#if BUILDING_GCC_VERSION <= 4007
101367 + add_referenced_var(new_fptr);
101368 +#endif
101369 + new_fptr = make_ssa_name(new_fptr, NULL);
101370 +
101371 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
101372 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
101373 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
101374 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
101375 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
101376 +#if BUILDING_GCC_VERSION <= 4007
101377 + VEC_safe_push(tree, gc, inputs, input);
101378 + VEC_safe_push(tree, gc, outputs, output);
101379 +#else
101380 + vec_safe_push(inputs, input);
101381 + vec_safe_push(outputs, output);
101382 +#endif
101383 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
101384 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
101385 + gimple_asm_set_volatile(asm_or_stmt, true);
101386 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
101387 + update_stmt(asm_or_stmt);
101388 +
101389 + // replace call stmt fn with the new fptr
101390 + gimple_call_set_fn(call_stmt, new_fptr);
101391 + update_stmt(call_stmt);
101392 +}
101393 +
101394 +/*
101395 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
101396 + */
101397 +static unsigned int execute_kernexec_fptr(void)
101398 +{
101399 + basic_block bb;
101400 +
101401 + // 1. loop through BBs and GIMPLE statements
101402 + FOR_EACH_BB(bb) {
101403 + gimple_stmt_iterator gsi;
101404 +
101405 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101406 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
101407 + tree fn;
101408 + gimple call_stmt;
101409 +
101410 + // is it a call ...
101411 + call_stmt = gsi_stmt(gsi);
101412 + if (!is_gimple_call(call_stmt))
101413 + continue;
101414 + fn = gimple_call_fn(call_stmt);
101415 + if (TREE_CODE(fn) == ADDR_EXPR)
101416 + continue;
101417 + if (TREE_CODE(fn) != SSA_NAME)
101418 + gcc_unreachable();
101419 +
101420 + // ... through a function pointer
101421 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
101422 + fn = SSA_NAME_VAR(fn);
101423 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
101424 + debug_tree(fn);
101425 + gcc_unreachable();
101426 + }
101427 + }
101428 + fn = TREE_TYPE(fn);
101429 + if (TREE_CODE(fn) != POINTER_TYPE)
101430 + continue;
101431 + fn = TREE_TYPE(fn);
101432 + if (TREE_CODE(fn) != FUNCTION_TYPE)
101433 + continue;
101434 +
101435 + kernexec_instrument_fptr(&gsi);
101436 +
101437 +//debug_tree(gimple_call_fn(call_stmt));
101438 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101439 + }
101440 + }
101441 +
101442 + return 0;
101443 +}
101444 +
101445 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
101446 +static void kernexec_instrument_retaddr_bts(rtx insn)
101447 +{
101448 + rtx btsq;
101449 + rtvec argvec, constraintvec, labelvec;
101450 + int line;
101451 +
101452 + // create asm volatile("btsq $63,(%%rsp)":::)
101453 + argvec = rtvec_alloc(0);
101454 + constraintvec = rtvec_alloc(0);
101455 + labelvec = rtvec_alloc(0);
101456 + line = expand_location(RTL_LOCATION(insn)).line;
101457 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101458 + MEM_VOLATILE_P(btsq) = 1;
101459 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
101460 + emit_insn_before(btsq, insn);
101461 +}
101462 +
101463 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
101464 +static void kernexec_instrument_retaddr_or(rtx insn)
101465 +{
101466 + rtx orq;
101467 + rtvec argvec, constraintvec, labelvec;
101468 + int line;
101469 +
101470 + // create asm volatile("orq %%r10,(%%rsp)":::)
101471 + argvec = rtvec_alloc(0);
101472 + constraintvec = rtvec_alloc(0);
101473 + labelvec = rtvec_alloc(0);
101474 + line = expand_location(RTL_LOCATION(insn)).line;
101475 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101476 + MEM_VOLATILE_P(orq) = 1;
101477 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
101478 + emit_insn_before(orq, insn);
101479 +}
101480 +
101481 +/*
101482 + * find all asm level function returns and forcibly set the highest bit of the return address
101483 + */
101484 +static unsigned int execute_kernexec_retaddr(void)
101485 +{
101486 + rtx insn;
101487 +
101488 + // 1. find function returns
101489 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101490 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101491 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101492 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101493 + rtx body;
101494 +
101495 + // is it a retn
101496 + if (!JUMP_P(insn))
101497 + continue;
101498 + body = PATTERN(insn);
101499 + if (GET_CODE(body) == PARALLEL)
101500 + body = XVECEXP(body, 0, 0);
101501 + if (!ANY_RETURN_P(body))
101502 + continue;
101503 + kernexec_instrument_retaddr(insn);
101504 + }
101505 +
101506 +// print_simple_rtl(stderr, get_insns());
101507 +// print_rtl(stderr, get_insns());
101508 +
101509 + return 0;
101510 +}
101511 +
101512 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101513 +{
101514 + const char * const plugin_name = plugin_info->base_name;
101515 + const int argc = plugin_info->argc;
101516 + const struct plugin_argument * const argv = plugin_info->argv;
101517 + int i;
101518 + struct register_pass_info kernexec_reload_pass_info = {
101519 + .pass = &kernexec_reload_pass.pass,
101520 + .reference_pass_name = "ssa",
101521 + .ref_pass_instance_number = 1,
101522 + .pos_op = PASS_POS_INSERT_AFTER
101523 + };
101524 + struct register_pass_info kernexec_fptr_pass_info = {
101525 + .pass = &kernexec_fptr_pass.pass,
101526 + .reference_pass_name = "ssa",
101527 + .ref_pass_instance_number = 1,
101528 + .pos_op = PASS_POS_INSERT_AFTER
101529 + };
101530 + struct register_pass_info kernexec_retaddr_pass_info = {
101531 + .pass = &kernexec_retaddr_pass.pass,
101532 + .reference_pass_name = "pro_and_epilogue",
101533 + .ref_pass_instance_number = 1,
101534 + .pos_op = PASS_POS_INSERT_AFTER
101535 + };
101536 +
101537 + if (!plugin_default_version_check(version, &gcc_version)) {
101538 + error(G_("incompatible gcc/plugin versions"));
101539 + return 1;
101540 + }
101541 +
101542 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
101543 +
101544 + if (TARGET_64BIT == 0)
101545 + return 0;
101546 +
101547 + for (i = 0; i < argc; ++i) {
101548 + if (!strcmp(argv[i].key, "method")) {
101549 + if (!argv[i].value) {
101550 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101551 + continue;
101552 + }
101553 + if (!strcmp(argv[i].value, "bts")) {
101554 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
101555 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
101556 + } else if (!strcmp(argv[i].value, "or")) {
101557 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
101558 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
101559 + fix_register("r10", 1, 1);
101560 + } else
101561 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
101562 + continue;
101563 + }
101564 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101565 + }
101566 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
101567 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
101568 +
101569 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
101570 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
101571 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
101572 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
101573 +
101574 + return 0;
101575 +}
101576 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
101577 new file mode 100644
101578 index 0000000..679b9ef
101579 --- /dev/null
101580 +++ b/tools/gcc/latent_entropy_plugin.c
101581 @@ -0,0 +1,335 @@
101582 +/*
101583 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
101584 + * Licensed under the GPL v2
101585 + *
101586 + * Note: the choice of the license means that the compilation process is
101587 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101588 + * but for the kernel it doesn't matter since it doesn't link against
101589 + * any of the gcc libraries
101590 + *
101591 + * gcc plugin to help generate a little bit of entropy from program state,
101592 + * used during boot in the kernel
101593 + *
101594 + * TODO:
101595 + * - add ipa pass to identify not explicitly marked candidate functions
101596 + * - mix in more program state (function arguments/return values, loop variables, etc)
101597 + * - more instrumentation control via attribute parameters
101598 + *
101599 + * BUGS:
101600 + * - LTO needs -flto-partition=none for now
101601 + */
101602 +#include "gcc-plugin.h"
101603 +#include "config.h"
101604 +#include "system.h"
101605 +#include "coretypes.h"
101606 +#include "tree.h"
101607 +#include "tree-pass.h"
101608 +#include "flags.h"
101609 +#include "intl.h"
101610 +#include "toplev.h"
101611 +#include "plugin.h"
101612 +//#include "expr.h" where are you...
101613 +#include "diagnostic.h"
101614 +#include "plugin-version.h"
101615 +#include "tm.h"
101616 +#include "function.h"
101617 +#include "basic-block.h"
101618 +#include "gimple.h"
101619 +#include "rtl.h"
101620 +#include "emit-rtl.h"
101621 +#include "tree-flow.h"
101622 +#include "langhooks.h"
101623 +
101624 +#if BUILDING_GCC_VERSION >= 4008
101625 +#define TODO_dump_func 0
101626 +#endif
101627 +
101628 +int plugin_is_GPL_compatible;
101629 +
101630 +static tree latent_entropy_decl;
101631 +
101632 +static struct plugin_info latent_entropy_plugin_info = {
101633 + .version = "201308230230",
101634 + .help = NULL
101635 +};
101636 +
101637 +static unsigned int execute_latent_entropy(void);
101638 +static bool gate_latent_entropy(void);
101639 +
101640 +static struct gimple_opt_pass latent_entropy_pass = {
101641 + .pass = {
101642 + .type = GIMPLE_PASS,
101643 + .name = "latent_entropy",
101644 +#if BUILDING_GCC_VERSION >= 4008
101645 + .optinfo_flags = OPTGROUP_NONE,
101646 +#endif
101647 + .gate = gate_latent_entropy,
101648 + .execute = execute_latent_entropy,
101649 + .sub = NULL,
101650 + .next = NULL,
101651 + .static_pass_number = 0,
101652 + .tv_id = TV_NONE,
101653 + .properties_required = PROP_gimple_leh | PROP_cfg,
101654 + .properties_provided = 0,
101655 + .properties_destroyed = 0,
101656 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
101657 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
101658 + }
101659 +};
101660 +
101661 +static unsigned HOST_WIDE_INT seed;
101662 +static unsigned HOST_WIDE_INT get_random_const(void)
101663 +{
101664 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
101665 + return seed;
101666 +}
101667 +
101668 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101669 +{
101670 + switch (TREE_CODE(*node)) {
101671 + default:
101672 + *no_add_attrs = true;
101673 + error("%qE attribute only applies to functions and variables", name);
101674 + break;
101675 +
101676 + case VAR_DECL:
101677 + if (DECL_INITIAL(*node)) {
101678 + *no_add_attrs = true;
101679 + error("variable %qD with %qE attribute must not be initialized", *node, name);
101680 + break;
101681 + }
101682 + DECL_INITIAL(*node) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
101683 + break;
101684 +
101685 + case FUNCTION_DECL:
101686 + break;
101687 + }
101688 +
101689 + return NULL_TREE;
101690 +}
101691 +
101692 +static struct attribute_spec latent_entropy_attr = {
101693 + .name = "latent_entropy",
101694 + .min_length = 0,
101695 + .max_length = 0,
101696 + .decl_required = true,
101697 + .type_required = false,
101698 + .function_type_required = false,
101699 + .handler = handle_latent_entropy_attribute,
101700 +#if BUILDING_GCC_VERSION >= 4007
101701 + .affects_type_identity = false
101702 +#endif
101703 +};
101704 +
101705 +static void register_attributes(void *event_data, void *data)
101706 +{
101707 + register_attribute(&latent_entropy_attr);
101708 +}
101709 +
101710 +static bool gate_latent_entropy(void)
101711 +{
101712 + tree latent_entropy_attr;
101713 +
101714 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
101715 + return latent_entropy_attr != NULL_TREE;
101716 +}
101717 +
101718 +static enum tree_code get_op(tree *rhs)
101719 +{
101720 + static enum tree_code op;
101721 + unsigned HOST_WIDE_INT random_const;
101722 +
101723 + random_const = get_random_const();
101724 +
101725 + switch (op) {
101726 + case BIT_XOR_EXPR:
101727 + op = PLUS_EXPR;
101728 + break;
101729 +
101730 + case PLUS_EXPR:
101731 + if (rhs) {
101732 + op = LROTATE_EXPR;
101733 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
101734 + break;
101735 + }
101736 +
101737 + case LROTATE_EXPR:
101738 + default:
101739 + op = BIT_XOR_EXPR;
101740 + break;
101741 + }
101742 + if (rhs)
101743 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
101744 + return op;
101745 +}
101746 +
101747 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
101748 +{
101749 + gimple_stmt_iterator gsi;
101750 + gimple assign;
101751 + tree addxorrol, rhs;
101752 + enum tree_code op;
101753 +
101754 + op = get_op(&rhs);
101755 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
101756 + assign = gimple_build_assign(local_entropy, addxorrol);
101757 + gsi = gsi_after_labels(bb);
101758 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101759 + update_stmt(assign);
101760 +//debug_bb(bb);
101761 +}
101762 +
101763 +static void perturb_latent_entropy(basic_block bb, tree rhs)
101764 +{
101765 + gimple_stmt_iterator gsi;
101766 + gimple assign;
101767 + tree addxorrol, temp;
101768 +
101769 + // 1. create temporary copy of latent_entropy
101770 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
101771 +#if BUILDING_GCC_VERSION <= 4007
101772 + add_referenced_var(temp);
101773 +#endif
101774 +
101775 + // 2. read...
101776 + temp = make_ssa_name(temp, NULL);
101777 + assign = gimple_build_assign(temp, latent_entropy_decl);
101778 + SSA_NAME_DEF_STMT(temp) = assign;
101779 +#if BUILDING_GCC_VERSION <= 4007
101780 + add_referenced_var(latent_entropy_decl);
101781 +#endif
101782 + gsi = gsi_after_labels(bb);
101783 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101784 + update_stmt(assign);
101785 +
101786 + // 3. ...modify...
101787 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
101788 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
101789 + assign = gimple_build_assign(temp, addxorrol);
101790 + SSA_NAME_DEF_STMT(temp) = assign;
101791 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101792 + update_stmt(assign);
101793 +
101794 + // 4. ...write latent_entropy
101795 + assign = gimple_build_assign(latent_entropy_decl, temp);
101796 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101797 + update_stmt(assign);
101798 +}
101799 +
101800 +static unsigned int execute_latent_entropy(void)
101801 +{
101802 + basic_block bb;
101803 + gimple assign;
101804 + gimple_stmt_iterator gsi;
101805 + tree local_entropy;
101806 +
101807 + if (!latent_entropy_decl) {
101808 + struct varpool_node *node;
101809 +
101810 +#if BUILDING_GCC_VERSION <= 4007
101811 + for (node = varpool_nodes; node; node = node->next) {
101812 + tree var = node->decl;
101813 +#else
101814 + FOR_EACH_VARIABLE(node) {
101815 + tree var = node->symbol.decl;
101816 +#endif
101817 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
101818 + continue;
101819 + latent_entropy_decl = var;
101820 +// debug_tree(var);
101821 + break;
101822 + }
101823 + if (!latent_entropy_decl) {
101824 +// debug_tree(current_function_decl);
101825 + return 0;
101826 + }
101827 + }
101828 +
101829 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
101830 +
101831 + // 1. create local entropy variable
101832 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
101833 +#if BUILDING_GCC_VERSION <= 4007
101834 + add_referenced_var(local_entropy);
101835 + mark_sym_for_renaming(local_entropy);
101836 +#endif
101837 +
101838 + // 2. initialize local entropy variable
101839 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101840 + if (dom_info_available_p(CDI_DOMINATORS))
101841 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
101842 + gsi = gsi_start_bb(bb);
101843 +
101844 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
101845 +// gimple_set_location(assign, loc);
101846 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101847 + update_stmt(assign);
101848 +//debug_bb(bb);
101849 + bb = bb->next_bb;
101850 +
101851 + // 3. instrument each BB with an operation on the local entropy variable
101852 + while (bb != EXIT_BLOCK_PTR) {
101853 + perturb_local_entropy(bb, local_entropy);
101854 +//debug_bb(bb);
101855 + bb = bb->next_bb;
101856 + };
101857 +
101858 + // 4. mix local entropy into the global entropy variable
101859 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
101860 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
101861 + return 0;
101862 +}
101863 +
101864 +static void start_unit_callback(void *gcc_data, void *user_data)
101865 +{
101866 + tree latent_entropy_type;
101867 +
101868 +#if BUILDING_GCC_VERSION >= 4007
101869 + seed = get_random_seed(false);
101870 +#else
101871 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
101872 + seed *= seed;
101873 +#endif
101874 +
101875 + if (in_lto_p)
101876 + return;
101877 +
101878 + // extern volatile u64 latent_entropy
101879 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
101880 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
101881 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
101882 +
101883 + TREE_STATIC(latent_entropy_decl) = 1;
101884 + TREE_PUBLIC(latent_entropy_decl) = 1;
101885 + TREE_USED(latent_entropy_decl) = 1;
101886 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
101887 + DECL_EXTERNAL(latent_entropy_decl) = 1;
101888 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
101889 + lang_hooks.decls.pushdecl(latent_entropy_decl);
101890 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
101891 +// varpool_finalize_decl(latent_entropy_decl);
101892 +// varpool_mark_needed_node(latent_entropy_decl);
101893 +}
101894 +
101895 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101896 +{
101897 + const char * const plugin_name = plugin_info->base_name;
101898 + struct register_pass_info latent_entropy_pass_info = {
101899 + .pass = &latent_entropy_pass.pass,
101900 + .reference_pass_name = "optimized",
101901 + .ref_pass_instance_number = 1,
101902 + .pos_op = PASS_POS_INSERT_BEFORE
101903 + };
101904 +
101905 + if (!plugin_default_version_check(version, &gcc_version)) {
101906 + error(G_("incompatible gcc/plugin versions"));
101907 + return 1;
101908 + }
101909 +
101910 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
101911 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
101912 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
101913 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101914 +
101915 + return 0;
101916 +}
101917 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
101918 new file mode 100644
101919 index 0000000..b04803b
101920 --- /dev/null
101921 +++ b/tools/gcc/size_overflow_hash.data
101922 @@ -0,0 +1,6350 @@
101923 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
101924 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
101925 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
101926 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
101927 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
101928 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
101929 +padzero_55 padzero 1 55 &sel_read_policyvers_55
101930 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
101931 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
101932 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
101933 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
101934 +load_msg_95 load_msg 2 95 NULL
101935 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
101936 +init_q_132 init_q 4 132 NULL
101937 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
101938 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
101939 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
101940 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
101941 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
101942 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
101943 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
101944 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
101945 +br_port_info_size_268 br_port_info_size 0 268 NULL
101946 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
101947 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
101948 +SYSC_connect_304 SYSC_connect 3 304 NULL
101949 +syslog_print_307 syslog_print 2 307 NULL
101950 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
101951 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
101952 +next_node_allowed_318 next_node_allowed 1 318 NULL
101953 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
101954 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
101955 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
101956 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
101957 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
101958 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
101959 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
101960 +pidlist_resize_496 pidlist_resize 2 496 NULL
101961 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
101962 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
101963 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
101964 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
101965 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
101966 +dle_count_543 dle_count 0 543 NULL
101967 +devres_alloc_551 devres_alloc 2 551 NULL
101968 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
101969 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
101970 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
101971 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
101972 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
101973 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
101974 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
101975 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
101976 +isp1760_register_628 isp1760_register 1-2 628 NULL
101977 +clone_split_bio_633 clone_split_bio 6 633 NULL
101978 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
101979 +remap_to_cache_640 remap_to_cache 3 640 NULL
101980 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
101981 +unlink_queued_645 unlink_queued 3-4 645 NULL
101982 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
101983 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
101984 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
101985 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
101986 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
101987 +disk_max_parts_719 disk_max_parts 0 719 NULL
101988 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
101989 +dvb_video_write_754 dvb_video_write 3 754 NULL
101990 +if_writecmd_815 if_writecmd 2 815 NULL
101991 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
101992 +read_fifo_826 read_fifo 3 826 NULL
101993 +um_idi_read_850 um_idi_read 3 850 NULL
101994 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
101995 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
101996 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
101997 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
101998 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
101999 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
102000 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
102001 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
102002 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
102003 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
102004 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
102005 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
102006 +_do_truncate_1019 _do_truncate 2 1019 NULL
102007 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
102008 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
102009 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
102010 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
102011 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
102012 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
102013 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
102014 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
102015 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
102016 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
102017 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
102018 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
102019 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
102020 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
102021 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
102022 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
102023 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
102024 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
102025 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
102026 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
102027 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
102028 +nested_get_page_1252 nested_get_page 2 1252 NULL
102029 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
102030 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
102031 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
102032 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
102033 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
102034 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
102035 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
102036 +ffs_1322 ffs 0 1322 NULL
102037 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
102038 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
102039 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
102040 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
102041 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
102042 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
102043 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
102044 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
102045 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
102046 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
102047 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
102048 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
102049 +zone_page_state_1393 zone_page_state 0 1393 NULL
102050 +file_read_actor_1401 file_read_actor 4 1401 NULL
102051 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
102052 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
102053 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
102054 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
102055 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
102056 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
102057 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
102058 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
102059 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
102060 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
102061 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
102062 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
102063 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
102064 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
102065 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
102066 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
102067 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
102068 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
102069 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
102070 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
102071 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
102072 +rmap_add_1677 rmap_add 3 1677 NULL
102073 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
102074 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
102075 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
102076 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
102077 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
102078 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
102079 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
102080 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
102081 +cosa_write_1774 cosa_write 3 1774 NULL
102082 +update_macheader_1775 update_macheader 7 1775 NULL
102083 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
102084 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
102085 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
102086 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
102087 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
102088 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
102089 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
102090 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
102091 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
102092 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
102093 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
102094 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
102095 +read_swap_header_1957 read_swap_header 0 1957 NULL
102096 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
102097 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
102098 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
102099 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
102100 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
102101 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
102102 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
102103 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
102104 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
102105 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
102106 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
102107 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
102108 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
102109 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
102110 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
102111 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
102112 +audit_expand_2098 audit_expand 2 2098 NULL
102113 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
102114 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
102115 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
102116 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
102117 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
102118 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
102119 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
102120 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
102121 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
102122 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
102123 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
102124 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
102125 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
102126 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
102127 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
102128 +vhci_write_2224 vhci_write 3 2224 NULL
102129 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
102130 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
102131 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
102132 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
102133 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
102134 +do_update_counters_2259 do_update_counters 4 2259 NULL
102135 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
102136 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
102137 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
102138 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
102139 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
102140 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
102141 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
102142 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
102143 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
102144 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
102145 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
102146 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
102147 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
102148 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
102149 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
102150 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
102151 +raid1_size_2419 raid1_size 0-2 2419 NULL
102152 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
102153 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
102154 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
102155 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
102156 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
102157 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
102158 +update_pmkid_2481 update_pmkid 4 2481 NULL
102159 +wiphy_new_2482 wiphy_new 2 2482 NULL
102160 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
102161 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
102162 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
102163 +dm_write_2513 dm_write 3 2513 NULL
102164 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
102165 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
102166 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
102167 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
102168 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
102169 +slot_bytes_2609 slot_bytes 0 2609 NULL
102170 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
102171 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
102172 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
102173 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
102174 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
102175 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
102176 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
102177 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
102178 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
102179 +__next_cpu_2782 __next_cpu 1 2782 NULL
102180 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
102181 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
102182 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
102183 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
102184 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
102185 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
102186 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
102187 +mq_map_2871 mq_map 2 2871 NULL
102188 +nla_padlen_2883 nla_padlen 1 2883 NULL
102189 +cmm_write_2896 cmm_write 3 2896 NULL
102190 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
102191 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
102192 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
102193 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
102194 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
102195 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
102196 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
102197 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
102198 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
102199 +depth_write_3021 depth_write 3 3021 NULL
102200 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
102201 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
102202 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
102203 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
102204 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
102205 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
102206 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
102207 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
102208 +free_coherent_3082 free_coherent 4-2 3082 NULL
102209 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
102210 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
102211 +rb_alloc_3102 rb_alloc 1 3102 NULL
102212 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
102213 +print_time_3132 print_time 0 3132 NULL
102214 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
102215 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
102216 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
102217 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
102218 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
102219 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
102220 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
102221 +alloc_context_3194 alloc_context 1 3194 NULL
102222 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
102223 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
102224 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
102225 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
102226 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
102227 +key_key_read_3241 key_key_read 3 3241 NULL
102228 +number_3243 number 0 3243 NULL
102229 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
102230 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
102231 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
102232 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
102233 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
102234 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
102235 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
102236 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
102237 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
102238 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
102239 +scnprintf_3360 scnprintf 0-2 3360 NULL
102240 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
102241 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
102242 +send_stream_3397 send_stream 4 3397 NULL
102243 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
102244 +msix_map_region_3411 msix_map_region 3 3411 NULL
102245 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
102246 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
102247 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
102248 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
102249 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
102250 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
102251 +map_single_3449 map_single 0-2 3449 NULL
102252 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
102253 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
102254 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
102255 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
102256 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
102257 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
102258 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
102259 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
102260 +SyS_readv_3539 SyS_readv 3 3539 NULL
102261 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
102262 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
102263 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
102264 +evtchn_read_3569 evtchn_read 3 3569 NULL
102265 +vc_resize_3585 vc_resize 2-3 3585 NULL
102266 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
102267 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
102268 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
102269 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
102270 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
102271 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
102272 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
102273 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
102274 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
102275 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
102276 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
102277 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
102278 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
102279 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
102280 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
102281 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
102282 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
102283 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
102284 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
102285 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
102286 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
102287 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
102288 +get_fd_set_3866 get_fd_set 1 3866 NULL
102289 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
102290 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
102291 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
102292 +nvram_write_3894 nvram_write 3 3894 NULL
102293 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
102294 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
102295 +vcs_write_3910 vcs_write 3 3910 NULL
102296 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
102297 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
102298 +do_add_counters_3992 do_add_counters 3 3992 NULL
102299 +userspace_status_4004 userspace_status 4 4004 NULL
102300 +mei_write_4005 mei_write 3 4005 NULL nohasharray
102301 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
102302 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
102303 +mm_populate_4016 mm_populate 1 4016 NULL
102304 +blk_end_request_4024 blk_end_request 3 4024 NULL
102305 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
102306 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
102307 +read_file_queues_4078 read_file_queues 3 4078 NULL
102308 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
102309 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
102310 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
102311 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
102312 +tm6000_read_4151 tm6000_read 3 4151 NULL
102313 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
102314 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
102315 +get_alua_req_4166 get_alua_req 3 4166 NULL
102316 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
102317 +read_file_bool_4180 read_file_bool 3 4180 NULL
102318 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
102319 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
102320 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
102321 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
102322 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
102323 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
102324 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
102325 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
102326 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
102327 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
102328 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
102329 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
102330 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
102331 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
102332 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
102333 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
102334 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
102335 +memparse_4444 memparse 0 4444 NULL
102336 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
102337 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
102338 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
102339 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
102340 +set_link_security_4502 set_link_security 4 4502 NULL
102341 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
102342 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
102343 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
102344 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
102345 +tty_register_device_4544 tty_register_device 2 4544 NULL
102346 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
102347 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
102348 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
102349 +bch_alloc_4593 bch_alloc 1 4593 NULL
102350 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
102351 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
102352 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
102353 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
102354 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
102355 +kone_receive_4690 kone_receive 4 4690 NULL
102356 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
102357 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
102358 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
102359 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
102360 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
102361 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
102362 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
102363 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
102364 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
102365 +create_subvol_4791 create_subvol 4 4791 NULL
102366 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
102367 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
102368 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
102369 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
102370 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
102371 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
102372 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
102373 +sys_ipc_4889 sys_ipc 3 4889 NULL
102374 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
102375 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
102376 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
102377 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
102378 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
102379 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
102380 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
102381 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
102382 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
102383 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
102384 +do_mincore_5018 do_mincore 0-1 5018 NULL
102385 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
102386 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
102387 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
102388 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
102389 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
102390 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
102391 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
102392 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
102393 +sound_write_5102 sound_write 3 5102 NULL
102394 +clear_dirty_5105 clear_dirty 3 5105 NULL
102395 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
102396 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
102397 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
102398 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
102399 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
102400 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
102401 +skb_network_header_5203 skb_network_header 0 5203 NULL
102402 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
102403 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
102404 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
102405 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
102406 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
102407 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
102408 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
102409 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
102410 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
102411 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
102412 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
102413 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
102414 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
102415 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
102416 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
102417 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
102418 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
102419 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
102420 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
102421 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
102422 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
102423 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
102424 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
102425 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
102426 +tty_write_5494 tty_write 3 5494 NULL
102427 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
102428 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
102429 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
102430 +spidev_message_5518 spidev_message 3 5518 NULL
102431 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
102432 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
102433 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
102434 +le_readq_5557 le_readq 0 5557 NULL
102435 +inw_5558 inw 0 5558 NULL
102436 +fir16_create_5574 fir16_create 3 5574 NULL
102437 +bioset_create_5580 bioset_create 1 5580 NULL
102438 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
102439 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
102440 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
102441 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
102442 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
102443 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
102444 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
102445 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
102446 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
102447 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
102448 +get_arg_5694 get_arg 3 5694 NULL
102449 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
102450 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
102451 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
102452 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
102453 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
102454 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
102455 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
102456 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
102457 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
102458 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
102459 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
102460 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
102461 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
102462 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
102463 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
102464 +setup_req_5848 setup_req 3 5848 NULL
102465 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
102466 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
102467 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
102468 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
102469 +port_show_regs_5904 port_show_regs 3 5904 NULL
102470 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
102471 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
102472 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
102473 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
102474 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
102475 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
102476 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
102477 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
102478 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
102479 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
102480 +native_pte_val_5978 native_pte_val 0 5978 NULL
102481 +SyS_semop_5980 SyS_semop 3 5980 NULL
102482 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
102483 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
102484 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
102485 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
102486 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
102487 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
102488 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
102489 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
102490 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
102491 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
102492 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
102493 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
102494 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
102495 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
102496 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
102497 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
102498 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
102499 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
102500 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
102501 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
102502 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
102503 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
102504 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
102505 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
102506 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
102507 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
102508 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
102509 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
102510 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
102511 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
102512 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
102513 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
102514 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
102515 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
102516 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
102517 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
102518 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
102519 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
102520 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
102521 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
102522 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
102523 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
102524 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
102525 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
102526 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
102527 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
102528 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
102529 +mei_read_6507 mei_read 3 6507 NULL
102530 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
102531 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
102532 +wdm_read_6549 wdm_read 3 6549 NULL
102533 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
102534 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
102535 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
102536 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
102537 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
102538 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
102539 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
102540 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
102541 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
102542 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
102543 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
102544 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
102545 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
102546 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
102547 +mpeg_read_6708 mpeg_read 3 6708 NULL
102548 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
102549 +video_proc_write_6724 video_proc_write 3 6724 NULL
102550 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
102551 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
102552 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
102553 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
102554 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
102555 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
102556 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
102557 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
102558 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
102559 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
102560 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
102561 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
102562 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
102563 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
102564 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
102565 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
102566 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
102567 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
102568 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
102569 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
102570 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
102571 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
102572 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
102573 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
102574 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
102575 +request_key_async_6990 request_key_async 4 6990 NULL
102576 +tpl_write_6998 tpl_write 3 6998 NULL
102577 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
102578 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
102579 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
102580 +wimax_msg_7030 wimax_msg 4 7030 NULL
102581 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
102582 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
102583 +event_enable_read_7074 event_enable_read 3 7074 NULL
102584 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
102585 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
102586 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
102587 +check_header_7108 check_header 0 7108 NULL
102588 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
102589 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
102590 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
102591 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
102592 +get_param_h_7247 get_param_h 0 7247 NULL
102593 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
102594 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
102595 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
102596 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
102597 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
102598 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
102599 +mgmt_control_7349 mgmt_control 3 7349 NULL
102600 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
102601 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
102602 +hweight_long_7388 hweight_long 0-1 7388 NULL
102603 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
102604 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
102605 +readb_7401 readb 0 7401 NULL
102606 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
102607 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
102608 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
102609 +numa_emulation_7466 numa_emulation 2 7466 NULL
102610 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
102611 +garp_request_join_7471 garp_request_join 4 7471 NULL
102612 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
102613 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
102614 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
102615 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
102616 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
102617 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
102618 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
102619 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
102620 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
102621 +groups_alloc_7614 groups_alloc 1 7614 NULL
102622 +sg_virt_7616 sg_virt 0 7616 NULL
102623 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
102624 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
102625 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
102626 +dev_write_7708 dev_write 3 7708 NULL
102627 +unmap_region_7709 unmap_region 1 7709 NULL
102628 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
102629 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
102630 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
102631 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
102632 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
102633 +ioread32be_7773 ioread32be 0 7773 NULL
102634 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
102635 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
102636 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
102637 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
102638 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
102639 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
102640 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
102641 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
102642 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
102643 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
102644 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
102645 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
102646 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
102647 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
102648 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
102649 +sys_mbind_7990 sys_mbind 5 7990 NULL
102650 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
102651 +vcs_read_8017 vcs_read 3 8017 NULL
102652 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
102653 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
102654 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
102655 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
102656 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
102657 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
102658 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
102659 +venus_lookup_8121 venus_lookup 4 8121 NULL
102660 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
102661 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
102662 +ore_truncate_8181 ore_truncate 3 8181 NULL
102663 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
102664 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
102665 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
102666 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
102667 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
102668 +play_iframe_8219 play_iframe 3 8219 NULL
102669 +create_log_8225 create_log 2 8225 NULL nohasharray
102670 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
102671 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
102672 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
102673 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
102674 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
102675 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
102676 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
102677 +init_cdev_8274 init_cdev 1 8274 NULL
102678 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
102679 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
102680 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
102681 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
102682 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
102683 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
102684 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
102685 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
102686 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
102687 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
102688 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
102689 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
102690 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
102691 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
102692 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
102693 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
102694 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
102695 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
102696 +dev_config_8506 dev_config 3 8506 NULL
102697 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
102698 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
102699 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
102700 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
102701 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
102702 +user_on_off_8552 user_on_off 2 8552 NULL
102703 +profile_remove_8556 profile_remove 3 8556 NULL
102704 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
102705 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
102706 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
102707 +tower_write_8580 tower_write 3 8580 NULL
102708 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
102709 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
102710 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
102711 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
102712 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
102713 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
102714 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
102715 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
102716 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
102717 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
102718 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
102719 +arcfb_write_8702 arcfb_write 3 8702 NULL
102720 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
102721 +init_header_8703 init_header 0 8703 &i_size_read_8703
102722 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
102723 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
102724 +f_dupfd_8730 f_dupfd 1 8730 NULL
102725 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
102726 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
102727 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
102728 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
102729 +sys_prctl_8766 sys_prctl 4 8766 NULL
102730 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
102731 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
102732 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
102733 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
102734 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
102735 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
102736 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
102737 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
102738 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
102739 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
102740 +clear_bitset_8840 clear_bitset 2 8840 NULL
102741 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
102742 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
102743 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
102744 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
102745 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
102746 +layout_commit_8926 layout_commit 3 8926 NULL
102747 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
102748 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
102749 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
102750 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
102751 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
102752 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
102753 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
102754 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
102755 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
102756 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
102757 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
102758 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
102759 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
102760 +nla_put_9042 nla_put 3 9042 NULL
102761 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
102762 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
102763 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
102764 +string_9080 string 0 9080 NULL
102765 +create_queues_9088 create_queues 2-3 9088 NULL
102766 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
102767 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
102768 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
102769 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
102770 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
102771 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
102772 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
102773 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
102774 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
102775 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
102776 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
102777 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
102778 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
102779 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
102780 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
102781 +get_pfn_9207 get_pfn 1 9207 NULL
102782 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
102783 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
102784 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
102785 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
102786 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
102787 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
102788 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
102789 +flakey_status_9274 flakey_status 5 9274 NULL
102790 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
102791 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
102792 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
102793 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
102794 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
102795 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
102796 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
102797 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
102798 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
102799 +read_9397 read 3 9397 NULL
102800 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
102801 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
102802 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
102803 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
102804 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
102805 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
102806 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
102807 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
102808 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
102809 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
102810 +lp_write_9511 lp_write 3 9511 NULL
102811 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
102812 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
102813 +read_file_dma_9530 read_file_dma 3 9530 NULL
102814 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
102815 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
102816 +fw_node_create_9559 fw_node_create 2 9559 NULL
102817 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
102818 +kobj_map_9566 kobj_map 2-3 9566 NULL
102819 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
102820 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
102821 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
102822 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
102823 +do_sync_9604 do_sync 1 9604 NULL
102824 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
102825 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
102826 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
102827 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
102828 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
102829 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
102830 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
102831 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
102832 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
102833 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
102834 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
102835 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
102836 +is_hole_9694 is_hole 2 9694 NULL nohasharray
102837 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
102838 +fnb_9703 fnb 2-3 9703 NULL
102839 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
102840 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
102841 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
102842 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
102843 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
102844 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
102845 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
102846 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
102847 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
102848 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
102849 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
102850 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
102851 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
102852 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
102853 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
102854 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
102855 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
102856 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
102857 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
102858 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
102859 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
102860 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
102861 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
102862 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
102863 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
102864 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
102865 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
102866 +read_file_misc_9948 read_file_misc 3 9948 NULL
102867 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
102868 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
102869 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
102870 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
102871 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
102872 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
102873 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
102874 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
102875 +handle_request_10024 handle_request 9 10024 NULL
102876 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
102877 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
102878 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
102879 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
102880 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
102881 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
102882 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
102883 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
102884 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
102885 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
102886 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
102887 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
102888 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
102889 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
102890 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
102891 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
102892 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
102893 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
102894 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
102895 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
102896 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
102897 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
102898 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
102899 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
102900 +read_emulate_10310 read_emulate 2-4 10310 NULL
102901 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
102902 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
102903 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
102904 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
102905 +get_dump_page_10338 get_dump_page 1 10338 NULL
102906 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
102907 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
102908 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
102909 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
102910 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
102911 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
102912 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
102913 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
102914 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
102915 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
102916 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
102917 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
102918 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
102919 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
102920 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
102921 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
102922 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
102923 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
102924 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
102925 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
102926 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
102927 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
102928 +otp_read_10594 otp_read 2-4-5 10594 NULL
102929 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
102930 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
102931 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
102932 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
102933 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
102934 +parport_write_10669 parport_write 0 10669 NULL
102935 +inl_10708 inl 0 10708 NULL nohasharray
102936 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
102937 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
102938 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
102939 +spi_sync_10731 spi_sync 0 10731 NULL
102940 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
102941 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
102942 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
102943 +sys_syslog_10746 sys_syslog 3 10746 NULL
102944 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
102945 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
102946 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
102947 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
102948 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
102949 +sys_bind_10799 sys_bind 3 10799 NULL
102950 +compat_put_int_10828 compat_put_int 1 10828 NULL
102951 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
102952 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
102953 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
102954 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
102955 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
102956 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
102957 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
102958 +get_scq_10897 get_scq 2 10897 NULL
102959 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
102960 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
102961 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
102962 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
102963 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
102964 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
102965 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
102966 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
102967 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
102968 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
102969 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
102970 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
102971 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
102972 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
102973 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
102974 +count_argc_11083 count_argc 0 11083 NULL
102975 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
102976 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
102977 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
102978 +page_offset_11120 page_offset 0 11120 NULL
102979 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
102980 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
102981 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
102982 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
102983 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
102984 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
102985 +__swab16p_11220 __swab16p 0 11220 NULL
102986 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
102987 +mmap_region_11247 mmap_region 0-2 11247 NULL
102988 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
102989 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
102990 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
102991 +cru_detect_11272 cru_detect 1 11272 NULL
102992 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
102993 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
102994 +construct_key_11329 construct_key 3 11329 NULL nohasharray
102995 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
102996 +next_segment_11330 next_segment 0-2-1 11330 NULL
102997 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
102998 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
102999 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
103000 +sel_write_create_11353 sel_write_create 3 11353 NULL
103001 +handle_unit_11355 handle_unit 0-1 11355 NULL
103002 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
103003 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
103004 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
103005 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
103006 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
103007 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
103008 +str_to_user_11411 str_to_user 2 11411 NULL
103009 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
103010 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
103011 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
103012 +trace_options_read_11419 trace_options_read 3 11419 NULL
103013 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
103014 +prepare_image_11424 prepare_image 0 11424 NULL
103015 +vring_size_11426 vring_size 0-1-2 11426 NULL
103016 +bttv_read_11432 bttv_read 3 11432 NULL
103017 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
103018 +swp_offset_11475 swp_offset 0 11475 NULL
103019 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
103020 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
103021 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
103022 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
103023 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
103024 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
103025 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
103026 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
103027 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
103028 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
103029 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
103030 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
103031 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
103032 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
103033 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
103034 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
103035 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
103036 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
103037 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
103038 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
103039 +split_11691 split 2 11691 NULL
103040 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
103041 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
103042 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
103043 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
103044 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
103045 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
103046 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
103047 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
103048 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
103049 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
103050 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
103051 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
103052 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
103053 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
103054 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
103055 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
103056 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
103057 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
103058 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
103059 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
103060 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
103061 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
103062 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
103063 +atmel_read16_11981 atmel_read16 0 11981 NULL
103064 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
103065 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
103066 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
103067 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
103068 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
103069 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
103070 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
103071 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
103072 +set_powered_12129 set_powered 4 12129 NULL
103073 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
103074 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
103075 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
103076 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
103077 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
103078 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
103079 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
103080 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
103081 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
103082 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
103083 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
103084 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
103085 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
103086 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
103087 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
103088 +scaled_div_12201 scaled_div 1-2 12201 NULL
103089 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
103090 +receive_copy_12216 receive_copy 3 12216 NULL
103091 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
103092 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
103093 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
103094 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
103095 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
103096 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
103097 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
103098 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
103099 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
103100 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
103101 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
103102 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
103103 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
103104 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
103105 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
103106 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
103107 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
103108 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
103109 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
103110 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
103111 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
103112 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
103113 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
103114 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
103115 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
103116 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
103117 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
103118 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
103119 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
103120 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
103121 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
103122 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
103123 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
103124 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
103125 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
103126 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
103127 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
103128 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
103129 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
103130 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
103131 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
103132 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
103133 +wb_create_12651 wb_create 1 12651 NULL
103134 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
103135 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
103136 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
103137 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
103138 +ivtv_write_12721 ivtv_write 3 12721 NULL
103139 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
103140 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
103141 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
103142 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
103143 +listxattr_12769 listxattr 3 12769 NULL
103144 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
103145 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
103146 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
103147 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
103148 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
103149 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
103150 +readq_12825 readq 0 12825 NULL
103151 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
103152 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
103153 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
103154 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
103155 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
103156 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
103157 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
103158 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
103159 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
103160 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
103161 +bm_status_write_12964 bm_status_write 3 12964 NULL
103162 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
103163 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
103164 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
103165 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
103166 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
103167 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
103168 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
103169 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
103170 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
103171 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
103172 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
103173 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
103174 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
103175 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
103176 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
103177 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
103178 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
103179 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
103180 +blk_update_request_13146 blk_update_request 3 13146 NULL
103181 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
103182 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
103183 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
103184 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
103185 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
103186 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
103187 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
103188 +comedi_read_13199 comedi_read 3 13199 NULL
103189 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
103190 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
103191 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
103192 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
103193 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
103194 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
103195 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
103196 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
103197 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
103198 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
103199 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
103200 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
103201 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
103202 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
103203 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
103204 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
103205 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
103206 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
103207 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
103208 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
103209 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
103210 +cache_ctr_13364 cache_ctr 2 13364 NULL
103211 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
103212 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
103213 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
103214 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
103215 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
103216 +sky2_receive_13407 sky2_receive 2 13407 NULL
103217 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
103218 +keyring_read_13438 keyring_read 3 13438 NULL
103219 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
103220 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
103221 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
103222 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
103223 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
103224 +core_status_13515 core_status 4 13515 NULL
103225 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
103226 +bm_init_13529 bm_init 2 13529 NULL
103227 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
103228 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
103229 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
103230 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
103231 +sys_madvise_13569 sys_madvise 1 13569 NULL
103232 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
103233 +cache_write_13589 cache_write 3 13589 NULL
103234 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
103235 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
103236 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
103237 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
103238 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
103239 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
103240 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
103241 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
103242 +packet_snd_13634 packet_snd 3 13634 NULL
103243 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
103244 +cache_downcall_13666 cache_downcall 3 13666 NULL
103245 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
103246 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
103247 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
103248 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
103249 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
103250 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
103251 +random_read_13815 random_read 3 13815 NULL
103252 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
103253 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
103254 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
103255 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
103256 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
103257 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
103258 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
103259 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
103260 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
103261 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
103262 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
103263 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
103264 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
103265 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
103266 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
103267 +com90xx_found_13974 com90xx_found 3 13974 NULL
103268 +qcam_read_13977 qcam_read 3 13977 NULL
103269 +dsp_read_13980 dsp_read 2 13980 NULL
103270 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
103271 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
103272 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
103273 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
103274 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
103275 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
103276 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
103277 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
103278 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
103279 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
103280 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
103281 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
103282 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
103283 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
103284 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
103285 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
103286 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
103287 +em_canid_change_14150 em_canid_change 3 14150 NULL
103288 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
103289 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
103290 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
103291 +alloc_async_14208 alloc_async 1 14208 NULL
103292 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
103293 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
103294 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
103295 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
103296 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
103297 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
103298 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
103299 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
103300 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
103301 +rr_status_14293 rr_status 5 14293 NULL
103302 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
103303 +oo_objects_14319 oo_objects 0 14319 NULL
103304 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
103305 +scsi2int_14358 scsi2int 0 14358 NULL
103306 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
103307 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
103308 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
103309 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
103310 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
103311 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
103312 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
103313 +block_size_14443 block_size 0 14443 NULL
103314 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
103315 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
103316 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
103317 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
103318 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
103319 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
103320 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
103321 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
103322 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
103323 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
103324 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
103325 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
103326 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
103327 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
103328 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
103329 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
103330 +dbJoin_14644 dbJoin 0 14644 NULL
103331 +profile_replace_14652 profile_replace 3 14652 NULL
103332 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
103333 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
103334 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
103335 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
103336 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
103337 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
103338 +get_bio_block_14714 get_bio_block 0 14714 NULL
103339 +vfd_write_14717 vfd_write 3 14717 NULL
103340 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
103341 +raid1_resize_14740 raid1_resize 2 14740 NULL
103342 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
103343 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
103344 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
103345 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
103346 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
103347 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
103348 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
103349 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
103350 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
103351 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
103352 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
103353 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
103354 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
103355 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
103356 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
103357 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
103358 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
103359 +unifi_read_14899 unifi_read 3 14899 NULL
103360 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
103361 +krealloc_14908 krealloc 2 14908 NULL
103362 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
103363 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
103364 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
103365 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
103366 +queue_cnt_14951 queue_cnt 0 14951 NULL
103367 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
103368 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
103369 +setkey_14987 setkey 3 14987 NULL nohasharray
103370 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
103371 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
103372 +vmap_15025 vmap 2 15025 NULL
103373 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
103374 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
103375 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
103376 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
103377 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
103378 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
103379 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
103380 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
103381 +start_port_15124 start_port 0 15124 NULL
103382 +memchr_15126 memchr 0 15126 NULL
103383 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
103384 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
103385 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
103386 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
103387 +reserve_resources_15194 reserve_resources 3 15194 NULL
103388 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
103389 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
103390 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
103391 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
103392 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
103393 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
103394 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
103395 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
103396 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
103397 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
103398 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
103399 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
103400 +ioread16_15342 ioread16 0 15342 NULL
103401 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
103402 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
103403 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
103404 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
103405 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
103406 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
103407 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
103408 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
103409 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
103410 +get_modalias_15406 get_modalias 2 15406 NULL
103411 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
103412 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
103413 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
103414 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
103415 +memweight_15450 memweight 2 15450 NULL
103416 +vmalloc_15464 vmalloc 1 15464 NULL
103417 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
103418 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
103419 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
103420 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
103421 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
103422 +persistent_status_15574 persistent_status 4 15574 NULL
103423 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
103424 +vme_user_write_15587 vme_user_write 3 15587 NULL
103425 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
103426 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
103427 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
103428 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
103429 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
103430 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
103431 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
103432 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
103433 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
103434 +fs_path_add_15648 fs_path_add 3 15648 NULL
103435 +xsd_read_15653 xsd_read 3 15653 NULL
103436 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
103437 +unix_bind_15668 unix_bind 3 15668 NULL
103438 +dm_read_15674 dm_read 3 15674 NULL
103439 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
103440 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
103441 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
103442 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
103443 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
103444 +do_test_15766 do_test 1 15766 NULL
103445 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
103446 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
103447 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
103448 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
103449 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
103450 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
103451 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
103452 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
103453 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
103454 +table_size_15851 table_size 0-1-2 15851 NULL
103455 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
103456 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
103457 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
103458 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
103459 +native_read_msr_15905 native_read_msr 0 15905 NULL
103460 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
103461 +power_read_15939 power_read 3 15939 NULL
103462 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
103463 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
103464 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
103465 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
103466 +frame_alloc_15981 frame_alloc 4 15981 NULL
103467 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
103468 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
103469 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
103470 +got_frame_16028 got_frame 2 16028 NULL
103471 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
103472 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
103473 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
103474 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
103475 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
103476 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
103477 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
103478 +fsm_init_16134 fsm_init 2 16134 NULL
103479 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
103480 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
103481 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
103482 +mapping_level_16188 mapping_level 2 16188 NULL
103483 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
103484 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
103485 +create_table_16213 create_table 2 16213 NULL
103486 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
103487 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
103488 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
103489 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
103490 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
103491 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
103492 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
103493 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
103494 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
103495 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
103496 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
103497 +account_16283 account 0-2-4 16283 NULL nohasharray
103498 +mirror_status_16283 mirror_status 5 16283 &account_16283
103499 +retry_instruction_16285 retry_instruction 2 16285 NULL
103500 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
103501 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
103502 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
103503 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
103504 +wb_map_16301 wb_map 2 16301 NULL
103505 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
103506 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
103507 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
103508 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
103509 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
103510 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
103511 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
103512 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
103513 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
103514 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
103515 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
103516 +raid10_resize_16537 raid10_resize 2 16537 NULL
103517 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
103518 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
103519 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
103520 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
103521 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
103522 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
103523 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
103524 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
103525 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
103526 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
103527 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
103528 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
103529 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
103530 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
103531 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
103532 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
103533 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
103534 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
103535 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
103536 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
103537 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
103538 +st_write_16874 st_write 3 16874 NULL
103539 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
103540 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
103541 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
103542 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
103543 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
103544 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
103545 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
103546 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
103547 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
103548 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
103549 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
103550 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
103551 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
103552 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
103553 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
103554 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
103555 +mac_address_string_17091 mac_address_string 0 17091 NULL
103556 +entry_length_17093 entry_length 0 17093 NULL
103557 +sys_preadv_17100 sys_preadv 3 17100 NULL
103558 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
103559 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
103560 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
103561 +sep_read_17161 sep_read 3 17161 NULL
103562 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
103563 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
103564 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
103565 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
103566 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
103567 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
103568 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
103569 +to_oblock_17254 to_oblock 0-1 17254 NULL
103570 +unpack_value_17259 unpack_value 1 17259 NULL
103571 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
103572 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
103573 +alloc_ep_17269 alloc_ep 1 17269 NULL
103574 +pg_read_17276 pg_read 3 17276 NULL
103575 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
103576 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
103577 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
103578 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
103579 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
103580 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
103581 +skb_pad_17302 skb_pad 2 17302 NULL
103582 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
103583 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
103584 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
103585 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
103586 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
103587 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
103588 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
103589 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
103590 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
103591 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
103592 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
103593 +compat_cmd_17465 compat_cmd 2 17465 NULL
103594 +probe_bios_17467 probe_bios 1 17467 NULL
103595 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
103596 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
103597 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
103598 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
103599 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
103600 +copy_from_user_17559 copy_from_user 3 17559 NULL
103601 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
103602 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
103603 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
103604 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
103605 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
103606 +osst_execute_17607 osst_execute 7-6 17607 NULL
103607 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
103608 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
103609 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
103610 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
103611 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
103612 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
103613 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
103614 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
103615 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
103616 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
103617 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
103618 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
103619 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
103620 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
103621 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
103622 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
103623 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
103624 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
103625 +perf_clock_17787 perf_clock 0 17787 NULL
103626 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
103627 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
103628 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
103629 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
103630 +count_leafs_17842 count_leafs 0 17842 NULL
103631 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
103632 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
103633 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
103634 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
103635 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
103636 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
103637 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
103638 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
103639 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
103640 +recover_head_17904 recover_head 3 17904 NULL
103641 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
103642 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
103643 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
103644 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
103645 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
103646 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
103647 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
103648 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
103649 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
103650 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
103651 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
103652 +fill_read_18019 fill_read 0 18019 NULL
103653 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
103654 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
103655 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
103656 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
103657 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
103658 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
103659 +packet_came_18072 packet_came 3 18072 NULL
103660 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
103661 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
103662 +get_vm_area_18080 get_vm_area 1 18080 NULL
103663 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
103664 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
103665 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
103666 +svc_getnl_18120 svc_getnl 0 18120 NULL
103667 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
103668 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
103669 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
103670 +_has_tag_18169 _has_tag 2 18169 NULL
103671 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
103672 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
103673 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
103674 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
103675 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
103676 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
103677 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
103678 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
103679 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
103680 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
103681 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
103682 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
103683 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
103684 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
103685 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
103686 +um_idi_write_18293 um_idi_write 3 18293 NULL
103687 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
103688 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
103689 +vga_r_18310 vga_r 0 18310 NULL
103690 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
103691 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
103692 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
103693 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
103694 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
103695 +ep_io_18367 ep_io 0 18367 NULL
103696 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
103697 +ci_role_write_18388 ci_role_write 3 18388 NULL
103698 +__video_register_device_18399 __video_register_device 3 18399 NULL
103699 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
103700 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
103701 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
103702 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
103703 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
103704 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
103705 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
103706 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
103707 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
103708 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
103709 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
103710 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
103711 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
103712 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
103713 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
103714 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
103715 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
103716 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
103717 +debug_output_18575 debug_output 3 18575 NULL
103718 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
103719 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
103720 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
103721 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
103722 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
103723 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
103724 +from_buffer_18625 from_buffer 3 18625 NULL
103725 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
103726 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
103727 +unmap_page_18665 unmap_page 2-3 18665 NULL
103728 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
103729 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
103730 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
103731 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
103732 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
103733 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
103734 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
103735 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
103736 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
103737 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
103738 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
103739 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
103740 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
103741 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
103742 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
103743 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
103744 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
103745 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
103746 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
103747 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
103748 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
103749 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
103750 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
103751 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
103752 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
103753 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
103754 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
103755 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
103756 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
103757 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
103758 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
103759 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
103760 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
103761 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
103762 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
103763 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
103764 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
103765 +huge_page_size_19008 huge_page_size 0 19008 NULL
103766 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
103767 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
103768 +revalidate_19043 revalidate 2 19043 NULL
103769 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
103770 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
103771 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
103772 +msix_map_region_19072 msix_map_region 2 19072 NULL
103773 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
103774 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
103775 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
103776 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
103777 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
103778 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
103779 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
103780 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
103781 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
103782 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
103783 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
103784 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
103785 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
103786 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
103787 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
103788 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
103789 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
103790 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
103791 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
103792 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
103793 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
103794 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
103795 +qc_capture_19298 qc_capture 3 19298 NULL
103796 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
103797 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
103798 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
103799 +debug_read_19322 debug_read 3 19322 NULL
103800 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
103801 +closure_sub_19359 closure_sub 2 19359 NULL
103802 +read_zero_19366 read_zero 3 19366 NULL
103803 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
103804 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
103805 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
103806 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
103807 +__phys_addr_19434 __phys_addr 0 19434 NULL
103808 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
103809 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
103810 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
103811 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
103812 +sky2_read16_19475 sky2_read16 0 19475 NULL
103813 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
103814 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
103815 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
103816 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
103817 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
103818 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
103819 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
103820 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
103821 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
103822 +nfsd_read_19568 nfsd_read 5 19568 NULL
103823 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
103824 +bm_status_read_19583 bm_status_read 3 19583 NULL
103825 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
103826 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
103827 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
103828 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
103829 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
103830 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
103831 +bio_detain_19690 bio_detain 2 19690 NULL
103832 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
103833 +read_reg_19723 read_reg 0 19723 NULL
103834 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
103835 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
103836 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
103837 +p9_client_read_19750 p9_client_read 5 19750 NULL
103838 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
103839 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
103840 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
103841 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
103842 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
103843 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
103844 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
103845 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
103846 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
103847 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
103848 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
103849 +__nla_put_19857 __nla_put 3 19857 NULL
103850 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
103851 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
103852 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
103853 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
103854 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
103855 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
103856 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
103857 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
103858 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
103859 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
103860 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
103861 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
103862 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
103863 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
103864 +team_options_register_20091 team_options_register 3 20091 NULL
103865 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
103866 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
103867 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
103868 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
103869 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
103870 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
103871 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
103872 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
103873 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
103874 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
103875 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
103876 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
103877 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
103878 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
103879 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
103880 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
103881 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
103882 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
103883 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
103884 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
103885 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
103886 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
103887 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
103888 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
103889 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
103890 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
103891 +read_buf_20469 read_buf 2 20469 NULL
103892 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
103893 +fast_user_write_20494 fast_user_write 5 20494 NULL
103894 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
103895 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
103896 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
103897 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
103898 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
103899 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
103900 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
103901 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
103902 +venus_create_20555 venus_create 4 20555 NULL
103903 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
103904 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
103905 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
103906 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
103907 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
103908 +lirc_write_20604 lirc_write 3 20604 NULL
103909 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
103910 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
103911 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
103912 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
103913 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
103914 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
103915 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
103916 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
103917 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
103918 +cpumask_size_20683 cpumask_size 0 20683 NULL
103919 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
103920 +gru_vtop_20689 gru_vtop 2 20689 NULL
103921 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
103922 +__maestro_read_20700 __maestro_read 0 20700 NULL
103923 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
103924 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
103925 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
103926 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
103927 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
103928 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
103929 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
103930 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
103931 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
103932 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
103933 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
103934 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
103935 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
103936 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
103937 +sys_sendto_20809 sys_sendto 6 20809 NULL
103938 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
103939 +strndup_user_20819 strndup_user 2 20819 NULL
103940 +calc_layout_20829 calc_layout 3 20829 NULL
103941 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
103942 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
103943 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
103944 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
103945 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
103946 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
103947 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
103948 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
103949 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
103950 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
103951 +htable_bits_20933 htable_bits 0 20933 NULL
103952 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
103953 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
103954 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
103955 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
103956 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
103957 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
103958 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
103959 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
103960 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
103961 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
103962 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
103963 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
103964 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
103965 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
103966 +multipath_status_21094 multipath_status 5 21094 NULL
103967 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
103968 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
103969 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
103970 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
103971 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
103972 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
103973 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
103974 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
103975 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
103976 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
103977 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
103978 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
103979 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
103980 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
103981 +input_ff_create_21240 input_ff_create 2 21240 NULL
103982 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
103983 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
103984 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
103985 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
103986 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
103987 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
103988 +add_res_range_21310 add_res_range 4 21310 NULL
103989 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
103990 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
103991 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
103992 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
103993 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
103994 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
103995 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
103996 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
103997 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
103998 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
103999 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
104000 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
104001 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
104002 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
104003 +concat_writev_21451 concat_writev 3 21451 NULL
104004 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
104005 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
104006 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
104007 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
104008 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
104009 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
104010 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
104011 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
104012 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
104013 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
104014 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
104015 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
104016 +validate_nnode_21638 validate_nnode 0 21638 NULL
104017 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
104018 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
104019 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
104020 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
104021 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
104022 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
104023 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
104024 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
104025 +vm_brk_21739 vm_brk 1 21739 NULL
104026 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
104027 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
104028 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
104029 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
104030 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
104031 +min_odd_21802 min_odd 0 21802 NULL
104032 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
104033 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
104034 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
104035 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
104036 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
104037 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
104038 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
104039 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
104040 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
104041 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
104042 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
104043 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
104044 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
104045 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
104046 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
104047 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
104048 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
104049 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
104050 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
104051 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
104052 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
104053 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
104054 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
104055 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
104056 +write_opcode_22082 write_opcode 2 22082 NULL
104057 +mem_rw_22085 mem_rw 3 22085 NULL
104058 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
104059 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
104060 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
104061 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
104062 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
104063 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
104064 +compat_insn_22142 compat_insn 2 22142 NULL
104065 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
104066 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
104067 +fls_22210 fls 0 22210 NULL
104068 +mem_write_22232 mem_write 3 22232 NULL
104069 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
104070 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
104071 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
104072 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
104073 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
104074 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
104075 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
104076 +extend_brk_22301 extend_brk 0 22301 NULL
104077 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
104078 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
104079 +get_segment_base_22324 get_segment_base 0 22324 NULL
104080 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
104081 +atomic_read_22342 atomic_read 0 22342 NULL
104082 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
104083 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
104084 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
104085 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
104086 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
104087 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
104088 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
104089 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
104090 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
104091 +zoran_write_22404 zoran_write 3 22404 NULL
104092 +queue_reply_22416 queue_reply 3 22416 NULL
104093 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
104094 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
104095 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
104096 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
104097 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
104098 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
104099 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
104100 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
104101 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
104102 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
104103 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
104104 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
104105 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
104106 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
104107 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
104108 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
104109 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
104110 +snapshot_read_22601 snapshot_read 3 22601 NULL
104111 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
104112 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
104113 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
104114 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
104115 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
104116 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
104117 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
104118 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
104119 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
104120 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
104121 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
104122 +map_22700 map 2 22700 NULL
104123 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
104124 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
104125 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
104126 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
104127 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
104128 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
104129 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
104130 +print_frame_22769 print_frame 0 22769 NULL
104131 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
104132 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
104133 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
104134 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
104135 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
104136 +create_attr_set_22861 create_attr_set 1 22861 NULL
104137 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
104138 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
104139 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
104140 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
104141 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
104142 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
104143 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
104144 +vme_get_size_22964 vme_get_size 0 22964 NULL
104145 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
104146 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
104147 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
104148 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
104149 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
104150 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
104151 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
104152 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
104153 +st_status_23032 st_status 5 23032 NULL
104154 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
104155 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
104156 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
104157 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
104158 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
104159 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
104160 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
104161 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
104162 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
104163 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
104164 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
104165 +fls_long_23096 fls_long 0 23096 NULL
104166 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
104167 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
104168 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
104169 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
104170 +__clear_user_23118 __clear_user 0 23118 NULL
104171 +dm_write_async_23120 dm_write_async 3 23120 NULL
104172 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
104173 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
104174 +read_file_ani_23161 read_file_ani 3 23161 NULL
104175 +ioremap_23172 ioremap 1-2 23172 NULL
104176 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
104177 +usblp_write_23178 usblp_write 3 23178 NULL
104178 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
104179 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
104180 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
104181 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
104182 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
104183 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
104184 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
104185 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
104186 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
104187 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
104188 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
104189 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
104190 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
104191 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
104192 +doc_probe_23285 doc_probe 1 23285 NULL
104193 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
104194 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
104195 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
104196 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
104197 +page_readlink_23346 page_readlink 3 23346 NULL
104198 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
104199 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
104200 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
104201 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
104202 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
104203 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
104204 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
104205 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
104206 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
104207 +event_filter_read_23494 event_filter_read 3 23494 NULL
104208 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
104209 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
104210 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
104211 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
104212 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
104213 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
104214 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
104215 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
104216 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
104217 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
104218 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
104219 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
104220 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
104221 +sInW_23663 sInW 0 23663 NULL
104222 +SyS_connect_23669 SyS_connect 3 23669 NULL
104223 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
104224 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
104225 +cx18_read_23699 cx18_read 3 23699 NULL
104226 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
104227 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
104228 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
104229 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
104230 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
104231 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
104232 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
104233 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
104234 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
104235 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
104236 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
104237 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
104238 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
104239 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
104240 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
104241 +p54_init_common_23850 p54_init_common 1 23850 NULL
104242 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
104243 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
104244 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
104245 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
104246 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
104247 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
104248 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
104249 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
104250 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
104251 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
104252 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
104253 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
104254 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
104255 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
104256 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
104257 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
104258 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
104259 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
104260 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
104261 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
104262 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
104263 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
104264 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
104265 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
104266 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
104267 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
104268 +mpu401_read_24126 mpu401_read 3 24126 NULL
104269 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
104270 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
104271 +set_discard_24162 set_discard 2 24162 NULL
104272 +adu_read_24177 adu_read 3 24177 NULL
104273 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
104274 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
104275 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
104276 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
104277 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
104278 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
104279 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
104280 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
104281 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
104282 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
104283 +thin_status_24278 thin_status 5 24278 NULL
104284 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
104285 +msg_size_24288 msg_size 0 24288 NULL
104286 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
104287 +map_page_24298 map_page 3-4 24298 NULL
104288 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
104289 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
104290 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
104291 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
104292 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
104293 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
104294 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
104295 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
104296 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
104297 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
104298 +igetword_24373 igetword 0 24373 NULL
104299 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
104300 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
104301 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
104302 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
104303 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
104304 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
104305 +smk_user_access_24440 smk_user_access 3 24440 NULL
104306 +page_address_24444 page_address 0 24444 NULL
104307 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
104308 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
104309 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
104310 +pd_video_read_24510 pd_video_read 3 24510 NULL
104311 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
104312 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
104313 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
104314 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
104315 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
104316 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
104317 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
104318 +count_preds_24600 count_preds 0 24600 NULL
104319 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
104320 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
104321 +context_alloc_24645 context_alloc 3 24645 NULL
104322 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
104323 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
104324 +read_fs_24717 read_fs 0 24717 NULL
104325 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
104326 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
104327 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
104328 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
104329 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
104330 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
104331 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
104332 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
104333 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
104334 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
104335 +cache_read_24790 cache_read 3 24790 NULL
104336 +unpack_str_24798 unpack_str 0 24798 NULL
104337 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
104338 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
104339 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
104340 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
104341 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
104342 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
104343 +setup_buffering_24872 setup_buffering 3 24872 NULL
104344 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
104345 +queues_read_24877 queues_read 3 24877 NULL nohasharray
104346 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
104347 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
104348 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
104349 +next_token_24929 next_token 0 24929 NULL
104350 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
104351 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
104352 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
104353 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
104354 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
104355 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
104356 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
104357 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
104358 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
104359 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
104360 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
104361 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
104362 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
104363 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
104364 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
104365 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
104366 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
104367 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
104368 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
104369 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
104370 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
104371 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
104372 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
104373 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
104374 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
104375 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
104376 +stripe_status_25259 stripe_status 5 25259 NULL
104377 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
104378 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
104379 +vfs_writev_25278 vfs_writev 3 25278 NULL
104380 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
104381 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
104382 +help_25316 help 5 25316 NULL nohasharray
104383 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
104384 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
104385 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
104386 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
104387 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
104388 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
104389 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
104390 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
104391 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
104392 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
104393 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
104394 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
104395 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
104396 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
104397 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
104398 +sb_permission_25523 sb_permission 0 25523 NULL
104399 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
104400 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
104401 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
104402 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
104403 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
104404 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
104405 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
104406 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
104407 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
104408 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
104409 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
104410 +__direct_map_25647 __direct_map 5-6 25647 NULL
104411 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
104412 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
104413 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
104414 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
104415 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
104416 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
104417 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
104418 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
104419 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
104420 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
104421 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
104422 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
104423 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
104424 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
104425 +sg_read_25799 sg_read 3 25799 NULL
104426 +system_enable_read_25815 system_enable_read 3 25815 NULL
104427 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
104428 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
104429 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
104430 +parport_read_25855 parport_read 0 25855 NULL
104431 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
104432 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
104433 +key_attr_size_25865 key_attr_size 0 25865 NULL
104434 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
104435 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
104436 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
104437 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
104438 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
104439 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
104440 +rcname_read_25919 rcname_read 3 25919 NULL
104441 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
104442 +key_flags_read_25931 key_flags_read 3 25931 NULL
104443 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
104444 +flush_25957 flush 2 25957 NULL
104445 +video_register_device_25971 video_register_device 3 25971 NULL
104446 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
104447 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
104448 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
104449 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
104450 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
104451 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
104452 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
104453 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
104454 +tun_do_read_26047 tun_do_read 5 26047 NULL
104455 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
104456 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
104457 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
104458 +skb_cow_26138 skb_cow 2 26138 NULL
104459 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
104460 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
104461 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
104462 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
104463 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
104464 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
104465 +disk_devt_26180 disk_devt 0 26180 NULL
104466 +get_registers_26187 get_registers 3 26187 NULL
104467 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
104468 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
104469 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
104470 +mce_write_26201 mce_write 3 26201 NULL
104471 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
104472 +bio_split_26235 bio_split 2 26235 NULL
104473 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
104474 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
104475 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
104476 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
104477 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
104478 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
104479 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
104480 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
104481 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
104482 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
104483 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
104484 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
104485 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
104486 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
104487 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
104488 +read_vmcore_26501 read_vmcore 3 26501 NULL
104489 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
104490 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
104491 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
104492 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
104493 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
104494 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
104495 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
104496 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
104497 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
104498 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
104499 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
104500 +pack_value_26625 pack_value 1 26625 NULL
104501 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
104502 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
104503 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
104504 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
104505 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
104506 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
104507 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
104508 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
104509 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
104510 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
104511 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
104512 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
104513 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
104514 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
104515 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
104516 +smk_write_load_26829 smk_write_load 3 26829 NULL
104517 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
104518 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
104519 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
104520 +scnprint_id_26842 scnprint_id 3 26842 NULL
104521 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
104522 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
104523 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
104524 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
104525 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
104526 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
104527 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
104528 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
104529 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
104530 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
104531 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
104532 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
104533 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
104534 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
104535 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
104536 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
104537 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
104538 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
104539 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
104540 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
104541 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
104542 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
104543 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
104544 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
104545 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
104546 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
104547 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
104548 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
104549 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
104550 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
104551 +pms_capture_27142 pms_capture 4 27142 NULL
104552 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
104553 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
104554 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
104555 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
104556 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
104557 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
104558 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
104559 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
104560 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
104561 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
104562 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
104563 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
104564 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
104565 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
104566 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
104567 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
104568 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
104569 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
104570 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
104571 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
104572 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
104573 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
104574 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
104575 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
104576 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
104577 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
104578 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
104579 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
104580 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
104581 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
104582 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
104583 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
104584 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
104585 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
104586 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
104587 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
104588 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
104589 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
104590 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
104591 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
104592 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
104593 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
104594 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
104595 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
104596 +qword_get_27670 qword_get 0 27670 NULL
104597 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
104598 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
104599 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
104600 +evm_write_key_27715 evm_write_key 3 27715 NULL
104601 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
104602 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
104603 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
104604 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
104605 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
104606 +kcalloc_27770 kcalloc 1-2 27770 NULL
104607 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
104608 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
104609 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
104610 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
104611 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
104612 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
104613 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
104614 +read_profile_27859 read_profile 3 27859 NULL
104615 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
104616 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
104617 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
104618 +gluebi_write_27905 gluebi_write 3 27905 NULL
104619 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
104620 +bm_find_next_27929 bm_find_next 2 27929 NULL
104621 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
104622 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
104623 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
104624 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
104625 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
104626 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
104627 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
104628 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
104629 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
104630 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
104631 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
104632 +pool_status_28055 pool_status 5 28055 NULL
104633 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
104634 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
104635 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
104636 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
104637 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
104638 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
104639 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
104640 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
104641 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
104642 +video_read_28148 video_read 3 28148 NULL
104643 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
104644 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
104645 +vread_28173 vread 0 28173 NULL
104646 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
104647 +d_path_28198 d_path 0 28198 NULL
104648 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
104649 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
104650 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
104651 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
104652 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
104653 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
104654 +usemap_size_28281 usemap_size 0 28281 NULL
104655 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
104656 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
104657 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
104658 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
104659 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
104660 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
104661 +snapshot_write_28351 snapshot_write 3 28351 NULL
104662 +sys_writev_28384 sys_writev 3 28384 NULL
104663 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
104664 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
104665 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
104666 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
104667 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
104668 +__split_large_page_28429 __split_large_page 2 28429 NULL
104669 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
104670 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
104671 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
104672 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
104673 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
104674 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
104675 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
104676 +max_response_pages_28492 max_response_pages 0 28492 NULL
104677 +clear_discard_28494 clear_discard 2 28494 NULL
104678 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
104679 +__next_node_28521 __next_node 1 28521 NULL
104680 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
104681 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
104682 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
104683 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
104684 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
104685 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
104686 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
104687 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
104688 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
104689 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
104690 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
104691 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
104692 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
104693 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
104694 +_set_range_28627 _set_range 3 28627 NULL
104695 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
104696 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
104697 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
104698 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
104699 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
104700 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
104701 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
104702 +spi_execute_28736 spi_execute 5 28736 NULL
104703 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
104704 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
104705 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
104706 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
104707 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
104708 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
104709 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
104710 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
104711 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
104712 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
104713 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
104714 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
104715 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
104716 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
104717 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
104718 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
104719 +to_cblock_28899 to_cblock 0-1 28899 NULL
104720 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
104721 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
104722 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
104723 +push_rx_28939 push_rx 3 28939 NULL
104724 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
104725 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
104726 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
104727 +bin_uuid_28999 bin_uuid 3 28999 NULL
104728 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
104729 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
104730 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
104731 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
104732 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
104733 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
104734 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
104735 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
104736 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
104737 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
104738 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
104739 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
104740 +snprintf_29125 snprintf 0 29125 NULL
104741 +iov_shorten_29130 iov_shorten 0 29130 NULL
104742 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
104743 +reshape_ring_29147 reshape_ring 2 29147 NULL
104744 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
104745 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
104746 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
104747 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
104748 +__mm_populate_29204 __mm_populate 1 29204 NULL
104749 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
104750 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
104751 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
104752 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
104753 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
104754 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
104755 +recover_peb_29238 recover_peb 6-7 29238 NULL
104756 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
104757 +block_div_29268 block_div 0-1-2 29268 NULL
104758 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
104759 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
104760 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
104761 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
104762 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
104763 +tun_put_user_29337 tun_put_user 5 29337 NULL
104764 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
104765 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
104766 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
104767 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
104768 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
104769 +mempool_create_29437 mempool_create 1 29437 NULL
104770 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
104771 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
104772 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
104773 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
104774 +do_register_entry_29478 do_register_entry 4 29478 NULL
104775 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
104776 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
104777 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
104778 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
104779 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
104780 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
104781 +set_brk_29551 set_brk 1 29551 NULL nohasharray
104782 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
104783 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
104784 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
104785 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
104786 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
104787 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
104788 +slots_per_page_29601 slots_per_page 0 29601 NULL
104789 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
104790 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
104791 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
104792 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
104793 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
104794 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
104795 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
104796 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
104797 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
104798 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
104799 +probes_write_29711 probes_write 3 29711 NULL
104800 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
104801 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
104802 +std_nic_write_29752 std_nic_write 3 29752 NULL
104803 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
104804 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
104805 +dbAlloc_29794 dbAlloc 0 29794 NULL
104806 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
104807 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
104808 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
104809 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
104810 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
104811 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
104812 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
104813 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
104814 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
104815 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
104816 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
104817 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
104818 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
104819 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
104820 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
104821 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
104822 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
104823 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
104824 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
104825 +drp_wmove_30043 drp_wmove 4 30043 NULL
104826 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
104827 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
104828 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
104829 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
104830 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
104831 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
104832 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
104833 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
104834 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
104835 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
104836 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
104837 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
104838 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
104839 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
104840 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
104841 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
104842 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
104843 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
104844 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
104845 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
104846 +compat_readv_30273 compat_readv 3 30273 NULL
104847 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
104848 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
104849 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
104850 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
104851 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
104852 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
104853 +resource_from_user_30341 resource_from_user 3 30341 NULL
104854 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
104855 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
104856 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
104857 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
104858 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
104859 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
104860 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
104861 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
104862 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
104863 +mq_create_30425 mq_create 1 30425 NULL
104864 +enable_write_30456 enable_write 3 30456 NULL
104865 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
104866 +urandom_read_30462 urandom_read 3 30462 NULL
104867 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
104868 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
104869 +write_head_30481 write_head 4 30481 NULL
104870 +adu_write_30487 adu_write 3 30487 NULL
104871 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
104872 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
104873 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
104874 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
104875 +set_le_30581 set_le 4 30581 NULL
104876 +from_cblock_30582 from_cblock 0-1 30582 NULL
104877 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
104878 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
104879 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
104880 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
104881 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
104882 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
104883 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
104884 +agp_remap_30665 agp_remap 2 30665 NULL
104885 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
104886 +il_free_pages_30692 il_free_pages 2 30692 NULL
104887 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
104888 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
104889 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
104890 +snapshot_status_30744 snapshot_status 5 30744 NULL
104891 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
104892 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
104893 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
104894 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
104895 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
104896 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
104897 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
104898 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
104899 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
104900 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
104901 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
104902 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
104903 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
104904 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
104905 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
104906 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
104907 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
104908 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
104909 +sys_mincore_31079 sys_mincore 1 31079 NULL
104910 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
104911 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
104912 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
104913 +depth_read_31112 depth_read 3 31112 NULL
104914 +ssb_read16_31139 ssb_read16 0 31139 NULL
104915 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
104916 +size_inside_page_31141 size_inside_page 0 31141 NULL
104917 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
104918 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
104919 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
104920 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
104921 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
104922 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
104923 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
104924 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
104925 +__read_reg_31216 __read_reg 0 31216 NULL
104926 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
104927 +cyy_readb_31240 cyy_readb 0 31240 NULL
104928 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
104929 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
104930 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
104931 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
104932 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
104933 +command_file_write_31318 command_file_write 3 31318 NULL
104934 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
104935 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
104936 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
104937 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
104938 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
104939 +inb_31388 inb 0 31388 NULL
104940 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
104941 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
104942 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
104943 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
104944 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
104945 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
104946 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
104947 +do_fcntl_31468 do_fcntl 3 31468 NULL
104948 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
104949 +alg_setkey_31485 alg_setkey 3 31485 NULL
104950 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
104951 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
104952 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
104953 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
104954 +hidraw_write_31536 hidraw_write 3 31536 NULL
104955 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
104956 +usbvision_read_31555 usbvision_read 3 31555 NULL
104957 +normalize_31566 normalize 0-1-2 31566 NULL
104958 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
104959 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
104960 +osst_write_31581 osst_write 3 31581 NULL
104961 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
104962 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
104963 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
104964 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
104965 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
104966 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
104967 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
104968 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
104969 +__lgread_31668 __lgread 4 31668 NULL
104970 +symbol_string_31670 symbol_string 0 31670 NULL
104971 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
104972 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
104973 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
104974 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
104975 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
104976 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
104977 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
104978 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
104979 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
104980 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
104981 +muldiv64_31743 muldiv64 2-3 31743 NULL
104982 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
104983 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
104984 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
104985 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
104986 +get_count_order_31800 get_count_order 0 31800 NULL
104987 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
104988 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
104989 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
104990 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
104991 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
104992 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
104993 +xattr_permission_31907 xattr_permission 0 31907 NULL
104994 +new_dir_31919 new_dir 3 31919 NULL
104995 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
104996 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
104997 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
104998 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
104999 +vb2_write_31948 vb2_write 3 31948 NULL
105000 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
105001 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
105002 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
105003 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
105004 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
105005 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
105006 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
105007 +calc_hmac_32010 calc_hmac 3 32010 NULL
105008 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
105009 +aead_len_32021 aead_len 0 32021 NULL
105010 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
105011 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
105012 +stk_read_32038 stk_read 3 32038 NULL
105013 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
105014 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
105015 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
105016 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
105017 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
105018 +bio_alloc_32095 bio_alloc 2 32095 NULL
105019 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
105020 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
105021 +disk_status_32120 disk_status 4 32120 NULL
105022 +venus_link_32165 venus_link 5 32165 NULL
105023 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
105024 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
105025 +load_header_32183 load_header 0 32183 NULL
105026 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
105027 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
105028 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
105029 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
105030 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
105031 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
105032 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
105033 +hex_string_32310 hex_string 0 32310 NULL
105034 +SyS_select_32319 SyS_select 1 32319 NULL
105035 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
105036 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
105037 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
105038 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
105039 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
105040 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
105041 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
105042 +local_clock_32385 local_clock 0 32385 NULL
105043 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
105044 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
105045 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
105046 +log_text_32428 log_text 0 32428 NULL
105047 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
105048 +hid_input_report_32458 hid_input_report 4 32458 NULL
105049 +cache_status_32462 cache_status 5 32462 NULL
105050 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
105051 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
105052 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
105053 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
105054 +disconnect_32521 disconnect 4 32521 NULL
105055 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
105056 +ilo_read_32531 ilo_read 3 32531 NULL
105057 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
105058 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
105059 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
105060 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
105061 +__first_node_32558 __first_node 0 32558 NULL
105062 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
105063 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
105064 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
105065 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
105066 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
105067 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
105068 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
105069 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
105070 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
105071 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
105072 +kvmalloc_32646 kvmalloc 1 32646 NULL
105073 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
105074 +generic_readlink_32654 generic_readlink 3 32654 NULL
105075 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
105076 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
105077 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
105078 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
105079 +get_arg_page_32746 get_arg_page 2 32746 NULL
105080 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
105081 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
105082 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
105083 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
105084 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
105085 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
105086 +vga_rseq_32848 vga_rseq 0 32848 NULL
105087 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
105088 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
105089 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
105090 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
105091 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
105092 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
105093 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
105094 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
105095 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
105096 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
105097 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
105098 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
105099 +compat_filldir_32999 compat_filldir 3 32999 NULL
105100 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
105101 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
105102 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
105103 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
105104 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
105105 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
105106 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
105107 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
105108 +alloc_tio_33077 alloc_tio 3 33077 NULL
105109 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
105110 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
105111 +write_node_33121 write_node 4 33121 NULL
105112 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
105113 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
105114 +__len_within_target_33132 __len_within_target 0 33132 NULL
105115 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
105116 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
105117 +pp_read_33210 pp_read 3 33210 NULL
105118 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
105119 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
105120 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
105121 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
105122 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
105123 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
105124 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
105125 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
105126 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
105127 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
105128 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
105129 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
105130 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
105131 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
105132 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
105133 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
105134 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
105135 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
105136 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
105137 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
105138 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
105139 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
105140 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
105141 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
105142 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
105143 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
105144 +create_entry_33479 create_entry 2 33479 NULL
105145 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
105146 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
105147 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
105148 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
105149 +res_counter_read_33499 res_counter_read 4 33499 NULL
105150 +fb_read_33506 fb_read 3 33506 NULL
105151 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
105152 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
105153 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
105154 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
105155 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
105156 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
105157 +dup_array_33551 dup_array 3 33551 NULL
105158 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
105159 +count_subheaders_33591 count_subheaders 0 33591 NULL
105160 +scsi_execute_33596 scsi_execute 5 33596 NULL
105161 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
105162 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
105163 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
105164 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
105165 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
105166 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
105167 +inw_p_33668 inw_p 0 33668 NULL
105168 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
105169 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
105170 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
105171 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
105172 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
105173 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
105174 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
105175 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
105176 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
105177 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
105178 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
105179 +Read_hfc_33755 Read_hfc 0 33755 NULL
105180 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
105181 +hashtab_create_33769 hashtab_create 3 33769 NULL
105182 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
105183 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
105184 +find_next_offset_33804 find_next_offset 3 33804 NULL
105185 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
105186 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
105187 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
105188 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
105189 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
105190 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
105191 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
105192 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
105193 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
105194 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
105195 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
105196 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
105197 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
105198 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
105199 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
105200 +ppp_write_34034 ppp_write 3 34034 NULL
105201 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
105202 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
105203 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
105204 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
105205 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
105206 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
105207 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
105208 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
105209 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
105210 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
105211 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
105212 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
105213 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
105214 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
105215 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
105216 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
105217 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
105218 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
105219 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
105220 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
105221 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
105222 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
105223 +__insert_34349 __insert 2-3 34349 NULL
105224 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
105225 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
105226 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
105227 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
105228 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
105229 +ea_read_34378 ea_read 0 34378 NULL
105230 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
105231 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
105232 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
105233 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
105234 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
105235 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
105236 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
105237 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
105238 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
105239 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
105240 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
105241 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
105242 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
105243 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
105244 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
105245 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
105246 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
105247 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
105248 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
105249 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
105250 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
105251 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
105252 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
105253 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
105254 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
105255 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
105256 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
105257 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
105258 +port_print_34704 port_print 3 34704 NULL
105259 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
105260 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
105261 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
105262 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
105263 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
105264 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
105265 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
105266 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
105267 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
105268 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
105269 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
105270 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
105271 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
105272 +msg_print_text_34889 msg_print_text 0 34889 NULL
105273 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
105274 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
105275 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
105276 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
105277 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
105278 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
105279 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
105280 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
105281 +Realloc_34961 Realloc 2 34961 NULL
105282 +mq_lookup_34990 mq_lookup 2 34990 NULL
105283 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
105284 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
105285 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
105286 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
105287 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
105288 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
105289 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
105290 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
105291 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
105292 +store_ifalias_35088 store_ifalias 4 35088 NULL
105293 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
105294 +capi_write_35104 capi_write 3 35104 NULL nohasharray
105295 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
105296 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
105297 +pointer_35138 pointer 0 35138 NULL
105298 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
105299 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
105300 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
105301 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
105302 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
105303 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
105304 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
105305 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
105306 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
105307 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
105308 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
105309 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
105310 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
105311 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
105312 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
105313 +set_fd_set_35249 set_fd_set 1 35249 NULL
105314 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
105315 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
105316 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
105317 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
105318 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
105319 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
105320 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
105321 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
105322 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
105323 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
105324 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
105325 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
105326 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
105327 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
105328 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
105329 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
105330 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
105331 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
105332 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
105333 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
105334 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
105335 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
105336 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
105337 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
105338 +async_setkey_35521 async_setkey 3 35521 NULL
105339 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
105340 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
105341 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
105342 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
105343 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
105344 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
105345 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
105346 +ReadZReg_35604 ReadZReg 0 35604 NULL
105347 +kernel_readv_35617 kernel_readv 3 35617 NULL
105348 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
105349 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
105350 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
105351 +store_debug_level_35652 store_debug_level 3 35652 NULL
105352 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
105353 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
105354 +dm_table_create_35687 dm_table_create 3 35687 NULL
105355 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
105356 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
105357 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
105358 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
105359 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
105360 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
105361 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
105362 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
105363 +fls64_35862 fls64 0 35862 NULL
105364 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
105365 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
105366 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
105367 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
105368 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
105369 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
105370 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
105371 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
105372 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
105373 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
105374 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
105375 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
105376 +acl_alloc_35979 acl_alloc 1 35979 NULL
105377 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
105378 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
105379 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
105380 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
105381 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
105382 +account_shadowed_36048 account_shadowed 2 36048 NULL
105383 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
105384 +write_emulate_36065 write_emulate 2-4 36065 NULL
105385 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
105386 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
105387 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
105388 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
105389 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
105390 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
105391 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
105392 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
105393 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
105394 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
105395 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
105396 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
105397 +twl_set_36154 twl_set 2 36154 NULL
105398 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
105399 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
105400 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
105401 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
105402 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
105403 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
105404 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
105405 +is_dirty_36223 is_dirty 2 36223 NULL
105406 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
105407 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
105408 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
105409 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
105410 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
105411 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
105412 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
105413 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
105414 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
105415 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
105416 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
105417 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
105418 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
105419 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
105420 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
105421 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
105422 +lc_create_36332 lc_create 4 36332 NULL
105423 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
105424 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
105425 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
105426 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
105427 +to_sector_36361 to_sector 0-1 36361 NULL
105428 +tunables_read_36385 tunables_read 3 36385 NULL
105429 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
105430 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
105431 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
105432 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
105433 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
105434 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
105435 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
105436 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
105437 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
105438 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
105439 +get_param_l_36518 get_param_l 0 36518 NULL
105440 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
105441 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
105442 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
105443 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
105444 +get_entry_len_36549 get_entry_len 0 36549 NULL
105445 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
105446 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
105447 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
105448 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
105449 +__erst_read_36579 __erst_read 0 36579 NULL
105450 +put_cmsg_36589 put_cmsg 4 36589 NULL
105451 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
105452 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
105453 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
105454 +format_decode_36638 format_decode 0 36638 NULL
105455 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
105456 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
105457 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
105458 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
105459 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
105460 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
105461 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
105462 +sched_clock_36717 sched_clock 0 36717 NULL
105463 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
105464 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
105465 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
105466 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
105467 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
105468 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
105469 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
105470 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
105471 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
105472 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
105473 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
105474 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
105475 +cm_write_36858 cm_write 3 36858 NULL
105476 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
105477 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
105478 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
105479 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
105480 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
105481 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
105482 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
105483 +build_key_36931 build_key 1 36931 NULL
105484 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
105485 +write_leb_36957 write_leb 5 36957 NULL
105486 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
105487 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
105488 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
105489 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
105490 +setxattr_37006 setxattr 4 37006 NULL
105491 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
105492 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
105493 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
105494 +parse_command_37079 parse_command 2 37079 NULL
105495 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
105496 +tun_get_user_37094 tun_get_user 5 37094 NULL
105497 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
105498 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
105499 +msg_word_37164 msg_word 0 37164 NULL
105500 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
105501 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
105502 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
105503 +__do_replace_37227 __do_replace 5 37227 NULL
105504 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
105505 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
105506 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
105507 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
105508 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
105509 +c101_run_37279 c101_run 2 37279 NULL
105510 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
105511 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
105512 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
105513 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
105514 +send_msg_37323 send_msg 4 37323 NULL
105515 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
105516 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
105517 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
105518 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
105519 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
105520 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
105521 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
105522 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
105523 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
105524 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
105525 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
105526 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
105527 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
105528 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
105529 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
105530 +__remove_37457 __remove 2 37457 NULL
105531 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
105532 +get_est_timing_37484 get_est_timing 0 37484 NULL
105533 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
105534 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
105535 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
105536 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
105537 +hdr_size_37536 hdr_size 0 37536 NULL
105538 +a2p_37544 a2p 0-1 37544 NULL
105539 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
105540 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
105541 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
105542 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
105543 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
105544 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
105545 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
105546 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
105547 +check_pt_base_37635 check_pt_base 3 37635 NULL
105548 +alloc_fd_37637 alloc_fd 1 37637 NULL
105549 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
105550 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
105551 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
105552 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
105553 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
105554 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
105555 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
105556 +nametbl_header_37698 nametbl_header 2 37698 NULL
105557 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
105558 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
105559 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
105560 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
105561 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
105562 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
105563 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
105564 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
105565 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
105566 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
105567 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
105568 +deny_write_access_37813 deny_write_access 0 37813 NULL
105569 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
105570 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
105571 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
105572 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
105573 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
105574 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
105575 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
105576 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
105577 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
105578 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
105579 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
105580 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
105581 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
105582 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
105583 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
105584 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
105585 +vfs_readv_38011 vfs_readv 3 38011 NULL
105586 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
105587 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
105588 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
105589 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
105590 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
105591 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
105592 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
105593 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
105594 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
105595 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
105596 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
105597 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
105598 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
105599 +ep0_read_38095 ep0_read 3 38095 NULL
105600 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
105601 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
105602 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
105603 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
105604 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
105605 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
105606 +cdev_add_38176 cdev_add 2-3 38176 NULL
105607 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
105608 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
105609 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
105610 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
105611 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
105612 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
105613 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
105614 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
105615 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
105616 +from_dblock_38256 from_dblock 0-1 38256 NULL
105617 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
105618 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
105619 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
105620 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
105621 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
105622 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
105623 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
105624 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
105625 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
105626 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
105627 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
105628 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
105629 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
105630 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
105631 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
105632 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
105633 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
105634 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
105635 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
105636 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
105637 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
105638 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
105639 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
105640 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
105641 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
105642 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
105643 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
105644 +dev_names_read_38509 dev_names_read 3 38509 NULL
105645 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
105646 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
105647 +set_queue_count_38519 set_queue_count 0 38519 NULL
105648 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
105649 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
105650 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
105651 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
105652 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
105653 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
105654 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
105655 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
105656 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
105657 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
105658 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
105659 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
105660 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
105661 +cma_create_area_38642 cma_create_area 2 38642 NULL
105662 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
105663 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
105664 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
105665 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
105666 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
105667 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
105668 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
105669 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
105670 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
105671 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
105672 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
105673 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
105674 +udf_readpages_38761 udf_readpages 4 38761 NULL
105675 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
105676 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
105677 +err_decode_38804 err_decode 2 38804 NULL
105678 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
105679 +sys_select_38827 sys_select 1 38827 NULL
105680 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
105681 +direct_entry_38836 direct_entry 3 38836 NULL
105682 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
105683 +interfaces_38859 interfaces 2 38859 NULL
105684 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
105685 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
105686 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
105687 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
105688 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
105689 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
105690 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
105691 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
105692 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
105693 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
105694 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
105695 +udf_new_block_38999 udf_new_block 4 38999 NULL
105696 +get_nodes_39012 get_nodes 3 39012 NULL
105697 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
105698 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
105699 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
105700 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
105701 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
105702 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
105703 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
105704 +ea_foreach_39133 ea_foreach 0 39133 NULL
105705 +generic_permission_39150 generic_permission 0 39150 NULL
105706 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
105707 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
105708 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
105709 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
105710 +init_list_set_39188 init_list_set 2-3 39188 NULL
105711 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
105712 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
105713 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
105714 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
105715 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
105716 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
105717 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
105718 +drm_order_39244 drm_order 0 39244 NULL
105719 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
105720 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
105721 +__skb_cow_39254 __skb_cow 2 39254 NULL
105722 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
105723 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
105724 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
105725 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
105726 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
105727 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
105728 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
105729 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
105730 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
105731 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
105732 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
105733 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
105734 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
105735 +__send_to_port_39386 __send_to_port 3 39386 NULL
105736 +user_power_read_39414 user_power_read 3 39414 NULL
105737 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
105738 +sys_semop_39457 sys_semop 3 39457 NULL
105739 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
105740 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
105741 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
105742 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
105743 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
105744 +int_proc_write_39542 int_proc_write 3 39542 NULL
105745 +pp_write_39554 pp_write 3 39554 NULL
105746 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
105747 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
105748 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
105749 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
105750 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
105751 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
105752 +ext_depth_39607 ext_depth 0 39607 NULL
105753 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
105754 +sdio_readb_39618 sdio_readb 0 39618 NULL
105755 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
105756 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
105757 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
105758 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
105759 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
105760 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
105761 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
105762 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
105763 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
105764 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
105765 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
105766 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
105767 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
105768 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
105769 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
105770 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
105771 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
105772 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
105773 +pkt_add_39897 pkt_add 3 39897 NULL
105774 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
105775 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
105776 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
105777 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
105778 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
105779 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
105780 +__spi_async_39932 __spi_async 0 39932 NULL
105781 +__get_order_39935 __get_order 0 39935 NULL
105782 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
105783 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
105784 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
105785 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
105786 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
105787 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
105788 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
105789 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
105790 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
105791 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
105792 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
105793 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
105794 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
105795 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
105796 +add_tty_40055 add_tty 1 40055 NULL nohasharray
105797 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
105798 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
105799 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
105800 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
105801 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
105802 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
105803 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
105804 +pt_write_40159 pt_write 3 40159 NULL
105805 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
105806 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
105807 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
105808 +allocate_probes_40204 allocate_probes 1 40204 NULL
105809 +compat_put_long_40214 compat_put_long 1 40214 NULL
105810 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
105811 +osst_read_40237 osst_read 3 40237 NULL
105812 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
105813 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
105814 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
105815 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
105816 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
105817 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
105818 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
105819 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
105820 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
105821 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
105822 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
105823 +mmio_read_40348 mmio_read 4 40348 NULL
105824 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
105825 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
105826 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
105827 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
105828 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
105829 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
105830 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
105831 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
105832 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
105833 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
105834 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
105835 +tty_write_room_40495 tty_write_room 0 40495 NULL
105836 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
105837 +sg_phys_40507 sg_phys 0 40507 NULL
105838 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
105839 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
105840 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
105841 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
105842 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
105843 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
105844 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
105845 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
105846 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
105847 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
105848 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
105849 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
105850 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
105851 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
105852 +fops_read_40672 fops_read 3 40672 NULL
105853 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
105854 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
105855 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
105856 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
105857 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
105858 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
105859 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
105860 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
105861 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
105862 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
105863 +card_send_command_40757 card_send_command 3 40757 NULL
105864 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
105865 +pg_write_40766 pg_write 3 40766 NULL
105866 +show_list_40775 show_list 3 40775 NULL
105867 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
105868 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
105869 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
105870 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
105871 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
105872 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
105873 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
105874 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
105875 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
105876 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
105877 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
105878 +read_file_queue_40895 read_file_queue 3 40895 NULL
105879 +waiters_read_40902 waiters_read 3 40902 NULL
105880 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
105881 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
105882 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
105883 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
105884 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
105885 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
105886 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
105887 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
105888 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
105889 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
105890 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
105891 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
105892 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
105893 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
105894 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
105895 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
105896 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
105897 +dma_attach_41094 dma_attach 5-6 41094 NULL
105898 +provide_user_output_41105 provide_user_output 3 41105 NULL
105899 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
105900 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
105901 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
105902 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
105903 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
105904 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
105905 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
105906 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
105907 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
105908 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
105909 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
105910 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
105911 +erst_read_41260 erst_read 0 41260 NULL
105912 +__fprog_create_41263 __fprog_create 2 41263 NULL
105913 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
105914 +alloc_context_41283 alloc_context 1 41283 NULL
105915 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
105916 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
105917 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
105918 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
105919 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
105920 +kmp_init_41373 kmp_init 2 41373 NULL
105921 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
105922 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
105923 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
105924 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
105925 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
105926 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
105927 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
105928 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
105929 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
105930 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
105931 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
105932 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
105933 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
105934 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
105935 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
105936 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
105937 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
105938 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
105939 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
105940 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
105941 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
105942 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
105943 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
105944 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
105945 +vga_io_r_41609 vga_io_r 0 41609 NULL
105946 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
105947 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
105948 +a2mp_send_41615 a2mp_send 4 41615 NULL
105949 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
105950 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
105951 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
105952 +get_std_timing_41654 get_std_timing 0 41654 NULL
105953 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
105954 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
105955 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
105956 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
105957 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
105958 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
105959 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
105960 +fillonedir_41746 fillonedir 3 41746 NULL
105961 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
105962 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
105963 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
105964 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
105965 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
105966 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
105967 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
105968 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
105969 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
105970 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
105971 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
105972 +get_packet_41914 get_packet 3 41914 NULL
105973 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
105974 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
105975 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
105976 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
105977 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
105978 +read_gssp_41947 read_gssp 3 41947 NULL
105979 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
105980 +portnames_read_41958 portnames_read 3 41958 NULL
105981 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
105982 +dst_mtu_41969 dst_mtu 0 41969 NULL
105983 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
105984 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
105985 +lguest_map_42008 lguest_map 1-2 42008 NULL
105986 +pool_allocate_42012 pool_allocate 3 42012 NULL
105987 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
105988 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
105989 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
105990 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
105991 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
105992 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
105993 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
105994 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
105995 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
105996 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
105997 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
105998 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
105999 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
106000 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
106001 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
106002 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
106003 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
106004 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
106005 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
106006 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
106007 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
106008 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
106009 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
106010 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
106011 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
106012 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
106013 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
106014 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
106015 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
106016 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
106017 +free_cblock_42318 free_cblock 2 42318 NULL
106018 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
106019 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
106020 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
106021 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
106022 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
106023 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
106024 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
106025 +krng_get_random_42420 krng_get_random 3 42420 NULL
106026 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
106027 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
106028 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
106029 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
106030 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
106031 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
106032 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
106033 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
106034 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
106035 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
106036 +bypass_write_42498 bypass_write 3 42498 NULL
106037 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
106038 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
106039 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
106040 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
106041 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
106042 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
106043 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
106044 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
106045 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
106046 +map_state_42602 map_state 1 42602 NULL nohasharray
106047 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
106048 +nd_get_link_42603 nd_get_link 0 42603 NULL
106049 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
106050 +resp_write_42628 resp_write 2 42628 NULL
106051 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
106052 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
106053 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
106054 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
106055 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
106056 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
106057 +vb2_read_42703 vb2_read 3 42703 NULL
106058 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
106059 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
106060 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
106061 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
106062 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
106063 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
106064 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
106065 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
106066 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
106067 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
106068 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
106069 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
106070 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
106071 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
106072 +set_arg_42824 set_arg 3 42824 NULL
106073 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
106074 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
106075 +prandom_u32_42853 prandom_u32 0 42853 NULL
106076 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
106077 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
106078 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
106079 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
106080 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
106081 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
106082 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
106083 +hd_end_request_42904 hd_end_request 2 42904 NULL
106084 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
106085 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
106086 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
106087 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
106088 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
106089 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
106090 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
106091 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
106092 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
106093 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
106094 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
106095 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
106096 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
106097 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
106098 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
106099 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
106100 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
106101 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
106102 +uuid_string_43154 uuid_string 0 43154 NULL
106103 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
106104 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
106105 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
106106 +process_measurement_43190 process_measurement 0 43190 NULL
106107 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
106108 +uio_write_43202 uio_write 3 43202 NULL
106109 +iso_callback_43208 iso_callback 3 43208 NULL
106110 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
106111 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
106112 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
106113 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
106114 +fixup_leb_43256 fixup_leb 3 43256 NULL
106115 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
106116 +evtchn_write_43278 evtchn_write 3 43278 NULL
106117 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
106118 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
106119 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
106120 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
106121 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
106122 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
106123 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
106124 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
106125 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
106126 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
106127 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
106128 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
106129 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
106130 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
106131 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
106132 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
106133 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
106134 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
106135 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
106136 +do_readlink_43518 do_readlink 2 43518 NULL
106137 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
106138 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
106139 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
106140 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
106141 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
106142 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
106143 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
106144 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
106145 +proc_read_43614 proc_read 3 43614 NULL
106146 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
106147 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
106148 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
106149 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
106150 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
106151 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
106152 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
106153 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
106154 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
106155 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
106156 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
106157 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
106158 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
106159 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
106160 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
106161 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
106162 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
106163 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
106164 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
106165 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
106166 +read_flush_43851 read_flush 3 43851 NULL
106167 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
106168 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
106169 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
106170 +SendString_43928 SendString 3 43928 NULL
106171 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
106172 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
106173 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
106174 +nla_reserve_43984 nla_reserve 3 43984 NULL
106175 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
106176 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
106177 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
106178 +emit_flags_44006 emit_flags 4-3 44006 NULL
106179 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
106180 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
106181 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
106182 +load_discard_44083 load_discard 3 44083 NULL
106183 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
106184 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
106185 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
106186 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
106187 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
106188 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
106189 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
106190 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
106191 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
106192 +__set_free_44211 __set_free 2 44211 NULL
106193 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
106194 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
106195 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
106196 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
106197 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
106198 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
106199 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
106200 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
106201 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
106202 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
106203 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
106204 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
106205 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
106206 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
106207 +__is_discarded_44359 __is_discarded 2 44359 NULL
106208 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
106209 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
106210 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
106211 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
106212 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
106213 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
106214 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
106215 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
106216 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
106217 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
106218 +bio_advance_44496 bio_advance 2 44496 NULL
106219 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
106220 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
106221 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
106222 +spidev_write_44510 spidev_write 3 44510 NULL
106223 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
106224 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
106225 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
106226 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
106227 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
106228 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
106229 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
106230 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
106231 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
106232 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
106233 +mpi_resize_44674 mpi_resize 2 44674 NULL
106234 +ts_read_44687 ts_read 3 44687 NULL
106235 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
106236 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
106237 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
106238 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
106239 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
106240 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
106241 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
106242 +set_brk_44749 set_brk 1 44749 NULL
106243 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
106244 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
106245 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
106246 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
106247 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
106248 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
106249 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
106250 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
106251 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
106252 +sisusb_write_44834 sisusb_write 3 44834 NULL
106253 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
106254 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
106255 +cubic_root_44848 cubic_root 1 44848 NULL
106256 +copydesc_user_44855 copydesc_user 3 44855 NULL
106257 +skb_availroom_44883 skb_availroom 0 44883 NULL
106258 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
106259 +do_tty_write_44896 do_tty_write 5 44896 NULL
106260 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
106261 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
106262 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
106263 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
106264 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
106265 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
106266 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
106267 +sel_write_user_45060 sel_write_user 3 45060 NULL
106268 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
106269 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
106270 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
106271 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
106272 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
106273 +usbdev_read_45114 usbdev_read 3 45114 NULL
106274 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
106275 +send_to_tty_45141 send_to_tty 3 45141 NULL
106276 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
106277 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
106278 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
106279 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
106280 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
106281 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
106282 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
106283 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
106284 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
106285 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
106286 +add_child_45201 add_child 4 45201 NULL
106287 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
106288 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
106289 +__dirty_45228 __dirty 2 45228 NULL
106290 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
106291 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
106292 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
106293 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
106294 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
106295 +pte_val_45313 pte_val 0 45313 NULL
106296 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
106297 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
106298 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
106299 +keymap_store_45406 keymap_store 4 45406 NULL
106300 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
106301 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
106302 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
106303 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
106304 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
106305 +__node_remap_45458 __node_remap 4 45458 NULL
106306 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
106307 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
106308 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
106309 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
106310 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
106311 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
106312 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
106313 +copy_macs_45534 copy_macs 4 45534 NULL
106314 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
106315 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
106316 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
106317 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
106318 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
106319 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
106320 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
106321 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
106322 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
106323 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
106324 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
106325 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
106326 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
106327 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
106328 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
106329 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
106330 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
106331 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
106332 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
106333 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
106334 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
106335 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
106336 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
106337 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
106338 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
106339 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
106340 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
106341 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
106342 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
106343 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
106344 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
106345 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
106346 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
106347 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
106348 +isdn_write_45863 isdn_write 3 45863 NULL
106349 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
106350 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
106351 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
106352 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
106353 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
106354 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
106355 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
106356 +alloc_mr_45935 alloc_mr 1 45935 NULL
106357 +split_large_page_45941 split_large_page 2 45941 NULL
106358 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
106359 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
106360 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
106361 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
106362 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
106363 +get_free_entries_46030 get_free_entries 1 46030 NULL
106364 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
106365 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
106366 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
106367 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
106368 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
106369 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
106370 +slhc_toss_46066 slhc_toss 0 46066 NULL
106371 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
106372 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
106373 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
106374 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
106375 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
106376 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
106377 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
106378 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
106379 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
106380 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
106381 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
106382 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
106383 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
106384 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
106385 +add_conn_list_46197 add_conn_list 3 46197 NULL
106386 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
106387 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
106388 +dsp_write_46218 dsp_write 2 46218 NULL
106389 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
106390 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
106391 +ReadReg_46277 ReadReg 0 46277 NULL
106392 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
106393 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
106394 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
106395 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
106396 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
106397 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
106398 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
106399 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
106400 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
106401 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
106402 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
106403 +filldir64_46469 filldir64 3 46469 NULL
106404 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
106405 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
106406 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
106407 +kmsg_read_46514 kmsg_read 3 46514 NULL
106408 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
106409 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
106410 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
106411 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
106412 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
106413 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
106414 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
106415 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
106416 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
106417 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
106418 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
106419 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
106420 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
106421 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
106422 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
106423 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
106424 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
106425 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
106426 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
106427 +prepare_copy_46725 prepare_copy 2 46725 NULL
106428 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
106429 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
106430 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
106431 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
106432 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
106433 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
106434 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
106435 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
106436 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
106437 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
106438 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
106439 +spi_async_46857 spi_async 0 46857 NULL
106440 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
106441 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
106442 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
106443 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
106444 +rvmalloc_46873 rvmalloc 1 46873 NULL
106445 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
106446 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
106447 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
106448 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
106449 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
106450 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
106451 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
106452 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
106453 +fb_write_46924 fb_write 3 46924 NULL
106454 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
106455 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
106456 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
106457 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
106458 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
106459 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
106460 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
106461 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
106462 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
106463 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
106464 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
106465 +__map_single_47020 __map_single 3-4-7 47020 NULL
106466 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
106467 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
106468 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
106469 +fs_path_len_47060 fs_path_len 0 47060 NULL
106470 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
106471 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
106472 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
106473 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
106474 +mousedev_read_47123 mousedev_read 3 47123 NULL
106475 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
106476 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
106477 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
106478 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
106479 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
106480 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
106481 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
106482 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
106483 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
106484 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
106485 +l2headersize_47238 l2headersize 0 47238 NULL
106486 +options_write_47243 options_write 3 47243 NULL
106487 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
106488 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
106489 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
106490 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
106491 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
106492 +vsnprintf_47291 vsnprintf 0 47291 NULL
106493 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
106494 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
106495 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
106496 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
106497 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
106498 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
106499 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
106500 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
106501 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
106502 +nametbl_list_47391 nametbl_list 2 47391 NULL
106503 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
106504 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
106505 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
106506 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
106507 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
106508 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
106509 +vzalloc_47421 vzalloc 1 47421 NULL
106510 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
106511 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
106512 +__load_mapping_47460 __load_mapping 2 47460 NULL
106513 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
106514 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
106515 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
106516 +core_sys_select_47494 core_sys_select 1 47494 NULL
106517 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
106518 +unlink_simple_47506 unlink_simple 3 47506 NULL
106519 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
106520 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
106521 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
106522 +oz_events_read_47535 oz_events_read 3 47535 NULL
106523 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
106524 +read_ldt_47570 read_ldt 2 47570 NULL
106525 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
106526 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
106527 +pci_iomap_47575 pci_iomap 3 47575 NULL
106528 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
106529 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
106530 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
106531 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
106532 +uea_request_47613 uea_request 4 47613 NULL
106533 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
106534 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
106535 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
106536 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
106537 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
106538 +save_microcode_47717 save_microcode 3 47717 NULL
106539 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
106540 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
106541 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
106542 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
106543 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
106544 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
106545 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
106546 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
106547 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
106548 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
106549 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
106550 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
106551 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
106552 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
106553 +vhci_read_47878 vhci_read 3 47878 NULL
106554 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
106555 +load_mapping_47904 load_mapping 3 47904 NULL
106556 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
106557 +comedi_write_47926 comedi_write 3 47926 NULL
106558 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
106559 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
106560 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
106561 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
106562 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
106563 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
106564 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
106565 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
106566 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
106567 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
106568 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
106569 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
106570 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
106571 +disc_write_48070 disc_write 3 48070 NULL
106572 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
106573 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
106574 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
106575 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
106576 +set_discoverable_48141 set_discoverable 4 48141 NULL
106577 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
106578 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
106579 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
106580 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
106581 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
106582 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
106583 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
106584 +init_ipath_48187 init_ipath 1 48187 NULL
106585 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
106586 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
106587 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
106588 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
106589 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
106590 +read_file_recv_48232 read_file_recv 3 48232 NULL
106591 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
106592 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
106593 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
106594 +send_set_info_48288 send_set_info 7 48288 NULL
106595 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
106596 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
106597 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
106598 +hash_setkey_48310 hash_setkey 3 48310 NULL
106599 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
106600 +skb_add_data_48363 skb_add_data 3 48363 NULL
106601 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
106602 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
106603 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
106604 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
106605 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
106606 +print_filtered_48442 print_filtered 2-0 48442 NULL
106607 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
106608 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
106609 +send_control_msg_48498 send_control_msg 6 48498 NULL
106610 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
106611 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
106612 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
106613 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
106614 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
106615 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
106616 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
106617 +named_distribute_48544 named_distribute 4 48544 NULL
106618 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
106619 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
106620 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
106621 +mtd_read_48655 mtd_read 0 48655 NULL
106622 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
106623 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
106624 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
106625 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
106626 +altera_drscan_48698 altera_drscan 2 48698 NULL
106627 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
106628 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
106629 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
106630 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
106631 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
106632 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
106633 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
106634 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
106635 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
106636 +azx_get_position_48841 azx_get_position 0 48841 NULL
106637 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
106638 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
106639 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
106640 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
106641 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
106642 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
106643 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
106644 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
106645 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
106646 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
106647 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
106648 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
106649 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
106650 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
106651 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
106652 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
106653 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
106654 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
106655 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
106656 +transient_status_49027 transient_status 4 49027 NULL
106657 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
106658 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
106659 +ubi_read_49061 ubi_read 0 49061 NULL
106660 +scsi_register_49094 scsi_register 2 49094 NULL
106661 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
106662 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
106663 +check_exists_49119 check_exists 2 49119 NULL nohasharray
106664 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
106665 +pt_read_49136 pt_read 3 49136 NULL
106666 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
106667 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
106668 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
106669 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
106670 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
106671 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
106672 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
106673 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
106674 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
106675 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
106676 +resp_write_same_49217 resp_write_same 2 49217 NULL
106677 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
106678 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
106679 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
106680 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
106681 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
106682 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
106683 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
106684 +uio_read_49300 uio_read 3 49300 NULL
106685 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
106686 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
106687 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
106688 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
106689 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
106690 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
106691 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
106692 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
106693 +px_raw_event_49371 px_raw_event 4 49371 NULL
106694 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
106695 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
106696 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
106697 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
106698 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
106699 +md_domain_init_49432 md_domain_init 2 49432 NULL
106700 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
106701 +get_lru_size_49441 get_lru_size 0 49441 NULL
106702 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
106703 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
106704 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
106705 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
106706 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
106707 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
106708 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
106709 +smk_write_access_49561 smk_write_access 3 49561 NULL
106710 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
106711 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
106712 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
106713 +tap_write_49595 tap_write 3 49595 NULL
106714 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
106715 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
106716 +heap_init_49617 heap_init 2 49617 NULL
106717 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
106718 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
106719 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
106720 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
106721 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
106722 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
106723 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
106724 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
106725 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
106726 +check_frame_49741 check_frame 0 49741 NULL
106727 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
106728 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
106729 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
106730 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
106731 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
106732 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
106733 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
106734 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
106735 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
106736 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
106737 +add_uuid_49831 add_uuid 4 49831 NULL
106738 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
106739 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
106740 +twl4030_write_49846 twl4030_write 2 49846 NULL
106741 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
106742 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
106743 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
106744 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
106745 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
106746 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
106747 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
106748 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
106749 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
106750 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
106751 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
106752 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
106753 +__module_alloc_50004 __module_alloc 1 50004 NULL
106754 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
106755 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
106756 +isdn_read_50021 isdn_read 3 50021 NULL
106757 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
106758 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
106759 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
106760 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
106761 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
106762 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
106763 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
106764 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
106765 +read_file_slot_50111 read_file_slot 3 50111 NULL
106766 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
106767 +copy_items_50140 copy_items 6 50140 NULL
106768 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
106769 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
106770 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
106771 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
106772 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
106773 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
106774 +odev_update_50169 odev_update 2 50169 NULL
106775 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
106776 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
106777 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
106778 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
106779 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
106780 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
106781 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
106782 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
106783 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
106784 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
106785 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
106786 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
106787 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
106788 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
106789 +do_launder_page_50329 do_launder_page 0 50329 NULL
106790 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
106791 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
106792 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
106793 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
106794 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
106795 +tpm_read_50344 tpm_read 3 50344 NULL
106796 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
106797 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
106798 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
106799 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
106800 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
106801 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
106802 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
106803 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
106804 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
106805 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
106806 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
106807 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
106808 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
106809 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
106810 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
106811 +force_mapping_50464 force_mapping 2 50464 NULL
106812 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
106813 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
106814 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
106815 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
106816 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
106817 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
106818 +fat_readpages_50582 fat_readpages 4 50582 NULL
106819 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
106820 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
106821 +sge_rx_50594 sge_rx 3 50594 NULL
106822 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
106823 +__ffs_50625 __ffs 0 50625 NULL
106824 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
106825 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
106826 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
106827 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
106828 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
106829 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
106830 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
106831 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
106832 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
106833 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
106834 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
106835 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
106836 +skb_padto_50759 skb_padto 2 50759 NULL
106837 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
106838 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
106839 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
106840 +tpm_write_50798 tpm_write 3 50798 NULL
106841 +write_flush_50803 write_flush 3 50803 NULL
106842 +dvb_play_50814 dvb_play 3 50814 NULL
106843 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
106844 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
106845 +SetArea_50835 SetArea 4 50835 NULL nohasharray
106846 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
106847 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
106848 +self_check_write_50856 self_check_write 5 50856 NULL
106849 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
106850 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
106851 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
106852 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
106853 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
106854 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
106855 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
106856 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
106857 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
106858 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
106859 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
106860 +timeout_write_50991 timeout_write 3 50991 NULL
106861 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
106862 +proc_write_51003 proc_write 3 51003 NULL
106863 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
106864 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
106865 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
106866 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
106867 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
106868 +dump_midi_51040 dump_midi 3 51040 NULL
106869 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
106870 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
106871 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
106872 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
106873 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
106874 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
106875 +ti_recv_51110 ti_recv 3 51110 NULL
106876 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
106877 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
106878 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
106879 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
106880 +set_dirty_51144 set_dirty 3 51144 NULL
106881 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
106882 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
106883 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
106884 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
106885 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
106886 +tipc_send_51238 tipc_send 4 51238 NULL
106887 +drm_property_create_51239 drm_property_create 4 51239 NULL
106888 +st_read_51251 st_read 3 51251 NULL
106889 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
106890 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
106891 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
106892 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
106893 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
106894 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
106895 +get_cell_51316 get_cell 2 51316 NULL
106896 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
106897 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
106898 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
106899 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
106900 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
106901 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
106902 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
106903 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
106904 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
106905 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
106906 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
106907 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
106908 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
106909 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
106910 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
106911 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
106912 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
106913 +vaddr_51480 vaddr 0 51480 NULL
106914 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
106915 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
106916 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
106917 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
106918 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
106919 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
106920 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
106921 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
106922 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
106923 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
106924 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
106925 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
106926 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
106927 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
106928 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
106929 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
106930 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
106931 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
106932 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
106933 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
106934 +sel_write_access_51704 sel_write_access 3 51704 NULL
106935 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
106936 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
106937 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
106938 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
106939 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
106940 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
106941 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
106942 +if_write_51756 if_write 3 51756 NULL
106943 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
106944 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
106945 +to_ratio_51809 to_ratio 2-1 51809 NULL
106946 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
106947 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
106948 +ioread32_51847 ioread32 0 51847 NULL nohasharray
106949 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
106950 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
106951 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
106952 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
106953 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
106954 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
106955 +user_read_51881 user_read 3 51881 NULL
106956 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
106957 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
106958 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
106959 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
106960 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
106961 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
106962 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
106963 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
106964 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
106965 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
106966 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
106967 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
106968 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
106969 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
106970 +rdmalt_52022 rdmalt 0 52022 NULL
106971 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
106972 +override_release_52032 override_release 2 52032 NULL
106973 +end_port_52042 end_port 0 52042 NULL
106974 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
106975 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
106976 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
106977 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
106978 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
106979 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
106980 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
106981 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
106982 +retry_count_read_52129 retry_count_read 3 52129 NULL
106983 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
106984 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
106985 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
106986 +htable_size_52148 htable_size 0-1 52148 NULL
106987 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
106988 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
106989 +alix_present_52165 alix_present 1 52165 NULL
106990 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
106991 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
106992 +print_prefix_52176 print_prefix 0 52176 NULL
106993 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
106994 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
106995 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
106996 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
106997 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
106998 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
106999 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
107000 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
107001 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
107002 +atomic64_read_52300 atomic64_read 0 52300 NULL
107003 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
107004 +read_file_reset_52310 read_file_reset 3 52310 NULL
107005 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
107006 +hwflags_read_52318 hwflags_read 3 52318 NULL
107007 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
107008 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
107009 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
107010 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
107011 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
107012 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
107013 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
107014 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
107015 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
107016 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
107017 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
107018 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
107019 +delay_status_52431 delay_status 5 52431 NULL
107020 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
107021 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
107022 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
107023 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
107024 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
107025 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
107026 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
107027 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
107028 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
107029 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
107030 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
107031 +from_oblock_52546 from_oblock 0-1 52546 NULL
107032 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
107033 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
107034 +emit_code_52583 emit_code 0-3 52583 NULL
107035 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
107036 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
107037 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
107038 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
107039 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
107040 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
107041 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
107042 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
107043 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
107044 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
107045 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
107046 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
107047 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
107048 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
107049 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
107050 +twlreg_write_52880 twlreg_write 3 52880 NULL
107051 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
107052 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
107053 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
107054 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
107055 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
107056 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
107057 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
107058 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
107059 +send_packet_52960 send_packet 4 52960 NULL
107060 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
107061 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
107062 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
107063 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
107064 +num_node_state_52989 num_node_state 0 52989 NULL
107065 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
107066 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
107067 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
107068 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
107069 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
107070 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
107071 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
107072 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
107073 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
107074 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
107075 +verity_status_53120 verity_status 5 53120 NULL
107076 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
107077 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
107078 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
107079 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
107080 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
107081 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
107082 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
107083 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
107084 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
107085 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
107086 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
107087 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
107088 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
107089 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
107090 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
107091 +vm_mmap_53339 vm_mmap 0 53339 NULL
107092 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
107093 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
107094 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
107095 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
107096 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
107097 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
107098 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
107099 +n2_run_53459 n2_run 3 53459 NULL
107100 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
107101 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
107102 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
107103 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
107104 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
107105 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
107106 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
107107 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
107108 +check_acl_53512 check_acl 0 53512 NULL
107109 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
107110 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
107111 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
107112 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
107113 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
107114 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
107115 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
107116 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
107117 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
107118 +_preload_range_53676 _preload_range 2-3 53676 NULL
107119 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
107120 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
107121 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
107122 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
107123 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
107124 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
107125 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
107126 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
107127 +wdm_write_53735 wdm_write 3 53735 NULL
107128 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
107129 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
107130 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
107131 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
107132 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
107133 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
107134 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
107135 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
107136 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
107137 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
107138 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
107139 +pms_read_53873 pms_read 3 53873 NULL
107140 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
107141 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
107142 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
107143 +proc_file_read_53905 proc_file_read 3 53905 NULL
107144 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
107145 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
107146 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
107147 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
107148 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
107149 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
107150 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
107151 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
107152 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
107153 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
107154 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
107155 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
107156 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
107157 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
107158 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
107159 +_malloc_54077 _malloc 1 54077 NULL
107160 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
107161 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
107162 +create_xattr_54106 create_xattr 5 54106 NULL
107163 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
107164 +strn_len_54122 strn_len 0 54122 NULL
107165 +isku_receive_54130 isku_receive 4 54130 NULL
107166 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
107167 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
107168 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
107169 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
107170 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
107171 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
107172 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
107173 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
107174 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
107175 +reada_add_block_54247 reada_add_block 2 54247 NULL
107176 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
107177 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
107178 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
107179 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
107180 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
107181 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
107182 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
107183 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
107184 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
107185 +sprintf_54306 sprintf 0 54306 NULL
107186 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
107187 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
107188 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
107189 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
107190 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
107191 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
107192 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
107193 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
107194 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
107195 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
107196 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
107197 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
107198 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
107199 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
107200 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
107201 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
107202 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
107203 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
107204 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
107205 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
107206 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
107207 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
107208 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
107209 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
107210 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
107211 +viacam_read_54526 viacam_read 3 54526 NULL
107212 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
107213 +setsockopt_54539 setsockopt 5 54539 NULL
107214 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
107215 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
107216 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
107217 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
107218 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
107219 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
107220 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
107221 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
107222 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
107223 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
107224 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
107225 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
107226 +evm_read_key_54674 evm_read_key 3 54674 NULL
107227 +resource_string_54699 resource_string 0 54699 NULL
107228 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
107229 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
107230 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
107231 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
107232 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
107233 +kzalloc_54740 kzalloc 1 54740 NULL
107234 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
107235 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
107236 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
107237 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
107238 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
107239 +domain_init_54797 domain_init 2 54797 NULL
107240 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
107241 +get_dev_size_54807 get_dev_size 0 54807 NULL
107242 +nfsd_write_54809 nfsd_write 6 54809 NULL
107243 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
107244 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
107245 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
107246 +write_rio_54837 write_rio 3 54837 NULL
107247 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
107248 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
107249 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
107250 +printer_read_54851 printer_read 3 54851 NULL
107251 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
107252 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
107253 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
107254 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
107255 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
107256 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
107257 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
107258 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
107259 +add_port_54941 add_port 2 54941 NULL
107260 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
107261 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
107262 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
107263 +c4_add_card_54968 c4_add_card 3 54968 NULL
107264 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
107265 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
107266 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
107267 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
107268 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
107269 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
107270 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
107271 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
107272 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
107273 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
107274 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
107275 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
107276 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
107277 +corrupt_data_55120 corrupt_data 0 55120 NULL
107278 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
107279 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
107280 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
107281 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
107282 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
107283 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
107284 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
107285 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
107286 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
107287 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
107288 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
107289 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
107290 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
107291 +dump_command_55220 dump_command 1 55220 NULL
107292 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
107293 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
107294 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
107295 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
107296 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
107297 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
107298 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
107299 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
107300 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
107301 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
107302 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
107303 +do_shmat_55336 do_shmat 5 55336 NULL
107304 +vme_user_read_55338 vme_user_read 3 55338 NULL
107305 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
107306 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
107307 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
107308 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
107309 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
107310 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
107311 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
107312 +alloc_skb_55439 alloc_skb 1 55439 NULL
107313 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
107314 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
107315 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
107316 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
107317 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
107318 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
107319 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
107320 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
107321 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
107322 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
107323 +ea_get_55522 ea_get 0 55522 NULL
107324 +buffer_size_55534 buffer_size 0 55534 NULL
107325 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
107326 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
107327 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
107328 +add_partition_55588 add_partition 2 55588 NULL
107329 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
107330 +free_pages_55603 free_pages 1 55603 NULL
107331 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
107332 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
107333 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
107334 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
107335 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
107336 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
107337 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
107338 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
107339 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
107340 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
107341 +read_oldmem_55658 read_oldmem 3 55658 NULL
107342 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
107343 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
107344 +get_info_55681 get_info 3 55681 NULL
107345 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
107346 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
107347 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
107348 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
107349 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
107350 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
107351 +set_local_name_55757 set_local_name 4 55757 NULL
107352 +strlen_55778 strlen 0 55778 NULL
107353 +set_spte_55783 set_spte 5-4 55783 NULL
107354 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
107355 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
107356 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
107357 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
107358 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
107359 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
107360 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
107361 +hsc_write_55875 hsc_write 3 55875 NULL
107362 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
107363 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
107364 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
107365 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
107366 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
107367 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
107368 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
107369 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
107370 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
107371 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
107372 +__set_discard_56081 __set_discard 2 56081 NULL
107373 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
107374 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
107375 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
107376 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
107377 +map_addr_56144 map_addr 7 56144 NULL
107378 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
107379 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
107380 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
107381 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
107382 +skb_headroom_56200 skb_headroom 0 56200 NULL
107383 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
107384 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
107385 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
107386 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
107387 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
107388 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
107389 +fd_copyin_56247 fd_copyin 3 56247 NULL
107390 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
107391 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
107392 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
107393 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
107394 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
107395 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
107396 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
107397 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
107398 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
107399 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
107400 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
107401 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
107402 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
107403 +dev_read_56369 dev_read 3 56369 NULL
107404 +write_gssp_56404 write_gssp 3 56404 NULL
107405 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
107406 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
107407 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
107408 +store_msg_56417 store_msg 3 56417 NULL
107409 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
107410 +fl_create_56435 fl_create 5 56435 NULL
107411 +gnttab_map_56439 gnttab_map 2 56439 NULL
107412 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
107413 +set_connectable_56458 set_connectable 4 56458 NULL
107414 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
107415 +putused_user_56467 putused_user 3 56467 NULL
107416 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
107417 +global_rt_period_56476 global_rt_period 0 56476 NULL
107418 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
107419 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
107420 +init_map_ip_56508 init_map_ip 5 56508 NULL
107421 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
107422 +ip_options_get_56538 ip_options_get 4 56538 NULL
107423 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
107424 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
107425 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
107426 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
107427 +event_filter_write_56609 event_filter_write 3 56609 NULL
107428 +gather_array_56641 gather_array 3 56641 NULL
107429 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
107430 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
107431 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
107432 +build_map_info_56696 build_map_info 2 56696 NULL
107433 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
107434 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
107435 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
107436 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
107437 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
107438 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
107439 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
107440 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
107441 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
107442 +hash_lookup_56792 hash_lookup 2 56792 NULL
107443 +do_syslog_56807 do_syslog 3 56807 NULL
107444 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
107445 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
107446 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
107447 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
107448 +wb_lookup_56858 wb_lookup 2 56858 NULL
107449 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
107450 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
107451 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
107452 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
107453 +strcspn_56913 strcspn 0 56913 NULL
107454 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
107455 +check_header_56930 check_header 2 56930 NULL
107456 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
107457 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
107458 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
107459 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
107460 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
107461 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
107462 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
107463 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
107464 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
107465 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
107466 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
107467 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
107468 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
107469 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
107470 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
107471 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
107472 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
107473 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
107474 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
107475 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
107476 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
107477 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
107478 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
107479 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
107480 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
107481 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
107482 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
107483 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
107484 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
107485 +flush_space_57241 flush_space 3 57241 NULL
107486 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
107487 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
107488 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
107489 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
107490 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
107491 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
107492 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
107493 +fw_file_size_57307 fw_file_size 0 57307 NULL
107494 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
107495 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
107496 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
107497 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
107498 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
107499 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
107500 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
107501 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
107502 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
107503 +read_file_blob_57406 read_file_blob 3 57406 NULL
107504 +enclosure_register_57412 enclosure_register 3 57412 NULL
107505 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
107506 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
107507 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
107508 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
107509 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
107510 +ReadReg_57453 ReadReg 0 57453 NULL
107511 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
107512 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
107513 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
107514 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
107515 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
107516 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
107517 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
107518 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
107519 +skb_headlen_57501 skb_headlen 0 57501 NULL
107520 +copy_in_user_57502 copy_in_user 3 57502 NULL
107521 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
107522 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
107523 +init_tag_map_57515 init_tag_map 3 57515 NULL
107524 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
107525 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
107526 +inode_permission_57531 inode_permission 0 57531 NULL
107527 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
107528 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
107529 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
107530 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
107531 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
107532 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
107533 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
107534 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
107535 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
107536 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
107537 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
107538 +mem_read_57631 mem_read 3 57631 NULL
107539 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
107540 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
107541 +r3964_write_57662 r3964_write 4 57662 NULL
107542 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
107543 +__lgwrite_57669 __lgwrite 4 57669 NULL
107544 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
107545 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
107546 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
107547 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
107548 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
107549 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
107550 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
107551 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
107552 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
107553 +ld2_57794 ld2 0 57794 NULL
107554 +ivtv_read_57796 ivtv_read 3 57796 NULL
107555 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
107556 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
107557 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
107558 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
107559 +copy_to_user_57835 copy_to_user 3 57835 NULL
107560 +flash_read_57843 flash_read 3 57843 NULL
107561 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
107562 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
107563 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
107564 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
107565 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
107566 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
107567 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
107568 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
107569 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
107570 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
107571 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
107572 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
107573 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
107574 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
107575 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
107576 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
107577 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
107578 +mce_async_out_58056 mce_async_out 3 58056 NULL
107579 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
107580 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
107581 +cm4040_write_58079 cm4040_write 3 58079 NULL
107582 +udi_log_event_58105 udi_log_event 3 58105 NULL
107583 +savemem_58129 savemem 3 58129 NULL
107584 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
107585 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
107586 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
107587 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
107588 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
107589 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
107590 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
107591 +read_file_debug_58256 read_file_debug 3 58256 NULL
107592 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
107593 +profile_load_58267 profile_load 3 58267 NULL
107594 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
107595 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
107596 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
107597 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
107598 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
107599 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
107600 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
107601 +next_pidmap_58347 next_pidmap 2 58347 NULL
107602 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
107603 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
107604 +save_hint_58359 save_hint 2 58359 NULL
107605 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
107606 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
107607 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
107608 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
107609 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
107610 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
107611 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
107612 +capabilities_read_58457 capabilities_read 3 58457 NULL
107613 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
107614 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
107615 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
107616 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
107617 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
107618 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
107619 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
107620 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
107621 +__clear_discard_58546 __clear_discard 2 58546 NULL
107622 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
107623 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
107624 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
107625 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
107626 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
107627 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
107628 +xip_file_read_58592 xip_file_read 3 58592 NULL
107629 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
107630 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
107631 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
107632 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
107633 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
107634 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
107635 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
107636 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
107637 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
107638 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
107639 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
107640 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
107641 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
107642 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
107643 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
107644 +acpi_map_58725 acpi_map 1-2 58725 NULL
107645 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
107646 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
107647 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
107648 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
107649 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
107650 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
107651 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
107652 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
107653 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
107654 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
107655 +ep_read_58813 ep_read 3 58813 NULL
107656 +command_write_58841 command_write 3 58841 NULL
107657 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
107658 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
107659 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
107660 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
107661 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
107662 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
107663 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
107664 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
107665 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
107666 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
107667 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
107668 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
107669 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
107670 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
107671 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
107672 +ep_write_59008 ep_write 3 59008 NULL
107673 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
107674 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
107675 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
107676 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
107677 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
107678 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
107679 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
107680 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
107681 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
107682 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
107683 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
107684 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
107685 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
107686 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
107687 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
107688 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
107689 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
107690 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
107691 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
107692 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
107693 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
107694 +dt3155_read_59226 dt3155_read 3 59226 NULL
107695 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
107696 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
107697 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
107698 +nla_len_59258 nla_len 0 59258 NULL
107699 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
107700 +fd_copyout_59323 fd_copyout 3 59323 NULL
107701 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
107702 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
107703 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
107704 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
107705 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
107706 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
107707 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
107708 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
107709 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
107710 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
107711 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
107712 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
107713 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
107714 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
107715 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
107716 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
107717 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
107718 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
107719 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
107720 +tunables_write_59563 tunables_write 3 59563 NULL
107721 +memdup_user_59590 memdup_user 2 59590 NULL
107722 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
107723 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
107724 +mtrr_write_59622 mtrr_write 3 59622 NULL
107725 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
107726 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
107727 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
107728 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
107729 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
107730 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
107731 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
107732 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
107733 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
107734 +sriov_enable_59689 sriov_enable 2 59689 NULL
107735 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
107736 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
107737 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
107738 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
107739 +strnlen_59746 strnlen 0 59746 NULL
107740 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
107741 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
107742 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
107743 +venus_remove_59781 venus_remove 4 59781 NULL
107744 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
107745 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
107746 +ipw_write_59807 ipw_write 3 59807 NULL
107747 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
107748 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
107749 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
107750 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
107751 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
107752 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
107753 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
107754 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
107755 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
107756 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
107757 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
107758 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
107759 +lookup_node_59953 lookup_node 2 59953 NULL
107760 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
107761 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
107762 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
107763 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
107764 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
107765 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
107766 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
107767 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
107768 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
107769 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
107770 +register_device_60015 register_device 2-3 60015 NULL
107771 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
107772 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
107773 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
107774 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
107775 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
107776 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
107777 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
107778 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
107779 +compat_writev_60063 compat_writev 3 60063 NULL
107780 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
107781 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
107782 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
107783 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
107784 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
107785 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
107786 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
107787 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
107788 +init_state_60165 init_state 2 60165 NULL
107789 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
107790 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
107791 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
107792 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
107793 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
107794 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
107795 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
107796 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
107797 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
107798 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
107799 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
107800 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
107801 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
107802 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
107803 +printer_write_60276 printer_write 3 60276 NULL
107804 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
107805 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
107806 +getDataLength_60301 getDataLength 0 60301 NULL
107807 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
107808 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
107809 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
107810 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
107811 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
107812 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
107813 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
107814 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
107815 +driver_names_read_60399 driver_names_read 3 60399 NULL
107816 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
107817 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
107818 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
107819 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
107820 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
107821 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
107822 +rx_data_60442 rx_data 4 60442 NULL nohasharray
107823 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
107824 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
107825 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
107826 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
107827 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
107828 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
107829 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
107830 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
107831 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
107832 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
107833 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
107834 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
107835 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
107836 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
107837 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
107838 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
107839 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
107840 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
107841 +init_data_container_60709 init_data_container 1 60709 NULL
107842 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
107843 +raid_status_60755 raid_status 5 60755 NULL
107844 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
107845 +opticon_write_60775 opticon_write 4 60775 NULL
107846 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
107847 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
107848 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
107849 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
107850 +generic_writepages_60871 generic_writepages 0 60871 NULL
107851 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
107852 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
107853 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
107854 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
107855 +sys_mlock_60932 sys_mlock 1 60932 NULL
107856 +pti_char_write_60960 pti_char_write 3 60960 NULL
107857 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
107858 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
107859 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
107860 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
107861 +symtab_init_61050 symtab_init 2 61050 NULL
107862 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
107863 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
107864 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
107865 +get_derived_key_61100 get_derived_key 4 61100 NULL
107866 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
107867 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
107868 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
107869 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
107870 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
107871 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
107872 +__vmalloc_61168 __vmalloc 1 61168 NULL
107873 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
107874 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
107875 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
107876 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
107877 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
107878 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
107879 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
107880 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
107881 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
107882 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
107883 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
107884 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
107885 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
107886 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
107887 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
107888 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
107889 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
107890 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
107891 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
107892 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
107893 +change_xattr_61390 change_xattr 5 61390 NULL
107894 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
107895 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
107896 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
107897 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
107898 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
107899 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
107900 +erst_errno_61526 erst_errno 0 61526 NULL
107901 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
107902 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
107903 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
107904 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
107905 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
107906 +seq_open_private_61589 seq_open_private 3 61589 NULL
107907 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
107908 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
107909 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
107910 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
107911 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
107912 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
107913 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
107914 +resize_stripes_61650 resize_stripes 2 61650 NULL
107915 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
107916 +insert_one_name_61668 insert_one_name 7 61668 NULL
107917 +lock_loop_61681 lock_loop 1 61681 NULL
107918 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
107919 +filter_read_61692 filter_read 3 61692 NULL
107920 +iov_length_61716 iov_length 0 61716 NULL
107921 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
107922 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
107923 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
107924 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
107925 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
107926 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
107927 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
107928 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
107929 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
107930 +get_fw_name_61874 get_fw_name 3 61874 NULL
107931 +free_init_pages_61875 free_init_pages 2 61875 NULL
107932 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
107933 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
107934 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
107935 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
107936 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
107937 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
107938 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
107939 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
107940 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
107941 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
107942 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
107943 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
107944 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
107945 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
107946 +cow_file_range_61979 cow_file_range 3 61979 NULL
107947 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
107948 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
107949 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
107950 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
107951 +SYSC_select_62024 SYSC_select 1 62024 NULL
107952 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
107953 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
107954 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
107955 +do_pselect_62061 do_pselect 1 62061 NULL
107956 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
107957 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
107958 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
107959 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
107960 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
107961 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
107962 +ql_status_62135 ql_status 5 62135 NULL
107963 +video_usercopy_62151 video_usercopy 2 62151 NULL
107964 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
107965 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
107966 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
107967 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
107968 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
107969 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
107970 +allocate_partition_62245 allocate_partition 4 62245 NULL
107971 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
107972 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
107973 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
107974 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
107975 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
107976 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
107977 +subseq_list_62332 subseq_list 3-0 62332 NULL
107978 +flash_write_62354 flash_write 3 62354 NULL
107979 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
107980 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
107981 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
107982 +altera_irscan_62396 altera_irscan 2 62396 NULL
107983 +set_ssp_62411 set_ssp 4 62411 NULL
107984 +unmap_single_62423 unmap_single 2 62423 NULL
107985 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
107986 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
107987 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
107988 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
107989 +remove_mapping_62491 remove_mapping 2 62491 NULL
107990 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
107991 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
107992 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
107993 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
107994 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
107995 +debugfs_read_62535 debugfs_read 3 62535 NULL
107996 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
107997 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
107998 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
107999 +get_subdir_62581 get_subdir 3 62581 NULL
108000 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
108001 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
108002 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
108003 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
108004 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
108005 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
108006 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
108007 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
108008 +write_62671 write 3 62671 NULL
108009 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
108010 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
108011 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
108012 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
108013 +rdm_62719 rdm 0 62719 NULL
108014 +key_replays_read_62746 key_replays_read 3 62746 NULL
108015 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
108016 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
108017 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
108018 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
108019 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
108020 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
108021 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
108022 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
108023 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
108024 +set_swbp_62853 set_swbp 3 62853 NULL
108025 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
108026 +aoechr_write_62883 aoechr_write 3 62883 NULL
108027 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
108028 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
108029 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
108030 +getdqbuf_62908 getdqbuf 1 62908 NULL
108031 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
108032 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
108033 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
108034 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
108035 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
108036 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
108037 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
108038 +unlink1_63059 unlink1 3 63059 NULL
108039 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
108040 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
108041 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
108042 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
108043 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
108044 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
108045 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
108046 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
108047 +vme_master_read_63221 vme_master_read 0 63221 NULL
108048 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
108049 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
108050 +ptp_read_63251 ptp_read 4 63251 NULL
108051 +raid5_resize_63306 raid5_resize 2 63306 NULL
108052 +proc_info_read_63344 proc_info_read 3 63344 NULL
108053 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
108054 +idmouse_read_63374 idmouse_read 3 63374 NULL
108055 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
108056 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
108057 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
108058 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
108059 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
108060 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
108061 +kone_send_63435 kone_send 4 63435 NULL
108062 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
108063 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
108064 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
108065 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
108066 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
108067 +read_kcore_63488 read_kcore 3 63488 NULL
108068 +save_hint_63497 save_hint 2 63497 NULL
108069 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
108070 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
108071 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
108072 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
108073 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
108074 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
108075 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
108076 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
108077 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
108078 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
108079 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
108080 +module_alloc_63630 module_alloc 1 63630 NULL
108081 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
108082 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
108083 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
108084 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
108085 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
108086 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
108087 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
108088 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
108089 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
108090 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
108091 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
108092 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
108093 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
108094 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
108095 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
108096 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
108097 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
108098 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
108099 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
108100 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
108101 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
108102 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
108103 +prepare_copy_63826 prepare_copy 2 63826 NULL
108104 +sel_write_load_63830 sel_write_load 3 63830 NULL
108105 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
108106 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
108107 +divas_write_63901 divas_write 3 63901 NULL
108108 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
108109 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
108110 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
108111 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
108112 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
108113 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
108114 +__team_options_register_63941 __team_options_register 3 63941 NULL
108115 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
108116 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
108117 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
108118 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
108119 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
108120 +kmemdup_64015 kmemdup 2 64015 NULL
108121 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
108122 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
108123 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
108124 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
108125 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
108126 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
108127 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
108128 +get_u8_64076 get_u8 0 64076 NULL
108129 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
108130 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
108131 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
108132 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
108133 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
108134 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
108135 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
108136 +init_bch_64130 init_bch 1-2 64130 NULL
108137 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
108138 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
108139 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
108140 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
108141 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
108142 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
108143 +read_pulse_64227 read_pulse 0-3 64227 NULL
108144 +header_len_64232 header_len 0 64232 NULL
108145 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
108146 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
108147 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
108148 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
108149 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
108150 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
108151 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
108152 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
108153 +ffz_64324 ffz 0 64324 NULL
108154 +map_region_64328 map_region 1 64328 NULL
108155 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
108156 +ts_write_64336 ts_write 3 64336 NULL
108157 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
108158 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
108159 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
108160 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
108161 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
108162 +ilo_write_64378 ilo_write 3 64378 NULL
108163 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
108164 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
108165 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
108166 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
108167 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
108168 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
108169 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
108170 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
108171 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
108172 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
108173 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
108174 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
108175 +cap_capable_64462 cap_capable 0 64462 NULL
108176 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
108177 +single_open_size_64483 single_open_size 4 64483 NULL
108178 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
108179 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
108180 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
108181 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
108182 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
108183 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
108184 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
108185 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
108186 +SyS_bind_64544 SyS_bind 3 64544 NULL
108187 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
108188 +__spi_sync_64561 __spi_sync 0 64561 NULL
108189 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
108190 +fanotify_write_64623 fanotify_write 3 64623 NULL
108191 +to_dblock_64655 to_dblock 0-1 64655 NULL
108192 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
108193 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
108194 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
108195 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
108196 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
108197 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
108198 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
108199 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
108200 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
108201 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
108202 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
108203 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
108204 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
108205 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
108206 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
108207 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
108208 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
108209 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
108210 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
108211 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
108212 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
108213 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
108214 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
108215 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
108216 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
108217 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
108218 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
108219 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
108220 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
108221 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
108222 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
108223 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
108224 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
108225 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
108226 +pskb_pull_65005 pskb_pull 2 65005 NULL
108227 +unifi_write_65012 unifi_write 3 65012 NULL
108228 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
108229 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
108230 +insert_dent_65034 insert_dent 7 65034 NULL
108231 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
108232 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
108233 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
108234 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
108235 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
108236 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
108237 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
108238 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
108239 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
108240 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
108241 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
108242 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
108243 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
108244 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
108245 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
108246 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
108247 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
108248 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
108249 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
108250 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
108251 +get_var_len_65304 get_var_len 0 65304 NULL
108252 +unpack_array_65318 unpack_array 0 65318 NULL
108253 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
108254 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
108255 +init_list_set_65351 init_list_set 2-3 65351 NULL
108256 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
108257 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
108258 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
108259 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
108260 +strchr_65372 strchr 0 65372 NULL nohasharray
108261 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
108262 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
108263 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
108264 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
108265 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
108266 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
108267 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
108268 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
108269 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
108270 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
108271 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
108272 +alloc_dr_65495 alloc_dr 2 65495 NULL
108273 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
108274 new file mode 100644
108275 index 0000000..03d0c84
108276 --- /dev/null
108277 +++ b/tools/gcc/size_overflow_plugin.c
108278 @@ -0,0 +1,2113 @@
108279 +/*
108280 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
108281 + * Licensed under the GPL v2, or (at your option) v3
108282 + *
108283 + * Homepage:
108284 + * http://www.grsecurity.net/~ephox/overflow_plugin/
108285 + *
108286 + * Documentation:
108287 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
108288 + *
108289 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
108290 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
108291 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
108292 + *
108293 + * Usage:
108294 + * $ 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
108295 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
108296 + */
108297 +
108298 +#include "gcc-plugin.h"
108299 +#include "config.h"
108300 +#include "system.h"
108301 +#include "coretypes.h"
108302 +#include "tree.h"
108303 +#include "tree-pass.h"
108304 +#include "intl.h"
108305 +#include "plugin-version.h"
108306 +#include "tm.h"
108307 +#include "toplev.h"
108308 +#include "function.h"
108309 +#include "tree-flow.h"
108310 +#include "plugin.h"
108311 +#include "gimple.h"
108312 +#include "diagnostic.h"
108313 +#include "cfgloop.h"
108314 +
108315 +#if BUILDING_GCC_VERSION >= 4008
108316 +#define TODO_dump_func 0
108317 +#endif
108318 +
108319 +struct size_overflow_hash {
108320 + const struct size_overflow_hash * const next;
108321 + const char * const name;
108322 + const unsigned int param;
108323 +};
108324 +
108325 +#include "size_overflow_hash.h"
108326 +
108327 +enum mark {
108328 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
108329 +};
108330 +
108331 +enum err_code_conditions {
108332 + CAST_ONLY, FROM_CONST
108333 +};
108334 +
108335 +static unsigned int call_count = 0;
108336 +
108337 +#define __unused __attribute__((__unused__))
108338 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
108339 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
108340 +#define BEFORE_STMT true
108341 +#define AFTER_STMT false
108342 +#define CREATE_NEW_VAR NULL_TREE
108343 +#define CODES_LIMIT 32
108344 +#define MAX_PARAM 31
108345 +#define MY_STMT GF_PLF_1
108346 +#define NO_CAST_CHECK GF_PLF_2
108347 +#define FROM_ARG true
108348 +#define FROM_RET false
108349 +
108350 +#if BUILDING_GCC_VERSION == 4005
108351 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
108352 +#endif
108353 +
108354 +int plugin_is_GPL_compatible;
108355 +void debug_gimple_stmt(gimple gs);
108356 +
108357 +static tree expand(struct pointer_set_t *visited, tree lhs);
108358 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
108359 +static tree report_size_overflow_decl;
108360 +static const_tree const_char_ptr_type_node;
108361 +static unsigned int handle_function(void);
108362 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
108363 +static tree get_size_overflow_type(gimple stmt, const_tree node);
108364 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
108365 +static void print_missing_msg(tree func, unsigned int argnum);
108366 +
108367 +static struct plugin_info size_overflow_plugin_info = {
108368 + .version = "20130822beta",
108369 + .help = "no-size-overflow\tturn off size overflow checking\n",
108370 +};
108371 +
108372 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108373 +{
108374 + unsigned int arg_count;
108375 + enum tree_code code = TREE_CODE(*node);
108376 +
108377 + switch (code) {
108378 + case FUNCTION_DECL:
108379 + arg_count = type_num_arguments(TREE_TYPE(*node));
108380 + break;
108381 + case FUNCTION_TYPE:
108382 + case METHOD_TYPE:
108383 + arg_count = type_num_arguments(*node);
108384 + break;
108385 + default:
108386 + *no_add_attrs = true;
108387 + error("%s: %qE attribute only applies to functions", __func__, name);
108388 + return NULL_TREE;
108389 + }
108390 +
108391 + for (; args; args = TREE_CHAIN(args)) {
108392 + tree position = TREE_VALUE(args);
108393 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108394 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108395 + *no_add_attrs = true;
108396 + }
108397 + }
108398 + return NULL_TREE;
108399 +}
108400 +
108401 +static const char* get_asm_name(tree node)
108402 +{
108403 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
108404 +}
108405 +
108406 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108407 +{
108408 + unsigned int arg_count, arg_num;
108409 + enum tree_code code = TREE_CODE(*node);
108410 +
108411 + switch (code) {
108412 + case FUNCTION_DECL:
108413 + arg_count = type_num_arguments(TREE_TYPE(*node));
108414 + break;
108415 + case FUNCTION_TYPE:
108416 + case METHOD_TYPE:
108417 + arg_count = type_num_arguments(*node);
108418 + break;
108419 + case FIELD_DECL:
108420 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
108421 + if (arg_num != 0) {
108422 + *no_add_attrs = true;
108423 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
108424 + }
108425 + return NULL_TREE;
108426 + default:
108427 + *no_add_attrs = true;
108428 + error("%qE attribute only applies to functions", name);
108429 + return NULL_TREE;
108430 + }
108431 +
108432 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
108433 + return NULL_TREE;
108434 +
108435 + for (; args; args = TREE_CHAIN(args)) {
108436 + tree position = TREE_VALUE(args);
108437 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108438 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108439 + *no_add_attrs = true;
108440 + }
108441 + }
108442 + return NULL_TREE;
108443 +}
108444 +
108445 +static struct attribute_spec size_overflow_attr = {
108446 + .name = "size_overflow",
108447 + .min_length = 1,
108448 + .max_length = -1,
108449 + .decl_required = true,
108450 + .type_required = false,
108451 + .function_type_required = false,
108452 + .handler = handle_size_overflow_attribute,
108453 +#if BUILDING_GCC_VERSION >= 4007
108454 + .affects_type_identity = false
108455 +#endif
108456 +};
108457 +
108458 +static struct attribute_spec intentional_overflow_attr = {
108459 + .name = "intentional_overflow",
108460 + .min_length = 1,
108461 + .max_length = -1,
108462 + .decl_required = true,
108463 + .type_required = false,
108464 + .function_type_required = false,
108465 + .handler = handle_intentional_overflow_attribute,
108466 +#if BUILDING_GCC_VERSION >= 4007
108467 + .affects_type_identity = false
108468 +#endif
108469 +};
108470 +
108471 +static void register_attributes(void __unused *event_data, void __unused *data)
108472 +{
108473 + register_attribute(&size_overflow_attr);
108474 + register_attribute(&intentional_overflow_attr);
108475 +}
108476 +
108477 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
108478 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
108479 +{
108480 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
108481 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
108482 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
108483 +
108484 + unsigned int m = 0x57559429;
108485 + unsigned int n = 0x5052acdb;
108486 + const unsigned int *key4 = (const unsigned int *)key;
108487 + unsigned int h = len;
108488 + unsigned int k = len + seed + n;
108489 + unsigned long long p;
108490 +
108491 + while (len >= 8) {
108492 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
108493 + len -= 8;
108494 + }
108495 + if (len >= 4) {
108496 + cwmixb(key4[0]) key4 += 1;
108497 + len -= 4;
108498 + }
108499 + if (len)
108500 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
108501 + cwmixb(h ^ (k + n));
108502 + return k ^ h;
108503 +
108504 +#undef cwfold
108505 +#undef cwmixa
108506 +#undef cwmixb
108507 +}
108508 +
108509 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
108510 +{
108511 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
108512 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
108513 + return fn ^ codes;
108514 +}
108515 +
108516 +static inline tree get_original_function_decl(tree fndecl)
108517 +{
108518 + if (DECL_ABSTRACT_ORIGIN(fndecl))
108519 + return DECL_ABSTRACT_ORIGIN(fndecl);
108520 + return fndecl;
108521 +}
108522 +
108523 +static inline gimple get_def_stmt(const_tree node)
108524 +{
108525 + gcc_assert(node != NULL_TREE);
108526 + if (TREE_CODE(node) != SSA_NAME)
108527 + return NULL;
108528 + return SSA_NAME_DEF_STMT(node);
108529 +}
108530 +
108531 +static unsigned char get_tree_code(const_tree type)
108532 +{
108533 + switch (TREE_CODE(type)) {
108534 + case ARRAY_TYPE:
108535 + return 0;
108536 + case BOOLEAN_TYPE:
108537 + return 1;
108538 + case ENUMERAL_TYPE:
108539 + return 2;
108540 + case FUNCTION_TYPE:
108541 + return 3;
108542 + case INTEGER_TYPE:
108543 + return 4;
108544 + case POINTER_TYPE:
108545 + return 5;
108546 + case RECORD_TYPE:
108547 + return 6;
108548 + case UNION_TYPE:
108549 + return 7;
108550 + case VOID_TYPE:
108551 + return 8;
108552 + case REAL_TYPE:
108553 + return 9;
108554 + case VECTOR_TYPE:
108555 + return 10;
108556 + case REFERENCE_TYPE:
108557 + return 11;
108558 + case OFFSET_TYPE:
108559 + return 12;
108560 + case COMPLEX_TYPE:
108561 + return 13;
108562 + default:
108563 + debug_tree((tree)type);
108564 + gcc_unreachable();
108565 + }
108566 +}
108567 +
108568 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
108569 +{
108570 + gcc_assert(type != NULL_TREE);
108571 +
108572 + while (type && len < CODES_LIMIT) {
108573 + tree_codes[len] = get_tree_code(type);
108574 + len++;
108575 + type = TREE_TYPE(type);
108576 + }
108577 + return len;
108578 +}
108579 +
108580 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
108581 +{
108582 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
108583 + enum tree_code code = TREE_CODE(type);
108584 + size_t len = 0;
108585 +
108586 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
108587 +
108588 + arg = TYPE_ARG_TYPES(type);
108589 + // skip builtins __builtin_constant_p
108590 + if (!arg && DECL_BUILT_IN(fndecl))
108591 + return 0;
108592 +
108593 + if (TREE_CODE_CLASS(code) == tcc_type)
108594 + result = type;
108595 + else
108596 + result = DECL_RESULT(fndecl);
108597 +
108598 + gcc_assert(result != NULL_TREE);
108599 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
108600 +
108601 + if (arg == NULL_TREE) {
108602 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
108603 + arg_field = DECL_ARGUMENT_FLD(fndecl);
108604 + if (arg_field == NULL_TREE)
108605 + return 0;
108606 + arg = TREE_TYPE(arg_field);
108607 + len = add_type_codes(arg, tree_codes, len);
108608 + gcc_assert(len != 0);
108609 + return len;
108610 + }
108611 +
108612 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
108613 + while (arg && len < CODES_LIMIT) {
108614 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
108615 + arg = TREE_CHAIN(arg);
108616 + }
108617 +
108618 + gcc_assert(len != 0);
108619 + return len;
108620 +}
108621 +
108622 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
108623 +{
108624 + unsigned int hash;
108625 + const struct size_overflow_hash *entry;
108626 + unsigned char tree_codes[CODES_LIMIT];
108627 + size_t len;
108628 + const char *func_name;
108629 +
108630 + fndecl = get_original_function_decl(fndecl);
108631 + len = get_function_decl(fndecl, tree_codes);
108632 + if (len == 0)
108633 + return NULL;
108634 +
108635 + func_name = get_asm_name(fndecl);
108636 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
108637 +
108638 + entry = size_overflow_hash[hash];
108639 + while (entry) {
108640 + if (!strcmp(entry->name, func_name))
108641 + return entry;
108642 + entry = entry->next;
108643 + }
108644 +
108645 + return NULL;
108646 +}
108647 +
108648 +static bool is_bool(const_tree node)
108649 +{
108650 + const_tree type;
108651 +
108652 + if (node == NULL_TREE)
108653 + return false;
108654 +
108655 + type = TREE_TYPE(node);
108656 + if (!INTEGRAL_TYPE_P(type))
108657 + return false;
108658 + if (TREE_CODE(type) == BOOLEAN_TYPE)
108659 + return true;
108660 + if (TYPE_PRECISION(type) == 1)
108661 + return true;
108662 + return false;
108663 +}
108664 +
108665 +static bool skip_types(const_tree var)
108666 +{
108667 + tree type;
108668 +
108669 + if (is_gimple_constant(var))
108670 + return true;
108671 +
108672 + switch (TREE_CODE(var)) {
108673 + case ADDR_EXPR:
108674 +#if BUILDING_GCC_VERSION >= 4006
108675 + case MEM_REF:
108676 +#endif
108677 + case ARRAY_REF:
108678 + case BIT_FIELD_REF:
108679 + case INDIRECT_REF:
108680 + case TARGET_MEM_REF:
108681 + return true;
108682 + case PARM_DECL:
108683 + case VAR_DECL:
108684 + case COMPONENT_REF:
108685 + return false;
108686 + default:
108687 + break;
108688 + }
108689 +
108690 + gcc_assert(TREE_CODE(var) == SSA_NAME);
108691 +
108692 + type = TREE_TYPE(var);
108693 + switch (TREE_CODE(type)) {
108694 + case INTEGER_TYPE:
108695 + case ENUMERAL_TYPE:
108696 + return false;
108697 + case BOOLEAN_TYPE:
108698 + return is_bool(var);
108699 + default:
108700 + break;
108701 + }
108702 +
108703 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
108704 +
108705 + type = TREE_TYPE(type);
108706 + gcc_assert(type != NULL_TREE);
108707 + switch (TREE_CODE(type)) {
108708 + case RECORD_TYPE:
108709 + case POINTER_TYPE:
108710 + case ARRAY_TYPE:
108711 + return true;
108712 + case VOID_TYPE:
108713 + case INTEGER_TYPE:
108714 + case UNION_TYPE:
108715 + return false;
108716 + default:
108717 + break;
108718 + }
108719 +
108720 + debug_tree((tree)var);
108721 + gcc_unreachable();
108722 +}
108723 +
108724 +static unsigned int find_arg_number(const_tree arg, tree func)
108725 +{
108726 + tree var;
108727 + unsigned int argnum = 1;
108728 +
108729 + if (TREE_CODE(arg) == SSA_NAME)
108730 + arg = SSA_NAME_VAR(arg);
108731 +
108732 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
108733 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
108734 + continue;
108735 + if (!skip_types(var))
108736 + return argnum;
108737 + }
108738 +
108739 + return 0;
108740 +}
108741 +
108742 +static tree create_new_var(tree type)
108743 +{
108744 + tree new_var = create_tmp_var(type, "cicus");
108745 +
108746 +#if BUILDING_GCC_VERSION <= 4007
108747 + add_referenced_var(new_var);
108748 +#endif
108749 + return new_var;
108750 +}
108751 +
108752 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
108753 +{
108754 + gimple assign;
108755 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108756 + tree type = TREE_TYPE(rhs1);
108757 + tree lhs = create_new_var(type);
108758 +
108759 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
108760 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
108761 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108762 +
108763 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
108764 + update_stmt(assign);
108765 + gimple_set_plf(assign, MY_STMT, true);
108766 + return assign;
108767 +}
108768 +
108769 +static tree cast_a_tree(tree type, tree var)
108770 +{
108771 + gcc_assert(type != NULL_TREE);
108772 + gcc_assert(var != NULL_TREE);
108773 + gcc_assert(fold_convertible_p(type, var));
108774 +
108775 + return fold_convert(type, var);
108776 +}
108777 +
108778 +static tree get_lhs(const_gimple stmt)
108779 +{
108780 + switch (gimple_code(stmt)) {
108781 + case GIMPLE_ASSIGN:
108782 + return gimple_get_lhs(stmt);
108783 + case GIMPLE_PHI:
108784 + return gimple_phi_result(stmt);
108785 + case GIMPLE_CALL:
108786 + return gimple_call_lhs(stmt);
108787 + default:
108788 + return NULL_TREE;
108789 + }
108790 +}
108791 +
108792 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
108793 +{
108794 + const_gimple def_stmt = get_def_stmt(rhs);
108795 +
108796 + if (force)
108797 + return false;
108798 +
108799 + if (is_gimple_constant(rhs))
108800 + return false;
108801 +
108802 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
108803 + return false;
108804 +
108805 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
108806 + return false;
108807 +
108808 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
108809 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
108810 + return false;
108811 +
108812 + return true;
108813 +}
108814 +
108815 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
108816 +{
108817 + gimple assign, def_stmt;
108818 +
108819 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
108820 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
108821 + gcc_unreachable();
108822 +
108823 + def_stmt = get_def_stmt(rhs);
108824 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
108825 + return def_stmt;
108826 +
108827 + if (lhs == CREATE_NEW_VAR)
108828 + lhs = create_new_var(dst_type);
108829 +
108830 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
108831 +
108832 + if (!gsi_end_p(*gsi)) {
108833 + location_t loc = gimple_location(gsi_stmt(*gsi));
108834 + gimple_set_location(assign, loc);
108835 + }
108836 +
108837 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108838 +
108839 + if (before)
108840 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
108841 + else
108842 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
108843 + update_stmt(assign);
108844 + gimple_set_plf(assign, MY_STMT, true);
108845 +
108846 + return assign;
108847 +}
108848 +
108849 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
108850 +{
108851 + gimple_stmt_iterator gsi;
108852 + tree lhs;
108853 + const_gimple new_stmt;
108854 +
108855 + if (rhs == NULL_TREE)
108856 + return NULL_TREE;
108857 +
108858 + gsi = gsi_for_stmt(stmt);
108859 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
108860 +
108861 + lhs = get_lhs(new_stmt);
108862 + gcc_assert(lhs != NULL_TREE);
108863 + return lhs;
108864 +}
108865 +
108866 +static tree cast_to_TI_type(gimple stmt, tree node)
108867 +{
108868 + gimple_stmt_iterator gsi;
108869 + gimple cast_stmt;
108870 + tree type = TREE_TYPE(node);
108871 +
108872 + if (types_compatible_p(type, intTI_type_node))
108873 + return node;
108874 +
108875 + gsi = gsi_for_stmt(stmt);
108876 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108877 + return gimple_get_lhs(cast_stmt);
108878 +}
108879 +
108880 +static void check_function_hash(const_gimple stmt)
108881 +{
108882 + tree func;
108883 + const struct size_overflow_hash *hash;
108884 +
108885 + if (gimple_code(stmt) != GIMPLE_CALL)
108886 + return;
108887 +
108888 + func = gimple_call_fndecl(stmt);
108889 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
108890 + if (func == NULL_TREE)
108891 + return;
108892 +
108893 + hash = get_function_hash(func);
108894 + if (!hash)
108895 + print_missing_msg(func, 0);
108896 +}
108897 +
108898 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
108899 +{
108900 + tree lhs, new_lhs;
108901 + gimple_stmt_iterator gsi;
108902 +
108903 + if (rhs1 == NULL_TREE) {
108904 + debug_gimple_stmt(oldstmt);
108905 + error("%s: rhs1 is NULL_TREE", __func__);
108906 + gcc_unreachable();
108907 + }
108908 +
108909 + switch (gimple_code(oldstmt)) {
108910 + case GIMPLE_ASM:
108911 + lhs = rhs1;
108912 + break;
108913 + case GIMPLE_CALL:
108914 + lhs = gimple_call_lhs(oldstmt);
108915 + break;
108916 + case GIMPLE_ASSIGN:
108917 + lhs = gimple_get_lhs(oldstmt);
108918 + break;
108919 + default:
108920 + debug_gimple_stmt(oldstmt);
108921 + gcc_unreachable();
108922 + }
108923 +
108924 + gsi = gsi_for_stmt(oldstmt);
108925 + pointer_set_insert(visited, oldstmt);
108926 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
108927 + basic_block next_bb, cur_bb;
108928 + const_edge e;
108929 +
108930 + gcc_assert(before == false);
108931 + gcc_assert(stmt_can_throw_internal(oldstmt));
108932 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
108933 + gcc_assert(!gsi_end_p(gsi));
108934 +
108935 + cur_bb = gimple_bb(oldstmt);
108936 + next_bb = cur_bb->next_bb;
108937 + e = find_edge(cur_bb, next_bb);
108938 + gcc_assert(e != NULL);
108939 + gcc_assert(e->flags & EDGE_FALLTHRU);
108940 +
108941 + gsi = gsi_after_labels(next_bb);
108942 + gcc_assert(!gsi_end_p(gsi));
108943 +
108944 + before = true;
108945 + oldstmt = gsi_stmt(gsi);
108946 + }
108947 +
108948 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
108949 + return new_lhs;
108950 +}
108951 +
108952 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
108953 +{
108954 + gimple stmt;
108955 + gimple_stmt_iterator gsi;
108956 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
108957 +
108958 + if (gimple_plf(oldstmt, MY_STMT))
108959 + return lhs;
108960 +
108961 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
108962 + rhs1 = gimple_assign_rhs1(oldstmt);
108963 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
108964 + }
108965 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
108966 + rhs2 = gimple_assign_rhs2(oldstmt);
108967 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
108968 + }
108969 +
108970 + stmt = gimple_copy(oldstmt);
108971 + gimple_set_location(stmt, gimple_location(oldstmt));
108972 + gimple_set_plf(stmt, MY_STMT, true);
108973 +
108974 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
108975 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
108976 +
108977 + size_overflow_type = get_size_overflow_type(oldstmt, node);
108978 +
108979 + new_var = create_new_var(size_overflow_type);
108980 + new_var = make_ssa_name(new_var, stmt);
108981 + gimple_set_lhs(stmt, new_var);
108982 +
108983 + if (rhs1 != NULL_TREE)
108984 + gimple_assign_set_rhs1(stmt, rhs1);
108985 +
108986 + if (rhs2 != NULL_TREE)
108987 + gimple_assign_set_rhs2(stmt, rhs2);
108988 +#if BUILDING_GCC_VERSION >= 4007
108989 + if (rhs3 != NULL_TREE)
108990 + gimple_assign_set_rhs3(stmt, rhs3);
108991 +#endif
108992 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
108993 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
108994 +
108995 + gsi = gsi_for_stmt(oldstmt);
108996 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
108997 + update_stmt(stmt);
108998 + pointer_set_insert(visited, oldstmt);
108999 + return gimple_get_lhs(stmt);
109000 +}
109001 +
109002 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
109003 +{
109004 + basic_block first_bb;
109005 + gimple assign;
109006 + gimple_stmt_iterator gsi;
109007 +
109008 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
109009 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
109010 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
109011 +
109012 + gsi = gsi_start_bb(first_bb);
109013 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
109014 + return gimple_get_lhs(assign);
109015 +}
109016 +
109017 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
109018 +{
109019 + gimple_stmt_iterator gsi;
109020 + const_gimple assign;
109021 + gimple def_stmt = get_def_stmt(new_arg);
109022 +
109023 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
109024 + gsi = gsi_after_labels(gimple_bb(def_stmt));
109025 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
109026 + } else {
109027 + gsi = gsi_for_stmt(def_stmt);
109028 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
109029 + }
109030 +
109031 + return gimple_get_lhs(assign);
109032 +}
109033 +
109034 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
109035 +{
109036 + basic_block bb;
109037 + gimple_stmt_iterator gsi;
109038 + const_gimple assign, def_stmt;
109039 +
109040 + def_stmt = get_def_stmt(arg);
109041 + bb = gimple_bb(def_stmt);
109042 + gcc_assert(bb->index != 0);
109043 + gsi = gsi_after_labels(bb);
109044 +
109045 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
109046 + return gimple_get_lhs(assign);
109047 +}
109048 +
109049 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
109050 +{
109051 + tree size_overflow_type;
109052 + const_gimple def_stmt = get_def_stmt(arg);
109053 +
109054 + if (phi_ssa_name != NULL_TREE)
109055 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
109056 +
109057 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
109058 +
109059 + if (new_arg != NULL_TREE) {
109060 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
109061 + return use_phi_ssa_name(phi_ssa_name, new_arg);
109062 + }
109063 +
109064 + switch(gimple_code(def_stmt)) {
109065 + case GIMPLE_PHI:
109066 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
109067 + case GIMPLE_NOP:
109068 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
109069 + default:
109070 + debug_gimple_stmt((gimple)def_stmt);
109071 + gcc_unreachable();
109072 + }
109073 +}
109074 +
109075 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
109076 +{
109077 + basic_block bb;
109078 + gimple phi;
109079 + gimple_seq seq;
109080 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
109081 +
109082 + bb = gsi_bb(gsi);
109083 +
109084 + phi = create_phi_node(result, bb);
109085 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
109086 + seq = phi_nodes(bb);
109087 + gsi = gsi_last(seq);
109088 + gsi_remove(&gsi, false);
109089 +
109090 + gsi = gsi_for_stmt(oldstmt);
109091 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
109092 + gimple_set_bb(phi, bb);
109093 + gimple_set_plf(phi, MY_STMT, true);
109094 + return phi;
109095 +}
109096 +
109097 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
109098 +{
109099 + gimple new_phi = NULL;
109100 + gimple oldstmt = get_def_stmt(orig_result);
109101 + tree phi_ssa_name = NULL_TREE;
109102 + unsigned int i;
109103 +
109104 + pointer_set_insert(visited, oldstmt);
109105 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
109106 + tree arg, new_arg;
109107 +
109108 + arg = gimple_phi_arg_def(oldstmt, i);
109109 +
109110 + new_arg = expand(visited, arg);
109111 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
109112 + if (i == 0) {
109113 + phi_ssa_name = new_arg;
109114 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
109115 + }
109116 +
109117 + gcc_assert(new_phi != NULL);
109118 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
109119 + }
109120 +
109121 + gcc_assert(new_phi != NULL);
109122 + update_stmt(new_phi);
109123 + return gimple_phi_result(new_phi);
109124 +}
109125 +
109126 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
109127 +{
109128 + const_gimple assign;
109129 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109130 + tree origtype = TREE_TYPE(orig_rhs);
109131 +
109132 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
109133 +
109134 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109135 + return gimple_get_lhs(assign);
109136 +}
109137 +
109138 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
109139 +{
109140 + const_tree rhs1, lhs, rhs1_type, lhs_type;
109141 + enum machine_mode lhs_mode, rhs_mode;
109142 + gimple def_stmt = get_def_stmt(no_const_rhs);
109143 +
109144 + if (!gimple_assign_cast_p(def_stmt))
109145 + return false;
109146 +
109147 + rhs1 = gimple_assign_rhs1(def_stmt);
109148 + lhs = gimple_get_lhs(def_stmt);
109149 + rhs1_type = TREE_TYPE(rhs1);
109150 + lhs_type = TREE_TYPE(lhs);
109151 + rhs_mode = TYPE_MODE(rhs1_type);
109152 + lhs_mode = TYPE_MODE(lhs_type);
109153 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
109154 + return false;
109155 +
109156 + return true;
109157 +}
109158 +
109159 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
109160 +{
109161 + tree rhs1 = gimple_assign_rhs1(stmt);
109162 + tree lhs = gimple_get_lhs(stmt);
109163 + const_tree rhs1_type = TREE_TYPE(rhs1);
109164 + const_tree lhs_type = TREE_TYPE(lhs);
109165 +
109166 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
109167 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109168 +
109169 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
109170 +}
109171 +
109172 +static bool no_uses(tree node)
109173 +{
109174 + imm_use_iterator imm_iter;
109175 + use_operand_p use_p;
109176 +
109177 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
109178 + const_gimple use_stmt = USE_STMT(use_p);
109179 + if (use_stmt == NULL)
109180 + return true;
109181 + if (is_gimple_debug(use_stmt))
109182 + continue;
109183 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
109184 + continue;
109185 + return false;
109186 + }
109187 + return true;
109188 +}
109189 +
109190 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
109191 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
109192 +{
109193 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
109194 + gimple def_stmt = get_def_stmt(lhs);
109195 +
109196 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
109197 + return false;
109198 +
109199 + rhs1 = gimple_assign_rhs1(def_stmt);
109200 + rhs_type = TREE_TYPE(rhs1);
109201 + lhs_type = TREE_TYPE(lhs);
109202 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
109203 + return false;
109204 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
109205 + return false;
109206 +
109207 + def_stmt = get_def_stmt(rhs1);
109208 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
109209 + return false;
109210 +
109211 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
109212 + return false;
109213 +
109214 + rhs1 = gimple_assign_rhs1(def_stmt);
109215 + rhs2 = gimple_assign_rhs2(def_stmt);
109216 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
109217 + return false;
109218 +
109219 + if (is_gimple_constant(rhs2))
109220 + not_const_rhs = rhs1;
109221 + else
109222 + not_const_rhs = rhs2;
109223 +
109224 + return no_uses(not_const_rhs);
109225 +}
109226 +
109227 +static bool skip_lhs_cast_check(const_gimple stmt)
109228 +{
109229 + const_tree rhs = gimple_assign_rhs1(stmt);
109230 + const_gimple def_stmt = get_def_stmt(rhs);
109231 +
109232 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
109233 + if (gimple_code(def_stmt) == GIMPLE_ASM)
109234 + return true;
109235 +
109236 + if (is_const_plus_unsigned_signed_truncation(rhs))
109237 + return true;
109238 +
109239 + return false;
109240 +}
109241 +
109242 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
109243 +{
109244 + bool cast_lhs, cast_rhs;
109245 + tree lhs = gimple_get_lhs(stmt);
109246 + tree rhs = gimple_assign_rhs1(stmt);
109247 + const_tree lhs_type = TREE_TYPE(lhs);
109248 + const_tree rhs_type = TREE_TYPE(rhs);
109249 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
109250 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
109251 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
109252 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
109253 +
109254 + static bool check_lhs[3][4] = {
109255 + // ss su us uu
109256 + { false, true, true, false }, // lhs > rhs
109257 + { false, false, false, false }, // lhs = rhs
109258 + { true, true, true, true }, // lhs < rhs
109259 + };
109260 +
109261 + static bool check_rhs[3][4] = {
109262 + // ss su us uu
109263 + { true, false, true, true }, // lhs > rhs
109264 + { true, false, true, true }, // lhs = rhs
109265 + { true, false, true, true }, // lhs < rhs
109266 + };
109267 +
109268 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
109269 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
109270 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109271 +
109272 + if (lhs_size > rhs_size) {
109273 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109274 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109275 + } else if (lhs_size == rhs_size) {
109276 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109277 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109278 + } else {
109279 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109280 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109281 + }
109282 +
109283 + if (!cast_lhs && !cast_rhs)
109284 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109285 +
109286 + if (cast_lhs && !skip_lhs_cast_check(stmt))
109287 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
109288 +
109289 + if (cast_rhs)
109290 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
109291 +
109292 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109293 +}
109294 +
109295 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
109296 +{
109297 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
109298 +
109299 + if (gimple_plf(stmt, MY_STMT))
109300 + return lhs;
109301 +
109302 + rhs1 = gimple_assign_rhs1(stmt);
109303 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
109304 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109305 +
109306 + new_rhs1 = expand(visited, rhs1);
109307 +
109308 + if (new_rhs1 == NULL_TREE)
109309 + return create_cast_assign(visited, stmt);
109310 +
109311 + if (gimple_plf(stmt, NO_CAST_CHECK))
109312 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109313 +
109314 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
109315 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
109316 +
109317 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
109318 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
109319 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109320 + }
109321 +
109322 + if (!gimple_assign_cast_p(stmt))
109323 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109324 +
109325 + return create_cast_overflow_check(visited, new_rhs1, stmt);
109326 +}
109327 +
109328 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
109329 +{
109330 + tree rhs1, lhs = gimple_get_lhs(stmt);
109331 + gimple def_stmt = get_def_stmt(lhs);
109332 +
109333 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
109334 + rhs1 = gimple_assign_rhs1(def_stmt);
109335 +
109336 + if (is_gimple_constant(rhs1))
109337 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109338 +
109339 + switch (TREE_CODE(rhs1)) {
109340 + case SSA_NAME:
109341 + return handle_unary_rhs(visited, def_stmt);
109342 + case ARRAY_REF:
109343 + case BIT_FIELD_REF:
109344 + case ADDR_EXPR:
109345 + case COMPONENT_REF:
109346 + case INDIRECT_REF:
109347 +#if BUILDING_GCC_VERSION >= 4006
109348 + case MEM_REF:
109349 +#endif
109350 + case TARGET_MEM_REF:
109351 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109352 + case PARM_DECL:
109353 + case VAR_DECL:
109354 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109355 +
109356 + default:
109357 + debug_gimple_stmt(def_stmt);
109358 + debug_tree(rhs1);
109359 + gcc_unreachable();
109360 + }
109361 +}
109362 +
109363 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
109364 +{
109365 + gimple cond_stmt;
109366 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
109367 +
109368 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
109369 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
109370 + update_stmt(cond_stmt);
109371 +}
109372 +
109373 +static tree create_string_param(tree string)
109374 +{
109375 + tree i_type, a_type;
109376 + const int length = TREE_STRING_LENGTH(string);
109377 +
109378 + gcc_assert(length > 0);
109379 +
109380 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
109381 + a_type = build_array_type(char_type_node, i_type);
109382 +
109383 + TREE_TYPE(string) = a_type;
109384 + TREE_CONSTANT(string) = 1;
109385 + TREE_READONLY(string) = 1;
109386 +
109387 + return build1(ADDR_EXPR, ptr_type_node, string);
109388 +}
109389 +
109390 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
109391 +{
109392 + gimple func_stmt;
109393 + const_gimple def_stmt;
109394 + const_tree loc_line;
109395 + tree loc_file, ssa_name, current_func;
109396 + expanded_location xloc;
109397 + char *ssa_name_buf;
109398 + int len;
109399 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
109400 +
109401 + def_stmt = get_def_stmt(arg);
109402 + xloc = expand_location(gimple_location(def_stmt));
109403 +
109404 + if (!gimple_has_location(def_stmt)) {
109405 + xloc = expand_location(gimple_location(stmt));
109406 + if (!gimple_has_location(stmt))
109407 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
109408 + }
109409 +
109410 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
109411 +
109412 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
109413 + loc_file = create_string_param(loc_file);
109414 +
109415 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
109416 + current_func = create_string_param(current_func);
109417 +
109418 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
109419 + call_count++;
109420 + 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);
109421 + gcc_assert(len > 0);
109422 + ssa_name = build_string(len + 1, ssa_name_buf);
109423 + free(ssa_name_buf);
109424 + ssa_name = create_string_param(ssa_name);
109425 +
109426 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
109427 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
109428 +
109429 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
109430 +}
109431 +
109432 +static void __unused print_the_code_insertions(const_gimple stmt)
109433 +{
109434 + location_t loc = gimple_location(stmt);
109435 +
109436 + inform(loc, "Integer size_overflow check applied here.");
109437 +}
109438 +
109439 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
109440 +{
109441 + basic_block cond_bb, join_bb, bb_true;
109442 + edge e;
109443 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109444 +
109445 + cond_bb = gimple_bb(stmt);
109446 + if (before)
109447 + gsi_prev(&gsi);
109448 + if (gsi_end_p(gsi))
109449 + e = split_block_after_labels(cond_bb);
109450 + else
109451 + e = split_block(cond_bb, gsi_stmt(gsi));
109452 + cond_bb = e->src;
109453 + join_bb = e->dest;
109454 + e->flags = EDGE_FALSE_VALUE;
109455 + e->probability = REG_BR_PROB_BASE;
109456 +
109457 + bb_true = create_empty_bb(cond_bb);
109458 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
109459 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
109460 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
109461 +
109462 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
109463 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
109464 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
109465 +
109466 + if (current_loops != NULL) {
109467 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
109468 + add_bb_to_loop(bb_true, cond_bb->loop_father);
109469 + }
109470 +
109471 + insert_cond(cond_bb, arg, cond_code, type_value);
109472 + insert_cond_result(bb_true, stmt, arg, min);
109473 +
109474 +// print_the_code_insertions(stmt);
109475 +}
109476 +
109477 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
109478 +{
109479 + const_tree rhs_type = TREE_TYPE(rhs);
109480 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
109481 +
109482 + gcc_assert(rhs_type != NULL_TREE);
109483 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
109484 + return;
109485 +
109486 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
109487 +
109488 + if (is_const_plus_unsigned_signed_truncation(rhs))
109489 + return;
109490 +
109491 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
109492 + // typemax (-1) < typemin (0)
109493 + if (TREE_OVERFLOW(type_max))
109494 + return;
109495 +
109496 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
109497 +
109498 + cast_rhs_type = TREE_TYPE(cast_rhs);
109499 + type_max_type = TREE_TYPE(type_max);
109500 + type_min_type = TREE_TYPE(type_min);
109501 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
109502 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
109503 +
109504 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
109505 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
109506 +}
109507 +
109508 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
109509 +{
109510 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
109511 + return false;
109512 + if (!is_gimple_constant(rhs))
109513 + return false;
109514 + return true;
109515 +}
109516 +
109517 +static tree get_def_stmt_rhs(const_tree var)
109518 +{
109519 + tree rhs1, def_stmt_rhs1;
109520 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
109521 +
109522 + def_stmt = get_def_stmt(var);
109523 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
109524 +
109525 + rhs1 = gimple_assign_rhs1(def_stmt);
109526 + rhs1_def_stmt = get_def_stmt(rhs1);
109527 + if (!gimple_assign_cast_p(rhs1_def_stmt))
109528 + return rhs1;
109529 +
109530 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109531 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
109532 +
109533 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
109534 + case GIMPLE_CALL:
109535 + case GIMPLE_NOP:
109536 + case GIMPLE_ASM:
109537 + case GIMPLE_PHI:
109538 + return def_stmt_rhs1;
109539 + case GIMPLE_ASSIGN:
109540 + return rhs1;
109541 + default:
109542 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
109543 + gcc_unreachable();
109544 + }
109545 +}
109546 +
109547 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
109548 +{
109549 + tree new_rhs, orig_rhs;
109550 + void (*gimple_assign_set_rhs)(gimple, tree);
109551 + tree rhs1 = gimple_assign_rhs1(stmt);
109552 + tree rhs2 = gimple_assign_rhs2(stmt);
109553 + tree lhs = gimple_get_lhs(stmt);
109554 +
109555 + if (!check_overflow)
109556 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109557 +
109558 + if (change_rhs == NULL_TREE)
109559 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109560 +
109561 + if (new_rhs2 == NULL_TREE) {
109562 + orig_rhs = rhs1;
109563 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
109564 + } else {
109565 + orig_rhs = rhs2;
109566 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
109567 + }
109568 +
109569 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
109570 +
109571 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
109572 + gimple_assign_set_rhs(stmt, new_rhs);
109573 + update_stmt(stmt);
109574 +
109575 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109576 +}
109577 +
109578 +static bool is_subtraction_special(const_gimple stmt)
109579 +{
109580 + gimple rhs1_def_stmt, rhs2_def_stmt;
109581 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
109582 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
109583 + const_tree rhs1 = gimple_assign_rhs1(stmt);
109584 + const_tree rhs2 = gimple_assign_rhs2(stmt);
109585 +
109586 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
109587 + return false;
109588 +
109589 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
109590 +
109591 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
109592 + return false;
109593 +
109594 + rhs1_def_stmt = get_def_stmt(rhs1);
109595 + rhs2_def_stmt = get_def_stmt(rhs2);
109596 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
109597 + return false;
109598 +
109599 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109600 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
109601 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
109602 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
109603 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
109604 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
109605 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
109606 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
109607 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
109608 + return false;
109609 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
109610 + return false;
109611 +
109612 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
109613 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
109614 + return true;
109615 +}
109616 +
109617 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
109618 +{
109619 + tree new_rhs1, new_rhs2;
109620 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
109621 + gimple assign, stmt = get_def_stmt(lhs);
109622 + tree rhs1 = gimple_assign_rhs1(stmt);
109623 + tree rhs2 = gimple_assign_rhs2(stmt);
109624 +
109625 + if (!is_subtraction_special(stmt))
109626 + return NULL_TREE;
109627 +
109628 + new_rhs1 = expand(visited, rhs1);
109629 + new_rhs2 = expand(visited, rhs2);
109630 +
109631 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
109632 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
109633 +
109634 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
109635 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
109636 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
109637 + }
109638 +
109639 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
109640 + new_lhs = gimple_get_lhs(assign);
109641 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
109642 +
109643 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109644 +}
109645 +
109646 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
109647 +{
109648 + const_gimple def_stmt;
109649 +
109650 + if (TREE_CODE(rhs) != SSA_NAME)
109651 + return false;
109652 +
109653 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
109654 + return false;
109655 +
109656 + def_stmt = get_def_stmt(rhs);
109657 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
109658 + return false;
109659 +
109660 + return true;
109661 +}
109662 +
109663 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
109664 +{
109665 + tree rhs1, rhs2, new_lhs;
109666 + gimple def_stmt = get_def_stmt(lhs);
109667 + tree new_rhs1 = NULL_TREE;
109668 + tree new_rhs2 = NULL_TREE;
109669 +
109670 + rhs1 = gimple_assign_rhs1(def_stmt);
109671 + rhs2 = gimple_assign_rhs2(def_stmt);
109672 +
109673 + /* no DImode/TImode division in the 32/64 bit kernel */
109674 + switch (gimple_assign_rhs_code(def_stmt)) {
109675 + case RDIV_EXPR:
109676 + case TRUNC_DIV_EXPR:
109677 + case CEIL_DIV_EXPR:
109678 + case FLOOR_DIV_EXPR:
109679 + case ROUND_DIV_EXPR:
109680 + case TRUNC_MOD_EXPR:
109681 + case CEIL_MOD_EXPR:
109682 + case FLOOR_MOD_EXPR:
109683 + case ROUND_MOD_EXPR:
109684 + case EXACT_DIV_EXPR:
109685 + case POINTER_PLUS_EXPR:
109686 + case BIT_AND_EXPR:
109687 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109688 + default:
109689 + break;
109690 + }
109691 +
109692 + new_lhs = handle_integer_truncation(visited, lhs);
109693 + if (new_lhs != NULL_TREE)
109694 + return new_lhs;
109695 +
109696 + if (TREE_CODE(rhs1) == SSA_NAME)
109697 + new_rhs1 = expand(visited, rhs1);
109698 + if (TREE_CODE(rhs2) == SSA_NAME)
109699 + new_rhs2 = expand(visited, rhs2);
109700 +
109701 + if (is_a_neg_overflow(def_stmt, rhs2))
109702 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
109703 + if (is_a_neg_overflow(def_stmt, rhs1))
109704 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
109705 +
109706 +
109707 + if (is_a_constant_overflow(def_stmt, rhs2))
109708 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
109709 + if (is_a_constant_overflow(def_stmt, rhs1))
109710 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
109711 +
109712 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109713 +}
109714 +
109715 +#if BUILDING_GCC_VERSION >= 4007
109716 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
109717 +{
109718 + if (is_gimple_constant(rhs))
109719 + return cast_a_tree(size_overflow_type, rhs);
109720 + if (TREE_CODE(rhs) != SSA_NAME)
109721 + return NULL_TREE;
109722 + return expand(visited, rhs);
109723 +}
109724 +
109725 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
109726 +{
109727 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
109728 + gimple def_stmt = get_def_stmt(lhs);
109729 +
109730 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
109731 +
109732 + rhs1 = gimple_assign_rhs1(def_stmt);
109733 + rhs2 = gimple_assign_rhs2(def_stmt);
109734 + rhs3 = gimple_assign_rhs3(def_stmt);
109735 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
109736 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
109737 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
109738 +
109739 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
109740 +}
109741 +#endif
109742 +
109743 +static tree get_size_overflow_type(gimple stmt, const_tree node)
109744 +{
109745 + const_tree type;
109746 + tree new_type;
109747 +
109748 + gcc_assert(node != NULL_TREE);
109749 +
109750 + type = TREE_TYPE(node);
109751 +
109752 + if (gimple_plf(stmt, MY_STMT))
109753 + return TREE_TYPE(node);
109754 +
109755 + switch (TYPE_MODE(type)) {
109756 + case QImode:
109757 + new_type = intHI_type_node;
109758 + break;
109759 + case HImode:
109760 + new_type = intSI_type_node;
109761 + break;
109762 + case SImode:
109763 + new_type = intDI_type_node;
109764 + break;
109765 + case DImode:
109766 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
109767 + new_type = intDI_type_node;
109768 + else
109769 + new_type = intTI_type_node;
109770 + break;
109771 + default:
109772 + debug_tree((tree)node);
109773 + error("%s: unsupported gcc configuration.", __func__);
109774 + gcc_unreachable();
109775 + }
109776 +
109777 + if (TYPE_QUALS(type) != 0)
109778 + return build_qualified_type(new_type, TYPE_QUALS(type));
109779 + return new_type;
109780 +}
109781 +
109782 +static tree expand_visited(gimple def_stmt)
109783 +{
109784 + const_gimple next_stmt;
109785 + gimple_stmt_iterator gsi;
109786 + enum gimple_code code = gimple_code(def_stmt);
109787 +
109788 + if (code == GIMPLE_ASM)
109789 + return NULL_TREE;
109790 +
109791 + gsi = gsi_for_stmt(def_stmt);
109792 + gsi_next(&gsi);
109793 +
109794 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
109795 + return NULL_TREE;
109796 + gcc_assert(!gsi_end_p(gsi));
109797 + next_stmt = gsi_stmt(gsi);
109798 +
109799 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
109800 + return NULL_TREE;
109801 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
109802 +
109803 + return get_lhs(next_stmt);
109804 +}
109805 +
109806 +static tree expand(struct pointer_set_t *visited, tree lhs)
109807 +{
109808 + gimple def_stmt;
109809 +
109810 + if (skip_types(lhs))
109811 + return NULL_TREE;
109812 +
109813 + def_stmt = get_def_stmt(lhs);
109814 +
109815 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
109816 + return NULL_TREE;
109817 +
109818 + if (gimple_plf(def_stmt, MY_STMT))
109819 + return lhs;
109820 +
109821 + if (pointer_set_contains(visited, def_stmt))
109822 + return expand_visited(def_stmt);
109823 +
109824 + switch (gimple_code(def_stmt)) {
109825 + case GIMPLE_PHI:
109826 + return handle_phi(visited, lhs);
109827 + case GIMPLE_CALL:
109828 + case GIMPLE_ASM:
109829 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109830 + case GIMPLE_ASSIGN:
109831 + switch (gimple_num_ops(def_stmt)) {
109832 + case 2:
109833 + return handle_unary_ops(visited, def_stmt);
109834 + case 3:
109835 + return handle_binary_ops(visited, lhs);
109836 +#if BUILDING_GCC_VERSION >= 4007
109837 + case 4:
109838 + return handle_ternary_ops(visited, lhs);
109839 +#endif
109840 + }
109841 + default:
109842 + debug_gimple_stmt(def_stmt);
109843 + error("%s: unknown gimple code", __func__);
109844 + gcc_unreachable();
109845 + }
109846 +}
109847 +
109848 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
109849 +{
109850 + const_gimple assign;
109851 + tree orig_type = TREE_TYPE(orig_node);
109852 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109853 +
109854 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109855 + return gimple_get_lhs(assign);
109856 +}
109857 +
109858 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
109859 +{
109860 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
109861 + update_stmt(stmt);
109862 +}
109863 +
109864 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
109865 +{
109866 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
109867 + update_stmt(stmt);
109868 +}
109869 +
109870 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
109871 +{
109872 + tree arg;
109873 + const_tree origarg;
109874 +
109875 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
109876 + return true;
109877 +
109878 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
109879 + while (origarg && *argnum) {
109880 + (*argnum)--;
109881 + origarg = TREE_CHAIN(origarg);
109882 + }
109883 +
109884 + gcc_assert(*argnum == 0);
109885 +
109886 + gcc_assert(origarg != NULL_TREE);
109887 + *argnum = 0;
109888 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
109889 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
109890 + return true;
109891 + return false;
109892 +}
109893 +
109894 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
109895 +{
109896 + gimple phi = get_def_stmt(result);
109897 + unsigned int i, n = gimple_phi_num_args(phi);
109898 +
109899 + if (!phi)
109900 + return MARK_NO;
109901 +
109902 + pointer_set_insert(visited, phi);
109903 + for (i = 0; i < n; i++) {
109904 + enum mark marked;
109905 + const_tree arg = gimple_phi_arg_def(phi, i);
109906 + marked = pre_expand(visited, search_err_code, arg);
109907 + if (marked != MARK_NO)
109908 + return marked;
109909 + }
109910 + return MARK_NO;
109911 +}
109912 +
109913 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109914 +{
109915 + gimple def_stmt = get_def_stmt(lhs);
109916 + const_tree rhs;
109917 +
109918 + if (!def_stmt)
109919 + return MARK_NO;
109920 +
109921 + rhs = gimple_assign_rhs1(def_stmt);
109922 +
109923 + def_stmt = get_def_stmt(rhs);
109924 + if (is_gimple_constant(rhs))
109925 + search_err_code[FROM_CONST] = true;
109926 +
109927 + return pre_expand(visited, search_err_code, rhs);
109928 +}
109929 +
109930 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109931 +{
109932 + gimple def_stmt = get_def_stmt(lhs);
109933 + const_tree rhs1, rhs2;
109934 + enum mark marked;
109935 +
109936 + if (!def_stmt)
109937 + return MARK_NO;
109938 +
109939 + search_err_code[CAST_ONLY] = false;
109940 +
109941 + rhs1 = gimple_assign_rhs1(def_stmt);
109942 + rhs2 = gimple_assign_rhs2(def_stmt);
109943 + marked = pre_expand(visited, search_err_code, rhs1);
109944 + if (marked != MARK_NO)
109945 + return marked;
109946 + return pre_expand(visited, search_err_code, rhs2);
109947 +}
109948 +
109949 +static const_tree search_field_decl(const_tree comp_ref)
109950 +{
109951 + const_tree field = NULL_TREE;
109952 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
109953 +
109954 + for (i = 0; i < len; i++) {
109955 + field = TREE_OPERAND(comp_ref, i);
109956 + if (TREE_CODE(field) == FIELD_DECL)
109957 + break;
109958 + }
109959 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
109960 + return field;
109961 +}
109962 +
109963 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
109964 +{
109965 + const_tree attr, p;
109966 +
109967 + // 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);
109968 + if (fndecl == NULL_TREE)
109969 + return MARK_NO;
109970 +
109971 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
109972 + if (!attr || !TREE_VALUE(attr))
109973 + return MARK_NO;
109974 +
109975 + p = TREE_VALUE(attr);
109976 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
109977 + return MARK_TURN_OFF;
109978 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
109979 + return MARK_NOT_INTENTIONAL;
109980 + if (argnum == 0) {
109981 + gcc_assert(current_function_decl == fndecl);
109982 + return MARK_NO;
109983 + }
109984 +
109985 + do {
109986 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
109987 + return MARK_YES;
109988 + p = TREE_CHAIN(p);
109989 + } while (p);
109990 +
109991 + return MARK_NO;
109992 +}
109993 +
109994 +static void print_missing_msg(tree func, unsigned int argnum)
109995 +{
109996 + unsigned int new_hash;
109997 + size_t len;
109998 + unsigned char tree_codes[CODES_LIMIT];
109999 + location_t loc;
110000 + const char *curfunc;
110001 +
110002 + func = get_original_function_decl(func);
110003 + loc = DECL_SOURCE_LOCATION(func);
110004 + curfunc = get_asm_name(func);
110005 +
110006 + len = get_function_decl(func, tree_codes);
110007 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
110008 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
110009 +}
110010 +
110011 +static unsigned int search_missing_attribute(const_tree arg)
110012 +{
110013 + unsigned int argnum;
110014 + const struct size_overflow_hash *hash;
110015 + const_tree type = TREE_TYPE(arg);
110016 + tree func = get_original_function_decl(current_function_decl);
110017 +
110018 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
110019 +
110020 + if (TREE_CODE(type) == POINTER_TYPE)
110021 + return 0;
110022 +
110023 + argnum = find_arg_number(arg, func);
110024 + if (argnum == 0)
110025 + return 0;
110026 +
110027 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
110028 + return argnum;
110029 +
110030 + hash = get_function_hash(func);
110031 + if (!hash || !(hash->param & (1U << argnum))) {
110032 + print_missing_msg(func, argnum);
110033 + return 0;
110034 + }
110035 + return argnum;
110036 +}
110037 +
110038 +static enum mark is_already_marked(const_tree lhs)
110039 +{
110040 + unsigned int argnum;
110041 + const_tree fndecl;
110042 +
110043 + argnum = search_missing_attribute(lhs);
110044 + fndecl = get_original_function_decl(current_function_decl);
110045 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
110046 + return MARK_YES;
110047 + return MARK_NO;
110048 +}
110049 +
110050 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
110051 +{
110052 + const_gimple def_stmt;
110053 +
110054 + if (skip_types(lhs))
110055 + return MARK_NO;
110056 +
110057 + if (TREE_CODE(lhs) == PARM_DECL)
110058 + return is_already_marked(lhs);
110059 +
110060 + if (TREE_CODE(lhs) == COMPONENT_REF) {
110061 + const_tree field, attr;
110062 +
110063 + field = search_field_decl(lhs);
110064 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
110065 + if (!attr || !TREE_VALUE(attr))
110066 + return MARK_NO;
110067 + return MARK_YES;
110068 + }
110069 +
110070 + def_stmt = get_def_stmt(lhs);
110071 +
110072 + if (!def_stmt)
110073 + return MARK_NO;
110074 +
110075 + if (pointer_set_contains(visited, def_stmt))
110076 + return MARK_NO;
110077 +
110078 + switch (gimple_code(def_stmt)) {
110079 + case GIMPLE_NOP:
110080 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
110081 + return is_already_marked(lhs);
110082 + return MARK_NO;
110083 + case GIMPLE_PHI:
110084 + return walk_phi(visited, search_err_code, lhs);
110085 + case GIMPLE_CALL:
110086 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
110087 + return MARK_TURN_OFF;
110088 + check_function_hash(def_stmt);
110089 + return MARK_NO;
110090 + case GIMPLE_ASM:
110091 + search_err_code[CAST_ONLY] = false;
110092 + return MARK_NO;
110093 + case GIMPLE_ASSIGN:
110094 + switch (gimple_num_ops(def_stmt)) {
110095 + case 2:
110096 + return walk_unary_ops(visited, search_err_code, lhs);
110097 + case 3:
110098 + return walk_binary_ops(visited, search_err_code, lhs);
110099 + }
110100 + default:
110101 + debug_gimple_stmt((gimple)def_stmt);
110102 + error("%s: unknown gimple code", __func__);
110103 + gcc_unreachable();
110104 + }
110105 +}
110106 +
110107 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
110108 +static bool skip_asm(const_tree arg)
110109 +{
110110 + gimple def_stmt = get_def_stmt(arg);
110111 +
110112 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
110113 + return false;
110114 +
110115 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
110116 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
110117 +}
110118 +
110119 +/*
110120 +0</MARK_YES: no dup, search attributes (so, int)
110121 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
110122 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
110123 +*/
110124 +
110125 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
110126 +{
110127 + struct pointer_set_t *visited;
110128 + enum mark is_marked, is_found;
110129 + location_t loc;
110130 + bool search_err_code[2] = {true, false};
110131 +
110132 + is_marked = mark_status(current_function_decl, 0);
110133 + if (is_marked == MARK_TURN_OFF)
110134 + return true;
110135 +
110136 + is_marked = mark_status(fndecl, argnum + 1);
110137 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
110138 + return true;
110139 +
110140 + visited = pointer_set_create();
110141 + is_found = pre_expand(visited, search_err_code, arg);
110142 + pointer_set_destroy(visited);
110143 +
110144 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
110145 + return true;
110146 +
110147 + if (where == FROM_ARG && skip_asm(arg))
110148 + return true;
110149 +
110150 + if (is_found == MARK_TURN_OFF)
110151 + return true;
110152 +
110153 + if ((is_found == MARK_YES && is_marked == MARK_YES))
110154 + return true;
110155 +
110156 + if (is_found == MARK_YES) {
110157 + loc = DECL_SOURCE_LOCATION(fndecl);
110158 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
110159 + return true;
110160 + }
110161 + return false;
110162 +}
110163 +
110164 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
110165 +{
110166 + struct pointer_set_t *visited;
110167 + tree arg, new_arg;
110168 + bool match;
110169 +
110170 + if (argnum == 0)
110171 + return;
110172 +
110173 + argnum--;
110174 +
110175 + match = get_function_arg(&argnum, fndecl);
110176 + if (!match)
110177 + return;
110178 + gcc_assert(gimple_call_num_args(stmt) > argnum);
110179 + arg = gimple_call_arg(stmt, argnum);
110180 + if (arg == NULL_TREE)
110181 + return;
110182 +
110183 + if (skip_types(arg))
110184 + return;
110185 +
110186 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
110187 + return;
110188 +
110189 + visited = pointer_set_create();
110190 + new_arg = expand(visited, arg);
110191 + pointer_set_destroy(visited);
110192 +
110193 + if (new_arg == NULL_TREE)
110194 + return;
110195 +
110196 + change_function_arg(stmt, arg, argnum, new_arg);
110197 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
110198 +}
110199 +
110200 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
110201 +{
110202 + tree p = TREE_VALUE(attr);
110203 + do {
110204 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
110205 + p = TREE_CHAIN(p);
110206 + } while (p);
110207 +}
110208 +
110209 +static void handle_function_by_hash(gimple stmt, tree fndecl)
110210 +{
110211 + unsigned int num;
110212 + const struct size_overflow_hash *hash;
110213 +
110214 + hash = get_function_hash(fndecl);
110215 + if (!hash)
110216 + return;
110217 +
110218 + for (num = 0; num <= MAX_PARAM; num++)
110219 + if (hash->param & (1U << num))
110220 + handle_function_arg(stmt, fndecl, num);
110221 +}
110222 +
110223 +static bool check_return_value(void)
110224 +{
110225 + const struct size_overflow_hash *hash;
110226 +
110227 + hash = get_function_hash(current_function_decl);
110228 + if (!hash || !(hash->param & 1U << 0))
110229 + return false;
110230 +
110231 + return true;
110232 +}
110233 +
110234 +static void handle_return_value(gimple ret_stmt)
110235 +{
110236 + struct pointer_set_t *visited;
110237 + tree ret, new_ret;
110238 +
110239 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
110240 + return;
110241 +
110242 + ret = gimple_return_retval(ret_stmt);
110243 +
110244 + if (skip_types(ret))
110245 + return;
110246 +
110247 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
110248 + return;
110249 +
110250 + visited = pointer_set_create();
110251 + new_ret = expand(visited, ret);
110252 + pointer_set_destroy(visited);
110253 +
110254 + change_function_return(ret_stmt, ret, new_ret);
110255 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
110256 +}
110257 +
110258 +static void set_plf_false(void)
110259 +{
110260 + basic_block bb;
110261 +
110262 + FOR_ALL_BB(bb) {
110263 + gimple_stmt_iterator si;
110264 +
110265 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
110266 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110267 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
110268 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110269 + }
110270 +}
110271 +
110272 +static unsigned int handle_function(void)
110273 +{
110274 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
110275 + bool check_ret;
110276 +
110277 + set_plf_false();
110278 +
110279 + check_ret = check_return_value();
110280 +
110281 + do {
110282 + gimple_stmt_iterator gsi;
110283 + next = bb->next_bb;
110284 +
110285 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110286 + tree fndecl, attr;
110287 + gimple stmt = gsi_stmt(gsi);
110288 +
110289 + if (check_ret)
110290 + handle_return_value(stmt);
110291 +
110292 + if (!(is_gimple_call(stmt)))
110293 + continue;
110294 + fndecl = gimple_call_fndecl(stmt);
110295 + if (fndecl == NULL_TREE)
110296 + continue;
110297 + if (gimple_call_num_args(stmt) == 0)
110298 + continue;
110299 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
110300 + if (!attr || !TREE_VALUE(attr))
110301 + handle_function_by_hash(stmt, fndecl);
110302 + else
110303 + handle_function_by_attribute(stmt, attr, fndecl);
110304 + gsi = gsi_for_stmt(stmt);
110305 + next = gimple_bb(stmt)->next_bb;
110306 + }
110307 + bb = next;
110308 + } while (bb);
110309 + return 0;
110310 +}
110311 +
110312 +static struct gimple_opt_pass size_overflow_pass = {
110313 + .pass = {
110314 + .type = GIMPLE_PASS,
110315 + .name = "size_overflow",
110316 +#if BUILDING_GCC_VERSION >= 4008
110317 + .optinfo_flags = OPTGROUP_NONE,
110318 +#endif
110319 + .gate = NULL,
110320 + .execute = handle_function,
110321 + .sub = NULL,
110322 + .next = NULL,
110323 + .static_pass_number = 0,
110324 + .tv_id = TV_NONE,
110325 + .properties_required = PROP_cfg,
110326 + .properties_provided = 0,
110327 + .properties_destroyed = 0,
110328 + .todo_flags_start = 0,
110329 + .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
110330 + }
110331 +};
110332 +
110333 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
110334 +{
110335 + tree fntype;
110336 +
110337 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
110338 +
110339 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
110340 + fntype = build_function_type_list(void_type_node,
110341 + const_char_ptr_type_node,
110342 + unsigned_type_node,
110343 + const_char_ptr_type_node,
110344 + const_char_ptr_type_node,
110345 + NULL_TREE);
110346 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
110347 +
110348 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
110349 + TREE_PUBLIC(report_size_overflow_decl) = 1;
110350 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
110351 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
110352 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
110353 +}
110354 +
110355 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110356 +{
110357 + int i;
110358 + const char * const plugin_name = plugin_info->base_name;
110359 + const int argc = plugin_info->argc;
110360 + const struct plugin_argument * const argv = plugin_info->argv;
110361 + bool enable = true;
110362 +
110363 + struct register_pass_info size_overflow_pass_info = {
110364 + .pass = &size_overflow_pass.pass,
110365 + .reference_pass_name = "ssa",
110366 + .ref_pass_instance_number = 1,
110367 + .pos_op = PASS_POS_INSERT_AFTER
110368 + };
110369 +
110370 + if (!plugin_default_version_check(version, &gcc_version)) {
110371 + error(G_("incompatible gcc/plugin versions"));
110372 + return 1;
110373 + }
110374 +
110375 + for (i = 0; i < argc; ++i) {
110376 + if (!strcmp(argv[i].key, "no-size-overflow")) {
110377 + enable = false;
110378 + continue;
110379 + }
110380 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110381 + }
110382 +
110383 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
110384 + if (enable) {
110385 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
110386 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
110387 + }
110388 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110389 +
110390 + return 0;
110391 +}
110392 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
110393 new file mode 100644
110394 index 0000000..ac2901e
110395 --- /dev/null
110396 +++ b/tools/gcc/stackleak_plugin.c
110397 @@ -0,0 +1,327 @@
110398 +/*
110399 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
110400 + * Licensed under the GPL v2
110401 + *
110402 + * Note: the choice of the license means that the compilation process is
110403 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110404 + * but for the kernel it doesn't matter since it doesn't link against
110405 + * any of the gcc libraries
110406 + *
110407 + * gcc plugin to help implement various PaX features
110408 + *
110409 + * - track lowest stack pointer
110410 + *
110411 + * TODO:
110412 + * - initialize all local variables
110413 + *
110414 + * BUGS:
110415 + * - none known
110416 + */
110417 +#include "gcc-plugin.h"
110418 +#include "config.h"
110419 +#include "system.h"
110420 +#include "coretypes.h"
110421 +#include "tree.h"
110422 +#include "tree-pass.h"
110423 +#include "flags.h"
110424 +#include "intl.h"
110425 +#include "toplev.h"
110426 +#include "plugin.h"
110427 +//#include "expr.h" where are you...
110428 +#include "diagnostic.h"
110429 +#include "plugin-version.h"
110430 +#include "tm.h"
110431 +#include "function.h"
110432 +#include "basic-block.h"
110433 +#include "gimple.h"
110434 +#include "rtl.h"
110435 +#include "emit-rtl.h"
110436 +
110437 +#if BUILDING_GCC_VERSION >= 4008
110438 +#define TODO_dump_func 0
110439 +#endif
110440 +
110441 +extern void print_gimple_stmt(FILE *, gimple, int, int);
110442 +
110443 +int plugin_is_GPL_compatible;
110444 +
110445 +static int track_frame_size = -1;
110446 +static const char track_function[] = "pax_track_stack";
110447 +static const char check_function[] = "pax_check_alloca";
110448 +static bool init_locals;
110449 +
110450 +static struct plugin_info stackleak_plugin_info = {
110451 + .version = "201302112000",
110452 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
110453 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
110454 +};
110455 +
110456 +static bool gate_stackleak_track_stack(void);
110457 +static unsigned int execute_stackleak_tree_instrument(void);
110458 +static unsigned int execute_stackleak_final(void);
110459 +
110460 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
110461 + .pass = {
110462 + .type = GIMPLE_PASS,
110463 + .name = "stackleak_tree_instrument",
110464 +#if BUILDING_GCC_VERSION >= 4008
110465 + .optinfo_flags = OPTGROUP_NONE,
110466 +#endif
110467 + .gate = gate_stackleak_track_stack,
110468 + .execute = execute_stackleak_tree_instrument,
110469 + .sub = NULL,
110470 + .next = NULL,
110471 + .static_pass_number = 0,
110472 + .tv_id = TV_NONE,
110473 + .properties_required = PROP_gimple_leh | PROP_cfg,
110474 + .properties_provided = 0,
110475 + .properties_destroyed = 0,
110476 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
110477 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
110478 + }
110479 +};
110480 +
110481 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
110482 + .pass = {
110483 + .type = RTL_PASS,
110484 + .name = "stackleak_final",
110485 +#if BUILDING_GCC_VERSION >= 4008
110486 + .optinfo_flags = OPTGROUP_NONE,
110487 +#endif
110488 + .gate = gate_stackleak_track_stack,
110489 + .execute = execute_stackleak_final,
110490 + .sub = NULL,
110491 + .next = NULL,
110492 + .static_pass_number = 0,
110493 + .tv_id = TV_NONE,
110494 + .properties_required = 0,
110495 + .properties_provided = 0,
110496 + .properties_destroyed = 0,
110497 + .todo_flags_start = 0,
110498 + .todo_flags_finish = TODO_dump_func
110499 + }
110500 +};
110501 +
110502 +static bool gate_stackleak_track_stack(void)
110503 +{
110504 + return track_frame_size >= 0;
110505 +}
110506 +
110507 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
110508 +{
110509 + gimple check_alloca;
110510 + tree fntype, fndecl, alloca_size;
110511 +
110512 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
110513 + fndecl = build_fn_decl(check_function, fntype);
110514 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110515 +
110516 + // insert call to void pax_check_alloca(unsigned long size)
110517 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
110518 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
110519 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
110520 +}
110521 +
110522 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
110523 +{
110524 + gimple track_stack;
110525 + tree fntype, fndecl;
110526 +
110527 + fntype = build_function_type_list(void_type_node, NULL_TREE);
110528 + fndecl = build_fn_decl(track_function, fntype);
110529 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110530 +
110531 + // insert call to void pax_track_stack(void)
110532 + track_stack = gimple_build_call(fndecl, 0);
110533 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
110534 +}
110535 +
110536 +#if BUILDING_GCC_VERSION == 4005
110537 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
110538 +{
110539 + tree fndecl;
110540 +
110541 + if (!is_gimple_call(stmt))
110542 + return false;
110543 + fndecl = gimple_call_fndecl(stmt);
110544 + if (!fndecl)
110545 + return false;
110546 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
110547 + return false;
110548 +// print_node(stderr, "pax", fndecl, 4);
110549 + return DECL_FUNCTION_CODE(fndecl) == code;
110550 +}
110551 +#endif
110552 +
110553 +static bool is_alloca(gimple stmt)
110554 +{
110555 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
110556 + return true;
110557 +
110558 +#if BUILDING_GCC_VERSION >= 4007
110559 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
110560 + return true;
110561 +#endif
110562 +
110563 + return false;
110564 +}
110565 +
110566 +static unsigned int execute_stackleak_tree_instrument(void)
110567 +{
110568 + basic_block bb, entry_bb;
110569 + bool prologue_instrumented = false, is_leaf = true;
110570 +
110571 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
110572 +
110573 + // 1. loop through BBs and GIMPLE statements
110574 + FOR_EACH_BB(bb) {
110575 + gimple_stmt_iterator gsi;
110576 +
110577 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110578 + gimple stmt;
110579 +
110580 + stmt = gsi_stmt(gsi);
110581 +
110582 + if (is_gimple_call(stmt))
110583 + is_leaf = false;
110584 +
110585 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
110586 + if (!is_alloca(stmt))
110587 + continue;
110588 +
110589 + // 2. insert stack overflow check before each __builtin_alloca call
110590 + stackleak_check_alloca(&gsi);
110591 +
110592 + // 3. insert track call after each __builtin_alloca call
110593 + stackleak_add_instrumentation(&gsi);
110594 + if (bb == entry_bb)
110595 + prologue_instrumented = true;
110596 + }
110597 + }
110598 +
110599 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
110600 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
110601 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
110602 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
110603 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
110604 + return 0;
110605 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
110606 + return 0;
110607 +
110608 + // 4. insert track call at the beginning
110609 + if (!prologue_instrumented) {
110610 + gimple_stmt_iterator gsi;
110611 +
110612 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110613 + if (dom_info_available_p(CDI_DOMINATORS))
110614 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110615 + gsi = gsi_start_bb(bb);
110616 + stackleak_add_instrumentation(&gsi);
110617 + }
110618 +
110619 + return 0;
110620 +}
110621 +
110622 +static unsigned int execute_stackleak_final(void)
110623 +{
110624 + rtx insn, next;
110625 +
110626 + if (cfun->calls_alloca)
110627 + return 0;
110628 +
110629 + // keep calls only if function frame is big enough
110630 + if (get_frame_size() >= track_frame_size)
110631 + return 0;
110632 +
110633 + // 1. find pax_track_stack calls
110634 + for (insn = get_insns(); insn; insn = next) {
110635 + // 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))
110636 + rtx body;
110637 +
110638 + next = NEXT_INSN(insn);
110639 + if (!CALL_P(insn))
110640 + continue;
110641 + body = PATTERN(insn);
110642 + if (GET_CODE(body) != CALL)
110643 + continue;
110644 + body = XEXP(body, 0);
110645 + if (GET_CODE(body) != MEM)
110646 + continue;
110647 + body = XEXP(body, 0);
110648 + if (GET_CODE(body) != SYMBOL_REF)
110649 + continue;
110650 + if (strcmp(XSTR(body, 0), track_function))
110651 + continue;
110652 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110653 + // 2. delete call
110654 + delete_insn_and_edges(insn);
110655 +#if BUILDING_GCC_VERSION >= 4007
110656 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
110657 + insn = next;
110658 + next = NEXT_INSN(insn);
110659 + delete_insn_and_edges(insn);
110660 + }
110661 +#endif
110662 + }
110663 +
110664 +// print_simple_rtl(stderr, get_insns());
110665 +// print_rtl(stderr, get_insns());
110666 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110667 +
110668 + return 0;
110669 +}
110670 +
110671 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110672 +{
110673 + const char * const plugin_name = plugin_info->base_name;
110674 + const int argc = plugin_info->argc;
110675 + const struct plugin_argument * const argv = plugin_info->argv;
110676 + int i;
110677 + struct register_pass_info stackleak_tree_instrument_pass_info = {
110678 + .pass = &stackleak_tree_instrument_pass.pass,
110679 +// .reference_pass_name = "tree_profile",
110680 + .reference_pass_name = "optimized",
110681 + .ref_pass_instance_number = 1,
110682 + .pos_op = PASS_POS_INSERT_BEFORE
110683 + };
110684 + struct register_pass_info stackleak_final_pass_info = {
110685 + .pass = &stackleak_final_rtl_opt_pass.pass,
110686 + .reference_pass_name = "final",
110687 + .ref_pass_instance_number = 1,
110688 + .pos_op = PASS_POS_INSERT_BEFORE
110689 + };
110690 +
110691 + if (!plugin_default_version_check(version, &gcc_version)) {
110692 + error(G_("incompatible gcc/plugin versions"));
110693 + return 1;
110694 + }
110695 +
110696 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
110697 +
110698 + for (i = 0; i < argc; ++i) {
110699 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
110700 + if (!argv[i].value) {
110701 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110702 + continue;
110703 + }
110704 + track_frame_size = atoi(argv[i].value);
110705 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
110706 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110707 + continue;
110708 + }
110709 + if (!strcmp(argv[i].key, "initialize-locals")) {
110710 + if (argv[i].value) {
110711 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110712 + continue;
110713 + }
110714 + init_locals = true;
110715 + continue;
110716 + }
110717 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110718 + }
110719 +
110720 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
110721 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
110722 +
110723 + return 0;
110724 +}
110725 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
110726 new file mode 100644
110727 index 0000000..4fae911
110728 --- /dev/null
110729 +++ b/tools/gcc/structleak_plugin.c
110730 @@ -0,0 +1,277 @@
110731 +/*
110732 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
110733 + * Licensed under the GPL v2
110734 + *
110735 + * Note: the choice of the license means that the compilation process is
110736 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110737 + * but for the kernel it doesn't matter since it doesn't link against
110738 + * any of the gcc libraries
110739 + *
110740 + * gcc plugin to forcibly initialize certain local variables that could
110741 + * otherwise leak kernel stack to userland if they aren't properly initialized
110742 + * by later code
110743 + *
110744 + * Homepage: http://pax.grsecurity.net/
110745 + *
110746 + * Usage:
110747 + * $ # for 4.5/4.6/C based 4.7
110748 + * $ 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
110749 + * $ # for C++ based 4.7/4.8+
110750 + * $ 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
110751 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
110752 + *
110753 + * TODO: eliminate redundant initializers
110754 + * increase type coverage
110755 + */
110756 +
110757 +#include "gcc-plugin.h"
110758 +#include "config.h"
110759 +#include "system.h"
110760 +#include "coretypes.h"
110761 +#include "tree.h"
110762 +#include "tree-pass.h"
110763 +#include "intl.h"
110764 +#include "plugin-version.h"
110765 +#include "tm.h"
110766 +#include "toplev.h"
110767 +#include "function.h"
110768 +#include "tree-flow.h"
110769 +#include "plugin.h"
110770 +#include "gimple.h"
110771 +#include "diagnostic.h"
110772 +#include "cfgloop.h"
110773 +#include "langhooks.h"
110774 +
110775 +#if BUILDING_GCC_VERSION >= 4008
110776 +#define TODO_dump_func 0
110777 +#endif
110778 +
110779 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110780 +
110781 +// unused type flag in all versions 4.5-4.8
110782 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
110783 +
110784 +int plugin_is_GPL_compatible;
110785 +void debug_gimple_stmt(gimple gs);
110786 +
110787 +static struct plugin_info structleak_plugin_info = {
110788 + .version = "201304082245",
110789 + .help = "disable\tdo not activate plugin\n",
110790 +};
110791 +
110792 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
110793 +{
110794 + *no_add_attrs = true;
110795 +
110796 + // check for types? for now accept everything linux has to offer
110797 + if (TREE_CODE(*node) != FIELD_DECL)
110798 + return NULL_TREE;
110799 +
110800 + *no_add_attrs = false;
110801 + return NULL_TREE;
110802 +}
110803 +
110804 +static struct attribute_spec user_attr = {
110805 + .name = "user",
110806 + .min_length = 0,
110807 + .max_length = 0,
110808 + .decl_required = false,
110809 + .type_required = false,
110810 + .function_type_required = false,
110811 + .handler = handle_user_attribute,
110812 +#if BUILDING_GCC_VERSION >= 4007
110813 + .affects_type_identity = true
110814 +#endif
110815 +};
110816 +
110817 +static void register_attributes(void *event_data, void *data)
110818 +{
110819 + register_attribute(&user_attr);
110820 +// register_attribute(&force_attr);
110821 +}
110822 +
110823 +static tree get_field_type(tree field)
110824 +{
110825 + return strip_array_types(TREE_TYPE(field));
110826 +}
110827 +
110828 +static bool is_userspace_type(tree type)
110829 +{
110830 + tree field;
110831 +
110832 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
110833 + tree fieldtype = get_field_type(field);
110834 + enum tree_code code = TREE_CODE(fieldtype);
110835 +
110836 + if (code == RECORD_TYPE || code == UNION_TYPE)
110837 + if (is_userspace_type(fieldtype))
110838 + return true;
110839 +
110840 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
110841 + return true;
110842 + }
110843 + return false;
110844 +}
110845 +
110846 +static void finish_type(void *event_data, void *data)
110847 +{
110848 + tree type = (tree)event_data;
110849 +
110850 + if (TYPE_USERSPACE(type))
110851 + return;
110852 +
110853 + if (is_userspace_type(type))
110854 + TYPE_USERSPACE(type) = 1;
110855 +}
110856 +
110857 +static void initialize(tree var)
110858 +{
110859 + basic_block bb;
110860 + gimple_stmt_iterator gsi;
110861 + tree initializer;
110862 + gimple init_stmt;
110863 +
110864 + // this is the original entry bb before the forced split
110865 + // TODO: check further BBs in case more splits occured before us
110866 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
110867 +
110868 + // first check if the variable is already initialized, warn otherwise
110869 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110870 + gimple stmt = gsi_stmt(gsi);
110871 + tree rhs1;
110872 +
110873 + // we're looking for an assignment of a single rhs...
110874 + if (!gimple_assign_single_p(stmt))
110875 + continue;
110876 + rhs1 = gimple_assign_rhs1(stmt);
110877 +#if BUILDING_GCC_VERSION >= 4007
110878 + // ... of a non-clobbering expression...
110879 + if (TREE_CLOBBER_P(rhs1))
110880 + continue;
110881 +#endif
110882 + // ... to our variable...
110883 + if (gimple_get_lhs(stmt) != var)
110884 + continue;
110885 + // if it's an initializer then we're good
110886 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
110887 + return;
110888 + }
110889 +
110890 + // these aren't the 0days you're looking for
110891 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
110892 +
110893 + // build the initializer expression
110894 + initializer = build_constructor(TREE_TYPE(var), NULL);
110895 +
110896 + // build the initializer stmt
110897 + init_stmt = gimple_build_assign(var, initializer);
110898 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
110899 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
110900 + update_stmt(init_stmt);
110901 +}
110902 +
110903 +static unsigned int handle_function(void)
110904 +{
110905 + basic_block bb;
110906 + unsigned int ret = 0;
110907 + tree var;
110908 +
110909 +#if BUILDING_GCC_VERSION == 4005
110910 + tree vars;
110911 +#else
110912 + unsigned int i;
110913 +#endif
110914 +
110915 + // split the first bb where we can put the forced initializers
110916 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110917 + if (dom_info_available_p(CDI_DOMINATORS))
110918 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110919 +
110920 + // enumarate all local variables and forcibly initialize our targets
110921 +#if BUILDING_GCC_VERSION == 4005
110922 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
110923 + var = TREE_VALUE(vars);
110924 +#else
110925 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
110926 +#endif
110927 + tree type = TREE_TYPE(var);
110928 +
110929 + gcc_assert(DECL_P(var));
110930 + if (!auto_var_in_fn_p(var, current_function_decl))
110931 + continue;
110932 +
110933 + // only care about structure types
110934 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
110935 + continue;
110936 +
110937 + // if the type is of interest, examine the variable
110938 + if (TYPE_USERSPACE(type))
110939 + initialize(var);
110940 + }
110941 +
110942 + return ret;
110943 +}
110944 +
110945 +static struct gimple_opt_pass structleak_pass = {
110946 + .pass = {
110947 + .type = GIMPLE_PASS,
110948 + .name = "structleak",
110949 +#if BUILDING_GCC_VERSION >= 4008
110950 + .optinfo_flags = OPTGROUP_NONE,
110951 +#endif
110952 + .gate = NULL,
110953 + .execute = handle_function,
110954 + .sub = NULL,
110955 + .next = NULL,
110956 + .static_pass_number = 0,
110957 + .tv_id = TV_NONE,
110958 + .properties_required = PROP_cfg,
110959 + .properties_provided = 0,
110960 + .properties_destroyed = 0,
110961 + .todo_flags_start = 0,
110962 + .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
110963 + }
110964 +};
110965 +
110966 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110967 +{
110968 + int i;
110969 + const char * const plugin_name = plugin_info->base_name;
110970 + const int argc = plugin_info->argc;
110971 + const struct plugin_argument * const argv = plugin_info->argv;
110972 + bool enable = true;
110973 +
110974 + struct register_pass_info structleak_pass_info = {
110975 + .pass = &structleak_pass.pass,
110976 + .reference_pass_name = "ssa",
110977 + .ref_pass_instance_number = 1,
110978 + .pos_op = PASS_POS_INSERT_AFTER
110979 + };
110980 +
110981 + if (!plugin_default_version_check(version, &gcc_version)) {
110982 + error(G_("incompatible gcc/plugin versions"));
110983 + return 1;
110984 + }
110985 +
110986 + if (strcmp(lang_hooks.name, "GNU C")) {
110987 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
110988 + enable = false;
110989 + }
110990 +
110991 + for (i = 0; i < argc; ++i) {
110992 + if (!strcmp(argv[i].key, "disable")) {
110993 + enable = false;
110994 + continue;
110995 + }
110996 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110997 + }
110998 +
110999 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
111000 + if (enable) {
111001 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
111002 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
111003 + }
111004 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
111005 +
111006 + return 0;
111007 +}
111008 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
111009 index 280dd82..077b427 100644
111010 --- a/tools/lib/lk/Makefile
111011 +++ b/tools/lib/lk/Makefile
111012 @@ -28,7 +28,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
111013
111014 LIBFILE = liblk.a
111015
111016 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
111017 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
111018 EXTLIBS = -lelf -lpthread -lrt -lm
111019 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
111020 ALL_LDFLAGS = $(LDFLAGS)
111021 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
111022 index 6789d78..4afd019e 100644
111023 --- a/tools/perf/util/include/asm/alternative-asm.h
111024 +++ b/tools/perf/util/include/asm/alternative-asm.h
111025 @@ -5,4 +5,7 @@
111026
111027 #define altinstruction_entry #
111028
111029 + .macro pax_force_retaddr rip=0, reload=0
111030 + .endm
111031 +
111032 #endif
111033 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
111034 index 96b919d..c49bb74 100644
111035 --- a/tools/perf/util/include/linux/compiler.h
111036 +++ b/tools/perf/util/include/linux/compiler.h
111037 @@ -18,4 +18,12 @@
111038 #define __force
111039 #endif
111040
111041 +#ifndef __size_overflow
111042 +# define __size_overflow(...)
111043 +#endif
111044 +
111045 +#ifndef __intentional_overflow
111046 +# define __intentional_overflow(...)
111047 +#endif
111048 +
111049 #endif
111050 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
111051 index 1580dd4..5627b5b 100644
111052 --- a/virt/kvm/kvm_main.c
111053 +++ b/virt/kvm/kvm_main.c
111054 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
111055
111056 static cpumask_var_t cpus_hardware_enabled;
111057 static int kvm_usage_count = 0;
111058 -static atomic_t hardware_enable_failed;
111059 +static atomic_unchecked_t hardware_enable_failed;
111060
111061 struct kmem_cache *kvm_vcpu_cache;
111062 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
111063
111064 -static __read_mostly struct preempt_ops kvm_preempt_ops;
111065 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
111066 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
111067 +static struct preempt_ops kvm_preempt_ops = {
111068 + .sched_in = kvm_sched_in,
111069 + .sched_out = kvm_sched_out,
111070 +};
111071
111072 struct dentry *kvm_debugfs_dir;
111073
111074 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
111075 /* We can read the guest memory with __xxx_user() later on. */
111076 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
111077 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
111078 - !access_ok(VERIFY_WRITE,
111079 + !__access_ok(VERIFY_WRITE,
111080 (void __user *)(unsigned long)mem->userspace_addr,
111081 mem->memory_size)))
111082 goto out;
111083 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
111084 return 0;
111085 }
111086
111087 -static struct file_operations kvm_vcpu_fops = {
111088 +static file_operations_no_const kvm_vcpu_fops __read_only = {
111089 .release = kvm_vcpu_release,
111090 .unlocked_ioctl = kvm_vcpu_ioctl,
111091 #ifdef CONFIG_COMPAT
111092 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
111093 return 0;
111094 }
111095
111096 -static struct file_operations kvm_vm_fops = {
111097 +static file_operations_no_const kvm_vm_fops __read_only = {
111098 .release = kvm_vm_release,
111099 .unlocked_ioctl = kvm_vm_ioctl,
111100 #ifdef CONFIG_COMPAT
111101 @@ -2662,7 +2667,7 @@ out:
111102 return r;
111103 }
111104
111105 -static struct file_operations kvm_chardev_ops = {
111106 +static file_operations_no_const kvm_chardev_ops __read_only = {
111107 .unlocked_ioctl = kvm_dev_ioctl,
111108 .compat_ioctl = kvm_dev_ioctl,
111109 .llseek = noop_llseek,
111110 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
111111
111112 if (r) {
111113 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
111114 - atomic_inc(&hardware_enable_failed);
111115 + atomic_inc_unchecked(&hardware_enable_failed);
111116 printk(KERN_INFO "kvm: enabling virtualization on "
111117 "CPU%d failed\n", cpu);
111118 }
111119 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
111120
111121 kvm_usage_count++;
111122 if (kvm_usage_count == 1) {
111123 - atomic_set(&hardware_enable_failed, 0);
111124 + atomic_set_unchecked(&hardware_enable_failed, 0);
111125 on_each_cpu(hardware_enable_nolock, NULL, 1);
111126
111127 - if (atomic_read(&hardware_enable_failed)) {
111128 + if (atomic_read_unchecked(&hardware_enable_failed)) {
111129 hardware_disable_all_nolock();
111130 r = -EBUSY;
111131 }
111132 @@ -3100,7 +3105,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
111133 kvm_arch_vcpu_put(vcpu);
111134 }
111135
111136 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111137 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111138 struct module *module)
111139 {
111140 int r;
111141 @@ -3147,7 +3152,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111142 if (!vcpu_align)
111143 vcpu_align = __alignof__(struct kvm_vcpu);
111144 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
111145 - 0, NULL);
111146 + SLAB_USERCOPY, NULL);
111147 if (!kvm_vcpu_cache) {
111148 r = -ENOMEM;
111149 goto out_free_3;
111150 @@ -3157,9 +3162,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111151 if (r)
111152 goto out_free;
111153
111154 + pax_open_kernel();
111155 kvm_chardev_ops.owner = module;
111156 kvm_vm_fops.owner = module;
111157 kvm_vcpu_fops.owner = module;
111158 + pax_close_kernel();
111159
111160 r = misc_register(&kvm_dev);
111161 if (r) {
111162 @@ -3169,9 +3176,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111163
111164 register_syscore_ops(&kvm_syscore_ops);
111165
111166 - kvm_preempt_ops.sched_in = kvm_sched_in;
111167 - kvm_preempt_ops.sched_out = kvm_sched_out;
111168 -
111169 r = kvm_init_debug();
111170 if (r) {
111171 printk(KERN_ERR "kvm: create debugfs files failed\n");