]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.11.8-201311182333.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.11.8-201311182333.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..79768fb 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,9 +75,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 +TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56 @@ -80,6 +88,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60 +ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64 @@ -92,19 +101,24 @@ bounds.h
65 bsetup
66 btfixupprep
67 build
68 +builtin-policy.h
69 bvmlinux
70 bzImage*
71 capability_names.h
72 capflags.c
73 classlist.h*
74 +clut_vga16.c
75 +common-cmds.h
76 comp*.log
77 compile.h*
78 conf
79 config
80 config-*
81 config_data.h*
82 +config.c
83 config.mak
84 config.mak.autogen
85 +config.tmp
86 conmakehash
87 consolemap_deftbl.c*
88 cpustr.h
89 @@ -115,9 +129,11 @@ devlist.h*
90 dnotify_test
91 docproc
92 dslm
93 +dtc-lexer.lex.c
94 elf2ecoff
95 elfconfig.h*
96 evergreen_reg_safe.h
97 +exception_policy.conf
98 fixdep
99 flask.h
100 fore200e_mkfirm
101 @@ -125,12 +141,15 @@ fore200e_pca_fw.c*
102 gconf
103 gconf.glade.h
104 gen-devlist
105 +gen-kdb_cmds.c
106 gen_crc32table
107 gen_init_cpio
108 generated
109 genheaders
110 genksyms
111 *_gray256.c
112 +hash
113 +hid-example
114 hpet_example
115 hugepage-mmap
116 hugepage-shm
117 @@ -145,14 +164,14 @@ int32.c
118 int4.c
119 int8.c
120 kallsyms
121 -kconfig
122 +kern_constants.h
123 keywords.c
124 ksym.c*
125 ksym.h*
126 kxgettext
127 lex.c
128 lex.*.c
129 -linux
130 +lib1funcs.S
131 logo_*.c
132 logo_*_clut224.c
133 logo_*_mono.c
134 @@ -162,14 +181,15 @@ mach-types.h
135 machtypes.h
136 map
137 map_hugetlb
138 -media
139 mconf
140 +mdp
141 miboot*
142 mk_elfconfig
143 mkboot
144 mkbugboot
145 mkcpustr
146 mkdep
147 +mkpiggy
148 mkprep
149 mkregtable
150 mktables
151 @@ -185,6 +205,8 @@ oui.c*
152 page-types
153 parse.c
154 parse.h
155 +parse-events*
156 +pasyms.h
157 patches*
158 pca200e.bin
159 pca200e_ecd.bin2
160 @@ -194,6 +216,7 @@ perf-archive
161 piggyback
162 piggy.gzip
163 piggy.S
164 +pmu-*
165 pnmtologo
166 ppc_defs.h*
167 pss_boot.h
168 @@ -203,7 +226,10 @@ r200_reg_safe.h
169 r300_reg_safe.h
170 r420_reg_safe.h
171 r600_reg_safe.h
172 +realmode.lds
173 +realmode.relocs
174 recordmcount
175 +regdb.c
176 relocs
177 rlim_names.h
178 rn50_reg_safe.h
179 @@ -213,8 +239,12 @@ series
180 setup
181 setup.bin
182 setup.elf
183 +signing_key*
184 +size_overflow_hash.h
185 sImage
186 +slabinfo
187 sm_tbl*
188 +sortextable
189 split-include
190 syscalltab.h
191 tables.c
192 @@ -224,6 +254,7 @@ tftpboot.img
193 timeconst.h
194 times.h*
195 trix_boot.h
196 +user_constants.h
197 utsrelease.h*
198 vdso-syms.lds
199 vdso.lds
200 @@ -235,13 +266,17 @@ vdso32.lds
201 vdso32.so.dbg
202 vdso64.lds
203 vdso64.so.dbg
204 +vdsox32.lds
205 +vdsox32-syms.lds
206 version.h*
207 vmImage
208 vmlinux
209 vmlinux-*
210 vmlinux.aout
211 vmlinux.bin.all
212 +vmlinux.bin.bz2
213 vmlinux.lds
214 +vmlinux.relocs
215 vmlinuz
216 voffset.h
217 vsyscall.lds
218 @@ -249,9 +284,12 @@ vsyscall_32.lds
219 wanxlfw.inc
220 uImage
221 unifdef
222 +utsrelease.h
223 wakeup.bin
224 wakeup.elf
225 wakeup.lds
226 +x509*
227 zImage*
228 zconf.hash.c
229 +zconf.lex.c
230 zoffset.h
231 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
232 index 7f9d4f5..6d1afd6 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -976,6 +976,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
236 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
237 Default: 1024
238
239 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
240 + ignore grsecurity's /proc restrictions
241 +
242 +
243 hashdist= [KNL,NUMA] Large hashes allocated during boot
244 are distributed across NUMA nodes. Defaults on
245 for 64-bit NUMA, off otherwise.
246 @@ -1932,6 +1936,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
247 noexec=on: enable non-executable mappings (default)
248 noexec=off: disable non-executable mappings
249
250 + nopcid [X86-64]
251 + Disable PCID (Process-Context IDentifier) even if it
252 + is supported by the processor.
253 +
254 nosmap [X86]
255 Disable SMAP (Supervisor Mode Access Prevention)
256 even if it is supported by processor.
257 @@ -2199,6 +2207,25 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
258 the specified number of seconds. This is to be used if
259 your oopses keep scrolling off the screen.
260
261 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
262 + virtualization environments that don't cope well with the
263 + expand down segment used by UDEREF on X86-32 or the frequent
264 + page table updates on X86-64.
265 +
266 + pax_sanitize_slab=
267 + 0/1 to disable/enable slab object sanitization (enabled by
268 + default).
269 +
270 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
271 +
272 + pax_extra_latent_entropy
273 + Enable a very simple form of latent entropy extraction
274 + from the first 4GB of memory as the bootmem allocator
275 + passes the memory pages to the buddy allocator.
276 +
277 + pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
278 + when the processor supports PCID.
279 +
280 pcbit= [HW,ISDN]
281
282 pcd. [PARIDE]
283 diff --git a/Makefile b/Makefile
284 index 7521adb..7279565 100644
285 --- a/Makefile
286 +++ b/Makefile
287 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
288
289 HOSTCC = gcc
290 HOSTCXX = g++
291 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
292 -HOSTCXXFLAGS = -O2
293 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
294 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
295 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
296
297 # Decide whether to build built-in, modular, or both.
298 # Normally, just do built-in.
299 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
300 # Rules shared between *config targets and build targets
301
302 # Basic helpers built in scripts/
303 -PHONY += scripts_basic
304 -scripts_basic:
305 +PHONY += scripts_basic gcc-plugins
306 +scripts_basic: gcc-plugins
307 $(Q)$(MAKE) $(build)=scripts/basic
308 $(Q)rm -f .tmp_quiet_recordmcount
309
310 @@ -576,6 +577,65 @@ else
311 KBUILD_CFLAGS += -O2
312 endif
313
314 +ifndef DISABLE_PAX_PLUGINS
315 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
316 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
317 +else
318 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
319 +endif
320 +ifneq ($(PLUGINCC),)
321 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
322 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
323 +endif
324 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
325 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
326 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
327 +endif
328 +ifdef CONFIG_KALLOCSTAT_PLUGIN
329 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
330 +endif
331 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
332 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
333 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
334 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
335 +endif
336 +ifdef CONFIG_CHECKER_PLUGIN
337 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
338 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
339 +endif
340 +endif
341 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
342 +ifdef CONFIG_PAX_SIZE_OVERFLOW
343 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
344 +endif
345 +ifdef CONFIG_PAX_LATENT_ENTROPY
346 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
347 +endif
348 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
349 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
350 +endif
351 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
352 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
353 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
354 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
355 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
356 +ifeq ($(KBUILD_EXTMOD),)
357 +gcc-plugins:
358 + $(Q)$(MAKE) $(build)=tools/gcc
359 +else
360 +gcc-plugins: ;
361 +endif
362 +else
363 +gcc-plugins:
364 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
365 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
366 +else
367 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
368 +endif
369 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
370 +endif
371 +endif
372 +
373 include $(srctree)/arch/$(SRCARCH)/Makefile
374
375 ifdef CONFIG_READABLE_ASM
376 @@ -733,7 +793,7 @@ export mod_sign_cmd
377
378
379 ifeq ($(KBUILD_EXTMOD),)
380 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
381 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
382
383 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
384 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
385 @@ -782,6 +842,8 @@ endif
386
387 # The actual objects are generated when descending,
388 # make sure no implicit rule kicks in
389 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
390 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
391 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
392
393 # Handle descending into subdirectories listed in $(vmlinux-dirs)
394 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
395 # Error messages still appears in the original language
396
397 PHONY += $(vmlinux-dirs)
398 -$(vmlinux-dirs): prepare scripts
399 +$(vmlinux-dirs): gcc-plugins prepare scripts
400 $(Q)$(MAKE) $(build)=$@
401
402 # Store (new) KERNELRELEASE string in include/config/kernel.release
403 @@ -835,6 +897,7 @@ prepare0: archprepare FORCE
404 $(Q)$(MAKE) $(build)=.
405
406 # All the preparing..
407 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
408 prepare: prepare0
409
410 # Generate some files
411 @@ -942,6 +1005,8 @@ all: modules
412 # using awk while concatenating to the final file.
413
414 PHONY += modules
415 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
416 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
417 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
418 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
419 @$(kecho) ' Building modules, stage 2.';
420 @@ -957,7 +1022,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
421
422 # Target to prepare building external modules
423 PHONY += modules_prepare
424 -modules_prepare: prepare scripts
425 +modules_prepare: gcc-plugins prepare scripts
426
427 # Target to install modules
428 PHONY += modules_install
429 @@ -1023,7 +1088,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
430 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
431 signing_key.priv signing_key.x509 x509.genkey \
432 extra_certificates signing_key.x509.keyid \
433 - signing_key.x509.signer
434 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
435
436 # clean - Delete most, but leave enough to build external modules
437 #
438 @@ -1063,6 +1128,7 @@ distclean: mrproper
439 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
440 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
441 -o -name '.*.rej' \
442 + -o -name '.*.rej' -o -name '*.so' \
443 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
444 -type f -print | xargs rm -f
445
446 @@ -1224,6 +1290,8 @@ PHONY += $(module-dirs) modules
447 $(module-dirs): crmodverdir $(objtree)/Module.symvers
448 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
449
450 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
451 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
452 modules: $(module-dirs)
453 @$(kecho) ' Building modules, stage 2.';
454 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
455 @@ -1363,17 +1431,21 @@ else
456 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
457 endif
458
459 -%.s: %.c prepare scripts FORCE
460 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 +%.s: %.c gcc-plugins prepare scripts FORCE
463 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
464 %.i: %.c prepare scripts FORCE
465 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
466 -%.o: %.c prepare scripts FORCE
467 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
468 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
469 +%.o: %.c gcc-plugins prepare scripts FORCE
470 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
471 %.lst: %.c prepare scripts FORCE
472 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
473 -%.s: %.S prepare scripts FORCE
474 +%.s: %.S gcc-plugins prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.S prepare scripts FORCE
477 +%.o: %.S gcc-plugins prepare scripts FORCE
478 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
479 %.symtypes: %.c prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 @@ -1383,11 +1455,15 @@ endif
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir)
485 -%/: prepare scripts FORCE
486 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
487 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
488 +%/: gcc-plugins prepare scripts FORCE
489 $(cmd_crmodverdir)
490 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
491 $(build)=$(build-dir)
492 -%.ko: prepare scripts FORCE
493 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
494 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
495 +%.ko: gcc-plugins prepare scripts FORCE
496 $(cmd_crmodverdir)
497 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
498 $(build)=$(build-dir) $(@:.ko=.o)
499 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
500 index 78b03ef..da28a51 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
504 #define atomic_dec(v) atomic_sub(1,(v))
505 #define atomic64_dec(v) atomic64_sub(1,(v))
506
507 +#define atomic64_read_unchecked(v) atomic64_read(v)
508 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
509 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
510 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
511 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
512 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
513 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
514 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
515 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
516 +
517 #define smp_mb__before_atomic_dec() smp_mb()
518 #define smp_mb__after_atomic_dec() smp_mb()
519 #define smp_mb__before_atomic_inc() smp_mb()
520 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
521 index ad368a9..fbe0f25 100644
522 --- a/arch/alpha/include/asm/cache.h
523 +++ b/arch/alpha/include/asm/cache.h
524 @@ -4,19 +4,19 @@
525 #ifndef __ARCH_ALPHA_CACHE_H
526 #define __ARCH_ALPHA_CACHE_H
527
528 +#include <linux/const.h>
529
530 /* Bytes per L1 (data) cache line. */
531 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
532 -# define L1_CACHE_BYTES 64
533 # define L1_CACHE_SHIFT 6
534 #else
535 /* Both EV4 and EV5 are write-through, read-allocate,
536 direct-mapped, physical.
537 */
538 -# define L1_CACHE_BYTES 32
539 # define L1_CACHE_SHIFT 5
540 #endif
541
542 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
543 #define SMP_CACHE_BYTES L1_CACHE_BYTES
544
545 #endif
546 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
547 index 968d999..d36b2df 100644
548 --- a/arch/alpha/include/asm/elf.h
549 +++ b/arch/alpha/include/asm/elf.h
550 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
551
552 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
553
554 +#ifdef CONFIG_PAX_ASLR
555 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
556 +
557 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
558 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
559 +#endif
560 +
561 /* $0 is set by ld.so to a pointer to a function which might be
562 registered using atexit. This provides a mean for the dynamic
563 linker to call DT_FINI functions for shared libraries that have
564 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
565 index bc2a0da..8ad11ee 100644
566 --- a/arch/alpha/include/asm/pgalloc.h
567 +++ b/arch/alpha/include/asm/pgalloc.h
568 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
569 pgd_set(pgd, pmd);
570 }
571
572 +static inline void
573 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
574 +{
575 + pgd_populate(mm, pgd, pmd);
576 +}
577 +
578 extern pgd_t *pgd_alloc(struct mm_struct *mm);
579
580 static inline void
581 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
582 index d8f9b7e..f6222fa 100644
583 --- a/arch/alpha/include/asm/pgtable.h
584 +++ b/arch/alpha/include/asm/pgtable.h
585 @@ -102,6 +102,17 @@ struct vm_area_struct;
586 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
587 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
588 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
589 +
590 +#ifdef CONFIG_PAX_PAGEEXEC
591 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
592 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
593 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
594 +#else
595 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
596 +# define PAGE_COPY_NOEXEC PAGE_COPY
597 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
598 +#endif
599 +
600 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
601
602 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
603 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
604 index 2fd00b7..cfd5069 100644
605 --- a/arch/alpha/kernel/module.c
606 +++ b/arch/alpha/kernel/module.c
607 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
608
609 /* The small sections were sorted to the end of the segment.
610 The following should definitely cover them. */
611 - gp = (u64)me->module_core + me->core_size - 0x8000;
612 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
613 got = sechdrs[me->arch.gotsecindex].sh_addr;
614
615 for (i = 0; i < n; i++) {
616 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
617 index 1402fcc..0b1abd2 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1298,10 +1298,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
621 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
622
623 static unsigned long
624 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
625 - unsigned long limit)
626 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
627 + unsigned long limit, unsigned long flags)
628 {
629 struct vm_unmapped_area_info info;
630 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
631
632 info.flags = 0;
633 info.length = len;
634 @@ -1309,6 +1310,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 info.high_limit = limit;
636 info.align_mask = 0;
637 info.align_offset = 0;
638 + info.threadstack_offset = offset;
639 return vm_unmapped_area(&info);
640 }
641
642 @@ -1341,20 +1343,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
643 merely specific addresses, but regions of memory -- perhaps
644 this feature should be incorporated into all ports? */
645
646 +#ifdef CONFIG_PAX_RANDMMAP
647 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
648 +#endif
649 +
650 if (addr) {
651 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
652 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
653 if (addr != (unsigned long) -ENOMEM)
654 return addr;
655 }
656
657 /* Next, try allocating at TASK_UNMAPPED_BASE. */
658 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
659 - len, limit);
660 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
661 +
662 if (addr != (unsigned long) -ENOMEM)
663 return addr;
664
665 /* Finally, try allocating in low memory. */
666 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
667 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
668
669 return addr;
670 }
671 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
672 index 0c4132d..88f0d53 100644
673 --- a/arch/alpha/mm/fault.c
674 +++ b/arch/alpha/mm/fault.c
675 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
676 __reload_thread(pcb);
677 }
678
679 +#ifdef CONFIG_PAX_PAGEEXEC
680 +/*
681 + * PaX: decide what to do with offenders (regs->pc = fault address)
682 + *
683 + * returns 1 when task should be killed
684 + * 2 when patched PLT trampoline was detected
685 + * 3 when unpatched PLT trampoline was detected
686 + */
687 +static int pax_handle_fetch_fault(struct pt_regs *regs)
688 +{
689 +
690 +#ifdef CONFIG_PAX_EMUPLT
691 + int err;
692 +
693 + do { /* PaX: patched PLT emulation #1 */
694 + unsigned int ldah, ldq, jmp;
695 +
696 + err = get_user(ldah, (unsigned int *)regs->pc);
697 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
698 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
699 +
700 + if (err)
701 + break;
702 +
703 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
704 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
705 + jmp == 0x6BFB0000U)
706 + {
707 + unsigned long r27, addr;
708 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
709 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
710 +
711 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
712 + err = get_user(r27, (unsigned long *)addr);
713 + if (err)
714 + break;
715 +
716 + regs->r27 = r27;
717 + regs->pc = r27;
718 + return 2;
719 + }
720 + } while (0);
721 +
722 + do { /* PaX: patched PLT emulation #2 */
723 + unsigned int ldah, lda, br;
724 +
725 + err = get_user(ldah, (unsigned int *)regs->pc);
726 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
727 + err |= get_user(br, (unsigned int *)(regs->pc+8));
728 +
729 + if (err)
730 + break;
731 +
732 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
733 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
734 + (br & 0xFFE00000U) == 0xC3E00000U)
735 + {
736 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
737 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
738 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
739 +
740 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
741 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + return 2;
743 + }
744 + } while (0);
745 +
746 + do { /* PaX: unpatched PLT emulation */
747 + unsigned int br;
748 +
749 + err = get_user(br, (unsigned int *)regs->pc);
750 +
751 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
752 + unsigned int br2, ldq, nop, jmp;
753 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
754 +
755 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
756 + err = get_user(br2, (unsigned int *)addr);
757 + err |= get_user(ldq, (unsigned int *)(addr+4));
758 + err |= get_user(nop, (unsigned int *)(addr+8));
759 + err |= get_user(jmp, (unsigned int *)(addr+12));
760 + err |= get_user(resolver, (unsigned long *)(addr+16));
761 +
762 + if (err)
763 + break;
764 +
765 + if (br2 == 0xC3600000U &&
766 + ldq == 0xA77B000CU &&
767 + nop == 0x47FF041FU &&
768 + jmp == 0x6B7B0000U)
769 + {
770 + regs->r28 = regs->pc+4;
771 + regs->r27 = addr+16;
772 + regs->pc = resolver;
773 + return 3;
774 + }
775 + }
776 + } while (0);
777 +#endif
778 +
779 + return 1;
780 +}
781 +
782 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
783 +{
784 + unsigned long i;
785 +
786 + printk(KERN_ERR "PAX: bytes at PC: ");
787 + for (i = 0; i < 5; i++) {
788 + unsigned int c;
789 + if (get_user(c, (unsigned int *)pc+i))
790 + printk(KERN_CONT "???????? ");
791 + else
792 + printk(KERN_CONT "%08x ", c);
793 + }
794 + printk("\n");
795 +}
796 +#endif
797
798 /*
799 * This routine handles page faults. It determines the address,
800 @@ -133,8 +251,29 @@ retry:
801 good_area:
802 si_code = SEGV_ACCERR;
803 if (cause < 0) {
804 - if (!(vma->vm_flags & VM_EXEC))
805 + if (!(vma->vm_flags & VM_EXEC)) {
806 +
807 +#ifdef CONFIG_PAX_PAGEEXEC
808 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
809 + goto bad_area;
810 +
811 + up_read(&mm->mmap_sem);
812 + switch (pax_handle_fetch_fault(regs)) {
813 +
814 +#ifdef CONFIG_PAX_EMUPLT
815 + case 2:
816 + case 3:
817 + return;
818 +#endif
819 +
820 + }
821 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
822 + do_group_exit(SIGKILL);
823 +#else
824 goto bad_area;
825 +#endif
826 +
827 + }
828 } else if (!cause) {
829 /* Allow reads even for write-only mappings */
830 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
831 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
832 index 43594d5..da71e62 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1791,7 +1791,7 @@ config ALIGNMENT_TRAP
836
837 config UACCESS_WITH_MEMCPY
838 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
839 - depends on MMU
840 + depends on MMU && !PAX_MEMORY_UDEREF
841 default y if CPU_FEROCEON
842 help
843 Implement faster copy_to_user and clear_user methods for CPU
844 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
845 index da1c77d..2ee6056 100644
846 --- a/arch/arm/include/asm/atomic.h
847 +++ b/arch/arm/include/asm/atomic.h
848 @@ -17,17 +17,35 @@
849 #include <asm/barrier.h>
850 #include <asm/cmpxchg.h>
851
852 +#ifdef CONFIG_GENERIC_ATOMIC64
853 +#include <asm-generic/atomic64.h>
854 +#endif
855 +
856 #define ATOMIC_INIT(i) { (i) }
857
858 #ifdef __KERNEL__
859
860 +#define _ASM_EXTABLE(from, to) \
861 +" .pushsection __ex_table,\"a\"\n"\
862 +" .align 3\n" \
863 +" .long " #from ", " #to"\n" \
864 +" .popsection"
865 +
866 /*
867 * On ARM, ordinary assignment (str instruction) doesn't clear the local
868 * strex/ldrex monitor on some implementations. The reason we can use it for
869 * atomic_set() is the clrex or dummy strex done on every exception return.
870 */
871 #define atomic_read(v) (*(volatile int *)&(v)->counter)
872 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
873 +{
874 + return v->counter;
875 +}
876 #define atomic_set(v,i) (((v)->counter) = (i))
877 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
878 +{
879 + v->counter = i;
880 +}
881
882 #if __LINUX_ARM_ARCH__ >= 6
883
884 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
885 int result;
886
887 __asm__ __volatile__("@ atomic_add\n"
888 +"1: ldrex %1, [%3]\n"
889 +" adds %0, %1, %4\n"
890 +
891 +#ifdef CONFIG_PAX_REFCOUNT
892 +" bvc 3f\n"
893 +"2: bkpt 0xf103\n"
894 +"3:\n"
895 +#endif
896 +
897 +" strex %1, %0, [%3]\n"
898 +" teq %1, #0\n"
899 +" bne 1b"
900 +
901 +#ifdef CONFIG_PAX_REFCOUNT
902 +"\n4:\n"
903 + _ASM_EXTABLE(2b, 4b)
904 +#endif
905 +
906 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
907 + : "r" (&v->counter), "Ir" (i)
908 + : "cc");
909 +}
910 +
911 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
912 +{
913 + unsigned long tmp;
914 + int result;
915 +
916 + __asm__ __volatile__("@ atomic_add_unchecked\n"
917 "1: ldrex %0, [%3]\n"
918 " add %0, %0, %4\n"
919 " strex %1, %0, [%3]\n"
920 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
921 smp_mb();
922
923 __asm__ __volatile__("@ atomic_add_return\n"
924 +"1: ldrex %1, [%3]\n"
925 +" adds %0, %1, %4\n"
926 +
927 +#ifdef CONFIG_PAX_REFCOUNT
928 +" bvc 3f\n"
929 +" mov %0, %1\n"
930 +"2: bkpt 0xf103\n"
931 +"3:\n"
932 +#endif
933 +
934 +" strex %1, %0, [%3]\n"
935 +" teq %1, #0\n"
936 +" bne 1b"
937 +
938 +#ifdef CONFIG_PAX_REFCOUNT
939 +"\n4:\n"
940 + _ASM_EXTABLE(2b, 4b)
941 +#endif
942 +
943 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
944 + : "r" (&v->counter), "Ir" (i)
945 + : "cc");
946 +
947 + smp_mb();
948 +
949 + return result;
950 +}
951 +
952 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
953 +{
954 + unsigned long tmp;
955 + int result;
956 +
957 + smp_mb();
958 +
959 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
960 "1: ldrex %0, [%3]\n"
961 " add %0, %0, %4\n"
962 " strex %1, %0, [%3]\n"
963 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
964 int result;
965
966 __asm__ __volatile__("@ atomic_sub\n"
967 +"1: ldrex %1, [%3]\n"
968 +" subs %0, %1, %4\n"
969 +
970 +#ifdef CONFIG_PAX_REFCOUNT
971 +" bvc 3f\n"
972 +"2: bkpt 0xf103\n"
973 +"3:\n"
974 +#endif
975 +
976 +" strex %1, %0, [%3]\n"
977 +" teq %1, #0\n"
978 +" bne 1b"
979 +
980 +#ifdef CONFIG_PAX_REFCOUNT
981 +"\n4:\n"
982 + _ASM_EXTABLE(2b, 4b)
983 +#endif
984 +
985 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
986 + : "r" (&v->counter), "Ir" (i)
987 + : "cc");
988 +}
989 +
990 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
991 +{
992 + unsigned long tmp;
993 + int result;
994 +
995 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
996 "1: ldrex %0, [%3]\n"
997 " sub %0, %0, %4\n"
998 " strex %1, %0, [%3]\n"
999 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1000 smp_mb();
1001
1002 __asm__ __volatile__("@ atomic_sub_return\n"
1003 -"1: ldrex %0, [%3]\n"
1004 -" sub %0, %0, %4\n"
1005 +"1: ldrex %1, [%3]\n"
1006 +" subs %0, %1, %4\n"
1007 +
1008 +#ifdef CONFIG_PAX_REFCOUNT
1009 +" bvc 3f\n"
1010 +" mov %0, %1\n"
1011 +"2: bkpt 0xf103\n"
1012 +"3:\n"
1013 +#endif
1014 +
1015 " strex %1, %0, [%3]\n"
1016 " teq %1, #0\n"
1017 " bne 1b"
1018 +
1019 +#ifdef CONFIG_PAX_REFCOUNT
1020 +"\n4:\n"
1021 + _ASM_EXTABLE(2b, 4b)
1022 +#endif
1023 +
1024 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1025 : "r" (&v->counter), "Ir" (i)
1026 : "cc");
1027 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1028 return oldval;
1029 }
1030
1031 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1032 +{
1033 + unsigned long oldval, res;
1034 +
1035 + smp_mb();
1036 +
1037 + do {
1038 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1039 + "ldrex %1, [%3]\n"
1040 + "mov %0, #0\n"
1041 + "teq %1, %4\n"
1042 + "strexeq %0, %5, [%3]\n"
1043 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1044 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1045 + : "cc");
1046 + } while (res);
1047 +
1048 + smp_mb();
1049 +
1050 + return oldval;
1051 +}
1052 +
1053 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1054 {
1055 unsigned long tmp, tmp2;
1056 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1057
1058 return val;
1059 }
1060 +
1061 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1062 +{
1063 + return atomic_add_return(i, v);
1064 +}
1065 +
1066 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1067 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1068 +{
1069 + (void) atomic_add_return(i, v);
1070 +}
1071
1072 static inline int atomic_sub_return(int i, atomic_t *v)
1073 {
1074 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1075 return val;
1076 }
1077 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1078 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1079 +{
1080 + (void) atomic_sub_return(i, v);
1081 +}
1082
1083 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1084 {
1085 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1086 return ret;
1087 }
1088
1089 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1090 +{
1091 + return atomic_cmpxchg(v, old, new);
1092 +}
1093 +
1094 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1095 {
1096 unsigned long flags;
1097 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1098 #endif /* __LINUX_ARM_ARCH__ */
1099
1100 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1101 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1102 +{
1103 + return xchg(&v->counter, new);
1104 +}
1105
1106 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1107 {
1108 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1109 }
1110
1111 #define atomic_inc(v) atomic_add(1, v)
1112 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1113 +{
1114 + atomic_add_unchecked(1, v);
1115 +}
1116 #define atomic_dec(v) atomic_sub(1, v)
1117 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1118 +{
1119 + atomic_sub_unchecked(1, v);
1120 +}
1121
1122 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1123 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1124 +{
1125 + return atomic_add_return_unchecked(1, v) == 0;
1126 +}
1127 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1128 #define atomic_inc_return(v) (atomic_add_return(1, v))
1129 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1130 +{
1131 + return atomic_add_return_unchecked(1, v);
1132 +}
1133 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1134 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1135
1136 @@ -241,6 +428,14 @@ typedef struct {
1137 u64 __aligned(8) counter;
1138 } atomic64_t;
1139
1140 +#ifdef CONFIG_PAX_REFCOUNT
1141 +typedef struct {
1142 + u64 __aligned(8) counter;
1143 +} atomic64_unchecked_t;
1144 +#else
1145 +typedef atomic64_t atomic64_unchecked_t;
1146 +#endif
1147 +
1148 #define ATOMIC64_INIT(i) { (i) }
1149
1150 #ifdef CONFIG_ARM_LPAE
1151 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1152 return result;
1153 }
1154
1155 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1156 +{
1157 + u64 result;
1158 +
1159 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1160 +" ldrd %0, %H0, [%1]"
1161 + : "=&r" (result)
1162 + : "r" (&v->counter), "Qo" (v->counter)
1163 + );
1164 +
1165 + return result;
1166 +}
1167 +
1168 static inline void atomic64_set(atomic64_t *v, u64 i)
1169 {
1170 __asm__ __volatile__("@ atomic64_set\n"
1171 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1172 : "r" (&v->counter), "r" (i)
1173 );
1174 }
1175 +
1176 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1177 +{
1178 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1179 +" strd %2, %H2, [%1]"
1180 + : "=Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + );
1183 +}
1184 #else
1185 static inline u64 atomic64_read(const atomic64_t *v)
1186 {
1187 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1188 return result;
1189 }
1190
1191 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1192 +{
1193 + u64 result;
1194 +
1195 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1196 +" ldrexd %0, %H0, [%1]"
1197 + : "=&r" (result)
1198 + : "r" (&v->counter), "Qo" (v->counter)
1199 + );
1200 +
1201 + return result;
1202 +}
1203 +
1204 static inline void atomic64_set(atomic64_t *v, u64 i)
1205 {
1206 u64 tmp;
1207 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1208 : "r" (&v->counter), "r" (i)
1209 : "cc");
1210 }
1211 +
1212 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1213 +{
1214 + u64 tmp;
1215 +
1216 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1217 +"1: ldrexd %0, %H0, [%2]\n"
1218 +" strexd %0, %3, %H3, [%2]\n"
1219 +" teq %0, #0\n"
1220 +" bne 1b"
1221 + : "=&r" (tmp), "=Qo" (v->counter)
1222 + : "r" (&v->counter), "r" (i)
1223 + : "cc");
1224 +}
1225 +
1226 #endif
1227
1228 static inline void atomic64_add(u64 i, atomic64_t *v)
1229 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1230 __asm__ __volatile__("@ atomic64_add\n"
1231 "1: ldrexd %0, %H0, [%3]\n"
1232 " adds %0, %0, %4\n"
1233 +" adcs %H0, %H0, %H4\n"
1234 +
1235 +#ifdef CONFIG_PAX_REFCOUNT
1236 +" bvc 3f\n"
1237 +"2: bkpt 0xf103\n"
1238 +"3:\n"
1239 +#endif
1240 +
1241 +" strexd %1, %0, %H0, [%3]\n"
1242 +" teq %1, #0\n"
1243 +" bne 1b"
1244 +
1245 +#ifdef CONFIG_PAX_REFCOUNT
1246 +"\n4:\n"
1247 + _ASM_EXTABLE(2b, 4b)
1248 +#endif
1249 +
1250 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1251 + : "r" (&v->counter), "r" (i)
1252 + : "cc");
1253 +}
1254 +
1255 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1256 +{
1257 + u64 result;
1258 + unsigned long tmp;
1259 +
1260 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1261 +"1: ldrexd %0, %H0, [%3]\n"
1262 +" adds %0, %0, %4\n"
1263 " adc %H0, %H0, %H4\n"
1264 " strexd %1, %0, %H0, [%3]\n"
1265 " teq %1, #0\n"
1266 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1267
1268 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1269 {
1270 - u64 result;
1271 - unsigned long tmp;
1272 + u64 result, tmp;
1273
1274 smp_mb();
1275
1276 __asm__ __volatile__("@ atomic64_add_return\n"
1277 +"1: ldrexd %1, %H1, [%3]\n"
1278 +" adds %0, %1, %4\n"
1279 +" adcs %H0, %H1, %H4\n"
1280 +
1281 +#ifdef CONFIG_PAX_REFCOUNT
1282 +" bvc 3f\n"
1283 +" mov %0, %1\n"
1284 +" mov %H0, %H1\n"
1285 +"2: bkpt 0xf103\n"
1286 +"3:\n"
1287 +#endif
1288 +
1289 +" strexd %1, %0, %H0, [%3]\n"
1290 +" teq %1, #0\n"
1291 +" bne 1b"
1292 +
1293 +#ifdef CONFIG_PAX_REFCOUNT
1294 +"\n4:\n"
1295 + _ASM_EXTABLE(2b, 4b)
1296 +#endif
1297 +
1298 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1299 + : "r" (&v->counter), "r" (i)
1300 + : "cc");
1301 +
1302 + smp_mb();
1303 +
1304 + return result;
1305 +}
1306 +
1307 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1308 +{
1309 + u64 result;
1310 + unsigned long tmp;
1311 +
1312 + smp_mb();
1313 +
1314 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1315 "1: ldrexd %0, %H0, [%3]\n"
1316 " adds %0, %0, %4\n"
1317 " adc %H0, %H0, %H4\n"
1318 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1319 __asm__ __volatile__("@ atomic64_sub\n"
1320 "1: ldrexd %0, %H0, [%3]\n"
1321 " subs %0, %0, %4\n"
1322 +" sbcs %H0, %H0, %H4\n"
1323 +
1324 +#ifdef CONFIG_PAX_REFCOUNT
1325 +" bvc 3f\n"
1326 +"2: bkpt 0xf103\n"
1327 +"3:\n"
1328 +#endif
1329 +
1330 +" strexd %1, %0, %H0, [%3]\n"
1331 +" teq %1, #0\n"
1332 +" bne 1b"
1333 +
1334 +#ifdef CONFIG_PAX_REFCOUNT
1335 +"\n4:\n"
1336 + _ASM_EXTABLE(2b, 4b)
1337 +#endif
1338 +
1339 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1340 + : "r" (&v->counter), "r" (i)
1341 + : "cc");
1342 +}
1343 +
1344 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1345 +{
1346 + u64 result;
1347 + unsigned long tmp;
1348 +
1349 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1350 +"1: ldrexd %0, %H0, [%3]\n"
1351 +" subs %0, %0, %4\n"
1352 " sbc %H0, %H0, %H4\n"
1353 " strexd %1, %0, %H0, [%3]\n"
1354 " teq %1, #0\n"
1355 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1356
1357 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1358 {
1359 - u64 result;
1360 - unsigned long tmp;
1361 + u64 result, tmp;
1362
1363 smp_mb();
1364
1365 __asm__ __volatile__("@ atomic64_sub_return\n"
1366 -"1: ldrexd %0, %H0, [%3]\n"
1367 -" subs %0, %0, %4\n"
1368 -" sbc %H0, %H0, %H4\n"
1369 +"1: ldrexd %1, %H1, [%3]\n"
1370 +" subs %0, %1, %4\n"
1371 +" sbcs %H0, %H1, %H4\n"
1372 +
1373 +#ifdef CONFIG_PAX_REFCOUNT
1374 +" bvc 3f\n"
1375 +" mov %0, %1\n"
1376 +" mov %H0, %H1\n"
1377 +"2: bkpt 0xf103\n"
1378 +"3:\n"
1379 +#endif
1380 +
1381 " strexd %1, %0, %H0, [%3]\n"
1382 " teq %1, #0\n"
1383 " bne 1b"
1384 +
1385 +#ifdef CONFIG_PAX_REFCOUNT
1386 +"\n4:\n"
1387 + _ASM_EXTABLE(2b, 4b)
1388 +#endif
1389 +
1390 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1391 : "r" (&v->counter), "r" (i)
1392 : "cc");
1393 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1394 return oldval;
1395 }
1396
1397 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1398 +{
1399 + u64 oldval;
1400 + unsigned long res;
1401 +
1402 + smp_mb();
1403 +
1404 + do {
1405 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1406 + "ldrexd %1, %H1, [%3]\n"
1407 + "mov %0, #0\n"
1408 + "teq %1, %4\n"
1409 + "teqeq %H1, %H4\n"
1410 + "strexdeq %0, %5, %H5, [%3]"
1411 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1412 + : "r" (&ptr->counter), "r" (old), "r" (new)
1413 + : "cc");
1414 + } while (res);
1415 +
1416 + smp_mb();
1417 +
1418 + return oldval;
1419 +}
1420 +
1421 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1422 {
1423 u64 result;
1424 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1425
1426 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1427 {
1428 - u64 result;
1429 - unsigned long tmp;
1430 + u64 result, tmp;
1431
1432 smp_mb();
1433
1434 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1435 -"1: ldrexd %0, %H0, [%3]\n"
1436 -" subs %0, %0, #1\n"
1437 -" sbc %H0, %H0, #0\n"
1438 +"1: ldrexd %1, %H1, [%3]\n"
1439 +" subs %0, %1, #1\n"
1440 +" sbcs %H0, %H1, #0\n"
1441 +
1442 +#ifdef CONFIG_PAX_REFCOUNT
1443 +" bvc 3f\n"
1444 +" mov %0, %1\n"
1445 +" mov %H0, %H1\n"
1446 +"2: bkpt 0xf103\n"
1447 +"3:\n"
1448 +#endif
1449 +
1450 " teq %H0, #0\n"
1451 -" bmi 2f\n"
1452 +" bmi 4f\n"
1453 " strexd %1, %0, %H0, [%3]\n"
1454 " teq %1, #0\n"
1455 " bne 1b\n"
1456 -"2:"
1457 +"4:\n"
1458 +
1459 +#ifdef CONFIG_PAX_REFCOUNT
1460 + _ASM_EXTABLE(2b, 4b)
1461 +#endif
1462 +
1463 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1464 : "r" (&v->counter)
1465 : "cc");
1466 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1467 " teq %0, %5\n"
1468 " teqeq %H0, %H5\n"
1469 " moveq %1, #0\n"
1470 -" beq 2f\n"
1471 +" beq 4f\n"
1472 " adds %0, %0, %6\n"
1473 -" adc %H0, %H0, %H6\n"
1474 +" adcs %H0, %H0, %H6\n"
1475 +
1476 +#ifdef CONFIG_PAX_REFCOUNT
1477 +" bvc 3f\n"
1478 +"2: bkpt 0xf103\n"
1479 +"3:\n"
1480 +#endif
1481 +
1482 " strexd %2, %0, %H0, [%4]\n"
1483 " teq %2, #0\n"
1484 " bne 1b\n"
1485 -"2:"
1486 +"4:\n"
1487 +
1488 +#ifdef CONFIG_PAX_REFCOUNT
1489 + _ASM_EXTABLE(2b, 4b)
1490 +#endif
1491 +
1492 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1493 : "r" (&v->counter), "r" (u), "r" (a)
1494 : "cc");
1495 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1496
1497 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1498 #define atomic64_inc(v) atomic64_add(1LL, (v))
1499 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1500 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1501 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1502 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1503 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1504 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1505 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1506 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1507 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1508 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1509 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1510 index 75fe66b..ba3dee4 100644
1511 --- a/arch/arm/include/asm/cache.h
1512 +++ b/arch/arm/include/asm/cache.h
1513 @@ -4,8 +4,10 @@
1514 #ifndef __ASMARM_CACHE_H
1515 #define __ASMARM_CACHE_H
1516
1517 +#include <linux/const.h>
1518 +
1519 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1520 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1521 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1522
1523 /*
1524 * Memory returned by kmalloc() may be used for DMA, so we must make
1525 @@ -24,5 +26,6 @@
1526 #endif
1527
1528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1529 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1530
1531 #endif
1532 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1533 index 17d0ae8..014e350 100644
1534 --- a/arch/arm/include/asm/cacheflush.h
1535 +++ b/arch/arm/include/asm/cacheflush.h
1536 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1537 void (*dma_unmap_area)(const void *, size_t, int);
1538
1539 void (*dma_flush_range)(const void *, const void *);
1540 -};
1541 +} __no_const;
1542
1543 /*
1544 * Select the calling method
1545 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1546 index 6dcc164..b14d917 100644
1547 --- a/arch/arm/include/asm/checksum.h
1548 +++ b/arch/arm/include/asm/checksum.h
1549 @@ -37,7 +37,19 @@ __wsum
1550 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1551
1552 __wsum
1553 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1554 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1555 +
1556 +static inline __wsum
1557 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1558 +{
1559 + __wsum ret;
1560 + pax_open_userland();
1561 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1562 + pax_close_userland();
1563 + return ret;
1564 +}
1565 +
1566 +
1567
1568 /*
1569 * Fold a partial checksum without adding pseudo headers
1570 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1571 index 4f009c1..466c59b 100644
1572 --- a/arch/arm/include/asm/cmpxchg.h
1573 +++ b/arch/arm/include/asm/cmpxchg.h
1574 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1575
1576 #define xchg(ptr,x) \
1577 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1578 +#define xchg_unchecked(ptr,x) \
1579 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1580
1581 #include <asm-generic/cmpxchg-local.h>
1582
1583 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1584 index 6ddbe44..b5e38b1 100644
1585 --- a/arch/arm/include/asm/domain.h
1586 +++ b/arch/arm/include/asm/domain.h
1587 @@ -48,18 +48,37 @@
1588 * Domain types
1589 */
1590 #define DOMAIN_NOACCESS 0
1591 -#define DOMAIN_CLIENT 1
1592 #ifdef CONFIG_CPU_USE_DOMAINS
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_KERNELCLIENT 1
1595 #define DOMAIN_MANAGER 3
1596 +#define DOMAIN_VECTORS DOMAIN_USER
1597 #else
1598 +
1599 +#ifdef CONFIG_PAX_KERNEXEC
1600 #define DOMAIN_MANAGER 1
1601 +#define DOMAIN_KERNEXEC 3
1602 +#else
1603 +#define DOMAIN_MANAGER 1
1604 +#endif
1605 +
1606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1607 +#define DOMAIN_USERCLIENT 0
1608 +#define DOMAIN_UDEREF 1
1609 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1610 +#else
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_VECTORS DOMAIN_USER
1613 +#endif
1614 +#define DOMAIN_KERNELCLIENT 1
1615 +
1616 #endif
1617
1618 #define domain_val(dom,type) ((type) << (2*(dom)))
1619
1620 #ifndef __ASSEMBLY__
1621
1622 -#ifdef CONFIG_CPU_USE_DOMAINS
1623 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1624 static inline void set_domain(unsigned val)
1625 {
1626 asm volatile(
1627 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1628 isb();
1629 }
1630
1631 -#define modify_domain(dom,type) \
1632 - do { \
1633 - struct thread_info *thread = current_thread_info(); \
1634 - unsigned int domain = thread->cpu_domain; \
1635 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1636 - thread->cpu_domain = domain | domain_val(dom, type); \
1637 - set_domain(thread->cpu_domain); \
1638 - } while (0)
1639 -
1640 +extern void modify_domain(unsigned int dom, unsigned int type);
1641 #else
1642 static inline void set_domain(unsigned val) { }
1643 static inline void modify_domain(unsigned dom, unsigned type) { }
1644 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1645 index 56211f2..17e8a25 100644
1646 --- a/arch/arm/include/asm/elf.h
1647 +++ b/arch/arm/include/asm/elf.h
1648 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1649 the loader. We need to make sure that it is out of the way of the program
1650 that it will "exec", and that there is sufficient room for the brk. */
1651
1652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1654 +
1655 +#ifdef CONFIG_PAX_ASLR
1656 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1657 +
1658 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1659 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1660 +#endif
1661
1662 /* When the program starts, a1 contains a pointer to a function to be
1663 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1664 @@ -126,10 +133,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1665 extern void elf_set_personality(const struct elf32_hdr *);
1666 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1667
1668 -struct mm_struct;
1669 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1670 -#define arch_randomize_brk arch_randomize_brk
1671 -
1672 #ifdef CONFIG_MMU
1673 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1674 struct linux_binprm;
1675 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1676 index de53547..52b9a28 100644
1677 --- a/arch/arm/include/asm/fncpy.h
1678 +++ b/arch/arm/include/asm/fncpy.h
1679 @@ -81,7 +81,9 @@
1680 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1681 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1682 \
1683 + pax_open_kernel(); \
1684 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1685 + pax_close_kernel(); \
1686 flush_icache_range((unsigned long)(dest_buf), \
1687 (unsigned long)(dest_buf) + (size)); \
1688 \
1689 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1690 index e42cf59..7b94b8f 100644
1691 --- a/arch/arm/include/asm/futex.h
1692 +++ b/arch/arm/include/asm/futex.h
1693 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1694 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1695 return -EFAULT;
1696
1697 + pax_open_userland();
1698 +
1699 smp_mb();
1700 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1701 "1: ldrex %1, [%4]\n"
1702 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1703 : "cc", "memory");
1704 smp_mb();
1705
1706 + pax_close_userland();
1707 +
1708 *uval = val;
1709 return ret;
1710 }
1711 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1718 "1: " TUSER(ldr) " %1, [%4]\n"
1719 " teq %1, %2\n"
1720 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1722 : "cc", "memory");
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1730 return -EFAULT;
1731
1732 pagefault_disable(); /* implies preempt_disable() */
1733 + pax_open_userland();
1734
1735 switch (op) {
1736 case FUTEX_OP_SET:
1737 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 ret = -ENOSYS;
1739 }
1740
1741 + pax_close_userland();
1742 pagefault_enable(); /* subsumes preempt_enable() */
1743
1744 if (!ret) {
1745 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1746 index 83eb2f7..ed77159 100644
1747 --- a/arch/arm/include/asm/kmap_types.h
1748 +++ b/arch/arm/include/asm/kmap_types.h
1749 @@ -4,6 +4,6 @@
1750 /*
1751 * This is the "bare minimum". AIO seems to require this.
1752 */
1753 -#define KM_TYPE_NR 16
1754 +#define KM_TYPE_NR 17
1755
1756 #endif
1757 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1758 index 9e614a1..3302cca 100644
1759 --- a/arch/arm/include/asm/mach/dma.h
1760 +++ b/arch/arm/include/asm/mach/dma.h
1761 @@ -22,7 +22,7 @@ struct dma_ops {
1762 int (*residue)(unsigned int, dma_t *); /* optional */
1763 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1764 const char *type;
1765 -};
1766 +} __do_const;
1767
1768 struct dma_struct {
1769 void *addr; /* single DMA address */
1770 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1771 index 2fe141f..192dc01 100644
1772 --- a/arch/arm/include/asm/mach/map.h
1773 +++ b/arch/arm/include/asm/mach/map.h
1774 @@ -27,13 +27,16 @@ struct map_desc {
1775 #define MT_MINICLEAN 6
1776 #define MT_LOW_VECTORS 7
1777 #define MT_HIGH_VECTORS 8
1778 -#define MT_MEMORY 9
1779 +#define MT_MEMORY_RWX 9
1780 #define MT_ROM 10
1781 -#define MT_MEMORY_NONCACHED 11
1782 +#define MT_MEMORY_NONCACHED_RX 11
1783 #define MT_MEMORY_DTCM 12
1784 #define MT_MEMORY_ITCM 13
1785 #define MT_MEMORY_SO 14
1786 #define MT_MEMORY_DMA_READY 15
1787 +#define MT_MEMORY_RW 16
1788 +#define MT_MEMORY_RX 17
1789 +#define MT_MEMORY_NONCACHED_RW 18
1790
1791 #ifdef CONFIG_MMU
1792 extern void iotable_init(struct map_desc *, int);
1793 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1794 index 12f71a1..04e063c 100644
1795 --- a/arch/arm/include/asm/outercache.h
1796 +++ b/arch/arm/include/asm/outercache.h
1797 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1798 #endif
1799 void (*set_debug)(unsigned long);
1800 void (*resume)(void);
1801 -};
1802 +} __no_const;
1803
1804 #ifdef CONFIG_OUTER_CACHE
1805
1806 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1807 index 4355f0e..c229913 100644
1808 --- a/arch/arm/include/asm/page.h
1809 +++ b/arch/arm/include/asm/page.h
1810 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1811 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1812 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1813 unsigned long vaddr, struct vm_area_struct *vma);
1814 -};
1815 +} __no_const;
1816
1817 #ifdef MULTI_USER
1818 extern struct cpu_user_fns cpu_user;
1819 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1820 index 943504f..c37a730 100644
1821 --- a/arch/arm/include/asm/pgalloc.h
1822 +++ b/arch/arm/include/asm/pgalloc.h
1823 @@ -17,6 +17,7 @@
1824 #include <asm/processor.h>
1825 #include <asm/cacheflush.h>
1826 #include <asm/tlbflush.h>
1827 +#include <asm/system_info.h>
1828
1829 #define check_pgt_cache() do { } while (0)
1830
1831 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1832 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1833 }
1834
1835 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1836 +{
1837 + pud_populate(mm, pud, pmd);
1838 +}
1839 +
1840 #else /* !CONFIG_ARM_LPAE */
1841
1842 /*
1843 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1845 #define pmd_free(mm, pmd) do { } while (0)
1846 #define pud_populate(mm,pmd,pte) BUG()
1847 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1848
1849 #endif /* CONFIG_ARM_LPAE */
1850
1851 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1852 __free_page(pte);
1853 }
1854
1855 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1856 +{
1857 +#ifdef CONFIG_ARM_LPAE
1858 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1859 +#else
1860 + if (addr & SECTION_SIZE)
1861 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1862 + else
1863 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1864 +#endif
1865 + flush_pmd_entry(pmdp);
1866 +}
1867 +
1868 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1869 pmdval_t prot)
1870 {
1871 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1872 static inline void
1873 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1874 {
1875 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1876 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1877 }
1878 #define pmd_pgtable(pmd) pmd_page(pmd)
1879
1880 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1881 index 5cfba15..f415e1a 100644
1882 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1883 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 @@ -20,12 +20,15 @@
1885 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1886 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1887 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1888 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1889 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1890 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1891 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1892 +
1893 /*
1894 * - section
1895 */
1896 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1897 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1898 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1899 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1900 @@ -37,6 +40,7 @@
1901 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1902 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1903 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1904 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1905
1906 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1907 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1908 @@ -66,6 +70,7 @@
1909 * - extended small page/tiny page
1910 */
1911 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1912 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1913 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1914 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1915 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1916 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1917 index f97ee02..cc9fe9e 100644
1918 --- a/arch/arm/include/asm/pgtable-2level.h
1919 +++ b/arch/arm/include/asm/pgtable-2level.h
1920 @@ -126,6 +126,9 @@
1921 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1922 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1923
1924 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1925 +#define L_PTE_PXN (_AT(pteval_t, 0))
1926 +
1927 /*
1928 * These are the memory types, defined to be compatible with
1929 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1930 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1931 index 626989f..9d67a33 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -75,6 +75,7 @@
1935 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1936 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1937 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1938 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1939 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1940
1941 /*
1942 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1943 index 5689c18..eea12f9 100644
1944 --- a/arch/arm/include/asm/pgtable-3level.h
1945 +++ b/arch/arm/include/asm/pgtable-3level.h
1946 @@ -82,6 +82,7 @@
1947 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1948 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1949 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1950 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1951 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1952 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1953 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1954 @@ -95,6 +96,7 @@
1955 /*
1956 * To be used in assembly code with the upper page attributes.
1957 */
1958 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1959 #define L_PTE_XN_HIGH (1 << (54 - 32))
1960 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1961
1962 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1963 index 04aeb02..73b70dd 100644
1964 --- a/arch/arm/include/asm/pgtable.h
1965 +++ b/arch/arm/include/asm/pgtable.h
1966 @@ -33,6 +33,9 @@
1967 #include <asm/pgtable-2level.h>
1968 #endif
1969
1970 +#define ktla_ktva(addr) (addr)
1971 +#define ktva_ktla(addr) (addr)
1972 +
1973 /*
1974 * Just any arbitrary offset to the start of the vmalloc VM area: the
1975 * current 8MB value just means that there will be a 8MB "hole" after the
1976 @@ -48,6 +51,9 @@
1977 #define LIBRARY_TEXT_START 0x0c000000
1978
1979 #ifndef __ASSEMBLY__
1980 +extern pteval_t __supported_pte_mask;
1981 +extern pmdval_t __supported_pmd_mask;
1982 +
1983 extern void __pte_error(const char *file, int line, pte_t);
1984 extern void __pmd_error(const char *file, int line, pmd_t);
1985 extern void __pgd_error(const char *file, int line, pgd_t);
1986 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1987 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1988 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1989
1990 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1991 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1992 +
1993 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1994 +#include <asm/domain.h>
1995 +#include <linux/thread_info.h>
1996 +#include <linux/preempt.h>
1997 +
1998 +static inline int test_domain(int domain, int domaintype)
1999 +{
2000 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2001 +}
2002 +#endif
2003 +
2004 +#ifdef CONFIG_PAX_KERNEXEC
2005 +static inline unsigned long pax_open_kernel(void) {
2006 +#ifdef CONFIG_ARM_LPAE
2007 + /* TODO */
2008 +#else
2009 + preempt_disable();
2010 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2011 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2012 +#endif
2013 + return 0;
2014 +}
2015 +
2016 +static inline unsigned long pax_close_kernel(void) {
2017 +#ifdef CONFIG_ARM_LPAE
2018 + /* TODO */
2019 +#else
2020 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2021 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2022 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2023 + preempt_enable_no_resched();
2024 +#endif
2025 + return 0;
2026 +}
2027 +#else
2028 +static inline unsigned long pax_open_kernel(void) { return 0; }
2029 +static inline unsigned long pax_close_kernel(void) { return 0; }
2030 +#endif
2031 +
2032 /*
2033 * This is the lowest virtual address we can permit any user space
2034 * mapping to be mapped at. This is particularly important for
2035 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2036 /*
2037 * The pgprot_* and protection_map entries will be fixed up in runtime
2038 * to include the cachable and bufferable bits based on memory policy,
2039 - * as well as any architecture dependent bits like global/ASID and SMP
2040 - * shared mapping bits.
2041 + * as well as any architecture dependent bits like global/ASID, PXN,
2042 + * and SMP shared mapping bits.
2043 */
2044 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2045
2046 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2047 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2048 {
2049 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2050 - L_PTE_NONE | L_PTE_VALID;
2051 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2052 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2053 return pte;
2054 }
2055 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2056 index 5324c11..bcae5f0 100644
2057 --- a/arch/arm/include/asm/proc-fns.h
2058 +++ b/arch/arm/include/asm/proc-fns.h
2059 @@ -75,7 +75,7 @@ extern struct processor {
2060 unsigned int suspend_size;
2061 void (*do_suspend)(void *);
2062 void (*do_resume)(void *);
2063 -} processor;
2064 +} __do_const processor;
2065
2066 #ifndef MULTI_CPU
2067 extern void cpu_proc_init(void);
2068 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2069 index c4ae171..ea0c0c2 100644
2070 --- a/arch/arm/include/asm/psci.h
2071 +++ b/arch/arm/include/asm/psci.h
2072 @@ -29,7 +29,7 @@ struct psci_operations {
2073 int (*cpu_off)(struct psci_power_state state);
2074 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2075 int (*migrate)(unsigned long cpuid);
2076 -};
2077 +} __no_const;
2078
2079 extern struct psci_operations psci_ops;
2080 extern struct smp_operations psci_smp_ops;
2081 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2082 index a8cae71c..65dd797 100644
2083 --- a/arch/arm/include/asm/smp.h
2084 +++ b/arch/arm/include/asm/smp.h
2085 @@ -110,7 +110,7 @@ struct smp_operations {
2086 int (*cpu_disable)(unsigned int cpu);
2087 #endif
2088 #endif
2089 -};
2090 +} __no_const;
2091
2092 /*
2093 * set platform specific SMP operations
2094 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2095 index 2b8114f..8fe9bcf 100644
2096 --- a/arch/arm/include/asm/thread_info.h
2097 +++ b/arch/arm/include/asm/thread_info.h
2098 @@ -77,9 +77,9 @@ struct thread_info {
2099 .flags = 0, \
2100 .preempt_count = INIT_PREEMPT_COUNT, \
2101 .addr_limit = KERNEL_DS, \
2102 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2103 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2104 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2105 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2106 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2107 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2108 .restart_block = { \
2109 .fn = do_no_restart_syscall, \
2110 }, \
2111 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2112 #define TIF_SYSCALL_AUDIT 9
2113 #define TIF_SYSCALL_TRACEPOINT 10
2114 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2115 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2116 +/* within 8 bits of TIF_SYSCALL_TRACE
2117 + * to meet flexible second operand requirements
2118 + */
2119 +#define TIF_GRSEC_SETXID 12
2120 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2121 #define TIF_USING_IWMMXT 17
2122 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2123 #define TIF_RESTORE_SIGMASK 20
2124 @@ -165,10 +169,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2125 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2126 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2127 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2128 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2129
2130 /* Checks for any syscall work in entry-common.S */
2131 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2132 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2133 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2134
2135 /*
2136 * Change these and you break ASM code in entry-common.S
2137 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2138 index 7e1f760..de33b13 100644
2139 --- a/arch/arm/include/asm/uaccess.h
2140 +++ b/arch/arm/include/asm/uaccess.h
2141 @@ -18,6 +18,7 @@
2142 #include <asm/domain.h>
2143 #include <asm/unified.h>
2144 #include <asm/compiler.h>
2145 +#include <asm/pgtable.h>
2146
2147 #define VERIFY_READ 0
2148 #define VERIFY_WRITE 1
2149 @@ -63,11 +64,38 @@ extern int __put_user_bad(void);
2150 static inline void set_fs(mm_segment_t fs)
2151 {
2152 current_thread_info()->addr_limit = fs;
2153 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2154 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2155 }
2156
2157 #define segment_eq(a,b) ((a) == (b))
2158
2159 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2160 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2161 +
2162 +static inline void pax_open_userland(void)
2163 +{
2164 +
2165 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2166 + if (segment_eq(get_fs(), USER_DS)) {
2167 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2168 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2169 + }
2170 +#endif
2171 +
2172 +}
2173 +
2174 +static inline void pax_close_userland(void)
2175 +{
2176 +
2177 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2178 + if (segment_eq(get_fs(), USER_DS)) {
2179 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2180 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2181 + }
2182 +#endif
2183 +
2184 +}
2185 +
2186 #define __addr_ok(addr) ({ \
2187 unsigned long flag; \
2188 __asm__("cmp %2, %0; movlo %0, #0" \
2189 @@ -143,8 +171,12 @@ extern int __get_user_4(void *);
2190
2191 #define get_user(x,p) \
2192 ({ \
2193 + int __e; \
2194 might_fault(); \
2195 - __get_user_check(x,p); \
2196 + pax_open_userland(); \
2197 + __e = __get_user_check(x,p); \
2198 + pax_close_userland(); \
2199 + __e; \
2200 })
2201
2202 extern int __put_user_1(void *, unsigned int);
2203 @@ -188,8 +220,12 @@ extern int __put_user_8(void *, unsigned long long);
2204
2205 #define put_user(x,p) \
2206 ({ \
2207 + int __e; \
2208 might_fault(); \
2209 - __put_user_check(x,p); \
2210 + pax_open_userland(); \
2211 + __e = __put_user_check(x,p); \
2212 + pax_close_userland(); \
2213 + __e; \
2214 })
2215
2216 #else /* CONFIG_MMU */
2217 @@ -230,13 +266,17 @@ static inline void set_fs(mm_segment_t fs)
2218 #define __get_user(x,ptr) \
2219 ({ \
2220 long __gu_err = 0; \
2221 + pax_open_userland(); \
2222 __get_user_err((x),(ptr),__gu_err); \
2223 + pax_close_userland(); \
2224 __gu_err; \
2225 })
2226
2227 #define __get_user_error(x,ptr,err) \
2228 ({ \
2229 + pax_open_userland(); \
2230 __get_user_err((x),(ptr),err); \
2231 + pax_close_userland(); \
2232 (void) 0; \
2233 })
2234
2235 @@ -312,13 +352,17 @@ do { \
2236 #define __put_user(x,ptr) \
2237 ({ \
2238 long __pu_err = 0; \
2239 + pax_open_userland(); \
2240 __put_user_err((x),(ptr),__pu_err); \
2241 + pax_close_userland(); \
2242 __pu_err; \
2243 })
2244
2245 #define __put_user_error(x,ptr,err) \
2246 ({ \
2247 + pax_open_userland(); \
2248 __put_user_err((x),(ptr),err); \
2249 + pax_close_userland(); \
2250 (void) 0; \
2251 })
2252
2253 @@ -418,11 +462,44 @@ do { \
2254
2255
2256 #ifdef CONFIG_MMU
2257 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2258 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2259 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2260 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2261 +
2262 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2263 +{
2264 + unsigned long ret;
2265 +
2266 + check_object_size(to, n, false);
2267 + pax_open_userland();
2268 + ret = ___copy_from_user(to, from, n);
2269 + pax_close_userland();
2270 + return ret;
2271 +}
2272 +
2273 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2274 +{
2275 + unsigned long ret;
2276 +
2277 + check_object_size(from, n, true);
2278 + pax_open_userland();
2279 + ret = ___copy_to_user(to, from, n);
2280 + pax_close_userland();
2281 + return ret;
2282 +}
2283 +
2284 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2285 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2286 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2287 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2288 +
2289 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2290 +{
2291 + unsigned long ret;
2292 + pax_open_userland();
2293 + ret = ___clear_user(addr, n);
2294 + pax_close_userland();
2295 + return ret;
2296 +}
2297 +
2298 #else
2299 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2300 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2301 @@ -431,6 +508,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2302
2303 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2304 {
2305 + if ((long)n < 0)
2306 + return n;
2307 +
2308 if (access_ok(VERIFY_READ, from, n))
2309 n = __copy_from_user(to, from, n);
2310 else /* security hole - plug it */
2311 @@ -440,6 +520,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2312
2313 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2314 {
2315 + if ((long)n < 0)
2316 + return n;
2317 +
2318 if (access_ok(VERIFY_WRITE, to, n))
2319 n = __copy_to_user(to, from, n);
2320 return n;
2321 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2322 index 5af0ed1..cea83883 100644
2323 --- a/arch/arm/include/uapi/asm/ptrace.h
2324 +++ b/arch/arm/include/uapi/asm/ptrace.h
2325 @@ -92,7 +92,7 @@
2326 * ARMv7 groups of PSR bits
2327 */
2328 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2329 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2330 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2331 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2332 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2333
2334 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2335 index 60d3b73..e5a0f22 100644
2336 --- a/arch/arm/kernel/armksyms.c
2337 +++ b/arch/arm/kernel/armksyms.c
2338 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2339
2340 /* networking */
2341 EXPORT_SYMBOL(csum_partial);
2342 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2343 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2344 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2345 EXPORT_SYMBOL(__csum_ipv6_magic);
2346
2347 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2348 #ifdef CONFIG_MMU
2349 EXPORT_SYMBOL(copy_page);
2350
2351 -EXPORT_SYMBOL(__copy_from_user);
2352 -EXPORT_SYMBOL(__copy_to_user);
2353 -EXPORT_SYMBOL(__clear_user);
2354 +EXPORT_SYMBOL(___copy_from_user);
2355 +EXPORT_SYMBOL(___copy_to_user);
2356 +EXPORT_SYMBOL(___clear_user);
2357
2358 EXPORT_SYMBOL(__get_user_1);
2359 EXPORT_SYMBOL(__get_user_2);
2360 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2361 index 9cbe70c..a7b5e34 100644
2362 --- a/arch/arm/kernel/entry-armv.S
2363 +++ b/arch/arm/kernel/entry-armv.S
2364 @@ -47,6 +47,87 @@
2365 9997:
2366 .endm
2367
2368 + .macro pax_enter_kernel
2369 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2370 + @ make aligned space for saved DACR
2371 + sub sp, sp, #8
2372 + @ save regs
2373 + stmdb sp!, {r1, r2}
2374 + @ read DACR from cpu_domain into r1
2375 + mov r2, sp
2376 + @ assume 8K pages, since we have to split the immediate in two
2377 + bic r2, r2, #(0x1fc0)
2378 + bic r2, r2, #(0x3f)
2379 + ldr r1, [r2, #TI_CPU_DOMAIN]
2380 + @ store old DACR on stack
2381 + str r1, [sp, #8]
2382 +#ifdef CONFIG_PAX_KERNEXEC
2383 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2384 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2385 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2386 +#endif
2387 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2388 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2389 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2390 +#endif
2391 + @ write r1 to current_thread_info()->cpu_domain
2392 + str r1, [r2, #TI_CPU_DOMAIN]
2393 + @ write r1 to DACR
2394 + mcr p15, 0, r1, c3, c0, 0
2395 + @ instruction sync
2396 + instr_sync
2397 + @ restore regs
2398 + ldmia sp!, {r1, r2}
2399 +#endif
2400 + .endm
2401 +
2402 + .macro pax_open_userland
2403 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2404 + @ save regs
2405 + stmdb sp!, {r0, r1}
2406 + @ read DACR from cpu_domain into r1
2407 + mov r0, sp
2408 + @ assume 8K pages, since we have to split the immediate in two
2409 + bic r0, r0, #(0x1fc0)
2410 + bic r0, r0, #(0x3f)
2411 + ldr r1, [r0, #TI_CPU_DOMAIN]
2412 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2413 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2414 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2415 + @ write r1 to current_thread_info()->cpu_domain
2416 + str r1, [r0, #TI_CPU_DOMAIN]
2417 + @ write r1 to DACR
2418 + mcr p15, 0, r1, c3, c0, 0
2419 + @ instruction sync
2420 + instr_sync
2421 + @ restore regs
2422 + ldmia sp!, {r0, r1}
2423 +#endif
2424 + .endm
2425 +
2426 + .macro pax_close_userland
2427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2428 + @ save regs
2429 + stmdb sp!, {r0, r1}
2430 + @ read DACR from cpu_domain into r1
2431 + mov r0, sp
2432 + @ assume 8K pages, since we have to split the immediate in two
2433 + bic r0, r0, #(0x1fc0)
2434 + bic r0, r0, #(0x3f)
2435 + ldr r1, [r0, #TI_CPU_DOMAIN]
2436 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2437 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2438 + @ write r1 to current_thread_info()->cpu_domain
2439 + str r1, [r0, #TI_CPU_DOMAIN]
2440 + @ write r1 to DACR
2441 + mcr p15, 0, r1, c3, c0, 0
2442 + @ instruction sync
2443 + instr_sync
2444 + @ restore regs
2445 + ldmia sp!, {r0, r1}
2446 +#endif
2447 + .endm
2448 +
2449 .macro pabt_helper
2450 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2451 #ifdef MULTI_PABORT
2452 @@ -89,11 +170,15 @@
2453 * Invalid mode handlers
2454 */
2455 .macro inv_entry, reason
2456 +
2457 + pax_enter_kernel
2458 +
2459 sub sp, sp, #S_FRAME_SIZE
2460 ARM( stmib sp, {r1 - lr} )
2461 THUMB( stmia sp, {r0 - r12} )
2462 THUMB( str sp, [sp, #S_SP] )
2463 THUMB( str lr, [sp, #S_LR] )
2464 +
2465 mov r1, #\reason
2466 .endm
2467
2468 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2469 .macro svc_entry, stack_hole=0
2470 UNWIND(.fnstart )
2471 UNWIND(.save {r0 - pc} )
2472 +
2473 + pax_enter_kernel
2474 +
2475 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2476 +
2477 #ifdef CONFIG_THUMB2_KERNEL
2478 SPFIX( str r0, [sp] ) @ temporarily saved
2479 SPFIX( mov r0, sp )
2480 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2481 ldmia r0, {r3 - r5}
2482 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2483 mov r6, #-1 @ "" "" "" ""
2484 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2485 + @ offset sp by 8 as done in pax_enter_kernel
2486 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2487 +#else
2488 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2489 +#endif
2490 SPFIX( addeq r2, r2, #4 )
2491 str r3, [sp, #-4]! @ save the "real" r0 copied
2492 @ from the exception stack
2493 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2494 .macro usr_entry
2495 UNWIND(.fnstart )
2496 UNWIND(.cantunwind ) @ don't unwind the user space
2497 +
2498 + pax_enter_kernel_user
2499 +
2500 sub sp, sp, #S_FRAME_SIZE
2501 ARM( stmib sp, {r1 - r12} )
2502 THUMB( stmia sp, {r0 - r12} )
2503 @@ -415,7 +512,9 @@ __und_usr:
2504 tst r3, #PSR_T_BIT @ Thumb mode?
2505 bne __und_usr_thumb
2506 sub r4, r2, #4 @ ARM instr at LR - 4
2507 + pax_open_userland
2508 1: ldrt r0, [r4]
2509 + pax_close_userland
2510 #ifdef CONFIG_CPU_ENDIAN_BE8
2511 rev r0, r0 @ little endian instruction
2512 #endif
2513 @@ -450,10 +549,14 @@ __und_usr_thumb:
2514 */
2515 .arch armv6t2
2516 #endif
2517 + pax_open_userland
2518 2: ldrht r5, [r4]
2519 + pax_close_userland
2520 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2521 blo __und_usr_fault_16 @ 16bit undefined instruction
2522 + pax_open_userland
2523 3: ldrht r0, [r2]
2524 + pax_close_userland
2525 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2526 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2527 orr r0, r0, r5, lsl #16
2528 @@ -482,7 +585,8 @@ ENDPROC(__und_usr)
2529 */
2530 .pushsection .fixup, "ax"
2531 .align 2
2532 -4: mov pc, r9
2533 +4: pax_close_userland
2534 + mov pc, r9
2535 .popsection
2536 .pushsection __ex_table,"a"
2537 .long 1b, 4b
2538 @@ -692,7 +796,7 @@ ENTRY(__switch_to)
2539 THUMB( str lr, [ip], #4 )
2540 ldr r4, [r2, #TI_TP_VALUE]
2541 ldr r5, [r2, #TI_TP_VALUE + 4]
2542 -#ifdef CONFIG_CPU_USE_DOMAINS
2543 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 ldr r6, [r2, #TI_CPU_DOMAIN]
2545 #endif
2546 switch_tls r1, r4, r5, r3, r7
2547 @@ -701,7 +805,7 @@ ENTRY(__switch_to)
2548 ldr r8, =__stack_chk_guard
2549 ldr r7, [r7, #TSK_STACK_CANARY]
2550 #endif
2551 -#ifdef CONFIG_CPU_USE_DOMAINS
2552 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2553 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2554 #endif
2555 mov r5, r0
2556 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2557 index 94104bf..e425391 100644
2558 --- a/arch/arm/kernel/entry-common.S
2559 +++ b/arch/arm/kernel/entry-common.S
2560 @@ -10,18 +10,46 @@
2561
2562 #include <asm/unistd.h>
2563 #include <asm/ftrace.h>
2564 +#include <asm/domain.h>
2565 #include <asm/unwind.h>
2566
2567 +#include "entry-header.S"
2568 +
2569 #ifdef CONFIG_NEED_RET_TO_USER
2570 #include <mach/entry-macro.S>
2571 #else
2572 .macro arch_ret_to_user, tmp1, tmp2
2573 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2574 + @ save regs
2575 + stmdb sp!, {r1, r2}
2576 + @ read DACR from cpu_domain into r1
2577 + mov r2, sp
2578 + @ assume 8K pages, since we have to split the immediate in two
2579 + bic r2, r2, #(0x1fc0)
2580 + bic r2, r2, #(0x3f)
2581 + ldr r1, [r2, #TI_CPU_DOMAIN]
2582 +#ifdef CONFIG_PAX_KERNEXEC
2583 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2584 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2585 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2586 +#endif
2587 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2588 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2589 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2590 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2591 +#endif
2592 + @ write r1 to current_thread_info()->cpu_domain
2593 + str r1, [r2, #TI_CPU_DOMAIN]
2594 + @ write r1 to DACR
2595 + mcr p15, 0, r1, c3, c0, 0
2596 + @ instruction sync
2597 + instr_sync
2598 + @ restore regs
2599 + ldmia sp!, {r1, r2}
2600 +#endif
2601 .endm
2602 #endif
2603
2604 -#include "entry-header.S"
2605 -
2606 -
2607 .align 5
2608 /*
2609 * This is the fast syscall return path. We do as little as
2610 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2611 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2612 #endif
2613
2614 + /*
2615 + * do this here to avoid a performance hit of wrapping the code above
2616 + * that directly dereferences userland to parse the SWI instruction
2617 + */
2618 + pax_enter_kernel_user
2619 +
2620 adr tbl, sys_call_table @ load syscall table pointer
2621
2622 #if defined(CONFIG_OABI_COMPAT)
2623 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2624 index de23a9b..94c37c4 100644
2625 --- a/arch/arm/kernel/entry-header.S
2626 +++ b/arch/arm/kernel/entry-header.S
2627 @@ -184,6 +184,60 @@
2628 msr cpsr_c, \rtemp @ switch back to the SVC mode
2629 .endm
2630
2631 + .macro pax_enter_kernel_user
2632 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2633 + @ save regs
2634 + stmdb sp!, {r0, r1}
2635 + @ read DACR from cpu_domain into r1
2636 + mov r0, sp
2637 + @ assume 8K pages, since we have to split the immediate in two
2638 + bic r0, r0, #(0x1fc0)
2639 + bic r0, r0, #(0x3f)
2640 + ldr r1, [r0, #TI_CPU_DOMAIN]
2641 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2642 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2643 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2644 +#endif
2645 +#ifdef CONFIG_PAX_KERNEXEC
2646 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2647 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2648 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2649 +#endif
2650 + @ write r1 to current_thread_info()->cpu_domain
2651 + str r1, [r0, #TI_CPU_DOMAIN]
2652 + @ write r1 to DACR
2653 + mcr p15, 0, r1, c3, c0, 0
2654 + @ instruction sync
2655 + instr_sync
2656 + @ restore regs
2657 + ldmia sp!, {r0, r1}
2658 +#endif
2659 + .endm
2660 +
2661 + .macro pax_exit_kernel
2662 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2663 + @ save regs
2664 + stmdb sp!, {r0, r1}
2665 + @ read old DACR from stack into r1
2666 + ldr r1, [sp, #(8 + S_SP)]
2667 + sub r1, r1, #8
2668 + ldr r1, [r1]
2669 +
2670 + @ write r1 to current_thread_info()->cpu_domain
2671 + mov r0, sp
2672 + @ assume 8K pages, since we have to split the immediate in two
2673 + bic r0, r0, #(0x1fc0)
2674 + bic r0, r0, #(0x3f)
2675 + str r1, [r0, #TI_CPU_DOMAIN]
2676 + @ write r1 to DACR
2677 + mcr p15, 0, r1, c3, c0, 0
2678 + @ instruction sync
2679 + instr_sync
2680 + @ restore regs
2681 + ldmia sp!, {r0, r1}
2682 +#endif
2683 + .endm
2684 +
2685 #ifndef CONFIG_THUMB2_KERNEL
2686 .macro svc_exit, rpsr, irq = 0
2687 .if \irq != 0
2688 @@ -203,6 +257,9 @@
2689 blne trace_hardirqs_off
2690 #endif
2691 .endif
2692 +
2693 + pax_exit_kernel
2694 +
2695 msr spsr_cxsf, \rpsr
2696 #if defined(CONFIG_CPU_V6)
2697 ldr r0, [sp]
2698 @@ -266,6 +323,9 @@
2699 blne trace_hardirqs_off
2700 #endif
2701 .endif
2702 +
2703 + pax_exit_kernel
2704 +
2705 ldr lr, [sp, #S_SP] @ top of the stack
2706 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2707 clrex @ clear the exclusive monitor
2708 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2709 index 918875d..cd5fa27 100644
2710 --- a/arch/arm/kernel/fiq.c
2711 +++ b/arch/arm/kernel/fiq.c
2712 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2713 void *base = vectors_page;
2714 unsigned offset = FIQ_OFFSET;
2715
2716 + pax_open_kernel();
2717 memcpy(base + offset, start, length);
2718 + pax_close_kernel();
2719 +
2720 if (!cache_is_vipt_nonaliasing())
2721 flush_icache_range((unsigned long)base + offset, offset +
2722 length);
2723 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2724 index 2c7cc1e..ab2e911 100644
2725 --- a/arch/arm/kernel/head.S
2726 +++ b/arch/arm/kernel/head.S
2727 @@ -52,7 +52,9 @@
2728 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2729
2730 .macro pgtbl, rd, phys
2731 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2732 + mov \rd, #TEXT_OFFSET
2733 + sub \rd, #PG_DIR_SIZE
2734 + add \rd, \rd, \phys
2735 .endm
2736
2737 /*
2738 @@ -432,7 +434,7 @@ __enable_mmu:
2739 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2740 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2741 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2742 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2743 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2744 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2745 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2746 #endif
2747 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2748 index 85c3fb6..054c2dc 100644
2749 --- a/arch/arm/kernel/module.c
2750 +++ b/arch/arm/kernel/module.c
2751 @@ -37,12 +37,39 @@
2752 #endif
2753
2754 #ifdef CONFIG_MMU
2755 -void *module_alloc(unsigned long size)
2756 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2757 {
2758 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2759 + return NULL;
2760 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2761 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2762 + GFP_KERNEL, prot, -1,
2763 __builtin_return_address(0));
2764 }
2765 +
2766 +void *module_alloc(unsigned long size)
2767 +{
2768 +
2769 +#ifdef CONFIG_PAX_KERNEXEC
2770 + return __module_alloc(size, PAGE_KERNEL);
2771 +#else
2772 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2773 +#endif
2774 +
2775 +}
2776 +
2777 +#ifdef CONFIG_PAX_KERNEXEC
2778 +void module_free_exec(struct module *mod, void *module_region)
2779 +{
2780 + module_free(mod, module_region);
2781 +}
2782 +EXPORT_SYMBOL(module_free_exec);
2783 +
2784 +void *module_alloc_exec(unsigned long size)
2785 +{
2786 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2787 +}
2788 +EXPORT_SYMBOL(module_alloc_exec);
2789 +#endif
2790 #endif
2791
2792 int
2793 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2794 index 07314af..c46655c 100644
2795 --- a/arch/arm/kernel/patch.c
2796 +++ b/arch/arm/kernel/patch.c
2797 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2798 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2799 int size;
2800
2801 + pax_open_kernel();
2802 if (thumb2 && __opcode_is_thumb16(insn)) {
2803 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2804 size = sizeof(u16);
2805 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2806 *(u32 *)addr = insn;
2807 size = sizeof(u32);
2808 }
2809 + pax_close_kernel();
2810
2811 flush_icache_range((uintptr_t)(addr),
2812 (uintptr_t)(addr) + size);
2813 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2814 index 94f6b05..efd7312 100644
2815 --- a/arch/arm/kernel/process.c
2816 +++ b/arch/arm/kernel/process.c
2817 @@ -217,6 +217,7 @@ void machine_power_off(void)
2818
2819 if (pm_power_off)
2820 pm_power_off();
2821 + BUG();
2822 }
2823
2824 /*
2825 @@ -230,7 +231,7 @@ void machine_power_off(void)
2826 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2827 * to use. Implementing such co-ordination would be essentially impossible.
2828 */
2829 -void machine_restart(char *cmd)
2830 +__noreturn void machine_restart(char *cmd)
2831 {
2832 local_irq_disable();
2833 smp_send_stop();
2834 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2835
2836 show_regs_print_info(KERN_DEFAULT);
2837
2838 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2839 - print_symbol("LR is at %s\n", regs->ARM_lr);
2840 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2841 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2842 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2843 "sp : %08lx ip : %08lx fp : %08lx\n",
2844 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2845 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2846 return 0;
2847 }
2848
2849 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2850 -{
2851 - unsigned long range_end = mm->brk + 0x02000000;
2852 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2853 -}
2854 -
2855 #ifdef CONFIG_MMU
2856 #ifdef CONFIG_KUSER_HELPERS
2857 /*
2858 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2859
2860 static int __init gate_vma_init(void)
2861 {
2862 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2863 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2864 return 0;
2865 }
2866 arch_initcall(gate_vma_init);
2867 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2868
2869 const char *arch_vma_name(struct vm_area_struct *vma)
2870 {
2871 - return is_gate_vma(vma) ? "[vectors]" :
2872 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2873 - "[sigpage]" : NULL;
2874 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2875 }
2876
2877 -static struct page *signal_page;
2878 -extern struct page *get_signal_page(void);
2879 -
2880 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2881 {
2882 struct mm_struct *mm = current->mm;
2883 - unsigned long addr;
2884 - int ret;
2885 -
2886 - if (!signal_page)
2887 - signal_page = get_signal_page();
2888 - if (!signal_page)
2889 - return -ENOMEM;
2890
2891 down_write(&mm->mmap_sem);
2892 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2893 - if (IS_ERR_VALUE(addr)) {
2894 - ret = addr;
2895 - goto up_fail;
2896 - }
2897 -
2898 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2899 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2900 - &signal_page);
2901 -
2902 - if (ret == 0)
2903 - mm->context.sigpage = addr;
2904 -
2905 - up_fail:
2906 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2907 up_write(&mm->mmap_sem);
2908 - return ret;
2909 + return 0;
2910 }
2911 #endif
2912 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2913 index 4693188..4596c5e 100644
2914 --- a/arch/arm/kernel/psci.c
2915 +++ b/arch/arm/kernel/psci.c
2916 @@ -24,7 +24,7 @@
2917 #include <asm/opcodes-virt.h>
2918 #include <asm/psci.h>
2919
2920 -struct psci_operations psci_ops;
2921 +struct psci_operations psci_ops __read_only;
2922
2923 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2924
2925 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2926 index 0dd3b79..e018f64 100644
2927 --- a/arch/arm/kernel/ptrace.c
2928 +++ b/arch/arm/kernel/ptrace.c
2929 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2930 return current_thread_info()->syscall;
2931 }
2932
2933 +#ifdef CONFIG_GRKERNSEC_SETXID
2934 +extern void gr_delayed_cred_worker(void);
2935 +#endif
2936 +
2937 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2938 {
2939 current_thread_info()->syscall = scno;
2940
2941 +#ifdef CONFIG_GRKERNSEC_SETXID
2942 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2943 + gr_delayed_cred_worker();
2944 +#endif
2945 +
2946 /* Do the secure computing check first; failures should be fast. */
2947 if (secure_computing(scno) == -1)
2948 return -1;
2949 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2950 index afc2489..6372bc8 100644
2951 --- a/arch/arm/kernel/setup.c
2952 +++ b/arch/arm/kernel/setup.c
2953 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2954 unsigned int elf_hwcap __read_mostly;
2955 EXPORT_SYMBOL(elf_hwcap);
2956
2957 +pteval_t __supported_pte_mask __read_only;
2958 +pmdval_t __supported_pmd_mask __read_only;
2959
2960 #ifdef MULTI_CPU
2961 -struct processor processor __read_mostly;
2962 +struct processor processor;
2963 #endif
2964 #ifdef MULTI_TLB
2965 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2966 +struct cpu_tlb_fns cpu_tlb __read_only;
2967 #endif
2968 #ifdef MULTI_USER
2969 -struct cpu_user_fns cpu_user __read_mostly;
2970 +struct cpu_user_fns cpu_user __read_only;
2971 #endif
2972 #ifdef MULTI_CACHE
2973 -struct cpu_cache_fns cpu_cache __read_mostly;
2974 +struct cpu_cache_fns cpu_cache __read_only;
2975 #endif
2976 #ifdef CONFIG_OUTER_CACHE
2977 -struct outer_cache_fns outer_cache __read_mostly;
2978 +struct outer_cache_fns outer_cache __read_only;
2979 EXPORT_SYMBOL(outer_cache);
2980 #endif
2981
2982 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
2983 asm("mrc p15, 0, %0, c0, c1, 4"
2984 : "=r" (mmfr0));
2985 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2986 - (mmfr0 & 0x000000f0) >= 0x00000030)
2987 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2988 cpu_arch = CPU_ARCH_ARMv7;
2989 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2990 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2991 + __supported_pte_mask |= L_PTE_PXN;
2992 + __supported_pmd_mask |= PMD_PXNTABLE;
2993 + }
2994 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2995 (mmfr0 & 0x000000f0) == 0x00000020)
2996 cpu_arch = CPU_ARCH_ARMv6;
2997 else
2998 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
2999 __cpu_architecture = __get_cpu_architecture();
3000
3001 #ifdef MULTI_CPU
3002 - processor = *list->proc;
3003 + memcpy((void *)&processor, list->proc, sizeof processor);
3004 #endif
3005 #ifdef MULTI_TLB
3006 cpu_tlb = *list->tlb;
3007 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3008 index ab33042..11248a8 100644
3009 --- a/arch/arm/kernel/signal.c
3010 +++ b/arch/arm/kernel/signal.c
3011 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3012 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3013 };
3014
3015 -static unsigned long signal_return_offset;
3016 -
3017 #ifdef CONFIG_CRUNCH
3018 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3019 {
3020 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3021 * except when the MPU has protected the vectors
3022 * page from PL0
3023 */
3024 - retcode = mm->context.sigpage + signal_return_offset +
3025 - (idx << 2) + thumb;
3026 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3027 } else
3028 #endif
3029 {
3030 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3031 } while (thread_flags & _TIF_WORK_MASK);
3032 return 0;
3033 }
3034 -
3035 -struct page *get_signal_page(void)
3036 -{
3037 - unsigned long ptr;
3038 - unsigned offset;
3039 - struct page *page;
3040 - void *addr;
3041 -
3042 - page = alloc_pages(GFP_KERNEL, 0);
3043 -
3044 - if (!page)
3045 - return NULL;
3046 -
3047 - addr = page_address(page);
3048 -
3049 - /* Give the signal return code some randomness */
3050 - offset = 0x200 + (get_random_int() & 0x7fc);
3051 - signal_return_offset = offset;
3052 -
3053 - /*
3054 - * Copy signal return handlers into the vector page, and
3055 - * set sigreturn to be a pointer to these.
3056 - */
3057 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3058 -
3059 - ptr = (unsigned long)addr + offset;
3060 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3061 -
3062 - return page;
3063 -}
3064 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3065 index 2dc1934..ecf0e21 100644
3066 --- a/arch/arm/kernel/smp.c
3067 +++ b/arch/arm/kernel/smp.c
3068 @@ -71,7 +71,7 @@ enum ipi_msg_type {
3069
3070 static DECLARE_COMPLETION(cpu_running);
3071
3072 -static struct smp_operations smp_ops;
3073 +static struct smp_operations smp_ops __read_only;
3074
3075 void __init smp_set_ops(struct smp_operations *ops)
3076 {
3077 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3078 index ab517fc..9adf2fa 100644
3079 --- a/arch/arm/kernel/traps.c
3080 +++ b/arch/arm/kernel/traps.c
3081 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3082 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3083 {
3084 #ifdef CONFIG_KALLSYMS
3085 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3086 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3087 #else
3088 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3089 #endif
3090 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3091 static int die_owner = -1;
3092 static unsigned int die_nest_count;
3093
3094 +extern void gr_handle_kernel_exploit(void);
3095 +
3096 static unsigned long oops_begin(void)
3097 {
3098 int cpu;
3099 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3100 panic("Fatal exception in interrupt");
3101 if (panic_on_oops)
3102 panic("Fatal exception");
3103 +
3104 + gr_handle_kernel_exploit();
3105 +
3106 if (signr)
3107 do_exit(signr);
3108 }
3109 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3110 * The user helper at 0xffff0fe0 must be used instead.
3111 * (see entry-armv.S for details)
3112 */
3113 + pax_open_kernel();
3114 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3115 + pax_close_kernel();
3116 }
3117 return 0;
3118
3119 @@ -849,7 +856,11 @@ void __init early_trap_init(void *vectors_base)
3120 kuser_init(vectors_base);
3121
3122 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3123 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3124 +
3125 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3126 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3127 +#endif
3128 +
3129 #else /* ifndef CONFIG_CPU_V7M */
3130 /*
3131 * on V7-M there is no need to copy the vector table to a dedicated
3132 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3133 index 7bcee5c..e2f3249 100644
3134 --- a/arch/arm/kernel/vmlinux.lds.S
3135 +++ b/arch/arm/kernel/vmlinux.lds.S
3136 @@ -8,7 +8,11 @@
3137 #include <asm/thread_info.h>
3138 #include <asm/memory.h>
3139 #include <asm/page.h>
3140 -
3141 +
3142 +#ifdef CONFIG_PAX_KERNEXEC
3143 +#include <asm/pgtable.h>
3144 +#endif
3145 +
3146 #define PROC_INFO \
3147 . = ALIGN(4); \
3148 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3149 @@ -34,7 +38,7 @@
3150 #endif
3151
3152 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3153 - defined(CONFIG_GENERIC_BUG)
3154 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3155 #define ARM_EXIT_KEEP(x) x
3156 #define ARM_EXIT_DISCARD(x)
3157 #else
3158 @@ -90,6 +94,11 @@ SECTIONS
3159 _text = .;
3160 HEAD_TEXT
3161 }
3162 +
3163 +#ifdef CONFIG_PAX_KERNEXEC
3164 + . = ALIGN(1<<SECTION_SHIFT);
3165 +#endif
3166 +
3167 .text : { /* Real text segment */
3168 _stext = .; /* Text and read-only data */
3169 __exception_text_start = .;
3170 @@ -112,6 +121,8 @@ SECTIONS
3171 ARM_CPU_KEEP(PROC_INFO)
3172 }
3173
3174 + _etext = .; /* End of text section */
3175 +
3176 RO_DATA(PAGE_SIZE)
3177
3178 . = ALIGN(4);
3179 @@ -142,7 +153,9 @@ SECTIONS
3180
3181 NOTES
3182
3183 - _etext = .; /* End of text and rodata section */
3184 +#ifdef CONFIG_PAX_KERNEXEC
3185 + . = ALIGN(1<<SECTION_SHIFT);
3186 +#endif
3187
3188 #ifndef CONFIG_XIP_KERNEL
3189 . = ALIGN(PAGE_SIZE);
3190 @@ -220,6 +233,11 @@ SECTIONS
3191 . = PAGE_OFFSET + TEXT_OFFSET;
3192 #else
3193 __init_end = .;
3194 +
3195 +#ifdef CONFIG_PAX_KERNEXEC
3196 + . = ALIGN(1<<SECTION_SHIFT);
3197 +#endif
3198 +
3199 . = ALIGN(THREAD_SIZE);
3200 __data_loc = .;
3201 #endif
3202 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3203 index 741f66a..8a5615c 100644
3204 --- a/arch/arm/kvm/arm.c
3205 +++ b/arch/arm/kvm/arm.c
3206 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3207 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3208
3209 /* The VMID used in the VTTBR */
3210 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3211 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3212 static u8 kvm_next_vmid;
3213 static DEFINE_SPINLOCK(kvm_vmid_lock);
3214
3215 @@ -392,7 +392,7 @@ void force_vm_exit(const cpumask_t *mask)
3216 */
3217 static bool need_new_vmid_gen(struct kvm *kvm)
3218 {
3219 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3220 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3221 }
3222
3223 /**
3224 @@ -425,7 +425,7 @@ static void update_vttbr(struct kvm *kvm)
3225
3226 /* First user of a new VMID generation? */
3227 if (unlikely(kvm_next_vmid == 0)) {
3228 - atomic64_inc(&kvm_vmid_gen);
3229 + atomic64_inc_unchecked(&kvm_vmid_gen);
3230 kvm_next_vmid = 1;
3231
3232 /*
3233 @@ -442,7 +442,7 @@ static void update_vttbr(struct kvm *kvm)
3234 kvm_call_hyp(__kvm_flush_vm_context);
3235 }
3236
3237 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3238 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3239 kvm->arch.vmid = kvm_next_vmid;
3240 kvm_next_vmid++;
3241
3242 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3243 index 14a0d98..7771a7d 100644
3244 --- a/arch/arm/lib/clear_user.S
3245 +++ b/arch/arm/lib/clear_user.S
3246 @@ -12,14 +12,14 @@
3247
3248 .text
3249
3250 -/* Prototype: int __clear_user(void *addr, size_t sz)
3251 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3252 * Purpose : clear some user memory
3253 * Params : addr - user memory address to clear
3254 * : sz - number of bytes to clear
3255 * Returns : number of bytes NOT cleared
3256 */
3257 ENTRY(__clear_user_std)
3258 -WEAK(__clear_user)
3259 +WEAK(___clear_user)
3260 stmfd sp!, {r1, lr}
3261 mov r2, #0
3262 cmp r1, #4
3263 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3264 USER( strnebt r2, [r0])
3265 mov r0, #0
3266 ldmfd sp!, {r1, pc}
3267 -ENDPROC(__clear_user)
3268 +ENDPROC(___clear_user)
3269 ENDPROC(__clear_user_std)
3270
3271 .pushsection .fixup,"ax"
3272 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3273 index 66a477a..bee61d3 100644
3274 --- a/arch/arm/lib/copy_from_user.S
3275 +++ b/arch/arm/lib/copy_from_user.S
3276 @@ -16,7 +16,7 @@
3277 /*
3278 * Prototype:
3279 *
3280 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3281 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3282 *
3283 * Purpose:
3284 *
3285 @@ -84,11 +84,11 @@
3286
3287 .text
3288
3289 -ENTRY(__copy_from_user)
3290 +ENTRY(___copy_from_user)
3291
3292 #include "copy_template.S"
3293
3294 -ENDPROC(__copy_from_user)
3295 +ENDPROC(___copy_from_user)
3296
3297 .pushsection .fixup,"ax"
3298 .align 0
3299 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3300 index 6ee2f67..d1cce76 100644
3301 --- a/arch/arm/lib/copy_page.S
3302 +++ b/arch/arm/lib/copy_page.S
3303 @@ -10,6 +10,7 @@
3304 * ASM optimised string functions
3305 */
3306 #include <linux/linkage.h>
3307 +#include <linux/const.h>
3308 #include <asm/assembler.h>
3309 #include <asm/asm-offsets.h>
3310 #include <asm/cache.h>
3311 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3312 index d066df6..df28194 100644
3313 --- a/arch/arm/lib/copy_to_user.S
3314 +++ b/arch/arm/lib/copy_to_user.S
3315 @@ -16,7 +16,7 @@
3316 /*
3317 * Prototype:
3318 *
3319 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3320 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3321 *
3322 * Purpose:
3323 *
3324 @@ -88,11 +88,11 @@
3325 .text
3326
3327 ENTRY(__copy_to_user_std)
3328 -WEAK(__copy_to_user)
3329 +WEAK(___copy_to_user)
3330
3331 #include "copy_template.S"
3332
3333 -ENDPROC(__copy_to_user)
3334 +ENDPROC(___copy_to_user)
3335 ENDPROC(__copy_to_user_std)
3336
3337 .pushsection .fixup,"ax"
3338 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3339 index 7d08b43..f7ca7ea 100644
3340 --- a/arch/arm/lib/csumpartialcopyuser.S
3341 +++ b/arch/arm/lib/csumpartialcopyuser.S
3342 @@ -57,8 +57,8 @@
3343 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3344 */
3345
3346 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3347 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3348 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3349 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3350
3351 #include "csumpartialcopygeneric.S"
3352
3353 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3354 index 5306de3..aed6d03 100644
3355 --- a/arch/arm/lib/delay.c
3356 +++ b/arch/arm/lib/delay.c
3357 @@ -28,7 +28,7 @@
3358 /*
3359 * Default to the loop-based delay implementation.
3360 */
3361 -struct arm_delay_ops arm_delay_ops = {
3362 +struct arm_delay_ops arm_delay_ops __read_only = {
3363 .delay = __loop_delay,
3364 .const_udelay = __loop_const_udelay,
3365 .udelay = __loop_udelay,
3366 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3367 index 025f742..a9e5b3b 100644
3368 --- a/arch/arm/lib/uaccess_with_memcpy.c
3369 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3370 @@ -104,7 +104,7 @@ out:
3371 }
3372
3373 unsigned long
3374 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3375 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3376 {
3377 /*
3378 * This test is stubbed out of the main function above to keep
3379 @@ -155,7 +155,7 @@ out:
3380 return n;
3381 }
3382
3383 -unsigned long __clear_user(void __user *addr, unsigned long n)
3384 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3385 {
3386 /* See rational for this in __copy_to_user() above. */
3387 if (n < 64)
3388 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3389 index e9238b5..6ed904a 100644
3390 --- a/arch/arm/mach-kirkwood/common.c
3391 +++ b/arch/arm/mach-kirkwood/common.c
3392 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3393 clk_gate_ops.disable(hw);
3394 }
3395
3396 -static struct clk_ops clk_gate_fn_ops;
3397 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3398 +{
3399 + return clk_gate_ops.is_enabled(hw);
3400 +}
3401 +
3402 +static struct clk_ops clk_gate_fn_ops = {
3403 + .enable = clk_gate_fn_enable,
3404 + .disable = clk_gate_fn_disable,
3405 + .is_enabled = clk_gate_fn_is_enabled,
3406 +};
3407
3408 static struct clk __init *clk_register_gate_fn(struct device *dev,
3409 const char *name,
3410 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3411 gate_fn->fn_en = fn_en;
3412 gate_fn->fn_dis = fn_dis;
3413
3414 - /* ops is the gate ops, but with our enable/disable functions */
3415 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3416 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3417 - clk_gate_fn_ops = clk_gate_ops;
3418 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3419 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3420 - }
3421 -
3422 clk = clk_register(dev, &gate_fn->gate.hw);
3423
3424 if (IS_ERR(clk))
3425 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3426 index 827d1500..2885dc6 100644
3427 --- a/arch/arm/mach-omap2/board-n8x0.c
3428 +++ b/arch/arm/mach-omap2/board-n8x0.c
3429 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3430 }
3431 #endif
3432
3433 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3434 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3435 .late_init = n8x0_menelaus_late_init,
3436 };
3437
3438 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3439 index f3fdd6a..3564800 100644
3440 --- a/arch/arm/mach-omap2/gpmc.c
3441 +++ b/arch/arm/mach-omap2/gpmc.c
3442 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3443 };
3444
3445 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3446 -static struct irq_chip gpmc_irq_chip;
3447 static unsigned gpmc_irq_start;
3448
3449 static struct resource gpmc_mem_root;
3450 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3451
3452 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3453
3454 +static struct irq_chip gpmc_irq_chip = {
3455 + .name = "gpmc",
3456 + .irq_startup = gpmc_irq_noop_ret,
3457 + .irq_enable = gpmc_irq_enable,
3458 + .irq_disable = gpmc_irq_disable,
3459 + .irq_shutdown = gpmc_irq_noop,
3460 + .irq_ack = gpmc_irq_noop,
3461 + .irq_mask = gpmc_irq_noop,
3462 + .irq_unmask = gpmc_irq_noop,
3463 +
3464 +};
3465 +
3466 static int gpmc_setup_irq(void)
3467 {
3468 int i;
3469 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3470 return gpmc_irq_start;
3471 }
3472
3473 - gpmc_irq_chip.name = "gpmc";
3474 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3475 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3476 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3477 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3478 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3479 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3480 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3481 -
3482 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3483 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3484
3485 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3486 index f991016..145ebeb 100644
3487 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3488 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3489 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3490 int (*finish_suspend)(unsigned long cpu_state);
3491 void (*resume)(void);
3492 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3493 -};
3494 +} __no_const;
3495
3496 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3497 static struct powerdomain *mpuss_pd;
3498 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3499 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3500 {}
3501
3502 -struct cpu_pm_ops omap_pm_ops = {
3503 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3504 .finish_suspend = default_finish_suspend,
3505 .resume = dummy_cpu_resume,
3506 .scu_prepare = dummy_scu_prepare,
3507 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3508 index 813c615..ce467c6 100644
3509 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3510 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3511 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3512 return NOTIFY_OK;
3513 }
3514
3515 -static struct notifier_block __refdata irq_hotplug_notifier = {
3516 +static struct notifier_block irq_hotplug_notifier = {
3517 .notifier_call = irq_cpu_hotplug_notify,
3518 };
3519
3520 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3521 index f99f68e..e573e20 100644
3522 --- a/arch/arm/mach-omap2/omap_device.c
3523 +++ b/arch/arm/mach-omap2/omap_device.c
3524 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3525 struct platform_device __init *omap_device_build(const char *pdev_name,
3526 int pdev_id,
3527 struct omap_hwmod *oh,
3528 - void *pdata, int pdata_len)
3529 + const void *pdata, int pdata_len)
3530 {
3531 struct omap_hwmod *ohs[] = { oh };
3532
3533 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3534 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3535 int pdev_id,
3536 struct omap_hwmod **ohs,
3537 - int oh_cnt, void *pdata,
3538 + int oh_cnt, const void *pdata,
3539 int pdata_len)
3540 {
3541 int ret = -ENOMEM;
3542 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3543 index 17ca1ae..beba869 100644
3544 --- a/arch/arm/mach-omap2/omap_device.h
3545 +++ b/arch/arm/mach-omap2/omap_device.h
3546 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3547 /* Core code interface */
3548
3549 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3550 - struct omap_hwmod *oh, void *pdata,
3551 + struct omap_hwmod *oh, const void *pdata,
3552 int pdata_len);
3553
3554 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3555 struct omap_hwmod **oh, int oh_cnt,
3556 - void *pdata, int pdata_len);
3557 + const void *pdata, int pdata_len);
3558
3559 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3560 struct omap_hwmod **ohs, int oh_cnt);
3561 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3562 index 7f4db12..0243012 100644
3563 --- a/arch/arm/mach-omap2/omap_hwmod.c
3564 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3565 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3566 int (*init_clkdm)(struct omap_hwmod *oh);
3567 void (*update_context_lost)(struct omap_hwmod *oh);
3568 int (*get_context_lost)(struct omap_hwmod *oh);
3569 -};
3570 +} __no_const;
3571
3572 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3573 -static struct omap_hwmod_soc_ops soc_ops;
3574 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3575
3576 /* omap_hwmod_list contains all registered struct omap_hwmods */
3577 static LIST_HEAD(omap_hwmod_list);
3578 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3579 index d15c7bb..b2d1f0c 100644
3580 --- a/arch/arm/mach-omap2/wd_timer.c
3581 +++ b/arch/arm/mach-omap2/wd_timer.c
3582 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3583 struct omap_hwmod *oh;
3584 char *oh_name = "wd_timer2";
3585 char *dev_name = "omap_wdt";
3586 - struct omap_wd_timer_platform_data pdata;
3587 + static struct omap_wd_timer_platform_data pdata = {
3588 + .read_reset_sources = prm_read_reset_sources
3589 + };
3590
3591 if (!cpu_class_is_omap2() || of_have_populated_dt())
3592 return 0;
3593 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3594 return -EINVAL;
3595 }
3596
3597 - pdata.read_reset_sources = prm_read_reset_sources;
3598 -
3599 pdev = omap_device_build(dev_name, id, oh, &pdata,
3600 sizeof(struct omap_wd_timer_platform_data));
3601 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3602 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3603 index 706aa42..f85e9131 100644
3604 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3605 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3606 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3607 bool entered_lp2 = false;
3608
3609 if (tegra_pending_sgi())
3610 - ACCESS_ONCE(abort_flag) = true;
3611 + ACCESS_ONCE_RW(abort_flag) = true;
3612
3613 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3614
3615 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3616 index cad3ca86..1d79e0f 100644
3617 --- a/arch/arm/mach-ux500/setup.h
3618 +++ b/arch/arm/mach-ux500/setup.h
3619 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3620 .type = MT_DEVICE, \
3621 }
3622
3623 -#define __MEM_DEV_DESC(x, sz) { \
3624 - .virtual = IO_ADDRESS(x), \
3625 - .pfn = __phys_to_pfn(x), \
3626 - .length = sz, \
3627 - .type = MT_MEMORY, \
3628 -}
3629 -
3630 extern struct smp_operations ux500_smp_ops;
3631 extern void ux500_cpu_die(unsigned int cpu);
3632
3633 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3634 index cd2c88e..4dd9b67 100644
3635 --- a/arch/arm/mm/Kconfig
3636 +++ b/arch/arm/mm/Kconfig
3637 @@ -446,7 +446,7 @@ config CPU_32v5
3638
3639 config CPU_32v6
3640 bool
3641 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3642 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3643 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3644
3645 config CPU_32v6K
3646 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3647
3648 config CPU_USE_DOMAINS
3649 bool
3650 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3651 help
3652 This option enables or disables the use of domain switching
3653 via the set_fs() function.
3654 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3655 config KUSER_HELPERS
3656 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3657 default y
3658 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3659 help
3660 Warning: disabling this option may break user programs.
3661
3662 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3663 See Documentation/arm/kernel_user_helpers.txt for details.
3664
3665 However, the fixed address nature of these helpers can be used
3666 - by ROP (return orientated programming) authors when creating
3667 + by ROP (Return Oriented Programming) authors when creating
3668 exploits.
3669
3670 If all of the binaries and libraries which run on your platform
3671 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3672 index 6f4585b..7b6f52b 100644
3673 --- a/arch/arm/mm/alignment.c
3674 +++ b/arch/arm/mm/alignment.c
3675 @@ -211,10 +211,12 @@ union offset_union {
3676 #define __get16_unaligned_check(ins,val,addr) \
3677 do { \
3678 unsigned int err = 0, v, a = addr; \
3679 + pax_open_userland(); \
3680 __get8_unaligned_check(ins,v,a,err); \
3681 val = v << ((BE) ? 8 : 0); \
3682 __get8_unaligned_check(ins,v,a,err); \
3683 val |= v << ((BE) ? 0 : 8); \
3684 + pax_close_userland(); \
3685 if (err) \
3686 goto fault; \
3687 } while (0)
3688 @@ -228,6 +230,7 @@ union offset_union {
3689 #define __get32_unaligned_check(ins,val,addr) \
3690 do { \
3691 unsigned int err = 0, v, a = addr; \
3692 + pax_open_userland(); \
3693 __get8_unaligned_check(ins,v,a,err); \
3694 val = v << ((BE) ? 24 : 0); \
3695 __get8_unaligned_check(ins,v,a,err); \
3696 @@ -236,6 +239,7 @@ union offset_union {
3697 val |= v << ((BE) ? 8 : 16); \
3698 __get8_unaligned_check(ins,v,a,err); \
3699 val |= v << ((BE) ? 0 : 24); \
3700 + pax_close_userland(); \
3701 if (err) \
3702 goto fault; \
3703 } while (0)
3704 @@ -249,6 +253,7 @@ union offset_union {
3705 #define __put16_unaligned_check(ins,val,addr) \
3706 do { \
3707 unsigned int err = 0, v = val, a = addr; \
3708 + pax_open_userland(); \
3709 __asm__( FIRST_BYTE_16 \
3710 ARM( "1: "ins" %1, [%2], #1\n" ) \
3711 THUMB( "1: "ins" %1, [%2]\n" ) \
3712 @@ -268,6 +273,7 @@ union offset_union {
3713 " .popsection\n" \
3714 : "=r" (err), "=&r" (v), "=&r" (a) \
3715 : "0" (err), "1" (v), "2" (a)); \
3716 + pax_close_userland(); \
3717 if (err) \
3718 goto fault; \
3719 } while (0)
3720 @@ -281,6 +287,7 @@ union offset_union {
3721 #define __put32_unaligned_check(ins,val,addr) \
3722 do { \
3723 unsigned int err = 0, v = val, a = addr; \
3724 + pax_open_userland(); \
3725 __asm__( FIRST_BYTE_32 \
3726 ARM( "1: "ins" %1, [%2], #1\n" ) \
3727 THUMB( "1: "ins" %1, [%2]\n" ) \
3728 @@ -310,6 +317,7 @@ union offset_union {
3729 " .popsection\n" \
3730 : "=r" (err), "=&r" (v), "=&r" (a) \
3731 : "0" (err), "1" (v), "2" (a)); \
3732 + pax_close_userland(); \
3733 if (err) \
3734 goto fault; \
3735 } while (0)
3736 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3737 index 4a05444..d21968c 100644
3738 --- a/arch/arm/mm/context.c
3739 +++ b/arch/arm/mm/context.c
3740 @@ -43,7 +43,7 @@
3741 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3742
3743 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3744 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3745 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3746 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3747
3748 static DEFINE_PER_CPU(atomic64_t, active_asids);
3749 @@ -183,7 +183,7 @@ static int is_reserved_asid(u64 asid)
3750 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3751 {
3752 u64 asid = atomic64_read(&mm->context.id);
3753 - u64 generation = atomic64_read(&asid_generation);
3754 + u64 generation = atomic64_read_unchecked(&asid_generation);
3755
3756 if (asid != 0 && is_reserved_asid(asid)) {
3757 /*
3758 @@ -201,7 +201,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3759 */
3760 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3761 if (asid == NUM_USER_ASIDS) {
3762 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3763 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3764 &asid_generation);
3765 flush_context(cpu);
3766 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3767 @@ -230,14 +230,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3768 cpu_set_reserved_ttbr0();
3769
3770 asid = atomic64_read(&mm->context.id);
3771 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3772 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3773 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3774 goto switch_mm_fastpath;
3775
3776 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3777 /* Check that our ASID belongs to the current generation. */
3778 asid = atomic64_read(&mm->context.id);
3779 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3780 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3781 asid = new_context(mm, cpu);
3782 atomic64_set(&mm->context.id, asid);
3783 }
3784 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3785 index c97f794..6461880 100644
3786 --- a/arch/arm/mm/fault.c
3787 +++ b/arch/arm/mm/fault.c
3788 @@ -25,6 +25,7 @@
3789 #include <asm/system_misc.h>
3790 #include <asm/system_info.h>
3791 #include <asm/tlbflush.h>
3792 +#include <asm/sections.h>
3793
3794 #include "fault.h"
3795
3796 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3797 if (fixup_exception(regs))
3798 return;
3799
3800 +#ifdef CONFIG_PAX_KERNEXEC
3801 + if ((fsr & FSR_WRITE) &&
3802 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3803 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3804 + {
3805 + if (current->signal->curr_ip)
3806 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3807 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3808 + else
3809 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3810 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3811 + }
3812 +#endif
3813 +
3814 /*
3815 * No handler, we'll have to terminate things with extreme prejudice.
3816 */
3817 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3818 }
3819 #endif
3820
3821 +#ifdef CONFIG_PAX_PAGEEXEC
3822 + if (fsr & FSR_LNX_PF) {
3823 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3824 + do_group_exit(SIGKILL);
3825 + }
3826 +#endif
3827 +
3828 tsk->thread.address = addr;
3829 tsk->thread.error_code = fsr;
3830 tsk->thread.trap_no = 14;
3831 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3832 }
3833 #endif /* CONFIG_MMU */
3834
3835 +#ifdef CONFIG_PAX_PAGEEXEC
3836 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3837 +{
3838 + long i;
3839 +
3840 + printk(KERN_ERR "PAX: bytes at PC: ");
3841 + for (i = 0; i < 20; i++) {
3842 + unsigned char c;
3843 + if (get_user(c, (__force unsigned char __user *)pc+i))
3844 + printk(KERN_CONT "?? ");
3845 + else
3846 + printk(KERN_CONT "%02x ", c);
3847 + }
3848 + printk("\n");
3849 +
3850 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3851 + for (i = -1; i < 20; i++) {
3852 + unsigned long c;
3853 + if (get_user(c, (__force unsigned long __user *)sp+i))
3854 + printk(KERN_CONT "???????? ");
3855 + else
3856 + printk(KERN_CONT "%08lx ", c);
3857 + }
3858 + printk("\n");
3859 +}
3860 +#endif
3861 +
3862 /*
3863 * First Level Translation Fault Handler
3864 *
3865 @@ -545,9 +594,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3866 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3867 struct siginfo info;
3868
3869 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3870 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3871 + if (current->signal->curr_ip)
3872 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3873 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3874 + else
3875 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3876 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3877 + goto die;
3878 + }
3879 +#endif
3880 +
3881 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3882 return;
3883
3884 +die:
3885 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3886 inf->name, fsr, addr);
3887
3888 @@ -571,15 +633,92 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3889 ifsr_info[nr].name = name;
3890 }
3891
3892 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3893 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3894 +
3895 asmlinkage void __exception
3896 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3897 {
3898 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3899 struct siginfo info;
3900 + unsigned long pc = instruction_pointer(regs);
3901 +
3902 + if (user_mode(regs)) {
3903 + unsigned long sigpage = current->mm->context.sigpage;
3904 +
3905 + if (sigpage <= pc && pc < sigpage + 7*4) {
3906 + if (pc < sigpage + 3*4)
3907 + sys_sigreturn(regs);
3908 + else
3909 + sys_rt_sigreturn(regs);
3910 + return;
3911 + }
3912 + if (pc == 0xffff0f60UL) {
3913 + /*
3914 + * PaX: __kuser_cmpxchg64 emulation
3915 + */
3916 + // TODO
3917 + //regs->ARM_pc = regs->ARM_lr;
3918 + //return;
3919 + }
3920 + if (pc == 0xffff0fa0UL) {
3921 + /*
3922 + * PaX: __kuser_memory_barrier emulation
3923 + */
3924 + // dmb(); implied by the exception
3925 + regs->ARM_pc = regs->ARM_lr;
3926 + return;
3927 + }
3928 + if (pc == 0xffff0fc0UL) {
3929 + /*
3930 + * PaX: __kuser_cmpxchg emulation
3931 + */
3932 + // TODO
3933 + //regs->ARM_pc = regs->ARM_lr;
3934 + //return;
3935 + }
3936 + if (pc == 0xffff0fe0UL) {
3937 + /*
3938 + * PaX: __kuser_get_tls emulation
3939 + */
3940 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3941 + regs->ARM_pc = regs->ARM_lr;
3942 + return;
3943 + }
3944 + }
3945 +
3946 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3947 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3948 + if (current->signal->curr_ip)
3949 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3950 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3951 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3952 + else
3953 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3954 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3955 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3956 + goto die;
3957 + }
3958 +#endif
3959 +
3960 +#ifdef CONFIG_PAX_REFCOUNT
3961 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3962 + unsigned int bkpt;
3963 +
3964 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3965 + current->thread.error_code = ifsr;
3966 + current->thread.trap_no = 0;
3967 + pax_report_refcount_overflow(regs);
3968 + fixup_exception(regs);
3969 + return;
3970 + }
3971 + }
3972 +#endif
3973
3974 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3975 return;
3976
3977 +die:
3978 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3979 inf->name, ifsr, addr);
3980
3981 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3982 index cf08bdf..772656c 100644
3983 --- a/arch/arm/mm/fault.h
3984 +++ b/arch/arm/mm/fault.h
3985 @@ -3,6 +3,7 @@
3986
3987 /*
3988 * Fault status register encodings. We steal bit 31 for our own purposes.
3989 + * Set when the FSR value is from an instruction fault.
3990 */
3991 #define FSR_LNX_PF (1 << 31)
3992 #define FSR_WRITE (1 << 11)
3993 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3994 }
3995 #endif
3996
3997 +/* valid for LPAE and !LPAE */
3998 +static inline int is_xn_fault(unsigned int fsr)
3999 +{
4000 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4001 +}
4002 +
4003 +static inline int is_domain_fault(unsigned int fsr)
4004 +{
4005 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4006 +}
4007 +
4008 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4009 unsigned long search_exception_table(unsigned long addr);
4010
4011 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4012 index 15225d8..25e2e3c 100644
4013 --- a/arch/arm/mm/init.c
4014 +++ b/arch/arm/mm/init.c
4015 @@ -30,6 +30,8 @@
4016 #include <asm/setup.h>
4017 #include <asm/tlb.h>
4018 #include <asm/fixmap.h>
4019 +#include <asm/system_info.h>
4020 +#include <asm/cp15.h>
4021
4022 #include <asm/mach/arch.h>
4023 #include <asm/mach/map.h>
4024 @@ -683,7 +685,46 @@ void free_initmem(void)
4025 {
4026 #ifdef CONFIG_HAVE_TCM
4027 extern char __tcm_start, __tcm_end;
4028 +#endif
4029
4030 +#ifdef CONFIG_PAX_KERNEXEC
4031 + unsigned long addr;
4032 + pgd_t *pgd;
4033 + pud_t *pud;
4034 + pmd_t *pmd;
4035 + int cpu_arch = cpu_architecture();
4036 + unsigned int cr = get_cr();
4037 +
4038 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4039 + /* make pages tables, etc before .text NX */
4040 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4041 + pgd = pgd_offset_k(addr);
4042 + pud = pud_offset(pgd, addr);
4043 + pmd = pmd_offset(pud, addr);
4044 + __section_update(pmd, addr, PMD_SECT_XN);
4045 + }
4046 + /* make init NX */
4047 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4048 + pgd = pgd_offset_k(addr);
4049 + pud = pud_offset(pgd, addr);
4050 + pmd = pmd_offset(pud, addr);
4051 + __section_update(pmd, addr, PMD_SECT_XN);
4052 + }
4053 + /* make kernel code/rodata RX */
4054 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4055 + pgd = pgd_offset_k(addr);
4056 + pud = pud_offset(pgd, addr);
4057 + pmd = pmd_offset(pud, addr);
4058 +#ifdef CONFIG_ARM_LPAE
4059 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4060 +#else
4061 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4062 +#endif
4063 + }
4064 + }
4065 +#endif
4066 +
4067 +#ifdef CONFIG_HAVE_TCM
4068 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4069 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4070 #endif
4071 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4072 index f123d6e..04bf569 100644
4073 --- a/arch/arm/mm/ioremap.c
4074 +++ b/arch/arm/mm/ioremap.c
4075 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4076 unsigned int mtype;
4077
4078 if (cached)
4079 - mtype = MT_MEMORY;
4080 + mtype = MT_MEMORY_RX;
4081 else
4082 - mtype = MT_MEMORY_NONCACHED;
4083 + mtype = MT_MEMORY_NONCACHED_RX;
4084
4085 return __arm_ioremap_caller(phys_addr, size, mtype,
4086 __builtin_return_address(0));
4087 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4088 index 0c63562..7128a90 100644
4089 --- a/arch/arm/mm/mmap.c
4090 +++ b/arch/arm/mm/mmap.c
4091 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4092 struct vm_area_struct *vma;
4093 int do_align = 0;
4094 int aliasing = cache_is_vipt_aliasing();
4095 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4096 struct vm_unmapped_area_info info;
4097
4098 /*
4099 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4100 if (len > TASK_SIZE)
4101 return -ENOMEM;
4102
4103 +#ifdef CONFIG_PAX_RANDMMAP
4104 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4105 +#endif
4106 +
4107 if (addr) {
4108 if (do_align)
4109 addr = COLOUR_ALIGN(addr, pgoff);
4110 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4111 addr = PAGE_ALIGN(addr);
4112
4113 vma = find_vma(mm, addr);
4114 - if (TASK_SIZE - len >= addr &&
4115 - (!vma || addr + len <= vma->vm_start))
4116 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4117 return addr;
4118 }
4119
4120 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4121 info.high_limit = TASK_SIZE;
4122 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4123 info.align_offset = pgoff << PAGE_SHIFT;
4124 + info.threadstack_offset = offset;
4125 return vm_unmapped_area(&info);
4126 }
4127
4128 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4129 unsigned long addr = addr0;
4130 int do_align = 0;
4131 int aliasing = cache_is_vipt_aliasing();
4132 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4133 struct vm_unmapped_area_info info;
4134
4135 /*
4136 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4137 return addr;
4138 }
4139
4140 +#ifdef CONFIG_PAX_RANDMMAP
4141 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4142 +#endif
4143 +
4144 /* requesting a specific address */
4145 if (addr) {
4146 if (do_align)
4147 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4148 else
4149 addr = PAGE_ALIGN(addr);
4150 vma = find_vma(mm, addr);
4151 - if (TASK_SIZE - len >= addr &&
4152 - (!vma || addr + len <= vma->vm_start))
4153 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4154 return addr;
4155 }
4156
4157 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4158 info.high_limit = mm->mmap_base;
4159 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4160 info.align_offset = pgoff << PAGE_SHIFT;
4161 + info.threadstack_offset = offset;
4162 addr = vm_unmapped_area(&info);
4163
4164 /*
4165 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4166 {
4167 unsigned long random_factor = 0UL;
4168
4169 +#ifdef CONFIG_PAX_RANDMMAP
4170 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4171 +#endif
4172 +
4173 /* 8 bits of randomness in 20 address space bits */
4174 if ((current->flags & PF_RANDOMIZE) &&
4175 !(current->personality & ADDR_NO_RANDOMIZE))
4176 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4177
4178 if (mmap_is_legacy()) {
4179 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4180 +
4181 +#ifdef CONFIG_PAX_RANDMMAP
4182 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4183 + mm->mmap_base += mm->delta_mmap;
4184 +#endif
4185 +
4186 mm->get_unmapped_area = arch_get_unmapped_area;
4187 } else {
4188 mm->mmap_base = mmap_base(random_factor);
4189 +
4190 +#ifdef CONFIG_PAX_RANDMMAP
4191 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4192 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4193 +#endif
4194 +
4195 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4196 }
4197 }
4198 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4199 index 53cdbd3..670f177 100644
4200 --- a/arch/arm/mm/mmu.c
4201 +++ b/arch/arm/mm/mmu.c
4202 @@ -36,6 +36,22 @@
4203 #include "mm.h"
4204 #include "tcm.h"
4205
4206 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4207 +void modify_domain(unsigned int dom, unsigned int type)
4208 +{
4209 + struct thread_info *thread = current_thread_info();
4210 + unsigned int domain = thread->cpu_domain;
4211 + /*
4212 + * DOMAIN_MANAGER might be defined to some other value,
4213 + * use the arch-defined constant
4214 + */
4215 + domain &= ~domain_val(dom, 3);
4216 + thread->cpu_domain = domain | domain_val(dom, type);
4217 + set_domain(thread->cpu_domain);
4218 +}
4219 +EXPORT_SYMBOL(modify_domain);
4220 +#endif
4221 +
4222 /*
4223 * empty_zero_page is a special page that is used for
4224 * zero-initialized data and COW.
4225 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4226
4227 #endif /* ifdef CONFIG_CPU_CP15 / else */
4228
4229 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4230 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4231 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4232
4233 -static struct mem_type mem_types[] = {
4234 +#ifdef CONFIG_PAX_KERNEXEC
4235 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4236 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4237 +#else
4238 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4239 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4240 +#endif
4241 +
4242 +static struct mem_type mem_types[] __read_only = {
4243 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4244 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4245 L_PTE_SHARED,
4246 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4247 [MT_UNCACHED] = {
4248 .prot_pte = PROT_PTE_DEVICE,
4249 .prot_l1 = PMD_TYPE_TABLE,
4250 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4251 + .prot_sect = PROT_SECT_DEVICE,
4252 .domain = DOMAIN_IO,
4253 },
4254 [MT_CACHECLEAN] = {
4255 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4256 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4257 .domain = DOMAIN_KERNEL,
4258 },
4259 #ifndef CONFIG_ARM_LPAE
4260 [MT_MINICLEAN] = {
4261 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4262 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4263 .domain = DOMAIN_KERNEL,
4264 },
4265 #endif
4266 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4267 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4268 L_PTE_RDONLY,
4269 .prot_l1 = PMD_TYPE_TABLE,
4270 - .domain = DOMAIN_USER,
4271 + .domain = DOMAIN_VECTORS,
4272 },
4273 [MT_HIGH_VECTORS] = {
4274 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4275 L_PTE_USER | L_PTE_RDONLY,
4276 .prot_l1 = PMD_TYPE_TABLE,
4277 - .domain = DOMAIN_USER,
4278 + .domain = DOMAIN_VECTORS,
4279 },
4280 - [MT_MEMORY] = {
4281 + [MT_MEMORY_RWX] = {
4282 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4283 .prot_l1 = PMD_TYPE_TABLE,
4284 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4285 .domain = DOMAIN_KERNEL,
4286 },
4287 + [MT_MEMORY_RW] = {
4288 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4289 + .prot_l1 = PMD_TYPE_TABLE,
4290 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4291 + .domain = DOMAIN_KERNEL,
4292 + },
4293 + [MT_MEMORY_RX] = {
4294 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4295 + .prot_l1 = PMD_TYPE_TABLE,
4296 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4297 + .domain = DOMAIN_KERNEL,
4298 + },
4299 [MT_ROM] = {
4300 - .prot_sect = PMD_TYPE_SECT,
4301 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4302 .domain = DOMAIN_KERNEL,
4303 },
4304 - [MT_MEMORY_NONCACHED] = {
4305 + [MT_MEMORY_NONCACHED_RW] = {
4306 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4307 L_PTE_MT_BUFFERABLE,
4308 .prot_l1 = PMD_TYPE_TABLE,
4309 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4310 .domain = DOMAIN_KERNEL,
4311 },
4312 + [MT_MEMORY_NONCACHED_RX] = {
4313 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4314 + L_PTE_MT_BUFFERABLE,
4315 + .prot_l1 = PMD_TYPE_TABLE,
4316 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4317 + .domain = DOMAIN_KERNEL,
4318 + },
4319 [MT_MEMORY_DTCM] = {
4320 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4321 - L_PTE_XN,
4322 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4323 .prot_l1 = PMD_TYPE_TABLE,
4324 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4325 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4326 .domain = DOMAIN_KERNEL,
4327 },
4328 [MT_MEMORY_ITCM] = {
4329 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4330 },
4331 [MT_MEMORY_SO] = {
4332 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4333 - L_PTE_MT_UNCACHED | L_PTE_XN,
4334 + L_PTE_MT_UNCACHED,
4335 .prot_l1 = PMD_TYPE_TABLE,
4336 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4337 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4338 + PMD_SECT_UNCACHED,
4339 .domain = DOMAIN_KERNEL,
4340 },
4341 [MT_MEMORY_DMA_READY] = {
4342 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4343 * to prevent speculative instruction fetches.
4344 */
4345 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4346 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4347 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4348 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4349 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4350 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4351 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4352 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4353 +
4354 + /* Mark other regions on ARMv6+ as execute-never */
4355 +
4356 +#ifdef CONFIG_PAX_KERNEXEC
4357 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4358 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4359 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4360 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4361 +#ifndef CONFIG_ARM_LPAE
4362 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4363 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4364 +#endif
4365 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4366 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4367 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4368 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4369 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4370 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4371 +#endif
4372 +
4373 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4374 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4375 }
4376 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4377 /*
4378 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4379 * from SVC mode and no access from userspace.
4380 */
4381 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4382 +#ifdef CONFIG_PAX_KERNEXEC
4383 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4384 +#endif
4385 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4386 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4387 #endif
4388 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4389 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4390 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4391 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4392 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4393 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4394 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4395 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4396 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4397 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4398 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4399 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4400 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4401 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4402 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4403 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4404 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4405 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4406 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4407 }
4408 }
4409
4410 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4411 if (cpu_arch >= CPU_ARCH_ARMv6) {
4412 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4413 /* Non-cacheable Normal is XCB = 001 */
4414 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4415 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4416 + PMD_SECT_BUFFERED;
4417 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4418 PMD_SECT_BUFFERED;
4419 } else {
4420 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4421 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4422 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4423 + PMD_SECT_TEX(1);
4424 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4425 PMD_SECT_TEX(1);
4426 }
4427 } else {
4428 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4429 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4430 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4431 }
4432
4433 #ifdef CONFIG_ARM_LPAE
4434 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4435 vecs_pgprot |= PTE_EXT_AF;
4436 #endif
4437
4438 + user_pgprot |= __supported_pte_mask;
4439 +
4440 for (i = 0; i < 16; i++) {
4441 pteval_t v = pgprot_val(protection_map[i]);
4442 protection_map[i] = __pgprot(v | user_pgprot);
4443 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4444
4445 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4446 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4447 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4448 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4449 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4450 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4451 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4452 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4453 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4454 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4455 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4456 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4457 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4458 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4459 mem_types[MT_ROM].prot_sect |= cp->pmd;
4460
4461 switch (cp->pmd) {
4462 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4463 * called function. This means you can't use any function or debugging
4464 * method which may touch any device, otherwise the kernel _will_ crash.
4465 */
4466 +
4467 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4468 +
4469 static void __init devicemaps_init(struct machine_desc *mdesc)
4470 {
4471 struct map_desc map;
4472 unsigned long addr;
4473 - void *vectors;
4474
4475 - /*
4476 - * Allocate the vector page early.
4477 - */
4478 - vectors = early_alloc(PAGE_SIZE * 2);
4479 -
4480 - early_trap_init(vectors);
4481 + early_trap_init(&vectors);
4482
4483 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4484 pmd_clear(pmd_off_k(addr));
4485 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4486 * location (0xffff0000). If we aren't using high-vectors, also
4487 * create a mapping at the low-vectors virtual address.
4488 */
4489 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4490 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4491 map.virtual = 0xffff0000;
4492 map.length = PAGE_SIZE;
4493 #ifdef CONFIG_KUSER_HELPERS
4494 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4495 map.pfn = __phys_to_pfn(start);
4496 map.virtual = __phys_to_virt(start);
4497 map.length = end - start;
4498 - map.type = MT_MEMORY;
4499
4500 +#ifdef CONFIG_PAX_KERNEXEC
4501 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4502 + struct map_desc kernel;
4503 + struct map_desc initmap;
4504 +
4505 + /* when freeing initmem we will make this RW */
4506 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4507 + initmap.virtual = (unsigned long)__init_begin;
4508 + initmap.length = _sdata - __init_begin;
4509 + initmap.type = MT_MEMORY_RWX;
4510 + create_mapping(&initmap);
4511 +
4512 + /* when freeing initmem we will make this RX */
4513 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4514 + kernel.virtual = (unsigned long)_stext;
4515 + kernel.length = __init_begin - _stext;
4516 + kernel.type = MT_MEMORY_RWX;
4517 + create_mapping(&kernel);
4518 +
4519 + if (map.virtual < (unsigned long)_stext) {
4520 + map.length = (unsigned long)_stext - map.virtual;
4521 + map.type = MT_MEMORY_RWX;
4522 + create_mapping(&map);
4523 + }
4524 +
4525 + map.pfn = __phys_to_pfn(__pa(_sdata));
4526 + map.virtual = (unsigned long)_sdata;
4527 + map.length = end - __pa(_sdata);
4528 + }
4529 +#endif
4530 +
4531 + map.type = MT_MEMORY_RW;
4532 create_mapping(&map);
4533 }
4534 }
4535 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4536 index a5bc92d..0bb4730 100644
4537 --- a/arch/arm/plat-omap/sram.c
4538 +++ b/arch/arm/plat-omap/sram.c
4539 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4540 * Looks like we need to preserve some bootloader code at the
4541 * beginning of SRAM for jumping to flash for reboot to work...
4542 */
4543 + pax_open_kernel();
4544 memset_io(omap_sram_base + omap_sram_skip, 0,
4545 omap_sram_size - omap_sram_skip);
4546 + pax_close_kernel();
4547 }
4548 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4549 index ce6d763..cfea917 100644
4550 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4551 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4552 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4553 int (*started)(unsigned ch);
4554 int (*flush)(unsigned ch);
4555 int (*stop)(unsigned ch);
4556 -};
4557 +} __no_const;
4558
4559 extern void *samsung_dmadev_get_ops(void);
4560 extern void *s3c_dma_get_ops(void);
4561 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4562 index c3a58a1..78fbf54 100644
4563 --- a/arch/avr32/include/asm/cache.h
4564 +++ b/arch/avr32/include/asm/cache.h
4565 @@ -1,8 +1,10 @@
4566 #ifndef __ASM_AVR32_CACHE_H
4567 #define __ASM_AVR32_CACHE_H
4568
4569 +#include <linux/const.h>
4570 +
4571 #define L1_CACHE_SHIFT 5
4572 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4573 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4574
4575 /*
4576 * Memory returned by kmalloc() may be used for DMA, so we must make
4577 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4578 index d232888..87c8df1 100644
4579 --- a/arch/avr32/include/asm/elf.h
4580 +++ b/arch/avr32/include/asm/elf.h
4581 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4582 the loader. We need to make sure that it is out of the way of the program
4583 that it will "exec", and that there is sufficient room for the brk. */
4584
4585 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4586 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4587
4588 +#ifdef CONFIG_PAX_ASLR
4589 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4590 +
4591 +#define PAX_DELTA_MMAP_LEN 15
4592 +#define PAX_DELTA_STACK_LEN 15
4593 +#endif
4594
4595 /* This yields a mask that user programs can use to figure out what
4596 instruction set this CPU supports. This could be done in user space,
4597 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4598 index 479330b..53717a8 100644
4599 --- a/arch/avr32/include/asm/kmap_types.h
4600 +++ b/arch/avr32/include/asm/kmap_types.h
4601 @@ -2,9 +2,9 @@
4602 #define __ASM_AVR32_KMAP_TYPES_H
4603
4604 #ifdef CONFIG_DEBUG_HIGHMEM
4605 -# define KM_TYPE_NR 29
4606 +# define KM_TYPE_NR 30
4607 #else
4608 -# define KM_TYPE_NR 14
4609 +# define KM_TYPE_NR 15
4610 #endif
4611
4612 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4613 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4614 index b2f2d2d..d1c85cb 100644
4615 --- a/arch/avr32/mm/fault.c
4616 +++ b/arch/avr32/mm/fault.c
4617 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4618
4619 int exception_trace = 1;
4620
4621 +#ifdef CONFIG_PAX_PAGEEXEC
4622 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4623 +{
4624 + unsigned long i;
4625 +
4626 + printk(KERN_ERR "PAX: bytes at PC: ");
4627 + for (i = 0; i < 20; i++) {
4628 + unsigned char c;
4629 + if (get_user(c, (unsigned char *)pc+i))
4630 + printk(KERN_CONT "???????? ");
4631 + else
4632 + printk(KERN_CONT "%02x ", c);
4633 + }
4634 + printk("\n");
4635 +}
4636 +#endif
4637 +
4638 /*
4639 * This routine handles page faults. It determines the address and the
4640 * problem, and then passes it off to one of the appropriate routines.
4641 @@ -174,6 +191,16 @@ bad_area:
4642 up_read(&mm->mmap_sem);
4643
4644 if (user_mode(regs)) {
4645 +
4646 +#ifdef CONFIG_PAX_PAGEEXEC
4647 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4648 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4649 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4650 + do_group_exit(SIGKILL);
4651 + }
4652 + }
4653 +#endif
4654 +
4655 if (exception_trace && printk_ratelimit())
4656 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4657 "sp %08lx ecr %lu\n",
4658 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4659 index 568885a..f8008df 100644
4660 --- a/arch/blackfin/include/asm/cache.h
4661 +++ b/arch/blackfin/include/asm/cache.h
4662 @@ -7,6 +7,7 @@
4663 #ifndef __ARCH_BLACKFIN_CACHE_H
4664 #define __ARCH_BLACKFIN_CACHE_H
4665
4666 +#include <linux/const.h>
4667 #include <linux/linkage.h> /* for asmlinkage */
4668
4669 /*
4670 @@ -14,7 +15,7 @@
4671 * Blackfin loads 32 bytes for cache
4672 */
4673 #define L1_CACHE_SHIFT 5
4674 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4675 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4676 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4677
4678 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4679 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4680 index aea2718..3639a60 100644
4681 --- a/arch/cris/include/arch-v10/arch/cache.h
4682 +++ b/arch/cris/include/arch-v10/arch/cache.h
4683 @@ -1,8 +1,9 @@
4684 #ifndef _ASM_ARCH_CACHE_H
4685 #define _ASM_ARCH_CACHE_H
4686
4687 +#include <linux/const.h>
4688 /* Etrax 100LX have 32-byte cache-lines. */
4689 -#define L1_CACHE_BYTES 32
4690 #define L1_CACHE_SHIFT 5
4691 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4692
4693 #endif /* _ASM_ARCH_CACHE_H */
4694 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4695 index 7caf25d..ee65ac5 100644
4696 --- a/arch/cris/include/arch-v32/arch/cache.h
4697 +++ b/arch/cris/include/arch-v32/arch/cache.h
4698 @@ -1,11 +1,12 @@
4699 #ifndef _ASM_CRIS_ARCH_CACHE_H
4700 #define _ASM_CRIS_ARCH_CACHE_H
4701
4702 +#include <linux/const.h>
4703 #include <arch/hwregs/dma.h>
4704
4705 /* A cache-line is 32 bytes. */
4706 -#define L1_CACHE_BYTES 32
4707 #define L1_CACHE_SHIFT 5
4708 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4709
4710 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4711
4712 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4713 index b86329d..6709906 100644
4714 --- a/arch/frv/include/asm/atomic.h
4715 +++ b/arch/frv/include/asm/atomic.h
4716 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4717 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4718 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4719
4720 +#define atomic64_read_unchecked(v) atomic64_read(v)
4721 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4722 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4723 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4724 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4725 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4726 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4727 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4728 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4729 +
4730 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4731 {
4732 int c, old;
4733 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4734 index 2797163..c2a401d 100644
4735 --- a/arch/frv/include/asm/cache.h
4736 +++ b/arch/frv/include/asm/cache.h
4737 @@ -12,10 +12,11 @@
4738 #ifndef __ASM_CACHE_H
4739 #define __ASM_CACHE_H
4740
4741 +#include <linux/const.h>
4742
4743 /* bytes per L1 cache line */
4744 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4745 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4746 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4747
4748 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4749 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4750 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4751 index 43901f2..0d8b865 100644
4752 --- a/arch/frv/include/asm/kmap_types.h
4753 +++ b/arch/frv/include/asm/kmap_types.h
4754 @@ -2,6 +2,6 @@
4755 #ifndef _ASM_KMAP_TYPES_H
4756 #define _ASM_KMAP_TYPES_H
4757
4758 -#define KM_TYPE_NR 17
4759 +#define KM_TYPE_NR 18
4760
4761 #endif
4762 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4763 index 836f147..4cf23f5 100644
4764 --- a/arch/frv/mm/elf-fdpic.c
4765 +++ b/arch/frv/mm/elf-fdpic.c
4766 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4767 {
4768 struct vm_area_struct *vma;
4769 struct vm_unmapped_area_info info;
4770 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4771
4772 if (len > TASK_SIZE)
4773 return -ENOMEM;
4774 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4775 if (addr) {
4776 addr = PAGE_ALIGN(addr);
4777 vma = find_vma(current->mm, addr);
4778 - if (TASK_SIZE - len >= addr &&
4779 - (!vma || addr + len <= vma->vm_start))
4780 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4781 goto success;
4782 }
4783
4784 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4785 info.high_limit = (current->mm->start_stack - 0x00200000);
4786 info.align_mask = 0;
4787 info.align_offset = 0;
4788 + info.threadstack_offset = offset;
4789 addr = vm_unmapped_area(&info);
4790 if (!(addr & ~PAGE_MASK))
4791 goto success;
4792 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4793 index f4ca594..adc72fd6 100644
4794 --- a/arch/hexagon/include/asm/cache.h
4795 +++ b/arch/hexagon/include/asm/cache.h
4796 @@ -21,9 +21,11 @@
4797 #ifndef __ASM_CACHE_H
4798 #define __ASM_CACHE_H
4799
4800 +#include <linux/const.h>
4801 +
4802 /* Bytes per L1 cache line */
4803 -#define L1_CACHE_SHIFT (5)
4804 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4805 +#define L1_CACHE_SHIFT 5
4806 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4807
4808 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4809 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4810 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4811 index 6e6fe18..a6ae668 100644
4812 --- a/arch/ia64/include/asm/atomic.h
4813 +++ b/arch/ia64/include/asm/atomic.h
4814 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4815 #define atomic64_inc(v) atomic64_add(1, (v))
4816 #define atomic64_dec(v) atomic64_sub(1, (v))
4817
4818 +#define atomic64_read_unchecked(v) atomic64_read(v)
4819 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4820 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4821 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4822 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4823 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4824 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4825 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4826 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4827 +
4828 /* Atomic operations are already serializing */
4829 #define smp_mb__before_atomic_dec() barrier()
4830 #define smp_mb__after_atomic_dec() barrier()
4831 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4832 index 988254a..e1ee885 100644
4833 --- a/arch/ia64/include/asm/cache.h
4834 +++ b/arch/ia64/include/asm/cache.h
4835 @@ -1,6 +1,7 @@
4836 #ifndef _ASM_IA64_CACHE_H
4837 #define _ASM_IA64_CACHE_H
4838
4839 +#include <linux/const.h>
4840
4841 /*
4842 * Copyright (C) 1998-2000 Hewlett-Packard Co
4843 @@ -9,7 +10,7 @@
4844
4845 /* Bytes per L1 (data) cache line. */
4846 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4847 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4848 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4849
4850 #ifdef CONFIG_SMP
4851 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4852 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4853 index 5a83c5c..4d7f553 100644
4854 --- a/arch/ia64/include/asm/elf.h
4855 +++ b/arch/ia64/include/asm/elf.h
4856 @@ -42,6 +42,13 @@
4857 */
4858 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4859
4860 +#ifdef CONFIG_PAX_ASLR
4861 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4862 +
4863 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4864 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4865 +#endif
4866 +
4867 #define PT_IA_64_UNWIND 0x70000001
4868
4869 /* IA-64 relocations: */
4870 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4871 index 96a8d92..617a1cf 100644
4872 --- a/arch/ia64/include/asm/pgalloc.h
4873 +++ b/arch/ia64/include/asm/pgalloc.h
4874 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4875 pgd_val(*pgd_entry) = __pa(pud);
4876 }
4877
4878 +static inline void
4879 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4880 +{
4881 + pgd_populate(mm, pgd_entry, pud);
4882 +}
4883 +
4884 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4885 {
4886 return quicklist_alloc(0, GFP_KERNEL, NULL);
4887 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4888 pud_val(*pud_entry) = __pa(pmd);
4889 }
4890
4891 +static inline void
4892 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4893 +{
4894 + pud_populate(mm, pud_entry, pmd);
4895 +}
4896 +
4897 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4898 {
4899 return quicklist_alloc(0, GFP_KERNEL, NULL);
4900 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4901 index 7935115..c0eca6a 100644
4902 --- a/arch/ia64/include/asm/pgtable.h
4903 +++ b/arch/ia64/include/asm/pgtable.h
4904 @@ -12,7 +12,7 @@
4905 * David Mosberger-Tang <davidm@hpl.hp.com>
4906 */
4907
4908 -
4909 +#include <linux/const.h>
4910 #include <asm/mman.h>
4911 #include <asm/page.h>
4912 #include <asm/processor.h>
4913 @@ -142,6 +142,17 @@
4914 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4915 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4916 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4917 +
4918 +#ifdef CONFIG_PAX_PAGEEXEC
4919 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4920 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4921 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4922 +#else
4923 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4924 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4925 +# define PAGE_COPY_NOEXEC PAGE_COPY
4926 +#endif
4927 +
4928 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4929 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4930 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4931 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4932 index 54ff557..70c88b7 100644
4933 --- a/arch/ia64/include/asm/spinlock.h
4934 +++ b/arch/ia64/include/asm/spinlock.h
4935 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4936 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4937
4938 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4939 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4940 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4941 }
4942
4943 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4944 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4945 index 449c8c0..18965fb 100644
4946 --- a/arch/ia64/include/asm/uaccess.h
4947 +++ b/arch/ia64/include/asm/uaccess.h
4948 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4949 static inline unsigned long
4950 __copy_to_user (void __user *to, const void *from, unsigned long count)
4951 {
4952 + if (count > INT_MAX)
4953 + return count;
4954 +
4955 + if (!__builtin_constant_p(count))
4956 + check_object_size(from, count, true);
4957 +
4958 return __copy_user(to, (__force void __user *) from, count);
4959 }
4960
4961 static inline unsigned long
4962 __copy_from_user (void *to, const void __user *from, unsigned long count)
4963 {
4964 + if (count > INT_MAX)
4965 + return count;
4966 +
4967 + if (!__builtin_constant_p(count))
4968 + check_object_size(to, count, false);
4969 +
4970 return __copy_user((__force void __user *) to, from, count);
4971 }
4972
4973 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4974 ({ \
4975 void __user *__cu_to = (to); \
4976 const void *__cu_from = (from); \
4977 - long __cu_len = (n); \
4978 + unsigned long __cu_len = (n); \
4979 \
4980 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4981 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4982 + if (!__builtin_constant_p(n)) \
4983 + check_object_size(__cu_from, __cu_len, true); \
4984 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4985 + } \
4986 __cu_len; \
4987 })
4988
4989 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4990 ({ \
4991 void *__cu_to = (to); \
4992 const void __user *__cu_from = (from); \
4993 - long __cu_len = (n); \
4994 + unsigned long __cu_len = (n); \
4995 \
4996 __chk_user_ptr(__cu_from); \
4997 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4998 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4999 + if (!__builtin_constant_p(n)) \
5000 + check_object_size(__cu_to, __cu_len, false); \
5001 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5002 + } \
5003 __cu_len; \
5004 })
5005
5006 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5007 index 24603be..948052d 100644
5008 --- a/arch/ia64/kernel/module.c
5009 +++ b/arch/ia64/kernel/module.c
5010 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5011 void
5012 module_free (struct module *mod, void *module_region)
5013 {
5014 - if (mod && mod->arch.init_unw_table &&
5015 - module_region == mod->module_init) {
5016 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5017 unw_remove_unwind_table(mod->arch.init_unw_table);
5018 mod->arch.init_unw_table = NULL;
5019 }
5020 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5021 }
5022
5023 static inline int
5024 +in_init_rx (const struct module *mod, uint64_t addr)
5025 +{
5026 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5027 +}
5028 +
5029 +static inline int
5030 +in_init_rw (const struct module *mod, uint64_t addr)
5031 +{
5032 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5033 +}
5034 +
5035 +static inline int
5036 in_init (const struct module *mod, uint64_t addr)
5037 {
5038 - return addr - (uint64_t) mod->module_init < mod->init_size;
5039 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5040 +}
5041 +
5042 +static inline int
5043 +in_core_rx (const struct module *mod, uint64_t addr)
5044 +{
5045 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5046 +}
5047 +
5048 +static inline int
5049 +in_core_rw (const struct module *mod, uint64_t addr)
5050 +{
5051 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5052 }
5053
5054 static inline int
5055 in_core (const struct module *mod, uint64_t addr)
5056 {
5057 - return addr - (uint64_t) mod->module_core < mod->core_size;
5058 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5059 }
5060
5061 static inline int
5062 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5063 break;
5064
5065 case RV_BDREL:
5066 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5067 + if (in_init_rx(mod, val))
5068 + val -= (uint64_t) mod->module_init_rx;
5069 + else if (in_init_rw(mod, val))
5070 + val -= (uint64_t) mod->module_init_rw;
5071 + else if (in_core_rx(mod, val))
5072 + val -= (uint64_t) mod->module_core_rx;
5073 + else if (in_core_rw(mod, val))
5074 + val -= (uint64_t) mod->module_core_rw;
5075 break;
5076
5077 case RV_LTV:
5078 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5079 * addresses have been selected...
5080 */
5081 uint64_t gp;
5082 - if (mod->core_size > MAX_LTOFF)
5083 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5084 /*
5085 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5086 * at the end of the module.
5087 */
5088 - gp = mod->core_size - MAX_LTOFF / 2;
5089 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5090 else
5091 - gp = mod->core_size / 2;
5092 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5093 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5094 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5095 mod->arch.gp = gp;
5096 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5097 }
5098 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5099 index ab33328..f39506c 100644
5100 --- a/arch/ia64/kernel/palinfo.c
5101 +++ b/arch/ia64/kernel/palinfo.c
5102 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5103 return NOTIFY_OK;
5104 }
5105
5106 -static struct notifier_block __refdata palinfo_cpu_notifier =
5107 +static struct notifier_block palinfo_cpu_notifier =
5108 {
5109 .notifier_call = palinfo_cpu_callback,
5110 .priority = 0,
5111 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5112 index 41e33f8..65180b2 100644
5113 --- a/arch/ia64/kernel/sys_ia64.c
5114 +++ b/arch/ia64/kernel/sys_ia64.c
5115 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5116 unsigned long align_mask = 0;
5117 struct mm_struct *mm = current->mm;
5118 struct vm_unmapped_area_info info;
5119 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5120
5121 if (len > RGN_MAP_LIMIT)
5122 return -ENOMEM;
5123 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5124 if (REGION_NUMBER(addr) == RGN_HPAGE)
5125 addr = 0;
5126 #endif
5127 +
5128 +#ifdef CONFIG_PAX_RANDMMAP
5129 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5130 + addr = mm->free_area_cache;
5131 + else
5132 +#endif
5133 +
5134 if (!addr)
5135 addr = TASK_UNMAPPED_BASE;
5136
5137 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5138 info.high_limit = TASK_SIZE;
5139 info.align_mask = align_mask;
5140 info.align_offset = 0;
5141 + info.threadstack_offset = offset;
5142 return vm_unmapped_area(&info);
5143 }
5144
5145 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5146 index 0ccb28f..8992469 100644
5147 --- a/arch/ia64/kernel/vmlinux.lds.S
5148 +++ b/arch/ia64/kernel/vmlinux.lds.S
5149 @@ -198,7 +198,7 @@ SECTIONS {
5150 /* Per-cpu data: */
5151 . = ALIGN(PERCPU_PAGE_SIZE);
5152 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5153 - __phys_per_cpu_start = __per_cpu_load;
5154 + __phys_per_cpu_start = per_cpu_load;
5155 /*
5156 * ensure percpu data fits
5157 * into percpu page size
5158 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5159 index 6cf0341..d352594 100644
5160 --- a/arch/ia64/mm/fault.c
5161 +++ b/arch/ia64/mm/fault.c
5162 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5163 return pte_present(pte);
5164 }
5165
5166 +#ifdef CONFIG_PAX_PAGEEXEC
5167 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5168 +{
5169 + unsigned long i;
5170 +
5171 + printk(KERN_ERR "PAX: bytes at PC: ");
5172 + for (i = 0; i < 8; i++) {
5173 + unsigned int c;
5174 + if (get_user(c, (unsigned int *)pc+i))
5175 + printk(KERN_CONT "???????? ");
5176 + else
5177 + printk(KERN_CONT "%08x ", c);
5178 + }
5179 + printk("\n");
5180 +}
5181 +#endif
5182 +
5183 # define VM_READ_BIT 0
5184 # define VM_WRITE_BIT 1
5185 # define VM_EXEC_BIT 2
5186 @@ -149,8 +166,21 @@ retry:
5187 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5188 goto bad_area;
5189
5190 - if ((vma->vm_flags & mask) != mask)
5191 + if ((vma->vm_flags & mask) != mask) {
5192 +
5193 +#ifdef CONFIG_PAX_PAGEEXEC
5194 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5195 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5196 + goto bad_area;
5197 +
5198 + up_read(&mm->mmap_sem);
5199 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5200 + do_group_exit(SIGKILL);
5201 + }
5202 +#endif
5203 +
5204 goto bad_area;
5205 + }
5206
5207 /*
5208 * If for any reason at all we couldn't handle the fault, make
5209 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5210 index 76069c1..c2aa816 100644
5211 --- a/arch/ia64/mm/hugetlbpage.c
5212 +++ b/arch/ia64/mm/hugetlbpage.c
5213 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5214 unsigned long pgoff, unsigned long flags)
5215 {
5216 struct vm_unmapped_area_info info;
5217 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5218
5219 if (len > RGN_MAP_LIMIT)
5220 return -ENOMEM;
5221 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5222 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5223 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5224 info.align_offset = 0;
5225 + info.threadstack_offset = offset;
5226 return vm_unmapped_area(&info);
5227 }
5228
5229 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5230 index b6f7f43..c04320d 100644
5231 --- a/arch/ia64/mm/init.c
5232 +++ b/arch/ia64/mm/init.c
5233 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5234 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5235 vma->vm_end = vma->vm_start + PAGE_SIZE;
5236 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5237 +
5238 +#ifdef CONFIG_PAX_PAGEEXEC
5239 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5240 + vma->vm_flags &= ~VM_EXEC;
5241 +
5242 +#ifdef CONFIG_PAX_MPROTECT
5243 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5244 + vma->vm_flags &= ~VM_MAYEXEC;
5245 +#endif
5246 +
5247 + }
5248 +#endif
5249 +
5250 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5251 down_write(&current->mm->mmap_sem);
5252 if (insert_vm_struct(current->mm, vma)) {
5253 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5254 index 40b3ee9..8c2c112 100644
5255 --- a/arch/m32r/include/asm/cache.h
5256 +++ b/arch/m32r/include/asm/cache.h
5257 @@ -1,8 +1,10 @@
5258 #ifndef _ASM_M32R_CACHE_H
5259 #define _ASM_M32R_CACHE_H
5260
5261 +#include <linux/const.h>
5262 +
5263 /* L1 cache line size */
5264 #define L1_CACHE_SHIFT 4
5265 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5266 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5267
5268 #endif /* _ASM_M32R_CACHE_H */
5269 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5270 index 82abd15..d95ae5d 100644
5271 --- a/arch/m32r/lib/usercopy.c
5272 +++ b/arch/m32r/lib/usercopy.c
5273 @@ -14,6 +14,9 @@
5274 unsigned long
5275 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5276 {
5277 + if ((long)n < 0)
5278 + return n;
5279 +
5280 prefetch(from);
5281 if (access_ok(VERIFY_WRITE, to, n))
5282 __copy_user(to,from,n);
5283 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5284 unsigned long
5285 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5286 {
5287 + if ((long)n < 0)
5288 + return n;
5289 +
5290 prefetchw(to);
5291 if (access_ok(VERIFY_READ, from, n))
5292 __copy_user_zeroing(to,from,n);
5293 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5294 index 0395c51..5f26031 100644
5295 --- a/arch/m68k/include/asm/cache.h
5296 +++ b/arch/m68k/include/asm/cache.h
5297 @@ -4,9 +4,11 @@
5298 #ifndef __ARCH_M68K_CACHE_H
5299 #define __ARCH_M68K_CACHE_H
5300
5301 +#include <linux/const.h>
5302 +
5303 /* bytes per L1 cache line */
5304 #define L1_CACHE_SHIFT 4
5305 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5306 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5307
5308 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5309
5310 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5311 index 3c52fa6..11b2ad8 100644
5312 --- a/arch/metag/mm/hugetlbpage.c
5313 +++ b/arch/metag/mm/hugetlbpage.c
5314 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5315 info.high_limit = TASK_SIZE;
5316 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5317 info.align_offset = 0;
5318 + info.threadstack_offset = 0;
5319 return vm_unmapped_area(&info);
5320 }
5321
5322 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5323 index 4efe96a..60e8699 100644
5324 --- a/arch/microblaze/include/asm/cache.h
5325 +++ b/arch/microblaze/include/asm/cache.h
5326 @@ -13,11 +13,12 @@
5327 #ifndef _ASM_MICROBLAZE_CACHE_H
5328 #define _ASM_MICROBLAZE_CACHE_H
5329
5330 +#include <linux/const.h>
5331 #include <asm/registers.h>
5332
5333 #define L1_CACHE_SHIFT 5
5334 /* word-granular cache in microblaze */
5335 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5336 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5337
5338 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5339
5340 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5341 index 08b6079..8b554d2 100644
5342 --- a/arch/mips/include/asm/atomic.h
5343 +++ b/arch/mips/include/asm/atomic.h
5344 @@ -21,15 +21,39 @@
5345 #include <asm/cmpxchg.h>
5346 #include <asm/war.h>
5347
5348 +#ifdef CONFIG_GENERIC_ATOMIC64
5349 +#include <asm-generic/atomic64.h>
5350 +#endif
5351 +
5352 #define ATOMIC_INIT(i) { (i) }
5353
5354 +#ifdef CONFIG_64BIT
5355 +#define _ASM_EXTABLE(from, to) \
5356 +" .section __ex_table,\"a\"\n" \
5357 +" .dword " #from ", " #to"\n" \
5358 +" .previous\n"
5359 +#else
5360 +#define _ASM_EXTABLE(from, to) \
5361 +" .section __ex_table,\"a\"\n" \
5362 +" .word " #from ", " #to"\n" \
5363 +" .previous\n"
5364 +#endif
5365 +
5366 /*
5367 * atomic_read - read atomic variable
5368 * @v: pointer of type atomic_t
5369 *
5370 * Atomically reads the value of @v.
5371 */
5372 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5373 +static inline int atomic_read(const atomic_t *v)
5374 +{
5375 + return (*(volatile const int *) &v->counter);
5376 +}
5377 +
5378 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5379 +{
5380 + return (*(volatile const int *) &v->counter);
5381 +}
5382
5383 /*
5384 * atomic_set - set atomic variable
5385 @@ -38,7 +62,15 @@
5386 *
5387 * Atomically sets the value of @v to @i.
5388 */
5389 -#define atomic_set(v, i) ((v)->counter = (i))
5390 +static inline void atomic_set(atomic_t *v, int i)
5391 +{
5392 + v->counter = i;
5393 +}
5394 +
5395 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5396 +{
5397 + v->counter = i;
5398 +}
5399
5400 /*
5401 * atomic_add - add integer to atomic variable
5402 @@ -47,7 +79,67 @@
5403 *
5404 * Atomically adds @i to @v.
5405 */
5406 -static __inline__ void atomic_add(int i, atomic_t * v)
5407 +static __inline__ void atomic_add(int i, atomic_t *v)
5408 +{
5409 + int temp;
5410 +
5411 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5412 + __asm__ __volatile__(
5413 + " .set mips3 \n"
5414 + "1: ll %0, %1 # atomic_add \n"
5415 +#ifdef CONFIG_PAX_REFCOUNT
5416 + /* Exception on overflow. */
5417 + "2: add %0, %2 \n"
5418 +#else
5419 + " addu %0, %2 \n"
5420 +#endif
5421 + " sc %0, %1 \n"
5422 + " beqzl %0, 1b \n"
5423 +#ifdef CONFIG_PAX_REFCOUNT
5424 + "3: \n"
5425 + _ASM_EXTABLE(2b, 3b)
5426 +#endif
5427 + " .set mips0 \n"
5428 + : "=&r" (temp), "+m" (v->counter)
5429 + : "Ir" (i));
5430 + } else if (kernel_uses_llsc) {
5431 + __asm__ __volatile__(
5432 + " .set mips3 \n"
5433 + "1: ll %0, %1 # atomic_add \n"
5434 +#ifdef CONFIG_PAX_REFCOUNT
5435 + /* Exception on overflow. */
5436 + "2: add %0, %2 \n"
5437 +#else
5438 + " addu %0, %2 \n"
5439 +#endif
5440 + " sc %0, %1 \n"
5441 + " beqz %0, 1b \n"
5442 +#ifdef CONFIG_PAX_REFCOUNT
5443 + "3: \n"
5444 + _ASM_EXTABLE(2b, 3b)
5445 +#endif
5446 + " .set mips0 \n"
5447 + : "=&r" (temp), "+m" (v->counter)
5448 + : "Ir" (i));
5449 + } else {
5450 + unsigned long flags;
5451 +
5452 + raw_local_irq_save(flags);
5453 + __asm__ __volatile__(
5454 +#ifdef CONFIG_PAX_REFCOUNT
5455 + /* Exception on overflow. */
5456 + "1: add %0, %1 \n"
5457 + "2: \n"
5458 + _ASM_EXTABLE(1b, 2b)
5459 +#else
5460 + " addu %0, %1 \n"
5461 +#endif
5462 + : "+r" (v->counter) : "Ir" (i));
5463 + raw_local_irq_restore(flags);
5464 + }
5465 +}
5466 +
5467 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5468 {
5469 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5470 int temp;
5471 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5472 *
5473 * Atomically subtracts @i from @v.
5474 */
5475 -static __inline__ void atomic_sub(int i, atomic_t * v)
5476 +static __inline__ void atomic_sub(int i, atomic_t *v)
5477 +{
5478 + int temp;
5479 +
5480 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5481 + __asm__ __volatile__(
5482 + " .set mips3 \n"
5483 + "1: ll %0, %1 # atomic64_sub \n"
5484 +#ifdef CONFIG_PAX_REFCOUNT
5485 + /* Exception on overflow. */
5486 + "2: sub %0, %2 \n"
5487 +#else
5488 + " subu %0, %2 \n"
5489 +#endif
5490 + " sc %0, %1 \n"
5491 + " beqzl %0, 1b \n"
5492 +#ifdef CONFIG_PAX_REFCOUNT
5493 + "3: \n"
5494 + _ASM_EXTABLE(2b, 3b)
5495 +#endif
5496 + " .set mips0 \n"
5497 + : "=&r" (temp), "+m" (v->counter)
5498 + : "Ir" (i));
5499 + } else if (kernel_uses_llsc) {
5500 + __asm__ __volatile__(
5501 + " .set mips3 \n"
5502 + "1: ll %0, %1 # atomic64_sub \n"
5503 +#ifdef CONFIG_PAX_REFCOUNT
5504 + /* Exception on overflow. */
5505 + "2: sub %0, %2 \n"
5506 +#else
5507 + " subu %0, %2 \n"
5508 +#endif
5509 + " sc %0, %1 \n"
5510 + " beqz %0, 1b \n"
5511 +#ifdef CONFIG_PAX_REFCOUNT
5512 + "3: \n"
5513 + _ASM_EXTABLE(2b, 3b)
5514 +#endif
5515 + " .set mips0 \n"
5516 + : "=&r" (temp), "+m" (v->counter)
5517 + : "Ir" (i));
5518 + } else {
5519 + unsigned long flags;
5520 +
5521 + raw_local_irq_save(flags);
5522 + __asm__ __volatile__(
5523 +#ifdef CONFIG_PAX_REFCOUNT
5524 + /* Exception on overflow. */
5525 + "1: sub %0, %1 \n"
5526 + "2: \n"
5527 + _ASM_EXTABLE(1b, 2b)
5528 +#else
5529 + " subu %0, %1 \n"
5530 +#endif
5531 + : "+r" (v->counter) : "Ir" (i));
5532 + raw_local_irq_restore(flags);
5533 + }
5534 +}
5535 +
5536 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5537 {
5538 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5539 int temp;
5540 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5541 /*
5542 * Same as above, but return the result value
5543 */
5544 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5545 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5546 +{
5547 + int result;
5548 + int temp;
5549 +
5550 + smp_mb__before_llsc();
5551 +
5552 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5553 + __asm__ __volatile__(
5554 + " .set mips3 \n"
5555 + "1: ll %1, %2 # atomic_add_return \n"
5556 +#ifdef CONFIG_PAX_REFCOUNT
5557 + "2: add %0, %1, %3 \n"
5558 +#else
5559 + " addu %0, %1, %3 \n"
5560 +#endif
5561 + " sc %0, %2 \n"
5562 + " beqzl %0, 1b \n"
5563 +#ifdef CONFIG_PAX_REFCOUNT
5564 + " b 4f \n"
5565 + " .set noreorder \n"
5566 + "3: b 5f \n"
5567 + " move %0, %1 \n"
5568 + " .set reorder \n"
5569 + _ASM_EXTABLE(2b, 3b)
5570 +#endif
5571 + "4: addu %0, %1, %3 \n"
5572 +#ifdef CONFIG_PAX_REFCOUNT
5573 + "5: \n"
5574 +#endif
5575 + " .set mips0 \n"
5576 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5577 + : "Ir" (i));
5578 + } else if (kernel_uses_llsc) {
5579 + __asm__ __volatile__(
5580 + " .set mips3 \n"
5581 + "1: ll %1, %2 # atomic_add_return \n"
5582 +#ifdef CONFIG_PAX_REFCOUNT
5583 + "2: add %0, %1, %3 \n"
5584 +#else
5585 + " addu %0, %1, %3 \n"
5586 +#endif
5587 + " sc %0, %2 \n"
5588 + " bnez %0, 4f \n"
5589 + " b 1b \n"
5590 +#ifdef CONFIG_PAX_REFCOUNT
5591 + " .set noreorder \n"
5592 + "3: b 5f \n"
5593 + " move %0, %1 \n"
5594 + " .set reorder \n"
5595 + _ASM_EXTABLE(2b, 3b)
5596 +#endif
5597 + "4: addu %0, %1, %3 \n"
5598 +#ifdef CONFIG_PAX_REFCOUNT
5599 + "5: \n"
5600 +#endif
5601 + " .set mips0 \n"
5602 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5603 + : "Ir" (i));
5604 + } else {
5605 + unsigned long flags;
5606 +
5607 + raw_local_irq_save(flags);
5608 + __asm__ __volatile__(
5609 + " lw %0, %1 \n"
5610 +#ifdef CONFIG_PAX_REFCOUNT
5611 + /* Exception on overflow. */
5612 + "1: add %0, %2 \n"
5613 +#else
5614 + " addu %0, %2 \n"
5615 +#endif
5616 + " sw %0, %1 \n"
5617 +#ifdef CONFIG_PAX_REFCOUNT
5618 + /* Note: Dest reg is not modified on overflow */
5619 + "2: \n"
5620 + _ASM_EXTABLE(1b, 2b)
5621 +#endif
5622 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5623 + raw_local_irq_restore(flags);
5624 + }
5625 +
5626 + smp_llsc_mb();
5627 +
5628 + return result;
5629 +}
5630 +
5631 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5632 {
5633 int result;
5634
5635 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5636 return result;
5637 }
5638
5639 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5640 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5641 +{
5642 + int result;
5643 + int temp;
5644 +
5645 + smp_mb__before_llsc();
5646 +
5647 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5648 + __asm__ __volatile__(
5649 + " .set mips3 \n"
5650 + "1: ll %1, %2 # atomic_sub_return \n"
5651 +#ifdef CONFIG_PAX_REFCOUNT
5652 + "2: sub %0, %1, %3 \n"
5653 +#else
5654 + " subu %0, %1, %3 \n"
5655 +#endif
5656 + " sc %0, %2 \n"
5657 + " beqzl %0, 1b \n"
5658 +#ifdef CONFIG_PAX_REFCOUNT
5659 + " b 4f \n"
5660 + " .set noreorder \n"
5661 + "3: b 5f \n"
5662 + " move %0, %1 \n"
5663 + " .set reorder \n"
5664 + _ASM_EXTABLE(2b, 3b)
5665 +#endif
5666 + "4: subu %0, %1, %3 \n"
5667 +#ifdef CONFIG_PAX_REFCOUNT
5668 + "5: \n"
5669 +#endif
5670 + " .set mips0 \n"
5671 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5672 + : "Ir" (i), "m" (v->counter)
5673 + : "memory");
5674 + } else if (kernel_uses_llsc) {
5675 + __asm__ __volatile__(
5676 + " .set mips3 \n"
5677 + "1: ll %1, %2 # atomic_sub_return \n"
5678 +#ifdef CONFIG_PAX_REFCOUNT
5679 + "2: sub %0, %1, %3 \n"
5680 +#else
5681 + " subu %0, %1, %3 \n"
5682 +#endif
5683 + " sc %0, %2 \n"
5684 + " bnez %0, 4f \n"
5685 + " b 1b \n"
5686 +#ifdef CONFIG_PAX_REFCOUNT
5687 + " .set noreorder \n"
5688 + "3: b 5f \n"
5689 + " move %0, %1 \n"
5690 + " .set reorder \n"
5691 + _ASM_EXTABLE(2b, 3b)
5692 +#endif
5693 + "4: subu %0, %1, %3 \n"
5694 +#ifdef CONFIG_PAX_REFCOUNT
5695 + "5: \n"
5696 +#endif
5697 + " .set mips0 \n"
5698 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5699 + : "Ir" (i));
5700 + } else {
5701 + unsigned long flags;
5702 +
5703 + raw_local_irq_save(flags);
5704 + __asm__ __volatile__(
5705 + " lw %0, %1 \n"
5706 +#ifdef CONFIG_PAX_REFCOUNT
5707 + /* Exception on overflow. */
5708 + "1: sub %0, %2 \n"
5709 +#else
5710 + " subu %0, %2 \n"
5711 +#endif
5712 + " sw %0, %1 \n"
5713 +#ifdef CONFIG_PAX_REFCOUNT
5714 + /* Note: Dest reg is not modified on overflow */
5715 + "2: \n"
5716 + _ASM_EXTABLE(1b, 2b)
5717 +#endif
5718 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5719 + raw_local_irq_restore(flags);
5720 + }
5721 +
5722 + smp_llsc_mb();
5723 +
5724 + return result;
5725 +}
5726 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5727 {
5728 int result;
5729
5730 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5731 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5732 * The function returns the old value of @v minus @i.
5733 */
5734 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5735 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5736 {
5737 int result;
5738
5739 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5740 return result;
5741 }
5742
5743 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5744 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5745 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5746 +{
5747 + return cmpxchg(&v->counter, old, new);
5748 +}
5749 +
5750 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5751 + int new)
5752 +{
5753 + return cmpxchg(&(v->counter), old, new);
5754 +}
5755 +
5756 +static inline int atomic_xchg(atomic_t *v, int new)
5757 +{
5758 + return xchg(&v->counter, new);
5759 +}
5760 +
5761 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5762 +{
5763 + return xchg(&(v->counter), new);
5764 +}
5765
5766 /**
5767 * __atomic_add_unless - add unless the number is a given value
5768 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5769
5770 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5771 #define atomic_inc_return(v) atomic_add_return(1, (v))
5772 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5773 +{
5774 + return atomic_add_return_unchecked(1, v);
5775 +}
5776
5777 /*
5778 * atomic_sub_and_test - subtract value from variable and test result
5779 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5780 * other cases.
5781 */
5782 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5783 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5784 +{
5785 + return atomic_add_return_unchecked(1, v) == 0;
5786 +}
5787
5788 /*
5789 * atomic_dec_and_test - decrement by 1 and test
5790 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5791 * Atomically increments @v by 1.
5792 */
5793 #define atomic_inc(v) atomic_add(1, (v))
5794 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5795 +{
5796 + atomic_add_unchecked(1, v);
5797 +}
5798
5799 /*
5800 * atomic_dec - decrement and test
5801 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5802 * Atomically decrements @v by 1.
5803 */
5804 #define atomic_dec(v) atomic_sub(1, (v))
5805 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5806 +{
5807 + atomic_sub_unchecked(1, v);
5808 +}
5809
5810 /*
5811 * atomic_add_negative - add and test if negative
5812 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5813 * @v: pointer of type atomic64_t
5814 *
5815 */
5816 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5817 +static inline long atomic64_read(const atomic64_t *v)
5818 +{
5819 + return (*(volatile const long *) &v->counter);
5820 +}
5821 +
5822 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5823 +{
5824 + return (*(volatile const long *) &v->counter);
5825 +}
5826
5827 /*
5828 * atomic64_set - set atomic variable
5829 * @v: pointer of type atomic64_t
5830 * @i: required value
5831 */
5832 -#define atomic64_set(v, i) ((v)->counter = (i))
5833 +static inline void atomic64_set(atomic64_t *v, long i)
5834 +{
5835 + v->counter = i;
5836 +}
5837 +
5838 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5839 +{
5840 + v->counter = i;
5841 +}
5842
5843 /*
5844 * atomic64_add - add integer to atomic variable
5845 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5846 *
5847 * Atomically adds @i to @v.
5848 */
5849 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5850 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5851 +{
5852 + long temp;
5853 +
5854 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5855 + __asm__ __volatile__(
5856 + " .set mips3 \n"
5857 + "1: lld %0, %1 # atomic64_add \n"
5858 +#ifdef CONFIG_PAX_REFCOUNT
5859 + /* Exception on overflow. */
5860 + "2: dadd %0, %2 \n"
5861 +#else
5862 + " daddu %0, %2 \n"
5863 +#endif
5864 + " scd %0, %1 \n"
5865 + " beqzl %0, 1b \n"
5866 +#ifdef CONFIG_PAX_REFCOUNT
5867 + "3: \n"
5868 + _ASM_EXTABLE(2b, 3b)
5869 +#endif
5870 + " .set mips0 \n"
5871 + : "=&r" (temp), "+m" (v->counter)
5872 + : "Ir" (i));
5873 + } else if (kernel_uses_llsc) {
5874 + __asm__ __volatile__(
5875 + " .set mips3 \n"
5876 + "1: lld %0, %1 # atomic64_add \n"
5877 +#ifdef CONFIG_PAX_REFCOUNT
5878 + /* Exception on overflow. */
5879 + "2: dadd %0, %2 \n"
5880 +#else
5881 + " daddu %0, %2 \n"
5882 +#endif
5883 + " scd %0, %1 \n"
5884 + " beqz %0, 1b \n"
5885 +#ifdef CONFIG_PAX_REFCOUNT
5886 + "3: \n"
5887 + _ASM_EXTABLE(2b, 3b)
5888 +#endif
5889 + " .set mips0 \n"
5890 + : "=&r" (temp), "+m" (v->counter)
5891 + : "Ir" (i));
5892 + } else {
5893 + unsigned long flags;
5894 +
5895 + raw_local_irq_save(flags);
5896 + __asm__ __volatile__(
5897 +#ifdef CONFIG_PAX_REFCOUNT
5898 + /* Exception on overflow. */
5899 + "1: dadd %0, %1 \n"
5900 + "2: \n"
5901 + _ASM_EXTABLE(1b, 2b)
5902 +#else
5903 + " daddu %0, %1 \n"
5904 +#endif
5905 + : "+r" (v->counter) : "Ir" (i));
5906 + raw_local_irq_restore(flags);
5907 + }
5908 +}
5909 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5910 {
5911 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5912 long temp;
5913 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5914 *
5915 * Atomically subtracts @i from @v.
5916 */
5917 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5918 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5919 +{
5920 + long temp;
5921 +
5922 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5923 + __asm__ __volatile__(
5924 + " .set mips3 \n"
5925 + "1: lld %0, %1 # atomic64_sub \n"
5926 +#ifdef CONFIG_PAX_REFCOUNT
5927 + /* Exception on overflow. */
5928 + "2: dsub %0, %2 \n"
5929 +#else
5930 + " dsubu %0, %2 \n"
5931 +#endif
5932 + " scd %0, %1 \n"
5933 + " beqzl %0, 1b \n"
5934 +#ifdef CONFIG_PAX_REFCOUNT
5935 + "3: \n"
5936 + _ASM_EXTABLE(2b, 3b)
5937 +#endif
5938 + " .set mips0 \n"
5939 + : "=&r" (temp), "+m" (v->counter)
5940 + : "Ir" (i));
5941 + } else if (kernel_uses_llsc) {
5942 + __asm__ __volatile__(
5943 + " .set mips3 \n"
5944 + "1: lld %0, %1 # atomic64_sub \n"
5945 +#ifdef CONFIG_PAX_REFCOUNT
5946 + /* Exception on overflow. */
5947 + "2: dsub %0, %2 \n"
5948 +#else
5949 + " dsubu %0, %2 \n"
5950 +#endif
5951 + " scd %0, %1 \n"
5952 + " beqz %0, 1b \n"
5953 +#ifdef CONFIG_PAX_REFCOUNT
5954 + "3: \n"
5955 + _ASM_EXTABLE(2b, 3b)
5956 +#endif
5957 + " .set mips0 \n"
5958 + : "=&r" (temp), "+m" (v->counter)
5959 + : "Ir" (i));
5960 + } else {
5961 + unsigned long flags;
5962 +
5963 + raw_local_irq_save(flags);
5964 + __asm__ __volatile__(
5965 +#ifdef CONFIG_PAX_REFCOUNT
5966 + /* Exception on overflow. */
5967 + "1: dsub %0, %1 \n"
5968 + "2: \n"
5969 + _ASM_EXTABLE(1b, 2b)
5970 +#else
5971 + " dsubu %0, %1 \n"
5972 +#endif
5973 + : "+r" (v->counter) : "Ir" (i));
5974 + raw_local_irq_restore(flags);
5975 + }
5976 +}
5977 +
5978 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
5979 {
5980 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5981 long temp;
5982 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
5983 /*
5984 * Same as above, but return the result value
5985 */
5986 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
5987 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
5988 +{
5989 + long result;
5990 + long temp;
5991 +
5992 + smp_mb__before_llsc();
5993 +
5994 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5995 + __asm__ __volatile__(
5996 + " .set mips3 \n"
5997 + "1: lld %1, %2 # atomic64_add_return \n"
5998 +#ifdef CONFIG_PAX_REFCOUNT
5999 + "2: dadd %0, %1, %3 \n"
6000 +#else
6001 + " daddu %0, %1, %3 \n"
6002 +#endif
6003 + " scd %0, %2 \n"
6004 + " beqzl %0, 1b \n"
6005 +#ifdef CONFIG_PAX_REFCOUNT
6006 + " b 4f \n"
6007 + " .set noreorder \n"
6008 + "3: b 5f \n"
6009 + " move %0, %1 \n"
6010 + " .set reorder \n"
6011 + _ASM_EXTABLE(2b, 3b)
6012 +#endif
6013 + "4: daddu %0, %1, %3 \n"
6014 +#ifdef CONFIG_PAX_REFCOUNT
6015 + "5: \n"
6016 +#endif
6017 + " .set mips0 \n"
6018 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6019 + : "Ir" (i));
6020 + } else if (kernel_uses_llsc) {
6021 + __asm__ __volatile__(
6022 + " .set mips3 \n"
6023 + "1: lld %1, %2 # atomic64_add_return \n"
6024 +#ifdef CONFIG_PAX_REFCOUNT
6025 + "2: dadd %0, %1, %3 \n"
6026 +#else
6027 + " daddu %0, %1, %3 \n"
6028 +#endif
6029 + " scd %0, %2 \n"
6030 + " bnez %0, 4f \n"
6031 + " b 1b \n"
6032 +#ifdef CONFIG_PAX_REFCOUNT
6033 + " .set noreorder \n"
6034 + "3: b 5f \n"
6035 + " move %0, %1 \n"
6036 + " .set reorder \n"
6037 + _ASM_EXTABLE(2b, 3b)
6038 +#endif
6039 + "4: daddu %0, %1, %3 \n"
6040 +#ifdef CONFIG_PAX_REFCOUNT
6041 + "5: \n"
6042 +#endif
6043 + " .set mips0 \n"
6044 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6045 + : "Ir" (i), "m" (v->counter)
6046 + : "memory");
6047 + } else {
6048 + unsigned long flags;
6049 +
6050 + raw_local_irq_save(flags);
6051 + __asm__ __volatile__(
6052 + " ld %0, %1 \n"
6053 +#ifdef CONFIG_PAX_REFCOUNT
6054 + /* Exception on overflow. */
6055 + "1: dadd %0, %2 \n"
6056 +#else
6057 + " daddu %0, %2 \n"
6058 +#endif
6059 + " sd %0, %1 \n"
6060 +#ifdef CONFIG_PAX_REFCOUNT
6061 + /* Note: Dest reg is not modified on overflow */
6062 + "2: \n"
6063 + _ASM_EXTABLE(1b, 2b)
6064 +#endif
6065 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6066 + raw_local_irq_restore(flags);
6067 + }
6068 +
6069 + smp_llsc_mb();
6070 +
6071 + return result;
6072 +}
6073 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6074 {
6075 long result;
6076
6077 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6078 return result;
6079 }
6080
6081 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6082 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6083 +{
6084 + long result;
6085 + long temp;
6086 +
6087 + smp_mb__before_llsc();
6088 +
6089 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6090 + long temp;
6091 +
6092 + __asm__ __volatile__(
6093 + " .set mips3 \n"
6094 + "1: lld %1, %2 # atomic64_sub_return \n"
6095 +#ifdef CONFIG_PAX_REFCOUNT
6096 + "2: dsub %0, %1, %3 \n"
6097 +#else
6098 + " dsubu %0, %1, %3 \n"
6099 +#endif
6100 + " scd %0, %2 \n"
6101 + " beqzl %0, 1b \n"
6102 +#ifdef CONFIG_PAX_REFCOUNT
6103 + " b 4f \n"
6104 + " .set noreorder \n"
6105 + "3: b 5f \n"
6106 + " move %0, %1 \n"
6107 + " .set reorder \n"
6108 + _ASM_EXTABLE(2b, 3b)
6109 +#endif
6110 + "4: dsubu %0, %1, %3 \n"
6111 +#ifdef CONFIG_PAX_REFCOUNT
6112 + "5: \n"
6113 +#endif
6114 + " .set mips0 \n"
6115 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6116 + : "Ir" (i), "m" (v->counter)
6117 + : "memory");
6118 + } else if (kernel_uses_llsc) {
6119 + __asm__ __volatile__(
6120 + " .set mips3 \n"
6121 + "1: lld %1, %2 # atomic64_sub_return \n"
6122 +#ifdef CONFIG_PAX_REFCOUNT
6123 + "2: dsub %0, %1, %3 \n"
6124 +#else
6125 + " dsubu %0, %1, %3 \n"
6126 +#endif
6127 + " scd %0, %2 \n"
6128 + " bnez %0, 4f \n"
6129 + " b 1b \n"
6130 +#ifdef CONFIG_PAX_REFCOUNT
6131 + " .set noreorder \n"
6132 + "3: b 5f \n"
6133 + " move %0, %1 \n"
6134 + " .set reorder \n"
6135 + _ASM_EXTABLE(2b, 3b)
6136 +#endif
6137 + "4: dsubu %0, %1, %3 \n"
6138 +#ifdef CONFIG_PAX_REFCOUNT
6139 + "5: \n"
6140 +#endif
6141 + " .set mips0 \n"
6142 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6143 + : "Ir" (i), "m" (v->counter)
6144 + : "memory");
6145 + } else {
6146 + unsigned long flags;
6147 +
6148 + raw_local_irq_save(flags);
6149 + __asm__ __volatile__(
6150 + " ld %0, %1 \n"
6151 +#ifdef CONFIG_PAX_REFCOUNT
6152 + /* Exception on overflow. */
6153 + "1: dsub %0, %2 \n"
6154 +#else
6155 + " dsubu %0, %2 \n"
6156 +#endif
6157 + " sd %0, %1 \n"
6158 +#ifdef CONFIG_PAX_REFCOUNT
6159 + /* Note: Dest reg is not modified on overflow */
6160 + "2: \n"
6161 + _ASM_EXTABLE(1b, 2b)
6162 +#endif
6163 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6164 + raw_local_irq_restore(flags);
6165 + }
6166 +
6167 + smp_llsc_mb();
6168 +
6169 + return result;
6170 +}
6171 +
6172 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6173 {
6174 long result;
6175
6176 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6177 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6178 * The function returns the old value of @v minus @i.
6179 */
6180 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6181 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6182 {
6183 long result;
6184
6185 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6186 return result;
6187 }
6188
6189 -#define atomic64_cmpxchg(v, o, n) \
6190 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6191 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6192 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6193 +{
6194 + return cmpxchg(&v->counter, old, new);
6195 +}
6196 +
6197 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6198 + long new)
6199 +{
6200 + return cmpxchg(&(v->counter), old, new);
6201 +}
6202 +
6203 +static inline long atomic64_xchg(atomic64_t *v, long new)
6204 +{
6205 + return xchg(&v->counter, new);
6206 +}
6207 +
6208 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6209 +{
6210 + return xchg(&(v->counter), new);
6211 +}
6212
6213 /**
6214 * atomic64_add_unless - add unless the number is a given value
6215 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6216
6217 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6218 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6219 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6220
6221 /*
6222 * atomic64_sub_and_test - subtract value from variable and test result
6223 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6224 * other cases.
6225 */
6226 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6227 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6228
6229 /*
6230 * atomic64_dec_and_test - decrement by 1 and test
6231 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6232 * Atomically increments @v by 1.
6233 */
6234 #define atomic64_inc(v) atomic64_add(1, (v))
6235 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6236
6237 /*
6238 * atomic64_dec - decrement and test
6239 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6240 * Atomically decrements @v by 1.
6241 */
6242 #define atomic64_dec(v) atomic64_sub(1, (v))
6243 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6244
6245 /*
6246 * atomic64_add_negative - add and test if negative
6247 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6248 index b4db69f..8f3b093 100644
6249 --- a/arch/mips/include/asm/cache.h
6250 +++ b/arch/mips/include/asm/cache.h
6251 @@ -9,10 +9,11 @@
6252 #ifndef _ASM_CACHE_H
6253 #define _ASM_CACHE_H
6254
6255 +#include <linux/const.h>
6256 #include <kmalloc.h>
6257
6258 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6259 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6260 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6261
6262 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6263 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6264 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6265 index cf3ae24..238d22f 100644
6266 --- a/arch/mips/include/asm/elf.h
6267 +++ b/arch/mips/include/asm/elf.h
6268 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6269 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6270 #endif
6271
6272 +#ifdef CONFIG_PAX_ASLR
6273 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6274 +
6275 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6276 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6277 +#endif
6278 +
6279 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6280 struct linux_binprm;
6281 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6282 int uses_interp);
6283
6284 -struct mm_struct;
6285 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6286 -#define arch_randomize_brk arch_randomize_brk
6287 -
6288 #endif /* _ASM_ELF_H */
6289 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6290 index c1f6afa..38cc6e9 100644
6291 --- a/arch/mips/include/asm/exec.h
6292 +++ b/arch/mips/include/asm/exec.h
6293 @@ -12,6 +12,6 @@
6294 #ifndef _ASM_EXEC_H
6295 #define _ASM_EXEC_H
6296
6297 -extern unsigned long arch_align_stack(unsigned long sp);
6298 +#define arch_align_stack(x) ((x) & ~0xfUL)
6299
6300 #endif /* _ASM_EXEC_H */
6301 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6302 index d44622c..64990d2 100644
6303 --- a/arch/mips/include/asm/local.h
6304 +++ b/arch/mips/include/asm/local.h
6305 @@ -12,15 +12,25 @@ typedef struct
6306 atomic_long_t a;
6307 } local_t;
6308
6309 +typedef struct {
6310 + atomic_long_unchecked_t a;
6311 +} local_unchecked_t;
6312 +
6313 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6314
6315 #define local_read(l) atomic_long_read(&(l)->a)
6316 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6317 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6318 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6319
6320 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6321 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6322 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6323 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6324 #define local_inc(l) atomic_long_inc(&(l)->a)
6325 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6326 #define local_dec(l) atomic_long_dec(&(l)->a)
6327 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6328
6329 /*
6330 * Same as above, but return the result value
6331 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6332 return result;
6333 }
6334
6335 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6336 +{
6337 + unsigned long result;
6338 +
6339 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6340 + unsigned long temp;
6341 +
6342 + __asm__ __volatile__(
6343 + " .set mips3 \n"
6344 + "1:" __LL "%1, %2 # local_add_return \n"
6345 + " addu %0, %1, %3 \n"
6346 + __SC "%0, %2 \n"
6347 + " beqzl %0, 1b \n"
6348 + " addu %0, %1, %3 \n"
6349 + " .set mips0 \n"
6350 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6351 + : "Ir" (i), "m" (l->a.counter)
6352 + : "memory");
6353 + } else if (kernel_uses_llsc) {
6354 + unsigned long temp;
6355 +
6356 + __asm__ __volatile__(
6357 + " .set mips3 \n"
6358 + "1:" __LL "%1, %2 # local_add_return \n"
6359 + " addu %0, %1, %3 \n"
6360 + __SC "%0, %2 \n"
6361 + " beqz %0, 1b \n"
6362 + " addu %0, %1, %3 \n"
6363 + " .set mips0 \n"
6364 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6365 + : "Ir" (i), "m" (l->a.counter)
6366 + : "memory");
6367 + } else {
6368 + unsigned long flags;
6369 +
6370 + local_irq_save(flags);
6371 + result = l->a.counter;
6372 + result += i;
6373 + l->a.counter = result;
6374 + local_irq_restore(flags);
6375 + }
6376 +
6377 + return result;
6378 +}
6379 +
6380 static __inline__ long local_sub_return(long i, local_t * l)
6381 {
6382 unsigned long result;
6383 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6384
6385 #define local_cmpxchg(l, o, n) \
6386 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6387 +#define local_cmpxchg_unchecked(l, o, n) \
6388 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6389 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6390
6391 /**
6392 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6393 index f6be474..12ad554 100644
6394 --- a/arch/mips/include/asm/page.h
6395 +++ b/arch/mips/include/asm/page.h
6396 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6397 #ifdef CONFIG_CPU_MIPS32
6398 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6399 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6400 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6401 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6402 #else
6403 typedef struct { unsigned long long pte; } pte_t;
6404 #define pte_val(x) ((x).pte)
6405 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6406 index 881d18b..cea38bc 100644
6407 --- a/arch/mips/include/asm/pgalloc.h
6408 +++ b/arch/mips/include/asm/pgalloc.h
6409 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6410 {
6411 set_pud(pud, __pud((unsigned long)pmd));
6412 }
6413 +
6414 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6415 +{
6416 + pud_populate(mm, pud, pmd);
6417 +}
6418 #endif
6419
6420 /*
6421 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6422 index 25da651..ae2a259 100644
6423 --- a/arch/mips/include/asm/smtc_proc.h
6424 +++ b/arch/mips/include/asm/smtc_proc.h
6425 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6426
6427 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6428
6429 -extern atomic_t smtc_fpu_recoveries;
6430 +extern atomic_unchecked_t smtc_fpu_recoveries;
6431
6432 #endif /* __ASM_SMTC_PROC_H */
6433 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6434 index 61215a3..213ee0e 100644
6435 --- a/arch/mips/include/asm/thread_info.h
6436 +++ b/arch/mips/include/asm/thread_info.h
6437 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6438 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6439 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6440 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6441 +/* li takes a 32bit immediate */
6442 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6443 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6444
6445 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6446 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6447 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6448 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6449 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6450 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6451
6452 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6453 - _TIF_SYSCALL_AUDIT)
6454 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6455
6456 /* work to do in syscall_trace_leave() */
6457 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6458 - _TIF_SYSCALL_AUDIT)
6459 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6460
6461 /* work to do on interrupt/exception return */
6462 #define _TIF_WORK_MASK \
6463 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6464 /* work to do on any return to u-space */
6465 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6466 - _TIF_WORK_SYSCALL_EXIT)
6467 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6468
6469 #endif /* __KERNEL__ */
6470
6471 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6472 index 1188e00..41cf144 100644
6473 --- a/arch/mips/kernel/binfmt_elfn32.c
6474 +++ b/arch/mips/kernel/binfmt_elfn32.c
6475 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6476 #undef ELF_ET_DYN_BASE
6477 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6478
6479 +#ifdef CONFIG_PAX_ASLR
6480 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6481 +
6482 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6483 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6484 +#endif
6485 +
6486 #include <asm/processor.h>
6487 #include <linux/module.h>
6488 #include <linux/elfcore.h>
6489 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6490 index 202e581..689ca79 100644
6491 --- a/arch/mips/kernel/binfmt_elfo32.c
6492 +++ b/arch/mips/kernel/binfmt_elfo32.c
6493 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6494 #undef ELF_ET_DYN_BASE
6495 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6496
6497 +#ifdef CONFIG_PAX_ASLR
6498 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6499 +
6500 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6501 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6502 +#endif
6503 +
6504 #include <asm/processor.h>
6505
6506 /*
6507 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6508 index d1fea7a..45602ea 100644
6509 --- a/arch/mips/kernel/irq.c
6510 +++ b/arch/mips/kernel/irq.c
6511 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6512 printk("unexpected IRQ # %d\n", irq);
6513 }
6514
6515 -atomic_t irq_err_count;
6516 +atomic_unchecked_t irq_err_count;
6517
6518 int arch_show_interrupts(struct seq_file *p, int prec)
6519 {
6520 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6521 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6522 return 0;
6523 }
6524
6525 asmlinkage void spurious_interrupt(void)
6526 {
6527 - atomic_inc(&irq_err_count);
6528 + atomic_inc_unchecked(&irq_err_count);
6529 }
6530
6531 void __init init_IRQ(void)
6532 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6533 index ddc7610..8c58f17 100644
6534 --- a/arch/mips/kernel/process.c
6535 +++ b/arch/mips/kernel/process.c
6536 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6537 out:
6538 return pc;
6539 }
6540 -
6541 -/*
6542 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6543 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6544 - */
6545 -unsigned long arch_align_stack(unsigned long sp)
6546 -{
6547 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6548 - sp -= get_random_int() & ~PAGE_MASK;
6549 -
6550 - return sp & ALMASK;
6551 -}
6552 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6553 index 8ae1ebe..1bcbf47 100644
6554 --- a/arch/mips/kernel/ptrace.c
6555 +++ b/arch/mips/kernel/ptrace.c
6556 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6557 return arch;
6558 }
6559
6560 +#ifdef CONFIG_GRKERNSEC_SETXID
6561 +extern void gr_delayed_cred_worker(void);
6562 +#endif
6563 +
6564 /*
6565 * Notification of system call entry/exit
6566 * - triggered by current->work.syscall_trace
6567 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6568 /* do the secure computing check first */
6569 secure_computing_strict(regs->regs[2]);
6570
6571 +#ifdef CONFIG_GRKERNSEC_SETXID
6572 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6573 + gr_delayed_cred_worker();
6574 +#endif
6575 +
6576 if (!(current->ptrace & PT_PTRACED))
6577 goto out;
6578
6579 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6580 index c10aa84..9ec2e60 100644
6581 --- a/arch/mips/kernel/smtc-proc.c
6582 +++ b/arch/mips/kernel/smtc-proc.c
6583 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6584
6585 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6586
6587 -atomic_t smtc_fpu_recoveries;
6588 +atomic_unchecked_t smtc_fpu_recoveries;
6589
6590 static int smtc_proc_show(struct seq_file *m, void *v)
6591 {
6592 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6593 for(i = 0; i < NR_CPUS; i++)
6594 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6595 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6596 - atomic_read(&smtc_fpu_recoveries));
6597 + atomic_read_unchecked(&smtc_fpu_recoveries));
6598 return 0;
6599 }
6600
6601 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6602 smtc_cpu_stats[i].selfipis = 0;
6603 }
6604
6605 - atomic_set(&smtc_fpu_recoveries, 0);
6606 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6607
6608 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6609 }
6610 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6611 index dfc1b91..11a2c07 100644
6612 --- a/arch/mips/kernel/smtc.c
6613 +++ b/arch/mips/kernel/smtc.c
6614 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6615 }
6616 smtc_ipi_qdump();
6617 printk("%d Recoveries of \"stolen\" FPU\n",
6618 - atomic_read(&smtc_fpu_recoveries));
6619 + atomic_read_unchecked(&smtc_fpu_recoveries));
6620 }
6621
6622
6623 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6624 index 84536bf..79caa4d 100644
6625 --- a/arch/mips/kernel/sync-r4k.c
6626 +++ b/arch/mips/kernel/sync-r4k.c
6627 @@ -21,8 +21,8 @@
6628 #include <asm/mipsregs.h>
6629
6630 static atomic_t count_start_flag = ATOMIC_INIT(0);
6631 -static atomic_t count_count_start = ATOMIC_INIT(0);
6632 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6633 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6634 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6635 static atomic_t count_reference = ATOMIC_INIT(0);
6636
6637 #define COUNTON 100
6638 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6639
6640 for (i = 0; i < NR_LOOPS; i++) {
6641 /* slaves loop on '!= 2' */
6642 - while (atomic_read(&count_count_start) != 1)
6643 + while (atomic_read_unchecked(&count_count_start) != 1)
6644 mb();
6645 - atomic_set(&count_count_stop, 0);
6646 + atomic_set_unchecked(&count_count_stop, 0);
6647 smp_wmb();
6648
6649 /* this lets the slaves write their count register */
6650 - atomic_inc(&count_count_start);
6651 + atomic_inc_unchecked(&count_count_start);
6652
6653 /*
6654 * Everyone initialises count in the last loop:
6655 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6656 /*
6657 * Wait for all slaves to leave the synchronization point:
6658 */
6659 - while (atomic_read(&count_count_stop) != 1)
6660 + while (atomic_read_unchecked(&count_count_stop) != 1)
6661 mb();
6662 - atomic_set(&count_count_start, 0);
6663 + atomic_set_unchecked(&count_count_start, 0);
6664 smp_wmb();
6665 - atomic_inc(&count_count_stop);
6666 + atomic_inc_unchecked(&count_count_stop);
6667 }
6668 /* Arrange for an interrupt in a short while */
6669 write_c0_compare(read_c0_count() + COUNTON);
6670 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6671 initcount = atomic_read(&count_reference);
6672
6673 for (i = 0; i < NR_LOOPS; i++) {
6674 - atomic_inc(&count_count_start);
6675 - while (atomic_read(&count_count_start) != 2)
6676 + atomic_inc_unchecked(&count_count_start);
6677 + while (atomic_read_unchecked(&count_count_start) != 2)
6678 mb();
6679
6680 /*
6681 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6682 if (i == NR_LOOPS-1)
6683 write_c0_count(initcount);
6684
6685 - atomic_inc(&count_count_stop);
6686 - while (atomic_read(&count_count_stop) != 2)
6687 + atomic_inc_unchecked(&count_count_stop);
6688 + while (atomic_read_unchecked(&count_count_stop) != 2)
6689 mb();
6690 }
6691 /* Arrange for an interrupt in a short while */
6692 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6693 index aec3408..74d79d3 100644
6694 --- a/arch/mips/kernel/traps.c
6695 +++ b/arch/mips/kernel/traps.c
6696 @@ -683,7 +683,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6697 siginfo_t info;
6698
6699 prev_state = exception_enter();
6700 - die_if_kernel("Integer overflow", regs);
6701 + if (unlikely(!user_mode(regs))) {
6702 +
6703 +#ifdef CONFIG_PAX_REFCOUNT
6704 + if (fixup_exception(regs)) {
6705 + pax_report_refcount_overflow(regs);
6706 + exception_exit(prev_state);
6707 + return;
6708 + }
6709 +#endif
6710 +
6711 + die("Integer overflow", regs);
6712 + }
6713
6714 info.si_code = FPE_INTOVF;
6715 info.si_signo = SIGFPE;
6716 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6717 index 85df1cd..4f0a4de 100644
6718 --- a/arch/mips/mm/fault.c
6719 +++ b/arch/mips/mm/fault.c
6720 @@ -28,6 +28,23 @@
6721 #include <asm/highmem.h> /* For VMALLOC_END */
6722 #include <linux/kdebug.h>
6723
6724 +#ifdef CONFIG_PAX_PAGEEXEC
6725 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6726 +{
6727 + unsigned long i;
6728 +
6729 + printk(KERN_ERR "PAX: bytes at PC: ");
6730 + for (i = 0; i < 5; i++) {
6731 + unsigned int c;
6732 + if (get_user(c, (unsigned int *)pc+i))
6733 + printk(KERN_CONT "???????? ");
6734 + else
6735 + printk(KERN_CONT "%08x ", c);
6736 + }
6737 + printk("\n");
6738 +}
6739 +#endif
6740 +
6741 /*
6742 * This routine handles page faults. It determines the address,
6743 * and the problem, and then passes it off to one of the appropriate
6744 @@ -197,6 +214,14 @@ bad_area:
6745 bad_area_nosemaphore:
6746 /* User mode accesses just cause a SIGSEGV */
6747 if (user_mode(regs)) {
6748 +
6749 +#ifdef CONFIG_PAX_PAGEEXEC
6750 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6751 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6752 + do_group_exit(SIGKILL);
6753 + }
6754 +#endif
6755 +
6756 tsk->thread.cp0_badvaddr = address;
6757 tsk->thread.error_code = write;
6758 #if 0
6759 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6760 index f1baadd..8537544 100644
6761 --- a/arch/mips/mm/mmap.c
6762 +++ b/arch/mips/mm/mmap.c
6763 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6764 struct vm_area_struct *vma;
6765 unsigned long addr = addr0;
6766 int do_color_align;
6767 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6768 struct vm_unmapped_area_info info;
6769
6770 if (unlikely(len > TASK_SIZE))
6771 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6772 do_color_align = 1;
6773
6774 /* requesting a specific address */
6775 +
6776 +#ifdef CONFIG_PAX_RANDMMAP
6777 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6778 +#endif
6779 +
6780 if (addr) {
6781 if (do_color_align)
6782 addr = COLOUR_ALIGN(addr, pgoff);
6783 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6784 addr = PAGE_ALIGN(addr);
6785
6786 vma = find_vma(mm, addr);
6787 - if (TASK_SIZE - len >= addr &&
6788 - (!vma || addr + len <= vma->vm_start))
6789 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6790 return addr;
6791 }
6792
6793 info.length = len;
6794 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6795 info.align_offset = pgoff << PAGE_SHIFT;
6796 + info.threadstack_offset = offset;
6797
6798 if (dir == DOWN) {
6799 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6800 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6801 {
6802 unsigned long random_factor = 0UL;
6803
6804 +#ifdef CONFIG_PAX_RANDMMAP
6805 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6806 +#endif
6807 +
6808 if (current->flags & PF_RANDOMIZE) {
6809 random_factor = get_random_int();
6810 random_factor = random_factor << PAGE_SHIFT;
6811 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6812
6813 if (mmap_is_legacy()) {
6814 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6815 +
6816 +#ifdef CONFIG_PAX_RANDMMAP
6817 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6818 + mm->mmap_base += mm->delta_mmap;
6819 +#endif
6820 +
6821 mm->get_unmapped_area = arch_get_unmapped_area;
6822 } else {
6823 mm->mmap_base = mmap_base(random_factor);
6824 +
6825 +#ifdef CONFIG_PAX_RANDMMAP
6826 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6827 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6828 +#endif
6829 +
6830 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6831 }
6832 }
6833
6834 -static inline unsigned long brk_rnd(void)
6835 -{
6836 - unsigned long rnd = get_random_int();
6837 -
6838 - rnd = rnd << PAGE_SHIFT;
6839 - /* 8MB for 32bit, 256MB for 64bit */
6840 - if (TASK_IS_32BIT_ADDR)
6841 - rnd = rnd & 0x7ffffful;
6842 - else
6843 - rnd = rnd & 0xffffffful;
6844 -
6845 - return rnd;
6846 -}
6847 -
6848 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6849 -{
6850 - unsigned long base = mm->brk;
6851 - unsigned long ret;
6852 -
6853 - ret = PAGE_ALIGN(base + brk_rnd());
6854 -
6855 - if (ret < mm->brk)
6856 - return mm->brk;
6857 -
6858 - return ret;
6859 -}
6860 -
6861 int __virt_addr_valid(const volatile void *kaddr)
6862 {
6863 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6864 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6865 index a2358b4..7cead4f 100644
6866 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6867 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6868 @@ -187,9 +187,9 @@ void
6869 cont_nmi_dump(void)
6870 {
6871 #ifndef REAL_NMI_SIGNAL
6872 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6873 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6874
6875 - atomic_inc(&nmied_cpus);
6876 + atomic_inc_unchecked(&nmied_cpus);
6877 #endif
6878 /*
6879 * Only allow 1 cpu to proceed
6880 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6881 udelay(10000);
6882 }
6883 #else
6884 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6885 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6886 #endif
6887
6888 /*
6889 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6890 index 967d144..db12197 100644
6891 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6892 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6893 @@ -11,12 +11,14 @@
6894 #ifndef _ASM_PROC_CACHE_H
6895 #define _ASM_PROC_CACHE_H
6896
6897 +#include <linux/const.h>
6898 +
6899 /* L1 cache */
6900
6901 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6902 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6903 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6904 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6905 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6906 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6907
6908 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6909 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6910 index bcb5df2..84fabd2 100644
6911 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6912 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6913 @@ -16,13 +16,15 @@
6914 #ifndef _ASM_PROC_CACHE_H
6915 #define _ASM_PROC_CACHE_H
6916
6917 +#include <linux/const.h>
6918 +
6919 /*
6920 * L1 cache
6921 */
6922 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6923 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6924 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6925 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6926 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6927 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6928
6929 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6930 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6931 index 4ce7a01..449202a 100644
6932 --- a/arch/openrisc/include/asm/cache.h
6933 +++ b/arch/openrisc/include/asm/cache.h
6934 @@ -19,11 +19,13 @@
6935 #ifndef __ASM_OPENRISC_CACHE_H
6936 #define __ASM_OPENRISC_CACHE_H
6937
6938 +#include <linux/const.h>
6939 +
6940 /* FIXME: How can we replace these with values from the CPU...
6941 * they shouldn't be hard-coded!
6942 */
6943
6944 -#define L1_CACHE_BYTES 16
6945 #define L1_CACHE_SHIFT 4
6946 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6947
6948 #endif /* __ASM_OPENRISC_CACHE_H */
6949 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6950 index 472886c..00e7df9 100644
6951 --- a/arch/parisc/include/asm/atomic.h
6952 +++ b/arch/parisc/include/asm/atomic.h
6953 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6954 return dec;
6955 }
6956
6957 +#define atomic64_read_unchecked(v) atomic64_read(v)
6958 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6959 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6960 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6961 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6962 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6963 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6964 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6965 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6966 +
6967 #endif /* !CONFIG_64BIT */
6968
6969
6970 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6971 index 47f11c7..3420df2 100644
6972 --- a/arch/parisc/include/asm/cache.h
6973 +++ b/arch/parisc/include/asm/cache.h
6974 @@ -5,6 +5,7 @@
6975 #ifndef __ARCH_PARISC_CACHE_H
6976 #define __ARCH_PARISC_CACHE_H
6977
6978 +#include <linux/const.h>
6979
6980 /*
6981 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
6982 @@ -15,13 +16,13 @@
6983 * just ruin performance.
6984 */
6985 #ifdef CONFIG_PA20
6986 -#define L1_CACHE_BYTES 64
6987 #define L1_CACHE_SHIFT 6
6988 #else
6989 -#define L1_CACHE_BYTES 32
6990 #define L1_CACHE_SHIFT 5
6991 #endif
6992
6993 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6994 +
6995 #ifndef __ASSEMBLY__
6996
6997 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6998 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
6999 index ad2b503..bdf1651 100644
7000 --- a/arch/parisc/include/asm/elf.h
7001 +++ b/arch/parisc/include/asm/elf.h
7002 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7003
7004 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7005
7006 +#ifdef CONFIG_PAX_ASLR
7007 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7008 +
7009 +#define PAX_DELTA_MMAP_LEN 16
7010 +#define PAX_DELTA_STACK_LEN 16
7011 +#endif
7012 +
7013 /* This yields a mask that user programs can use to figure out what
7014 instruction set this CPU supports. This could be done in user space,
7015 but it's not easy, and we've already done it here. */
7016 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7017 index fc987a1..6e068ef 100644
7018 --- a/arch/parisc/include/asm/pgalloc.h
7019 +++ b/arch/parisc/include/asm/pgalloc.h
7020 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7021 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7022 }
7023
7024 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7025 +{
7026 + pgd_populate(mm, pgd, pmd);
7027 +}
7028 +
7029 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7030 {
7031 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7032 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7033 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7034 #define pmd_free(mm, x) do { } while (0)
7035 #define pgd_populate(mm, pmd, pte) BUG()
7036 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7037
7038 #endif
7039
7040 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7041 index 34899b5..02dd060 100644
7042 --- a/arch/parisc/include/asm/pgtable.h
7043 +++ b/arch/parisc/include/asm/pgtable.h
7044 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7045 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7046 #define PAGE_COPY PAGE_EXECREAD
7047 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7048 +
7049 +#ifdef CONFIG_PAX_PAGEEXEC
7050 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7051 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7052 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7053 +#else
7054 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7055 +# define PAGE_COPY_NOEXEC PAGE_COPY
7056 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7057 +#endif
7058 +
7059 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7060 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7061 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7062 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7063 index e0a8235..ce2f1e1 100644
7064 --- a/arch/parisc/include/asm/uaccess.h
7065 +++ b/arch/parisc/include/asm/uaccess.h
7066 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7067 const void __user *from,
7068 unsigned long n)
7069 {
7070 - int sz = __compiletime_object_size(to);
7071 + size_t sz = __compiletime_object_size(to);
7072 int ret = -EFAULT;
7073
7074 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7075 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7076 ret = __copy_from_user(to, from, n);
7077 else
7078 copy_from_user_overflow();
7079 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7080 index 2a625fb..9908930 100644
7081 --- a/arch/parisc/kernel/module.c
7082 +++ b/arch/parisc/kernel/module.c
7083 @@ -98,16 +98,38 @@
7084
7085 /* three functions to determine where in the module core
7086 * or init pieces the location is */
7087 +static inline int in_init_rx(struct module *me, void *loc)
7088 +{
7089 + return (loc >= me->module_init_rx &&
7090 + loc < (me->module_init_rx + me->init_size_rx));
7091 +}
7092 +
7093 +static inline int in_init_rw(struct module *me, void *loc)
7094 +{
7095 + return (loc >= me->module_init_rw &&
7096 + loc < (me->module_init_rw + me->init_size_rw));
7097 +}
7098 +
7099 static inline int in_init(struct module *me, void *loc)
7100 {
7101 - return (loc >= me->module_init &&
7102 - loc <= (me->module_init + me->init_size));
7103 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7104 +}
7105 +
7106 +static inline int in_core_rx(struct module *me, void *loc)
7107 +{
7108 + return (loc >= me->module_core_rx &&
7109 + loc < (me->module_core_rx + me->core_size_rx));
7110 +}
7111 +
7112 +static inline int in_core_rw(struct module *me, void *loc)
7113 +{
7114 + return (loc >= me->module_core_rw &&
7115 + loc < (me->module_core_rw + me->core_size_rw));
7116 }
7117
7118 static inline int in_core(struct module *me, void *loc)
7119 {
7120 - return (loc >= me->module_core &&
7121 - loc <= (me->module_core + me->core_size));
7122 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7123 }
7124
7125 static inline int in_local(struct module *me, void *loc)
7126 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7127 }
7128
7129 /* align things a bit */
7130 - me->core_size = ALIGN(me->core_size, 16);
7131 - me->arch.got_offset = me->core_size;
7132 - me->core_size += gots * sizeof(struct got_entry);
7133 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7134 + me->arch.got_offset = me->core_size_rw;
7135 + me->core_size_rw += gots * sizeof(struct got_entry);
7136
7137 - me->core_size = ALIGN(me->core_size, 16);
7138 - me->arch.fdesc_offset = me->core_size;
7139 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7140 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7141 + me->arch.fdesc_offset = me->core_size_rw;
7142 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7143
7144 me->arch.got_max = gots;
7145 me->arch.fdesc_max = fdescs;
7146 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7147
7148 BUG_ON(value == 0);
7149
7150 - got = me->module_core + me->arch.got_offset;
7151 + got = me->module_core_rw + me->arch.got_offset;
7152 for (i = 0; got[i].addr; i++)
7153 if (got[i].addr == value)
7154 goto out;
7155 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7156 #ifdef CONFIG_64BIT
7157 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7158 {
7159 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7160 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7161
7162 if (!value) {
7163 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7164 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7165
7166 /* Create new one */
7167 fdesc->addr = value;
7168 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7169 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7170 return (Elf_Addr)fdesc;
7171 }
7172 #endif /* CONFIG_64BIT */
7173 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7174
7175 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7176 end = table + sechdrs[me->arch.unwind_section].sh_size;
7177 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7178 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7179
7180 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7181 me->arch.unwind_section, table, end, gp);
7182 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7183 index 5dfd248..64914ac 100644
7184 --- a/arch/parisc/kernel/sys_parisc.c
7185 +++ b/arch/parisc/kernel/sys_parisc.c
7186 @@ -33,9 +33,11 @@
7187 #include <linux/utsname.h>
7188 #include <linux/personality.h>
7189
7190 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7191 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7192 + unsigned long flags)
7193 {
7194 struct vm_unmapped_area_info info;
7195 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7196
7197 info.flags = 0;
7198 info.length = len;
7199 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7200 info.high_limit = TASK_SIZE;
7201 info.align_mask = 0;
7202 info.align_offset = 0;
7203 + info.threadstack_offset = offset;
7204 return vm_unmapped_area(&info);
7205 }
7206
7207 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7208 return (unsigned long) mapping >> 8;
7209 }
7210
7211 -static unsigned long get_shared_area(struct address_space *mapping,
7212 - unsigned long addr, unsigned long len, unsigned long pgoff)
7213 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7214 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7215 {
7216 struct vm_unmapped_area_info info;
7217 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7218
7219 info.flags = 0;
7220 info.length = len;
7221 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7222 info.high_limit = TASK_SIZE;
7223 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7224 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7225 + info.threadstack_offset = offset;
7226 return vm_unmapped_area(&info);
7227 }
7228
7229 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7230 return -EINVAL;
7231 return addr;
7232 }
7233 - if (!addr)
7234 + if (!addr) {
7235 addr = TASK_UNMAPPED_BASE;
7236
7237 +#ifdef CONFIG_PAX_RANDMMAP
7238 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7239 + addr += current->mm->delta_mmap;
7240 +#endif
7241 +
7242 + }
7243 +
7244 if (filp) {
7245 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7246 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7247 } else if(flags & MAP_SHARED) {
7248 - addr = get_shared_area(NULL, addr, len, pgoff);
7249 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7250 } else {
7251 - addr = get_unshared_area(addr, len);
7252 + addr = get_unshared_area(filp, addr, len, flags);
7253 }
7254 return addr;
7255 }
7256 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7257 index b3f87a3..5d5d03d 100644
7258 --- a/arch/parisc/kernel/traps.c
7259 +++ b/arch/parisc/kernel/traps.c
7260 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7261
7262 down_read(&current->mm->mmap_sem);
7263 vma = find_vma(current->mm,regs->iaoq[0]);
7264 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7265 - && (vma->vm_flags & VM_EXEC)) {
7266 -
7267 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7268 fault_address = regs->iaoq[0];
7269 fault_space = regs->iasq[0];
7270
7271 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7272 index f247a34..dc0f219 100644
7273 --- a/arch/parisc/mm/fault.c
7274 +++ b/arch/parisc/mm/fault.c
7275 @@ -15,6 +15,7 @@
7276 #include <linux/sched.h>
7277 #include <linux/interrupt.h>
7278 #include <linux/module.h>
7279 +#include <linux/unistd.h>
7280
7281 #include <asm/uaccess.h>
7282 #include <asm/traps.h>
7283 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7284 static unsigned long
7285 parisc_acctyp(unsigned long code, unsigned int inst)
7286 {
7287 - if (code == 6 || code == 16)
7288 + if (code == 6 || code == 7 || code == 16)
7289 return VM_EXEC;
7290
7291 switch (inst & 0xf0000000) {
7292 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7293 }
7294 #endif
7295
7296 +#ifdef CONFIG_PAX_PAGEEXEC
7297 +/*
7298 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7299 + *
7300 + * returns 1 when task should be killed
7301 + * 2 when rt_sigreturn trampoline was detected
7302 + * 3 when unpatched PLT trampoline was detected
7303 + */
7304 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7305 +{
7306 +
7307 +#ifdef CONFIG_PAX_EMUPLT
7308 + int err;
7309 +
7310 + do { /* PaX: unpatched PLT emulation */
7311 + unsigned int bl, depwi;
7312 +
7313 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7314 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7315 +
7316 + if (err)
7317 + break;
7318 +
7319 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7320 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7321 +
7322 + err = get_user(ldw, (unsigned int *)addr);
7323 + err |= get_user(bv, (unsigned int *)(addr+4));
7324 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7325 +
7326 + if (err)
7327 + break;
7328 +
7329 + if (ldw == 0x0E801096U &&
7330 + bv == 0xEAC0C000U &&
7331 + ldw2 == 0x0E881095U)
7332 + {
7333 + unsigned int resolver, map;
7334 +
7335 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7336 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7337 + if (err)
7338 + break;
7339 +
7340 + regs->gr[20] = instruction_pointer(regs)+8;
7341 + regs->gr[21] = map;
7342 + regs->gr[22] = resolver;
7343 + regs->iaoq[0] = resolver | 3UL;
7344 + regs->iaoq[1] = regs->iaoq[0] + 4;
7345 + return 3;
7346 + }
7347 + }
7348 + } while (0);
7349 +#endif
7350 +
7351 +#ifdef CONFIG_PAX_EMUTRAMP
7352 +
7353 +#ifndef CONFIG_PAX_EMUSIGRT
7354 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7355 + return 1;
7356 +#endif
7357 +
7358 + do { /* PaX: rt_sigreturn emulation */
7359 + unsigned int ldi1, ldi2, bel, nop;
7360 +
7361 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7362 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7363 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7364 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7365 +
7366 + if (err)
7367 + break;
7368 +
7369 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7370 + ldi2 == 0x3414015AU &&
7371 + bel == 0xE4008200U &&
7372 + nop == 0x08000240U)
7373 + {
7374 + regs->gr[25] = (ldi1 & 2) >> 1;
7375 + regs->gr[20] = __NR_rt_sigreturn;
7376 + regs->gr[31] = regs->iaoq[1] + 16;
7377 + regs->sr[0] = regs->iasq[1];
7378 + regs->iaoq[0] = 0x100UL;
7379 + regs->iaoq[1] = regs->iaoq[0] + 4;
7380 + regs->iasq[0] = regs->sr[2];
7381 + regs->iasq[1] = regs->sr[2];
7382 + return 2;
7383 + }
7384 + } while (0);
7385 +#endif
7386 +
7387 + return 1;
7388 +}
7389 +
7390 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7391 +{
7392 + unsigned long i;
7393 +
7394 + printk(KERN_ERR "PAX: bytes at PC: ");
7395 + for (i = 0; i < 5; i++) {
7396 + unsigned int c;
7397 + if (get_user(c, (unsigned int *)pc+i))
7398 + printk(KERN_CONT "???????? ");
7399 + else
7400 + printk(KERN_CONT "%08x ", c);
7401 + }
7402 + printk("\n");
7403 +}
7404 +#endif
7405 +
7406 int fixup_exception(struct pt_regs *regs)
7407 {
7408 const struct exception_table_entry *fix;
7409 @@ -194,8 +305,33 @@ good_area:
7410
7411 acc_type = parisc_acctyp(code,regs->iir);
7412
7413 - if ((vma->vm_flags & acc_type) != acc_type)
7414 + if ((vma->vm_flags & acc_type) != acc_type) {
7415 +
7416 +#ifdef CONFIG_PAX_PAGEEXEC
7417 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7418 + (address & ~3UL) == instruction_pointer(regs))
7419 + {
7420 + up_read(&mm->mmap_sem);
7421 + switch (pax_handle_fetch_fault(regs)) {
7422 +
7423 +#ifdef CONFIG_PAX_EMUPLT
7424 + case 3:
7425 + return;
7426 +#endif
7427 +
7428 +#ifdef CONFIG_PAX_EMUTRAMP
7429 + case 2:
7430 + return;
7431 +#endif
7432 +
7433 + }
7434 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7435 + do_group_exit(SIGKILL);
7436 + }
7437 +#endif
7438 +
7439 goto bad_area;
7440 + }
7441
7442 /*
7443 * If for any reason at all we couldn't handle the fault, make
7444 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7445 index e3b1d41..8e81edf 100644
7446 --- a/arch/powerpc/include/asm/atomic.h
7447 +++ b/arch/powerpc/include/asm/atomic.h
7448 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7449 return t1;
7450 }
7451
7452 +#define atomic64_read_unchecked(v) atomic64_read(v)
7453 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7454 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7455 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7456 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7457 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7458 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7459 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7460 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7461 +
7462 #endif /* __powerpc64__ */
7463
7464 #endif /* __KERNEL__ */
7465 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7466 index 9e495c9..b6878e5 100644
7467 --- a/arch/powerpc/include/asm/cache.h
7468 +++ b/arch/powerpc/include/asm/cache.h
7469 @@ -3,6 +3,7 @@
7470
7471 #ifdef __KERNEL__
7472
7473 +#include <linux/const.h>
7474
7475 /* bytes per L1 cache line */
7476 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7477 @@ -22,7 +23,7 @@
7478 #define L1_CACHE_SHIFT 7
7479 #endif
7480
7481 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7482 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7483
7484 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7485
7486 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7487 index cc0655a..13eac2e 100644
7488 --- a/arch/powerpc/include/asm/elf.h
7489 +++ b/arch/powerpc/include/asm/elf.h
7490 @@ -28,8 +28,19 @@
7491 the loader. We need to make sure that it is out of the way of the program
7492 that it will "exec", and that there is sufficient room for the brk. */
7493
7494 -extern unsigned long randomize_et_dyn(unsigned long base);
7495 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7496 +#define ELF_ET_DYN_BASE (0x20000000)
7497 +
7498 +#ifdef CONFIG_PAX_ASLR
7499 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7500 +
7501 +#ifdef __powerpc64__
7502 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7503 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7504 +#else
7505 +#define PAX_DELTA_MMAP_LEN 15
7506 +#define PAX_DELTA_STACK_LEN 15
7507 +#endif
7508 +#endif
7509
7510 /*
7511 * Our registers are always unsigned longs, whether we're a 32 bit
7512 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7513 (0x7ff >> (PAGE_SHIFT - 12)) : \
7514 (0x3ffff >> (PAGE_SHIFT - 12)))
7515
7516 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7517 -#define arch_randomize_brk arch_randomize_brk
7518 -
7519 -
7520 #ifdef CONFIG_SPU_BASE
7521 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7522 #define NT_SPU 1
7523 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7524 index 8196e9c..d83a9f3 100644
7525 --- a/arch/powerpc/include/asm/exec.h
7526 +++ b/arch/powerpc/include/asm/exec.h
7527 @@ -4,6 +4,6 @@
7528 #ifndef _ASM_POWERPC_EXEC_H
7529 #define _ASM_POWERPC_EXEC_H
7530
7531 -extern unsigned long arch_align_stack(unsigned long sp);
7532 +#define arch_align_stack(x) ((x) & ~0xfUL)
7533
7534 #endif /* _ASM_POWERPC_EXEC_H */
7535 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7536 index 5acabbd..7ea14fa 100644
7537 --- a/arch/powerpc/include/asm/kmap_types.h
7538 +++ b/arch/powerpc/include/asm/kmap_types.h
7539 @@ -10,7 +10,7 @@
7540 * 2 of the License, or (at your option) any later version.
7541 */
7542
7543 -#define KM_TYPE_NR 16
7544 +#define KM_TYPE_NR 17
7545
7546 #endif /* __KERNEL__ */
7547 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7548 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7549 index 8565c25..2865190 100644
7550 --- a/arch/powerpc/include/asm/mman.h
7551 +++ b/arch/powerpc/include/asm/mman.h
7552 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7553 }
7554 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7555
7556 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7557 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7558 {
7559 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7560 }
7561 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7562 index b9f4262..dcf04f7 100644
7563 --- a/arch/powerpc/include/asm/page.h
7564 +++ b/arch/powerpc/include/asm/page.h
7565 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7566 * and needs to be executable. This means the whole heap ends
7567 * up being executable.
7568 */
7569 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7570 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7571 +#define VM_DATA_DEFAULT_FLAGS32 \
7572 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7573 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7574
7575 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7576 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7577 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7578 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7579 #endif
7580
7581 +#define ktla_ktva(addr) (addr)
7582 +#define ktva_ktla(addr) (addr)
7583 +
7584 #ifndef CONFIG_PPC_BOOK3S_64
7585 /*
7586 * Use the top bit of the higher-level page table entries to indicate whether
7587 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7588 index 88693ce..ac6f9ab 100644
7589 --- a/arch/powerpc/include/asm/page_64.h
7590 +++ b/arch/powerpc/include/asm/page_64.h
7591 @@ -153,15 +153,18 @@ do { \
7592 * stack by default, so in the absence of a PT_GNU_STACK program header
7593 * we turn execute permission off.
7594 */
7595 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7596 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7597 +#define VM_STACK_DEFAULT_FLAGS32 \
7598 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7599 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7600
7601 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7602 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7603
7604 +#ifndef CONFIG_PAX_PAGEEXEC
7605 #define VM_STACK_DEFAULT_FLAGS \
7606 (is_32bit_task() ? \
7607 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7608 +#endif
7609
7610 #include <asm-generic/getorder.h>
7611
7612 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7613 index f65e27b..23ffb5b 100644
7614 --- a/arch/powerpc/include/asm/pgalloc-64.h
7615 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7616 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7617 #ifndef CONFIG_PPC_64K_PAGES
7618
7619 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7620 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7621
7622 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7623 {
7624 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7625 pud_set(pud, (unsigned long)pmd);
7626 }
7627
7628 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7629 +{
7630 + pud_populate(mm, pud, pmd);
7631 +}
7632 +
7633 #define pmd_populate(mm, pmd, pte_page) \
7634 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7635 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7636 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7637 #endif
7638
7639 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7640 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7641
7642 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7643 pte_t *pte)
7644 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7645 index 7d6eacf..14c0240 100644
7646 --- a/arch/powerpc/include/asm/pgtable.h
7647 +++ b/arch/powerpc/include/asm/pgtable.h
7648 @@ -2,6 +2,7 @@
7649 #define _ASM_POWERPC_PGTABLE_H
7650 #ifdef __KERNEL__
7651
7652 +#include <linux/const.h>
7653 #ifndef __ASSEMBLY__
7654 #include <asm/processor.h> /* For TASK_SIZE */
7655 #include <asm/mmu.h>
7656 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7657 index 4aad413..85d86bf 100644
7658 --- a/arch/powerpc/include/asm/pte-hash32.h
7659 +++ b/arch/powerpc/include/asm/pte-hash32.h
7660 @@ -21,6 +21,7 @@
7661 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7662 #define _PAGE_USER 0x004 /* usermode access allowed */
7663 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7664 +#define _PAGE_EXEC _PAGE_GUARDED
7665 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7666 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7667 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7668 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7669 index 99222e2..f629aef 100644
7670 --- a/arch/powerpc/include/asm/reg.h
7671 +++ b/arch/powerpc/include/asm/reg.h
7672 @@ -234,6 +234,7 @@
7673 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7674 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7675 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7676 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7677 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7678 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7679 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7680 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7681 index 48cfc85..891382f 100644
7682 --- a/arch/powerpc/include/asm/smp.h
7683 +++ b/arch/powerpc/include/asm/smp.h
7684 @@ -50,7 +50,7 @@ struct smp_ops_t {
7685 int (*cpu_disable)(void);
7686 void (*cpu_die)(unsigned int nr);
7687 int (*cpu_bootable)(unsigned int nr);
7688 -};
7689 +} __no_const;
7690
7691 extern void smp_send_debugger_break(void);
7692 extern void start_secondary_resume(void);
7693 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7694 index ba7b197..d292e26 100644
7695 --- a/arch/powerpc/include/asm/thread_info.h
7696 +++ b/arch/powerpc/include/asm/thread_info.h
7697 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7698 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7699 TIF_NEED_RESCHED */
7700 #define TIF_32BIT 4 /* 32 bit binary */
7701 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7702 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7703 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7704 #define TIF_SINGLESTEP 8 /* singlestepping active */
7705 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7706 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7707 for stack store? */
7708 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7709 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7710 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7711 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7712
7713 /* as above, but as bit values */
7714 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7715 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7716 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7717 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7718 #define _TIF_NOHZ (1<<TIF_NOHZ)
7719 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7720 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7721 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7722 - _TIF_NOHZ)
7723 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7724
7725 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7726 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7727 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7728 index 9485b43..4718d50 100644
7729 --- a/arch/powerpc/include/asm/uaccess.h
7730 +++ b/arch/powerpc/include/asm/uaccess.h
7731 @@ -318,52 +318,6 @@ do { \
7732 extern unsigned long __copy_tofrom_user(void __user *to,
7733 const void __user *from, unsigned long size);
7734
7735 -#ifndef __powerpc64__
7736 -
7737 -static inline unsigned long copy_from_user(void *to,
7738 - const void __user *from, unsigned long n)
7739 -{
7740 - unsigned long over;
7741 -
7742 - if (access_ok(VERIFY_READ, from, n))
7743 - return __copy_tofrom_user((__force void __user *)to, from, n);
7744 - if ((unsigned long)from < TASK_SIZE) {
7745 - over = (unsigned long)from + n - TASK_SIZE;
7746 - return __copy_tofrom_user((__force void __user *)to, from,
7747 - n - over) + over;
7748 - }
7749 - return n;
7750 -}
7751 -
7752 -static inline unsigned long copy_to_user(void __user *to,
7753 - const void *from, unsigned long n)
7754 -{
7755 - unsigned long over;
7756 -
7757 - if (access_ok(VERIFY_WRITE, to, n))
7758 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7759 - if ((unsigned long)to < TASK_SIZE) {
7760 - over = (unsigned long)to + n - TASK_SIZE;
7761 - return __copy_tofrom_user(to, (__force void __user *)from,
7762 - n - over) + over;
7763 - }
7764 - return n;
7765 -}
7766 -
7767 -#else /* __powerpc64__ */
7768 -
7769 -#define __copy_in_user(to, from, size) \
7770 - __copy_tofrom_user((to), (from), (size))
7771 -
7772 -extern unsigned long copy_from_user(void *to, const void __user *from,
7773 - unsigned long n);
7774 -extern unsigned long copy_to_user(void __user *to, const void *from,
7775 - unsigned long n);
7776 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7777 - unsigned long n);
7778 -
7779 -#endif /* __powerpc64__ */
7780 -
7781 static inline unsigned long __copy_from_user_inatomic(void *to,
7782 const void __user *from, unsigned long n)
7783 {
7784 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7785 if (ret == 0)
7786 return 0;
7787 }
7788 +
7789 + if (!__builtin_constant_p(n))
7790 + check_object_size(to, n, false);
7791 +
7792 return __copy_tofrom_user((__force void __user *)to, from, n);
7793 }
7794
7795 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7796 if (ret == 0)
7797 return 0;
7798 }
7799 +
7800 + if (!__builtin_constant_p(n))
7801 + check_object_size(from, n, true);
7802 +
7803 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7804 }
7805
7806 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7807 return __copy_to_user_inatomic(to, from, size);
7808 }
7809
7810 +#ifndef __powerpc64__
7811 +
7812 +static inline unsigned long __must_check copy_from_user(void *to,
7813 + const void __user *from, unsigned long n)
7814 +{
7815 + unsigned long over;
7816 +
7817 + if ((long)n < 0)
7818 + return n;
7819 +
7820 + if (access_ok(VERIFY_READ, from, n)) {
7821 + if (!__builtin_constant_p(n))
7822 + check_object_size(to, n, false);
7823 + return __copy_tofrom_user((__force void __user *)to, from, n);
7824 + }
7825 + if ((unsigned long)from < TASK_SIZE) {
7826 + over = (unsigned long)from + n - TASK_SIZE;
7827 + if (!__builtin_constant_p(n - over))
7828 + check_object_size(to, n - over, false);
7829 + return __copy_tofrom_user((__force void __user *)to, from,
7830 + n - over) + over;
7831 + }
7832 + return n;
7833 +}
7834 +
7835 +static inline unsigned long __must_check copy_to_user(void __user *to,
7836 + const void *from, unsigned long n)
7837 +{
7838 + unsigned long over;
7839 +
7840 + if ((long)n < 0)
7841 + return n;
7842 +
7843 + if (access_ok(VERIFY_WRITE, to, n)) {
7844 + if (!__builtin_constant_p(n))
7845 + check_object_size(from, n, true);
7846 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7847 + }
7848 + if ((unsigned long)to < TASK_SIZE) {
7849 + over = (unsigned long)to + n - TASK_SIZE;
7850 + if (!__builtin_constant_p(n))
7851 + check_object_size(from, n - over, true);
7852 + return __copy_tofrom_user(to, (__force void __user *)from,
7853 + n - over) + over;
7854 + }
7855 + return n;
7856 +}
7857 +
7858 +#else /* __powerpc64__ */
7859 +
7860 +#define __copy_in_user(to, from, size) \
7861 + __copy_tofrom_user((to), (from), (size))
7862 +
7863 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7864 +{
7865 + if ((long)n < 0 || n > INT_MAX)
7866 + return n;
7867 +
7868 + if (!__builtin_constant_p(n))
7869 + check_object_size(to, n, false);
7870 +
7871 + if (likely(access_ok(VERIFY_READ, from, n)))
7872 + n = __copy_from_user(to, from, n);
7873 + else
7874 + memset(to, 0, n);
7875 + return n;
7876 +}
7877 +
7878 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7879 +{
7880 + if ((long)n < 0 || n > INT_MAX)
7881 + return n;
7882 +
7883 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7884 + if (!__builtin_constant_p(n))
7885 + check_object_size(from, n, true);
7886 + n = __copy_to_user(to, from, n);
7887 + }
7888 + return n;
7889 +}
7890 +
7891 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7892 + unsigned long n);
7893 +
7894 +#endif /* __powerpc64__ */
7895 +
7896 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7897
7898 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7899 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7900 index 645170a..6cf0271 100644
7901 --- a/arch/powerpc/kernel/exceptions-64e.S
7902 +++ b/arch/powerpc/kernel/exceptions-64e.S
7903 @@ -757,6 +757,7 @@ storage_fault_common:
7904 std r14,_DAR(r1)
7905 std r15,_DSISR(r1)
7906 addi r3,r1,STACK_FRAME_OVERHEAD
7907 + bl .save_nvgprs
7908 mr r4,r14
7909 mr r5,r15
7910 ld r14,PACA_EXGEN+EX_R14(r13)
7911 @@ -765,8 +766,7 @@ storage_fault_common:
7912 cmpdi r3,0
7913 bne- 1f
7914 b .ret_from_except_lite
7915 -1: bl .save_nvgprs
7916 - mr r5,r3
7917 +1: mr r5,r3
7918 addi r3,r1,STACK_FRAME_OVERHEAD
7919 ld r4,_DAR(r1)
7920 bl .bad_page_fault
7921 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7922 index 902ca3c..e942155 100644
7923 --- a/arch/powerpc/kernel/exceptions-64s.S
7924 +++ b/arch/powerpc/kernel/exceptions-64s.S
7925 @@ -1357,10 +1357,10 @@ handle_page_fault:
7926 11: ld r4,_DAR(r1)
7927 ld r5,_DSISR(r1)
7928 addi r3,r1,STACK_FRAME_OVERHEAD
7929 + bl .save_nvgprs
7930 bl .do_page_fault
7931 cmpdi r3,0
7932 beq+ 12f
7933 - bl .save_nvgprs
7934 mr r5,r3
7935 addi r3,r1,STACK_FRAME_OVERHEAD
7936 lwz r4,_DAR(r1)
7937 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7938 index 2e3200c..72095ce 100644
7939 --- a/arch/powerpc/kernel/module_32.c
7940 +++ b/arch/powerpc/kernel/module_32.c
7941 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7942 me->arch.core_plt_section = i;
7943 }
7944 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7945 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7946 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7947 return -ENOEXEC;
7948 }
7949
7950 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7951
7952 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7953 /* Init, or core PLT? */
7954 - if (location >= mod->module_core
7955 - && location < mod->module_core + mod->core_size)
7956 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7957 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7958 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7959 - else
7960 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7961 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7962 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7963 + else {
7964 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7965 + return ~0UL;
7966 + }
7967
7968 /* Find this entry, or if that fails, the next avail. entry */
7969 while (entry->jump[0]) {
7970 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7971 index 8083be2..10aa352 100644
7972 --- a/arch/powerpc/kernel/process.c
7973 +++ b/arch/powerpc/kernel/process.c
7974 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
7975 * Lookup NIP late so we have the best change of getting the
7976 * above info out without failing
7977 */
7978 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7979 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7980 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7981 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7982 #endif
7983 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
7984 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
7985 @@ -1349,10 +1349,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7986 newsp = stack[0];
7987 ip = stack[STACK_FRAME_LR_SAVE];
7988 if (!firstframe || ip != lr) {
7989 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
7990 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
7991 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
7992 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
7993 - printk(" (%pS)",
7994 + printk(" (%pA)",
7995 (void *)current->ret_stack[curr_frame].ret);
7996 curr_frame--;
7997 }
7998 @@ -1372,7 +1372,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7999 struct pt_regs *regs = (struct pt_regs *)
8000 (sp + STACK_FRAME_OVERHEAD);
8001 lr = regs->link;
8002 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8003 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8004 regs->trap, (void *)regs->nip, (void *)lr);
8005 firstframe = 1;
8006 }
8007 @@ -1408,58 +1408,3 @@ void notrace __ppc64_runlatch_off(void)
8008 mtspr(SPRN_CTRLT, ctrl);
8009 }
8010 #endif /* CONFIG_PPC64 */
8011 -
8012 -unsigned long arch_align_stack(unsigned long sp)
8013 -{
8014 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8015 - sp -= get_random_int() & ~PAGE_MASK;
8016 - return sp & ~0xf;
8017 -}
8018 -
8019 -static inline unsigned long brk_rnd(void)
8020 -{
8021 - unsigned long rnd = 0;
8022 -
8023 - /* 8MB for 32bit, 1GB for 64bit */
8024 - if (is_32bit_task())
8025 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8026 - else
8027 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8028 -
8029 - return rnd << PAGE_SHIFT;
8030 -}
8031 -
8032 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8033 -{
8034 - unsigned long base = mm->brk;
8035 - unsigned long ret;
8036 -
8037 -#ifdef CONFIG_PPC_STD_MMU_64
8038 - /*
8039 - * If we are using 1TB segments and we are allowed to randomise
8040 - * the heap, we can put it above 1TB so it is backed by a 1TB
8041 - * segment. Otherwise the heap will be in the bottom 1TB
8042 - * which always uses 256MB segments and this may result in a
8043 - * performance penalty.
8044 - */
8045 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8046 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8047 -#endif
8048 -
8049 - ret = PAGE_ALIGN(base + brk_rnd());
8050 -
8051 - if (ret < mm->brk)
8052 - return mm->brk;
8053 -
8054 - return ret;
8055 -}
8056 -
8057 -unsigned long randomize_et_dyn(unsigned long base)
8058 -{
8059 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8060 -
8061 - if (ret < base)
8062 - return base;
8063 -
8064 - return ret;
8065 -}
8066 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8067 index 9a0d24c..e7fbedf 100644
8068 --- a/arch/powerpc/kernel/ptrace.c
8069 +++ b/arch/powerpc/kernel/ptrace.c
8070 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8071 return ret;
8072 }
8073
8074 +#ifdef CONFIG_GRKERNSEC_SETXID
8075 +extern void gr_delayed_cred_worker(void);
8076 +#endif
8077 +
8078 /*
8079 * We must return the syscall number to actually look up in the table.
8080 * This can be -1L to skip running any syscall at all.
8081 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8082
8083 secure_computing_strict(regs->gpr[0]);
8084
8085 +#ifdef CONFIG_GRKERNSEC_SETXID
8086 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8087 + gr_delayed_cred_worker();
8088 +#endif
8089 +
8090 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8091 tracehook_report_syscall_entry(regs))
8092 /*
8093 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8094 {
8095 int step;
8096
8097 +#ifdef CONFIG_GRKERNSEC_SETXID
8098 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8099 + gr_delayed_cred_worker();
8100 +#endif
8101 +
8102 audit_syscall_exit(regs);
8103
8104 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8105 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8106 index 0f83122..c0aca6a 100644
8107 --- a/arch/powerpc/kernel/signal_32.c
8108 +++ b/arch/powerpc/kernel/signal_32.c
8109 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8110 /* Save user registers on the stack */
8111 frame = &rt_sf->uc.uc_mcontext;
8112 addr = frame;
8113 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8114 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8115 sigret = 0;
8116 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8117 } else {
8118 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8119 index 887e99d..310bc11 100644
8120 --- a/arch/powerpc/kernel/signal_64.c
8121 +++ b/arch/powerpc/kernel/signal_64.c
8122 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8123 #endif
8124
8125 /* Set up to return from userspace. */
8126 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8127 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8128 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8129 } else {
8130 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8131 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8132 index e435bc0..41c2964 100644
8133 --- a/arch/powerpc/kernel/traps.c
8134 +++ b/arch/powerpc/kernel/traps.c
8135 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8136 return flags;
8137 }
8138
8139 +extern void gr_handle_kernel_exploit(void);
8140 +
8141 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8142 int signr)
8143 {
8144 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8145 panic("Fatal exception in interrupt");
8146 if (panic_on_oops)
8147 panic("Fatal exception");
8148 +
8149 + gr_handle_kernel_exploit();
8150 +
8151 do_exit(signr);
8152 }
8153
8154 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8155 index 1d9c926..25f4741 100644
8156 --- a/arch/powerpc/kernel/vdso.c
8157 +++ b/arch/powerpc/kernel/vdso.c
8158 @@ -34,6 +34,7 @@
8159 #include <asm/firmware.h>
8160 #include <asm/vdso.h>
8161 #include <asm/vdso_datapage.h>
8162 +#include <asm/mman.h>
8163
8164 #include "setup.h"
8165
8166 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8167 vdso_base = VDSO32_MBASE;
8168 #endif
8169
8170 - current->mm->context.vdso_base = 0;
8171 + current->mm->context.vdso_base = ~0UL;
8172
8173 /* vDSO has a problem and was disabled, just don't "enable" it for the
8174 * process
8175 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8176 vdso_base = get_unmapped_area(NULL, vdso_base,
8177 (vdso_pages << PAGE_SHIFT) +
8178 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8179 - 0, 0);
8180 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8181 if (IS_ERR_VALUE(vdso_base)) {
8182 rc = vdso_base;
8183 goto fail_mmapsem;
8184 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8185 index 5eea6f3..5d10396 100644
8186 --- a/arch/powerpc/lib/usercopy_64.c
8187 +++ b/arch/powerpc/lib/usercopy_64.c
8188 @@ -9,22 +9,6 @@
8189 #include <linux/module.h>
8190 #include <asm/uaccess.h>
8191
8192 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8193 -{
8194 - if (likely(access_ok(VERIFY_READ, from, n)))
8195 - n = __copy_from_user(to, from, n);
8196 - else
8197 - memset(to, 0, n);
8198 - return n;
8199 -}
8200 -
8201 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8202 -{
8203 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8204 - n = __copy_to_user(to, from, n);
8205 - return n;
8206 -}
8207 -
8208 unsigned long copy_in_user(void __user *to, const void __user *from,
8209 unsigned long n)
8210 {
8211 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8212 return n;
8213 }
8214
8215 -EXPORT_SYMBOL(copy_from_user);
8216 -EXPORT_SYMBOL(copy_to_user);
8217 EXPORT_SYMBOL(copy_in_user);
8218
8219 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8220 index 8726779..a33c512 100644
8221 --- a/arch/powerpc/mm/fault.c
8222 +++ b/arch/powerpc/mm/fault.c
8223 @@ -33,6 +33,10 @@
8224 #include <linux/magic.h>
8225 #include <linux/ratelimit.h>
8226 #include <linux/context_tracking.h>
8227 +#include <linux/slab.h>
8228 +#include <linux/pagemap.h>
8229 +#include <linux/compiler.h>
8230 +#include <linux/unistd.h>
8231
8232 #include <asm/firmware.h>
8233 #include <asm/page.h>
8234 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8235 }
8236 #endif
8237
8238 +#ifdef CONFIG_PAX_PAGEEXEC
8239 +/*
8240 + * PaX: decide what to do with offenders (regs->nip = fault address)
8241 + *
8242 + * returns 1 when task should be killed
8243 + */
8244 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8245 +{
8246 + return 1;
8247 +}
8248 +
8249 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8250 +{
8251 + unsigned long i;
8252 +
8253 + printk(KERN_ERR "PAX: bytes at PC: ");
8254 + for (i = 0; i < 5; i++) {
8255 + unsigned int c;
8256 + if (get_user(c, (unsigned int __user *)pc+i))
8257 + printk(KERN_CONT "???????? ");
8258 + else
8259 + printk(KERN_CONT "%08x ", c);
8260 + }
8261 + printk("\n");
8262 +}
8263 +#endif
8264 +
8265 /*
8266 * Check whether the instruction at regs->nip is a store using
8267 * an update addressing form which will update r1.
8268 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8269 * indicate errors in DSISR but can validly be set in SRR1.
8270 */
8271 if (trap == 0x400)
8272 - error_code &= 0x48200000;
8273 + error_code &= 0x58200000;
8274 else
8275 is_write = error_code & DSISR_ISSTORE;
8276 #else
8277 @@ -371,7 +402,7 @@ good_area:
8278 * "undefined". Of those that can be set, this is the only
8279 * one which seems bad.
8280 */
8281 - if (error_code & 0x10000000)
8282 + if (error_code & DSISR_GUARDED)
8283 /* Guarded storage error. */
8284 goto bad_area;
8285 #endif /* CONFIG_8xx */
8286 @@ -386,7 +417,7 @@ good_area:
8287 * processors use the same I/D cache coherency mechanism
8288 * as embedded.
8289 */
8290 - if (error_code & DSISR_PROTFAULT)
8291 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8292 goto bad_area;
8293 #endif /* CONFIG_PPC_STD_MMU */
8294
8295 @@ -471,6 +502,23 @@ bad_area:
8296 bad_area_nosemaphore:
8297 /* User mode accesses cause a SIGSEGV */
8298 if (user_mode(regs)) {
8299 +
8300 +#ifdef CONFIG_PAX_PAGEEXEC
8301 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8302 +#ifdef CONFIG_PPC_STD_MMU
8303 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8304 +#else
8305 + if (is_exec && regs->nip == address) {
8306 +#endif
8307 + switch (pax_handle_fetch_fault(regs)) {
8308 + }
8309 +
8310 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8311 + do_group_exit(SIGKILL);
8312 + }
8313 + }
8314 +#endif
8315 +
8316 _exception(SIGSEGV, regs, code, address);
8317 goto bail;
8318 }
8319 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8320 index cb8bdbe..d770680 100644
8321 --- a/arch/powerpc/mm/mmap.c
8322 +++ b/arch/powerpc/mm/mmap.c
8323 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8324 {
8325 unsigned long rnd = 0;
8326
8327 +#ifdef CONFIG_PAX_RANDMMAP
8328 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8329 +#endif
8330 +
8331 if (current->flags & PF_RANDOMIZE) {
8332 /* 8MB for 32bit, 1GB for 64bit */
8333 if (is_32bit_task())
8334 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8335 */
8336 if (mmap_is_legacy()) {
8337 mm->mmap_base = TASK_UNMAPPED_BASE;
8338 +
8339 +#ifdef CONFIG_PAX_RANDMMAP
8340 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8341 + mm->mmap_base += mm->delta_mmap;
8342 +#endif
8343 +
8344 mm->get_unmapped_area = arch_get_unmapped_area;
8345 } else {
8346 mm->mmap_base = mmap_base();
8347 +
8348 +#ifdef CONFIG_PAX_RANDMMAP
8349 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8350 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8351 +#endif
8352 +
8353 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8354 }
8355 }
8356 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8357 index 3e99c14..f00953c 100644
8358 --- a/arch/powerpc/mm/slice.c
8359 +++ b/arch/powerpc/mm/slice.c
8360 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8361 if ((mm->task_size - len) < addr)
8362 return 0;
8363 vma = find_vma(mm, addr);
8364 - return (!vma || (addr + len) <= vma->vm_start);
8365 + return check_heap_stack_gap(vma, addr, len, 0);
8366 }
8367
8368 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8369 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8370 info.align_offset = 0;
8371
8372 addr = TASK_UNMAPPED_BASE;
8373 +
8374 +#ifdef CONFIG_PAX_RANDMMAP
8375 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8376 + addr += mm->delta_mmap;
8377 +#endif
8378 +
8379 while (addr < TASK_SIZE) {
8380 info.low_limit = addr;
8381 if (!slice_scan_available(addr, available, 1, &addr))
8382 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8383 if (fixed && addr > (mm->task_size - len))
8384 return -EINVAL;
8385
8386 +#ifdef CONFIG_PAX_RANDMMAP
8387 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8388 + addr = 0;
8389 +#endif
8390 +
8391 /* If hint, make sure it matches our alignment restrictions */
8392 if (!fixed && addr) {
8393 addr = _ALIGN_UP(addr, 1ul << pshift);
8394 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8395 index 9098692..3d54cd1 100644
8396 --- a/arch/powerpc/platforms/cell/spufs/file.c
8397 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8398 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8399 return VM_FAULT_NOPAGE;
8400 }
8401
8402 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8403 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8404 unsigned long address,
8405 - void *buf, int len, int write)
8406 + void *buf, size_t len, int write)
8407 {
8408 struct spu_context *ctx = vma->vm_file->private_data;
8409 unsigned long offset = address - vma->vm_start;
8410 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8411 index c797832..ce575c8 100644
8412 --- a/arch/s390/include/asm/atomic.h
8413 +++ b/arch/s390/include/asm/atomic.h
8414 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8415 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8416 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8417
8418 +#define atomic64_read_unchecked(v) atomic64_read(v)
8419 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8420 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8421 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8422 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8423 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8424 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8425 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8426 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8427 +
8428 #define smp_mb__before_atomic_dec() smp_mb()
8429 #define smp_mb__after_atomic_dec() smp_mb()
8430 #define smp_mb__before_atomic_inc() smp_mb()
8431 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8432 index 4d7ccac..d03d0ad 100644
8433 --- a/arch/s390/include/asm/cache.h
8434 +++ b/arch/s390/include/asm/cache.h
8435 @@ -9,8 +9,10 @@
8436 #ifndef __ARCH_S390_CACHE_H
8437 #define __ARCH_S390_CACHE_H
8438
8439 -#define L1_CACHE_BYTES 256
8440 +#include <linux/const.h>
8441 +
8442 #define L1_CACHE_SHIFT 8
8443 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8444 #define NET_SKB_PAD 32
8445
8446 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8447 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8448 index 78f4f87..598ce39 100644
8449 --- a/arch/s390/include/asm/elf.h
8450 +++ b/arch/s390/include/asm/elf.h
8451 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8452 the loader. We need to make sure that it is out of the way of the program
8453 that it will "exec", and that there is sufficient room for the brk. */
8454
8455 -extern unsigned long randomize_et_dyn(unsigned long base);
8456 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8457 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8458 +
8459 +#ifdef CONFIG_PAX_ASLR
8460 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8461 +
8462 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8463 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8464 +#endif
8465
8466 /* This yields a mask that user programs can use to figure out what
8467 instruction set this CPU supports. */
8468 @@ -222,9 +228,6 @@ struct linux_binprm;
8469 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8470 int arch_setup_additional_pages(struct linux_binprm *, int);
8471
8472 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8473 -#define arch_randomize_brk arch_randomize_brk
8474 -
8475 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8476
8477 #endif
8478 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8479 index c4a93d6..4d2a9b4 100644
8480 --- a/arch/s390/include/asm/exec.h
8481 +++ b/arch/s390/include/asm/exec.h
8482 @@ -7,6 +7,6 @@
8483 #ifndef __ASM_EXEC_H
8484 #define __ASM_EXEC_H
8485
8486 -extern unsigned long arch_align_stack(unsigned long sp);
8487 +#define arch_align_stack(x) ((x) & ~0xfUL)
8488
8489 #endif /* __ASM_EXEC_H */
8490 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8491 index 9c33ed4..e40cbef 100644
8492 --- a/arch/s390/include/asm/uaccess.h
8493 +++ b/arch/s390/include/asm/uaccess.h
8494 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8495 copy_to_user(void __user *to, const void *from, unsigned long n)
8496 {
8497 might_fault();
8498 +
8499 + if ((long)n < 0)
8500 + return n;
8501 +
8502 return __copy_to_user(to, from, n);
8503 }
8504
8505 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8506 static inline unsigned long __must_check
8507 __copy_from_user(void *to, const void __user *from, unsigned long n)
8508 {
8509 + if ((long)n < 0)
8510 + return n;
8511 +
8512 if (__builtin_constant_p(n) && (n <= 256))
8513 return uaccess.copy_from_user_small(n, from, to);
8514 else
8515 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8516 static inline unsigned long __must_check
8517 copy_from_user(void *to, const void __user *from, unsigned long n)
8518 {
8519 - unsigned int sz = __compiletime_object_size(to);
8520 + size_t sz = __compiletime_object_size(to);
8521
8522 might_fault();
8523 - if (unlikely(sz != -1 && sz < n)) {
8524 +
8525 + if ((long)n < 0)
8526 + return n;
8527 +
8528 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8529 copy_from_user_overflow();
8530 return n;
8531 }
8532 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8533 index 7845e15..59c4353 100644
8534 --- a/arch/s390/kernel/module.c
8535 +++ b/arch/s390/kernel/module.c
8536 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8537
8538 /* Increase core size by size of got & plt and set start
8539 offsets for got and plt. */
8540 - me->core_size = ALIGN(me->core_size, 4);
8541 - me->arch.got_offset = me->core_size;
8542 - me->core_size += me->arch.got_size;
8543 - me->arch.plt_offset = me->core_size;
8544 - me->core_size += me->arch.plt_size;
8545 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8546 + me->arch.got_offset = me->core_size_rw;
8547 + me->core_size_rw += me->arch.got_size;
8548 + me->arch.plt_offset = me->core_size_rx;
8549 + me->core_size_rx += me->arch.plt_size;
8550 return 0;
8551 }
8552
8553 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8554 if (info->got_initialized == 0) {
8555 Elf_Addr *gotent;
8556
8557 - gotent = me->module_core + me->arch.got_offset +
8558 + gotent = me->module_core_rw + me->arch.got_offset +
8559 info->got_offset;
8560 *gotent = val;
8561 info->got_initialized = 1;
8562 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8563 rc = apply_rela_bits(loc, val, 0, 64, 0);
8564 else if (r_type == R_390_GOTENT ||
8565 r_type == R_390_GOTPLTENT) {
8566 - val += (Elf_Addr) me->module_core - loc;
8567 + val += (Elf_Addr) me->module_core_rw - loc;
8568 rc = apply_rela_bits(loc, val, 1, 32, 1);
8569 }
8570 break;
8571 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8572 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8573 if (info->plt_initialized == 0) {
8574 unsigned int *ip;
8575 - ip = me->module_core + me->arch.plt_offset +
8576 + ip = me->module_core_rx + me->arch.plt_offset +
8577 info->plt_offset;
8578 #ifndef CONFIG_64BIT
8579 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8580 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8581 val - loc + 0xffffUL < 0x1ffffeUL) ||
8582 (r_type == R_390_PLT32DBL &&
8583 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8584 - val = (Elf_Addr) me->module_core +
8585 + val = (Elf_Addr) me->module_core_rx +
8586 me->arch.plt_offset +
8587 info->plt_offset;
8588 val += rela->r_addend - loc;
8589 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8590 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8591 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8592 val = val + rela->r_addend -
8593 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8594 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8595 if (r_type == R_390_GOTOFF16)
8596 rc = apply_rela_bits(loc, val, 0, 16, 0);
8597 else if (r_type == R_390_GOTOFF32)
8598 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8599 break;
8600 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8601 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8602 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8603 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8604 rela->r_addend - loc;
8605 if (r_type == R_390_GOTPC)
8606 rc = apply_rela_bits(loc, val, 1, 32, 0);
8607 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8608 index 2bc3edd..ab9d598 100644
8609 --- a/arch/s390/kernel/process.c
8610 +++ b/arch/s390/kernel/process.c
8611 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
8612 }
8613 return 0;
8614 }
8615 -
8616 -unsigned long arch_align_stack(unsigned long sp)
8617 -{
8618 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8619 - sp -= get_random_int() & ~PAGE_MASK;
8620 - return sp & ~0xf;
8621 -}
8622 -
8623 -static inline unsigned long brk_rnd(void)
8624 -{
8625 - /* 8MB for 32bit, 1GB for 64bit */
8626 - if (is_32bit_task())
8627 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8628 - else
8629 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8630 -}
8631 -
8632 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8633 -{
8634 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8635 -
8636 - if (ret < mm->brk)
8637 - return mm->brk;
8638 - return ret;
8639 -}
8640 -
8641 -unsigned long randomize_et_dyn(unsigned long base)
8642 -{
8643 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8644 -
8645 - if (!(current->flags & PF_RANDOMIZE))
8646 - return base;
8647 - if (ret < base)
8648 - return base;
8649 - return ret;
8650 -}
8651 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8652 index 4002329..99b67cb 100644
8653 --- a/arch/s390/mm/mmap.c
8654 +++ b/arch/s390/mm/mmap.c
8655 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8656 */
8657 if (mmap_is_legacy()) {
8658 mm->mmap_base = TASK_UNMAPPED_BASE;
8659 +
8660 +#ifdef CONFIG_PAX_RANDMMAP
8661 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8662 + mm->mmap_base += mm->delta_mmap;
8663 +#endif
8664 +
8665 mm->get_unmapped_area = arch_get_unmapped_area;
8666 } else {
8667 mm->mmap_base = mmap_base();
8668 +
8669 +#ifdef CONFIG_PAX_RANDMMAP
8670 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8671 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8672 +#endif
8673 +
8674 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8675 }
8676 }
8677 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8678 */
8679 if (mmap_is_legacy()) {
8680 mm->mmap_base = TASK_UNMAPPED_BASE;
8681 +
8682 +#ifdef CONFIG_PAX_RANDMMAP
8683 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8684 + mm->mmap_base += mm->delta_mmap;
8685 +#endif
8686 +
8687 mm->get_unmapped_area = s390_get_unmapped_area;
8688 } else {
8689 mm->mmap_base = mmap_base();
8690 +
8691 +#ifdef CONFIG_PAX_RANDMMAP
8692 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8693 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8694 +#endif
8695 +
8696 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8697 }
8698 }
8699 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8700 index ae3d59f..f65f075 100644
8701 --- a/arch/score/include/asm/cache.h
8702 +++ b/arch/score/include/asm/cache.h
8703 @@ -1,7 +1,9 @@
8704 #ifndef _ASM_SCORE_CACHE_H
8705 #define _ASM_SCORE_CACHE_H
8706
8707 +#include <linux/const.h>
8708 +
8709 #define L1_CACHE_SHIFT 4
8710 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8711 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8712
8713 #endif /* _ASM_SCORE_CACHE_H */
8714 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8715 index f9f3cd5..58ff438 100644
8716 --- a/arch/score/include/asm/exec.h
8717 +++ b/arch/score/include/asm/exec.h
8718 @@ -1,6 +1,6 @@
8719 #ifndef _ASM_SCORE_EXEC_H
8720 #define _ASM_SCORE_EXEC_H
8721
8722 -extern unsigned long arch_align_stack(unsigned long sp);
8723 +#define arch_align_stack(x) (x)
8724
8725 #endif /* _ASM_SCORE_EXEC_H */
8726 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8727 index f4c6d02..e9355c3 100644
8728 --- a/arch/score/kernel/process.c
8729 +++ b/arch/score/kernel/process.c
8730 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8731
8732 return task_pt_regs(task)->cp0_epc;
8733 }
8734 -
8735 -unsigned long arch_align_stack(unsigned long sp)
8736 -{
8737 - return sp;
8738 -}
8739 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8740 index ef9e555..331bd29 100644
8741 --- a/arch/sh/include/asm/cache.h
8742 +++ b/arch/sh/include/asm/cache.h
8743 @@ -9,10 +9,11 @@
8744 #define __ASM_SH_CACHE_H
8745 #ifdef __KERNEL__
8746
8747 +#include <linux/const.h>
8748 #include <linux/init.h>
8749 #include <cpu/cache.h>
8750
8751 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8752 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8753
8754 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8755
8756 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8757 index 6777177..cb5e44f 100644
8758 --- a/arch/sh/mm/mmap.c
8759 +++ b/arch/sh/mm/mmap.c
8760 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8761 struct mm_struct *mm = current->mm;
8762 struct vm_area_struct *vma;
8763 int do_colour_align;
8764 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8765 struct vm_unmapped_area_info info;
8766
8767 if (flags & MAP_FIXED) {
8768 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8769 if (filp || (flags & MAP_SHARED))
8770 do_colour_align = 1;
8771
8772 +#ifdef CONFIG_PAX_RANDMMAP
8773 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8774 +#endif
8775 +
8776 if (addr) {
8777 if (do_colour_align)
8778 addr = COLOUR_ALIGN(addr, pgoff);
8779 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8780 addr = PAGE_ALIGN(addr);
8781
8782 vma = find_vma(mm, addr);
8783 - if (TASK_SIZE - len >= addr &&
8784 - (!vma || addr + len <= vma->vm_start))
8785 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8786 return addr;
8787 }
8788
8789 info.flags = 0;
8790 info.length = len;
8791 - info.low_limit = TASK_UNMAPPED_BASE;
8792 + info.low_limit = mm->mmap_base;
8793 info.high_limit = TASK_SIZE;
8794 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8795 info.align_offset = pgoff << PAGE_SHIFT;
8796 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8797 struct mm_struct *mm = current->mm;
8798 unsigned long addr = addr0;
8799 int do_colour_align;
8800 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8801 struct vm_unmapped_area_info info;
8802
8803 if (flags & MAP_FIXED) {
8804 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8805 if (filp || (flags & MAP_SHARED))
8806 do_colour_align = 1;
8807
8808 +#ifdef CONFIG_PAX_RANDMMAP
8809 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8810 +#endif
8811 +
8812 /* requesting a specific address */
8813 if (addr) {
8814 if (do_colour_align)
8815 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8816 addr = PAGE_ALIGN(addr);
8817
8818 vma = find_vma(mm, addr);
8819 - if (TASK_SIZE - len >= addr &&
8820 - (!vma || addr + len <= vma->vm_start))
8821 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8822 return addr;
8823 }
8824
8825 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8826 VM_BUG_ON(addr != -ENOMEM);
8827 info.flags = 0;
8828 info.low_limit = TASK_UNMAPPED_BASE;
8829 +
8830 +#ifdef CONFIG_PAX_RANDMMAP
8831 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8832 + info.low_limit += mm->delta_mmap;
8833 +#endif
8834 +
8835 info.high_limit = TASK_SIZE;
8836 addr = vm_unmapped_area(&info);
8837 }
8838 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8839 index be56a24..443328f 100644
8840 --- a/arch/sparc/include/asm/atomic_64.h
8841 +++ b/arch/sparc/include/asm/atomic_64.h
8842 @@ -14,18 +14,40 @@
8843 #define ATOMIC64_INIT(i) { (i) }
8844
8845 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8846 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8847 +{
8848 + return v->counter;
8849 +}
8850 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8851 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8852 +{
8853 + return v->counter;
8854 +}
8855
8856 #define atomic_set(v, i) (((v)->counter) = i)
8857 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8858 +{
8859 + v->counter = i;
8860 +}
8861 #define atomic64_set(v, i) (((v)->counter) = i)
8862 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8863 +{
8864 + v->counter = i;
8865 +}
8866
8867 extern void atomic_add(int, atomic_t *);
8868 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8869 extern void atomic64_add(long, atomic64_t *);
8870 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8871 extern void atomic_sub(int, atomic_t *);
8872 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8873 extern void atomic64_sub(long, atomic64_t *);
8874 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8875
8876 extern int atomic_add_ret(int, atomic_t *);
8877 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8878 extern long atomic64_add_ret(long, atomic64_t *);
8879 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8880 extern int atomic_sub_ret(int, atomic_t *);
8881 extern long atomic64_sub_ret(long, atomic64_t *);
8882
8883 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8884 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8885
8886 #define atomic_inc_return(v) atomic_add_ret(1, v)
8887 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8888 +{
8889 + return atomic_add_ret_unchecked(1, v);
8890 +}
8891 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8892 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8893 +{
8894 + return atomic64_add_ret_unchecked(1, v);
8895 +}
8896
8897 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8898 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8899
8900 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8901 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8902 +{
8903 + return atomic_add_ret_unchecked(i, v);
8904 +}
8905 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8906 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8907 +{
8908 + return atomic64_add_ret_unchecked(i, v);
8909 +}
8910
8911 /*
8912 * atomic_inc_and_test - increment and test
8913 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8914 * other cases.
8915 */
8916 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8917 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8918 +{
8919 + return atomic_inc_return_unchecked(v) == 0;
8920 +}
8921 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8922
8923 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8924 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8925 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8926
8927 #define atomic_inc(v) atomic_add(1, v)
8928 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8929 +{
8930 + atomic_add_unchecked(1, v);
8931 +}
8932 #define atomic64_inc(v) atomic64_add(1, v)
8933 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8934 +{
8935 + atomic64_add_unchecked(1, v);
8936 +}
8937
8938 #define atomic_dec(v) atomic_sub(1, v)
8939 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8940 +{
8941 + atomic_sub_unchecked(1, v);
8942 +}
8943 #define atomic64_dec(v) atomic64_sub(1, v)
8944 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8945 +{
8946 + atomic64_sub_unchecked(1, v);
8947 +}
8948
8949 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8950 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8951
8952 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8953 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8954 +{
8955 + return cmpxchg(&v->counter, old, new);
8956 +}
8957 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8958 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8959 +{
8960 + return xchg(&v->counter, new);
8961 +}
8962
8963 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8964 {
8965 - int c, old;
8966 + int c, old, new;
8967 c = atomic_read(v);
8968 for (;;) {
8969 - if (unlikely(c == (u)))
8970 + if (unlikely(c == u))
8971 break;
8972 - old = atomic_cmpxchg((v), c, c + (a));
8973 +
8974 + asm volatile("addcc %2, %0, %0\n"
8975 +
8976 +#ifdef CONFIG_PAX_REFCOUNT
8977 + "tvs %%icc, 6\n"
8978 +#endif
8979 +
8980 + : "=r" (new)
8981 + : "0" (c), "ir" (a)
8982 + : "cc");
8983 +
8984 + old = atomic_cmpxchg(v, c, new);
8985 if (likely(old == c))
8986 break;
8987 c = old;
8988 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8989 #define atomic64_cmpxchg(v, o, n) \
8990 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8991 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8992 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8993 +{
8994 + return xchg(&v->counter, new);
8995 +}
8996
8997 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8998 {
8999 - long c, old;
9000 + long c, old, new;
9001 c = atomic64_read(v);
9002 for (;;) {
9003 - if (unlikely(c == (u)))
9004 + if (unlikely(c == u))
9005 break;
9006 - old = atomic64_cmpxchg((v), c, c + (a));
9007 +
9008 + asm volatile("addcc %2, %0, %0\n"
9009 +
9010 +#ifdef CONFIG_PAX_REFCOUNT
9011 + "tvs %%xcc, 6\n"
9012 +#endif
9013 +
9014 + : "=r" (new)
9015 + : "0" (c), "ir" (a)
9016 + : "cc");
9017 +
9018 + old = atomic64_cmpxchg(v, c, new);
9019 if (likely(old == c))
9020 break;
9021 c = old;
9022 }
9023 - return c != (u);
9024 + return c != u;
9025 }
9026
9027 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9028 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9029 index 5bb6991..5c2132e 100644
9030 --- a/arch/sparc/include/asm/cache.h
9031 +++ b/arch/sparc/include/asm/cache.h
9032 @@ -7,10 +7,12 @@
9033 #ifndef _SPARC_CACHE_H
9034 #define _SPARC_CACHE_H
9035
9036 +#include <linux/const.h>
9037 +
9038 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9039
9040 #define L1_CACHE_SHIFT 5
9041 -#define L1_CACHE_BYTES 32
9042 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9043
9044 #ifdef CONFIG_SPARC32
9045 #define SMP_CACHE_BYTES_SHIFT 5
9046 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9047 index a24e41f..47677ff 100644
9048 --- a/arch/sparc/include/asm/elf_32.h
9049 +++ b/arch/sparc/include/asm/elf_32.h
9050 @@ -114,6 +114,13 @@ typedef struct {
9051
9052 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9053
9054 +#ifdef CONFIG_PAX_ASLR
9055 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9056 +
9057 +#define PAX_DELTA_MMAP_LEN 16
9058 +#define PAX_DELTA_STACK_LEN 16
9059 +#endif
9060 +
9061 /* This yields a mask that user programs can use to figure out what
9062 instruction set this cpu supports. This can NOT be done in userspace
9063 on Sparc. */
9064 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9065 index 370ca1e..d4f4a98 100644
9066 --- a/arch/sparc/include/asm/elf_64.h
9067 +++ b/arch/sparc/include/asm/elf_64.h
9068 @@ -189,6 +189,13 @@ typedef struct {
9069 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9070 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9071
9072 +#ifdef CONFIG_PAX_ASLR
9073 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9074 +
9075 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9076 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9077 +#endif
9078 +
9079 extern unsigned long sparc64_elf_hwcap;
9080 #define ELF_HWCAP sparc64_elf_hwcap
9081
9082 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9083 index 9b1c36d..209298b 100644
9084 --- a/arch/sparc/include/asm/pgalloc_32.h
9085 +++ b/arch/sparc/include/asm/pgalloc_32.h
9086 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9087 }
9088
9089 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9090 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9091
9092 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9093 unsigned long address)
9094 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9095 index bcfe063..b333142 100644
9096 --- a/arch/sparc/include/asm/pgalloc_64.h
9097 +++ b/arch/sparc/include/asm/pgalloc_64.h
9098 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9099 }
9100
9101 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9102 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9103
9104 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9105 {
9106 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9107 index 502f632..da1917f 100644
9108 --- a/arch/sparc/include/asm/pgtable_32.h
9109 +++ b/arch/sparc/include/asm/pgtable_32.h
9110 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9111 #define PAGE_SHARED SRMMU_PAGE_SHARED
9112 #define PAGE_COPY SRMMU_PAGE_COPY
9113 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9114 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9115 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9116 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9117 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9118
9119 /* Top-level page directory - dummy used by init-mm.
9120 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9121
9122 /* xwr */
9123 #define __P000 PAGE_NONE
9124 -#define __P001 PAGE_READONLY
9125 -#define __P010 PAGE_COPY
9126 -#define __P011 PAGE_COPY
9127 +#define __P001 PAGE_READONLY_NOEXEC
9128 +#define __P010 PAGE_COPY_NOEXEC
9129 +#define __P011 PAGE_COPY_NOEXEC
9130 #define __P100 PAGE_READONLY
9131 #define __P101 PAGE_READONLY
9132 #define __P110 PAGE_COPY
9133 #define __P111 PAGE_COPY
9134
9135 #define __S000 PAGE_NONE
9136 -#define __S001 PAGE_READONLY
9137 -#define __S010 PAGE_SHARED
9138 -#define __S011 PAGE_SHARED
9139 +#define __S001 PAGE_READONLY_NOEXEC
9140 +#define __S010 PAGE_SHARED_NOEXEC
9141 +#define __S011 PAGE_SHARED_NOEXEC
9142 #define __S100 PAGE_READONLY
9143 #define __S101 PAGE_READONLY
9144 #define __S110 PAGE_SHARED
9145 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9146 index 79da178..c2eede8 100644
9147 --- a/arch/sparc/include/asm/pgtsrmmu.h
9148 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9149 @@ -115,6 +115,11 @@
9150 SRMMU_EXEC | SRMMU_REF)
9151 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9152 SRMMU_EXEC | SRMMU_REF)
9153 +
9154 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9155 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9156 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9157 +
9158 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9159 SRMMU_DIRTY | SRMMU_REF)
9160
9161 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9162 index 9689176..63c18ea 100644
9163 --- a/arch/sparc/include/asm/spinlock_64.h
9164 +++ b/arch/sparc/include/asm/spinlock_64.h
9165 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9166
9167 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9168
9169 -static void inline arch_read_lock(arch_rwlock_t *lock)
9170 +static inline void arch_read_lock(arch_rwlock_t *lock)
9171 {
9172 unsigned long tmp1, tmp2;
9173
9174 __asm__ __volatile__ (
9175 "1: ldsw [%2], %0\n"
9176 " brlz,pn %0, 2f\n"
9177 -"4: add %0, 1, %1\n"
9178 +"4: addcc %0, 1, %1\n"
9179 +
9180 +#ifdef CONFIG_PAX_REFCOUNT
9181 +" tvs %%icc, 6\n"
9182 +#endif
9183 +
9184 " cas [%2], %0, %1\n"
9185 " cmp %0, %1\n"
9186 " bne,pn %%icc, 1b\n"
9187 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9188 " .previous"
9189 : "=&r" (tmp1), "=&r" (tmp2)
9190 : "r" (lock)
9191 - : "memory");
9192 + : "memory", "cc");
9193 }
9194
9195 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9196 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9197 {
9198 int tmp1, tmp2;
9199
9200 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9201 "1: ldsw [%2], %0\n"
9202 " brlz,a,pn %0, 2f\n"
9203 " mov 0, %0\n"
9204 -" add %0, 1, %1\n"
9205 +" addcc %0, 1, %1\n"
9206 +
9207 +#ifdef CONFIG_PAX_REFCOUNT
9208 +" tvs %%icc, 6\n"
9209 +#endif
9210 +
9211 " cas [%2], %0, %1\n"
9212 " cmp %0, %1\n"
9213 " bne,pn %%icc, 1b\n"
9214 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9215 return tmp1;
9216 }
9217
9218 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9219 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9220 {
9221 unsigned long tmp1, tmp2;
9222
9223 __asm__ __volatile__(
9224 "1: lduw [%2], %0\n"
9225 -" sub %0, 1, %1\n"
9226 +" subcc %0, 1, %1\n"
9227 +
9228 +#ifdef CONFIG_PAX_REFCOUNT
9229 +" tvs %%icc, 6\n"
9230 +#endif
9231 +
9232 " cas [%2], %0, %1\n"
9233 " cmp %0, %1\n"
9234 " bne,pn %%xcc, 1b\n"
9235 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9236 : "memory");
9237 }
9238
9239 -static void inline arch_write_lock(arch_rwlock_t *lock)
9240 +static inline void arch_write_lock(arch_rwlock_t *lock)
9241 {
9242 unsigned long mask, tmp1, tmp2;
9243
9244 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9245 : "memory");
9246 }
9247
9248 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9249 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9250 {
9251 __asm__ __volatile__(
9252 " stw %%g0, [%0]"
9253 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9254 : "memory");
9255 }
9256
9257 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9258 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9259 {
9260 unsigned long mask, tmp1, tmp2, result;
9261
9262 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9263 index dd38075..e7cac83 100644
9264 --- a/arch/sparc/include/asm/thread_info_32.h
9265 +++ b/arch/sparc/include/asm/thread_info_32.h
9266 @@ -49,6 +49,8 @@ struct thread_info {
9267 unsigned long w_saved;
9268
9269 struct restart_block restart_block;
9270 +
9271 + unsigned long lowest_stack;
9272 };
9273
9274 /*
9275 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9276 index d5e5042..9bfee76 100644
9277 --- a/arch/sparc/include/asm/thread_info_64.h
9278 +++ b/arch/sparc/include/asm/thread_info_64.h
9279 @@ -63,6 +63,8 @@ struct thread_info {
9280 struct pt_regs *kern_una_regs;
9281 unsigned int kern_una_insn;
9282
9283 + unsigned long lowest_stack;
9284 +
9285 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9286 };
9287
9288 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9289 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9290 /* flag bit 6 is available */
9291 #define TIF_32BIT 7 /* 32-bit binary */
9292 -/* flag bit 8 is available */
9293 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9294 #define TIF_SECCOMP 9 /* secure computing */
9295 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9296 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9297 +
9298 /* NOTE: Thread flags >= 12 should be ones we have no interest
9299 * in using in assembly, else we can't use the mask as
9300 * an immediate value in instructions such as andcc.
9301 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9302 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9303 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9304 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9305 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9306
9307 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9308 _TIF_DO_NOTIFY_RESUME_MASK | \
9309 _TIF_NEED_RESCHED)
9310 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9311
9312 +#define _TIF_WORK_SYSCALL \
9313 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9314 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9315 +
9316 +
9317 /*
9318 * Thread-synchronous status.
9319 *
9320 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9321 index 0167d26..767bb0c 100644
9322 --- a/arch/sparc/include/asm/uaccess.h
9323 +++ b/arch/sparc/include/asm/uaccess.h
9324 @@ -1,5 +1,6 @@
9325 #ifndef ___ASM_SPARC_UACCESS_H
9326 #define ___ASM_SPARC_UACCESS_H
9327 +
9328 #if defined(__sparc__) && defined(__arch64__)
9329 #include <asm/uaccess_64.h>
9330 #else
9331 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9332 index 53a28dd..50c38c3 100644
9333 --- a/arch/sparc/include/asm/uaccess_32.h
9334 +++ b/arch/sparc/include/asm/uaccess_32.h
9335 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9336
9337 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9338 {
9339 - if (n && __access_ok((unsigned long) to, n))
9340 + if ((long)n < 0)
9341 + return n;
9342 +
9343 + if (n && __access_ok((unsigned long) to, n)) {
9344 + if (!__builtin_constant_p(n))
9345 + check_object_size(from, n, true);
9346 return __copy_user(to, (__force void __user *) from, n);
9347 - else
9348 + } else
9349 return n;
9350 }
9351
9352 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9353 {
9354 + if ((long)n < 0)
9355 + return n;
9356 +
9357 + if (!__builtin_constant_p(n))
9358 + check_object_size(from, n, true);
9359 +
9360 return __copy_user(to, (__force void __user *) from, n);
9361 }
9362
9363 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9364 {
9365 - if (n && __access_ok((unsigned long) from, n))
9366 + if ((long)n < 0)
9367 + return n;
9368 +
9369 + if (n && __access_ok((unsigned long) from, n)) {
9370 + if (!__builtin_constant_p(n))
9371 + check_object_size(to, n, false);
9372 return __copy_user((__force void __user *) to, from, n);
9373 - else
9374 + } else
9375 return n;
9376 }
9377
9378 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9379 {
9380 + if ((long)n < 0)
9381 + return n;
9382 +
9383 return __copy_user((__force void __user *) to, from, n);
9384 }
9385
9386 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9387 index e562d3c..191f176 100644
9388 --- a/arch/sparc/include/asm/uaccess_64.h
9389 +++ b/arch/sparc/include/asm/uaccess_64.h
9390 @@ -10,6 +10,7 @@
9391 #include <linux/compiler.h>
9392 #include <linux/string.h>
9393 #include <linux/thread_info.h>
9394 +#include <linux/kernel.h>
9395 #include <asm/asi.h>
9396 #include <asm/spitfire.h>
9397 #include <asm-generic/uaccess-unaligned.h>
9398 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9399 static inline unsigned long __must_check
9400 copy_from_user(void *to, const void __user *from, unsigned long size)
9401 {
9402 - unsigned long ret = ___copy_from_user(to, from, size);
9403 + unsigned long ret;
9404
9405 + if ((long)size < 0 || size > INT_MAX)
9406 + return size;
9407 +
9408 + if (!__builtin_constant_p(size))
9409 + check_object_size(to, size, false);
9410 +
9411 + ret = ___copy_from_user(to, from, size);
9412 if (unlikely(ret))
9413 ret = copy_from_user_fixup(to, from, size);
9414
9415 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9416 static inline unsigned long __must_check
9417 copy_to_user(void __user *to, const void *from, unsigned long size)
9418 {
9419 - unsigned long ret = ___copy_to_user(to, from, size);
9420 + unsigned long ret;
9421
9422 + if ((long)size < 0 || size > INT_MAX)
9423 + return size;
9424 +
9425 + if (!__builtin_constant_p(size))
9426 + check_object_size(from, size, true);
9427 +
9428 + ret = ___copy_to_user(to, from, size);
9429 if (unlikely(ret))
9430 ret = copy_to_user_fixup(to, from, size);
9431 return ret;
9432 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9433 index d432fb2..6056af1 100644
9434 --- a/arch/sparc/kernel/Makefile
9435 +++ b/arch/sparc/kernel/Makefile
9436 @@ -3,7 +3,7 @@
9437 #
9438
9439 asflags-y := -ansi
9440 -ccflags-y := -Werror
9441 +#ccflags-y := -Werror
9442
9443 extra-y := head_$(BITS).o
9444
9445 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9446 index fdd819d..5af08c8 100644
9447 --- a/arch/sparc/kernel/process_32.c
9448 +++ b/arch/sparc/kernel/process_32.c
9449 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9450
9451 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9452 r->psr, r->pc, r->npc, r->y, print_tainted());
9453 - printk("PC: <%pS>\n", (void *) r->pc);
9454 + printk("PC: <%pA>\n", (void *) r->pc);
9455 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9456 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9457 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9458 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9459 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9460 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9461 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9462 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9463
9464 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9465 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9466 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9467 rw = (struct reg_window32 *) fp;
9468 pc = rw->ins[7];
9469 printk("[%08lx : ", pc);
9470 - printk("%pS ] ", (void *) pc);
9471 + printk("%pA ] ", (void *) pc);
9472 fp = rw->ins[6];
9473 } while (++count < 16);
9474 printk("\n");
9475 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9476 index baebab2..9cd13b1 100644
9477 --- a/arch/sparc/kernel/process_64.c
9478 +++ b/arch/sparc/kernel/process_64.c
9479 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9480 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9481 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9482 if (regs->tstate & TSTATE_PRIV)
9483 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9484 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9485 }
9486
9487 void show_regs(struct pt_regs *regs)
9488 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9489
9490 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9491 regs->tpc, regs->tnpc, regs->y, print_tainted());
9492 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9493 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9494 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9495 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9496 regs->u_regs[3]);
9497 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9498 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9499 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9500 regs->u_regs[15]);
9501 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9502 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9503 show_regwindow(regs);
9504 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9505 }
9506 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9507 ((tp && tp->task) ? tp->task->pid : -1));
9508
9509 if (gp->tstate & TSTATE_PRIV) {
9510 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9511 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9512 (void *) gp->tpc,
9513 (void *) gp->o7,
9514 (void *) gp->i7,
9515 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9516 index 79cc0d1..ec62734 100644
9517 --- a/arch/sparc/kernel/prom_common.c
9518 +++ b/arch/sparc/kernel/prom_common.c
9519 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9520
9521 unsigned int prom_early_allocated __initdata;
9522
9523 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9524 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9525 .nextprop = prom_common_nextprop,
9526 .getproplen = prom_getproplen,
9527 .getproperty = prom_getproperty,
9528 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9529 index 7ff45e4..a58f271 100644
9530 --- a/arch/sparc/kernel/ptrace_64.c
9531 +++ b/arch/sparc/kernel/ptrace_64.c
9532 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
9533 return ret;
9534 }
9535
9536 +#ifdef CONFIG_GRKERNSEC_SETXID
9537 +extern void gr_delayed_cred_worker(void);
9538 +#endif
9539 +
9540 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9541 {
9542 int ret = 0;
9543 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9544 /* do the secure computing check first */
9545 secure_computing_strict(regs->u_regs[UREG_G1]);
9546
9547 +#ifdef CONFIG_GRKERNSEC_SETXID
9548 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9549 + gr_delayed_cred_worker();
9550 +#endif
9551 +
9552 if (test_thread_flag(TIF_SYSCALL_TRACE))
9553 ret = tracehook_report_syscall_entry(regs);
9554
9555 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9556
9557 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9558 {
9559 +#ifdef CONFIG_GRKERNSEC_SETXID
9560 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9561 + gr_delayed_cred_worker();
9562 +#endif
9563 +
9564 audit_syscall_exit(regs);
9565
9566 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9567 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9568 index e142545..fd29654 100644
9569 --- a/arch/sparc/kernel/smp_64.c
9570 +++ b/arch/sparc/kernel/smp_64.c
9571 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9572 extern unsigned long xcall_flush_dcache_page_spitfire;
9573
9574 #ifdef CONFIG_DEBUG_DCFLUSH
9575 -extern atomic_t dcpage_flushes;
9576 -extern atomic_t dcpage_flushes_xcall;
9577 +extern atomic_unchecked_t dcpage_flushes;
9578 +extern atomic_unchecked_t dcpage_flushes_xcall;
9579 #endif
9580
9581 static inline void __local_flush_dcache_page(struct page *page)
9582 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9583 return;
9584
9585 #ifdef CONFIG_DEBUG_DCFLUSH
9586 - atomic_inc(&dcpage_flushes);
9587 + atomic_inc_unchecked(&dcpage_flushes);
9588 #endif
9589
9590 this_cpu = get_cpu();
9591 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9592 xcall_deliver(data0, __pa(pg_addr),
9593 (u64) pg_addr, cpumask_of(cpu));
9594 #ifdef CONFIG_DEBUG_DCFLUSH
9595 - atomic_inc(&dcpage_flushes_xcall);
9596 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9597 #endif
9598 }
9599 }
9600 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9601 preempt_disable();
9602
9603 #ifdef CONFIG_DEBUG_DCFLUSH
9604 - atomic_inc(&dcpage_flushes);
9605 + atomic_inc_unchecked(&dcpage_flushes);
9606 #endif
9607 data0 = 0;
9608 pg_addr = page_address(page);
9609 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9610 xcall_deliver(data0, __pa(pg_addr),
9611 (u64) pg_addr, cpu_online_mask);
9612 #ifdef CONFIG_DEBUG_DCFLUSH
9613 - atomic_inc(&dcpage_flushes_xcall);
9614 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9615 #endif
9616 }
9617 __local_flush_dcache_page(page);
9618 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9619 index 3a8d184..49498a8 100644
9620 --- a/arch/sparc/kernel/sys_sparc_32.c
9621 +++ b/arch/sparc/kernel/sys_sparc_32.c
9622 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9623 if (len > TASK_SIZE - PAGE_SIZE)
9624 return -ENOMEM;
9625 if (!addr)
9626 - addr = TASK_UNMAPPED_BASE;
9627 + addr = current->mm->mmap_base;
9628
9629 info.flags = 0;
9630 info.length = len;
9631 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9632 index 51561b8..8256764 100644
9633 --- a/arch/sparc/kernel/sys_sparc_64.c
9634 +++ b/arch/sparc/kernel/sys_sparc_64.c
9635 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9636 struct vm_area_struct * vma;
9637 unsigned long task_size = TASK_SIZE;
9638 int do_color_align;
9639 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9640 struct vm_unmapped_area_info info;
9641
9642 if (flags & MAP_FIXED) {
9643 /* We do not accept a shared mapping if it would violate
9644 * cache aliasing constraints.
9645 */
9646 - if ((flags & MAP_SHARED) &&
9647 + if ((filp || (flags & MAP_SHARED)) &&
9648 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9649 return -EINVAL;
9650 return addr;
9651 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9652 if (filp || (flags & MAP_SHARED))
9653 do_color_align = 1;
9654
9655 +#ifdef CONFIG_PAX_RANDMMAP
9656 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9657 +#endif
9658 +
9659 if (addr) {
9660 if (do_color_align)
9661 addr = COLOR_ALIGN(addr, pgoff);
9662 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9663 addr = PAGE_ALIGN(addr);
9664
9665 vma = find_vma(mm, addr);
9666 - if (task_size - len >= addr &&
9667 - (!vma || addr + len <= vma->vm_start))
9668 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9669 return addr;
9670 }
9671
9672 info.flags = 0;
9673 info.length = len;
9674 - info.low_limit = TASK_UNMAPPED_BASE;
9675 + info.low_limit = mm->mmap_base;
9676 info.high_limit = min(task_size, VA_EXCLUDE_START);
9677 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9678 info.align_offset = pgoff << PAGE_SHIFT;
9679 + info.threadstack_offset = offset;
9680 addr = vm_unmapped_area(&info);
9681
9682 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9683 VM_BUG_ON(addr != -ENOMEM);
9684 info.low_limit = VA_EXCLUDE_END;
9685 +
9686 +#ifdef CONFIG_PAX_RANDMMAP
9687 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9688 + info.low_limit += mm->delta_mmap;
9689 +#endif
9690 +
9691 info.high_limit = task_size;
9692 addr = vm_unmapped_area(&info);
9693 }
9694 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9695 unsigned long task_size = STACK_TOP32;
9696 unsigned long addr = addr0;
9697 int do_color_align;
9698 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9699 struct vm_unmapped_area_info info;
9700
9701 /* This should only ever run for 32-bit processes. */
9702 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9703 /* We do not accept a shared mapping if it would violate
9704 * cache aliasing constraints.
9705 */
9706 - if ((flags & MAP_SHARED) &&
9707 + if ((filp || (flags & MAP_SHARED)) &&
9708 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9709 return -EINVAL;
9710 return addr;
9711 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9712 if (filp || (flags & MAP_SHARED))
9713 do_color_align = 1;
9714
9715 +#ifdef CONFIG_PAX_RANDMMAP
9716 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9717 +#endif
9718 +
9719 /* requesting a specific address */
9720 if (addr) {
9721 if (do_color_align)
9722 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9723 addr = PAGE_ALIGN(addr);
9724
9725 vma = find_vma(mm, addr);
9726 - if (task_size - len >= addr &&
9727 - (!vma || addr + len <= vma->vm_start))
9728 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9729 return addr;
9730 }
9731
9732 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9733 info.high_limit = mm->mmap_base;
9734 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9735 info.align_offset = pgoff << PAGE_SHIFT;
9736 + info.threadstack_offset = offset;
9737 addr = vm_unmapped_area(&info);
9738
9739 /*
9740 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9741 VM_BUG_ON(addr != -ENOMEM);
9742 info.flags = 0;
9743 info.low_limit = TASK_UNMAPPED_BASE;
9744 +
9745 +#ifdef CONFIG_PAX_RANDMMAP
9746 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9747 + info.low_limit += mm->delta_mmap;
9748 +#endif
9749 +
9750 info.high_limit = STACK_TOP32;
9751 addr = vm_unmapped_area(&info);
9752 }
9753 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9754 EXPORT_SYMBOL(get_fb_unmapped_area);
9755
9756 /* Essentially the same as PowerPC. */
9757 -static unsigned long mmap_rnd(void)
9758 +static unsigned long mmap_rnd(struct mm_struct *mm)
9759 {
9760 unsigned long rnd = 0UL;
9761
9762 +#ifdef CONFIG_PAX_RANDMMAP
9763 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9764 +#endif
9765 +
9766 if (current->flags & PF_RANDOMIZE) {
9767 unsigned long val = get_random_int();
9768 if (test_thread_flag(TIF_32BIT))
9769 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9770
9771 void arch_pick_mmap_layout(struct mm_struct *mm)
9772 {
9773 - unsigned long random_factor = mmap_rnd();
9774 + unsigned long random_factor = mmap_rnd(mm);
9775 unsigned long gap;
9776
9777 /*
9778 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9779 gap == RLIM_INFINITY ||
9780 sysctl_legacy_va_layout) {
9781 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9782 +
9783 +#ifdef CONFIG_PAX_RANDMMAP
9784 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9785 + mm->mmap_base += mm->delta_mmap;
9786 +#endif
9787 +
9788 mm->get_unmapped_area = arch_get_unmapped_area;
9789 } else {
9790 /* We know it's 32-bit */
9791 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9792 gap = (task_size / 6 * 5);
9793
9794 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9795 +
9796 +#ifdef CONFIG_PAX_RANDMMAP
9797 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9798 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9799 +#endif
9800 +
9801 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9802 }
9803 }
9804 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9805 index 73ec8a7..4611979 100644
9806 --- a/arch/sparc/kernel/syscalls.S
9807 +++ b/arch/sparc/kernel/syscalls.S
9808 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9809 #endif
9810 .align 32
9811 1: ldx [%g6 + TI_FLAGS], %l5
9812 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9813 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9814 be,pt %icc, rtrap
9815 nop
9816 call syscall_trace_leave
9817 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9818
9819 srl %i3, 0, %o3 ! IEU0
9820 srl %i2, 0, %o2 ! IEU0 Group
9821 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9822 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9823 bne,pn %icc, linux_syscall_trace32 ! CTI
9824 mov %i0, %l5 ! IEU1
9825 5: call %l7 ! CTI Group brk forced
9826 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9827
9828 mov %i3, %o3 ! IEU1
9829 mov %i4, %o4 ! IEU0 Group
9830 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9831 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9832 bne,pn %icc, linux_syscall_trace ! CTI Group
9833 mov %i0, %l5 ! IEU0
9834 2: call %l7 ! CTI Group brk forced
9835 @@ -223,7 +223,7 @@ ret_sys_call:
9836
9837 cmp %o0, -ERESTART_RESTARTBLOCK
9838 bgeu,pn %xcc, 1f
9839 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9840 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9841 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9842
9843 2:
9844 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9845 index 6629829..036032d 100644
9846 --- a/arch/sparc/kernel/traps_32.c
9847 +++ b/arch/sparc/kernel/traps_32.c
9848 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9849 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9850 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9851
9852 +extern void gr_handle_kernel_exploit(void);
9853 +
9854 void die_if_kernel(char *str, struct pt_regs *regs)
9855 {
9856 static int die_counter;
9857 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9858 count++ < 30 &&
9859 (((unsigned long) rw) >= PAGE_OFFSET) &&
9860 !(((unsigned long) rw) & 0x7)) {
9861 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9862 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9863 (void *) rw->ins[7]);
9864 rw = (struct reg_window32 *)rw->ins[6];
9865 }
9866 }
9867 printk("Instruction DUMP:");
9868 instruction_dump ((unsigned long *) regs->pc);
9869 - if(regs->psr & PSR_PS)
9870 + if(regs->psr & PSR_PS) {
9871 + gr_handle_kernel_exploit();
9872 do_exit(SIGKILL);
9873 + }
9874 do_exit(SIGSEGV);
9875 }
9876
9877 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9878 index b3f833a..f485f80 100644
9879 --- a/arch/sparc/kernel/traps_64.c
9880 +++ b/arch/sparc/kernel/traps_64.c
9881 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9882 i + 1,
9883 p->trapstack[i].tstate, p->trapstack[i].tpc,
9884 p->trapstack[i].tnpc, p->trapstack[i].tt);
9885 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9886 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9887 }
9888 }
9889
9890 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9891
9892 lvl -= 0x100;
9893 if (regs->tstate & TSTATE_PRIV) {
9894 +
9895 +#ifdef CONFIG_PAX_REFCOUNT
9896 + if (lvl == 6)
9897 + pax_report_refcount_overflow(regs);
9898 +#endif
9899 +
9900 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9901 die_if_kernel(buffer, regs);
9902 }
9903 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9904 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9905 {
9906 char buffer[32];
9907 -
9908 +
9909 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9910 0, lvl, SIGTRAP) == NOTIFY_STOP)
9911 return;
9912
9913 +#ifdef CONFIG_PAX_REFCOUNT
9914 + if (lvl == 6)
9915 + pax_report_refcount_overflow(regs);
9916 +#endif
9917 +
9918 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9919
9920 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9921 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9922 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9923 printk("%s" "ERROR(%d): ",
9924 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9925 - printk("TPC<%pS>\n", (void *) regs->tpc);
9926 + printk("TPC<%pA>\n", (void *) regs->tpc);
9927 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9928 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9929 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9930 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9931 smp_processor_id(),
9932 (type & 0x1) ? 'I' : 'D',
9933 regs->tpc);
9934 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9935 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9936 panic("Irrecoverable Cheetah+ parity error.");
9937 }
9938
9939 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9940 smp_processor_id(),
9941 (type & 0x1) ? 'I' : 'D',
9942 regs->tpc);
9943 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9944 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9945 }
9946
9947 struct sun4v_error_entry {
9948 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9949 /*0x38*/u64 reserved_5;
9950 };
9951
9952 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9953 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9954 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9955 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9956
9957 static const char *sun4v_err_type_to_str(u8 type)
9958 {
9959 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9960 }
9961
9962 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9963 - int cpu, const char *pfx, atomic_t *ocnt)
9964 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9965 {
9966 u64 *raw_ptr = (u64 *) ent;
9967 u32 attrs;
9968 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9969
9970 show_regs(regs);
9971
9972 - if ((cnt = atomic_read(ocnt)) != 0) {
9973 - atomic_set(ocnt, 0);
9974 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9975 + atomic_set_unchecked(ocnt, 0);
9976 wmb();
9977 printk("%s: Queue overflowed %d times.\n",
9978 pfx, cnt);
9979 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
9980 */
9981 void sun4v_resum_overflow(struct pt_regs *regs)
9982 {
9983 - atomic_inc(&sun4v_resum_oflow_cnt);
9984 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
9985 }
9986
9987 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
9988 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
9989 /* XXX Actually even this can make not that much sense. Perhaps
9990 * XXX we should just pull the plug and panic directly from here?
9991 */
9992 - atomic_inc(&sun4v_nonresum_oflow_cnt);
9993 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
9994 }
9995
9996 unsigned long sun4v_err_itlb_vaddr;
9997 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
9998
9999 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10000 regs->tpc, tl);
10001 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10002 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10003 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10004 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10005 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10006 (void *) regs->u_regs[UREG_I7]);
10007 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10008 "pte[%lx] error[%lx]\n",
10009 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10010
10011 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10012 regs->tpc, tl);
10013 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10014 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10015 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10016 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10017 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10018 (void *) regs->u_regs[UREG_I7]);
10019 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10020 "pte[%lx] error[%lx]\n",
10021 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10022 fp = (unsigned long)sf->fp + STACK_BIAS;
10023 }
10024
10025 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10026 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10027 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10028 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10029 int index = tsk->curr_ret_stack;
10030 if (tsk->ret_stack && index >= graph) {
10031 pc = tsk->ret_stack[index - graph].ret;
10032 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10033 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10034 graph++;
10035 }
10036 }
10037 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10038 return (struct reg_window *) (fp + STACK_BIAS);
10039 }
10040
10041 +extern void gr_handle_kernel_exploit(void);
10042 +
10043 void die_if_kernel(char *str, struct pt_regs *regs)
10044 {
10045 static int die_counter;
10046 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10047 while (rw &&
10048 count++ < 30 &&
10049 kstack_valid(tp, (unsigned long) rw)) {
10050 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10051 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10052 (void *) rw->ins[7]);
10053
10054 rw = kernel_stack_up(rw);
10055 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10056 }
10057 user_instruction_dump ((unsigned int __user *) regs->tpc);
10058 }
10059 - if (regs->tstate & TSTATE_PRIV)
10060 + if (regs->tstate & TSTATE_PRIV) {
10061 + gr_handle_kernel_exploit();
10062 do_exit(SIGKILL);
10063 + }
10064 do_exit(SIGSEGV);
10065 }
10066 EXPORT_SYMBOL(die_if_kernel);
10067 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10068 index 8201c25e..072a2a7 100644
10069 --- a/arch/sparc/kernel/unaligned_64.c
10070 +++ b/arch/sparc/kernel/unaligned_64.c
10071 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10072 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10073
10074 if (__ratelimit(&ratelimit)) {
10075 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10076 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10077 regs->tpc, (void *) regs->tpc);
10078 }
10079 }
10080 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10081 index dbe119b..089c7c1 100644
10082 --- a/arch/sparc/lib/Makefile
10083 +++ b/arch/sparc/lib/Makefile
10084 @@ -2,7 +2,7 @@
10085 #
10086
10087 asflags-y := -ansi -DST_DIV0=0x02
10088 -ccflags-y := -Werror
10089 +#ccflags-y := -Werror
10090
10091 lib-$(CONFIG_SPARC32) += ashrdi3.o
10092 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10093 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10094 index 85c233d..68500e0 100644
10095 --- a/arch/sparc/lib/atomic_64.S
10096 +++ b/arch/sparc/lib/atomic_64.S
10097 @@ -17,7 +17,12 @@
10098 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10099 BACKOFF_SETUP(%o2)
10100 1: lduw [%o1], %g1
10101 - add %g1, %o0, %g7
10102 + addcc %g1, %o0, %g7
10103 +
10104 +#ifdef CONFIG_PAX_REFCOUNT
10105 + tvs %icc, 6
10106 +#endif
10107 +
10108 cas [%o1], %g1, %g7
10109 cmp %g1, %g7
10110 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10111 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10112 2: BACKOFF_SPIN(%o2, %o3, 1b)
10113 ENDPROC(atomic_add)
10114
10115 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10116 + BACKOFF_SETUP(%o2)
10117 +1: lduw [%o1], %g1
10118 + add %g1, %o0, %g7
10119 + cas [%o1], %g1, %g7
10120 + cmp %g1, %g7
10121 + bne,pn %icc, 2f
10122 + nop
10123 + retl
10124 + nop
10125 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10126 +ENDPROC(atomic_add_unchecked)
10127 +
10128 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10129 BACKOFF_SETUP(%o2)
10130 1: lduw [%o1], %g1
10131 - sub %g1, %o0, %g7
10132 + subcc %g1, %o0, %g7
10133 +
10134 +#ifdef CONFIG_PAX_REFCOUNT
10135 + tvs %icc, 6
10136 +#endif
10137 +
10138 cas [%o1], %g1, %g7
10139 cmp %g1, %g7
10140 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10141 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10142 2: BACKOFF_SPIN(%o2, %o3, 1b)
10143 ENDPROC(atomic_sub)
10144
10145 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10146 + BACKOFF_SETUP(%o2)
10147 +1: lduw [%o1], %g1
10148 + sub %g1, %o0, %g7
10149 + cas [%o1], %g1, %g7
10150 + cmp %g1, %g7
10151 + bne,pn %icc, 2f
10152 + nop
10153 + retl
10154 + nop
10155 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10156 +ENDPROC(atomic_sub_unchecked)
10157 +
10158 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10159 BACKOFF_SETUP(%o2)
10160 1: lduw [%o1], %g1
10161 - add %g1, %o0, %g7
10162 + addcc %g1, %o0, %g7
10163 +
10164 +#ifdef CONFIG_PAX_REFCOUNT
10165 + tvs %icc, 6
10166 +#endif
10167 +
10168 cas [%o1], %g1, %g7
10169 cmp %g1, %g7
10170 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10171 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10172 2: BACKOFF_SPIN(%o2, %o3, 1b)
10173 ENDPROC(atomic_add_ret)
10174
10175 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10176 + BACKOFF_SETUP(%o2)
10177 +1: lduw [%o1], %g1
10178 + addcc %g1, %o0, %g7
10179 + cas [%o1], %g1, %g7
10180 + cmp %g1, %g7
10181 + bne,pn %icc, 2f
10182 + add %g7, %o0, %g7
10183 + sra %g7, 0, %o0
10184 + retl
10185 + nop
10186 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10187 +ENDPROC(atomic_add_ret_unchecked)
10188 +
10189 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10190 BACKOFF_SETUP(%o2)
10191 1: lduw [%o1], %g1
10192 - sub %g1, %o0, %g7
10193 + subcc %g1, %o0, %g7
10194 +
10195 +#ifdef CONFIG_PAX_REFCOUNT
10196 + tvs %icc, 6
10197 +#endif
10198 +
10199 cas [%o1], %g1, %g7
10200 cmp %g1, %g7
10201 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10202 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10203 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10204 BACKOFF_SETUP(%o2)
10205 1: ldx [%o1], %g1
10206 - add %g1, %o0, %g7
10207 + addcc %g1, %o0, %g7
10208 +
10209 +#ifdef CONFIG_PAX_REFCOUNT
10210 + tvs %xcc, 6
10211 +#endif
10212 +
10213 casx [%o1], %g1, %g7
10214 cmp %g1, %g7
10215 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10216 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10217 2: BACKOFF_SPIN(%o2, %o3, 1b)
10218 ENDPROC(atomic64_add)
10219
10220 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10221 + BACKOFF_SETUP(%o2)
10222 +1: ldx [%o1], %g1
10223 + addcc %g1, %o0, %g7
10224 + casx [%o1], %g1, %g7
10225 + cmp %g1, %g7
10226 + bne,pn %xcc, 2f
10227 + nop
10228 + retl
10229 + nop
10230 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10231 +ENDPROC(atomic64_add_unchecked)
10232 +
10233 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10234 BACKOFF_SETUP(%o2)
10235 1: ldx [%o1], %g1
10236 - sub %g1, %o0, %g7
10237 + subcc %g1, %o0, %g7
10238 +
10239 +#ifdef CONFIG_PAX_REFCOUNT
10240 + tvs %xcc, 6
10241 +#endif
10242 +
10243 casx [%o1], %g1, %g7
10244 cmp %g1, %g7
10245 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10246 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10247 2: BACKOFF_SPIN(%o2, %o3, 1b)
10248 ENDPROC(atomic64_sub)
10249
10250 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10251 + BACKOFF_SETUP(%o2)
10252 +1: ldx [%o1], %g1
10253 + subcc %g1, %o0, %g7
10254 + casx [%o1], %g1, %g7
10255 + cmp %g1, %g7
10256 + bne,pn %xcc, 2f
10257 + nop
10258 + retl
10259 + nop
10260 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10261 +ENDPROC(atomic64_sub_unchecked)
10262 +
10263 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10264 BACKOFF_SETUP(%o2)
10265 1: ldx [%o1], %g1
10266 - add %g1, %o0, %g7
10267 + addcc %g1, %o0, %g7
10268 +
10269 +#ifdef CONFIG_PAX_REFCOUNT
10270 + tvs %xcc, 6
10271 +#endif
10272 +
10273 casx [%o1], %g1, %g7
10274 cmp %g1, %g7
10275 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10276 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10277 2: BACKOFF_SPIN(%o2, %o3, 1b)
10278 ENDPROC(atomic64_add_ret)
10279
10280 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10281 + BACKOFF_SETUP(%o2)
10282 +1: ldx [%o1], %g1
10283 + addcc %g1, %o0, %g7
10284 + casx [%o1], %g1, %g7
10285 + cmp %g1, %g7
10286 + bne,pn %xcc, 2f
10287 + add %g7, %o0, %g7
10288 + mov %g7, %o0
10289 + retl
10290 + nop
10291 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10292 +ENDPROC(atomic64_add_ret_unchecked)
10293 +
10294 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10295 BACKOFF_SETUP(%o2)
10296 1: ldx [%o1], %g1
10297 - sub %g1, %o0, %g7
10298 + subcc %g1, %o0, %g7
10299 +
10300 +#ifdef CONFIG_PAX_REFCOUNT
10301 + tvs %xcc, 6
10302 +#endif
10303 +
10304 casx [%o1], %g1, %g7
10305 cmp %g1, %g7
10306 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10307 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10308 index 323335b..ed85ea2 100644
10309 --- a/arch/sparc/lib/ksyms.c
10310 +++ b/arch/sparc/lib/ksyms.c
10311 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10312
10313 /* Atomic counter implementation. */
10314 EXPORT_SYMBOL(atomic_add);
10315 +EXPORT_SYMBOL(atomic_add_unchecked);
10316 EXPORT_SYMBOL(atomic_add_ret);
10317 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10318 EXPORT_SYMBOL(atomic_sub);
10319 +EXPORT_SYMBOL(atomic_sub_unchecked);
10320 EXPORT_SYMBOL(atomic_sub_ret);
10321 EXPORT_SYMBOL(atomic64_add);
10322 +EXPORT_SYMBOL(atomic64_add_unchecked);
10323 EXPORT_SYMBOL(atomic64_add_ret);
10324 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10325 EXPORT_SYMBOL(atomic64_sub);
10326 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10327 EXPORT_SYMBOL(atomic64_sub_ret);
10328 EXPORT_SYMBOL(atomic64_dec_if_positive);
10329
10330 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10331 index 30c3ecc..736f015 100644
10332 --- a/arch/sparc/mm/Makefile
10333 +++ b/arch/sparc/mm/Makefile
10334 @@ -2,7 +2,7 @@
10335 #
10336
10337 asflags-y := -ansi
10338 -ccflags-y := -Werror
10339 +#ccflags-y := -Werror
10340
10341 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10342 obj-y += fault_$(BITS).o
10343 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10344 index e98bfda..ea8d221 100644
10345 --- a/arch/sparc/mm/fault_32.c
10346 +++ b/arch/sparc/mm/fault_32.c
10347 @@ -21,6 +21,9 @@
10348 #include <linux/perf_event.h>
10349 #include <linux/interrupt.h>
10350 #include <linux/kdebug.h>
10351 +#include <linux/slab.h>
10352 +#include <linux/pagemap.h>
10353 +#include <linux/compiler.h>
10354
10355 #include <asm/page.h>
10356 #include <asm/pgtable.h>
10357 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10358 return safe_compute_effective_address(regs, insn);
10359 }
10360
10361 +#ifdef CONFIG_PAX_PAGEEXEC
10362 +#ifdef CONFIG_PAX_DLRESOLVE
10363 +static void pax_emuplt_close(struct vm_area_struct *vma)
10364 +{
10365 + vma->vm_mm->call_dl_resolve = 0UL;
10366 +}
10367 +
10368 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10369 +{
10370 + unsigned int *kaddr;
10371 +
10372 + vmf->page = alloc_page(GFP_HIGHUSER);
10373 + if (!vmf->page)
10374 + return VM_FAULT_OOM;
10375 +
10376 + kaddr = kmap(vmf->page);
10377 + memset(kaddr, 0, PAGE_SIZE);
10378 + kaddr[0] = 0x9DE3BFA8U; /* save */
10379 + flush_dcache_page(vmf->page);
10380 + kunmap(vmf->page);
10381 + return VM_FAULT_MAJOR;
10382 +}
10383 +
10384 +static const struct vm_operations_struct pax_vm_ops = {
10385 + .close = pax_emuplt_close,
10386 + .fault = pax_emuplt_fault
10387 +};
10388 +
10389 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10390 +{
10391 + int ret;
10392 +
10393 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10394 + vma->vm_mm = current->mm;
10395 + vma->vm_start = addr;
10396 + vma->vm_end = addr + PAGE_SIZE;
10397 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10398 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10399 + vma->vm_ops = &pax_vm_ops;
10400 +
10401 + ret = insert_vm_struct(current->mm, vma);
10402 + if (ret)
10403 + return ret;
10404 +
10405 + ++current->mm->total_vm;
10406 + return 0;
10407 +}
10408 +#endif
10409 +
10410 +/*
10411 + * PaX: decide what to do with offenders (regs->pc = fault address)
10412 + *
10413 + * returns 1 when task should be killed
10414 + * 2 when patched PLT trampoline was detected
10415 + * 3 when unpatched PLT trampoline was detected
10416 + */
10417 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10418 +{
10419 +
10420 +#ifdef CONFIG_PAX_EMUPLT
10421 + int err;
10422 +
10423 + do { /* PaX: patched PLT emulation #1 */
10424 + unsigned int sethi1, sethi2, jmpl;
10425 +
10426 + err = get_user(sethi1, (unsigned int *)regs->pc);
10427 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10428 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10429 +
10430 + if (err)
10431 + break;
10432 +
10433 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10434 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10435 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10436 + {
10437 + unsigned int addr;
10438 +
10439 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10440 + addr = regs->u_regs[UREG_G1];
10441 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10442 + regs->pc = addr;
10443 + regs->npc = addr+4;
10444 + return 2;
10445 + }
10446 + } while (0);
10447 +
10448 + do { /* PaX: patched PLT emulation #2 */
10449 + unsigned int ba;
10450 +
10451 + err = get_user(ba, (unsigned int *)regs->pc);
10452 +
10453 + if (err)
10454 + break;
10455 +
10456 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10457 + unsigned int addr;
10458 +
10459 + if ((ba & 0xFFC00000U) == 0x30800000U)
10460 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10461 + else
10462 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10463 + regs->pc = addr;
10464 + regs->npc = addr+4;
10465 + return 2;
10466 + }
10467 + } while (0);
10468 +
10469 + do { /* PaX: patched PLT emulation #3 */
10470 + unsigned int sethi, bajmpl, nop;
10471 +
10472 + err = get_user(sethi, (unsigned int *)regs->pc);
10473 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10474 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10475 +
10476 + if (err)
10477 + break;
10478 +
10479 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10480 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10481 + nop == 0x01000000U)
10482 + {
10483 + unsigned int addr;
10484 +
10485 + addr = (sethi & 0x003FFFFFU) << 10;
10486 + regs->u_regs[UREG_G1] = addr;
10487 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10488 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10489 + else
10490 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10491 + regs->pc = addr;
10492 + regs->npc = addr+4;
10493 + return 2;
10494 + }
10495 + } while (0);
10496 +
10497 + do { /* PaX: unpatched PLT emulation step 1 */
10498 + unsigned int sethi, ba, nop;
10499 +
10500 + err = get_user(sethi, (unsigned int *)regs->pc);
10501 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10502 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10503 +
10504 + if (err)
10505 + break;
10506 +
10507 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10508 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10509 + nop == 0x01000000U)
10510 + {
10511 + unsigned int addr, save, call;
10512 +
10513 + if ((ba & 0xFFC00000U) == 0x30800000U)
10514 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10515 + else
10516 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10517 +
10518 + err = get_user(save, (unsigned int *)addr);
10519 + err |= get_user(call, (unsigned int *)(addr+4));
10520 + err |= get_user(nop, (unsigned int *)(addr+8));
10521 + if (err)
10522 + break;
10523 +
10524 +#ifdef CONFIG_PAX_DLRESOLVE
10525 + if (save == 0x9DE3BFA8U &&
10526 + (call & 0xC0000000U) == 0x40000000U &&
10527 + nop == 0x01000000U)
10528 + {
10529 + struct vm_area_struct *vma;
10530 + unsigned long call_dl_resolve;
10531 +
10532 + down_read(&current->mm->mmap_sem);
10533 + call_dl_resolve = current->mm->call_dl_resolve;
10534 + up_read(&current->mm->mmap_sem);
10535 + if (likely(call_dl_resolve))
10536 + goto emulate;
10537 +
10538 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10539 +
10540 + down_write(&current->mm->mmap_sem);
10541 + if (current->mm->call_dl_resolve) {
10542 + call_dl_resolve = current->mm->call_dl_resolve;
10543 + up_write(&current->mm->mmap_sem);
10544 + if (vma)
10545 + kmem_cache_free(vm_area_cachep, vma);
10546 + goto emulate;
10547 + }
10548 +
10549 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10550 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10551 + up_write(&current->mm->mmap_sem);
10552 + if (vma)
10553 + kmem_cache_free(vm_area_cachep, vma);
10554 + return 1;
10555 + }
10556 +
10557 + if (pax_insert_vma(vma, call_dl_resolve)) {
10558 + up_write(&current->mm->mmap_sem);
10559 + kmem_cache_free(vm_area_cachep, vma);
10560 + return 1;
10561 + }
10562 +
10563 + current->mm->call_dl_resolve = call_dl_resolve;
10564 + up_write(&current->mm->mmap_sem);
10565 +
10566 +emulate:
10567 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10568 + regs->pc = call_dl_resolve;
10569 + regs->npc = addr+4;
10570 + return 3;
10571 + }
10572 +#endif
10573 +
10574 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10575 + if ((save & 0xFFC00000U) == 0x05000000U &&
10576 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10577 + nop == 0x01000000U)
10578 + {
10579 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10580 + regs->u_regs[UREG_G2] = addr + 4;
10581 + addr = (save & 0x003FFFFFU) << 10;
10582 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10583 + regs->pc = addr;
10584 + regs->npc = addr+4;
10585 + return 3;
10586 + }
10587 + }
10588 + } while (0);
10589 +
10590 + do { /* PaX: unpatched PLT emulation step 2 */
10591 + unsigned int save, call, nop;
10592 +
10593 + err = get_user(save, (unsigned int *)(regs->pc-4));
10594 + err |= get_user(call, (unsigned int *)regs->pc);
10595 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10596 + if (err)
10597 + break;
10598 +
10599 + if (save == 0x9DE3BFA8U &&
10600 + (call & 0xC0000000U) == 0x40000000U &&
10601 + nop == 0x01000000U)
10602 + {
10603 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10604 +
10605 + regs->u_regs[UREG_RETPC] = regs->pc;
10606 + regs->pc = dl_resolve;
10607 + regs->npc = dl_resolve+4;
10608 + return 3;
10609 + }
10610 + } while (0);
10611 +#endif
10612 +
10613 + return 1;
10614 +}
10615 +
10616 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10617 +{
10618 + unsigned long i;
10619 +
10620 + printk(KERN_ERR "PAX: bytes at PC: ");
10621 + for (i = 0; i < 8; i++) {
10622 + unsigned int c;
10623 + if (get_user(c, (unsigned int *)pc+i))
10624 + printk(KERN_CONT "???????? ");
10625 + else
10626 + printk(KERN_CONT "%08x ", c);
10627 + }
10628 + printk("\n");
10629 +}
10630 +#endif
10631 +
10632 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10633 int text_fault)
10634 {
10635 @@ -230,6 +504,24 @@ good_area:
10636 if (!(vma->vm_flags & VM_WRITE))
10637 goto bad_area;
10638 } else {
10639 +
10640 +#ifdef CONFIG_PAX_PAGEEXEC
10641 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10642 + up_read(&mm->mmap_sem);
10643 + switch (pax_handle_fetch_fault(regs)) {
10644 +
10645 +#ifdef CONFIG_PAX_EMUPLT
10646 + case 2:
10647 + case 3:
10648 + return;
10649 +#endif
10650 +
10651 + }
10652 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10653 + do_group_exit(SIGKILL);
10654 + }
10655 +#endif
10656 +
10657 /* Allow reads even for write-only mappings */
10658 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10659 goto bad_area;
10660 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10661 index 5062ff3..e0b75f3 100644
10662 --- a/arch/sparc/mm/fault_64.c
10663 +++ b/arch/sparc/mm/fault_64.c
10664 @@ -21,6 +21,9 @@
10665 #include <linux/kprobes.h>
10666 #include <linux/kdebug.h>
10667 #include <linux/percpu.h>
10668 +#include <linux/slab.h>
10669 +#include <linux/pagemap.h>
10670 +#include <linux/compiler.h>
10671
10672 #include <asm/page.h>
10673 #include <asm/pgtable.h>
10674 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10675 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10676 regs->tpc);
10677 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10678 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10679 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10680 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10681 dump_stack();
10682 unhandled_fault(regs->tpc, current, regs);
10683 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10684 show_regs(regs);
10685 }
10686
10687 +#ifdef CONFIG_PAX_PAGEEXEC
10688 +#ifdef CONFIG_PAX_DLRESOLVE
10689 +static void pax_emuplt_close(struct vm_area_struct *vma)
10690 +{
10691 + vma->vm_mm->call_dl_resolve = 0UL;
10692 +}
10693 +
10694 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10695 +{
10696 + unsigned int *kaddr;
10697 +
10698 + vmf->page = alloc_page(GFP_HIGHUSER);
10699 + if (!vmf->page)
10700 + return VM_FAULT_OOM;
10701 +
10702 + kaddr = kmap(vmf->page);
10703 + memset(kaddr, 0, PAGE_SIZE);
10704 + kaddr[0] = 0x9DE3BFA8U; /* save */
10705 + flush_dcache_page(vmf->page);
10706 + kunmap(vmf->page);
10707 + return VM_FAULT_MAJOR;
10708 +}
10709 +
10710 +static const struct vm_operations_struct pax_vm_ops = {
10711 + .close = pax_emuplt_close,
10712 + .fault = pax_emuplt_fault
10713 +};
10714 +
10715 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10716 +{
10717 + int ret;
10718 +
10719 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10720 + vma->vm_mm = current->mm;
10721 + vma->vm_start = addr;
10722 + vma->vm_end = addr + PAGE_SIZE;
10723 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10724 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10725 + vma->vm_ops = &pax_vm_ops;
10726 +
10727 + ret = insert_vm_struct(current->mm, vma);
10728 + if (ret)
10729 + return ret;
10730 +
10731 + ++current->mm->total_vm;
10732 + return 0;
10733 +}
10734 +#endif
10735 +
10736 +/*
10737 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10738 + *
10739 + * returns 1 when task should be killed
10740 + * 2 when patched PLT trampoline was detected
10741 + * 3 when unpatched PLT trampoline was detected
10742 + */
10743 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10744 +{
10745 +
10746 +#ifdef CONFIG_PAX_EMUPLT
10747 + int err;
10748 +
10749 + do { /* PaX: patched PLT emulation #1 */
10750 + unsigned int sethi1, sethi2, jmpl;
10751 +
10752 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10753 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10754 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10755 +
10756 + if (err)
10757 + break;
10758 +
10759 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10760 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10761 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10762 + {
10763 + unsigned long addr;
10764 +
10765 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10766 + addr = regs->u_regs[UREG_G1];
10767 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10768 +
10769 + if (test_thread_flag(TIF_32BIT))
10770 + addr &= 0xFFFFFFFFUL;
10771 +
10772 + regs->tpc = addr;
10773 + regs->tnpc = addr+4;
10774 + return 2;
10775 + }
10776 + } while (0);
10777 +
10778 + do { /* PaX: patched PLT emulation #2 */
10779 + unsigned int ba;
10780 +
10781 + err = get_user(ba, (unsigned int *)regs->tpc);
10782 +
10783 + if (err)
10784 + break;
10785 +
10786 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10787 + unsigned long addr;
10788 +
10789 + if ((ba & 0xFFC00000U) == 0x30800000U)
10790 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10791 + else
10792 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10793 +
10794 + if (test_thread_flag(TIF_32BIT))
10795 + addr &= 0xFFFFFFFFUL;
10796 +
10797 + regs->tpc = addr;
10798 + regs->tnpc = addr+4;
10799 + return 2;
10800 + }
10801 + } while (0);
10802 +
10803 + do { /* PaX: patched PLT emulation #3 */
10804 + unsigned int sethi, bajmpl, nop;
10805 +
10806 + err = get_user(sethi, (unsigned int *)regs->tpc);
10807 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10808 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10809 +
10810 + if (err)
10811 + break;
10812 +
10813 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10814 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10815 + nop == 0x01000000U)
10816 + {
10817 + unsigned long addr;
10818 +
10819 + addr = (sethi & 0x003FFFFFU) << 10;
10820 + regs->u_regs[UREG_G1] = addr;
10821 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10822 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10823 + else
10824 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10825 +
10826 + if (test_thread_flag(TIF_32BIT))
10827 + addr &= 0xFFFFFFFFUL;
10828 +
10829 + regs->tpc = addr;
10830 + regs->tnpc = addr+4;
10831 + return 2;
10832 + }
10833 + } while (0);
10834 +
10835 + do { /* PaX: patched PLT emulation #4 */
10836 + unsigned int sethi, mov1, call, mov2;
10837 +
10838 + err = get_user(sethi, (unsigned int *)regs->tpc);
10839 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10840 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10841 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10842 +
10843 + if (err)
10844 + break;
10845 +
10846 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10847 + mov1 == 0x8210000FU &&
10848 + (call & 0xC0000000U) == 0x40000000U &&
10849 + mov2 == 0x9E100001U)
10850 + {
10851 + unsigned long addr;
10852 +
10853 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10854 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10855 +
10856 + if (test_thread_flag(TIF_32BIT))
10857 + addr &= 0xFFFFFFFFUL;
10858 +
10859 + regs->tpc = addr;
10860 + regs->tnpc = addr+4;
10861 + return 2;
10862 + }
10863 + } while (0);
10864 +
10865 + do { /* PaX: patched PLT emulation #5 */
10866 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10867 +
10868 + err = get_user(sethi, (unsigned int *)regs->tpc);
10869 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10870 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10871 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10872 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10873 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10874 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10875 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10876 +
10877 + if (err)
10878 + break;
10879 +
10880 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10881 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10882 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10883 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10884 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10885 + sllx == 0x83287020U &&
10886 + jmpl == 0x81C04005U &&
10887 + nop == 0x01000000U)
10888 + {
10889 + unsigned long addr;
10890 +
10891 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10892 + regs->u_regs[UREG_G1] <<= 32;
10893 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10894 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10895 + regs->tpc = addr;
10896 + regs->tnpc = addr+4;
10897 + return 2;
10898 + }
10899 + } while (0);
10900 +
10901 + do { /* PaX: patched PLT emulation #6 */
10902 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10903 +
10904 + err = get_user(sethi, (unsigned int *)regs->tpc);
10905 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10906 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10907 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10908 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10909 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10910 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10911 +
10912 + if (err)
10913 + break;
10914 +
10915 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10916 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10917 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10918 + sllx == 0x83287020U &&
10919 + (or & 0xFFFFE000U) == 0x8A116000U &&
10920 + jmpl == 0x81C04005U &&
10921 + nop == 0x01000000U)
10922 + {
10923 + unsigned long addr;
10924 +
10925 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10926 + regs->u_regs[UREG_G1] <<= 32;
10927 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10928 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10929 + regs->tpc = addr;
10930 + regs->tnpc = addr+4;
10931 + return 2;
10932 + }
10933 + } while (0);
10934 +
10935 + do { /* PaX: unpatched PLT emulation step 1 */
10936 + unsigned int sethi, ba, nop;
10937 +
10938 + err = get_user(sethi, (unsigned int *)regs->tpc);
10939 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10940 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10941 +
10942 + if (err)
10943 + break;
10944 +
10945 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10946 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10947 + nop == 0x01000000U)
10948 + {
10949 + unsigned long addr;
10950 + unsigned int save, call;
10951 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10952 +
10953 + if ((ba & 0xFFC00000U) == 0x30800000U)
10954 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10955 + else
10956 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10957 +
10958 + if (test_thread_flag(TIF_32BIT))
10959 + addr &= 0xFFFFFFFFUL;
10960 +
10961 + err = get_user(save, (unsigned int *)addr);
10962 + err |= get_user(call, (unsigned int *)(addr+4));
10963 + err |= get_user(nop, (unsigned int *)(addr+8));
10964 + if (err)
10965 + break;
10966 +
10967 +#ifdef CONFIG_PAX_DLRESOLVE
10968 + if (save == 0x9DE3BFA8U &&
10969 + (call & 0xC0000000U) == 0x40000000U &&
10970 + nop == 0x01000000U)
10971 + {
10972 + struct vm_area_struct *vma;
10973 + unsigned long call_dl_resolve;
10974 +
10975 + down_read(&current->mm->mmap_sem);
10976 + call_dl_resolve = current->mm->call_dl_resolve;
10977 + up_read(&current->mm->mmap_sem);
10978 + if (likely(call_dl_resolve))
10979 + goto emulate;
10980 +
10981 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10982 +
10983 + down_write(&current->mm->mmap_sem);
10984 + if (current->mm->call_dl_resolve) {
10985 + call_dl_resolve = current->mm->call_dl_resolve;
10986 + up_write(&current->mm->mmap_sem);
10987 + if (vma)
10988 + kmem_cache_free(vm_area_cachep, vma);
10989 + goto emulate;
10990 + }
10991 +
10992 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10993 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10994 + up_write(&current->mm->mmap_sem);
10995 + if (vma)
10996 + kmem_cache_free(vm_area_cachep, vma);
10997 + return 1;
10998 + }
10999 +
11000 + if (pax_insert_vma(vma, call_dl_resolve)) {
11001 + up_write(&current->mm->mmap_sem);
11002 + kmem_cache_free(vm_area_cachep, vma);
11003 + return 1;
11004 + }
11005 +
11006 + current->mm->call_dl_resolve = call_dl_resolve;
11007 + up_write(&current->mm->mmap_sem);
11008 +
11009 +emulate:
11010 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11011 + regs->tpc = call_dl_resolve;
11012 + regs->tnpc = addr+4;
11013 + return 3;
11014 + }
11015 +#endif
11016 +
11017 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11018 + if ((save & 0xFFC00000U) == 0x05000000U &&
11019 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11020 + nop == 0x01000000U)
11021 + {
11022 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11023 + regs->u_regs[UREG_G2] = addr + 4;
11024 + addr = (save & 0x003FFFFFU) << 10;
11025 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11026 +
11027 + if (test_thread_flag(TIF_32BIT))
11028 + addr &= 0xFFFFFFFFUL;
11029 +
11030 + regs->tpc = addr;
11031 + regs->tnpc = addr+4;
11032 + return 3;
11033 + }
11034 +
11035 + /* PaX: 64-bit PLT stub */
11036 + err = get_user(sethi1, (unsigned int *)addr);
11037 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11038 + err |= get_user(or1, (unsigned int *)(addr+8));
11039 + err |= get_user(or2, (unsigned int *)(addr+12));
11040 + err |= get_user(sllx, (unsigned int *)(addr+16));
11041 + err |= get_user(add, (unsigned int *)(addr+20));
11042 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11043 + err |= get_user(nop, (unsigned int *)(addr+28));
11044 + if (err)
11045 + break;
11046 +
11047 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11048 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11049 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11050 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11051 + sllx == 0x89293020U &&
11052 + add == 0x8A010005U &&
11053 + jmpl == 0x89C14000U &&
11054 + nop == 0x01000000U)
11055 + {
11056 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11057 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11058 + regs->u_regs[UREG_G4] <<= 32;
11059 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11060 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11061 + regs->u_regs[UREG_G4] = addr + 24;
11062 + addr = regs->u_regs[UREG_G5];
11063 + regs->tpc = addr;
11064 + regs->tnpc = addr+4;
11065 + return 3;
11066 + }
11067 + }
11068 + } while (0);
11069 +
11070 +#ifdef CONFIG_PAX_DLRESOLVE
11071 + do { /* PaX: unpatched PLT emulation step 2 */
11072 + unsigned int save, call, nop;
11073 +
11074 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11075 + err |= get_user(call, (unsigned int *)regs->tpc);
11076 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11077 + if (err)
11078 + break;
11079 +
11080 + if (save == 0x9DE3BFA8U &&
11081 + (call & 0xC0000000U) == 0x40000000U &&
11082 + nop == 0x01000000U)
11083 + {
11084 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11085 +
11086 + if (test_thread_flag(TIF_32BIT))
11087 + dl_resolve &= 0xFFFFFFFFUL;
11088 +
11089 + regs->u_regs[UREG_RETPC] = regs->tpc;
11090 + regs->tpc = dl_resolve;
11091 + regs->tnpc = dl_resolve+4;
11092 + return 3;
11093 + }
11094 + } while (0);
11095 +#endif
11096 +
11097 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11098 + unsigned int sethi, ba, nop;
11099 +
11100 + err = get_user(sethi, (unsigned int *)regs->tpc);
11101 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11102 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11103 +
11104 + if (err)
11105 + break;
11106 +
11107 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11108 + (ba & 0xFFF00000U) == 0x30600000U &&
11109 + nop == 0x01000000U)
11110 + {
11111 + unsigned long addr;
11112 +
11113 + addr = (sethi & 0x003FFFFFU) << 10;
11114 + regs->u_regs[UREG_G1] = addr;
11115 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11116 +
11117 + if (test_thread_flag(TIF_32BIT))
11118 + addr &= 0xFFFFFFFFUL;
11119 +
11120 + regs->tpc = addr;
11121 + regs->tnpc = addr+4;
11122 + return 2;
11123 + }
11124 + } while (0);
11125 +
11126 +#endif
11127 +
11128 + return 1;
11129 +}
11130 +
11131 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11132 +{
11133 + unsigned long i;
11134 +
11135 + printk(KERN_ERR "PAX: bytes at PC: ");
11136 + for (i = 0; i < 8; i++) {
11137 + unsigned int c;
11138 + if (get_user(c, (unsigned int *)pc+i))
11139 + printk(KERN_CONT "???????? ");
11140 + else
11141 + printk(KERN_CONT "%08x ", c);
11142 + }
11143 + printk("\n");
11144 +}
11145 +#endif
11146 +
11147 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11148 {
11149 struct mm_struct *mm = current->mm;
11150 @@ -341,6 +804,29 @@ retry:
11151 if (!vma)
11152 goto bad_area;
11153
11154 +#ifdef CONFIG_PAX_PAGEEXEC
11155 + /* PaX: detect ITLB misses on non-exec pages */
11156 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11157 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11158 + {
11159 + if (address != regs->tpc)
11160 + goto good_area;
11161 +
11162 + up_read(&mm->mmap_sem);
11163 + switch (pax_handle_fetch_fault(regs)) {
11164 +
11165 +#ifdef CONFIG_PAX_EMUPLT
11166 + case 2:
11167 + case 3:
11168 + return;
11169 +#endif
11170 +
11171 + }
11172 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11173 + do_group_exit(SIGKILL);
11174 + }
11175 +#endif
11176 +
11177 /* Pure DTLB misses do not tell us whether the fault causing
11178 * load/store/atomic was a write or not, it only says that there
11179 * was no match. So in such a case we (carefully) read the
11180 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11181 index d2b5944..d878f3c 100644
11182 --- a/arch/sparc/mm/hugetlbpage.c
11183 +++ b/arch/sparc/mm/hugetlbpage.c
11184 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11185 unsigned long addr,
11186 unsigned long len,
11187 unsigned long pgoff,
11188 - unsigned long flags)
11189 + unsigned long flags,
11190 + unsigned long offset)
11191 {
11192 unsigned long task_size = TASK_SIZE;
11193 struct vm_unmapped_area_info info;
11194 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11195
11196 info.flags = 0;
11197 info.length = len;
11198 - info.low_limit = TASK_UNMAPPED_BASE;
11199 + info.low_limit = mm->mmap_base;
11200 info.high_limit = min(task_size, VA_EXCLUDE_START);
11201 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11202 info.align_offset = 0;
11203 + info.threadstack_offset = offset;
11204 addr = vm_unmapped_area(&info);
11205
11206 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11207 VM_BUG_ON(addr != -ENOMEM);
11208 info.low_limit = VA_EXCLUDE_END;
11209 +
11210 +#ifdef CONFIG_PAX_RANDMMAP
11211 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11212 + info.low_limit += mm->delta_mmap;
11213 +#endif
11214 +
11215 info.high_limit = task_size;
11216 addr = vm_unmapped_area(&info);
11217 }
11218 @@ -58,7 +66,8 @@ static unsigned long
11219 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11220 const unsigned long len,
11221 const unsigned long pgoff,
11222 - const unsigned long flags)
11223 + const unsigned long flags,
11224 + const unsigned long offset)
11225 {
11226 struct mm_struct *mm = current->mm;
11227 unsigned long addr = addr0;
11228 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11229 info.high_limit = mm->mmap_base;
11230 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11231 info.align_offset = 0;
11232 + info.threadstack_offset = offset;
11233 addr = vm_unmapped_area(&info);
11234
11235 /*
11236 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11237 VM_BUG_ON(addr != -ENOMEM);
11238 info.flags = 0;
11239 info.low_limit = TASK_UNMAPPED_BASE;
11240 +
11241 +#ifdef CONFIG_PAX_RANDMMAP
11242 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11243 + info.low_limit += mm->delta_mmap;
11244 +#endif
11245 +
11246 info.high_limit = STACK_TOP32;
11247 addr = vm_unmapped_area(&info);
11248 }
11249 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11250 struct mm_struct *mm = current->mm;
11251 struct vm_area_struct *vma;
11252 unsigned long task_size = TASK_SIZE;
11253 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11254
11255 if (test_thread_flag(TIF_32BIT))
11256 task_size = STACK_TOP32;
11257 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11258 return addr;
11259 }
11260
11261 +#ifdef CONFIG_PAX_RANDMMAP
11262 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11263 +#endif
11264 +
11265 if (addr) {
11266 addr = ALIGN(addr, HPAGE_SIZE);
11267 vma = find_vma(mm, addr);
11268 - if (task_size - len >= addr &&
11269 - (!vma || addr + len <= vma->vm_start))
11270 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11271 return addr;
11272 }
11273 if (mm->get_unmapped_area == arch_get_unmapped_area)
11274 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11275 - pgoff, flags);
11276 + pgoff, flags, offset);
11277 else
11278 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11279 - pgoff, flags);
11280 + pgoff, flags, offset);
11281 }
11282
11283 pte_t *huge_pte_alloc(struct mm_struct *mm,
11284 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11285 index ed82eda..0d80e77 100644
11286 --- a/arch/sparc/mm/init_64.c
11287 +++ b/arch/sparc/mm/init_64.c
11288 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11289 int num_kernel_image_mappings;
11290
11291 #ifdef CONFIG_DEBUG_DCFLUSH
11292 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11293 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11294 #ifdef CONFIG_SMP
11295 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11296 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11297 #endif
11298 #endif
11299
11300 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11301 {
11302 BUG_ON(tlb_type == hypervisor);
11303 #ifdef CONFIG_DEBUG_DCFLUSH
11304 - atomic_inc(&dcpage_flushes);
11305 + atomic_inc_unchecked(&dcpage_flushes);
11306 #endif
11307
11308 #ifdef DCACHE_ALIASING_POSSIBLE
11309 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11310
11311 #ifdef CONFIG_DEBUG_DCFLUSH
11312 seq_printf(m, "DCPageFlushes\t: %d\n",
11313 - atomic_read(&dcpage_flushes));
11314 + atomic_read_unchecked(&dcpage_flushes));
11315 #ifdef CONFIG_SMP
11316 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11317 - atomic_read(&dcpage_flushes_xcall));
11318 + atomic_read_unchecked(&dcpage_flushes_xcall));
11319 #endif /* CONFIG_SMP */
11320 #endif /* CONFIG_DEBUG_DCFLUSH */
11321 }
11322 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11323 index f4500c6..889656c 100644
11324 --- a/arch/tile/include/asm/atomic_64.h
11325 +++ b/arch/tile/include/asm/atomic_64.h
11326 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11327
11328 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11329
11330 +#define atomic64_read_unchecked(v) atomic64_read(v)
11331 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11332 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11333 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11334 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11335 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11336 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11337 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11338 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11339 +
11340 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11341 #define smp_mb__before_atomic_dec() smp_mb()
11342 #define smp_mb__after_atomic_dec() smp_mb()
11343 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11344 index a9a5299..0fce79e 100644
11345 --- a/arch/tile/include/asm/cache.h
11346 +++ b/arch/tile/include/asm/cache.h
11347 @@ -15,11 +15,12 @@
11348 #ifndef _ASM_TILE_CACHE_H
11349 #define _ASM_TILE_CACHE_H
11350
11351 +#include <linux/const.h>
11352 #include <arch/chip.h>
11353
11354 /* bytes per L1 data cache line */
11355 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11356 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11357 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11358
11359 /* bytes per L2 cache line */
11360 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11361 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11362 index e4d44bd..99927a3 100644
11363 --- a/arch/tile/include/asm/uaccess.h
11364 +++ b/arch/tile/include/asm/uaccess.h
11365 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11366 const void __user *from,
11367 unsigned long n)
11368 {
11369 - int sz = __compiletime_object_size(to);
11370 + size_t sz = __compiletime_object_size(to);
11371
11372 - if (likely(sz == -1 || sz >= n))
11373 + if (likely(sz == (size_t)-1 || sz >= n))
11374 n = _copy_from_user(to, from, n);
11375 else
11376 copy_from_user_overflow();
11377 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11378 index 650ccff..45fe2d6 100644
11379 --- a/arch/tile/mm/hugetlbpage.c
11380 +++ b/arch/tile/mm/hugetlbpage.c
11381 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11382 info.high_limit = TASK_SIZE;
11383 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11384 info.align_offset = 0;
11385 + info.threadstack_offset = 0;
11386 return vm_unmapped_area(&info);
11387 }
11388
11389 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11390 info.high_limit = current->mm->mmap_base;
11391 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11392 info.align_offset = 0;
11393 + info.threadstack_offset = 0;
11394 addr = vm_unmapped_area(&info);
11395
11396 /*
11397 diff --git a/arch/um/Makefile b/arch/um/Makefile
11398 index 133f7de..1d6f2f1 100644
11399 --- a/arch/um/Makefile
11400 +++ b/arch/um/Makefile
11401 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11402 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11403 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11404
11405 +ifdef CONSTIFY_PLUGIN
11406 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11407 +endif
11408 +
11409 #This will adjust *FLAGS accordingly to the platform.
11410 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11411
11412 diff --git a/arch/um/defconfig b/arch/um/defconfig
11413 index 08107a7..ab22afe 100644
11414 --- a/arch/um/defconfig
11415 +++ b/arch/um/defconfig
11416 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11417 CONFIG_X86_L1_CACHE_SHIFT=5
11418 CONFIG_X86_XADD=y
11419 CONFIG_X86_PPRO_FENCE=y
11420 -CONFIG_X86_WP_WORKS_OK=y
11421 CONFIG_X86_INVLPG=y
11422 CONFIG_X86_BSWAP=y
11423 CONFIG_X86_POPAD_OK=y
11424 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11425 index 19e1bdd..3665b77 100644
11426 --- a/arch/um/include/asm/cache.h
11427 +++ b/arch/um/include/asm/cache.h
11428 @@ -1,6 +1,7 @@
11429 #ifndef __UM_CACHE_H
11430 #define __UM_CACHE_H
11431
11432 +#include <linux/const.h>
11433
11434 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11435 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11436 @@ -12,6 +13,6 @@
11437 # define L1_CACHE_SHIFT 5
11438 #endif
11439
11440 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11441 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11442
11443 #endif
11444 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11445 index 2e0a6b1..a64d0f5 100644
11446 --- a/arch/um/include/asm/kmap_types.h
11447 +++ b/arch/um/include/asm/kmap_types.h
11448 @@ -8,6 +8,6 @@
11449
11450 /* No more #include "asm/arch/kmap_types.h" ! */
11451
11452 -#define KM_TYPE_NR 14
11453 +#define KM_TYPE_NR 15
11454
11455 #endif
11456 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11457 index 5ff53d9..5850cdf 100644
11458 --- a/arch/um/include/asm/page.h
11459 +++ b/arch/um/include/asm/page.h
11460 @@ -14,6 +14,9 @@
11461 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11462 #define PAGE_MASK (~(PAGE_SIZE-1))
11463
11464 +#define ktla_ktva(addr) (addr)
11465 +#define ktva_ktla(addr) (addr)
11466 +
11467 #ifndef __ASSEMBLY__
11468
11469 struct page;
11470 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11471 index 0032f92..cd151e0 100644
11472 --- a/arch/um/include/asm/pgtable-3level.h
11473 +++ b/arch/um/include/asm/pgtable-3level.h
11474 @@ -58,6 +58,7 @@
11475 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11476 #define pud_populate(mm, pud, pmd) \
11477 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11478 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11479
11480 #ifdef CONFIG_64BIT
11481 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11482 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11483 index bbcef52..6a2a483 100644
11484 --- a/arch/um/kernel/process.c
11485 +++ b/arch/um/kernel/process.c
11486 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11487 return 2;
11488 }
11489
11490 -/*
11491 - * Only x86 and x86_64 have an arch_align_stack().
11492 - * All other arches have "#define arch_align_stack(x) (x)"
11493 - * in their asm/system.h
11494 - * As this is included in UML from asm-um/system-generic.h,
11495 - * we can use it to behave as the subarch does.
11496 - */
11497 -#ifndef arch_align_stack
11498 -unsigned long arch_align_stack(unsigned long sp)
11499 -{
11500 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11501 - sp -= get_random_int() % 8192;
11502 - return sp & ~0xf;
11503 -}
11504 -#endif
11505 -
11506 unsigned long get_wchan(struct task_struct *p)
11507 {
11508 unsigned long stack_page, sp, ip;
11509 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11510 index ad8f795..2c7eec6 100644
11511 --- a/arch/unicore32/include/asm/cache.h
11512 +++ b/arch/unicore32/include/asm/cache.h
11513 @@ -12,8 +12,10 @@
11514 #ifndef __UNICORE_CACHE_H__
11515 #define __UNICORE_CACHE_H__
11516
11517 -#define L1_CACHE_SHIFT (5)
11518 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11519 +#include <linux/const.h>
11520 +
11521 +#define L1_CACHE_SHIFT 5
11522 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11523
11524 /*
11525 * Memory returned by kmalloc() may be used for DMA, so we must make
11526 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11527 index b32ebf9..5704f98 100644
11528 --- a/arch/x86/Kconfig
11529 +++ b/arch/x86/Kconfig
11530 @@ -248,7 +248,7 @@ config X86_HT
11531
11532 config X86_32_LAZY_GS
11533 def_bool y
11534 - depends on X86_32 && !CC_STACKPROTECTOR
11535 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11536
11537 config ARCH_HWEIGHT_CFLAGS
11538 string
11539 @@ -1088,6 +1088,7 @@ config MICROCODE_EARLY
11540
11541 config X86_MSR
11542 tristate "/dev/cpu/*/msr - Model-specific register support"
11543 + depends on !GRKERNSEC_KMEM
11544 ---help---
11545 This device gives privileged processes access to the x86
11546 Model-Specific Registers (MSRs). It is a character device with
11547 @@ -1111,7 +1112,7 @@ choice
11548
11549 config NOHIGHMEM
11550 bool "off"
11551 - depends on !X86_NUMAQ
11552 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11553 ---help---
11554 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11555 However, the address space of 32-bit x86 processors is only 4
11556 @@ -1148,7 +1149,7 @@ config NOHIGHMEM
11557
11558 config HIGHMEM4G
11559 bool "4GB"
11560 - depends on !X86_NUMAQ
11561 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11562 ---help---
11563 Select this if you have a 32-bit processor and between 1 and 4
11564 gigabytes of physical RAM.
11565 @@ -1201,7 +1202,7 @@ config PAGE_OFFSET
11566 hex
11567 default 0xB0000000 if VMSPLIT_3G_OPT
11568 default 0x80000000 if VMSPLIT_2G
11569 - default 0x78000000 if VMSPLIT_2G_OPT
11570 + default 0x70000000 if VMSPLIT_2G_OPT
11571 default 0x40000000 if VMSPLIT_1G
11572 default 0xC0000000
11573 depends on X86_32
11574 @@ -1599,6 +1600,7 @@ config SECCOMP
11575
11576 config CC_STACKPROTECTOR
11577 bool "Enable -fstack-protector buffer overflow detection"
11578 + depends on X86_64 || !PAX_MEMORY_UDEREF
11579 ---help---
11580 This option turns on the -fstack-protector GCC feature. This
11581 feature puts, at the beginning of functions, a canary value on
11582 @@ -1718,6 +1720,8 @@ config X86_NEED_RELOCS
11583 config PHYSICAL_ALIGN
11584 hex "Alignment value to which kernel should be aligned" if X86_32
11585 default "0x1000000"
11586 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11587 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11588 range 0x2000 0x1000000
11589 ---help---
11590 This value puts the alignment restrictions on physical address
11591 @@ -1793,9 +1797,10 @@ config DEBUG_HOTPLUG_CPU0
11592 If unsure, say N.
11593
11594 config COMPAT_VDSO
11595 - def_bool y
11596 + def_bool n
11597 prompt "Compat VDSO support"
11598 depends on X86_32 || IA32_EMULATION
11599 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11600 ---help---
11601 Map the 32-bit VDSO to the predictable old-style address too.
11602
11603 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11604 index c026cca..14657ae 100644
11605 --- a/arch/x86/Kconfig.cpu
11606 +++ b/arch/x86/Kconfig.cpu
11607 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11608
11609 config X86_F00F_BUG
11610 def_bool y
11611 - depends on M586MMX || M586TSC || M586 || M486
11612 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11613
11614 config X86_INVD_BUG
11615 def_bool y
11616 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11617
11618 config X86_ALIGNMENT_16
11619 def_bool y
11620 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11621 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11622
11623 config X86_INTEL_USERCOPY
11624 def_bool y
11625 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11626 # generates cmov.
11627 config X86_CMOV
11628 def_bool y
11629 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11630 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11631
11632 config X86_MINIMUM_CPU_FAMILY
11633 int
11634 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11635 index 78d91af..8ceb94b 100644
11636 --- a/arch/x86/Kconfig.debug
11637 +++ b/arch/x86/Kconfig.debug
11638 @@ -74,7 +74,7 @@ config X86_PTDUMP
11639 config DEBUG_RODATA
11640 bool "Write protect kernel read-only data structures"
11641 default y
11642 - depends on DEBUG_KERNEL
11643 + depends on DEBUG_KERNEL && BROKEN
11644 ---help---
11645 Mark the kernel read-only data as write-protected in the pagetables,
11646 in order to catch accidental (and incorrect) writes to such const
11647 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11648
11649 config DEBUG_SET_MODULE_RONX
11650 bool "Set loadable kernel module data as NX and text as RO"
11651 - depends on MODULES
11652 + depends on MODULES && BROKEN
11653 ---help---
11654 This option helps catch unintended modifications to loadable
11655 kernel module's text and read-only data. It also prevents execution
11656 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11657 index 07639c6..6f2c901 100644
11658 --- a/arch/x86/Makefile
11659 +++ b/arch/x86/Makefile
11660 @@ -54,6 +54,7 @@ else
11661 UTS_MACHINE := x86_64
11662 CHECKFLAGS += -D__x86_64__ -m64
11663
11664 + biarch := $(call cc-option,-m64)
11665 KBUILD_AFLAGS += -m64
11666 KBUILD_CFLAGS += -m64
11667
11668 @@ -241,3 +242,12 @@ define archhelp
11669 echo ' FDINITRD=file initrd for the booted kernel'
11670 echo ' kvmconfig - Enable additional options for guest kernel support'
11671 endef
11672 +
11673 +define OLD_LD
11674 +
11675 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11676 +*** Please upgrade your binutils to 2.18 or newer
11677 +endef
11678 +
11679 +archprepare:
11680 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11681 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11682 index 379814b..add62ce 100644
11683 --- a/arch/x86/boot/Makefile
11684 +++ b/arch/x86/boot/Makefile
11685 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11686 $(call cc-option, -fno-stack-protector) \
11687 $(call cc-option, -mpreferred-stack-boundary=2)
11688 KBUILD_CFLAGS += $(call cc-option, -m32)
11689 +ifdef CONSTIFY_PLUGIN
11690 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11691 +endif
11692 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11693 GCOV_PROFILE := n
11694
11695 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11696 index 878e4b9..20537ab 100644
11697 --- a/arch/x86/boot/bitops.h
11698 +++ b/arch/x86/boot/bitops.h
11699 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11700 u8 v;
11701 const u32 *p = (const u32 *)addr;
11702
11703 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11704 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11705 return v;
11706 }
11707
11708 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11709
11710 static inline void set_bit(int nr, void *addr)
11711 {
11712 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11713 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11714 }
11715
11716 #endif /* BOOT_BITOPS_H */
11717 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11718 index 5b75319..331a4ca 100644
11719 --- a/arch/x86/boot/boot.h
11720 +++ b/arch/x86/boot/boot.h
11721 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11722 static inline u16 ds(void)
11723 {
11724 u16 seg;
11725 - asm("movw %%ds,%0" : "=rm" (seg));
11726 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11727 return seg;
11728 }
11729
11730 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11731 static inline int memcmp(const void *s1, const void *s2, size_t len)
11732 {
11733 u8 diff;
11734 - asm("repe; cmpsb; setnz %0"
11735 + asm volatile("repe; cmpsb; setnz %0"
11736 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11737 return diff;
11738 }
11739 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11740 index dcd90df..c830d7d 100644
11741 --- a/arch/x86/boot/compressed/Makefile
11742 +++ b/arch/x86/boot/compressed/Makefile
11743 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11744 KBUILD_CFLAGS += $(cflags-y)
11745 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11746 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11747 +ifdef CONSTIFY_PLUGIN
11748 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11749 +endif
11750
11751 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11752 GCOV_PROFILE := n
11753 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11754 index b7388a4..03844ec 100644
11755 --- a/arch/x86/boot/compressed/eboot.c
11756 +++ b/arch/x86/boot/compressed/eboot.c
11757 @@ -150,7 +150,6 @@ again:
11758 *addr = max_addr;
11759 }
11760
11761 -free_pool:
11762 efi_call_phys1(sys_table->boottime->free_pool, map);
11763
11764 fail:
11765 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11766 if (i == map_size / desc_size)
11767 status = EFI_NOT_FOUND;
11768
11769 -free_pool:
11770 efi_call_phys1(sys_table->boottime->free_pool, map);
11771 fail:
11772 return status;
11773 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11774 index a53440e..c3dbf1e 100644
11775 --- a/arch/x86/boot/compressed/efi_stub_32.S
11776 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11777 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11778 * parameter 2, ..., param n. To make things easy, we save the return
11779 * address of efi_call_phys in a global variable.
11780 */
11781 - popl %ecx
11782 - movl %ecx, saved_return_addr(%edx)
11783 - /* get the function pointer into ECX*/
11784 - popl %ecx
11785 - movl %ecx, efi_rt_function_ptr(%edx)
11786 + popl saved_return_addr(%edx)
11787 + popl efi_rt_function_ptr(%edx)
11788
11789 /*
11790 * 3. Call the physical function.
11791 */
11792 - call *%ecx
11793 + call *efi_rt_function_ptr(%edx)
11794
11795 /*
11796 * 4. Balance the stack. And because EAX contain the return value,
11797 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11798 1: popl %edx
11799 subl $1b, %edx
11800
11801 - movl efi_rt_function_ptr(%edx), %ecx
11802 - pushl %ecx
11803 + pushl efi_rt_function_ptr(%edx)
11804
11805 /*
11806 * 10. Push the saved return address onto the stack and return.
11807 */
11808 - movl saved_return_addr(%edx), %ecx
11809 - pushl %ecx
11810 - ret
11811 + jmpl *saved_return_addr(%edx)
11812 ENDPROC(efi_call_phys)
11813 .previous
11814
11815 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11816 index 1e3184f..0d11e2e 100644
11817 --- a/arch/x86/boot/compressed/head_32.S
11818 +++ b/arch/x86/boot/compressed/head_32.S
11819 @@ -118,7 +118,7 @@ preferred_addr:
11820 notl %eax
11821 andl %eax, %ebx
11822 #else
11823 - movl $LOAD_PHYSICAL_ADDR, %ebx
11824 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11825 #endif
11826
11827 /* Target address to relocate to for decompression */
11828 @@ -204,7 +204,7 @@ relocated:
11829 * and where it was actually loaded.
11830 */
11831 movl %ebp, %ebx
11832 - subl $LOAD_PHYSICAL_ADDR, %ebx
11833 + subl $____LOAD_PHYSICAL_ADDR, %ebx
11834 jz 2f /* Nothing to be done if loaded at compiled addr. */
11835 /*
11836 * Process relocations.
11837 @@ -212,8 +212,7 @@ relocated:
11838
11839 1: subl $4, %edi
11840 movl (%edi), %ecx
11841 - testl %ecx, %ecx
11842 - jz 2f
11843 + jecxz 2f
11844 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
11845 jmp 1b
11846 2:
11847 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11848 index 06e71c2..88a98264 100644
11849 --- a/arch/x86/boot/compressed/head_64.S
11850 +++ b/arch/x86/boot/compressed/head_64.S
11851 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11852 notl %eax
11853 andl %eax, %ebx
11854 #else
11855 - movl $LOAD_PHYSICAL_ADDR, %ebx
11856 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11857 #endif
11858
11859 /* Target address to relocate to for decompression */
11860 @@ -270,7 +270,7 @@ preferred_addr:
11861 notq %rax
11862 andq %rax, %rbp
11863 #else
11864 - movq $LOAD_PHYSICAL_ADDR, %rbp
11865 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11866 #endif
11867
11868 /* Target address to relocate to for decompression */
11869 @@ -361,8 +361,8 @@ gdt:
11870 .long gdt
11871 .word 0
11872 .quad 0x0000000000000000 /* NULL descriptor */
11873 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11874 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11875 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11876 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11877 .quad 0x0080890000000000 /* TS descriptor */
11878 .quad 0x0000000000000000 /* TS continued */
11879 gdt_end:
11880 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11881 index 0319c88..7c1931f 100644
11882 --- a/arch/x86/boot/compressed/misc.c
11883 +++ b/arch/x86/boot/compressed/misc.c
11884 @@ -307,7 +307,7 @@ static void parse_elf(void *output)
11885 case PT_LOAD:
11886 #ifdef CONFIG_RELOCATABLE
11887 dest = output;
11888 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11889 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11890 #else
11891 dest = (void *)(phdr->p_paddr);
11892 #endif
11893 @@ -358,7 +358,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11894 error("Destination address too large");
11895 #endif
11896 #ifndef CONFIG_RELOCATABLE
11897 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11898 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11899 error("Wrong destination address");
11900 #endif
11901
11902 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11903 index 4d3ff03..e4972ff 100644
11904 --- a/arch/x86/boot/cpucheck.c
11905 +++ b/arch/x86/boot/cpucheck.c
11906 @@ -74,7 +74,7 @@ static int has_fpu(void)
11907 u16 fcw = -1, fsw = -1;
11908 u32 cr0;
11909
11910 - asm("movl %%cr0,%0" : "=r" (cr0));
11911 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11912 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11913 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11914 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11915 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11916 {
11917 u32 f0, f1;
11918
11919 - asm("pushfl ; "
11920 + asm volatile("pushfl ; "
11921 "pushfl ; "
11922 "popl %0 ; "
11923 "movl %0,%1 ; "
11924 @@ -115,7 +115,7 @@ static void get_flags(void)
11925 set_bit(X86_FEATURE_FPU, cpu.flags);
11926
11927 if (has_eflag(X86_EFLAGS_ID)) {
11928 - asm("cpuid"
11929 + asm volatile("cpuid"
11930 : "=a" (max_intel_level),
11931 "=b" (cpu_vendor[0]),
11932 "=d" (cpu_vendor[1]),
11933 @@ -124,7 +124,7 @@ static void get_flags(void)
11934
11935 if (max_intel_level >= 0x00000001 &&
11936 max_intel_level <= 0x0000ffff) {
11937 - asm("cpuid"
11938 + asm volatile("cpuid"
11939 : "=a" (tfms),
11940 "=c" (cpu.flags[4]),
11941 "=d" (cpu.flags[0])
11942 @@ -136,7 +136,7 @@ static void get_flags(void)
11943 cpu.model += ((tfms >> 16) & 0xf) << 4;
11944 }
11945
11946 - asm("cpuid"
11947 + asm volatile("cpuid"
11948 : "=a" (max_amd_level)
11949 : "a" (0x80000000)
11950 : "ebx", "ecx", "edx");
11951 @@ -144,7 +144,7 @@ static void get_flags(void)
11952 if (max_amd_level >= 0x80000001 &&
11953 max_amd_level <= 0x8000ffff) {
11954 u32 eax = 0x80000001;
11955 - asm("cpuid"
11956 + asm volatile("cpuid"
11957 : "+a" (eax),
11958 "=c" (cpu.flags[6]),
11959 "=d" (cpu.flags[1])
11960 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11961 u32 ecx = MSR_K7_HWCR;
11962 u32 eax, edx;
11963
11964 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11965 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11966 eax &= ~(1 << 15);
11967 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11968 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11969
11970 get_flags(); /* Make sure it really did something */
11971 err = check_flags();
11972 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11973 u32 ecx = MSR_VIA_FCR;
11974 u32 eax, edx;
11975
11976 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11977 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11978 eax |= (1<<1)|(1<<7);
11979 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11980 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11981
11982 set_bit(X86_FEATURE_CX8, cpu.flags);
11983 err = check_flags();
11984 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11985 u32 eax, edx;
11986 u32 level = 1;
11987
11988 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11989 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11990 - asm("cpuid"
11991 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11992 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11993 + asm volatile("cpuid"
11994 : "+a" (level), "=d" (cpu.flags[0])
11995 : : "ecx", "ebx");
11996 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11997 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11998
11999 err = check_flags();
12000 }
12001 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12002 index 9ec06a1..2c25e79 100644
12003 --- a/arch/x86/boot/header.S
12004 +++ b/arch/x86/boot/header.S
12005 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12006 # single linked list of
12007 # struct setup_data
12008
12009 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12010 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12011
12012 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12013 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12014 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12015 +#else
12016 #define VO_INIT_SIZE (VO__end - VO__text)
12017 +#endif
12018 #if ZO_INIT_SIZE > VO_INIT_SIZE
12019 #define INIT_SIZE ZO_INIT_SIZE
12020 #else
12021 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12022 index db75d07..8e6d0af 100644
12023 --- a/arch/x86/boot/memory.c
12024 +++ b/arch/x86/boot/memory.c
12025 @@ -19,7 +19,7 @@
12026
12027 static int detect_memory_e820(void)
12028 {
12029 - int count = 0;
12030 + unsigned int count = 0;
12031 struct biosregs ireg, oreg;
12032 struct e820entry *desc = boot_params.e820_map;
12033 static struct e820entry buf; /* static so it is zeroed */
12034 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12035 index 11e8c6e..fdbb1ed 100644
12036 --- a/arch/x86/boot/video-vesa.c
12037 +++ b/arch/x86/boot/video-vesa.c
12038 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12039
12040 boot_params.screen_info.vesapm_seg = oreg.es;
12041 boot_params.screen_info.vesapm_off = oreg.di;
12042 + boot_params.screen_info.vesapm_size = oreg.cx;
12043 }
12044
12045 /*
12046 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12047 index 43eda28..5ab5fdb 100644
12048 --- a/arch/x86/boot/video.c
12049 +++ b/arch/x86/boot/video.c
12050 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12051 static unsigned int get_entry(void)
12052 {
12053 char entry_buf[4];
12054 - int i, len = 0;
12055 + unsigned int i, len = 0;
12056 int key;
12057 unsigned int v;
12058
12059 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12060 index 9105655..5e37f27 100644
12061 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12062 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12063 @@ -8,6 +8,8 @@
12064 * including this sentence is retained in full.
12065 */
12066
12067 +#include <asm/alternative-asm.h>
12068 +
12069 .extern crypto_ft_tab
12070 .extern crypto_it_tab
12071 .extern crypto_fl_tab
12072 @@ -70,6 +72,8 @@
12073 je B192; \
12074 leaq 32(r9),r9;
12075
12076 +#define ret pax_force_retaddr 0, 1; ret
12077 +
12078 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12079 movq r1,r2; \
12080 movq r3,r4; \
12081 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12082 index 477e9d7..3ab339f 100644
12083 --- a/arch/x86/crypto/aesni-intel_asm.S
12084 +++ b/arch/x86/crypto/aesni-intel_asm.S
12085 @@ -31,6 +31,7 @@
12086
12087 #include <linux/linkage.h>
12088 #include <asm/inst.h>
12089 +#include <asm/alternative-asm.h>
12090
12091 #ifdef __x86_64__
12092 .data
12093 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12094 pop %r14
12095 pop %r13
12096 pop %r12
12097 + pax_force_retaddr 0, 1
12098 ret
12099 ENDPROC(aesni_gcm_dec)
12100
12101 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12102 pop %r14
12103 pop %r13
12104 pop %r12
12105 + pax_force_retaddr 0, 1
12106 ret
12107 ENDPROC(aesni_gcm_enc)
12108
12109 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12110 pxor %xmm1, %xmm0
12111 movaps %xmm0, (TKEYP)
12112 add $0x10, TKEYP
12113 + pax_force_retaddr_bts
12114 ret
12115 ENDPROC(_key_expansion_128)
12116 ENDPROC(_key_expansion_256a)
12117 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12118 shufps $0b01001110, %xmm2, %xmm1
12119 movaps %xmm1, 0x10(TKEYP)
12120 add $0x20, TKEYP
12121 + pax_force_retaddr_bts
12122 ret
12123 ENDPROC(_key_expansion_192a)
12124
12125 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12126
12127 movaps %xmm0, (TKEYP)
12128 add $0x10, TKEYP
12129 + pax_force_retaddr_bts
12130 ret
12131 ENDPROC(_key_expansion_192b)
12132
12133 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12134 pxor %xmm1, %xmm2
12135 movaps %xmm2, (TKEYP)
12136 add $0x10, TKEYP
12137 + pax_force_retaddr_bts
12138 ret
12139 ENDPROC(_key_expansion_256b)
12140
12141 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12142 #ifndef __x86_64__
12143 popl KEYP
12144 #endif
12145 + pax_force_retaddr 0, 1
12146 ret
12147 ENDPROC(aesni_set_key)
12148
12149 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12150 popl KLEN
12151 popl KEYP
12152 #endif
12153 + pax_force_retaddr 0, 1
12154 ret
12155 ENDPROC(aesni_enc)
12156
12157 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12158 AESENC KEY STATE
12159 movaps 0x70(TKEYP), KEY
12160 AESENCLAST KEY STATE
12161 + pax_force_retaddr_bts
12162 ret
12163 ENDPROC(_aesni_enc1)
12164
12165 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12166 AESENCLAST KEY STATE2
12167 AESENCLAST KEY STATE3
12168 AESENCLAST KEY STATE4
12169 + pax_force_retaddr_bts
12170 ret
12171 ENDPROC(_aesni_enc4)
12172
12173 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12174 popl KLEN
12175 popl KEYP
12176 #endif
12177 + pax_force_retaddr 0, 1
12178 ret
12179 ENDPROC(aesni_dec)
12180
12181 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12182 AESDEC KEY STATE
12183 movaps 0x70(TKEYP), KEY
12184 AESDECLAST KEY STATE
12185 + pax_force_retaddr_bts
12186 ret
12187 ENDPROC(_aesni_dec1)
12188
12189 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12190 AESDECLAST KEY STATE2
12191 AESDECLAST KEY STATE3
12192 AESDECLAST KEY STATE4
12193 + pax_force_retaddr_bts
12194 ret
12195 ENDPROC(_aesni_dec4)
12196
12197 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12198 popl KEYP
12199 popl LEN
12200 #endif
12201 + pax_force_retaddr 0, 1
12202 ret
12203 ENDPROC(aesni_ecb_enc)
12204
12205 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12206 popl KEYP
12207 popl LEN
12208 #endif
12209 + pax_force_retaddr 0, 1
12210 ret
12211 ENDPROC(aesni_ecb_dec)
12212
12213 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12214 popl LEN
12215 popl IVP
12216 #endif
12217 + pax_force_retaddr 0, 1
12218 ret
12219 ENDPROC(aesni_cbc_enc)
12220
12221 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12222 popl LEN
12223 popl IVP
12224 #endif
12225 + pax_force_retaddr 0, 1
12226 ret
12227 ENDPROC(aesni_cbc_dec)
12228
12229 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12230 mov $1, TCTR_LOW
12231 MOVQ_R64_XMM TCTR_LOW INC
12232 MOVQ_R64_XMM CTR TCTR_LOW
12233 + pax_force_retaddr_bts
12234 ret
12235 ENDPROC(_aesni_inc_init)
12236
12237 @@ -2579,6 +2598,7 @@ _aesni_inc:
12238 .Linc_low:
12239 movaps CTR, IV
12240 PSHUFB_XMM BSWAP_MASK IV
12241 + pax_force_retaddr_bts
12242 ret
12243 ENDPROC(_aesni_inc)
12244
12245 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12246 .Lctr_enc_ret:
12247 movups IV, (IVP)
12248 .Lctr_enc_just_ret:
12249 + pax_force_retaddr 0, 1
12250 ret
12251 ENDPROC(aesni_ctr_enc)
12252
12253 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12254 pxor INC, STATE4
12255 movdqu STATE4, 0x70(OUTP)
12256
12257 + pax_force_retaddr 0, 1
12258 ret
12259 ENDPROC(aesni_xts_crypt8)
12260
12261 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12262 index 246c670..4d1ed00 100644
12263 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12264 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12265 @@ -21,6 +21,7 @@
12266 */
12267
12268 #include <linux/linkage.h>
12269 +#include <asm/alternative-asm.h>
12270
12271 .file "blowfish-x86_64-asm.S"
12272 .text
12273 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12274 jnz .L__enc_xor;
12275
12276 write_block();
12277 + pax_force_retaddr 0, 1
12278 ret;
12279 .L__enc_xor:
12280 xor_block();
12281 + pax_force_retaddr 0, 1
12282 ret;
12283 ENDPROC(__blowfish_enc_blk)
12284
12285 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12286
12287 movq %r11, %rbp;
12288
12289 + pax_force_retaddr 0, 1
12290 ret;
12291 ENDPROC(blowfish_dec_blk)
12292
12293 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12294
12295 popq %rbx;
12296 popq %rbp;
12297 + pax_force_retaddr 0, 1
12298 ret;
12299
12300 .L__enc_xor4:
12301 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12302
12303 popq %rbx;
12304 popq %rbp;
12305 + pax_force_retaddr 0, 1
12306 ret;
12307 ENDPROC(__blowfish_enc_blk_4way)
12308
12309 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12310 popq %rbx;
12311 popq %rbp;
12312
12313 + pax_force_retaddr 0, 1
12314 ret;
12315 ENDPROC(blowfish_dec_blk_4way)
12316 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12317 index ce71f92..2dd5b1e 100644
12318 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12319 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12320 @@ -16,6 +16,7 @@
12321 */
12322
12323 #include <linux/linkage.h>
12324 +#include <asm/alternative-asm.h>
12325
12326 #define CAMELLIA_TABLE_BYTE_LEN 272
12327
12328 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12329 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12330 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12331 %rcx, (%r9));
12332 + pax_force_retaddr_bts
12333 ret;
12334 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12335
12336 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12337 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12338 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12339 %rax, (%r9));
12340 + pax_force_retaddr_bts
12341 ret;
12342 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12343
12344 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12345 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12346 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12347
12348 + pax_force_retaddr_bts
12349 ret;
12350
12351 .align 8
12352 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12353 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12354 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12355
12356 + pax_force_retaddr_bts
12357 ret;
12358
12359 .align 8
12360 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12361 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12362 %xmm8, %rsi);
12363
12364 + pax_force_retaddr 0, 1
12365 ret;
12366 ENDPROC(camellia_ecb_enc_16way)
12367
12368 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12369 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12370 %xmm8, %rsi);
12371
12372 + pax_force_retaddr 0, 1
12373 ret;
12374 ENDPROC(camellia_ecb_dec_16way)
12375
12376 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12377 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12378 %xmm8, %rsi);
12379
12380 + pax_force_retaddr 0, 1
12381 ret;
12382 ENDPROC(camellia_cbc_dec_16way)
12383
12384 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12385 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12386 %xmm8, %rsi);
12387
12388 + pax_force_retaddr 0, 1
12389 ret;
12390 ENDPROC(camellia_ctr_16way)
12391
12392 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12393 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12394 %xmm8, %rsi);
12395
12396 + pax_force_retaddr 0, 1
12397 ret;
12398 ENDPROC(camellia_xts_crypt_16way)
12399
12400 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12401 index 0e0b886..8fc756a 100644
12402 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12403 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12404 @@ -11,6 +11,7 @@
12405 */
12406
12407 #include <linux/linkage.h>
12408 +#include <asm/alternative-asm.h>
12409
12410 #define CAMELLIA_TABLE_BYTE_LEN 272
12411
12412 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12413 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12414 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12415 %rcx, (%r9));
12416 + pax_force_retaddr_bts
12417 ret;
12418 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12419
12420 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12421 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12422 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12423 %rax, (%r9));
12424 + pax_force_retaddr_bts
12425 ret;
12426 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12427
12428 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12429 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12430 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12431
12432 + pax_force_retaddr_bts
12433 ret;
12434
12435 .align 8
12436 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12437 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12438 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12439
12440 + pax_force_retaddr_bts
12441 ret;
12442
12443 .align 8
12444 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12445
12446 vzeroupper;
12447
12448 + pax_force_retaddr 0, 1
12449 ret;
12450 ENDPROC(camellia_ecb_enc_32way)
12451
12452 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12453
12454 vzeroupper;
12455
12456 + pax_force_retaddr 0, 1
12457 ret;
12458 ENDPROC(camellia_ecb_dec_32way)
12459
12460 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12461
12462 vzeroupper;
12463
12464 + pax_force_retaddr 0, 1
12465 ret;
12466 ENDPROC(camellia_cbc_dec_32way)
12467
12468 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12469
12470 vzeroupper;
12471
12472 + pax_force_retaddr 0, 1
12473 ret;
12474 ENDPROC(camellia_ctr_32way)
12475
12476 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12477
12478 vzeroupper;
12479
12480 + pax_force_retaddr 0, 1
12481 ret;
12482 ENDPROC(camellia_xts_crypt_32way)
12483
12484 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12485 index 310319c..ce174a4 100644
12486 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12487 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12488 @@ -21,6 +21,7 @@
12489 */
12490
12491 #include <linux/linkage.h>
12492 +#include <asm/alternative-asm.h>
12493
12494 .file "camellia-x86_64-asm_64.S"
12495 .text
12496 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12497 enc_outunpack(mov, RT1);
12498
12499 movq RRBP, %rbp;
12500 + pax_force_retaddr 0, 1
12501 ret;
12502
12503 .L__enc_xor:
12504 enc_outunpack(xor, RT1);
12505
12506 movq RRBP, %rbp;
12507 + pax_force_retaddr 0, 1
12508 ret;
12509 ENDPROC(__camellia_enc_blk)
12510
12511 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12512 dec_outunpack();
12513
12514 movq RRBP, %rbp;
12515 + pax_force_retaddr 0, 1
12516 ret;
12517 ENDPROC(camellia_dec_blk)
12518
12519 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12520
12521 movq RRBP, %rbp;
12522 popq %rbx;
12523 + pax_force_retaddr 0, 1
12524 ret;
12525
12526 .L__enc2_xor:
12527 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12528
12529 movq RRBP, %rbp;
12530 popq %rbx;
12531 + pax_force_retaddr 0, 1
12532 ret;
12533 ENDPROC(__camellia_enc_blk_2way)
12534
12535 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12536
12537 movq RRBP, %rbp;
12538 movq RXOR, %rbx;
12539 + pax_force_retaddr 0, 1
12540 ret;
12541 ENDPROC(camellia_dec_blk_2way)
12542 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12543 index c35fd5d..c1ee236 100644
12544 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12545 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12546 @@ -24,6 +24,7 @@
12547 */
12548
12549 #include <linux/linkage.h>
12550 +#include <asm/alternative-asm.h>
12551
12552 .file "cast5-avx-x86_64-asm_64.S"
12553
12554 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12555 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12556 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12557
12558 + pax_force_retaddr 0, 1
12559 ret;
12560 ENDPROC(__cast5_enc_blk16)
12561
12562 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12563 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12564 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12565
12566 + pax_force_retaddr 0, 1
12567 ret;
12568
12569 .L__skip_dec:
12570 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12571 vmovdqu RR4, (6*4*4)(%r11);
12572 vmovdqu RL4, (7*4*4)(%r11);
12573
12574 + pax_force_retaddr
12575 ret;
12576 ENDPROC(cast5_ecb_enc_16way)
12577
12578 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12579 vmovdqu RR4, (6*4*4)(%r11);
12580 vmovdqu RL4, (7*4*4)(%r11);
12581
12582 + pax_force_retaddr
12583 ret;
12584 ENDPROC(cast5_ecb_dec_16way)
12585
12586 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12587
12588 popq %r12;
12589
12590 + pax_force_retaddr
12591 ret;
12592 ENDPROC(cast5_cbc_dec_16way)
12593
12594 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12595
12596 popq %r12;
12597
12598 + pax_force_retaddr
12599 ret;
12600 ENDPROC(cast5_ctr_16way)
12601 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12602 index e3531f8..18ded3a 100644
12603 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12604 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12605 @@ -24,6 +24,7 @@
12606 */
12607
12608 #include <linux/linkage.h>
12609 +#include <asm/alternative-asm.h>
12610 #include "glue_helper-asm-avx.S"
12611
12612 .file "cast6-avx-x86_64-asm_64.S"
12613 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12614 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12615 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12616
12617 + pax_force_retaddr 0, 1
12618 ret;
12619 ENDPROC(__cast6_enc_blk8)
12620
12621 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12622 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12623 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12624
12625 + pax_force_retaddr 0, 1
12626 ret;
12627 ENDPROC(__cast6_dec_blk8)
12628
12629 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12630
12631 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12632
12633 + pax_force_retaddr
12634 ret;
12635 ENDPROC(cast6_ecb_enc_8way)
12636
12637 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12638
12639 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12640
12641 + pax_force_retaddr
12642 ret;
12643 ENDPROC(cast6_ecb_dec_8way)
12644
12645 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12646
12647 popq %r12;
12648
12649 + pax_force_retaddr
12650 ret;
12651 ENDPROC(cast6_cbc_dec_8way)
12652
12653 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12654
12655 popq %r12;
12656
12657 + pax_force_retaddr
12658 ret;
12659 ENDPROC(cast6_ctr_8way)
12660
12661 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12662 /* dst <= regs xor IVs(in dst) */
12663 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12664
12665 + pax_force_retaddr
12666 ret;
12667 ENDPROC(cast6_xts_enc_8way)
12668
12669 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12670 /* dst <= regs xor IVs(in dst) */
12671 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12672
12673 + pax_force_retaddr
12674 ret;
12675 ENDPROC(cast6_xts_dec_8way)
12676 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12677 index dbc4339..3d868c5 100644
12678 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12679 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12680 @@ -45,6 +45,7 @@
12681
12682 #include <asm/inst.h>
12683 #include <linux/linkage.h>
12684 +#include <asm/alternative-asm.h>
12685
12686 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12687
12688 @@ -312,6 +313,7 @@ do_return:
12689 popq %rsi
12690 popq %rdi
12691 popq %rbx
12692 + pax_force_retaddr 0, 1
12693 ret
12694
12695 ################################################################
12696 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12697 index 586f41a..d02851e 100644
12698 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12699 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12700 @@ -18,6 +18,7 @@
12701
12702 #include <linux/linkage.h>
12703 #include <asm/inst.h>
12704 +#include <asm/alternative-asm.h>
12705
12706 .data
12707
12708 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12709 psrlq $1, T2
12710 pxor T2, T1
12711 pxor T1, DATA
12712 + pax_force_retaddr
12713 ret
12714 ENDPROC(__clmul_gf128mul_ble)
12715
12716 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12717 call __clmul_gf128mul_ble
12718 PSHUFB_XMM BSWAP DATA
12719 movups DATA, (%rdi)
12720 + pax_force_retaddr
12721 ret
12722 ENDPROC(clmul_ghash_mul)
12723
12724 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12725 PSHUFB_XMM BSWAP DATA
12726 movups DATA, (%rdi)
12727 .Lupdate_just_ret:
12728 + pax_force_retaddr
12729 ret
12730 ENDPROC(clmul_ghash_update)
12731
12732 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12733 pand .Lpoly, %xmm1
12734 pxor %xmm1, %xmm0
12735 movups %xmm0, (%rdi)
12736 + pax_force_retaddr
12737 ret
12738 ENDPROC(clmul_ghash_setkey)
12739 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12740 index 9279e0b..9270820 100644
12741 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12742 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12743 @@ -1,4 +1,5 @@
12744 #include <linux/linkage.h>
12745 +#include <asm/alternative-asm.h>
12746
12747 # enter salsa20_encrypt_bytes
12748 ENTRY(salsa20_encrypt_bytes)
12749 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12750 add %r11,%rsp
12751 mov %rdi,%rax
12752 mov %rsi,%rdx
12753 + pax_force_retaddr 0, 1
12754 ret
12755 # bytesatleast65:
12756 ._bytesatleast65:
12757 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12758 add %r11,%rsp
12759 mov %rdi,%rax
12760 mov %rsi,%rdx
12761 + pax_force_retaddr
12762 ret
12763 ENDPROC(salsa20_keysetup)
12764
12765 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12766 add %r11,%rsp
12767 mov %rdi,%rax
12768 mov %rsi,%rdx
12769 + pax_force_retaddr
12770 ret
12771 ENDPROC(salsa20_ivsetup)
12772 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12773 index 2f202f4..d9164d6 100644
12774 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12775 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12776 @@ -24,6 +24,7 @@
12777 */
12778
12779 #include <linux/linkage.h>
12780 +#include <asm/alternative-asm.h>
12781 #include "glue_helper-asm-avx.S"
12782
12783 .file "serpent-avx-x86_64-asm_64.S"
12784 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12785 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12786 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12787
12788 + pax_force_retaddr
12789 ret;
12790 ENDPROC(__serpent_enc_blk8_avx)
12791
12792 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12793 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12794 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12795
12796 + pax_force_retaddr
12797 ret;
12798 ENDPROC(__serpent_dec_blk8_avx)
12799
12800 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12801
12802 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12803
12804 + pax_force_retaddr
12805 ret;
12806 ENDPROC(serpent_ecb_enc_8way_avx)
12807
12808 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12809
12810 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12811
12812 + pax_force_retaddr
12813 ret;
12814 ENDPROC(serpent_ecb_dec_8way_avx)
12815
12816 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12817
12818 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12819
12820 + pax_force_retaddr
12821 ret;
12822 ENDPROC(serpent_cbc_dec_8way_avx)
12823
12824 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12825
12826 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12827
12828 + pax_force_retaddr
12829 ret;
12830 ENDPROC(serpent_ctr_8way_avx)
12831
12832 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12833 /* dst <= regs xor IVs(in dst) */
12834 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12835
12836 + pax_force_retaddr
12837 ret;
12838 ENDPROC(serpent_xts_enc_8way_avx)
12839
12840 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12841 /* dst <= regs xor IVs(in dst) */
12842 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12843
12844 + pax_force_retaddr
12845 ret;
12846 ENDPROC(serpent_xts_dec_8way_avx)
12847 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12848 index b222085..abd483c 100644
12849 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12850 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12851 @@ -15,6 +15,7 @@
12852 */
12853
12854 #include <linux/linkage.h>
12855 +#include <asm/alternative-asm.h>
12856 #include "glue_helper-asm-avx2.S"
12857
12858 .file "serpent-avx2-asm_64.S"
12859 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12860 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12861 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12862
12863 + pax_force_retaddr
12864 ret;
12865 ENDPROC(__serpent_enc_blk16)
12866
12867 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12868 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12869 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12870
12871 + pax_force_retaddr
12872 ret;
12873 ENDPROC(__serpent_dec_blk16)
12874
12875 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12876
12877 vzeroupper;
12878
12879 + pax_force_retaddr
12880 ret;
12881 ENDPROC(serpent_ecb_enc_16way)
12882
12883 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12884
12885 vzeroupper;
12886
12887 + pax_force_retaddr
12888 ret;
12889 ENDPROC(serpent_ecb_dec_16way)
12890
12891 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12892
12893 vzeroupper;
12894
12895 + pax_force_retaddr
12896 ret;
12897 ENDPROC(serpent_cbc_dec_16way)
12898
12899 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12900
12901 vzeroupper;
12902
12903 + pax_force_retaddr
12904 ret;
12905 ENDPROC(serpent_ctr_16way)
12906
12907 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12908
12909 vzeroupper;
12910
12911 + pax_force_retaddr
12912 ret;
12913 ENDPROC(serpent_xts_enc_16way)
12914
12915 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12916
12917 vzeroupper;
12918
12919 + pax_force_retaddr
12920 ret;
12921 ENDPROC(serpent_xts_dec_16way)
12922 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12923 index acc066c..1559cc4 100644
12924 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12925 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12926 @@ -25,6 +25,7 @@
12927 */
12928
12929 #include <linux/linkage.h>
12930 +#include <asm/alternative-asm.h>
12931
12932 .file "serpent-sse2-x86_64-asm_64.S"
12933 .text
12934 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12935 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12936 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12937
12938 + pax_force_retaddr
12939 ret;
12940
12941 .L__enc_xor8:
12942 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12943 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12944
12945 + pax_force_retaddr
12946 ret;
12947 ENDPROC(__serpent_enc_blk_8way)
12948
12949 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12950 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12951 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12952
12953 + pax_force_retaddr
12954 ret;
12955 ENDPROC(serpent_dec_blk_8way)
12956 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12957 index a410950..3356d42 100644
12958 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12959 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12960 @@ -29,6 +29,7 @@
12961 */
12962
12963 #include <linux/linkage.h>
12964 +#include <asm/alternative-asm.h>
12965
12966 #define CTX %rdi // arg1
12967 #define BUF %rsi // arg2
12968 @@ -104,6 +105,7 @@
12969 pop %r12
12970 pop %rbp
12971 pop %rbx
12972 + pax_force_retaddr 0, 1
12973 ret
12974
12975 ENDPROC(\name)
12976 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
12977 index 642f156..4ab07b9 100644
12978 --- a/arch/x86/crypto/sha256-avx-asm.S
12979 +++ b/arch/x86/crypto/sha256-avx-asm.S
12980 @@ -49,6 +49,7 @@
12981
12982 #ifdef CONFIG_AS_AVX
12983 #include <linux/linkage.h>
12984 +#include <asm/alternative-asm.h>
12985
12986 ## assume buffers not aligned
12987 #define VMOVDQ vmovdqu
12988 @@ -460,6 +461,7 @@ done_hash:
12989 popq %r13
12990 popq %rbp
12991 popq %rbx
12992 + pax_force_retaddr 0, 1
12993 ret
12994 ENDPROC(sha256_transform_avx)
12995
12996 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
12997 index 9e86944..2e7f95a 100644
12998 --- a/arch/x86/crypto/sha256-avx2-asm.S
12999 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13000 @@ -50,6 +50,7 @@
13001
13002 #ifdef CONFIG_AS_AVX2
13003 #include <linux/linkage.h>
13004 +#include <asm/alternative-asm.h>
13005
13006 ## assume buffers not aligned
13007 #define VMOVDQ vmovdqu
13008 @@ -720,6 +721,7 @@ done_hash:
13009 popq %r12
13010 popq %rbp
13011 popq %rbx
13012 + pax_force_retaddr 0, 1
13013 ret
13014 ENDPROC(sha256_transform_rorx)
13015
13016 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13017 index f833b74..c36ed14 100644
13018 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13019 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13020 @@ -47,6 +47,7 @@
13021 ########################################################################
13022
13023 #include <linux/linkage.h>
13024 +#include <asm/alternative-asm.h>
13025
13026 ## assume buffers not aligned
13027 #define MOVDQ movdqu
13028 @@ -471,6 +472,7 @@ done_hash:
13029 popq %rbp
13030 popq %rbx
13031
13032 + pax_force_retaddr 0, 1
13033 ret
13034 ENDPROC(sha256_transform_ssse3)
13035
13036 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13037 index 974dde9..4533d34 100644
13038 --- a/arch/x86/crypto/sha512-avx-asm.S
13039 +++ b/arch/x86/crypto/sha512-avx-asm.S
13040 @@ -49,6 +49,7 @@
13041
13042 #ifdef CONFIG_AS_AVX
13043 #include <linux/linkage.h>
13044 +#include <asm/alternative-asm.h>
13045
13046 .text
13047
13048 @@ -364,6 +365,7 @@ updateblock:
13049 mov frame_RSPSAVE(%rsp), %rsp
13050
13051 nowork:
13052 + pax_force_retaddr 0, 1
13053 ret
13054 ENDPROC(sha512_transform_avx)
13055
13056 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13057 index 568b961..061ef1d 100644
13058 --- a/arch/x86/crypto/sha512-avx2-asm.S
13059 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13060 @@ -51,6 +51,7 @@
13061
13062 #ifdef CONFIG_AS_AVX2
13063 #include <linux/linkage.h>
13064 +#include <asm/alternative-asm.h>
13065
13066 .text
13067
13068 @@ -678,6 +679,7 @@ done_hash:
13069
13070 # Restore Stack Pointer
13071 mov frame_RSPSAVE(%rsp), %rsp
13072 + pax_force_retaddr 0, 1
13073 ret
13074 ENDPROC(sha512_transform_rorx)
13075
13076 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13077 index fb56855..e23914f 100644
13078 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13079 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13080 @@ -48,6 +48,7 @@
13081 ########################################################################
13082
13083 #include <linux/linkage.h>
13084 +#include <asm/alternative-asm.h>
13085
13086 .text
13087
13088 @@ -363,6 +364,7 @@ updateblock:
13089 mov frame_RSPSAVE(%rsp), %rsp
13090
13091 nowork:
13092 + pax_force_retaddr 0, 1
13093 ret
13094 ENDPROC(sha512_transform_ssse3)
13095
13096 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13097 index 0505813..63b1d00 100644
13098 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13099 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13100 @@ -24,6 +24,7 @@
13101 */
13102
13103 #include <linux/linkage.h>
13104 +#include <asm/alternative-asm.h>
13105 #include "glue_helper-asm-avx.S"
13106
13107 .file "twofish-avx-x86_64-asm_64.S"
13108 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13109 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13110 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13111
13112 + pax_force_retaddr 0, 1
13113 ret;
13114 ENDPROC(__twofish_enc_blk8)
13115
13116 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13117 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13118 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13119
13120 + pax_force_retaddr 0, 1
13121 ret;
13122 ENDPROC(__twofish_dec_blk8)
13123
13124 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13125
13126 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13127
13128 + pax_force_retaddr 0, 1
13129 ret;
13130 ENDPROC(twofish_ecb_enc_8way)
13131
13132 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13133
13134 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13135
13136 + pax_force_retaddr 0, 1
13137 ret;
13138 ENDPROC(twofish_ecb_dec_8way)
13139
13140 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13141
13142 popq %r12;
13143
13144 + pax_force_retaddr 0, 1
13145 ret;
13146 ENDPROC(twofish_cbc_dec_8way)
13147
13148 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13149
13150 popq %r12;
13151
13152 + pax_force_retaddr 0, 1
13153 ret;
13154 ENDPROC(twofish_ctr_8way)
13155
13156 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13157 /* dst <= regs xor IVs(in dst) */
13158 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13159
13160 + pax_force_retaddr 0, 1
13161 ret;
13162 ENDPROC(twofish_xts_enc_8way)
13163
13164 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13165 /* dst <= regs xor IVs(in dst) */
13166 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13167
13168 + pax_force_retaddr 0, 1
13169 ret;
13170 ENDPROC(twofish_xts_dec_8way)
13171 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13172 index 1c3b7ce..b365c5e 100644
13173 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13174 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13175 @@ -21,6 +21,7 @@
13176 */
13177
13178 #include <linux/linkage.h>
13179 +#include <asm/alternative-asm.h>
13180
13181 .file "twofish-x86_64-asm-3way.S"
13182 .text
13183 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13184 popq %r13;
13185 popq %r14;
13186 popq %r15;
13187 + pax_force_retaddr 0, 1
13188 ret;
13189
13190 .L__enc_xor3:
13191 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13192 popq %r13;
13193 popq %r14;
13194 popq %r15;
13195 + pax_force_retaddr 0, 1
13196 ret;
13197 ENDPROC(__twofish_enc_blk_3way)
13198
13199 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13200 popq %r13;
13201 popq %r14;
13202 popq %r15;
13203 + pax_force_retaddr 0, 1
13204 ret;
13205 ENDPROC(twofish_dec_blk_3way)
13206 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13207 index a039d21..29e7615 100644
13208 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13209 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13210 @@ -22,6 +22,7 @@
13211
13212 #include <linux/linkage.h>
13213 #include <asm/asm-offsets.h>
13214 +#include <asm/alternative-asm.h>
13215
13216 #define a_offset 0
13217 #define b_offset 4
13218 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13219
13220 popq R1
13221 movq $1,%rax
13222 + pax_force_retaddr 0, 1
13223 ret
13224 ENDPROC(twofish_enc_blk)
13225
13226 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13227
13228 popq R1
13229 movq $1,%rax
13230 + pax_force_retaddr 0, 1
13231 ret
13232 ENDPROC(twofish_dec_blk)
13233 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13234 index bae3aba..c1788c1 100644
13235 --- a/arch/x86/ia32/ia32_aout.c
13236 +++ b/arch/x86/ia32/ia32_aout.c
13237 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13238 unsigned long dump_start, dump_size;
13239 struct user32 dump;
13240
13241 + memset(&dump, 0, sizeof(dump));
13242 +
13243 fs = get_fs();
13244 set_fs(KERNEL_DS);
13245 has_dumped = 1;
13246 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13247 index 665a730..8e7a67a 100644
13248 --- a/arch/x86/ia32/ia32_signal.c
13249 +++ b/arch/x86/ia32/ia32_signal.c
13250 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13251 sp -= frame_size;
13252 /* Align the stack pointer according to the i386 ABI,
13253 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13254 - sp = ((sp + 4) & -16ul) - 4;
13255 + sp = ((sp - 12) & -16ul) - 4;
13256 return (void __user *) sp;
13257 }
13258
13259 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13260 * These are actually not used anymore, but left because some
13261 * gdb versions depend on them as a marker.
13262 */
13263 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13264 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13265 } put_user_catch(err);
13266
13267 if (err)
13268 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13269 0xb8,
13270 __NR_ia32_rt_sigreturn,
13271 0x80cd,
13272 - 0,
13273 + 0
13274 };
13275
13276 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13277 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13278
13279 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13280 restorer = ksig->ka.sa.sa_restorer;
13281 + else if (current->mm->context.vdso)
13282 + /* Return stub is in 32bit vsyscall page */
13283 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13284 else
13285 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13286 - rt_sigreturn);
13287 + restorer = &frame->retcode;
13288 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13289
13290 /*
13291 * Not actually used anymore, but left because some gdb
13292 * versions need it.
13293 */
13294 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13295 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13296 } put_user_catch(err);
13297
13298 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13299 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13300 index 474dc1b..9297c58 100644
13301 --- a/arch/x86/ia32/ia32entry.S
13302 +++ b/arch/x86/ia32/ia32entry.S
13303 @@ -15,8 +15,10 @@
13304 #include <asm/irqflags.h>
13305 #include <asm/asm.h>
13306 #include <asm/smap.h>
13307 +#include <asm/pgtable.h>
13308 #include <linux/linkage.h>
13309 #include <linux/err.h>
13310 +#include <asm/alternative-asm.h>
13311
13312 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13313 #include <linux/elf-em.h>
13314 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13315 ENDPROC(native_irq_enable_sysexit)
13316 #endif
13317
13318 + .macro pax_enter_kernel_user
13319 + pax_set_fptr_mask
13320 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13321 + call pax_enter_kernel_user
13322 +#endif
13323 + .endm
13324 +
13325 + .macro pax_exit_kernel_user
13326 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13327 + call pax_exit_kernel_user
13328 +#endif
13329 +#ifdef CONFIG_PAX_RANDKSTACK
13330 + pushq %rax
13331 + pushq %r11
13332 + call pax_randomize_kstack
13333 + popq %r11
13334 + popq %rax
13335 +#endif
13336 + .endm
13337 +
13338 + .macro pax_erase_kstack
13339 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13340 + call pax_erase_kstack
13341 +#endif
13342 + .endm
13343 +
13344 /*
13345 * 32bit SYSENTER instruction entry.
13346 *
13347 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13348 CFI_REGISTER rsp,rbp
13349 SWAPGS_UNSAFE_STACK
13350 movq PER_CPU_VAR(kernel_stack), %rsp
13351 - addq $(KERNEL_STACK_OFFSET),%rsp
13352 - /*
13353 - * No need to follow this irqs on/off section: the syscall
13354 - * disabled irqs, here we enable it straight after entry:
13355 - */
13356 - ENABLE_INTERRUPTS(CLBR_NONE)
13357 movl %ebp,%ebp /* zero extension */
13358 pushq_cfi $__USER32_DS
13359 /*CFI_REL_OFFSET ss,0*/
13360 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13361 CFI_REL_OFFSET rsp,0
13362 pushfq_cfi
13363 /*CFI_REL_OFFSET rflags,0*/
13364 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13365 - CFI_REGISTER rip,r10
13366 + orl $X86_EFLAGS_IF,(%rsp)
13367 + GET_THREAD_INFO(%r11)
13368 + movl TI_sysenter_return(%r11), %r11d
13369 + CFI_REGISTER rip,r11
13370 pushq_cfi $__USER32_CS
13371 /*CFI_REL_OFFSET cs,0*/
13372 movl %eax, %eax
13373 - pushq_cfi %r10
13374 + pushq_cfi %r11
13375 CFI_REL_OFFSET rip,0
13376 pushq_cfi %rax
13377 cld
13378 SAVE_ARGS 0,1,0
13379 + pax_enter_kernel_user
13380 +
13381 +#ifdef CONFIG_PAX_RANDKSTACK
13382 + pax_erase_kstack
13383 +#endif
13384 +
13385 + /*
13386 + * No need to follow this irqs on/off section: the syscall
13387 + * disabled irqs, here we enable it straight after entry:
13388 + */
13389 + ENABLE_INTERRUPTS(CLBR_NONE)
13390 /* no need to do an access_ok check here because rbp has been
13391 32bit zero extended */
13392 +
13393 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13394 + addq pax_user_shadow_base,%rbp
13395 + ASM_PAX_OPEN_USERLAND
13396 +#endif
13397 +
13398 ASM_STAC
13399 1: movl (%rbp),%ebp
13400 _ASM_EXTABLE(1b,ia32_badarg)
13401 ASM_CLAC
13402 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13403 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13404 +
13405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13406 + ASM_PAX_CLOSE_USERLAND
13407 +#endif
13408 +
13409 + GET_THREAD_INFO(%r11)
13410 + orl $TS_COMPAT,TI_status(%r11)
13411 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13412 CFI_REMEMBER_STATE
13413 jnz sysenter_tracesys
13414 cmpq $(IA32_NR_syscalls-1),%rax
13415 @@ -162,12 +209,15 @@ sysenter_do_call:
13416 sysenter_dispatch:
13417 call *ia32_sys_call_table(,%rax,8)
13418 movq %rax,RAX-ARGOFFSET(%rsp)
13419 + GET_THREAD_INFO(%r11)
13420 DISABLE_INTERRUPTS(CLBR_NONE)
13421 TRACE_IRQS_OFF
13422 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13423 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13424 jnz sysexit_audit
13425 sysexit_from_sys_call:
13426 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13427 + pax_exit_kernel_user
13428 + pax_erase_kstack
13429 + andl $~TS_COMPAT,TI_status(%r11)
13430 /* clear IF, that popfq doesn't enable interrupts early */
13431 andl $~0x200,EFLAGS-R11(%rsp)
13432 movl RIP-R11(%rsp),%edx /* User %eip */
13433 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13434 movl %eax,%esi /* 2nd arg: syscall number */
13435 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13436 call __audit_syscall_entry
13437 +
13438 + pax_erase_kstack
13439 +
13440 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13441 cmpq $(IA32_NR_syscalls-1),%rax
13442 ja ia32_badsys
13443 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13444 .endm
13445
13446 .macro auditsys_exit exit
13447 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13448 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13449 jnz ia32_ret_from_sys_call
13450 TRACE_IRQS_ON
13451 ENABLE_INTERRUPTS(CLBR_NONE)
13452 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13453 1: setbe %al /* 1 if error, 0 if not */
13454 movzbl %al,%edi /* zero-extend that into %edi */
13455 call __audit_syscall_exit
13456 + GET_THREAD_INFO(%r11)
13457 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13458 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13459 DISABLE_INTERRUPTS(CLBR_NONE)
13460 TRACE_IRQS_OFF
13461 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13462 + testl %edi,TI_flags(%r11)
13463 jz \exit
13464 CLEAR_RREGS -ARGOFFSET
13465 jmp int_with_check
13466 @@ -237,7 +291,7 @@ sysexit_audit:
13467
13468 sysenter_tracesys:
13469 #ifdef CONFIG_AUDITSYSCALL
13470 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13471 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13472 jz sysenter_auditsys
13473 #endif
13474 SAVE_REST
13475 @@ -249,6 +303,9 @@ sysenter_tracesys:
13476 RESTORE_REST
13477 cmpq $(IA32_NR_syscalls-1),%rax
13478 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13479 +
13480 + pax_erase_kstack
13481 +
13482 jmp sysenter_do_call
13483 CFI_ENDPROC
13484 ENDPROC(ia32_sysenter_target)
13485 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13486 ENTRY(ia32_cstar_target)
13487 CFI_STARTPROC32 simple
13488 CFI_SIGNAL_FRAME
13489 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13490 + CFI_DEF_CFA rsp,0
13491 CFI_REGISTER rip,rcx
13492 /*CFI_REGISTER rflags,r11*/
13493 SWAPGS_UNSAFE_STACK
13494 movl %esp,%r8d
13495 CFI_REGISTER rsp,r8
13496 movq PER_CPU_VAR(kernel_stack),%rsp
13497 + SAVE_ARGS 8*6,0,0
13498 + pax_enter_kernel_user
13499 +
13500 +#ifdef CONFIG_PAX_RANDKSTACK
13501 + pax_erase_kstack
13502 +#endif
13503 +
13504 /*
13505 * No need to follow this irqs on/off section: the syscall
13506 * disabled irqs and here we enable it straight after entry:
13507 */
13508 ENABLE_INTERRUPTS(CLBR_NONE)
13509 - SAVE_ARGS 8,0,0
13510 movl %eax,%eax /* zero extension */
13511 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13512 movq %rcx,RIP-ARGOFFSET(%rsp)
13513 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13514 /* no need to do an access_ok check here because r8 has been
13515 32bit zero extended */
13516 /* hardware stack frame is complete now */
13517 +
13518 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13519 + ASM_PAX_OPEN_USERLAND
13520 + movq pax_user_shadow_base,%r8
13521 + addq RSP-ARGOFFSET(%rsp),%r8
13522 +#endif
13523 +
13524 ASM_STAC
13525 1: movl (%r8),%r9d
13526 _ASM_EXTABLE(1b,ia32_badarg)
13527 ASM_CLAC
13528 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13529 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13530 +
13531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13532 + ASM_PAX_CLOSE_USERLAND
13533 +#endif
13534 +
13535 + GET_THREAD_INFO(%r11)
13536 + orl $TS_COMPAT,TI_status(%r11)
13537 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13538 CFI_REMEMBER_STATE
13539 jnz cstar_tracesys
13540 cmpq $IA32_NR_syscalls-1,%rax
13541 @@ -319,12 +395,15 @@ cstar_do_call:
13542 cstar_dispatch:
13543 call *ia32_sys_call_table(,%rax,8)
13544 movq %rax,RAX-ARGOFFSET(%rsp)
13545 + GET_THREAD_INFO(%r11)
13546 DISABLE_INTERRUPTS(CLBR_NONE)
13547 TRACE_IRQS_OFF
13548 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13549 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13550 jnz sysretl_audit
13551 sysretl_from_sys_call:
13552 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13553 + pax_exit_kernel_user
13554 + pax_erase_kstack
13555 + andl $~TS_COMPAT,TI_status(%r11)
13556 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13557 movl RIP-ARGOFFSET(%rsp),%ecx
13558 CFI_REGISTER rip,rcx
13559 @@ -352,7 +431,7 @@ sysretl_audit:
13560
13561 cstar_tracesys:
13562 #ifdef CONFIG_AUDITSYSCALL
13563 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13564 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13565 jz cstar_auditsys
13566 #endif
13567 xchgl %r9d,%ebp
13568 @@ -366,11 +445,19 @@ cstar_tracesys:
13569 xchgl %ebp,%r9d
13570 cmpq $(IA32_NR_syscalls-1),%rax
13571 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13572 +
13573 + pax_erase_kstack
13574 +
13575 jmp cstar_do_call
13576 END(ia32_cstar_target)
13577
13578 ia32_badarg:
13579 ASM_CLAC
13580 +
13581 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13582 + ASM_PAX_CLOSE_USERLAND
13583 +#endif
13584 +
13585 movq $-EFAULT,%rax
13586 jmp ia32_sysret
13587 CFI_ENDPROC
13588 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13589 CFI_REL_OFFSET rip,RIP-RIP
13590 PARAVIRT_ADJUST_EXCEPTION_FRAME
13591 SWAPGS
13592 - /*
13593 - * No need to follow this irqs on/off section: the syscall
13594 - * disabled irqs and here we enable it straight after entry:
13595 - */
13596 - ENABLE_INTERRUPTS(CLBR_NONE)
13597 movl %eax,%eax
13598 pushq_cfi %rax
13599 cld
13600 /* note the registers are not zero extended to the sf.
13601 this could be a problem. */
13602 SAVE_ARGS 0,1,0
13603 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13604 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13605 + pax_enter_kernel_user
13606 +
13607 +#ifdef CONFIG_PAX_RANDKSTACK
13608 + pax_erase_kstack
13609 +#endif
13610 +
13611 + /*
13612 + * No need to follow this irqs on/off section: the syscall
13613 + * disabled irqs and here we enable it straight after entry:
13614 + */
13615 + ENABLE_INTERRUPTS(CLBR_NONE)
13616 + GET_THREAD_INFO(%r11)
13617 + orl $TS_COMPAT,TI_status(%r11)
13618 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13619 jnz ia32_tracesys
13620 cmpq $(IA32_NR_syscalls-1),%rax
13621 ja ia32_badsys
13622 @@ -442,6 +536,9 @@ ia32_tracesys:
13623 RESTORE_REST
13624 cmpq $(IA32_NR_syscalls-1),%rax
13625 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13626 +
13627 + pax_erase_kstack
13628 +
13629 jmp ia32_do_call
13630 END(ia32_syscall)
13631
13632 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13633 index 8e0ceec..af13504 100644
13634 --- a/arch/x86/ia32/sys_ia32.c
13635 +++ b/arch/x86/ia32/sys_ia32.c
13636 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13637 */
13638 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13639 {
13640 - typeof(ubuf->st_uid) uid = 0;
13641 - typeof(ubuf->st_gid) gid = 0;
13642 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13643 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13644 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13645 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13646 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13647 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13648 index 372231c..a5aa1a1 100644
13649 --- a/arch/x86/include/asm/alternative-asm.h
13650 +++ b/arch/x86/include/asm/alternative-asm.h
13651 @@ -18,6 +18,45 @@
13652 .endm
13653 #endif
13654
13655 +#ifdef KERNEXEC_PLUGIN
13656 + .macro pax_force_retaddr_bts rip=0
13657 + btsq $63,\rip(%rsp)
13658 + .endm
13659 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13660 + .macro pax_force_retaddr rip=0, reload=0
13661 + btsq $63,\rip(%rsp)
13662 + .endm
13663 + .macro pax_force_fptr ptr
13664 + btsq $63,\ptr
13665 + .endm
13666 + .macro pax_set_fptr_mask
13667 + .endm
13668 +#endif
13669 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13670 + .macro pax_force_retaddr rip=0, reload=0
13671 + .if \reload
13672 + pax_set_fptr_mask
13673 + .endif
13674 + orq %r10,\rip(%rsp)
13675 + .endm
13676 + .macro pax_force_fptr ptr
13677 + orq %r10,\ptr
13678 + .endm
13679 + .macro pax_set_fptr_mask
13680 + movabs $0x8000000000000000,%r10
13681 + .endm
13682 +#endif
13683 +#else
13684 + .macro pax_force_retaddr rip=0, reload=0
13685 + .endm
13686 + .macro pax_force_fptr ptr
13687 + .endm
13688 + .macro pax_force_retaddr_bts rip=0
13689 + .endm
13690 + .macro pax_set_fptr_mask
13691 + .endm
13692 +#endif
13693 +
13694 .macro altinstruction_entry orig alt feature orig_len alt_len
13695 .long \orig - .
13696 .long \alt - .
13697 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13698 index 58ed6d9..f1cbe58 100644
13699 --- a/arch/x86/include/asm/alternative.h
13700 +++ b/arch/x86/include/asm/alternative.h
13701 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13702 ".pushsection .discard,\"aw\",@progbits\n" \
13703 DISCARD_ENTRY(1) \
13704 ".popsection\n" \
13705 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13706 + ".pushsection .altinstr_replacement, \"a\"\n" \
13707 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13708 ".popsection"
13709
13710 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13711 DISCARD_ENTRY(1) \
13712 DISCARD_ENTRY(2) \
13713 ".popsection\n" \
13714 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13715 + ".pushsection .altinstr_replacement, \"a\"\n" \
13716 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13717 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13718 ".popsection"
13719 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13720 index f8119b5..7209d5b 100644
13721 --- a/arch/x86/include/asm/apic.h
13722 +++ b/arch/x86/include/asm/apic.h
13723 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13724
13725 #ifdef CONFIG_X86_LOCAL_APIC
13726
13727 -extern unsigned int apic_verbosity;
13728 +extern int apic_verbosity;
13729 extern int local_apic_timer_c2_ok;
13730
13731 extern int disable_apic;
13732 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13733 index 20370c6..a2eb9b0 100644
13734 --- a/arch/x86/include/asm/apm.h
13735 +++ b/arch/x86/include/asm/apm.h
13736 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13737 __asm__ __volatile__(APM_DO_ZERO_SEGS
13738 "pushl %%edi\n\t"
13739 "pushl %%ebp\n\t"
13740 - "lcall *%%cs:apm_bios_entry\n\t"
13741 + "lcall *%%ss:apm_bios_entry\n\t"
13742 "setc %%al\n\t"
13743 "popl %%ebp\n\t"
13744 "popl %%edi\n\t"
13745 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13746 __asm__ __volatile__(APM_DO_ZERO_SEGS
13747 "pushl %%edi\n\t"
13748 "pushl %%ebp\n\t"
13749 - "lcall *%%cs:apm_bios_entry\n\t"
13750 + "lcall *%%ss:apm_bios_entry\n\t"
13751 "setc %%bl\n\t"
13752 "popl %%ebp\n\t"
13753 "popl %%edi\n\t"
13754 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13755 index 722aa3b..3a0bb27 100644
13756 --- a/arch/x86/include/asm/atomic.h
13757 +++ b/arch/x86/include/asm/atomic.h
13758 @@ -22,7 +22,18 @@
13759 */
13760 static inline int atomic_read(const atomic_t *v)
13761 {
13762 - return (*(volatile int *)&(v)->counter);
13763 + return (*(volatile const int *)&(v)->counter);
13764 +}
13765 +
13766 +/**
13767 + * atomic_read_unchecked - read atomic variable
13768 + * @v: pointer of type atomic_unchecked_t
13769 + *
13770 + * Atomically reads the value of @v.
13771 + */
13772 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13773 +{
13774 + return (*(volatile const int *)&(v)->counter);
13775 }
13776
13777 /**
13778 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13779 }
13780
13781 /**
13782 + * atomic_set_unchecked - set atomic variable
13783 + * @v: pointer of type atomic_unchecked_t
13784 + * @i: required value
13785 + *
13786 + * Atomically sets the value of @v to @i.
13787 + */
13788 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13789 +{
13790 + v->counter = i;
13791 +}
13792 +
13793 +/**
13794 * atomic_add - add integer to atomic variable
13795 * @i: integer value to add
13796 * @v: pointer of type atomic_t
13797 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13798 */
13799 static inline void atomic_add(int i, atomic_t *v)
13800 {
13801 - asm volatile(LOCK_PREFIX "addl %1,%0"
13802 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13803 +
13804 +#ifdef CONFIG_PAX_REFCOUNT
13805 + "jno 0f\n"
13806 + LOCK_PREFIX "subl %1,%0\n"
13807 + "int $4\n0:\n"
13808 + _ASM_EXTABLE(0b, 0b)
13809 +#endif
13810 +
13811 + : "+m" (v->counter)
13812 + : "ir" (i));
13813 +}
13814 +
13815 +/**
13816 + * atomic_add_unchecked - add integer to atomic variable
13817 + * @i: integer value to add
13818 + * @v: pointer of type atomic_unchecked_t
13819 + *
13820 + * Atomically adds @i to @v.
13821 + */
13822 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13823 +{
13824 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13825 : "+m" (v->counter)
13826 : "ir" (i));
13827 }
13828 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13829 */
13830 static inline void atomic_sub(int i, atomic_t *v)
13831 {
13832 - asm volatile(LOCK_PREFIX "subl %1,%0"
13833 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13834 +
13835 +#ifdef CONFIG_PAX_REFCOUNT
13836 + "jno 0f\n"
13837 + LOCK_PREFIX "addl %1,%0\n"
13838 + "int $4\n0:\n"
13839 + _ASM_EXTABLE(0b, 0b)
13840 +#endif
13841 +
13842 + : "+m" (v->counter)
13843 + : "ir" (i));
13844 +}
13845 +
13846 +/**
13847 + * atomic_sub_unchecked - subtract integer from atomic variable
13848 + * @i: integer value to subtract
13849 + * @v: pointer of type atomic_unchecked_t
13850 + *
13851 + * Atomically subtracts @i from @v.
13852 + */
13853 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13854 +{
13855 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13856 : "+m" (v->counter)
13857 : "ir" (i));
13858 }
13859 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13860 {
13861 unsigned char c;
13862
13863 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13864 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13865 +
13866 +#ifdef CONFIG_PAX_REFCOUNT
13867 + "jno 0f\n"
13868 + LOCK_PREFIX "addl %2,%0\n"
13869 + "int $4\n0:\n"
13870 + _ASM_EXTABLE(0b, 0b)
13871 +#endif
13872 +
13873 + "sete %1\n"
13874 : "+m" (v->counter), "=qm" (c)
13875 : "ir" (i) : "memory");
13876 return c;
13877 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13878 */
13879 static inline void atomic_inc(atomic_t *v)
13880 {
13881 - asm volatile(LOCK_PREFIX "incl %0"
13882 + asm volatile(LOCK_PREFIX "incl %0\n"
13883 +
13884 +#ifdef CONFIG_PAX_REFCOUNT
13885 + "jno 0f\n"
13886 + LOCK_PREFIX "decl %0\n"
13887 + "int $4\n0:\n"
13888 + _ASM_EXTABLE(0b, 0b)
13889 +#endif
13890 +
13891 + : "+m" (v->counter));
13892 +}
13893 +
13894 +/**
13895 + * atomic_inc_unchecked - increment atomic variable
13896 + * @v: pointer of type atomic_unchecked_t
13897 + *
13898 + * Atomically increments @v by 1.
13899 + */
13900 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13901 +{
13902 + asm volatile(LOCK_PREFIX "incl %0\n"
13903 : "+m" (v->counter));
13904 }
13905
13906 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13907 */
13908 static inline void atomic_dec(atomic_t *v)
13909 {
13910 - asm volatile(LOCK_PREFIX "decl %0"
13911 + asm volatile(LOCK_PREFIX "decl %0\n"
13912 +
13913 +#ifdef CONFIG_PAX_REFCOUNT
13914 + "jno 0f\n"
13915 + LOCK_PREFIX "incl %0\n"
13916 + "int $4\n0:\n"
13917 + _ASM_EXTABLE(0b, 0b)
13918 +#endif
13919 +
13920 + : "+m" (v->counter));
13921 +}
13922 +
13923 +/**
13924 + * atomic_dec_unchecked - decrement atomic variable
13925 + * @v: pointer of type atomic_unchecked_t
13926 + *
13927 + * Atomically decrements @v by 1.
13928 + */
13929 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13930 +{
13931 + asm volatile(LOCK_PREFIX "decl %0\n"
13932 : "+m" (v->counter));
13933 }
13934
13935 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13936 {
13937 unsigned char c;
13938
13939 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13940 + asm volatile(LOCK_PREFIX "decl %0\n"
13941 +
13942 +#ifdef CONFIG_PAX_REFCOUNT
13943 + "jno 0f\n"
13944 + LOCK_PREFIX "incl %0\n"
13945 + "int $4\n0:\n"
13946 + _ASM_EXTABLE(0b, 0b)
13947 +#endif
13948 +
13949 + "sete %1\n"
13950 : "+m" (v->counter), "=qm" (c)
13951 : : "memory");
13952 return c != 0;
13953 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13954 {
13955 unsigned char c;
13956
13957 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13958 + asm volatile(LOCK_PREFIX "incl %0\n"
13959 +
13960 +#ifdef CONFIG_PAX_REFCOUNT
13961 + "jno 0f\n"
13962 + LOCK_PREFIX "decl %0\n"
13963 + "int $4\n0:\n"
13964 + _ASM_EXTABLE(0b, 0b)
13965 +#endif
13966 +
13967 + "sete %1\n"
13968 + : "+m" (v->counter), "=qm" (c)
13969 + : : "memory");
13970 + return c != 0;
13971 +}
13972 +
13973 +/**
13974 + * atomic_inc_and_test_unchecked - increment and test
13975 + * @v: pointer of type atomic_unchecked_t
13976 + *
13977 + * Atomically increments @v by 1
13978 + * and returns true if the result is zero, or false for all
13979 + * other cases.
13980 + */
13981 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
13982 +{
13983 + unsigned char c;
13984 +
13985 + asm volatile(LOCK_PREFIX "incl %0\n"
13986 + "sete %1\n"
13987 : "+m" (v->counter), "=qm" (c)
13988 : : "memory");
13989 return c != 0;
13990 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13991 {
13992 unsigned char c;
13993
13994 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
13995 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
13996 +
13997 +#ifdef CONFIG_PAX_REFCOUNT
13998 + "jno 0f\n"
13999 + LOCK_PREFIX "subl %2,%0\n"
14000 + "int $4\n0:\n"
14001 + _ASM_EXTABLE(0b, 0b)
14002 +#endif
14003 +
14004 + "sets %1\n"
14005 : "+m" (v->counter), "=qm" (c)
14006 : "ir" (i) : "memory");
14007 return c;
14008 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14009 */
14010 static inline int atomic_add_return(int i, atomic_t *v)
14011 {
14012 + return i + xadd_check_overflow(&v->counter, i);
14013 +}
14014 +
14015 +/**
14016 + * atomic_add_return_unchecked - add integer and return
14017 + * @i: integer value to add
14018 + * @v: pointer of type atomic_unchecked_t
14019 + *
14020 + * Atomically adds @i to @v and returns @i + @v
14021 + */
14022 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14023 +{
14024 return i + xadd(&v->counter, i);
14025 }
14026
14027 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14028 }
14029
14030 #define atomic_inc_return(v) (atomic_add_return(1, v))
14031 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14032 +{
14033 + return atomic_add_return_unchecked(1, v);
14034 +}
14035 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14036
14037 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14038 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14039 return cmpxchg(&v->counter, old, new);
14040 }
14041
14042 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14043 +{
14044 + return cmpxchg(&v->counter, old, new);
14045 +}
14046 +
14047 static inline int atomic_xchg(atomic_t *v, int new)
14048 {
14049 return xchg(&v->counter, new);
14050 }
14051
14052 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14053 +{
14054 + return xchg(&v->counter, new);
14055 +}
14056 +
14057 /**
14058 * __atomic_add_unless - add unless the number is already a given value
14059 * @v: pointer of type atomic_t
14060 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14061 */
14062 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14063 {
14064 - int c, old;
14065 + int c, old, new;
14066 c = atomic_read(v);
14067 for (;;) {
14068 - if (unlikely(c == (u)))
14069 + if (unlikely(c == u))
14070 break;
14071 - old = atomic_cmpxchg((v), c, c + (a));
14072 +
14073 + asm volatile("addl %2,%0\n"
14074 +
14075 +#ifdef CONFIG_PAX_REFCOUNT
14076 + "jno 0f\n"
14077 + "subl %2,%0\n"
14078 + "int $4\n0:\n"
14079 + _ASM_EXTABLE(0b, 0b)
14080 +#endif
14081 +
14082 + : "=r" (new)
14083 + : "0" (c), "ir" (a));
14084 +
14085 + old = atomic_cmpxchg(v, c, new);
14086 if (likely(old == c))
14087 break;
14088 c = old;
14089 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14090 }
14091
14092 /**
14093 + * atomic_inc_not_zero_hint - increment if not null
14094 + * @v: pointer of type atomic_t
14095 + * @hint: probable value of the atomic before the increment
14096 + *
14097 + * This version of atomic_inc_not_zero() gives a hint of probable
14098 + * value of the atomic. This helps processor to not read the memory
14099 + * before doing the atomic read/modify/write cycle, lowering
14100 + * number of bus transactions on some arches.
14101 + *
14102 + * Returns: 0 if increment was not done, 1 otherwise.
14103 + */
14104 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14105 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14106 +{
14107 + int val, c = hint, new;
14108 +
14109 + /* sanity test, should be removed by compiler if hint is a constant */
14110 + if (!hint)
14111 + return __atomic_add_unless(v, 1, 0);
14112 +
14113 + do {
14114 + asm volatile("incl %0\n"
14115 +
14116 +#ifdef CONFIG_PAX_REFCOUNT
14117 + "jno 0f\n"
14118 + "decl %0\n"
14119 + "int $4\n0:\n"
14120 + _ASM_EXTABLE(0b, 0b)
14121 +#endif
14122 +
14123 + : "=r" (new)
14124 + : "0" (c));
14125 +
14126 + val = atomic_cmpxchg(v, c, new);
14127 + if (val == c)
14128 + return 1;
14129 + c = val;
14130 + } while (c);
14131 +
14132 + return 0;
14133 +}
14134 +
14135 +/**
14136 * atomic_inc_short - increment of a short integer
14137 * @v: pointer to type int
14138 *
14139 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14140 #endif
14141
14142 /* These are x86-specific, used by some header files */
14143 -#define atomic_clear_mask(mask, addr) \
14144 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14145 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14146 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14147 +{
14148 + asm volatile(LOCK_PREFIX "andl %1,%0"
14149 + : "+m" (v->counter)
14150 + : "r" (~(mask))
14151 + : "memory");
14152 +}
14153
14154 -#define atomic_set_mask(mask, addr) \
14155 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14156 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14157 - : "memory")
14158 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14159 +{
14160 + asm volatile(LOCK_PREFIX "andl %1,%0"
14161 + : "+m" (v->counter)
14162 + : "r" (~(mask))
14163 + : "memory");
14164 +}
14165 +
14166 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14167 +{
14168 + asm volatile(LOCK_PREFIX "orl %1,%0"
14169 + : "+m" (v->counter)
14170 + : "r" (mask)
14171 + : "memory");
14172 +}
14173 +
14174 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14175 +{
14176 + asm volatile(LOCK_PREFIX "orl %1,%0"
14177 + : "+m" (v->counter)
14178 + : "r" (mask)
14179 + : "memory");
14180 +}
14181
14182 /* Atomic operations are already serializing on x86 */
14183 #define smp_mb__before_atomic_dec() barrier()
14184 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14185 index b154de7..aadebd8 100644
14186 --- a/arch/x86/include/asm/atomic64_32.h
14187 +++ b/arch/x86/include/asm/atomic64_32.h
14188 @@ -12,6 +12,14 @@ typedef struct {
14189 u64 __aligned(8) counter;
14190 } atomic64_t;
14191
14192 +#ifdef CONFIG_PAX_REFCOUNT
14193 +typedef struct {
14194 + u64 __aligned(8) counter;
14195 +} atomic64_unchecked_t;
14196 +#else
14197 +typedef atomic64_t atomic64_unchecked_t;
14198 +#endif
14199 +
14200 #define ATOMIC64_INIT(val) { (val) }
14201
14202 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14203 @@ -37,21 +45,31 @@ typedef struct {
14204 ATOMIC64_DECL_ONE(sym##_386)
14205
14206 ATOMIC64_DECL_ONE(add_386);
14207 +ATOMIC64_DECL_ONE(add_unchecked_386);
14208 ATOMIC64_DECL_ONE(sub_386);
14209 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14210 ATOMIC64_DECL_ONE(inc_386);
14211 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14212 ATOMIC64_DECL_ONE(dec_386);
14213 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14214 #endif
14215
14216 #define alternative_atomic64(f, out, in...) \
14217 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14218
14219 ATOMIC64_DECL(read);
14220 +ATOMIC64_DECL(read_unchecked);
14221 ATOMIC64_DECL(set);
14222 +ATOMIC64_DECL(set_unchecked);
14223 ATOMIC64_DECL(xchg);
14224 ATOMIC64_DECL(add_return);
14225 +ATOMIC64_DECL(add_return_unchecked);
14226 ATOMIC64_DECL(sub_return);
14227 +ATOMIC64_DECL(sub_return_unchecked);
14228 ATOMIC64_DECL(inc_return);
14229 +ATOMIC64_DECL(inc_return_unchecked);
14230 ATOMIC64_DECL(dec_return);
14231 +ATOMIC64_DECL(dec_return_unchecked);
14232 ATOMIC64_DECL(dec_if_positive);
14233 ATOMIC64_DECL(inc_not_zero);
14234 ATOMIC64_DECL(add_unless);
14235 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14236 }
14237
14238 /**
14239 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14240 + * @p: pointer to type atomic64_unchecked_t
14241 + * @o: expected value
14242 + * @n: new value
14243 + *
14244 + * Atomically sets @v to @n if it was equal to @o and returns
14245 + * the old value.
14246 + */
14247 +
14248 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14249 +{
14250 + return cmpxchg64(&v->counter, o, n);
14251 +}
14252 +
14253 +/**
14254 * atomic64_xchg - xchg atomic64 variable
14255 * @v: pointer to type atomic64_t
14256 * @n: value to assign
14257 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14258 }
14259
14260 /**
14261 + * atomic64_set_unchecked - set atomic64 variable
14262 + * @v: pointer to type atomic64_unchecked_t
14263 + * @n: value to assign
14264 + *
14265 + * Atomically sets the value of @v to @n.
14266 + */
14267 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14268 +{
14269 + unsigned high = (unsigned)(i >> 32);
14270 + unsigned low = (unsigned)i;
14271 + alternative_atomic64(set, /* no output */,
14272 + "S" (v), "b" (low), "c" (high)
14273 + : "eax", "edx", "memory");
14274 +}
14275 +
14276 +/**
14277 * atomic64_read - read atomic64 variable
14278 * @v: pointer to type atomic64_t
14279 *
14280 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14281 }
14282
14283 /**
14284 + * atomic64_read_unchecked - read atomic64 variable
14285 + * @v: pointer to type atomic64_unchecked_t
14286 + *
14287 + * Atomically reads the value of @v and returns it.
14288 + */
14289 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14290 +{
14291 + long long r;
14292 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14293 + return r;
14294 + }
14295 +
14296 +/**
14297 * atomic64_add_return - add and return
14298 * @i: integer value to add
14299 * @v: pointer to type atomic64_t
14300 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14301 return i;
14302 }
14303
14304 +/**
14305 + * atomic64_add_return_unchecked - add and return
14306 + * @i: integer value to add
14307 + * @v: pointer to type atomic64_unchecked_t
14308 + *
14309 + * Atomically adds @i to @v and returns @i + *@v
14310 + */
14311 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14312 +{
14313 + alternative_atomic64(add_return_unchecked,
14314 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14315 + ASM_NO_INPUT_CLOBBER("memory"));
14316 + return i;
14317 +}
14318 +
14319 /*
14320 * Other variants with different arithmetic operators:
14321 */
14322 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14323 return a;
14324 }
14325
14326 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14327 +{
14328 + long long a;
14329 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14330 + "S" (v) : "memory", "ecx");
14331 + return a;
14332 +}
14333 +
14334 static inline long long atomic64_dec_return(atomic64_t *v)
14335 {
14336 long long a;
14337 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14338 }
14339
14340 /**
14341 + * atomic64_add_unchecked - add integer to atomic64 variable
14342 + * @i: integer value to add
14343 + * @v: pointer to type atomic64_unchecked_t
14344 + *
14345 + * Atomically adds @i to @v.
14346 + */
14347 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14348 +{
14349 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14350 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14351 + ASM_NO_INPUT_CLOBBER("memory"));
14352 + return i;
14353 +}
14354 +
14355 +/**
14356 * atomic64_sub - subtract the atomic64 variable
14357 * @i: integer value to subtract
14358 * @v: pointer to type atomic64_t
14359 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14360 index 0e1cbfc..5623683 100644
14361 --- a/arch/x86/include/asm/atomic64_64.h
14362 +++ b/arch/x86/include/asm/atomic64_64.h
14363 @@ -18,7 +18,19 @@
14364 */
14365 static inline long atomic64_read(const atomic64_t *v)
14366 {
14367 - return (*(volatile long *)&(v)->counter);
14368 + return (*(volatile const long *)&(v)->counter);
14369 +}
14370 +
14371 +/**
14372 + * atomic64_read_unchecked - read atomic64 variable
14373 + * @v: pointer of type atomic64_unchecked_t
14374 + *
14375 + * Atomically reads the value of @v.
14376 + * Doesn't imply a read memory barrier.
14377 + */
14378 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14379 +{
14380 + return (*(volatile const long *)&(v)->counter);
14381 }
14382
14383 /**
14384 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14385 }
14386
14387 /**
14388 + * atomic64_set_unchecked - set atomic64 variable
14389 + * @v: pointer to type atomic64_unchecked_t
14390 + * @i: required value
14391 + *
14392 + * Atomically sets the value of @v to @i.
14393 + */
14394 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14395 +{
14396 + v->counter = i;
14397 +}
14398 +
14399 +/**
14400 * atomic64_add - add integer to atomic64 variable
14401 * @i: integer value to add
14402 * @v: pointer to type atomic64_t
14403 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14404 */
14405 static inline void atomic64_add(long i, atomic64_t *v)
14406 {
14407 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14408 +
14409 +#ifdef CONFIG_PAX_REFCOUNT
14410 + "jno 0f\n"
14411 + LOCK_PREFIX "subq %1,%0\n"
14412 + "int $4\n0:\n"
14413 + _ASM_EXTABLE(0b, 0b)
14414 +#endif
14415 +
14416 + : "=m" (v->counter)
14417 + : "er" (i), "m" (v->counter));
14418 +}
14419 +
14420 +/**
14421 + * atomic64_add_unchecked - add integer to atomic64 variable
14422 + * @i: integer value to add
14423 + * @v: pointer to type atomic64_unchecked_t
14424 + *
14425 + * Atomically adds @i to @v.
14426 + */
14427 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14428 +{
14429 asm volatile(LOCK_PREFIX "addq %1,%0"
14430 : "=m" (v->counter)
14431 : "er" (i), "m" (v->counter));
14432 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14433 */
14434 static inline void atomic64_sub(long i, atomic64_t *v)
14435 {
14436 - asm volatile(LOCK_PREFIX "subq %1,%0"
14437 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14438 +
14439 +#ifdef CONFIG_PAX_REFCOUNT
14440 + "jno 0f\n"
14441 + LOCK_PREFIX "addq %1,%0\n"
14442 + "int $4\n0:\n"
14443 + _ASM_EXTABLE(0b, 0b)
14444 +#endif
14445 +
14446 + : "=m" (v->counter)
14447 + : "er" (i), "m" (v->counter));
14448 +}
14449 +
14450 +/**
14451 + * atomic64_sub_unchecked - subtract the atomic64 variable
14452 + * @i: integer value to subtract
14453 + * @v: pointer to type atomic64_unchecked_t
14454 + *
14455 + * Atomically subtracts @i from @v.
14456 + */
14457 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14458 +{
14459 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14460 : "=m" (v->counter)
14461 : "er" (i), "m" (v->counter));
14462 }
14463 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14464 {
14465 unsigned char c;
14466
14467 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14468 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14469 +
14470 +#ifdef CONFIG_PAX_REFCOUNT
14471 + "jno 0f\n"
14472 + LOCK_PREFIX "addq %2,%0\n"
14473 + "int $4\n0:\n"
14474 + _ASM_EXTABLE(0b, 0b)
14475 +#endif
14476 +
14477 + "sete %1\n"
14478 : "=m" (v->counter), "=qm" (c)
14479 : "er" (i), "m" (v->counter) : "memory");
14480 return c;
14481 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14482 */
14483 static inline void atomic64_inc(atomic64_t *v)
14484 {
14485 + asm volatile(LOCK_PREFIX "incq %0\n"
14486 +
14487 +#ifdef CONFIG_PAX_REFCOUNT
14488 + "jno 0f\n"
14489 + LOCK_PREFIX "decq %0\n"
14490 + "int $4\n0:\n"
14491 + _ASM_EXTABLE(0b, 0b)
14492 +#endif
14493 +
14494 + : "=m" (v->counter)
14495 + : "m" (v->counter));
14496 +}
14497 +
14498 +/**
14499 + * atomic64_inc_unchecked - increment atomic64 variable
14500 + * @v: pointer to type atomic64_unchecked_t
14501 + *
14502 + * Atomically increments @v by 1.
14503 + */
14504 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14505 +{
14506 asm volatile(LOCK_PREFIX "incq %0"
14507 : "=m" (v->counter)
14508 : "m" (v->counter));
14509 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14510 */
14511 static inline void atomic64_dec(atomic64_t *v)
14512 {
14513 - asm volatile(LOCK_PREFIX "decq %0"
14514 + asm volatile(LOCK_PREFIX "decq %0\n"
14515 +
14516 +#ifdef CONFIG_PAX_REFCOUNT
14517 + "jno 0f\n"
14518 + LOCK_PREFIX "incq %0\n"
14519 + "int $4\n0:\n"
14520 + _ASM_EXTABLE(0b, 0b)
14521 +#endif
14522 +
14523 + : "=m" (v->counter)
14524 + : "m" (v->counter));
14525 +}
14526 +
14527 +/**
14528 + * atomic64_dec_unchecked - decrement atomic64 variable
14529 + * @v: pointer to type atomic64_t
14530 + *
14531 + * Atomically decrements @v by 1.
14532 + */
14533 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14534 +{
14535 + asm volatile(LOCK_PREFIX "decq %0\n"
14536 : "=m" (v->counter)
14537 : "m" (v->counter));
14538 }
14539 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14540 {
14541 unsigned char c;
14542
14543 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14544 + asm volatile(LOCK_PREFIX "decq %0\n"
14545 +
14546 +#ifdef CONFIG_PAX_REFCOUNT
14547 + "jno 0f\n"
14548 + LOCK_PREFIX "incq %0\n"
14549 + "int $4\n0:\n"
14550 + _ASM_EXTABLE(0b, 0b)
14551 +#endif
14552 +
14553 + "sete %1\n"
14554 : "=m" (v->counter), "=qm" (c)
14555 : "m" (v->counter) : "memory");
14556 return c != 0;
14557 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14558 {
14559 unsigned char c;
14560
14561 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14562 + asm volatile(LOCK_PREFIX "incq %0\n"
14563 +
14564 +#ifdef CONFIG_PAX_REFCOUNT
14565 + "jno 0f\n"
14566 + LOCK_PREFIX "decq %0\n"
14567 + "int $4\n0:\n"
14568 + _ASM_EXTABLE(0b, 0b)
14569 +#endif
14570 +
14571 + "sete %1\n"
14572 : "=m" (v->counter), "=qm" (c)
14573 : "m" (v->counter) : "memory");
14574 return c != 0;
14575 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14576 {
14577 unsigned char c;
14578
14579 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14580 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14581 +
14582 +#ifdef CONFIG_PAX_REFCOUNT
14583 + "jno 0f\n"
14584 + LOCK_PREFIX "subq %2,%0\n"
14585 + "int $4\n0:\n"
14586 + _ASM_EXTABLE(0b, 0b)
14587 +#endif
14588 +
14589 + "sets %1\n"
14590 : "=m" (v->counter), "=qm" (c)
14591 : "er" (i), "m" (v->counter) : "memory");
14592 return c;
14593 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14594 */
14595 static inline long atomic64_add_return(long i, atomic64_t *v)
14596 {
14597 + return i + xadd_check_overflow(&v->counter, i);
14598 +}
14599 +
14600 +/**
14601 + * atomic64_add_return_unchecked - add and return
14602 + * @i: integer value to add
14603 + * @v: pointer to type atomic64_unchecked_t
14604 + *
14605 + * Atomically adds @i to @v and returns @i + @v
14606 + */
14607 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14608 +{
14609 return i + xadd(&v->counter, i);
14610 }
14611
14612 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14613 }
14614
14615 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14616 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14617 +{
14618 + return atomic64_add_return_unchecked(1, v);
14619 +}
14620 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14621
14622 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14623 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14624 return cmpxchg(&v->counter, old, new);
14625 }
14626
14627 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14628 +{
14629 + return cmpxchg(&v->counter, old, new);
14630 +}
14631 +
14632 static inline long atomic64_xchg(atomic64_t *v, long new)
14633 {
14634 return xchg(&v->counter, new);
14635 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14636 */
14637 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14638 {
14639 - long c, old;
14640 + long c, old, new;
14641 c = atomic64_read(v);
14642 for (;;) {
14643 - if (unlikely(c == (u)))
14644 + if (unlikely(c == u))
14645 break;
14646 - old = atomic64_cmpxchg((v), c, c + (a));
14647 +
14648 + asm volatile("add %2,%0\n"
14649 +
14650 +#ifdef CONFIG_PAX_REFCOUNT
14651 + "jno 0f\n"
14652 + "sub %2,%0\n"
14653 + "int $4\n0:\n"
14654 + _ASM_EXTABLE(0b, 0b)
14655 +#endif
14656 +
14657 + : "=r" (new)
14658 + : "0" (c), "ir" (a));
14659 +
14660 + old = atomic64_cmpxchg(v, c, new);
14661 if (likely(old == c))
14662 break;
14663 c = old;
14664 }
14665 - return c != (u);
14666 + return c != u;
14667 }
14668
14669 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14670 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14671 index 6dfd019..28e188d 100644
14672 --- a/arch/x86/include/asm/bitops.h
14673 +++ b/arch/x86/include/asm/bitops.h
14674 @@ -40,7 +40,7 @@
14675 * a mask operation on a byte.
14676 */
14677 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14678 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14679 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14680 #define CONST_MASK(nr) (1 << ((nr) & 7))
14681
14682 /**
14683 @@ -486,7 +486,7 @@ static inline int fls(int x)
14684 * at position 64.
14685 */
14686 #ifdef CONFIG_X86_64
14687 -static __always_inline int fls64(__u64 x)
14688 +static __always_inline long fls64(__u64 x)
14689 {
14690 int bitpos = -1;
14691 /*
14692 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14693 index 4fa687a..60f2d39 100644
14694 --- a/arch/x86/include/asm/boot.h
14695 +++ b/arch/x86/include/asm/boot.h
14696 @@ -6,10 +6,15 @@
14697 #include <uapi/asm/boot.h>
14698
14699 /* Physical address where kernel should be loaded. */
14700 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14701 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14702 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14703 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14704
14705 +#ifndef __ASSEMBLY__
14706 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14707 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14708 +#endif
14709 +
14710 /* Minimum kernel alignment, as a power of two */
14711 #ifdef CONFIG_X86_64
14712 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14713 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14714 index 48f99f1..d78ebf9 100644
14715 --- a/arch/x86/include/asm/cache.h
14716 +++ b/arch/x86/include/asm/cache.h
14717 @@ -5,12 +5,13 @@
14718
14719 /* L1 cache line size */
14720 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14721 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14722 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14723
14724 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14725 +#define __read_only __attribute__((__section__(".data..read_only")))
14726
14727 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14728 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14729 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14730
14731 #ifdef CONFIG_X86_VSMP
14732 #ifdef CONFIG_SMP
14733 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14734 index 9863ee3..4a1f8e1 100644
14735 --- a/arch/x86/include/asm/cacheflush.h
14736 +++ b/arch/x86/include/asm/cacheflush.h
14737 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14738 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14739
14740 if (pg_flags == _PGMT_DEFAULT)
14741 - return -1;
14742 + return ~0UL;
14743 else if (pg_flags == _PGMT_WC)
14744 return _PAGE_CACHE_WC;
14745 else if (pg_flags == _PGMT_UC_MINUS)
14746 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14747 index f50de69..2b0a458 100644
14748 --- a/arch/x86/include/asm/checksum_32.h
14749 +++ b/arch/x86/include/asm/checksum_32.h
14750 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14751 int len, __wsum sum,
14752 int *src_err_ptr, int *dst_err_ptr);
14753
14754 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14755 + int len, __wsum sum,
14756 + int *src_err_ptr, int *dst_err_ptr);
14757 +
14758 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14759 + int len, __wsum sum,
14760 + int *src_err_ptr, int *dst_err_ptr);
14761 +
14762 /*
14763 * Note: when you get a NULL pointer exception here this means someone
14764 * passed in an incorrect kernel address to one of these functions.
14765 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14766
14767 might_sleep();
14768 stac();
14769 - ret = csum_partial_copy_generic((__force void *)src, dst,
14770 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14771 len, sum, err_ptr, NULL);
14772 clac();
14773
14774 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14775 might_sleep();
14776 if (access_ok(VERIFY_WRITE, dst, len)) {
14777 stac();
14778 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14779 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14780 len, sum, NULL, err_ptr);
14781 clac();
14782 return ret;
14783 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14784 index d47786a..ce1b05d 100644
14785 --- a/arch/x86/include/asm/cmpxchg.h
14786 +++ b/arch/x86/include/asm/cmpxchg.h
14787 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14788 __compiletime_error("Bad argument size for cmpxchg");
14789 extern void __xadd_wrong_size(void)
14790 __compiletime_error("Bad argument size for xadd");
14791 +extern void __xadd_check_overflow_wrong_size(void)
14792 + __compiletime_error("Bad argument size for xadd_check_overflow");
14793 extern void __add_wrong_size(void)
14794 __compiletime_error("Bad argument size for add");
14795 +extern void __add_check_overflow_wrong_size(void)
14796 + __compiletime_error("Bad argument size for add_check_overflow");
14797
14798 /*
14799 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14800 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14801 __ret; \
14802 })
14803
14804 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14805 + ({ \
14806 + __typeof__ (*(ptr)) __ret = (arg); \
14807 + switch (sizeof(*(ptr))) { \
14808 + case __X86_CASE_L: \
14809 + asm volatile (lock #op "l %0, %1\n" \
14810 + "jno 0f\n" \
14811 + "mov %0,%1\n" \
14812 + "int $4\n0:\n" \
14813 + _ASM_EXTABLE(0b, 0b) \
14814 + : "+r" (__ret), "+m" (*(ptr)) \
14815 + : : "memory", "cc"); \
14816 + break; \
14817 + case __X86_CASE_Q: \
14818 + asm volatile (lock #op "q %q0, %1\n" \
14819 + "jno 0f\n" \
14820 + "mov %0,%1\n" \
14821 + "int $4\n0:\n" \
14822 + _ASM_EXTABLE(0b, 0b) \
14823 + : "+r" (__ret), "+m" (*(ptr)) \
14824 + : : "memory", "cc"); \
14825 + break; \
14826 + default: \
14827 + __ ## op ## _check_overflow_wrong_size(); \
14828 + } \
14829 + __ret; \
14830 + })
14831 +
14832 /*
14833 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14834 * Since this is generally used to protect other memory information, we
14835 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14836 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14837 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14838
14839 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14840 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14841 +
14842 #define __add(ptr, inc, lock) \
14843 ({ \
14844 __typeof__ (*(ptr)) __ret = (inc); \
14845 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14846 index 59c6c40..5e0b22c 100644
14847 --- a/arch/x86/include/asm/compat.h
14848 +++ b/arch/x86/include/asm/compat.h
14849 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14850 typedef u32 compat_uint_t;
14851 typedef u32 compat_ulong_t;
14852 typedef u64 __attribute__((aligned(4))) compat_u64;
14853 -typedef u32 compat_uptr_t;
14854 +typedef u32 __user compat_uptr_t;
14855
14856 struct compat_timespec {
14857 compat_time_t tv_sec;
14858 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14859 index 7290585..717e89e 100644
14860 --- a/arch/x86/include/asm/cpufeature.h
14861 +++ b/arch/x86/include/asm/cpufeature.h
14862 @@ -203,7 +203,7 @@
14863 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14864 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14865 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14866 -
14867 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14868
14869 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14870 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14871 @@ -211,7 +211,7 @@
14872 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14873 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14874 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14875 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14876 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14877 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14878 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14879 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14880 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14881 #undef cpu_has_centaur_mcr
14882 #define cpu_has_centaur_mcr 0
14883
14884 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14885 #endif /* CONFIG_X86_64 */
14886
14887 #if __GNUC__ >= 4
14888 @@ -403,7 +404,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14889
14890 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14891 t_warn:
14892 - warn_pre_alternatives();
14893 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14894 + warn_pre_alternatives();
14895 return false;
14896 #endif
14897 #else /* GCC_VERSION >= 40500 */
14898 @@ -421,7 +423,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14899 ".section .discard,\"aw\",@progbits\n"
14900 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14901 ".previous\n"
14902 - ".section .altinstr_replacement,\"ax\"\n"
14903 + ".section .altinstr_replacement,\"a\"\n"
14904 "3: movb $1,%0\n"
14905 "4:\n"
14906 ".previous\n"
14907 @@ -457,7 +459,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14908 " .byte 2b - 1b\n" /* src len */
14909 " .byte 4f - 3f\n" /* repl len */
14910 ".previous\n"
14911 - ".section .altinstr_replacement,\"ax\"\n"
14912 + ".section .altinstr_replacement,\"a\"\n"
14913 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14914 "4:\n"
14915 ".previous\n"
14916 @@ -490,7 +492,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14917 ".section .discard,\"aw\",@progbits\n"
14918 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14919 ".previous\n"
14920 - ".section .altinstr_replacement,\"ax\"\n"
14921 + ".section .altinstr_replacement,\"a\"\n"
14922 "3: movb $0,%0\n"
14923 "4:\n"
14924 ".previous\n"
14925 @@ -504,7 +506,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14926 ".section .discard,\"aw\",@progbits\n"
14927 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14928 ".previous\n"
14929 - ".section .altinstr_replacement,\"ax\"\n"
14930 + ".section .altinstr_replacement,\"a\"\n"
14931 "5: movb $1,%0\n"
14932 "6:\n"
14933 ".previous\n"
14934 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14935 index b90e5df..b462c91 100644
14936 --- a/arch/x86/include/asm/desc.h
14937 +++ b/arch/x86/include/asm/desc.h
14938 @@ -4,6 +4,7 @@
14939 #include <asm/desc_defs.h>
14940 #include <asm/ldt.h>
14941 #include <asm/mmu.h>
14942 +#include <asm/pgtable.h>
14943
14944 #include <linux/smp.h>
14945 #include <linux/percpu.h>
14946 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14947
14948 desc->type = (info->read_exec_only ^ 1) << 1;
14949 desc->type |= info->contents << 2;
14950 + desc->type |= info->seg_not_present ^ 1;
14951
14952 desc->s = 1;
14953 desc->dpl = 0x3;
14954 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14955 }
14956
14957 extern struct desc_ptr idt_descr;
14958 -extern gate_desc idt_table[];
14959 -extern struct desc_ptr debug_idt_descr;
14960 -extern gate_desc debug_idt_table[];
14961 -
14962 -struct gdt_page {
14963 - struct desc_struct gdt[GDT_ENTRIES];
14964 -} __attribute__((aligned(PAGE_SIZE)));
14965 -
14966 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14967 +extern gate_desc idt_table[IDT_ENTRIES];
14968 +extern const struct desc_ptr debug_idt_descr;
14969 +extern gate_desc debug_idt_table[IDT_ENTRIES];
14970
14971 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14972 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14973 {
14974 - return per_cpu(gdt_page, cpu).gdt;
14975 + return cpu_gdt_table[cpu];
14976 }
14977
14978 #ifdef CONFIG_X86_64
14979 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
14980 unsigned long base, unsigned dpl, unsigned flags,
14981 unsigned short seg)
14982 {
14983 - gate->a = (seg << 16) | (base & 0xffff);
14984 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
14985 + gate->gate.offset_low = base;
14986 + gate->gate.seg = seg;
14987 + gate->gate.reserved = 0;
14988 + gate->gate.type = type;
14989 + gate->gate.s = 0;
14990 + gate->gate.dpl = dpl;
14991 + gate->gate.p = 1;
14992 + gate->gate.offset_high = base >> 16;
14993 }
14994
14995 #endif
14996 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
14997
14998 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
14999 {
15000 + pax_open_kernel();
15001 memcpy(&idt[entry], gate, sizeof(*gate));
15002 + pax_close_kernel();
15003 }
15004
15005 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15006 {
15007 + pax_open_kernel();
15008 memcpy(&ldt[entry], desc, 8);
15009 + pax_close_kernel();
15010 }
15011
15012 static inline void
15013 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15014 default: size = sizeof(*gdt); break;
15015 }
15016
15017 + pax_open_kernel();
15018 memcpy(&gdt[entry], desc, size);
15019 + pax_close_kernel();
15020 }
15021
15022 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15023 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15024
15025 static inline void native_load_tr_desc(void)
15026 {
15027 + pax_open_kernel();
15028 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15029 + pax_close_kernel();
15030 }
15031
15032 static inline void native_load_gdt(const struct desc_ptr *dtr)
15033 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15034 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15035 unsigned int i;
15036
15037 + pax_open_kernel();
15038 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15039 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15040 + pax_close_kernel();
15041 }
15042
15043 #define _LDT_empty(info) \
15044 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15045 preempt_enable();
15046 }
15047
15048 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15049 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15050 {
15051 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15052 }
15053 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15054 }
15055
15056 #ifdef CONFIG_X86_64
15057 -static inline void set_nmi_gate(int gate, void *addr)
15058 +static inline void set_nmi_gate(int gate, const void *addr)
15059 {
15060 gate_desc s;
15061
15062 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15063 #endif
15064
15065 #ifdef CONFIG_TRACING
15066 -extern struct desc_ptr trace_idt_descr;
15067 -extern gate_desc trace_idt_table[];
15068 +extern const struct desc_ptr trace_idt_descr;
15069 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15070 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15071 {
15072 write_idt_entry(trace_idt_table, entry, gate);
15073 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15074 }
15075 #endif
15076
15077 -static inline void _set_gate(int gate, unsigned type, void *addr,
15078 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15079 unsigned dpl, unsigned ist, unsigned seg)
15080 {
15081 gate_desc s;
15082 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15083 * Pentium F0 0F bugfix can have resulted in the mapped
15084 * IDT being write-protected.
15085 */
15086 -static inline void set_intr_gate(unsigned int n, void *addr)
15087 +static inline void set_intr_gate(unsigned int n, const void *addr)
15088 {
15089 BUG_ON((unsigned)n > 0xFF);
15090 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15091 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15092 /*
15093 * This routine sets up an interrupt gate at directory privilege level 3.
15094 */
15095 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15096 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15097 {
15098 BUG_ON((unsigned)n > 0xFF);
15099 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15100 }
15101
15102 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15103 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15104 {
15105 BUG_ON((unsigned)n > 0xFF);
15106 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15107 }
15108
15109 -static inline void set_trap_gate(unsigned int n, void *addr)
15110 +static inline void set_trap_gate(unsigned int n, const void *addr)
15111 {
15112 BUG_ON((unsigned)n > 0xFF);
15113 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15114 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15115 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15116 {
15117 BUG_ON((unsigned)n > 0xFF);
15118 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15119 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15120 }
15121
15122 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15123 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15124 {
15125 BUG_ON((unsigned)n > 0xFF);
15126 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15127 }
15128
15129 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15130 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15131 {
15132 BUG_ON((unsigned)n > 0xFF);
15133 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15134 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15135 else
15136 load_idt((const struct desc_ptr *)&idt_descr);
15137 }
15138 +
15139 +#ifdef CONFIG_X86_32
15140 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15141 +{
15142 + struct desc_struct d;
15143 +
15144 + if (likely(limit))
15145 + limit = (limit - 1UL) >> PAGE_SHIFT;
15146 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15147 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15148 +}
15149 +#endif
15150 +
15151 #endif /* _ASM_X86_DESC_H */
15152 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15153 index 278441f..b95a174 100644
15154 --- a/arch/x86/include/asm/desc_defs.h
15155 +++ b/arch/x86/include/asm/desc_defs.h
15156 @@ -31,6 +31,12 @@ struct desc_struct {
15157 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15158 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15159 };
15160 + struct {
15161 + u16 offset_low;
15162 + u16 seg;
15163 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15164 + unsigned offset_high: 16;
15165 + } gate;
15166 };
15167 } __attribute__((packed));
15168
15169 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15170 index ced283a..ffe04cc 100644
15171 --- a/arch/x86/include/asm/div64.h
15172 +++ b/arch/x86/include/asm/div64.h
15173 @@ -39,7 +39,7 @@
15174 __mod; \
15175 })
15176
15177 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15178 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15179 {
15180 union {
15181 u64 v64;
15182 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15183 index 9c999c1..3860cb8 100644
15184 --- a/arch/x86/include/asm/elf.h
15185 +++ b/arch/x86/include/asm/elf.h
15186 @@ -243,7 +243,25 @@ extern int force_personality32;
15187 the loader. We need to make sure that it is out of the way of the program
15188 that it will "exec", and that there is sufficient room for the brk. */
15189
15190 +#ifdef CONFIG_PAX_SEGMEXEC
15191 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15192 +#else
15193 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15194 +#endif
15195 +
15196 +#ifdef CONFIG_PAX_ASLR
15197 +#ifdef CONFIG_X86_32
15198 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15199 +
15200 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15201 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15202 +#else
15203 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15204 +
15205 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15206 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15207 +#endif
15208 +#endif
15209
15210 /* This yields a mask that user programs can use to figure out what
15211 instruction set this CPU supports. This could be done in user space,
15212 @@ -296,16 +314,12 @@ do { \
15213
15214 #define ARCH_DLINFO \
15215 do { \
15216 - if (vdso_enabled) \
15217 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15218 - (unsigned long)current->mm->context.vdso); \
15219 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15220 } while (0)
15221
15222 #define ARCH_DLINFO_X32 \
15223 do { \
15224 - if (vdso_enabled) \
15225 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15226 - (unsigned long)current->mm->context.vdso); \
15227 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15228 } while (0)
15229
15230 #define AT_SYSINFO 32
15231 @@ -320,7 +334,7 @@ else \
15232
15233 #endif /* !CONFIG_X86_32 */
15234
15235 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15236 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15237
15238 #define VDSO_ENTRY \
15239 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15240 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15241 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15242 #define compat_arch_setup_additional_pages syscall32_setup_pages
15243
15244 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15245 -#define arch_randomize_brk arch_randomize_brk
15246 -
15247 /*
15248 * True on X86_32 or when emulating IA32 on X86_64
15249 */
15250 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15251 index 77a99ac..39ff7f5 100644
15252 --- a/arch/x86/include/asm/emergency-restart.h
15253 +++ b/arch/x86/include/asm/emergency-restart.h
15254 @@ -1,6 +1,6 @@
15255 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15256 #define _ASM_X86_EMERGENCY_RESTART_H
15257
15258 -extern void machine_emergency_restart(void);
15259 +extern void machine_emergency_restart(void) __noreturn;
15260
15261 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15262 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15263 index 4d0bda7..221da4d 100644
15264 --- a/arch/x86/include/asm/fpu-internal.h
15265 +++ b/arch/x86/include/asm/fpu-internal.h
15266 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15267 #define user_insn(insn, output, input...) \
15268 ({ \
15269 int err; \
15270 + pax_open_userland(); \
15271 asm volatile(ASM_STAC "\n" \
15272 - "1:" #insn "\n\t" \
15273 + "1:" \
15274 + __copyuser_seg \
15275 + #insn "\n\t" \
15276 "2: " ASM_CLAC "\n" \
15277 ".section .fixup,\"ax\"\n" \
15278 "3: movl $-1,%[err]\n" \
15279 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15280 _ASM_EXTABLE(1b, 3b) \
15281 : [err] "=r" (err), output \
15282 : "0"(0), input); \
15283 + pax_close_userland(); \
15284 err; \
15285 })
15286
15287 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15288 "emms\n\t" /* clear stack tags */
15289 "fildl %P[addr]", /* set F?P to defined value */
15290 X86_FEATURE_FXSAVE_LEAK,
15291 - [addr] "m" (tsk->thread.fpu.has_fpu));
15292 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15293
15294 return fpu_restore_checking(&tsk->thread.fpu);
15295 }
15296 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15297 index be27ba1..04a8801 100644
15298 --- a/arch/x86/include/asm/futex.h
15299 +++ b/arch/x86/include/asm/futex.h
15300 @@ -12,6 +12,7 @@
15301 #include <asm/smap.h>
15302
15303 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15304 + typecheck(u32 __user *, uaddr); \
15305 asm volatile("\t" ASM_STAC "\n" \
15306 "1:\t" insn "\n" \
15307 "2:\t" ASM_CLAC "\n" \
15308 @@ -20,15 +21,16 @@
15309 "\tjmp\t2b\n" \
15310 "\t.previous\n" \
15311 _ASM_EXTABLE(1b, 3b) \
15312 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15313 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15314 : "i" (-EFAULT), "0" (oparg), "1" (0))
15315
15316 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15317 + typecheck(u32 __user *, uaddr); \
15318 asm volatile("\t" ASM_STAC "\n" \
15319 "1:\tmovl %2, %0\n" \
15320 "\tmovl\t%0, %3\n" \
15321 "\t" insn "\n" \
15322 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15323 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15324 "\tjnz\t1b\n" \
15325 "3:\t" ASM_CLAC "\n" \
15326 "\t.section .fixup,\"ax\"\n" \
15327 @@ -38,7 +40,7 @@
15328 _ASM_EXTABLE(1b, 4b) \
15329 _ASM_EXTABLE(2b, 4b) \
15330 : "=&a" (oldval), "=&r" (ret), \
15331 - "+m" (*uaddr), "=&r" (tem) \
15332 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15333 : "r" (oparg), "i" (-EFAULT), "1" (0))
15334
15335 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15336 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15337
15338 pagefault_disable();
15339
15340 + pax_open_userland();
15341 switch (op) {
15342 case FUTEX_OP_SET:
15343 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15344 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15345 break;
15346 case FUTEX_OP_ADD:
15347 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15348 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15349 uaddr, oparg);
15350 break;
15351 case FUTEX_OP_OR:
15352 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15353 default:
15354 ret = -ENOSYS;
15355 }
15356 + pax_close_userland();
15357
15358 pagefault_enable();
15359
15360 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15361 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15362 return -EFAULT;
15363
15364 + pax_open_userland();
15365 asm volatile("\t" ASM_STAC "\n"
15366 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15367 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15368 "2:\t" ASM_CLAC "\n"
15369 "\t.section .fixup, \"ax\"\n"
15370 "3:\tmov %3, %0\n"
15371 "\tjmp 2b\n"
15372 "\t.previous\n"
15373 _ASM_EXTABLE(1b, 3b)
15374 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15375 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15376 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15377 : "memory"
15378 );
15379 + pax_close_userland();
15380
15381 *uval = oldval;
15382 return ret;
15383 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15384 index e4ac559..c1c0c87 100644
15385 --- a/arch/x86/include/asm/hw_irq.h
15386 +++ b/arch/x86/include/asm/hw_irq.h
15387 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15388 extern void enable_IO_APIC(void);
15389
15390 /* Statistics */
15391 -extern atomic_t irq_err_count;
15392 -extern atomic_t irq_mis_count;
15393 +extern atomic_unchecked_t irq_err_count;
15394 +extern atomic_unchecked_t irq_mis_count;
15395
15396 /* EISA */
15397 extern void eisa_set_level_irq(unsigned int irq);
15398 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15399 index a203659..9889f1c 100644
15400 --- a/arch/x86/include/asm/i8259.h
15401 +++ b/arch/x86/include/asm/i8259.h
15402 @@ -62,7 +62,7 @@ struct legacy_pic {
15403 void (*init)(int auto_eoi);
15404 int (*irq_pending)(unsigned int irq);
15405 void (*make_irq)(unsigned int irq);
15406 -};
15407 +} __do_const;
15408
15409 extern struct legacy_pic *legacy_pic;
15410 extern struct legacy_pic null_legacy_pic;
15411 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15412 index 34f69cb..6d95446 100644
15413 --- a/arch/x86/include/asm/io.h
15414 +++ b/arch/x86/include/asm/io.h
15415 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15416 "m" (*(volatile type __force *)addr) barrier); }
15417
15418 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15419 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15420 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15421 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15422 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15423
15424 build_mmio_read(__readb, "b", unsigned char, "=q", )
15425 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15426 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15427 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15428 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15429
15430 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15431 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15432 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15433 return ioremap_nocache(offset, size);
15434 }
15435
15436 -extern void iounmap(volatile void __iomem *addr);
15437 +extern void iounmap(const volatile void __iomem *addr);
15438
15439 extern void set_iounmap_nonlazy(void);
15440
15441 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15442
15443 #include <linux/vmalloc.h>
15444
15445 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15446 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15447 +{
15448 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15449 +}
15450 +
15451 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15452 +{
15453 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15454 +}
15455 +
15456 /*
15457 * Convert a virtual cached pointer to an uncached pointer
15458 */
15459 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15460 index bba3cf8..06bc8da 100644
15461 --- a/arch/x86/include/asm/irqflags.h
15462 +++ b/arch/x86/include/asm/irqflags.h
15463 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15464 sti; \
15465 sysexit
15466
15467 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15468 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15469 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15470 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15471 +
15472 #else
15473 #define INTERRUPT_RETURN iret
15474 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15475 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15476 index 5a6d287..f815789 100644
15477 --- a/arch/x86/include/asm/kprobes.h
15478 +++ b/arch/x86/include/asm/kprobes.h
15479 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15480 #define RELATIVEJUMP_SIZE 5
15481 #define RELATIVECALL_OPCODE 0xe8
15482 #define RELATIVE_ADDR_SIZE 4
15483 -#define MAX_STACK_SIZE 64
15484 -#define MIN_STACK_SIZE(ADDR) \
15485 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15486 - THREAD_SIZE - (unsigned long)(ADDR))) \
15487 - ? (MAX_STACK_SIZE) \
15488 - : (((unsigned long)current_thread_info()) + \
15489 - THREAD_SIZE - (unsigned long)(ADDR)))
15490 +#define MAX_STACK_SIZE 64UL
15491 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15492
15493 #define flush_insn_slot(p) do { } while (0)
15494
15495 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15496 index 2d89e39..baee879 100644
15497 --- a/arch/x86/include/asm/local.h
15498 +++ b/arch/x86/include/asm/local.h
15499 @@ -10,33 +10,97 @@ typedef struct {
15500 atomic_long_t a;
15501 } local_t;
15502
15503 +typedef struct {
15504 + atomic_long_unchecked_t a;
15505 +} local_unchecked_t;
15506 +
15507 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15508
15509 #define local_read(l) atomic_long_read(&(l)->a)
15510 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15511 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15512 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15513
15514 static inline void local_inc(local_t *l)
15515 {
15516 - asm volatile(_ASM_INC "%0"
15517 + asm volatile(_ASM_INC "%0\n"
15518 +
15519 +#ifdef CONFIG_PAX_REFCOUNT
15520 + "jno 0f\n"
15521 + _ASM_DEC "%0\n"
15522 + "int $4\n0:\n"
15523 + _ASM_EXTABLE(0b, 0b)
15524 +#endif
15525 +
15526 + : "+m" (l->a.counter));
15527 +}
15528 +
15529 +static inline void local_inc_unchecked(local_unchecked_t *l)
15530 +{
15531 + asm volatile(_ASM_INC "%0\n"
15532 : "+m" (l->a.counter));
15533 }
15534
15535 static inline void local_dec(local_t *l)
15536 {
15537 - asm volatile(_ASM_DEC "%0"
15538 + asm volatile(_ASM_DEC "%0\n"
15539 +
15540 +#ifdef CONFIG_PAX_REFCOUNT
15541 + "jno 0f\n"
15542 + _ASM_INC "%0\n"
15543 + "int $4\n0:\n"
15544 + _ASM_EXTABLE(0b, 0b)
15545 +#endif
15546 +
15547 + : "+m" (l->a.counter));
15548 +}
15549 +
15550 +static inline void local_dec_unchecked(local_unchecked_t *l)
15551 +{
15552 + asm volatile(_ASM_DEC "%0\n"
15553 : "+m" (l->a.counter));
15554 }
15555
15556 static inline void local_add(long i, local_t *l)
15557 {
15558 - asm volatile(_ASM_ADD "%1,%0"
15559 + asm volatile(_ASM_ADD "%1,%0\n"
15560 +
15561 +#ifdef CONFIG_PAX_REFCOUNT
15562 + "jno 0f\n"
15563 + _ASM_SUB "%1,%0\n"
15564 + "int $4\n0:\n"
15565 + _ASM_EXTABLE(0b, 0b)
15566 +#endif
15567 +
15568 + : "+m" (l->a.counter)
15569 + : "ir" (i));
15570 +}
15571 +
15572 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15573 +{
15574 + asm volatile(_ASM_ADD "%1,%0\n"
15575 : "+m" (l->a.counter)
15576 : "ir" (i));
15577 }
15578
15579 static inline void local_sub(long i, local_t *l)
15580 {
15581 - asm volatile(_ASM_SUB "%1,%0"
15582 + asm volatile(_ASM_SUB "%1,%0\n"
15583 +
15584 +#ifdef CONFIG_PAX_REFCOUNT
15585 + "jno 0f\n"
15586 + _ASM_ADD "%1,%0\n"
15587 + "int $4\n0:\n"
15588 + _ASM_EXTABLE(0b, 0b)
15589 +#endif
15590 +
15591 + : "+m" (l->a.counter)
15592 + : "ir" (i));
15593 +}
15594 +
15595 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15596 +{
15597 + asm volatile(_ASM_SUB "%1,%0\n"
15598 : "+m" (l->a.counter)
15599 : "ir" (i));
15600 }
15601 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15602 {
15603 unsigned char c;
15604
15605 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15606 + asm volatile(_ASM_SUB "%2,%0\n"
15607 +
15608 +#ifdef CONFIG_PAX_REFCOUNT
15609 + "jno 0f\n"
15610 + _ASM_ADD "%2,%0\n"
15611 + "int $4\n0:\n"
15612 + _ASM_EXTABLE(0b, 0b)
15613 +#endif
15614 +
15615 + "sete %1\n"
15616 : "+m" (l->a.counter), "=qm" (c)
15617 : "ir" (i) : "memory");
15618 return c;
15619 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15620 {
15621 unsigned char c;
15622
15623 - asm volatile(_ASM_DEC "%0; sete %1"
15624 + asm volatile(_ASM_DEC "%0\n"
15625 +
15626 +#ifdef CONFIG_PAX_REFCOUNT
15627 + "jno 0f\n"
15628 + _ASM_INC "%0\n"
15629 + "int $4\n0:\n"
15630 + _ASM_EXTABLE(0b, 0b)
15631 +#endif
15632 +
15633 + "sete %1\n"
15634 : "+m" (l->a.counter), "=qm" (c)
15635 : : "memory");
15636 return c != 0;
15637 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15638 {
15639 unsigned char c;
15640
15641 - asm volatile(_ASM_INC "%0; sete %1"
15642 + asm volatile(_ASM_INC "%0\n"
15643 +
15644 +#ifdef CONFIG_PAX_REFCOUNT
15645 + "jno 0f\n"
15646 + _ASM_DEC "%0\n"
15647 + "int $4\n0:\n"
15648 + _ASM_EXTABLE(0b, 0b)
15649 +#endif
15650 +
15651 + "sete %1\n"
15652 : "+m" (l->a.counter), "=qm" (c)
15653 : : "memory");
15654 return c != 0;
15655 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15656 {
15657 unsigned char c;
15658
15659 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15660 + asm volatile(_ASM_ADD "%2,%0\n"
15661 +
15662 +#ifdef CONFIG_PAX_REFCOUNT
15663 + "jno 0f\n"
15664 + _ASM_SUB "%2,%0\n"
15665 + "int $4\n0:\n"
15666 + _ASM_EXTABLE(0b, 0b)
15667 +#endif
15668 +
15669 + "sets %1\n"
15670 : "+m" (l->a.counter), "=qm" (c)
15671 : "ir" (i) : "memory");
15672 return c;
15673 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15674 static inline long local_add_return(long i, local_t *l)
15675 {
15676 long __i = i;
15677 + asm volatile(_ASM_XADD "%0, %1\n"
15678 +
15679 +#ifdef CONFIG_PAX_REFCOUNT
15680 + "jno 0f\n"
15681 + _ASM_MOV "%0,%1\n"
15682 + "int $4\n0:\n"
15683 + _ASM_EXTABLE(0b, 0b)
15684 +#endif
15685 +
15686 + : "+r" (i), "+m" (l->a.counter)
15687 + : : "memory");
15688 + return i + __i;
15689 +}
15690 +
15691 +/**
15692 + * local_add_return_unchecked - add and return
15693 + * @i: integer value to add
15694 + * @l: pointer to type local_unchecked_t
15695 + *
15696 + * Atomically adds @i to @l and returns @i + @l
15697 + */
15698 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15699 +{
15700 + long __i = i;
15701 asm volatile(_ASM_XADD "%0, %1;"
15702 : "+r" (i), "+m" (l->a.counter)
15703 : : "memory");
15704 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15705
15706 #define local_cmpxchg(l, o, n) \
15707 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15708 +#define local_cmpxchg_unchecked(l, o, n) \
15709 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15710 /* Always has a lock prefix */
15711 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15712
15713 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15714 new file mode 100644
15715 index 0000000..2bfd3ba
15716 --- /dev/null
15717 +++ b/arch/x86/include/asm/mman.h
15718 @@ -0,0 +1,15 @@
15719 +#ifndef _X86_MMAN_H
15720 +#define _X86_MMAN_H
15721 +
15722 +#include <uapi/asm/mman.h>
15723 +
15724 +#ifdef __KERNEL__
15725 +#ifndef __ASSEMBLY__
15726 +#ifdef CONFIG_X86_32
15727 +#define arch_mmap_check i386_mmap_check
15728 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15729 +#endif
15730 +#endif
15731 +#endif
15732 +
15733 +#endif /* X86_MMAN_H */
15734 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15735 index 5f55e69..e20bfb1 100644
15736 --- a/arch/x86/include/asm/mmu.h
15737 +++ b/arch/x86/include/asm/mmu.h
15738 @@ -9,7 +9,7 @@
15739 * we put the segment information here.
15740 */
15741 typedef struct {
15742 - void *ldt;
15743 + struct desc_struct *ldt;
15744 int size;
15745
15746 #ifdef CONFIG_X86_64
15747 @@ -18,7 +18,19 @@ typedef struct {
15748 #endif
15749
15750 struct mutex lock;
15751 - void *vdso;
15752 + unsigned long vdso;
15753 +
15754 +#ifdef CONFIG_X86_32
15755 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15756 + unsigned long user_cs_base;
15757 + unsigned long user_cs_limit;
15758 +
15759 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15760 + cpumask_t cpu_user_cs_mask;
15761 +#endif
15762 +
15763 +#endif
15764 +#endif
15765 } mm_context_t;
15766
15767 #ifdef CONFIG_SMP
15768 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15769 index be12c53..4d24039 100644
15770 --- a/arch/x86/include/asm/mmu_context.h
15771 +++ b/arch/x86/include/asm/mmu_context.h
15772 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15773
15774 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15775 {
15776 +
15777 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15778 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15779 + unsigned int i;
15780 + pgd_t *pgd;
15781 +
15782 + pax_open_kernel();
15783 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15784 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15785 + set_pgd_batched(pgd+i, native_make_pgd(0));
15786 + pax_close_kernel();
15787 + }
15788 +#endif
15789 +
15790 #ifdef CONFIG_SMP
15791 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15792 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15793 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15794 struct task_struct *tsk)
15795 {
15796 unsigned cpu = smp_processor_id();
15797 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15798 + int tlbstate = TLBSTATE_OK;
15799 +#endif
15800
15801 if (likely(prev != next)) {
15802 #ifdef CONFIG_SMP
15803 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15804 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15805 +#endif
15806 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15807 this_cpu_write(cpu_tlbstate.active_mm, next);
15808 #endif
15809 cpumask_set_cpu(cpu, mm_cpumask(next));
15810
15811 /* Re-load page tables */
15812 +#ifdef CONFIG_PAX_PER_CPU_PGD
15813 + pax_open_kernel();
15814 +
15815 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15816 + if (static_cpu_has(X86_FEATURE_PCID))
15817 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15818 + else
15819 +#endif
15820 +
15821 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15822 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15823 + pax_close_kernel();
15824 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
15825 +
15826 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15827 + if (static_cpu_has(X86_FEATURE_PCID)) {
15828 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15829 + u64 descriptor[2];
15830 + descriptor[0] = PCID_USER;
15831 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15832 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15833 + descriptor[0] = PCID_KERNEL;
15834 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15835 + }
15836 + } else {
15837 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15838 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15839 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15840 + else
15841 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15842 + }
15843 + } else
15844 +#endif
15845 +
15846 + load_cr3(get_cpu_pgd(cpu, kernel));
15847 +#else
15848 load_cr3(next->pgd);
15849 +#endif
15850
15851 /* Stop flush ipis for the previous mm */
15852 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15853 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15854 /* Load the LDT, if the LDT is different: */
15855 if (unlikely(prev->context.ldt != next->context.ldt))
15856 load_LDT_nolock(&next->context);
15857 +
15858 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15859 + if (!(__supported_pte_mask & _PAGE_NX)) {
15860 + smp_mb__before_clear_bit();
15861 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15862 + smp_mb__after_clear_bit();
15863 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15864 + }
15865 +#endif
15866 +
15867 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15868 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15869 + prev->context.user_cs_limit != next->context.user_cs_limit))
15870 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15871 +#ifdef CONFIG_SMP
15872 + else if (unlikely(tlbstate != TLBSTATE_OK))
15873 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15874 +#endif
15875 +#endif
15876 +
15877 }
15878 + else {
15879 +
15880 +#ifdef CONFIG_PAX_PER_CPU_PGD
15881 + pax_open_kernel();
15882 +
15883 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15884 + if (static_cpu_has(X86_FEATURE_PCID))
15885 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15886 + else
15887 +#endif
15888 +
15889 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15890 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15891 + pax_close_kernel();
15892 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
15893 +
15894 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15895 + if (static_cpu_has(X86_FEATURE_PCID)) {
15896 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15897 + u64 descriptor[2];
15898 + descriptor[0] = PCID_USER;
15899 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15900 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15901 + descriptor[0] = PCID_KERNEL;
15902 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15903 + }
15904 + } else {
15905 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15906 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15907 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15908 + else
15909 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15910 + }
15911 + } else
15912 +#endif
15913 +
15914 + load_cr3(get_cpu_pgd(cpu, kernel));
15915 +#endif
15916 +
15917 #ifdef CONFIG_SMP
15918 - else {
15919 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15920 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15921
15922 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15923 * tlb flush IPI delivery. We must reload CR3
15924 * to make sure to use no freed page tables.
15925 */
15926 +
15927 +#ifndef CONFIG_PAX_PER_CPU_PGD
15928 load_cr3(next->pgd);
15929 +#endif
15930 +
15931 load_LDT_nolock(&next->context);
15932 +
15933 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15934 + if (!(__supported_pte_mask & _PAGE_NX))
15935 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15936 +#endif
15937 +
15938 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15939 +#ifdef CONFIG_PAX_PAGEEXEC
15940 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15941 +#endif
15942 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15943 +#endif
15944 +
15945 }
15946 +#endif
15947 }
15948 -#endif
15949 }
15950
15951 #define activate_mm(prev, next) \
15952 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15953 index e3b7819..b257c64 100644
15954 --- a/arch/x86/include/asm/module.h
15955 +++ b/arch/x86/include/asm/module.h
15956 @@ -5,6 +5,7 @@
15957
15958 #ifdef CONFIG_X86_64
15959 /* X86_64 does not define MODULE_PROC_FAMILY */
15960 +#define MODULE_PROC_FAMILY ""
15961 #elif defined CONFIG_M486
15962 #define MODULE_PROC_FAMILY "486 "
15963 #elif defined CONFIG_M586
15964 @@ -57,8 +58,20 @@
15965 #error unknown processor family
15966 #endif
15967
15968 -#ifdef CONFIG_X86_32
15969 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
15970 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
15971 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
15972 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
15973 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
15974 +#else
15975 +#define MODULE_PAX_KERNEXEC ""
15976 #endif
15977
15978 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15979 +#define MODULE_PAX_UDEREF "UDEREF "
15980 +#else
15981 +#define MODULE_PAX_UDEREF ""
15982 +#endif
15983 +
15984 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
15985 +
15986 #endif /* _ASM_X86_MODULE_H */
15987 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
15988 index 86f9301..b365cda 100644
15989 --- a/arch/x86/include/asm/nmi.h
15990 +++ b/arch/x86/include/asm/nmi.h
15991 @@ -40,11 +40,11 @@ struct nmiaction {
15992 nmi_handler_t handler;
15993 unsigned long flags;
15994 const char *name;
15995 -};
15996 +} __do_const;
15997
15998 #define register_nmi_handler(t, fn, fg, n, init...) \
15999 ({ \
16000 - static struct nmiaction init fn##_na = { \
16001 + static const struct nmiaction init fn##_na = { \
16002 .handler = (fn), \
16003 .name = (n), \
16004 .flags = (fg), \
16005 @@ -52,7 +52,7 @@ struct nmiaction {
16006 __register_nmi_handler((t), &fn##_na); \
16007 })
16008
16009 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16010 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16011
16012 void unregister_nmi_handler(unsigned int, const char *);
16013
16014 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16015 index c878924..21f4889 100644
16016 --- a/arch/x86/include/asm/page.h
16017 +++ b/arch/x86/include/asm/page.h
16018 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16019 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16020
16021 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16022 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16023
16024 #define __boot_va(x) __va(x)
16025 #define __boot_pa(x) __pa(x)
16026 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16027 index 0f1ddee..e2fc3d1 100644
16028 --- a/arch/x86/include/asm/page_64.h
16029 +++ b/arch/x86/include/asm/page_64.h
16030 @@ -7,9 +7,9 @@
16031
16032 /* duplicated to the one in bootmem.h */
16033 extern unsigned long max_pfn;
16034 -extern unsigned long phys_base;
16035 +extern const unsigned long phys_base;
16036
16037 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16038 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16039 {
16040 unsigned long y = x - __START_KERNEL_map;
16041
16042 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16043 index cfdc9ee..3f7b5d6 100644
16044 --- a/arch/x86/include/asm/paravirt.h
16045 +++ b/arch/x86/include/asm/paravirt.h
16046 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16047 return (pmd_t) { ret };
16048 }
16049
16050 -static inline pmdval_t pmd_val(pmd_t pmd)
16051 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16052 {
16053 pmdval_t ret;
16054
16055 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16056 val);
16057 }
16058
16059 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16060 +{
16061 + pgdval_t val = native_pgd_val(pgd);
16062 +
16063 + if (sizeof(pgdval_t) > sizeof(long))
16064 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16065 + val, (u64)val >> 32);
16066 + else
16067 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16068 + val);
16069 +}
16070 +
16071 static inline void pgd_clear(pgd_t *pgdp)
16072 {
16073 set_pgd(pgdp, __pgd(0));
16074 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16075 pv_mmu_ops.set_fixmap(idx, phys, flags);
16076 }
16077
16078 +#ifdef CONFIG_PAX_KERNEXEC
16079 +static inline unsigned long pax_open_kernel(void)
16080 +{
16081 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16082 +}
16083 +
16084 +static inline unsigned long pax_close_kernel(void)
16085 +{
16086 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16087 +}
16088 +#else
16089 +static inline unsigned long pax_open_kernel(void) { return 0; }
16090 +static inline unsigned long pax_close_kernel(void) { return 0; }
16091 +#endif
16092 +
16093 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16094
16095 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
16096 @@ -926,7 +953,7 @@ extern void default_banner(void);
16097
16098 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16099 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16100 -#define PARA_INDIRECT(addr) *%cs:addr
16101 +#define PARA_INDIRECT(addr) *%ss:addr
16102 #endif
16103
16104 #define INTERRUPT_RETURN \
16105 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
16106 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16107 CLBR_NONE, \
16108 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16109 +
16110 +#define GET_CR0_INTO_RDI \
16111 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16112 + mov %rax,%rdi
16113 +
16114 +#define SET_RDI_INTO_CR0 \
16115 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16116 +
16117 +#define GET_CR3_INTO_RDI \
16118 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16119 + mov %rax,%rdi
16120 +
16121 +#define SET_RDI_INTO_CR3 \
16122 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16123 +
16124 #endif /* CONFIG_X86_32 */
16125
16126 #endif /* __ASSEMBLY__ */
16127 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16128 index 0db1fca..52310cc 100644
16129 --- a/arch/x86/include/asm/paravirt_types.h
16130 +++ b/arch/x86/include/asm/paravirt_types.h
16131 @@ -84,7 +84,7 @@ struct pv_init_ops {
16132 */
16133 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16134 unsigned long addr, unsigned len);
16135 -};
16136 +} __no_const;
16137
16138
16139 struct pv_lazy_ops {
16140 @@ -98,7 +98,7 @@ struct pv_time_ops {
16141 unsigned long long (*sched_clock)(void);
16142 unsigned long long (*steal_clock)(int cpu);
16143 unsigned long (*get_tsc_khz)(void);
16144 -};
16145 +} __no_const;
16146
16147 struct pv_cpu_ops {
16148 /* hooks for various privileged instructions */
16149 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16150
16151 void (*start_context_switch)(struct task_struct *prev);
16152 void (*end_context_switch)(struct task_struct *next);
16153 -};
16154 +} __no_const;
16155
16156 struct pv_irq_ops {
16157 /*
16158 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16159 unsigned long start_eip,
16160 unsigned long start_esp);
16161 #endif
16162 -};
16163 +} __no_const;
16164
16165 struct pv_mmu_ops {
16166 unsigned long (*read_cr2)(void);
16167 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16168 struct paravirt_callee_save make_pud;
16169
16170 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16171 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16172 #endif /* PAGETABLE_LEVELS == 4 */
16173 #endif /* PAGETABLE_LEVELS >= 3 */
16174
16175 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16176 an mfn. We can tell which is which from the index. */
16177 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16178 phys_addr_t phys, pgprot_t flags);
16179 +
16180 +#ifdef CONFIG_PAX_KERNEXEC
16181 + unsigned long (*pax_open_kernel)(void);
16182 + unsigned long (*pax_close_kernel)(void);
16183 +#endif
16184 +
16185 };
16186
16187 struct arch_spinlock;
16188 @@ -334,7 +341,7 @@ struct pv_lock_ops {
16189 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
16190 int (*spin_trylock)(struct arch_spinlock *lock);
16191 void (*spin_unlock)(struct arch_spinlock *lock);
16192 -};
16193 +} __no_const;
16194
16195 /* This contains all the paravirt structures: we get a convenient
16196 * number for each function using the offset which we use to indicate
16197 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16198 index b4389a4..7024269 100644
16199 --- a/arch/x86/include/asm/pgalloc.h
16200 +++ b/arch/x86/include/asm/pgalloc.h
16201 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16202 pmd_t *pmd, pte_t *pte)
16203 {
16204 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16205 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16206 +}
16207 +
16208 +static inline void pmd_populate_user(struct mm_struct *mm,
16209 + pmd_t *pmd, pte_t *pte)
16210 +{
16211 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16212 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16213 }
16214
16215 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16216
16217 #ifdef CONFIG_X86_PAE
16218 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16219 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16220 +{
16221 + pud_populate(mm, pudp, pmd);
16222 +}
16223 #else /* !CONFIG_X86_PAE */
16224 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16225 {
16226 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16227 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16228 }
16229 +
16230 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16231 +{
16232 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16233 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16234 +}
16235 #endif /* CONFIG_X86_PAE */
16236
16237 #if PAGETABLE_LEVELS > 3
16238 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16239 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16240 }
16241
16242 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16243 +{
16244 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16245 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16246 +}
16247 +
16248 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16249 {
16250 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16251 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16252 index 3bf2dd0..23d2a9f 100644
16253 --- a/arch/x86/include/asm/pgtable-2level.h
16254 +++ b/arch/x86/include/asm/pgtable-2level.h
16255 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16256
16257 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16258 {
16259 + pax_open_kernel();
16260 *pmdp = pmd;
16261 + pax_close_kernel();
16262 }
16263
16264 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16265 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16266 index 81bb91b..9392125 100644
16267 --- a/arch/x86/include/asm/pgtable-3level.h
16268 +++ b/arch/x86/include/asm/pgtable-3level.h
16269 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16270
16271 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16272 {
16273 + pax_open_kernel();
16274 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16275 + pax_close_kernel();
16276 }
16277
16278 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16279 {
16280 + pax_open_kernel();
16281 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16282 + pax_close_kernel();
16283 }
16284
16285 /*
16286 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16287 index 1c00631..845f898 100644
16288 --- a/arch/x86/include/asm/pgtable.h
16289 +++ b/arch/x86/include/asm/pgtable.h
16290 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16291
16292 #ifndef __PAGETABLE_PUD_FOLDED
16293 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16294 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16295 #define pgd_clear(pgd) native_pgd_clear(pgd)
16296 #endif
16297
16298 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16299
16300 #define arch_end_context_switch(prev) do {} while(0)
16301
16302 +#define pax_open_kernel() native_pax_open_kernel()
16303 +#define pax_close_kernel() native_pax_close_kernel()
16304 #endif /* CONFIG_PARAVIRT */
16305
16306 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16307 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16308 +
16309 +#ifdef CONFIG_PAX_KERNEXEC
16310 +static inline unsigned long native_pax_open_kernel(void)
16311 +{
16312 + unsigned long cr0;
16313 +
16314 + preempt_disable();
16315 + barrier();
16316 + cr0 = read_cr0() ^ X86_CR0_WP;
16317 + BUG_ON(cr0 & X86_CR0_WP);
16318 + write_cr0(cr0);
16319 + return cr0 ^ X86_CR0_WP;
16320 +}
16321 +
16322 +static inline unsigned long native_pax_close_kernel(void)
16323 +{
16324 + unsigned long cr0;
16325 +
16326 + cr0 = read_cr0() ^ X86_CR0_WP;
16327 + BUG_ON(!(cr0 & X86_CR0_WP));
16328 + write_cr0(cr0);
16329 + barrier();
16330 + preempt_enable_no_resched();
16331 + return cr0 ^ X86_CR0_WP;
16332 +}
16333 +#else
16334 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16335 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16336 +#endif
16337 +
16338 /*
16339 * The following only work if pte_present() is true.
16340 * Undefined behaviour if not..
16341 */
16342 +static inline int pte_user(pte_t pte)
16343 +{
16344 + return pte_val(pte) & _PAGE_USER;
16345 +}
16346 +
16347 static inline int pte_dirty(pte_t pte)
16348 {
16349 return pte_flags(pte) & _PAGE_DIRTY;
16350 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16351 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16352 }
16353
16354 +static inline unsigned long pgd_pfn(pgd_t pgd)
16355 +{
16356 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16357 +}
16358 +
16359 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16360
16361 static inline int pmd_large(pmd_t pte)
16362 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16363 return pte_clear_flags(pte, _PAGE_RW);
16364 }
16365
16366 +static inline pte_t pte_mkread(pte_t pte)
16367 +{
16368 + return __pte(pte_val(pte) | _PAGE_USER);
16369 +}
16370 +
16371 static inline pte_t pte_mkexec(pte_t pte)
16372 {
16373 - return pte_clear_flags(pte, _PAGE_NX);
16374 +#ifdef CONFIG_X86_PAE
16375 + if (__supported_pte_mask & _PAGE_NX)
16376 + return pte_clear_flags(pte, _PAGE_NX);
16377 + else
16378 +#endif
16379 + return pte_set_flags(pte, _PAGE_USER);
16380 +}
16381 +
16382 +static inline pte_t pte_exprotect(pte_t pte)
16383 +{
16384 +#ifdef CONFIG_X86_PAE
16385 + if (__supported_pte_mask & _PAGE_NX)
16386 + return pte_set_flags(pte, _PAGE_NX);
16387 + else
16388 +#endif
16389 + return pte_clear_flags(pte, _PAGE_USER);
16390 }
16391
16392 static inline pte_t pte_mkdirty(pte_t pte)
16393 @@ -444,6 +509,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16394 #endif
16395
16396 #ifndef __ASSEMBLY__
16397 +
16398 +#ifdef CONFIG_PAX_PER_CPU_PGD
16399 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16400 +enum cpu_pgd_type {kernel = 0, user = 1};
16401 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16402 +{
16403 + return cpu_pgd[cpu][type];
16404 +}
16405 +#endif
16406 +
16407 #include <linux/mm_types.h>
16408 #include <linux/log2.h>
16409
16410 @@ -576,7 +651,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16411 * Currently stuck as a macro due to indirect forward reference to
16412 * linux/mmzone.h's __section_mem_map_addr() definition:
16413 */
16414 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16415 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16416
16417 /* Find an entry in the second-level page table.. */
16418 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16419 @@ -616,7 +691,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16420 * Currently stuck as a macro due to indirect forward reference to
16421 * linux/mmzone.h's __section_mem_map_addr() definition:
16422 */
16423 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16424 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16425
16426 /* to find an entry in a page-table-directory. */
16427 static inline unsigned long pud_index(unsigned long address)
16428 @@ -631,7 +706,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16429
16430 static inline int pgd_bad(pgd_t pgd)
16431 {
16432 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16433 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16434 }
16435
16436 static inline int pgd_none(pgd_t pgd)
16437 @@ -654,7 +729,12 @@ static inline int pgd_none(pgd_t pgd)
16438 * pgd_offset() returns a (pgd_t *)
16439 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16440 */
16441 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16442 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16443 +
16444 +#ifdef CONFIG_PAX_PER_CPU_PGD
16445 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16446 +#endif
16447 +
16448 /*
16449 * a shortcut which implies the use of the kernel's pgd, instead
16450 * of a process's
16451 @@ -665,6 +745,23 @@ static inline int pgd_none(pgd_t pgd)
16452 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16453 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16454
16455 +#ifdef CONFIG_X86_32
16456 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16457 +#else
16458 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16459 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16460 +
16461 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16462 +#ifdef __ASSEMBLY__
16463 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16464 +#else
16465 +extern unsigned long pax_user_shadow_base;
16466 +extern pgdval_t clone_pgd_mask;
16467 +#endif
16468 +#endif
16469 +
16470 +#endif
16471 +
16472 #ifndef __ASSEMBLY__
16473
16474 extern int direct_gbpages;
16475 @@ -831,11 +928,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16476 * dst and src can be on the same page, but the range must not overlap,
16477 * and must not cross a page boundary.
16478 */
16479 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16480 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16481 {
16482 - memcpy(dst, src, count * sizeof(pgd_t));
16483 + pax_open_kernel();
16484 + while (count--)
16485 + *dst++ = *src++;
16486 + pax_close_kernel();
16487 }
16488
16489 +#ifdef CONFIG_PAX_PER_CPU_PGD
16490 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16491 +#endif
16492 +
16493 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16494 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16495 +#else
16496 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16497 +#endif
16498 +
16499 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16500 static inline int page_level_shift(enum pg_level level)
16501 {
16502 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16503 index 9ee3221..b979c6b 100644
16504 --- a/arch/x86/include/asm/pgtable_32.h
16505 +++ b/arch/x86/include/asm/pgtable_32.h
16506 @@ -25,9 +25,6 @@
16507 struct mm_struct;
16508 struct vm_area_struct;
16509
16510 -extern pgd_t swapper_pg_dir[1024];
16511 -extern pgd_t initial_page_table[1024];
16512 -
16513 static inline void pgtable_cache_init(void) { }
16514 static inline void check_pgt_cache(void) { }
16515 void paging_init(void);
16516 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16517 # include <asm/pgtable-2level.h>
16518 #endif
16519
16520 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16521 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16522 +#ifdef CONFIG_X86_PAE
16523 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16524 +#endif
16525 +
16526 #if defined(CONFIG_HIGHPTE)
16527 #define pte_offset_map(dir, address) \
16528 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16529 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16530 /* Clear a kernel PTE and flush it from the TLB */
16531 #define kpte_clear_flush(ptep, vaddr) \
16532 do { \
16533 + pax_open_kernel(); \
16534 pte_clear(&init_mm, (vaddr), (ptep)); \
16535 + pax_close_kernel(); \
16536 __flush_tlb_one((vaddr)); \
16537 } while (0)
16538
16539 #endif /* !__ASSEMBLY__ */
16540
16541 +#define HAVE_ARCH_UNMAPPED_AREA
16542 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16543 +
16544 /*
16545 * kern_addr_valid() is (1) for FLATMEM and (0) for
16546 * SPARSEMEM and DISCONTIGMEM
16547 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16548 index ed5903b..c7fe163 100644
16549 --- a/arch/x86/include/asm/pgtable_32_types.h
16550 +++ b/arch/x86/include/asm/pgtable_32_types.h
16551 @@ -8,7 +8,7 @@
16552 */
16553 #ifdef CONFIG_X86_PAE
16554 # include <asm/pgtable-3level_types.h>
16555 -# define PMD_SIZE (1UL << PMD_SHIFT)
16556 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16557 # define PMD_MASK (~(PMD_SIZE - 1))
16558 #else
16559 # include <asm/pgtable-2level_types.h>
16560 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16561 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16562 #endif
16563
16564 +#ifdef CONFIG_PAX_KERNEXEC
16565 +#ifndef __ASSEMBLY__
16566 +extern unsigned char MODULES_EXEC_VADDR[];
16567 +extern unsigned char MODULES_EXEC_END[];
16568 +#endif
16569 +#include <asm/boot.h>
16570 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16571 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16572 +#else
16573 +#define ktla_ktva(addr) (addr)
16574 +#define ktva_ktla(addr) (addr)
16575 +#endif
16576 +
16577 #define MODULES_VADDR VMALLOC_START
16578 #define MODULES_END VMALLOC_END
16579 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16580 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16581 index e22c1db..23a625a 100644
16582 --- a/arch/x86/include/asm/pgtable_64.h
16583 +++ b/arch/x86/include/asm/pgtable_64.h
16584 @@ -16,10 +16,14 @@
16585
16586 extern pud_t level3_kernel_pgt[512];
16587 extern pud_t level3_ident_pgt[512];
16588 +extern pud_t level3_vmalloc_start_pgt[512];
16589 +extern pud_t level3_vmalloc_end_pgt[512];
16590 +extern pud_t level3_vmemmap_pgt[512];
16591 +extern pud_t level2_vmemmap_pgt[512];
16592 extern pmd_t level2_kernel_pgt[512];
16593 extern pmd_t level2_fixmap_pgt[512];
16594 -extern pmd_t level2_ident_pgt[512];
16595 -extern pgd_t init_level4_pgt[];
16596 +extern pmd_t level2_ident_pgt[512*2];
16597 +extern pgd_t init_level4_pgt[512];
16598
16599 #define swapper_pg_dir init_level4_pgt
16600
16601 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16602
16603 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16604 {
16605 + pax_open_kernel();
16606 *pmdp = pmd;
16607 + pax_close_kernel();
16608 }
16609
16610 static inline void native_pmd_clear(pmd_t *pmd)
16611 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16612
16613 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16614 {
16615 + pax_open_kernel();
16616 *pudp = pud;
16617 + pax_close_kernel();
16618 }
16619
16620 static inline void native_pud_clear(pud_t *pud)
16621 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16622
16623 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16624 {
16625 + pax_open_kernel();
16626 + *pgdp = pgd;
16627 + pax_close_kernel();
16628 +}
16629 +
16630 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16631 +{
16632 *pgdp = pgd;
16633 }
16634
16635 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16636 index 2d88344..4679fc3 100644
16637 --- a/arch/x86/include/asm/pgtable_64_types.h
16638 +++ b/arch/x86/include/asm/pgtable_64_types.h
16639 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16640 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16641 #define MODULES_END _AC(0xffffffffff000000, UL)
16642 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16643 +#define MODULES_EXEC_VADDR MODULES_VADDR
16644 +#define MODULES_EXEC_END MODULES_END
16645 +
16646 +#define ktla_ktva(addr) (addr)
16647 +#define ktva_ktla(addr) (addr)
16648
16649 #define EARLY_DYNAMIC_PAGE_TABLES 64
16650
16651 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16652 index f4843e0..a2526f8 100644
16653 --- a/arch/x86/include/asm/pgtable_types.h
16654 +++ b/arch/x86/include/asm/pgtable_types.h
16655 @@ -16,13 +16,12 @@
16656 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16657 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16658 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16659 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16660 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16661 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16662 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16663 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16664 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16665 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16666 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16667 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16668 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16669 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16670
16671 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16672 @@ -40,7 +39,6 @@
16673 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16674 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16675 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16676 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16677 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16678 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16679 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16680 @@ -84,8 +82,10 @@
16681
16682 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16683 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16684 -#else
16685 +#elif defined(CONFIG_KMEMCHECK)
16686 #define _PAGE_NX (_AT(pteval_t, 0))
16687 +#else
16688 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16689 #endif
16690
16691 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16692 @@ -143,6 +143,9 @@
16693 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16694 _PAGE_ACCESSED)
16695
16696 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16697 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16698 +
16699 #define __PAGE_KERNEL_EXEC \
16700 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16701 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16702 @@ -153,7 +156,7 @@
16703 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16704 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16705 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16706 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16707 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16708 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16709 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16710 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16711 @@ -215,8 +218,8 @@
16712 * bits are combined, this will alow user to access the high address mapped
16713 * VDSO in the presence of CONFIG_COMPAT_VDSO
16714 */
16715 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16716 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16717 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16718 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16719 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16720 #endif
16721
16722 @@ -254,7 +257,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16723 {
16724 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16725 }
16726 +#endif
16727
16728 +#if PAGETABLE_LEVELS == 3
16729 +#include <asm-generic/pgtable-nopud.h>
16730 +#endif
16731 +
16732 +#if PAGETABLE_LEVELS == 2
16733 +#include <asm-generic/pgtable-nopmd.h>
16734 +#endif
16735 +
16736 +#ifndef __ASSEMBLY__
16737 #if PAGETABLE_LEVELS > 3
16738 typedef struct { pudval_t pud; } pud_t;
16739
16740 @@ -268,8 +281,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16741 return pud.pud;
16742 }
16743 #else
16744 -#include <asm-generic/pgtable-nopud.h>
16745 -
16746 static inline pudval_t native_pud_val(pud_t pud)
16747 {
16748 return native_pgd_val(pud.pgd);
16749 @@ -289,8 +300,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16750 return pmd.pmd;
16751 }
16752 #else
16753 -#include <asm-generic/pgtable-nopmd.h>
16754 -
16755 static inline pmdval_t native_pmd_val(pmd_t pmd)
16756 {
16757 return native_pgd_val(pmd.pud.pgd);
16758 @@ -330,7 +339,6 @@ typedef struct page *pgtable_t;
16759
16760 extern pteval_t __supported_pte_mask;
16761 extern void set_nx(void);
16762 -extern int nx_enabled;
16763
16764 #define pgprot_writecombine pgprot_writecombine
16765 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16766 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16767 index 24cf5ae..4d9fa2d 100644
16768 --- a/arch/x86/include/asm/processor.h
16769 +++ b/arch/x86/include/asm/processor.h
16770 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16771 : "memory");
16772 }
16773
16774 +/* invpcid (%rdx),%rax */
16775 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16776 +
16777 +#define INVPCID_SINGLE_ADDRESS 0UL
16778 +#define INVPCID_SINGLE_CONTEXT 1UL
16779 +#define INVPCID_ALL_GLOBAL 2UL
16780 +#define INVPCID_ALL_MONGLOBAL 3UL
16781 +
16782 +#define PCID_KERNEL 0UL
16783 +#define PCID_USER 1UL
16784 +#define PCID_NOFLUSH (1UL << 63)
16785 +
16786 static inline void load_cr3(pgd_t *pgdir)
16787 {
16788 - write_cr3(__pa(pgdir));
16789 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16790 }
16791
16792 #ifdef CONFIG_X86_32
16793 @@ -283,7 +295,7 @@ struct tss_struct {
16794
16795 } ____cacheline_aligned;
16796
16797 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16798 +extern struct tss_struct init_tss[NR_CPUS];
16799
16800 /*
16801 * Save the original ist values for checking stack pointers during debugging
16802 @@ -453,6 +465,7 @@ struct thread_struct {
16803 unsigned short ds;
16804 unsigned short fsindex;
16805 unsigned short gsindex;
16806 + unsigned short ss;
16807 #endif
16808 #ifdef CONFIG_X86_32
16809 unsigned long ip;
16810 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16811 extern unsigned long mmu_cr4_features;
16812 extern u32 *trampoline_cr4_features;
16813
16814 -static inline void set_in_cr4(unsigned long mask)
16815 -{
16816 - unsigned long cr4;
16817 -
16818 - mmu_cr4_features |= mask;
16819 - if (trampoline_cr4_features)
16820 - *trampoline_cr4_features = mmu_cr4_features;
16821 - cr4 = read_cr4();
16822 - cr4 |= mask;
16823 - write_cr4(cr4);
16824 -}
16825 -
16826 -static inline void clear_in_cr4(unsigned long mask)
16827 -{
16828 - unsigned long cr4;
16829 -
16830 - mmu_cr4_features &= ~mask;
16831 - if (trampoline_cr4_features)
16832 - *trampoline_cr4_features = mmu_cr4_features;
16833 - cr4 = read_cr4();
16834 - cr4 &= ~mask;
16835 - write_cr4(cr4);
16836 -}
16837 +extern void set_in_cr4(unsigned long mask);
16838 +extern void clear_in_cr4(unsigned long mask);
16839
16840 typedef struct {
16841 unsigned long seg;
16842 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16843 */
16844 #define TASK_SIZE PAGE_OFFSET
16845 #define TASK_SIZE_MAX TASK_SIZE
16846 +
16847 +#ifdef CONFIG_PAX_SEGMEXEC
16848 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16849 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16850 +#else
16851 #define STACK_TOP TASK_SIZE
16852 -#define STACK_TOP_MAX STACK_TOP
16853 +#endif
16854 +
16855 +#define STACK_TOP_MAX TASK_SIZE
16856
16857 #define INIT_THREAD { \
16858 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16859 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16860 .vm86_info = NULL, \
16861 .sysenter_cs = __KERNEL_CS, \
16862 .io_bitmap_ptr = NULL, \
16863 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16864 */
16865 #define INIT_TSS { \
16866 .x86_tss = { \
16867 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16868 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16869 .ss0 = __KERNEL_DS, \
16870 .ss1 = __KERNEL_CS, \
16871 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16872 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16873 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16874
16875 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16876 -#define KSTK_TOP(info) \
16877 -({ \
16878 - unsigned long *__ptr = (unsigned long *)(info); \
16879 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16880 -})
16881 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16882
16883 /*
16884 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16885 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16886 #define task_pt_regs(task) \
16887 ({ \
16888 struct pt_regs *__regs__; \
16889 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16890 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16891 __regs__ - 1; \
16892 })
16893
16894 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16895 /*
16896 * User space process size. 47bits minus one guard page.
16897 */
16898 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16899 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16900
16901 /* This decides where the kernel will search for a free chunk of vm
16902 * space during mmap's.
16903 */
16904 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16905 - 0xc0000000 : 0xFFFFe000)
16906 + 0xc0000000 : 0xFFFFf000)
16907
16908 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16909 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16910 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16911 #define STACK_TOP_MAX TASK_SIZE_MAX
16912
16913 #define INIT_THREAD { \
16914 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16915 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16916 }
16917
16918 #define INIT_TSS { \
16919 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16920 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16921 }
16922
16923 /*
16924 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16925 */
16926 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16927
16928 +#ifdef CONFIG_PAX_SEGMEXEC
16929 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16930 +#endif
16931 +
16932 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16933
16934 /* Get/set a process' ability to use the timestamp counter instruction */
16935 @@ -943,7 +942,8 @@ extern int set_tsc_mode(unsigned int val);
16936 extern u16 amd_get_nb_id(int cpu);
16937
16938 struct aperfmperf {
16939 - u64 aperf, mperf;
16940 + u64 aperf __intentional_overflow(0);
16941 + u64 mperf __intentional_overflow(0);
16942 };
16943
16944 static inline void get_aperfmperf(struct aperfmperf *am)
16945 @@ -971,7 +971,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
16946 return ratio;
16947 }
16948
16949 -extern unsigned long arch_align_stack(unsigned long sp);
16950 +#define arch_align_stack(x) ((x) & ~0xfUL)
16951 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16952
16953 void default_idle(void);
16954 @@ -981,6 +981,6 @@ bool xen_set_default_idle(void);
16955 #define xen_set_default_idle 0
16956 #endif
16957
16958 -void stop_this_cpu(void *dummy);
16959 +void stop_this_cpu(void *dummy) __noreturn;
16960 void df_debug(struct pt_regs *regs, long error_code);
16961 #endif /* _ASM_X86_PROCESSOR_H */
16962 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16963 index 942a086..6c26446 100644
16964 --- a/arch/x86/include/asm/ptrace.h
16965 +++ b/arch/x86/include/asm/ptrace.h
16966 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16967 }
16968
16969 /*
16970 - * user_mode_vm(regs) determines whether a register set came from user mode.
16971 + * user_mode(regs) determines whether a register set came from user mode.
16972 * This is true if V8086 mode was enabled OR if the register set was from
16973 * protected mode with RPL-3 CS value. This tricky test checks that with
16974 * one comparison. Many places in the kernel can bypass this full check
16975 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
16976 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
16977 + * be used.
16978 */
16979 -static inline int user_mode(struct pt_regs *regs)
16980 +static inline int user_mode_novm(struct pt_regs *regs)
16981 {
16982 #ifdef CONFIG_X86_32
16983 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
16984 #else
16985 - return !!(regs->cs & 3);
16986 + return !!(regs->cs & SEGMENT_RPL_MASK);
16987 #endif
16988 }
16989
16990 -static inline int user_mode_vm(struct pt_regs *regs)
16991 +static inline int user_mode(struct pt_regs *regs)
16992 {
16993 #ifdef CONFIG_X86_32
16994 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
16995 USER_RPL;
16996 #else
16997 - return user_mode(regs);
16998 + return user_mode_novm(regs);
16999 #endif
17000 }
17001
17002 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17003 #ifdef CONFIG_X86_64
17004 static inline bool user_64bit_mode(struct pt_regs *regs)
17005 {
17006 + unsigned long cs = regs->cs & 0xffff;
17007 #ifndef CONFIG_PARAVIRT
17008 /*
17009 * On non-paravirt systems, this is the only long mode CPL 3
17010 * selector. We do not allow long mode selectors in the LDT.
17011 */
17012 - return regs->cs == __USER_CS;
17013 + return cs == __USER_CS;
17014 #else
17015 /* Headers are too twisted for this to go in paravirt.h. */
17016 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17017 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17018 #endif
17019 }
17020
17021 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17022 * Traps from the kernel do not save sp and ss.
17023 * Use the helper function to retrieve sp.
17024 */
17025 - if (offset == offsetof(struct pt_regs, sp) &&
17026 - regs->cs == __KERNEL_CS)
17027 - return kernel_stack_pointer(regs);
17028 + if (offset == offsetof(struct pt_regs, sp)) {
17029 + unsigned long cs = regs->cs & 0xffff;
17030 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17031 + return kernel_stack_pointer(regs);
17032 + }
17033 #endif
17034 return *(unsigned long *)((unsigned long)regs + offset);
17035 }
17036 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17037 index 9c6b890..5305f53 100644
17038 --- a/arch/x86/include/asm/realmode.h
17039 +++ b/arch/x86/include/asm/realmode.h
17040 @@ -22,16 +22,14 @@ struct real_mode_header {
17041 #endif
17042 /* APM/BIOS reboot */
17043 u32 machine_real_restart_asm;
17044 -#ifdef CONFIG_X86_64
17045 u32 machine_real_restart_seg;
17046 -#endif
17047 };
17048
17049 /* This must match data at trampoline_32/64.S */
17050 struct trampoline_header {
17051 #ifdef CONFIG_X86_32
17052 u32 start;
17053 - u16 gdt_pad;
17054 + u16 boot_cs;
17055 u16 gdt_limit;
17056 u32 gdt_base;
17057 #else
17058 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17059 index a82c4f1..ac45053 100644
17060 --- a/arch/x86/include/asm/reboot.h
17061 +++ b/arch/x86/include/asm/reboot.h
17062 @@ -6,13 +6,13 @@
17063 struct pt_regs;
17064
17065 struct machine_ops {
17066 - void (*restart)(char *cmd);
17067 - void (*halt)(void);
17068 - void (*power_off)(void);
17069 + void (* __noreturn restart)(char *cmd);
17070 + void (* __noreturn halt)(void);
17071 + void (* __noreturn power_off)(void);
17072 void (*shutdown)(void);
17073 void (*crash_shutdown)(struct pt_regs *);
17074 - void (*emergency_restart)(void);
17075 -};
17076 + void (* __noreturn emergency_restart)(void);
17077 +} __no_const;
17078
17079 extern struct machine_ops machine_ops;
17080
17081 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17082 index cad82c9..2e5c5c1 100644
17083 --- a/arch/x86/include/asm/rwsem.h
17084 +++ b/arch/x86/include/asm/rwsem.h
17085 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17086 {
17087 asm volatile("# beginning down_read\n\t"
17088 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17089 +
17090 +#ifdef CONFIG_PAX_REFCOUNT
17091 + "jno 0f\n"
17092 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17093 + "int $4\n0:\n"
17094 + _ASM_EXTABLE(0b, 0b)
17095 +#endif
17096 +
17097 /* adds 0x00000001 */
17098 " jns 1f\n"
17099 " call call_rwsem_down_read_failed\n"
17100 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17101 "1:\n\t"
17102 " mov %1,%2\n\t"
17103 " add %3,%2\n\t"
17104 +
17105 +#ifdef CONFIG_PAX_REFCOUNT
17106 + "jno 0f\n"
17107 + "sub %3,%2\n"
17108 + "int $4\n0:\n"
17109 + _ASM_EXTABLE(0b, 0b)
17110 +#endif
17111 +
17112 " jle 2f\n\t"
17113 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17114 " jnz 1b\n\t"
17115 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17116 long tmp;
17117 asm volatile("# beginning down_write\n\t"
17118 LOCK_PREFIX " xadd %1,(%2)\n\t"
17119 +
17120 +#ifdef CONFIG_PAX_REFCOUNT
17121 + "jno 0f\n"
17122 + "mov %1,(%2)\n"
17123 + "int $4\n0:\n"
17124 + _ASM_EXTABLE(0b, 0b)
17125 +#endif
17126 +
17127 /* adds 0xffff0001, returns the old value */
17128 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17129 /* was the active mask 0 before? */
17130 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17131 long tmp;
17132 asm volatile("# beginning __up_read\n\t"
17133 LOCK_PREFIX " xadd %1,(%2)\n\t"
17134 +
17135 +#ifdef CONFIG_PAX_REFCOUNT
17136 + "jno 0f\n"
17137 + "mov %1,(%2)\n"
17138 + "int $4\n0:\n"
17139 + _ASM_EXTABLE(0b, 0b)
17140 +#endif
17141 +
17142 /* subtracts 1, returns the old value */
17143 " jns 1f\n\t"
17144 " call call_rwsem_wake\n" /* expects old value in %edx */
17145 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17146 long tmp;
17147 asm volatile("# beginning __up_write\n\t"
17148 LOCK_PREFIX " xadd %1,(%2)\n\t"
17149 +
17150 +#ifdef CONFIG_PAX_REFCOUNT
17151 + "jno 0f\n"
17152 + "mov %1,(%2)\n"
17153 + "int $4\n0:\n"
17154 + _ASM_EXTABLE(0b, 0b)
17155 +#endif
17156 +
17157 /* subtracts 0xffff0001, returns the old value */
17158 " jns 1f\n\t"
17159 " call call_rwsem_wake\n" /* expects old value in %edx */
17160 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17161 {
17162 asm volatile("# beginning __downgrade_write\n\t"
17163 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17164 +
17165 +#ifdef CONFIG_PAX_REFCOUNT
17166 + "jno 0f\n"
17167 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17168 + "int $4\n0:\n"
17169 + _ASM_EXTABLE(0b, 0b)
17170 +#endif
17171 +
17172 /*
17173 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17174 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17175 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17176 */
17177 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17178 {
17179 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17180 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17181 +
17182 +#ifdef CONFIG_PAX_REFCOUNT
17183 + "jno 0f\n"
17184 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17185 + "int $4\n0:\n"
17186 + _ASM_EXTABLE(0b, 0b)
17187 +#endif
17188 +
17189 : "+m" (sem->count)
17190 : "er" (delta));
17191 }
17192 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17193 */
17194 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17195 {
17196 - return delta + xadd(&sem->count, delta);
17197 + return delta + xadd_check_overflow(&sem->count, delta);
17198 }
17199
17200 #endif /* __KERNEL__ */
17201 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17202 index c48a950..bc40804 100644
17203 --- a/arch/x86/include/asm/segment.h
17204 +++ b/arch/x86/include/asm/segment.h
17205 @@ -64,10 +64,15 @@
17206 * 26 - ESPFIX small SS
17207 * 27 - per-cpu [ offset to per-cpu data area ]
17208 * 28 - stack_canary-20 [ for stack protector ]
17209 - * 29 - unused
17210 - * 30 - unused
17211 + * 29 - PCI BIOS CS
17212 + * 30 - PCI BIOS DS
17213 * 31 - TSS for double fault handler
17214 */
17215 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17216 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17217 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17218 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17219 +
17220 #define GDT_ENTRY_TLS_MIN 6
17221 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17222
17223 @@ -79,6 +84,8 @@
17224
17225 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17226
17227 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17228 +
17229 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17230
17231 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17232 @@ -104,6 +111,12 @@
17233 #define __KERNEL_STACK_CANARY 0
17234 #endif
17235
17236 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17237 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17238 +
17239 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17240 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17241 +
17242 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17243
17244 /*
17245 @@ -141,7 +154,7 @@
17246 */
17247
17248 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17249 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17250 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17251
17252
17253 #else
17254 @@ -165,6 +178,8 @@
17255 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17256 #define __USER32_DS __USER_DS
17257
17258 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17259 +
17260 #define GDT_ENTRY_TSS 8 /* needs two entries */
17261 #define GDT_ENTRY_LDT 10 /* needs two entries */
17262 #define GDT_ENTRY_TLS_MIN 12
17263 @@ -173,6 +188,8 @@
17264 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17265 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17266
17267 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17268 +
17269 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17270 #define FS_TLS 0
17271 #define GS_TLS 1
17272 @@ -180,12 +197,14 @@
17273 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17274 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17275
17276 -#define GDT_ENTRIES 16
17277 +#define GDT_ENTRIES 17
17278
17279 #endif
17280
17281 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17282 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17283 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17284 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17285 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17286 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17287 #ifndef CONFIG_PARAVIRT
17288 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17289 {
17290 unsigned long __limit;
17291 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17292 - return __limit + 1;
17293 + return __limit;
17294 }
17295
17296 #endif /* !__ASSEMBLY__ */
17297 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17298 index 8d3120f..352b440 100644
17299 --- a/arch/x86/include/asm/smap.h
17300 +++ b/arch/x86/include/asm/smap.h
17301 @@ -25,11 +25,40 @@
17302
17303 #include <asm/alternative-asm.h>
17304
17305 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17306 +#define ASM_PAX_OPEN_USERLAND \
17307 + 661: jmp 663f; \
17308 + .pushsection .altinstr_replacement, "a" ; \
17309 + 662: pushq %rax; nop; \
17310 + .popsection ; \
17311 + .pushsection .altinstructions, "a" ; \
17312 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17313 + .popsection ; \
17314 + call __pax_open_userland; \
17315 + popq %rax; \
17316 + 663:
17317 +
17318 +#define ASM_PAX_CLOSE_USERLAND \
17319 + 661: jmp 663f; \
17320 + .pushsection .altinstr_replacement, "a" ; \
17321 + 662: pushq %rax; nop; \
17322 + .popsection; \
17323 + .pushsection .altinstructions, "a" ; \
17324 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17325 + .popsection; \
17326 + call __pax_close_userland; \
17327 + popq %rax; \
17328 + 663:
17329 +#else
17330 +#define ASM_PAX_OPEN_USERLAND
17331 +#define ASM_PAX_CLOSE_USERLAND
17332 +#endif
17333 +
17334 #ifdef CONFIG_X86_SMAP
17335
17336 #define ASM_CLAC \
17337 661: ASM_NOP3 ; \
17338 - .pushsection .altinstr_replacement, "ax" ; \
17339 + .pushsection .altinstr_replacement, "a" ; \
17340 662: __ASM_CLAC ; \
17341 .popsection ; \
17342 .pushsection .altinstructions, "a" ; \
17343 @@ -38,7 +67,7 @@
17344
17345 #define ASM_STAC \
17346 661: ASM_NOP3 ; \
17347 - .pushsection .altinstr_replacement, "ax" ; \
17348 + .pushsection .altinstr_replacement, "a" ; \
17349 662: __ASM_STAC ; \
17350 .popsection ; \
17351 .pushsection .altinstructions, "a" ; \
17352 @@ -56,6 +85,37 @@
17353
17354 #include <asm/alternative.h>
17355
17356 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17357 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17358 +
17359 +extern void __pax_open_userland(void);
17360 +static __always_inline unsigned long pax_open_userland(void)
17361 +{
17362 +
17363 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17364 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17365 + :
17366 + : [open] "i" (__pax_open_userland)
17367 + : "memory", "rax");
17368 +#endif
17369 +
17370 + return 0;
17371 +}
17372 +
17373 +extern void __pax_close_userland(void);
17374 +static __always_inline unsigned long pax_close_userland(void)
17375 +{
17376 +
17377 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17378 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17379 + :
17380 + : [close] "i" (__pax_close_userland)
17381 + : "memory", "rax");
17382 +#endif
17383 +
17384 + return 0;
17385 +}
17386 +
17387 #ifdef CONFIG_X86_SMAP
17388
17389 static __always_inline void clac(void)
17390 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17391 index 4137890..03fa172 100644
17392 --- a/arch/x86/include/asm/smp.h
17393 +++ b/arch/x86/include/asm/smp.h
17394 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17395 /* cpus sharing the last level cache: */
17396 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17397 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17398 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17399 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17400
17401 static inline struct cpumask *cpu_sibling_mask(int cpu)
17402 {
17403 @@ -79,7 +79,7 @@ struct smp_ops {
17404
17405 void (*send_call_func_ipi)(const struct cpumask *mask);
17406 void (*send_call_func_single_ipi)(int cpu);
17407 -};
17408 +} __no_const;
17409
17410 /* Globals due to paravirt */
17411 extern void set_cpu_sibling_map(int cpu);
17412 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17413 extern int safe_smp_processor_id(void);
17414
17415 #elif defined(CONFIG_X86_64_SMP)
17416 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17417 -
17418 -#define stack_smp_processor_id() \
17419 -({ \
17420 - struct thread_info *ti; \
17421 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17422 - ti->cpu; \
17423 -})
17424 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17425 +#define stack_smp_processor_id() raw_smp_processor_id()
17426 #define safe_smp_processor_id() smp_processor_id()
17427
17428 #endif
17429 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17430 index e3ddd7d..3611fce 100644
17431 --- a/arch/x86/include/asm/spinlock.h
17432 +++ b/arch/x86/include/asm/spinlock.h
17433 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17434 static inline void arch_read_lock(arch_rwlock_t *rw)
17435 {
17436 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17437 +
17438 +#ifdef CONFIG_PAX_REFCOUNT
17439 + "jno 0f\n"
17440 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17441 + "int $4\n0:\n"
17442 + _ASM_EXTABLE(0b, 0b)
17443 +#endif
17444 +
17445 "jns 1f\n"
17446 "call __read_lock_failed\n\t"
17447 "1:\n"
17448 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17449 static inline void arch_write_lock(arch_rwlock_t *rw)
17450 {
17451 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17452 +
17453 +#ifdef CONFIG_PAX_REFCOUNT
17454 + "jno 0f\n"
17455 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17456 + "int $4\n0:\n"
17457 + _ASM_EXTABLE(0b, 0b)
17458 +#endif
17459 +
17460 "jz 1f\n"
17461 "call __write_lock_failed\n\t"
17462 "1:\n"
17463 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17464
17465 static inline void arch_read_unlock(arch_rwlock_t *rw)
17466 {
17467 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17468 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17469 +
17470 +#ifdef CONFIG_PAX_REFCOUNT
17471 + "jno 0f\n"
17472 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17473 + "int $4\n0:\n"
17474 + _ASM_EXTABLE(0b, 0b)
17475 +#endif
17476 +
17477 :"+m" (rw->lock) : : "memory");
17478 }
17479
17480 static inline void arch_write_unlock(arch_rwlock_t *rw)
17481 {
17482 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17483 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17484 +
17485 +#ifdef CONFIG_PAX_REFCOUNT
17486 + "jno 0f\n"
17487 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17488 + "int $4\n0:\n"
17489 + _ASM_EXTABLE(0b, 0b)
17490 +#endif
17491 +
17492 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17493 }
17494
17495 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17496 index 6a99859..03cb807 100644
17497 --- a/arch/x86/include/asm/stackprotector.h
17498 +++ b/arch/x86/include/asm/stackprotector.h
17499 @@ -47,7 +47,7 @@
17500 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17501 */
17502 #define GDT_STACK_CANARY_INIT \
17503 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17504 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17505
17506 /*
17507 * Initialize the stackprotector canary value.
17508 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17509
17510 static inline void load_stack_canary_segment(void)
17511 {
17512 -#ifdef CONFIG_X86_32
17513 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17514 asm volatile ("mov %0, %%gs" : : "r" (0));
17515 #endif
17516 }
17517 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17518 index 70bbe39..4ae2bd4 100644
17519 --- a/arch/x86/include/asm/stacktrace.h
17520 +++ b/arch/x86/include/asm/stacktrace.h
17521 @@ -11,28 +11,20 @@
17522
17523 extern int kstack_depth_to_print;
17524
17525 -struct thread_info;
17526 +struct task_struct;
17527 struct stacktrace_ops;
17528
17529 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17530 - unsigned long *stack,
17531 - unsigned long bp,
17532 - const struct stacktrace_ops *ops,
17533 - void *data,
17534 - unsigned long *end,
17535 - int *graph);
17536 +typedef unsigned long walk_stack_t(struct task_struct *task,
17537 + void *stack_start,
17538 + unsigned long *stack,
17539 + unsigned long bp,
17540 + const struct stacktrace_ops *ops,
17541 + void *data,
17542 + unsigned long *end,
17543 + int *graph);
17544
17545 -extern unsigned long
17546 -print_context_stack(struct thread_info *tinfo,
17547 - unsigned long *stack, unsigned long bp,
17548 - const struct stacktrace_ops *ops, void *data,
17549 - unsigned long *end, int *graph);
17550 -
17551 -extern unsigned long
17552 -print_context_stack_bp(struct thread_info *tinfo,
17553 - unsigned long *stack, unsigned long bp,
17554 - const struct stacktrace_ops *ops, void *data,
17555 - unsigned long *end, int *graph);
17556 +extern walk_stack_t print_context_stack;
17557 +extern walk_stack_t print_context_stack_bp;
17558
17559 /* Generic stack tracer with callbacks */
17560
17561 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17562 void (*address)(void *data, unsigned long address, int reliable);
17563 /* On negative return stop dumping */
17564 int (*stack)(void *data, char *name);
17565 - walk_stack_t walk_stack;
17566 + walk_stack_t *walk_stack;
17567 };
17568
17569 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17570 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17571 index 4ec45b3..a4f0a8a 100644
17572 --- a/arch/x86/include/asm/switch_to.h
17573 +++ b/arch/x86/include/asm/switch_to.h
17574 @@ -108,7 +108,7 @@ do { \
17575 "call __switch_to\n\t" \
17576 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17577 __switch_canary \
17578 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17579 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17580 "movq %%rax,%%rdi\n\t" \
17581 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17582 "jnz ret_from_fork\n\t" \
17583 @@ -119,7 +119,7 @@ do { \
17584 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17585 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17586 [_tif_fork] "i" (_TIF_FORK), \
17587 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17588 + [thread_info] "m" (current_tinfo), \
17589 [current_task] "m" (current_task) \
17590 __switch_canary_iparam \
17591 : "memory", "cc" __EXTRA_CLOBBER)
17592 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17593 index 2781119..618b59b 100644
17594 --- a/arch/x86/include/asm/thread_info.h
17595 +++ b/arch/x86/include/asm/thread_info.h
17596 @@ -10,6 +10,7 @@
17597 #include <linux/compiler.h>
17598 #include <asm/page.h>
17599 #include <asm/types.h>
17600 +#include <asm/percpu.h>
17601
17602 /*
17603 * low level task data that entry.S needs immediate access to
17604 @@ -23,7 +24,6 @@ struct exec_domain;
17605 #include <linux/atomic.h>
17606
17607 struct thread_info {
17608 - struct task_struct *task; /* main task structure */
17609 struct exec_domain *exec_domain; /* execution domain */
17610 __u32 flags; /* low level flags */
17611 __u32 status; /* thread synchronous flags */
17612 @@ -33,19 +33,13 @@ struct thread_info {
17613 mm_segment_t addr_limit;
17614 struct restart_block restart_block;
17615 void __user *sysenter_return;
17616 -#ifdef CONFIG_X86_32
17617 - unsigned long previous_esp; /* ESP of the previous stack in
17618 - case of nested (IRQ) stacks
17619 - */
17620 - __u8 supervisor_stack[0];
17621 -#endif
17622 + unsigned long lowest_stack;
17623 unsigned int sig_on_uaccess_error:1;
17624 unsigned int uaccess_err:1; /* uaccess failed */
17625 };
17626
17627 -#define INIT_THREAD_INFO(tsk) \
17628 +#define INIT_THREAD_INFO \
17629 { \
17630 - .task = &tsk, \
17631 .exec_domain = &default_exec_domain, \
17632 .flags = 0, \
17633 .cpu = 0, \
17634 @@ -56,7 +50,7 @@ struct thread_info {
17635 }, \
17636 }
17637
17638 -#define init_thread_info (init_thread_union.thread_info)
17639 +#define init_thread_info (init_thread_union.stack)
17640 #define init_stack (init_thread_union.stack)
17641
17642 #else /* !__ASSEMBLY__ */
17643 @@ -96,6 +90,7 @@ struct thread_info {
17644 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17645 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17646 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17647 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17648
17649 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17650 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17651 @@ -119,17 +114,18 @@ struct thread_info {
17652 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17653 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17654 #define _TIF_X32 (1 << TIF_X32)
17655 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17656
17657 /* work to do in syscall_trace_enter() */
17658 #define _TIF_WORK_SYSCALL_ENTRY \
17659 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17660 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17661 - _TIF_NOHZ)
17662 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17663
17664 /* work to do in syscall_trace_leave() */
17665 #define _TIF_WORK_SYSCALL_EXIT \
17666 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17667 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17668 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17669
17670 /* work to do on interrupt/exception return */
17671 #define _TIF_WORK_MASK \
17672 @@ -140,7 +136,7 @@ struct thread_info {
17673 /* work to do on any return to user space */
17674 #define _TIF_ALLWORK_MASK \
17675 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17676 - _TIF_NOHZ)
17677 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17678
17679 /* Only used for 64 bit */
17680 #define _TIF_DO_NOTIFY_MASK \
17681 @@ -156,45 +152,40 @@ struct thread_info {
17682
17683 #define PREEMPT_ACTIVE 0x10000000
17684
17685 -#ifdef CONFIG_X86_32
17686 -
17687 -#define STACK_WARN (THREAD_SIZE/8)
17688 -/*
17689 - * macros/functions for gaining access to the thread information structure
17690 - *
17691 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17692 - */
17693 -#ifndef __ASSEMBLY__
17694 -
17695 -
17696 -/* how to get the current stack pointer from C */
17697 -register unsigned long current_stack_pointer asm("esp") __used;
17698 -
17699 -/* how to get the thread information struct from C */
17700 -static inline struct thread_info *current_thread_info(void)
17701 -{
17702 - return (struct thread_info *)
17703 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17704 -}
17705 -
17706 -#else /* !__ASSEMBLY__ */
17707 -
17708 +#ifdef __ASSEMBLY__
17709 /* how to get the thread information struct from ASM */
17710 #define GET_THREAD_INFO(reg) \
17711 - movl $-THREAD_SIZE, reg; \
17712 - andl %esp, reg
17713 + mov PER_CPU_VAR(current_tinfo), reg
17714
17715 /* use this one if reg already contains %esp */
17716 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17717 - andl $-THREAD_SIZE, reg
17718 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17719 +#else
17720 +/* how to get the thread information struct from C */
17721 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17722 +
17723 +static __always_inline struct thread_info *current_thread_info(void)
17724 +{
17725 + return this_cpu_read_stable(current_tinfo);
17726 +}
17727 +#endif
17728 +
17729 +#ifdef CONFIG_X86_32
17730 +
17731 +#define STACK_WARN (THREAD_SIZE/8)
17732 +/*
17733 + * macros/functions for gaining access to the thread information structure
17734 + *
17735 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17736 + */
17737 +#ifndef __ASSEMBLY__
17738 +
17739 +/* how to get the current stack pointer from C */
17740 +register unsigned long current_stack_pointer asm("esp") __used;
17741
17742 #endif
17743
17744 #else /* X86_32 */
17745
17746 -#include <asm/percpu.h>
17747 -#define KERNEL_STACK_OFFSET (5*8)
17748 -
17749 /*
17750 * macros/functions for gaining access to the thread information structure
17751 * preempt_count needs to be 1 initially, until the scheduler is functional.
17752 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17753 #ifndef __ASSEMBLY__
17754 DECLARE_PER_CPU(unsigned long, kernel_stack);
17755
17756 -static inline struct thread_info *current_thread_info(void)
17757 -{
17758 - struct thread_info *ti;
17759 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17760 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17761 - return ti;
17762 -}
17763 -
17764 -#else /* !__ASSEMBLY__ */
17765 -
17766 -/* how to get the thread information struct from ASM */
17767 -#define GET_THREAD_INFO(reg) \
17768 - movq PER_CPU_VAR(kernel_stack),reg ; \
17769 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17770 -
17771 -/*
17772 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17773 - * a certain register (to be used in assembler memory operands).
17774 - */
17775 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17776 -
17777 +/* how to get the current stack pointer from C */
17778 +register unsigned long current_stack_pointer asm("rsp") __used;
17779 #endif
17780
17781 #endif /* !X86_32 */
17782 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17783 extern void arch_task_cache_init(void);
17784 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17785 extern void arch_release_task_struct(struct task_struct *tsk);
17786 +
17787 +#define __HAVE_THREAD_FUNCTIONS
17788 +#define task_thread_info(task) (&(task)->tinfo)
17789 +#define task_stack_page(task) ((task)->stack)
17790 +#define setup_thread_stack(p, org) do {} while (0)
17791 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17792 +
17793 #endif
17794 #endif /* _ASM_X86_THREAD_INFO_H */
17795 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17796 index cf51200..63ff068 100644
17797 --- a/arch/x86/include/asm/tlbflush.h
17798 +++ b/arch/x86/include/asm/tlbflush.h
17799 @@ -17,18 +17,44 @@
17800
17801 static inline void __native_flush_tlb(void)
17802 {
17803 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17804 + u64 descriptor[2];
17805 +
17806 + descriptor[0] = PCID_KERNEL;
17807 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17808 + return;
17809 + }
17810 +
17811 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17812 + if (static_cpu_has(X86_FEATURE_PCID)) {
17813 + unsigned int cpu = raw_get_cpu();
17814 +
17815 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17816 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17817 + raw_put_cpu_no_resched();
17818 + return;
17819 + }
17820 +#endif
17821 +
17822 native_write_cr3(native_read_cr3());
17823 }
17824
17825 static inline void __native_flush_tlb_global_irq_disabled(void)
17826 {
17827 - unsigned long cr4;
17828 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17829 + u64 descriptor[2];
17830
17831 - cr4 = native_read_cr4();
17832 - /* clear PGE */
17833 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17834 - /* write old PGE again and flush TLBs */
17835 - native_write_cr4(cr4);
17836 + descriptor[0] = PCID_KERNEL;
17837 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17838 + } else {
17839 + unsigned long cr4;
17840 +
17841 + cr4 = native_read_cr4();
17842 + /* clear PGE */
17843 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17844 + /* write old PGE again and flush TLBs */
17845 + native_write_cr4(cr4);
17846 + }
17847 }
17848
17849 static inline void __native_flush_tlb_global(void)
17850 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17851
17852 static inline void __native_flush_tlb_single(unsigned long addr)
17853 {
17854 +
17855 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17856 + u64 descriptor[2];
17857 +
17858 + descriptor[0] = PCID_KERNEL;
17859 + descriptor[1] = addr;
17860 +
17861 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17862 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17863 + if (addr < TASK_SIZE_MAX)
17864 + descriptor[1] += pax_user_shadow_base;
17865 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17866 + }
17867 +
17868 + descriptor[0] = PCID_USER;
17869 + descriptor[1] = addr;
17870 +#endif
17871 +
17872 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17873 + return;
17874 + }
17875 +
17876 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17877 + if (static_cpu_has(X86_FEATURE_PCID)) {
17878 + unsigned int cpu = raw_get_cpu();
17879 +
17880 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17881 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17882 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17883 + raw_put_cpu_no_resched();
17884 +
17885 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17886 + addr += pax_user_shadow_base;
17887 + }
17888 +#endif
17889 +
17890 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17891 }
17892
17893 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17894 index 5ee2687..74590b9 100644
17895 --- a/arch/x86/include/asm/uaccess.h
17896 +++ b/arch/x86/include/asm/uaccess.h
17897 @@ -7,6 +7,7 @@
17898 #include <linux/compiler.h>
17899 #include <linux/thread_info.h>
17900 #include <linux/string.h>
17901 +#include <linux/sched.h>
17902 #include <asm/asm.h>
17903 #include <asm/page.h>
17904 #include <asm/smap.h>
17905 @@ -29,7 +30,12 @@
17906
17907 #define get_ds() (KERNEL_DS)
17908 #define get_fs() (current_thread_info()->addr_limit)
17909 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17910 +void __set_fs(mm_segment_t x);
17911 +void set_fs(mm_segment_t x);
17912 +#else
17913 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17914 +#endif
17915
17916 #define segment_eq(a, b) ((a).seg == (b).seg)
17917
17918 @@ -77,8 +83,33 @@
17919 * checks that the pointer is in the user space range - after calling
17920 * this function, memory access functions may still return -EFAULT.
17921 */
17922 -#define access_ok(type, addr, size) \
17923 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17924 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17925 +#define access_ok(type, addr, size) \
17926 +({ \
17927 + long __size = size; \
17928 + unsigned long __addr = (unsigned long)addr; \
17929 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17930 + unsigned long __end_ao = __addr + __size - 1; \
17931 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17932 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17933 + while(__addr_ao <= __end_ao) { \
17934 + char __c_ao; \
17935 + __addr_ao += PAGE_SIZE; \
17936 + if (__size > PAGE_SIZE) \
17937 + cond_resched(); \
17938 + if (__get_user(__c_ao, (char __user *)__addr)) \
17939 + break; \
17940 + if (type != VERIFY_WRITE) { \
17941 + __addr = __addr_ao; \
17942 + continue; \
17943 + } \
17944 + if (__put_user(__c_ao, (char __user *)__addr)) \
17945 + break; \
17946 + __addr = __addr_ao; \
17947 + } \
17948 + } \
17949 + __ret_ao; \
17950 +})
17951
17952 /*
17953 * The exception table consists of pairs of addresses relative to the
17954 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17955 register __inttype(*(ptr)) __val_gu asm("%edx"); \
17956 __chk_user_ptr(ptr); \
17957 might_fault(); \
17958 + pax_open_userland(); \
17959 asm volatile("call __get_user_%P3" \
17960 : "=a" (__ret_gu), "=r" (__val_gu) \
17961 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17962 (x) = (__typeof__(*(ptr))) __val_gu; \
17963 + pax_close_userland(); \
17964 __ret_gu; \
17965 })
17966
17967 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17968 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17969 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17970
17971 -
17972 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17973 +#define __copyuser_seg "gs;"
17974 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17975 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
17976 +#else
17977 +#define __copyuser_seg
17978 +#define __COPYUSER_SET_ES
17979 +#define __COPYUSER_RESTORE_ES
17980 +#endif
17981
17982 #ifdef CONFIG_X86_32
17983 #define __put_user_asm_u64(x, addr, err, errret) \
17984 asm volatile(ASM_STAC "\n" \
17985 - "1: movl %%eax,0(%2)\n" \
17986 - "2: movl %%edx,4(%2)\n" \
17987 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
17988 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
17989 "3: " ASM_CLAC "\n" \
17990 ".section .fixup,\"ax\"\n" \
17991 "4: movl %3,%0\n" \
17992 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17993
17994 #define __put_user_asm_ex_u64(x, addr) \
17995 asm volatile(ASM_STAC "\n" \
17996 - "1: movl %%eax,0(%1)\n" \
17997 - "2: movl %%edx,4(%1)\n" \
17998 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
17999 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18000 "3: " ASM_CLAC "\n" \
18001 _ASM_EXTABLE_EX(1b, 2b) \
18002 _ASM_EXTABLE_EX(2b, 3b) \
18003 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
18004 __typeof__(*(ptr)) __pu_val; \
18005 __chk_user_ptr(ptr); \
18006 might_fault(); \
18007 - __pu_val = x; \
18008 + __pu_val = (x); \
18009 + pax_open_userland(); \
18010 switch (sizeof(*(ptr))) { \
18011 case 1: \
18012 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18013 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
18014 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18015 break; \
18016 } \
18017 + pax_close_userland(); \
18018 __ret_pu; \
18019 })
18020
18021 @@ -344,8 +387,10 @@ do { \
18022 } while (0)
18023
18024 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18025 +do { \
18026 + pax_open_userland(); \
18027 asm volatile(ASM_STAC "\n" \
18028 - "1: mov"itype" %2,%"rtype"1\n" \
18029 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18030 "2: " ASM_CLAC "\n" \
18031 ".section .fixup,\"ax\"\n" \
18032 "3: mov %3,%0\n" \
18033 @@ -353,8 +398,10 @@ do { \
18034 " jmp 2b\n" \
18035 ".previous\n" \
18036 _ASM_EXTABLE(1b, 3b) \
18037 - : "=r" (err), ltype(x) \
18038 - : "m" (__m(addr)), "i" (errret), "0" (err))
18039 + : "=r" (err), ltype (x) \
18040 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18041 + pax_close_userland(); \
18042 +} while (0)
18043
18044 #define __get_user_size_ex(x, ptr, size) \
18045 do { \
18046 @@ -378,7 +425,7 @@ do { \
18047 } while (0)
18048
18049 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18050 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18051 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18052 "2:\n" \
18053 _ASM_EXTABLE_EX(1b, 2b) \
18054 : ltype(x) : "m" (__m(addr)))
18055 @@ -395,13 +442,24 @@ do { \
18056 int __gu_err; \
18057 unsigned long __gu_val; \
18058 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18059 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18060 + (x) = (__typeof__(*(ptr)))__gu_val; \
18061 __gu_err; \
18062 })
18063
18064 /* FIXME: this hack is definitely wrong -AK */
18065 struct __large_struct { unsigned long buf[100]; };
18066 -#define __m(x) (*(struct __large_struct __user *)(x))
18067 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18068 +#define ____m(x) \
18069 +({ \
18070 + unsigned long ____x = (unsigned long)(x); \
18071 + if (____x < pax_user_shadow_base) \
18072 + ____x += pax_user_shadow_base; \
18073 + (typeof(x))____x; \
18074 +})
18075 +#else
18076 +#define ____m(x) (x)
18077 +#endif
18078 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18079
18080 /*
18081 * Tell gcc we read from memory instead of writing: this is because
18082 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
18083 * aliasing issues.
18084 */
18085 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18086 +do { \
18087 + pax_open_userland(); \
18088 asm volatile(ASM_STAC "\n" \
18089 - "1: mov"itype" %"rtype"1,%2\n" \
18090 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18091 "2: " ASM_CLAC "\n" \
18092 ".section .fixup,\"ax\"\n" \
18093 "3: mov %3,%0\n" \
18094 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
18095 ".previous\n" \
18096 _ASM_EXTABLE(1b, 3b) \
18097 : "=r"(err) \
18098 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18099 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18100 + pax_close_userland(); \
18101 +} while (0)
18102
18103 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18104 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18105 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18106 "2:\n" \
18107 _ASM_EXTABLE_EX(1b, 2b) \
18108 : : ltype(x), "m" (__m(addr)))
18109 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
18110 */
18111 #define uaccess_try do { \
18112 current_thread_info()->uaccess_err = 0; \
18113 + pax_open_userland(); \
18114 stac(); \
18115 barrier();
18116
18117 #define uaccess_catch(err) \
18118 clac(); \
18119 + pax_close_userland(); \
18120 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18121 } while (0)
18122
18123 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
18124 * On error, the variable @x is set to zero.
18125 */
18126
18127 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18128 +#define __get_user(x, ptr) get_user((x), (ptr))
18129 +#else
18130 #define __get_user(x, ptr) \
18131 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18132 +#endif
18133
18134 /**
18135 * __put_user: - Write a simple value into user space, with less checking.
18136 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
18137 * Returns zero on success, or -EFAULT on error.
18138 */
18139
18140 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18141 +#define __put_user(x, ptr) put_user((x), (ptr))
18142 +#else
18143 #define __put_user(x, ptr) \
18144 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18145 +#endif
18146
18147 #define __get_user_unaligned __get_user
18148 #define __put_user_unaligned __put_user
18149 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
18150 #define get_user_ex(x, ptr) do { \
18151 unsigned long __gue_val; \
18152 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18153 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18154 + (x) = (__typeof__(*(ptr)))__gue_val; \
18155 } while (0)
18156
18157 #define put_user_try uaccess_try
18158 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
18159 extern __must_check long strlen_user(const char __user *str);
18160 extern __must_check long strnlen_user(const char __user *str, long n);
18161
18162 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
18163 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
18164 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18165 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18166
18167 /*
18168 * movsl can be slow when source and dest are not both 8-byte aligned
18169 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18170 index 7f760a9..04b1c65 100644
18171 --- a/arch/x86/include/asm/uaccess_32.h
18172 +++ b/arch/x86/include/asm/uaccess_32.h
18173 @@ -11,15 +11,15 @@
18174 #include <asm/page.h>
18175
18176 unsigned long __must_check __copy_to_user_ll
18177 - (void __user *to, const void *from, unsigned long n);
18178 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
18179 unsigned long __must_check __copy_from_user_ll
18180 - (void *to, const void __user *from, unsigned long n);
18181 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18182 unsigned long __must_check __copy_from_user_ll_nozero
18183 - (void *to, const void __user *from, unsigned long n);
18184 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18185 unsigned long __must_check __copy_from_user_ll_nocache
18186 - (void *to, const void __user *from, unsigned long n);
18187 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18188 unsigned long __must_check __copy_from_user_ll_nocache_nozero
18189 - (void *to, const void __user *from, unsigned long n);
18190 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18191
18192 /**
18193 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
18194 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18195 static __always_inline unsigned long __must_check
18196 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18197 {
18198 + if ((long)n < 0)
18199 + return n;
18200 +
18201 + check_object_size(from, n, true);
18202 +
18203 if (__builtin_constant_p(n)) {
18204 unsigned long ret;
18205
18206 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18207 __copy_to_user(void __user *to, const void *from, unsigned long n)
18208 {
18209 might_fault();
18210 +
18211 return __copy_to_user_inatomic(to, from, n);
18212 }
18213
18214 static __always_inline unsigned long
18215 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18216 {
18217 + if ((long)n < 0)
18218 + return n;
18219 +
18220 /* Avoid zeroing the tail if the copy fails..
18221 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18222 * but as the zeroing behaviour is only significant when n is not
18223 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18224 __copy_from_user(void *to, const void __user *from, unsigned long n)
18225 {
18226 might_fault();
18227 +
18228 + if ((long)n < 0)
18229 + return n;
18230 +
18231 + check_object_size(to, n, false);
18232 +
18233 if (__builtin_constant_p(n)) {
18234 unsigned long ret;
18235
18236 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18237 const void __user *from, unsigned long n)
18238 {
18239 might_fault();
18240 +
18241 + if ((long)n < 0)
18242 + return n;
18243 +
18244 if (__builtin_constant_p(n)) {
18245 unsigned long ret;
18246
18247 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18248 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18249 unsigned long n)
18250 {
18251 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18252 + if ((long)n < 0)
18253 + return n;
18254 +
18255 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18256 }
18257
18258 -unsigned long __must_check copy_to_user(void __user *to,
18259 - const void *from, unsigned long n);
18260 -unsigned long __must_check _copy_from_user(void *to,
18261 - const void __user *from,
18262 - unsigned long n);
18263 -
18264 +extern void copy_to_user_overflow(void)
18265 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18266 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18267 +#else
18268 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18269 +#endif
18270 +;
18271
18272 extern void copy_from_user_overflow(void)
18273 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18274 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18275 #endif
18276 ;
18277
18278 -static inline unsigned long __must_check copy_from_user(void *to,
18279 - const void __user *from,
18280 - unsigned long n)
18281 +/**
18282 + * copy_to_user: - Copy a block of data into user space.
18283 + * @to: Destination address, in user space.
18284 + * @from: Source address, in kernel space.
18285 + * @n: Number of bytes to copy.
18286 + *
18287 + * Context: User context only. This function may sleep.
18288 + *
18289 + * Copy data from kernel space to user space.
18290 + *
18291 + * Returns number of bytes that could not be copied.
18292 + * On success, this will be zero.
18293 + */
18294 +static inline unsigned long __must_check
18295 +copy_to_user(void __user *to, const void *from, unsigned long n)
18296 {
18297 - int sz = __compiletime_object_size(to);
18298 + size_t sz = __compiletime_object_size(from);
18299
18300 - if (likely(sz == -1 || sz >= n))
18301 - n = _copy_from_user(to, from, n);
18302 - else
18303 + if (unlikely(sz != (size_t)-1 && sz < n))
18304 + copy_to_user_overflow();
18305 + else if (access_ok(VERIFY_WRITE, to, n))
18306 + n = __copy_to_user(to, from, n);
18307 + return n;
18308 +}
18309 +
18310 +/**
18311 + * copy_from_user: - Copy a block of data from user space.
18312 + * @to: Destination address, in kernel space.
18313 + * @from: Source address, in user space.
18314 + * @n: Number of bytes to copy.
18315 + *
18316 + * Context: User context only. This function may sleep.
18317 + *
18318 + * Copy data from user space to kernel space.
18319 + *
18320 + * Returns number of bytes that could not be copied.
18321 + * On success, this will be zero.
18322 + *
18323 + * If some data could not be copied, this function will pad the copied
18324 + * data to the requested size using zero bytes.
18325 + */
18326 +static inline unsigned long __must_check
18327 +copy_from_user(void *to, const void __user *from, unsigned long n)
18328 +{
18329 + size_t sz = __compiletime_object_size(to);
18330 +
18331 + check_object_size(to, n, false);
18332 +
18333 + if (unlikely(sz != (size_t)-1 && sz < n))
18334 copy_from_user_overflow();
18335 -
18336 + else if (access_ok(VERIFY_READ, from, n))
18337 + n = __copy_from_user(to, from, n);
18338 + else if ((long)n > 0)
18339 + memset(to, 0, n);
18340 return n;
18341 }
18342
18343 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18344 index 4f7923d..d3526c1 100644
18345 --- a/arch/x86/include/asm/uaccess_64.h
18346 +++ b/arch/x86/include/asm/uaccess_64.h
18347 @@ -10,6 +10,9 @@
18348 #include <asm/alternative.h>
18349 #include <asm/cpufeature.h>
18350 #include <asm/page.h>
18351 +#include <asm/pgtable.h>
18352 +
18353 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18354
18355 /*
18356 * Copy To/From Userspace
18357 @@ -17,14 +20,14 @@
18358
18359 /* Handles exceptions in both to and from, but doesn't do access_ok */
18360 __must_check unsigned long
18361 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18362 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18363 __must_check unsigned long
18364 -copy_user_generic_string(void *to, const void *from, unsigned len);
18365 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18366 __must_check unsigned long
18367 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18368 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18369
18370 -static __always_inline __must_check unsigned long
18371 -copy_user_generic(void *to, const void *from, unsigned len)
18372 +static __always_inline __must_check __size_overflow(3) unsigned long
18373 +copy_user_generic(void *to, const void *from, unsigned long len)
18374 {
18375 unsigned ret;
18376
18377 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
18378 return ret;
18379 }
18380
18381 +static __always_inline __must_check unsigned long
18382 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18383 +static __always_inline __must_check unsigned long
18384 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18385 __must_check unsigned long
18386 -_copy_to_user(void __user *to, const void *from, unsigned len);
18387 -__must_check unsigned long
18388 -_copy_from_user(void *to, const void __user *from, unsigned len);
18389 -__must_check unsigned long
18390 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18391 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18392 +
18393 +extern void copy_to_user_overflow(void)
18394 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18395 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18396 +#else
18397 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18398 +#endif
18399 +;
18400 +
18401 +extern void copy_from_user_overflow(void)
18402 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18403 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18404 +#else
18405 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18406 +#endif
18407 +;
18408
18409 static inline unsigned long __must_check copy_from_user(void *to,
18410 const void __user *from,
18411 unsigned long n)
18412 {
18413 - int sz = __compiletime_object_size(to);
18414 -
18415 might_fault();
18416 - if (likely(sz == -1 || sz >= n))
18417 - n = _copy_from_user(to, from, n);
18418 -#ifdef CONFIG_DEBUG_VM
18419 - else
18420 - WARN(1, "Buffer overflow detected!\n");
18421 -#endif
18422 +
18423 + check_object_size(to, n, false);
18424 +
18425 + if (access_ok(VERIFY_READ, from, n))
18426 + n = __copy_from_user(to, from, n);
18427 + else if (n < INT_MAX)
18428 + memset(to, 0, n);
18429 return n;
18430 }
18431
18432 static __always_inline __must_check
18433 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18434 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18435 {
18436 might_fault();
18437
18438 - return _copy_to_user(dst, src, size);
18439 + if (access_ok(VERIFY_WRITE, dst, size))
18440 + size = __copy_to_user(dst, src, size);
18441 + return size;
18442 }
18443
18444 static __always_inline __must_check
18445 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18446 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18447 {
18448 - int ret = 0;
18449 + size_t sz = __compiletime_object_size(dst);
18450 + unsigned ret = 0;
18451
18452 might_fault();
18453 +
18454 + if (size > INT_MAX)
18455 + return size;
18456 +
18457 + check_object_size(dst, size, false);
18458 +
18459 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18460 + if (!__access_ok(VERIFY_READ, src, size))
18461 + return size;
18462 +#endif
18463 +
18464 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18465 + copy_from_user_overflow();
18466 + return size;
18467 + }
18468 +
18469 if (!__builtin_constant_p(size))
18470 - return copy_user_generic(dst, (__force void *)src, size);
18471 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18472 switch (size) {
18473 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18474 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18475 ret, "b", "b", "=q", 1);
18476 return ret;
18477 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18478 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18479 ret, "w", "w", "=r", 2);
18480 return ret;
18481 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18482 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18483 ret, "l", "k", "=r", 4);
18484 return ret;
18485 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18486 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18487 ret, "q", "", "=r", 8);
18488 return ret;
18489 case 10:
18490 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18491 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18492 ret, "q", "", "=r", 10);
18493 if (unlikely(ret))
18494 return ret;
18495 __get_user_asm(*(u16 *)(8 + (char *)dst),
18496 - (u16 __user *)(8 + (char __user *)src),
18497 + (const u16 __user *)(8 + (const char __user *)src),
18498 ret, "w", "w", "=r", 2);
18499 return ret;
18500 case 16:
18501 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18502 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18503 ret, "q", "", "=r", 16);
18504 if (unlikely(ret))
18505 return ret;
18506 __get_user_asm(*(u64 *)(8 + (char *)dst),
18507 - (u64 __user *)(8 + (char __user *)src),
18508 + (const u64 __user *)(8 + (const char __user *)src),
18509 ret, "q", "", "=r", 8);
18510 return ret;
18511 default:
18512 - return copy_user_generic(dst, (__force void *)src, size);
18513 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18514 }
18515 }
18516
18517 static __always_inline __must_check
18518 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18519 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18520 {
18521 - int ret = 0;
18522 + size_t sz = __compiletime_object_size(src);
18523 + unsigned ret = 0;
18524
18525 might_fault();
18526 +
18527 + if (size > INT_MAX)
18528 + return size;
18529 +
18530 + check_object_size(src, size, true);
18531 +
18532 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18533 + if (!__access_ok(VERIFY_WRITE, dst, size))
18534 + return size;
18535 +#endif
18536 +
18537 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18538 + copy_to_user_overflow();
18539 + return size;
18540 + }
18541 +
18542 if (!__builtin_constant_p(size))
18543 - return copy_user_generic((__force void *)dst, src, size);
18544 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18545 switch (size) {
18546 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18547 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18548 ret, "b", "b", "iq", 1);
18549 return ret;
18550 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18551 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18552 ret, "w", "w", "ir", 2);
18553 return ret;
18554 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18555 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18556 ret, "l", "k", "ir", 4);
18557 return ret;
18558 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18559 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18560 ret, "q", "", "er", 8);
18561 return ret;
18562 case 10:
18563 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18564 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18565 ret, "q", "", "er", 10);
18566 if (unlikely(ret))
18567 return ret;
18568 asm("":::"memory");
18569 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18570 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18571 ret, "w", "w", "ir", 2);
18572 return ret;
18573 case 16:
18574 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18575 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18576 ret, "q", "", "er", 16);
18577 if (unlikely(ret))
18578 return ret;
18579 asm("":::"memory");
18580 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18581 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18582 ret, "q", "", "er", 8);
18583 return ret;
18584 default:
18585 - return copy_user_generic((__force void *)dst, src, size);
18586 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18587 }
18588 }
18589
18590 static __always_inline __must_check
18591 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18592 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18593 {
18594 - int ret = 0;
18595 + unsigned ret = 0;
18596
18597 might_fault();
18598 +
18599 + if (size > INT_MAX)
18600 + return size;
18601 +
18602 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18603 + if (!__access_ok(VERIFY_READ, src, size))
18604 + return size;
18605 + if (!__access_ok(VERIFY_WRITE, dst, size))
18606 + return size;
18607 +#endif
18608 +
18609 if (!__builtin_constant_p(size))
18610 - return copy_user_generic((__force void *)dst,
18611 - (__force void *)src, size);
18612 + return copy_user_generic((__force_kernel void *)____m(dst),
18613 + (__force_kernel const void *)____m(src), size);
18614 switch (size) {
18615 case 1: {
18616 u8 tmp;
18617 - __get_user_asm(tmp, (u8 __user *)src,
18618 + __get_user_asm(tmp, (const u8 __user *)src,
18619 ret, "b", "b", "=q", 1);
18620 if (likely(!ret))
18621 __put_user_asm(tmp, (u8 __user *)dst,
18622 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18623 }
18624 case 2: {
18625 u16 tmp;
18626 - __get_user_asm(tmp, (u16 __user *)src,
18627 + __get_user_asm(tmp, (const u16 __user *)src,
18628 ret, "w", "w", "=r", 2);
18629 if (likely(!ret))
18630 __put_user_asm(tmp, (u16 __user *)dst,
18631 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18632
18633 case 4: {
18634 u32 tmp;
18635 - __get_user_asm(tmp, (u32 __user *)src,
18636 + __get_user_asm(tmp, (const u32 __user *)src,
18637 ret, "l", "k", "=r", 4);
18638 if (likely(!ret))
18639 __put_user_asm(tmp, (u32 __user *)dst,
18640 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18641 }
18642 case 8: {
18643 u64 tmp;
18644 - __get_user_asm(tmp, (u64 __user *)src,
18645 + __get_user_asm(tmp, (const u64 __user *)src,
18646 ret, "q", "", "=r", 8);
18647 if (likely(!ret))
18648 __put_user_asm(tmp, (u64 __user *)dst,
18649 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18650 return ret;
18651 }
18652 default:
18653 - return copy_user_generic((__force void *)dst,
18654 - (__force void *)src, size);
18655 + return copy_user_generic((__force_kernel void *)____m(dst),
18656 + (__force_kernel const void *)____m(src), size);
18657 }
18658 }
18659
18660 -static __must_check __always_inline int
18661 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18662 +static __must_check __always_inline unsigned long
18663 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18664 {
18665 - return copy_user_generic(dst, (__force const void *)src, size);
18666 + if (size > INT_MAX)
18667 + return size;
18668 +
18669 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18670 + if (!__access_ok(VERIFY_READ, src, size))
18671 + return size;
18672 +#endif
18673 +
18674 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18675 }
18676
18677 -static __must_check __always_inline int
18678 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18679 +static __must_check __always_inline unsigned long
18680 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18681 {
18682 - return copy_user_generic((__force void *)dst, src, size);
18683 + if (size > INT_MAX)
18684 + return size;
18685 +
18686 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18687 + if (!__access_ok(VERIFY_WRITE, dst, size))
18688 + return size;
18689 +#endif
18690 +
18691 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18692 }
18693
18694 -extern long __copy_user_nocache(void *dst, const void __user *src,
18695 - unsigned size, int zerorest);
18696 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18697 + unsigned long size, int zerorest) __size_overflow(3);
18698
18699 -static inline int
18700 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18701 +static inline unsigned long
18702 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18703 {
18704 might_fault();
18705 +
18706 + if (size > INT_MAX)
18707 + return size;
18708 +
18709 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18710 + if (!__access_ok(VERIFY_READ, src, size))
18711 + return size;
18712 +#endif
18713 +
18714 return __copy_user_nocache(dst, src, size, 1);
18715 }
18716
18717 -static inline int
18718 +static inline unsigned long
18719 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18720 - unsigned size)
18721 + unsigned long size)
18722 {
18723 + if (size > INT_MAX)
18724 + return size;
18725 +
18726 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18727 + if (!__access_ok(VERIFY_READ, src, size))
18728 + return size;
18729 +#endif
18730 +
18731 return __copy_user_nocache(dst, src, size, 0);
18732 }
18733
18734 unsigned long
18735 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18736 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18737
18738 #endif /* _ASM_X86_UACCESS_64_H */
18739 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18740 index 5b238981..77fdd78 100644
18741 --- a/arch/x86/include/asm/word-at-a-time.h
18742 +++ b/arch/x86/include/asm/word-at-a-time.h
18743 @@ -11,7 +11,7 @@
18744 * and shift, for example.
18745 */
18746 struct word_at_a_time {
18747 - const unsigned long one_bits, high_bits;
18748 + unsigned long one_bits, high_bits;
18749 };
18750
18751 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18752 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18753 index 828a156..650e625 100644
18754 --- a/arch/x86/include/asm/x86_init.h
18755 +++ b/arch/x86/include/asm/x86_init.h
18756 @@ -129,7 +129,7 @@ struct x86_init_ops {
18757 struct x86_init_timers timers;
18758 struct x86_init_iommu iommu;
18759 struct x86_init_pci pci;
18760 -};
18761 +} __no_const;
18762
18763 /**
18764 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18765 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18766 void (*setup_percpu_clockev)(void);
18767 void (*early_percpu_clock_init)(void);
18768 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18769 -};
18770 +} __no_const;
18771
18772 struct timespec;
18773
18774 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18775 void (*save_sched_clock_state)(void);
18776 void (*restore_sched_clock_state)(void);
18777 void (*apic_post_init)(void);
18778 -};
18779 +} __no_const;
18780
18781 struct pci_dev;
18782 struct msi_msg;
18783 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18784 void (*teardown_msi_irqs)(struct pci_dev *dev);
18785 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18786 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18787 -};
18788 +} __no_const;
18789
18790 struct IO_APIC_route_entry;
18791 struct io_apic_irq_attr;
18792 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18793 unsigned int destination, int vector,
18794 struct io_apic_irq_attr *attr);
18795 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18796 -};
18797 +} __no_const;
18798
18799 extern struct x86_init_ops x86_init;
18800 extern struct x86_cpuinit_ops x86_cpuinit;
18801 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18802 index 0415cda..3b22adc 100644
18803 --- a/arch/x86/include/asm/xsave.h
18804 +++ b/arch/x86/include/asm/xsave.h
18805 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18806 if (unlikely(err))
18807 return -EFAULT;
18808
18809 + pax_open_userland();
18810 __asm__ __volatile__(ASM_STAC "\n"
18811 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18812 + "1:"
18813 + __copyuser_seg
18814 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18815 "2: " ASM_CLAC "\n"
18816 ".section .fixup,\"ax\"\n"
18817 "3: movl $-1,%[err]\n"
18818 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18819 : [err] "=r" (err)
18820 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18821 : "memory");
18822 + pax_close_userland();
18823 return err;
18824 }
18825
18826 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18827 {
18828 int err;
18829 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18830 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18831 u32 lmask = mask;
18832 u32 hmask = mask >> 32;
18833
18834 + pax_open_userland();
18835 __asm__ __volatile__(ASM_STAC "\n"
18836 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18837 + "1:"
18838 + __copyuser_seg
18839 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18840 "2: " ASM_CLAC "\n"
18841 ".section .fixup,\"ax\"\n"
18842 "3: movl $-1,%[err]\n"
18843 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18844 : [err] "=r" (err)
18845 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18846 : "memory"); /* memory required? */
18847 + pax_close_userland();
18848 return err;
18849 }
18850
18851 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18852 index bbae024..e1528f9 100644
18853 --- a/arch/x86/include/uapi/asm/e820.h
18854 +++ b/arch/x86/include/uapi/asm/e820.h
18855 @@ -63,7 +63,7 @@ struct e820map {
18856 #define ISA_START_ADDRESS 0xa0000
18857 #define ISA_END_ADDRESS 0x100000
18858
18859 -#define BIOS_BEGIN 0x000a0000
18860 +#define BIOS_BEGIN 0x000c0000
18861 #define BIOS_END 0x00100000
18862
18863 #define BIOS_ROM_BASE 0xffe00000
18864 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18865 index 88d99ea..9fc7e17 100644
18866 --- a/arch/x86/kernel/Makefile
18867 +++ b/arch/x86/kernel/Makefile
18868 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18869 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18870 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18871 obj-y += probe_roms.o
18872 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18873 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18874 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18875 obj-y += syscall_$(BITS).o
18876 obj-$(CONFIG_X86_64) += vsyscall_64.o
18877 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18878 index 2627a81..cd8325e 100644
18879 --- a/arch/x86/kernel/acpi/boot.c
18880 +++ b/arch/x86/kernel/acpi/boot.c
18881 @@ -1368,7 +1368,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18882 * If your system is blacklisted here, but you find that acpi=force
18883 * works for you, please contact linux-acpi@vger.kernel.org
18884 */
18885 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18886 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18887 /*
18888 * Boxes that need ACPI disabled
18889 */
18890 @@ -1443,7 +1443,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18891 };
18892
18893 /* second table for DMI checks that should run after early-quirks */
18894 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18895 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18896 /*
18897 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18898 * which includes some code which overrides all temperature
18899 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18900 index 3312010..a65ca7b 100644
18901 --- a/arch/x86/kernel/acpi/sleep.c
18902 +++ b/arch/x86/kernel/acpi/sleep.c
18903 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18904 #else /* CONFIG_64BIT */
18905 #ifdef CONFIG_SMP
18906 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18907 +
18908 + pax_open_kernel();
18909 early_gdt_descr.address =
18910 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18911 + pax_close_kernel();
18912 +
18913 initial_gs = per_cpu_offset(smp_processor_id());
18914 #endif
18915 initial_code = (unsigned long)wakeup_long64;
18916 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18917 index d1daa66..59fecba 100644
18918 --- a/arch/x86/kernel/acpi/wakeup_32.S
18919 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18920 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18921 # and restore the stack ... but you need gdt for this to work
18922 movl saved_context_esp, %esp
18923
18924 - movl %cs:saved_magic, %eax
18925 - cmpl $0x12345678, %eax
18926 + cmpl $0x12345678, saved_magic
18927 jne bogus_magic
18928
18929 # jump to place where we left off
18930 - movl saved_eip, %eax
18931 - jmp *%eax
18932 + jmp *(saved_eip)
18933
18934 bogus_magic:
18935 jmp bogus_magic
18936 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18937 index c15cf9a..0e63558 100644
18938 --- a/arch/x86/kernel/alternative.c
18939 +++ b/arch/x86/kernel/alternative.c
18940 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18941 */
18942 for (a = start; a < end; a++) {
18943 instr = (u8 *)&a->instr_offset + a->instr_offset;
18944 +
18945 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18946 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18947 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18948 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18949 +#endif
18950 +
18951 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18952 BUG_ON(a->replacementlen > a->instrlen);
18953 BUG_ON(a->instrlen > sizeof(insnbuf));
18954 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18955 for (poff = start; poff < end; poff++) {
18956 u8 *ptr = (u8 *)poff + *poff;
18957
18958 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18959 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18960 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18961 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18962 +#endif
18963 +
18964 if (!*poff || ptr < text || ptr >= text_end)
18965 continue;
18966 /* turn DS segment override prefix into lock prefix */
18967 - if (*ptr == 0x3e)
18968 + if (*ktla_ktva(ptr) == 0x3e)
18969 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18970 }
18971 mutex_unlock(&text_mutex);
18972 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18973 for (poff = start; poff < end; poff++) {
18974 u8 *ptr = (u8 *)poff + *poff;
18975
18976 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18977 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18978 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18979 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18980 +#endif
18981 +
18982 if (!*poff || ptr < text || ptr >= text_end)
18983 continue;
18984 /* turn lock prefix into DS segment override prefix */
18985 - if (*ptr == 0xf0)
18986 + if (*ktla_ktva(ptr) == 0xf0)
18987 text_poke(ptr, ((unsigned char []){0x3E}), 1);
18988 }
18989 mutex_unlock(&text_mutex);
18990 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
18991
18992 BUG_ON(p->len > MAX_PATCH_LEN);
18993 /* prep the buffer with the original instructions */
18994 - memcpy(insnbuf, p->instr, p->len);
18995 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
18996 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
18997 (unsigned long)p->instr, p->len);
18998
18999 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
19000 if (!uniproc_patched || num_possible_cpus() == 1)
19001 free_init_pages("SMP alternatives",
19002 (unsigned long)__smp_locks,
19003 - (unsigned long)__smp_locks_end);
19004 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19005 #endif
19006
19007 apply_paravirt(__parainstructions, __parainstructions_end);
19008 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
19009 * instructions. And on the local CPU you need to be protected again NMI or MCE
19010 * handlers seeing an inconsistent instruction while you patch.
19011 */
19012 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19013 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19014 size_t len)
19015 {
19016 unsigned long flags;
19017 local_irq_save(flags);
19018 - memcpy(addr, opcode, len);
19019 +
19020 + pax_open_kernel();
19021 + memcpy(ktla_ktva(addr), opcode, len);
19022 sync_core();
19023 + pax_close_kernel();
19024 +
19025 local_irq_restore(flags);
19026 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19027 that causes hangs on some VIA CPUs. */
19028 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19029 */
19030 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19031 {
19032 - unsigned long flags;
19033 - char *vaddr;
19034 + unsigned char *vaddr = ktla_ktva(addr);
19035 struct page *pages[2];
19036 - int i;
19037 + size_t i;
19038
19039 if (!core_kernel_text((unsigned long)addr)) {
19040 - pages[0] = vmalloc_to_page(addr);
19041 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19042 + pages[0] = vmalloc_to_page(vaddr);
19043 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19044 } else {
19045 - pages[0] = virt_to_page(addr);
19046 + pages[0] = virt_to_page(vaddr);
19047 WARN_ON(!PageReserved(pages[0]));
19048 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19049 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19050 }
19051 BUG_ON(!pages[0]);
19052 - local_irq_save(flags);
19053 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19054 - if (pages[1])
19055 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19056 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19057 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19058 - clear_fixmap(FIX_TEXT_POKE0);
19059 - if (pages[1])
19060 - clear_fixmap(FIX_TEXT_POKE1);
19061 - local_flush_tlb();
19062 - sync_core();
19063 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19064 - that causes hangs on some VIA CPUs. */
19065 + text_poke_early(addr, opcode, len);
19066 for (i = 0; i < len; i++)
19067 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19068 - local_irq_restore(flags);
19069 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19070 return addr;
19071 }
19072
19073 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19074 index eca89c5..d566b78 100644
19075 --- a/arch/x86/kernel/apic/apic.c
19076 +++ b/arch/x86/kernel/apic/apic.c
19077 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19078 /*
19079 * Debug level, exported for io_apic.c
19080 */
19081 -unsigned int apic_verbosity;
19082 +int apic_verbosity;
19083
19084 int pic_mode;
19085
19086 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19087 apic_write(APIC_ESR, 0);
19088 v1 = apic_read(APIC_ESR);
19089 ack_APIC_irq();
19090 - atomic_inc(&irq_err_count);
19091 + atomic_inc_unchecked(&irq_err_count);
19092
19093 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19094 smp_processor_id(), v0 , v1);
19095 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19096 index 00c77cf..2dc6a2d 100644
19097 --- a/arch/x86/kernel/apic/apic_flat_64.c
19098 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19099 @@ -157,7 +157,7 @@ static int flat_probe(void)
19100 return 1;
19101 }
19102
19103 -static struct apic apic_flat = {
19104 +static struct apic apic_flat __read_only = {
19105 .name = "flat",
19106 .probe = flat_probe,
19107 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19108 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19109 return 0;
19110 }
19111
19112 -static struct apic apic_physflat = {
19113 +static struct apic apic_physflat __read_only = {
19114
19115 .name = "physical flat",
19116 .probe = physflat_probe,
19117 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19118 index e145f28..2752888 100644
19119 --- a/arch/x86/kernel/apic/apic_noop.c
19120 +++ b/arch/x86/kernel/apic/apic_noop.c
19121 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19122 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19123 }
19124
19125 -struct apic apic_noop = {
19126 +struct apic apic_noop __read_only = {
19127 .name = "noop",
19128 .probe = noop_probe,
19129 .acpi_madt_oem_check = NULL,
19130 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19131 index d50e364..543bee3 100644
19132 --- a/arch/x86/kernel/apic/bigsmp_32.c
19133 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19134 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19135 return dmi_bigsmp;
19136 }
19137
19138 -static struct apic apic_bigsmp = {
19139 +static struct apic apic_bigsmp __read_only = {
19140
19141 .name = "bigsmp",
19142 .probe = probe_bigsmp,
19143 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19144 index c552247..587a316 100644
19145 --- a/arch/x86/kernel/apic/es7000_32.c
19146 +++ b/arch/x86/kernel/apic/es7000_32.c
19147 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19148 return ret && es7000_apic_is_cluster();
19149 }
19150
19151 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19152 -static struct apic __refdata apic_es7000_cluster = {
19153 +static struct apic apic_es7000_cluster __read_only = {
19154
19155 .name = "es7000",
19156 .probe = probe_es7000,
19157 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19158 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19159 };
19160
19161 -static struct apic __refdata apic_es7000 = {
19162 +static struct apic apic_es7000 __read_only = {
19163
19164 .name = "es7000",
19165 .probe = probe_es7000,
19166 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19167 index 9ed796c..e930fe4 100644
19168 --- a/arch/x86/kernel/apic/io_apic.c
19169 +++ b/arch/x86/kernel/apic/io_apic.c
19170 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19171 }
19172 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19173
19174 -void lock_vector_lock(void)
19175 +void lock_vector_lock(void) __acquires(vector_lock)
19176 {
19177 /* Used to the online set of cpus does not change
19178 * during assign_irq_vector.
19179 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19180 raw_spin_lock(&vector_lock);
19181 }
19182
19183 -void unlock_vector_lock(void)
19184 +void unlock_vector_lock(void) __releases(vector_lock)
19185 {
19186 raw_spin_unlock(&vector_lock);
19187 }
19188 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
19189 ack_APIC_irq();
19190 }
19191
19192 -atomic_t irq_mis_count;
19193 +atomic_unchecked_t irq_mis_count;
19194
19195 #ifdef CONFIG_GENERIC_PENDING_IRQ
19196 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19197 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
19198 * at the cpu.
19199 */
19200 if (!(v & (1 << (i & 0x1f)))) {
19201 - atomic_inc(&irq_mis_count);
19202 + atomic_inc_unchecked(&irq_mis_count);
19203
19204 eoi_ioapic_irq(irq, cfg);
19205 }
19206 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19207 index 1e42e8f..daacf44 100644
19208 --- a/arch/x86/kernel/apic/numaq_32.c
19209 +++ b/arch/x86/kernel/apic/numaq_32.c
19210 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19211 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19212 }
19213
19214 -/* Use __refdata to keep false positive warning calm. */
19215 -static struct apic __refdata apic_numaq = {
19216 +static struct apic apic_numaq __read_only = {
19217
19218 .name = "NUMAQ",
19219 .probe = probe_numaq,
19220 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19221 index eb35ef9..f184a21 100644
19222 --- a/arch/x86/kernel/apic/probe_32.c
19223 +++ b/arch/x86/kernel/apic/probe_32.c
19224 @@ -72,7 +72,7 @@ static int probe_default(void)
19225 return 1;
19226 }
19227
19228 -static struct apic apic_default = {
19229 +static struct apic apic_default __read_only = {
19230
19231 .name = "default",
19232 .probe = probe_default,
19233 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19234 index 77c95c0..434f8a4 100644
19235 --- a/arch/x86/kernel/apic/summit_32.c
19236 +++ b/arch/x86/kernel/apic/summit_32.c
19237 @@ -486,7 +486,7 @@ void setup_summit(void)
19238 }
19239 #endif
19240
19241 -static struct apic apic_summit = {
19242 +static struct apic apic_summit __read_only = {
19243
19244 .name = "summit",
19245 .probe = probe_summit,
19246 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19247 index 140e29d..d88bc95 100644
19248 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19249 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19250 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19251 return notifier_from_errno(err);
19252 }
19253
19254 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19255 +static struct notifier_block x2apic_cpu_notifier = {
19256 .notifier_call = update_clusterinfo,
19257 };
19258
19259 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19260 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19261 }
19262
19263 -static struct apic apic_x2apic_cluster = {
19264 +static struct apic apic_x2apic_cluster __read_only = {
19265
19266 .name = "cluster x2apic",
19267 .probe = x2apic_cluster_probe,
19268 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19269 index 562a76d..a003c0f 100644
19270 --- a/arch/x86/kernel/apic/x2apic_phys.c
19271 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19272 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19273 return apic == &apic_x2apic_phys;
19274 }
19275
19276 -static struct apic apic_x2apic_phys = {
19277 +static struct apic apic_x2apic_phys __read_only = {
19278
19279 .name = "physical x2apic",
19280 .probe = x2apic_phys_probe,
19281 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19282 index a419814..1dd34a0 100644
19283 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19284 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19285 @@ -357,7 +357,7 @@ static int uv_probe(void)
19286 return apic == &apic_x2apic_uv_x;
19287 }
19288
19289 -static struct apic __refdata apic_x2apic_uv_x = {
19290 +static struct apic apic_x2apic_uv_x __read_only = {
19291
19292 .name = "UV large system",
19293 .probe = uv_probe,
19294 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19295 index 53a4e27..038760a 100644
19296 --- a/arch/x86/kernel/apm_32.c
19297 +++ b/arch/x86/kernel/apm_32.c
19298 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19299 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19300 * even though they are called in protected mode.
19301 */
19302 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19303 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19304 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19305
19306 static const char driver_version[] = "1.16ac"; /* no spaces */
19307 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19308 BUG_ON(cpu != 0);
19309 gdt = get_cpu_gdt_table(cpu);
19310 save_desc_40 = gdt[0x40 / 8];
19311 +
19312 + pax_open_kernel();
19313 gdt[0x40 / 8] = bad_bios_desc;
19314 + pax_close_kernel();
19315
19316 apm_irq_save(flags);
19317 APM_DO_SAVE_SEGS;
19318 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19319 &call->esi);
19320 APM_DO_RESTORE_SEGS;
19321 apm_irq_restore(flags);
19322 +
19323 + pax_open_kernel();
19324 gdt[0x40 / 8] = save_desc_40;
19325 + pax_close_kernel();
19326 +
19327 put_cpu();
19328
19329 return call->eax & 0xff;
19330 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19331 BUG_ON(cpu != 0);
19332 gdt = get_cpu_gdt_table(cpu);
19333 save_desc_40 = gdt[0x40 / 8];
19334 +
19335 + pax_open_kernel();
19336 gdt[0x40 / 8] = bad_bios_desc;
19337 + pax_close_kernel();
19338
19339 apm_irq_save(flags);
19340 APM_DO_SAVE_SEGS;
19341 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19342 &call->eax);
19343 APM_DO_RESTORE_SEGS;
19344 apm_irq_restore(flags);
19345 +
19346 + pax_open_kernel();
19347 gdt[0x40 / 8] = save_desc_40;
19348 + pax_close_kernel();
19349 +
19350 put_cpu();
19351 return error;
19352 }
19353 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19354 * code to that CPU.
19355 */
19356 gdt = get_cpu_gdt_table(0);
19357 +
19358 + pax_open_kernel();
19359 set_desc_base(&gdt[APM_CS >> 3],
19360 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19361 set_desc_base(&gdt[APM_CS_16 >> 3],
19362 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19363 set_desc_base(&gdt[APM_DS >> 3],
19364 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19365 + pax_close_kernel();
19366
19367 proc_create("apm", 0, NULL, &apm_file_ops);
19368
19369 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19370 index 2861082..6d4718e 100644
19371 --- a/arch/x86/kernel/asm-offsets.c
19372 +++ b/arch/x86/kernel/asm-offsets.c
19373 @@ -33,6 +33,8 @@ void common(void) {
19374 OFFSET(TI_status, thread_info, status);
19375 OFFSET(TI_addr_limit, thread_info, addr_limit);
19376 OFFSET(TI_preempt_count, thread_info, preempt_count);
19377 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19378 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19379
19380 BLANK();
19381 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19382 @@ -53,8 +55,26 @@ void common(void) {
19383 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19384 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19385 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19386 +
19387 +#ifdef CONFIG_PAX_KERNEXEC
19388 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19389 #endif
19390
19391 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19392 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19393 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19394 +#ifdef CONFIG_X86_64
19395 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19396 +#endif
19397 +#endif
19398 +
19399 +#endif
19400 +
19401 + BLANK();
19402 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19403 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19404 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19405 +
19406 #ifdef CONFIG_XEN
19407 BLANK();
19408 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19409 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19410 index e7c798b..2b2019b 100644
19411 --- a/arch/x86/kernel/asm-offsets_64.c
19412 +++ b/arch/x86/kernel/asm-offsets_64.c
19413 @@ -77,6 +77,7 @@ int main(void)
19414 BLANK();
19415 #undef ENTRY
19416
19417 + DEFINE(TSS_size, sizeof(struct tss_struct));
19418 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19419 BLANK();
19420
19421 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19422 index 47b56a7..efc2bc6 100644
19423 --- a/arch/x86/kernel/cpu/Makefile
19424 +++ b/arch/x86/kernel/cpu/Makefile
19425 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19426 CFLAGS_REMOVE_perf_event.o = -pg
19427 endif
19428
19429 -# Make sure load_percpu_segment has no stackprotector
19430 -nostackp := $(call cc-option, -fno-stack-protector)
19431 -CFLAGS_common.o := $(nostackp)
19432 -
19433 obj-y := intel_cacheinfo.o scattered.o topology.o
19434 obj-y += proc.o capflags.o powerflags.o common.o
19435 obj-y += rdrand.o
19436 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19437 index 08a0890..e557865 100644
19438 --- a/arch/x86/kernel/cpu/amd.c
19439 +++ b/arch/x86/kernel/cpu/amd.c
19440 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19441 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19442 {
19443 /* AMD errata T13 (order #21922) */
19444 - if ((c->x86 == 6)) {
19445 + if (c->x86 == 6) {
19446 /* Duron Rev A0 */
19447 if (c->x86_model == 3 && c->x86_mask == 0)
19448 size = 64;
19449 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19450 index 25eb274..3a92d93 100644
19451 --- a/arch/x86/kernel/cpu/common.c
19452 +++ b/arch/x86/kernel/cpu/common.c
19453 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19454
19455 static const struct cpu_dev *this_cpu = &default_cpu;
19456
19457 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19458 -#ifdef CONFIG_X86_64
19459 - /*
19460 - * We need valid kernel segments for data and code in long mode too
19461 - * IRET will check the segment types kkeil 2000/10/28
19462 - * Also sysret mandates a special GDT layout
19463 - *
19464 - * TLS descriptors are currently at a different place compared to i386.
19465 - * Hopefully nobody expects them at a fixed place (Wine?)
19466 - */
19467 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19468 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19469 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19470 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19471 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19472 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19473 -#else
19474 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19475 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19476 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19477 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19478 - /*
19479 - * Segments used for calling PnP BIOS have byte granularity.
19480 - * They code segments and data segments have fixed 64k limits,
19481 - * the transfer segment sizes are set at run time.
19482 - */
19483 - /* 32-bit code */
19484 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19485 - /* 16-bit code */
19486 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19487 - /* 16-bit data */
19488 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19489 - /* 16-bit data */
19490 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19491 - /* 16-bit data */
19492 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19493 - /*
19494 - * The APM segments have byte granularity and their bases
19495 - * are set at run time. All have 64k limits.
19496 - */
19497 - /* 32-bit code */
19498 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19499 - /* 16-bit code */
19500 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19501 - /* data */
19502 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19503 -
19504 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19505 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19506 - GDT_STACK_CANARY_INIT
19507 -#endif
19508 -} };
19509 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19510 -
19511 static int __init x86_xsave_setup(char *s)
19512 {
19513 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19514 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19515 set_in_cr4(X86_CR4_SMAP);
19516 }
19517
19518 +#ifdef CONFIG_X86_64
19519 +static __init int setup_disable_pcid(char *arg)
19520 +{
19521 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19522 +
19523 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19524 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19525 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19526 +#endif
19527 +
19528 + return 1;
19529 +}
19530 +__setup("nopcid", setup_disable_pcid);
19531 +
19532 +static void setup_pcid(struct cpuinfo_x86 *c)
19533 +{
19534 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19535 +
19536 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19537 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19538 + pax_open_kernel();
19539 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19540 + pax_close_kernel();
19541 + printk("PAX: slow and weak UDEREF enabled\n");
19542 + } else
19543 + printk("PAX: UDEREF disabled\n");
19544 +#endif
19545 +
19546 + return;
19547 + }
19548 +
19549 + printk("PAX: PCID detected\n");
19550 + set_in_cr4(X86_CR4_PCIDE);
19551 +
19552 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19553 + pax_open_kernel();
19554 + clone_pgd_mask = ~(pgdval_t)0UL;
19555 + pax_close_kernel();
19556 + if (pax_user_shadow_base)
19557 + printk("PAX: weak UDEREF enabled\n");
19558 + else {
19559 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19560 + printk("PAX: strong UDEREF enabled\n");
19561 + }
19562 +#endif
19563 +
19564 + if (cpu_has(c, X86_FEATURE_INVPCID))
19565 + printk("PAX: INVPCID detected\n");
19566 +}
19567 +#endif
19568 +
19569 /*
19570 * Some CPU features depend on higher CPUID levels, which may not always
19571 * be available due to CPUID level capping or broken virtualization
19572 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19573 {
19574 struct desc_ptr gdt_descr;
19575
19576 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19577 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19578 gdt_descr.size = GDT_SIZE - 1;
19579 load_gdt(&gdt_descr);
19580 /* Reload the per-cpu base */
19581 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19582 setup_smep(c);
19583 setup_smap(c);
19584
19585 +#ifdef CONFIG_X86_64
19586 + setup_pcid(c);
19587 +#endif
19588 +
19589 /*
19590 * The vendor-specific functions might have changed features.
19591 * Now we do "generic changes."
19592 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19593 /* Filter out anything that depends on CPUID levels we don't have */
19594 filter_cpuid_features(c, true);
19595
19596 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19597 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19598 +#endif
19599 +
19600 /* If the model name is still unset, do table lookup. */
19601 if (!c->x86_model_id[0]) {
19602 const char *p;
19603 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19604 }
19605 __setup("clearcpuid=", setup_disablecpuid);
19606
19607 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19608 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19609 +
19610 #ifdef CONFIG_X86_64
19611 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19612 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19613 - (unsigned long) debug_idt_table };
19614 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19615 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19616
19617 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19618 irq_stack_union) __aligned(PAGE_SIZE);
19619 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19620 EXPORT_PER_CPU_SYMBOL(current_task);
19621
19622 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19623 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19624 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19625 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19626
19627 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19628 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19629 load_ucode_ap();
19630
19631 cpu = stack_smp_processor_id();
19632 - t = &per_cpu(init_tss, cpu);
19633 + t = init_tss + cpu;
19634 oist = &per_cpu(orig_ist, cpu);
19635
19636 #ifdef CONFIG_NUMA
19637 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19638 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19639 barrier();
19640
19641 - x86_configure_nx();
19642 enable_x2apic();
19643
19644 /*
19645 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19646 {
19647 int cpu = smp_processor_id();
19648 struct task_struct *curr = current;
19649 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19650 + struct tss_struct *t = init_tss + cpu;
19651 struct thread_struct *thread = &curr->thread;
19652
19653 show_ucode_info_early();
19654 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19655 index 1414c90..1159406 100644
19656 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19657 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19658 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19659 };
19660
19661 #ifdef CONFIG_AMD_NB
19662 +static struct attribute *default_attrs_amd_nb[] = {
19663 + &type.attr,
19664 + &level.attr,
19665 + &coherency_line_size.attr,
19666 + &physical_line_partition.attr,
19667 + &ways_of_associativity.attr,
19668 + &number_of_sets.attr,
19669 + &size.attr,
19670 + &shared_cpu_map.attr,
19671 + &shared_cpu_list.attr,
19672 + NULL,
19673 + NULL,
19674 + NULL,
19675 + NULL
19676 +};
19677 +
19678 static struct attribute **amd_l3_attrs(void)
19679 {
19680 static struct attribute **attrs;
19681 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19682
19683 n = ARRAY_SIZE(default_attrs);
19684
19685 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19686 - n += 2;
19687 -
19688 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19689 - n += 1;
19690 -
19691 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19692 - if (attrs == NULL)
19693 - return attrs = default_attrs;
19694 -
19695 - for (n = 0; default_attrs[n]; n++)
19696 - attrs[n] = default_attrs[n];
19697 + attrs = default_attrs_amd_nb;
19698
19699 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19700 attrs[n++] = &cache_disable_0.attr;
19701 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19702 .default_attrs = default_attrs,
19703 };
19704
19705 +#ifdef CONFIG_AMD_NB
19706 +static struct kobj_type ktype_cache_amd_nb = {
19707 + .sysfs_ops = &sysfs_ops,
19708 + .default_attrs = default_attrs_amd_nb,
19709 +};
19710 +#endif
19711 +
19712 static struct kobj_type ktype_percpu_entry = {
19713 .sysfs_ops = &sysfs_ops,
19714 };
19715 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19716 return retval;
19717 }
19718
19719 +#ifdef CONFIG_AMD_NB
19720 + amd_l3_attrs();
19721 +#endif
19722 +
19723 for (i = 0; i < num_cache_leaves; i++) {
19724 + struct kobj_type *ktype;
19725 +
19726 this_object = INDEX_KOBJECT_PTR(cpu, i);
19727 this_object->cpu = cpu;
19728 this_object->index = i;
19729
19730 this_leaf = CPUID4_INFO_IDX(cpu, i);
19731
19732 - ktype_cache.default_attrs = default_attrs;
19733 + ktype = &ktype_cache;
19734 #ifdef CONFIG_AMD_NB
19735 if (this_leaf->base.nb)
19736 - ktype_cache.default_attrs = amd_l3_attrs();
19737 + ktype = &ktype_cache_amd_nb;
19738 #endif
19739 retval = kobject_init_and_add(&(this_object->kobj),
19740 - &ktype_cache,
19741 + ktype,
19742 per_cpu(ici_cache_kobject, cpu),
19743 "index%1lu", i);
19744 if (unlikely(retval)) {
19745 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19746 index 87a65c9..92fcce6 100644
19747 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19748 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19749 @@ -45,6 +45,7 @@
19750 #include <asm/processor.h>
19751 #include <asm/mce.h>
19752 #include <asm/msr.h>
19753 +#include <asm/local.h>
19754
19755 #include "mce-internal.h"
19756
19757 @@ -249,7 +250,7 @@ static void print_mce(struct mce *m)
19758 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19759 m->cs, m->ip);
19760
19761 - if (m->cs == __KERNEL_CS)
19762 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19763 print_symbol("{%s}", m->ip);
19764 pr_cont("\n");
19765 }
19766 @@ -282,10 +283,10 @@ static void print_mce(struct mce *m)
19767
19768 #define PANIC_TIMEOUT 5 /* 5 seconds */
19769
19770 -static atomic_t mce_paniced;
19771 +static atomic_unchecked_t mce_paniced;
19772
19773 static int fake_panic;
19774 -static atomic_t mce_fake_paniced;
19775 +static atomic_unchecked_t mce_fake_paniced;
19776
19777 /* Panic in progress. Enable interrupts and wait for final IPI */
19778 static void wait_for_panic(void)
19779 @@ -309,7 +310,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19780 /*
19781 * Make sure only one CPU runs in machine check panic
19782 */
19783 - if (atomic_inc_return(&mce_paniced) > 1)
19784 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19785 wait_for_panic();
19786 barrier();
19787
19788 @@ -317,7 +318,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19789 console_verbose();
19790 } else {
19791 /* Don't log too much for fake panic */
19792 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19793 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19794 return;
19795 }
19796 /* First print corrected ones that are still unlogged */
19797 @@ -356,7 +357,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19798 if (!fake_panic) {
19799 if (panic_timeout == 0)
19800 panic_timeout = mca_cfg.panic_timeout;
19801 - panic(msg);
19802 + panic("%s", msg);
19803 } else
19804 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19805 }
19806 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
19807 * might have been modified by someone else.
19808 */
19809 rmb();
19810 - if (atomic_read(&mce_paniced))
19811 + if (atomic_read_unchecked(&mce_paniced))
19812 wait_for_panic();
19813 if (!mca_cfg.monarch_timeout)
19814 goto out;
19815 @@ -1657,7 +1658,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19816 }
19817
19818 /* Call the installed machine check handler for this CPU setup. */
19819 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19820 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19821 unexpected_machine_check;
19822
19823 /*
19824 @@ -1680,7 +1681,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19825 return;
19826 }
19827
19828 + pax_open_kernel();
19829 machine_check_vector = do_machine_check;
19830 + pax_close_kernel();
19831
19832 __mcheck_cpu_init_generic();
19833 __mcheck_cpu_init_vendor(c);
19834 @@ -1694,7 +1697,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19835 */
19836
19837 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19838 -static int mce_chrdev_open_count; /* #times opened */
19839 +static local_t mce_chrdev_open_count; /* #times opened */
19840 static int mce_chrdev_open_exclu; /* already open exclusive? */
19841
19842 static int mce_chrdev_open(struct inode *inode, struct file *file)
19843 @@ -1702,7 +1705,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19844 spin_lock(&mce_chrdev_state_lock);
19845
19846 if (mce_chrdev_open_exclu ||
19847 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19848 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19849 spin_unlock(&mce_chrdev_state_lock);
19850
19851 return -EBUSY;
19852 @@ -1710,7 +1713,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19853
19854 if (file->f_flags & O_EXCL)
19855 mce_chrdev_open_exclu = 1;
19856 - mce_chrdev_open_count++;
19857 + local_inc(&mce_chrdev_open_count);
19858
19859 spin_unlock(&mce_chrdev_state_lock);
19860
19861 @@ -1721,7 +1724,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19862 {
19863 spin_lock(&mce_chrdev_state_lock);
19864
19865 - mce_chrdev_open_count--;
19866 + local_dec(&mce_chrdev_open_count);
19867 mce_chrdev_open_exclu = 0;
19868
19869 spin_unlock(&mce_chrdev_state_lock);
19870 @@ -2376,7 +2379,7 @@ static __init void mce_init_banks(void)
19871
19872 for (i = 0; i < mca_cfg.banks; i++) {
19873 struct mce_bank *b = &mce_banks[i];
19874 - struct device_attribute *a = &b->attr;
19875 + device_attribute_no_const *a = &b->attr;
19876
19877 sysfs_attr_init(&a->attr);
19878 a->attr.name = b->attrname;
19879 @@ -2444,7 +2447,7 @@ struct dentry *mce_get_debugfs_dir(void)
19880 static void mce_reset(void)
19881 {
19882 cpu_missing = 0;
19883 - atomic_set(&mce_fake_paniced, 0);
19884 + atomic_set_unchecked(&mce_fake_paniced, 0);
19885 atomic_set(&mce_executing, 0);
19886 atomic_set(&mce_callin, 0);
19887 atomic_set(&global_nwo, 0);
19888 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19889 index 1c044b1..37a2a43 100644
19890 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19891 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19892 @@ -11,6 +11,7 @@
19893 #include <asm/processor.h>
19894 #include <asm/mce.h>
19895 #include <asm/msr.h>
19896 +#include <asm/pgtable.h>
19897
19898 /* By default disabled */
19899 int mce_p5_enabled __read_mostly;
19900 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19901 if (!cpu_has(c, X86_FEATURE_MCE))
19902 return;
19903
19904 + pax_open_kernel();
19905 machine_check_vector = pentium_machine_check;
19906 + pax_close_kernel();
19907 /* Make sure the vector pointer is visible before we enable MCEs: */
19908 wmb();
19909
19910 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19911 index e9a701a..35317d6 100644
19912 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19913 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19914 @@ -10,6 +10,7 @@
19915 #include <asm/processor.h>
19916 #include <asm/mce.h>
19917 #include <asm/msr.h>
19918 +#include <asm/pgtable.h>
19919
19920 /* Machine check handler for WinChip C6: */
19921 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19922 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19923 {
19924 u32 lo, hi;
19925
19926 + pax_open_kernel();
19927 machine_check_vector = winchip_machine_check;
19928 + pax_close_kernel();
19929 /* Make sure the vector pointer is visible before we enable MCEs: */
19930 wmb();
19931
19932 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19933 index f961de9..8a9d332 100644
19934 --- a/arch/x86/kernel/cpu/mtrr/main.c
19935 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19936 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19937 u64 size_or_mask, size_and_mask;
19938 static bool mtrr_aps_delayed_init;
19939
19940 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19941 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19942
19943 const struct mtrr_ops *mtrr_if;
19944
19945 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19946 index df5e41f..816c719 100644
19947 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19948 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19949 @@ -25,7 +25,7 @@ struct mtrr_ops {
19950 int (*validate_add_page)(unsigned long base, unsigned long size,
19951 unsigned int type);
19952 int (*have_wrcomb)(void);
19953 -};
19954 +} __do_const;
19955
19956 extern int generic_get_free_region(unsigned long base, unsigned long size,
19957 int replace_reg);
19958 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19959 index a7c7305..b9705ab 100644
19960 --- a/arch/x86/kernel/cpu/perf_event.c
19961 +++ b/arch/x86/kernel/cpu/perf_event.c
19962 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19963 pr_info("no hardware sampling interrupt available.\n");
19964 }
19965
19966 -static struct attribute_group x86_pmu_format_group = {
19967 +static attribute_group_no_const x86_pmu_format_group = {
19968 .name = "format",
19969 .attrs = NULL,
19970 };
19971 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19972 NULL,
19973 };
19974
19975 -static struct attribute_group x86_pmu_events_group = {
19976 +static attribute_group_no_const x86_pmu_events_group = {
19977 .name = "events",
19978 .attrs = events_attr,
19979 };
19980 @@ -1957,7 +1957,7 @@ static unsigned long get_segment_base(unsigned int segment)
19981 if (idx > GDT_ENTRIES)
19982 return 0;
19983
19984 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
19985 + desc = get_cpu_gdt_table(smp_processor_id());
19986 }
19987
19988 return get_desc_base(desc + idx);
19989 @@ -2047,7 +2047,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
19990 break;
19991
19992 perf_callchain_store(entry, frame.return_address);
19993 - fp = frame.next_frame;
19994 + fp = (const void __force_user *)frame.next_frame;
19995 }
19996 }
19997
19998 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
19999 index 639d128..e92d7e5 100644
20000 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20001 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20002 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20003 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20004 {
20005 struct attribute **attrs;
20006 - struct attribute_group *attr_group;
20007 + attribute_group_no_const *attr_group;
20008 int i = 0, j;
20009
20010 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20011 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20012 index a45d8d4..8abd32c 100644
20013 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20014 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20015 @@ -2099,10 +2099,10 @@ __init int intel_pmu_init(void)
20016 * v2 and above have a perf capabilities MSR
20017 */
20018 if (version > 1) {
20019 - u64 capabilities;
20020 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20021
20022 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20023 - x86_pmu.intel_cap.capabilities = capabilities;
20024 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20025 + x86_pmu.intel_cap.capabilities = capabilities;
20026 }
20027
20028 intel_ds_init();
20029 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20030 index 1fb6c72..f5fa2a3 100644
20031 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20032 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20033 @@ -3095,7 +3095,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20034 static int __init uncore_type_init(struct intel_uncore_type *type)
20035 {
20036 struct intel_uncore_pmu *pmus;
20037 - struct attribute_group *attr_group;
20038 + attribute_group_no_const *attr_group;
20039 struct attribute **attrs;
20040 int i, j;
20041
20042 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20043 index 47b3d00c..2cf1751 100644
20044 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20045 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20046 @@ -488,7 +488,7 @@ struct intel_uncore_box {
20047 struct uncore_event_desc {
20048 struct kobj_attribute attr;
20049 const char *config;
20050 -};
20051 +} __do_const;
20052
20053 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20054 { \
20055 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20056 index 7d9481c..99c7e4b 100644
20057 --- a/arch/x86/kernel/cpuid.c
20058 +++ b/arch/x86/kernel/cpuid.c
20059 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20060 return notifier_from_errno(err);
20061 }
20062
20063 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20064 +static struct notifier_block cpuid_class_cpu_notifier =
20065 {
20066 .notifier_call = cpuid_class_cpu_callback,
20067 };
20068 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20069 index 74467fe..18793d5 100644
20070 --- a/arch/x86/kernel/crash.c
20071 +++ b/arch/x86/kernel/crash.c
20072 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20073 {
20074 #ifdef CONFIG_X86_32
20075 struct pt_regs fixed_regs;
20076 -#endif
20077
20078 -#ifdef CONFIG_X86_32
20079 - if (!user_mode_vm(regs)) {
20080 + if (!user_mode(regs)) {
20081 crash_fixup_ss_esp(&fixed_regs, regs);
20082 regs = &fixed_regs;
20083 }
20084 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20085 index afa64ad..dce67dd 100644
20086 --- a/arch/x86/kernel/crash_dump_64.c
20087 +++ b/arch/x86/kernel/crash_dump_64.c
20088 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20089 return -ENOMEM;
20090
20091 if (userbuf) {
20092 - if (copy_to_user(buf, vaddr + offset, csize)) {
20093 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20094 iounmap(vaddr);
20095 return -EFAULT;
20096 }
20097 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20098 index 5d3fe8d..02e1429 100644
20099 --- a/arch/x86/kernel/doublefault.c
20100 +++ b/arch/x86/kernel/doublefault.c
20101 @@ -13,7 +13,7 @@
20102
20103 #define DOUBLEFAULT_STACKSIZE (1024)
20104 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20105 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20106 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20107
20108 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20109
20110 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20111 unsigned long gdt, tss;
20112
20113 native_store_gdt(&gdt_desc);
20114 - gdt = gdt_desc.address;
20115 + gdt = (unsigned long)gdt_desc.address;
20116
20117 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20118
20119 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20120 /* 0x2 bit is always set */
20121 .flags = X86_EFLAGS_SF | 0x2,
20122 .sp = STACK_START,
20123 - .es = __USER_DS,
20124 + .es = __KERNEL_DS,
20125 .cs = __KERNEL_CS,
20126 .ss = __KERNEL_DS,
20127 - .ds = __USER_DS,
20128 + .ds = __KERNEL_DS,
20129 .fs = __KERNEL_PERCPU,
20130
20131 .__cr3 = __pa_nodebug(swapper_pg_dir),
20132 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20133 index deb6421..76bbc12 100644
20134 --- a/arch/x86/kernel/dumpstack.c
20135 +++ b/arch/x86/kernel/dumpstack.c
20136 @@ -2,6 +2,9 @@
20137 * Copyright (C) 1991, 1992 Linus Torvalds
20138 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20139 */
20140 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20141 +#define __INCLUDED_BY_HIDESYM 1
20142 +#endif
20143 #include <linux/kallsyms.h>
20144 #include <linux/kprobes.h>
20145 #include <linux/uaccess.h>
20146 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20147 static void
20148 print_ftrace_graph_addr(unsigned long addr, void *data,
20149 const struct stacktrace_ops *ops,
20150 - struct thread_info *tinfo, int *graph)
20151 + struct task_struct *task, int *graph)
20152 {
20153 - struct task_struct *task;
20154 unsigned long ret_addr;
20155 int index;
20156
20157 if (addr != (unsigned long)return_to_handler)
20158 return;
20159
20160 - task = tinfo->task;
20161 index = task->curr_ret_stack;
20162
20163 if (!task->ret_stack || index < *graph)
20164 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20165 static inline void
20166 print_ftrace_graph_addr(unsigned long addr, void *data,
20167 const struct stacktrace_ops *ops,
20168 - struct thread_info *tinfo, int *graph)
20169 + struct task_struct *task, int *graph)
20170 { }
20171 #endif
20172
20173 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20174 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20175 */
20176
20177 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20178 - void *p, unsigned int size, void *end)
20179 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20180 {
20181 - void *t = tinfo;
20182 if (end) {
20183 if (p < end && p >= (end-THREAD_SIZE))
20184 return 1;
20185 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20186 }
20187
20188 unsigned long
20189 -print_context_stack(struct thread_info *tinfo,
20190 +print_context_stack(struct task_struct *task, void *stack_start,
20191 unsigned long *stack, unsigned long bp,
20192 const struct stacktrace_ops *ops, void *data,
20193 unsigned long *end, int *graph)
20194 {
20195 struct stack_frame *frame = (struct stack_frame *)bp;
20196
20197 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20198 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20199 unsigned long addr;
20200
20201 addr = *stack;
20202 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20203 } else {
20204 ops->address(data, addr, 0);
20205 }
20206 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20207 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20208 }
20209 stack++;
20210 }
20211 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20212 EXPORT_SYMBOL_GPL(print_context_stack);
20213
20214 unsigned long
20215 -print_context_stack_bp(struct thread_info *tinfo,
20216 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20217 unsigned long *stack, unsigned long bp,
20218 const struct stacktrace_ops *ops, void *data,
20219 unsigned long *end, int *graph)
20220 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20221 struct stack_frame *frame = (struct stack_frame *)bp;
20222 unsigned long *ret_addr = &frame->return_address;
20223
20224 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20225 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20226 unsigned long addr = *ret_addr;
20227
20228 if (!__kernel_text_address(addr))
20229 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20230 ops->address(data, addr, 1);
20231 frame = frame->next_frame;
20232 ret_addr = &frame->return_address;
20233 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20234 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20235 }
20236
20237 return (unsigned long)frame;
20238 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20239 static void print_trace_address(void *data, unsigned long addr, int reliable)
20240 {
20241 touch_nmi_watchdog();
20242 - printk(data);
20243 + printk("%s", (char *)data);
20244 printk_address(addr, reliable);
20245 }
20246
20247 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20248 }
20249 EXPORT_SYMBOL_GPL(oops_begin);
20250
20251 +extern void gr_handle_kernel_exploit(void);
20252 +
20253 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20254 {
20255 if (regs && kexec_should_crash(current))
20256 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20257 panic("Fatal exception in interrupt");
20258 if (panic_on_oops)
20259 panic("Fatal exception");
20260 - do_exit(signr);
20261 +
20262 + gr_handle_kernel_exploit();
20263 +
20264 + do_group_exit(signr);
20265 }
20266
20267 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20268 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20269 print_modules();
20270 show_regs(regs);
20271 #ifdef CONFIG_X86_32
20272 - if (user_mode_vm(regs)) {
20273 + if (user_mode(regs)) {
20274 sp = regs->sp;
20275 ss = regs->ss & 0xffff;
20276 } else {
20277 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20278 unsigned long flags = oops_begin();
20279 int sig = SIGSEGV;
20280
20281 - if (!user_mode_vm(regs))
20282 + if (!user_mode(regs))
20283 report_bug(regs->ip, regs);
20284
20285 if (__die(str, regs, err))
20286 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20287 index f2a1770..540657f 100644
20288 --- a/arch/x86/kernel/dumpstack_32.c
20289 +++ b/arch/x86/kernel/dumpstack_32.c
20290 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20291 bp = stack_frame(task, regs);
20292
20293 for (;;) {
20294 - struct thread_info *context;
20295 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20296
20297 - context = (struct thread_info *)
20298 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20299 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20300 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20301
20302 - stack = (unsigned long *)context->previous_esp;
20303 - if (!stack)
20304 + if (stack_start == task_stack_page(task))
20305 break;
20306 + stack = *(unsigned long **)stack_start;
20307 if (ops->stack(data, "IRQ") < 0)
20308 break;
20309 touch_nmi_watchdog();
20310 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20311 int i;
20312
20313 show_regs_print_info(KERN_EMERG);
20314 - __show_regs(regs, !user_mode_vm(regs));
20315 + __show_regs(regs, !user_mode(regs));
20316
20317 /*
20318 * When in-kernel, we also print out the stack and code at the
20319 * time of the fault..
20320 */
20321 - if (!user_mode_vm(regs)) {
20322 + if (!user_mode(regs)) {
20323 unsigned int code_prologue = code_bytes * 43 / 64;
20324 unsigned int code_len = code_bytes;
20325 unsigned char c;
20326 u8 *ip;
20327 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20328
20329 pr_emerg("Stack:\n");
20330 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20331
20332 pr_emerg("Code:");
20333
20334 - ip = (u8 *)regs->ip - code_prologue;
20335 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20336 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20337 /* try starting at IP */
20338 - ip = (u8 *)regs->ip;
20339 + ip = (u8 *)regs->ip + cs_base;
20340 code_len = code_len - code_prologue + 1;
20341 }
20342 for (i = 0; i < code_len; i++, ip++) {
20343 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20344 pr_cont(" Bad EIP value.");
20345 break;
20346 }
20347 - if (ip == (u8 *)regs->ip)
20348 + if (ip == (u8 *)regs->ip + cs_base)
20349 pr_cont(" <%02x>", c);
20350 else
20351 pr_cont(" %02x", c);
20352 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20353 {
20354 unsigned short ud2;
20355
20356 + ip = ktla_ktva(ip);
20357 if (ip < PAGE_OFFSET)
20358 return 0;
20359 if (probe_kernel_address((unsigned short *)ip, ud2))
20360 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20361
20362 return ud2 == 0x0b0f;
20363 }
20364 +
20365 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20366 +void pax_check_alloca(unsigned long size)
20367 +{
20368 + unsigned long sp = (unsigned long)&sp, stack_left;
20369 +
20370 + /* all kernel stacks are of the same size */
20371 + stack_left = sp & (THREAD_SIZE - 1);
20372 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20373 +}
20374 +EXPORT_SYMBOL(pax_check_alloca);
20375 +#endif
20376 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20377 index addb207..99635fa 100644
20378 --- a/arch/x86/kernel/dumpstack_64.c
20379 +++ b/arch/x86/kernel/dumpstack_64.c
20380 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20381 unsigned long *irq_stack_end =
20382 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20383 unsigned used = 0;
20384 - struct thread_info *tinfo;
20385 int graph = 0;
20386 unsigned long dummy;
20387 + void *stack_start;
20388
20389 if (!task)
20390 task = current;
20391 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20392 * current stack address. If the stacks consist of nested
20393 * exceptions
20394 */
20395 - tinfo = task_thread_info(task);
20396 for (;;) {
20397 char *id;
20398 unsigned long *estack_end;
20399 +
20400 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20401 &used, &id);
20402
20403 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20404 if (ops->stack(data, id) < 0)
20405 break;
20406
20407 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20408 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20409 data, estack_end, &graph);
20410 ops->stack(data, "<EOE>");
20411 /*
20412 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20413 * second-to-last pointer (index -2 to end) in the
20414 * exception stack:
20415 */
20416 + if ((u16)estack_end[-1] != __KERNEL_DS)
20417 + goto out;
20418 stack = (unsigned long *) estack_end[-2];
20419 continue;
20420 }
20421 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20422 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20423 if (ops->stack(data, "IRQ") < 0)
20424 break;
20425 - bp = ops->walk_stack(tinfo, stack, bp,
20426 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20427 ops, data, irq_stack_end, &graph);
20428 /*
20429 * We link to the next stack (which would be
20430 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20431 /*
20432 * This handles the process stack:
20433 */
20434 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20435 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20436 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20437 +out:
20438 put_cpu();
20439 }
20440 EXPORT_SYMBOL(dump_trace);
20441 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20442
20443 return ud2 == 0x0b0f;
20444 }
20445 +
20446 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20447 +void pax_check_alloca(unsigned long size)
20448 +{
20449 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20450 + unsigned cpu, used;
20451 + char *id;
20452 +
20453 + /* check the process stack first */
20454 + stack_start = (unsigned long)task_stack_page(current);
20455 + stack_end = stack_start + THREAD_SIZE;
20456 + if (likely(stack_start <= sp && sp < stack_end)) {
20457 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20458 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20459 + return;
20460 + }
20461 +
20462 + cpu = get_cpu();
20463 +
20464 + /* check the irq stacks */
20465 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20466 + stack_start = stack_end - IRQ_STACK_SIZE;
20467 + if (stack_start <= sp && sp < stack_end) {
20468 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20469 + put_cpu();
20470 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20471 + return;
20472 + }
20473 +
20474 + /* check the exception stacks */
20475 + used = 0;
20476 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20477 + stack_start = stack_end - EXCEPTION_STKSZ;
20478 + if (stack_end && stack_start <= sp && sp < stack_end) {
20479 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20480 + put_cpu();
20481 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20482 + return;
20483 + }
20484 +
20485 + put_cpu();
20486 +
20487 + /* unknown stack */
20488 + BUG();
20489 +}
20490 +EXPORT_SYMBOL(pax_check_alloca);
20491 +#endif
20492 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20493 index 174da5f..5e55606 100644
20494 --- a/arch/x86/kernel/e820.c
20495 +++ b/arch/x86/kernel/e820.c
20496 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20497
20498 static void early_panic(char *msg)
20499 {
20500 - early_printk(msg);
20501 - panic(msg);
20502 + early_printk("%s", msg);
20503 + panic("%s", msg);
20504 }
20505
20506 static int userdef __initdata;
20507 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20508 index d15f575..d692043 100644
20509 --- a/arch/x86/kernel/early_printk.c
20510 +++ b/arch/x86/kernel/early_printk.c
20511 @@ -7,6 +7,7 @@
20512 #include <linux/pci_regs.h>
20513 #include <linux/pci_ids.h>
20514 #include <linux/errno.h>
20515 +#include <linux/sched.h>
20516 #include <asm/io.h>
20517 #include <asm/processor.h>
20518 #include <asm/fcntl.h>
20519 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20520 index 2cfbc3a..b756682 100644
20521 --- a/arch/x86/kernel/entry_32.S
20522 +++ b/arch/x86/kernel/entry_32.S
20523 @@ -177,13 +177,153 @@
20524 /*CFI_REL_OFFSET gs, PT_GS*/
20525 .endm
20526 .macro SET_KERNEL_GS reg
20527 +
20528 +#ifdef CONFIG_CC_STACKPROTECTOR
20529 movl $(__KERNEL_STACK_CANARY), \reg
20530 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20531 + movl $(__USER_DS), \reg
20532 +#else
20533 + xorl \reg, \reg
20534 +#endif
20535 +
20536 movl \reg, %gs
20537 .endm
20538
20539 #endif /* CONFIG_X86_32_LAZY_GS */
20540
20541 -.macro SAVE_ALL
20542 +.macro pax_enter_kernel
20543 +#ifdef CONFIG_PAX_KERNEXEC
20544 + call pax_enter_kernel
20545 +#endif
20546 +.endm
20547 +
20548 +.macro pax_exit_kernel
20549 +#ifdef CONFIG_PAX_KERNEXEC
20550 + call pax_exit_kernel
20551 +#endif
20552 +.endm
20553 +
20554 +#ifdef CONFIG_PAX_KERNEXEC
20555 +ENTRY(pax_enter_kernel)
20556 +#ifdef CONFIG_PARAVIRT
20557 + pushl %eax
20558 + pushl %ecx
20559 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20560 + mov %eax, %esi
20561 +#else
20562 + mov %cr0, %esi
20563 +#endif
20564 + bts $16, %esi
20565 + jnc 1f
20566 + mov %cs, %esi
20567 + cmp $__KERNEL_CS, %esi
20568 + jz 3f
20569 + ljmp $__KERNEL_CS, $3f
20570 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20571 +2:
20572 +#ifdef CONFIG_PARAVIRT
20573 + mov %esi, %eax
20574 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20575 +#else
20576 + mov %esi, %cr0
20577 +#endif
20578 +3:
20579 +#ifdef CONFIG_PARAVIRT
20580 + popl %ecx
20581 + popl %eax
20582 +#endif
20583 + ret
20584 +ENDPROC(pax_enter_kernel)
20585 +
20586 +ENTRY(pax_exit_kernel)
20587 +#ifdef CONFIG_PARAVIRT
20588 + pushl %eax
20589 + pushl %ecx
20590 +#endif
20591 + mov %cs, %esi
20592 + cmp $__KERNEXEC_KERNEL_CS, %esi
20593 + jnz 2f
20594 +#ifdef CONFIG_PARAVIRT
20595 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20596 + mov %eax, %esi
20597 +#else
20598 + mov %cr0, %esi
20599 +#endif
20600 + btr $16, %esi
20601 + ljmp $__KERNEL_CS, $1f
20602 +1:
20603 +#ifdef CONFIG_PARAVIRT
20604 + mov %esi, %eax
20605 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20606 +#else
20607 + mov %esi, %cr0
20608 +#endif
20609 +2:
20610 +#ifdef CONFIG_PARAVIRT
20611 + popl %ecx
20612 + popl %eax
20613 +#endif
20614 + ret
20615 +ENDPROC(pax_exit_kernel)
20616 +#endif
20617 +
20618 + .macro pax_erase_kstack
20619 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20620 + call pax_erase_kstack
20621 +#endif
20622 + .endm
20623 +
20624 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20625 +/*
20626 + * ebp: thread_info
20627 + */
20628 +ENTRY(pax_erase_kstack)
20629 + pushl %edi
20630 + pushl %ecx
20631 + pushl %eax
20632 +
20633 + mov TI_lowest_stack(%ebp), %edi
20634 + mov $-0xBEEF, %eax
20635 + std
20636 +
20637 +1: mov %edi, %ecx
20638 + and $THREAD_SIZE_asm - 1, %ecx
20639 + shr $2, %ecx
20640 + repne scasl
20641 + jecxz 2f
20642 +
20643 + cmp $2*16, %ecx
20644 + jc 2f
20645 +
20646 + mov $2*16, %ecx
20647 + repe scasl
20648 + jecxz 2f
20649 + jne 1b
20650 +
20651 +2: cld
20652 + mov %esp, %ecx
20653 + sub %edi, %ecx
20654 +
20655 + cmp $THREAD_SIZE_asm, %ecx
20656 + jb 3f
20657 + ud2
20658 +3:
20659 +
20660 + shr $2, %ecx
20661 + rep stosl
20662 +
20663 + mov TI_task_thread_sp0(%ebp), %edi
20664 + sub $128, %edi
20665 + mov %edi, TI_lowest_stack(%ebp)
20666 +
20667 + popl %eax
20668 + popl %ecx
20669 + popl %edi
20670 + ret
20671 +ENDPROC(pax_erase_kstack)
20672 +#endif
20673 +
20674 +.macro __SAVE_ALL _DS
20675 cld
20676 PUSH_GS
20677 pushl_cfi %fs
20678 @@ -206,7 +346,7 @@
20679 CFI_REL_OFFSET ecx, 0
20680 pushl_cfi %ebx
20681 CFI_REL_OFFSET ebx, 0
20682 - movl $(__USER_DS), %edx
20683 + movl $\_DS, %edx
20684 movl %edx, %ds
20685 movl %edx, %es
20686 movl $(__KERNEL_PERCPU), %edx
20687 @@ -214,6 +354,15 @@
20688 SET_KERNEL_GS %edx
20689 .endm
20690
20691 +.macro SAVE_ALL
20692 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20693 + __SAVE_ALL __KERNEL_DS
20694 + pax_enter_kernel
20695 +#else
20696 + __SAVE_ALL __USER_DS
20697 +#endif
20698 +.endm
20699 +
20700 .macro RESTORE_INT_REGS
20701 popl_cfi %ebx
20702 CFI_RESTORE ebx
20703 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20704 popfl_cfi
20705 jmp syscall_exit
20706 CFI_ENDPROC
20707 -END(ret_from_fork)
20708 +ENDPROC(ret_from_fork)
20709
20710 ENTRY(ret_from_kernel_thread)
20711 CFI_STARTPROC
20712 @@ -344,7 +493,15 @@ ret_from_intr:
20713 andl $SEGMENT_RPL_MASK, %eax
20714 #endif
20715 cmpl $USER_RPL, %eax
20716 +
20717 +#ifdef CONFIG_PAX_KERNEXEC
20718 + jae resume_userspace
20719 +
20720 + pax_exit_kernel
20721 + jmp resume_kernel
20722 +#else
20723 jb resume_kernel # not returning to v8086 or userspace
20724 +#endif
20725
20726 ENTRY(resume_userspace)
20727 LOCKDEP_SYS_EXIT
20728 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20729 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20730 # int/exception return?
20731 jne work_pending
20732 - jmp restore_all
20733 -END(ret_from_exception)
20734 + jmp restore_all_pax
20735 +ENDPROC(ret_from_exception)
20736
20737 #ifdef CONFIG_PREEMPT
20738 ENTRY(resume_kernel)
20739 @@ -372,7 +529,7 @@ need_resched:
20740 jz restore_all
20741 call preempt_schedule_irq
20742 jmp need_resched
20743 -END(resume_kernel)
20744 +ENDPROC(resume_kernel)
20745 #endif
20746 CFI_ENDPROC
20747 /*
20748 @@ -406,30 +563,45 @@ sysenter_past_esp:
20749 /*CFI_REL_OFFSET cs, 0*/
20750 /*
20751 * Push current_thread_info()->sysenter_return to the stack.
20752 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20753 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20754 */
20755 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20756 + pushl_cfi $0
20757 CFI_REL_OFFSET eip, 0
20758
20759 pushl_cfi %eax
20760 SAVE_ALL
20761 + GET_THREAD_INFO(%ebp)
20762 + movl TI_sysenter_return(%ebp),%ebp
20763 + movl %ebp,PT_EIP(%esp)
20764 ENABLE_INTERRUPTS(CLBR_NONE)
20765
20766 /*
20767 * Load the potential sixth argument from user stack.
20768 * Careful about security.
20769 */
20770 + movl PT_OLDESP(%esp),%ebp
20771 +
20772 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20773 + mov PT_OLDSS(%esp),%ds
20774 +1: movl %ds:(%ebp),%ebp
20775 + push %ss
20776 + pop %ds
20777 +#else
20778 cmpl $__PAGE_OFFSET-3,%ebp
20779 jae syscall_fault
20780 ASM_STAC
20781 1: movl (%ebp),%ebp
20782 ASM_CLAC
20783 +#endif
20784 +
20785 movl %ebp,PT_EBP(%esp)
20786 _ASM_EXTABLE(1b,syscall_fault)
20787
20788 GET_THREAD_INFO(%ebp)
20789
20790 +#ifdef CONFIG_PAX_RANDKSTACK
20791 + pax_erase_kstack
20792 +#endif
20793 +
20794 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20795 jnz sysenter_audit
20796 sysenter_do_call:
20797 @@ -444,12 +616,24 @@ sysenter_do_call:
20798 testl $_TIF_ALLWORK_MASK, %ecx
20799 jne sysexit_audit
20800 sysenter_exit:
20801 +
20802 +#ifdef CONFIG_PAX_RANDKSTACK
20803 + pushl_cfi %eax
20804 + movl %esp, %eax
20805 + call pax_randomize_kstack
20806 + popl_cfi %eax
20807 +#endif
20808 +
20809 + pax_erase_kstack
20810 +
20811 /* if something modifies registers it must also disable sysexit */
20812 movl PT_EIP(%esp), %edx
20813 movl PT_OLDESP(%esp), %ecx
20814 xorl %ebp,%ebp
20815 TRACE_IRQS_ON
20816 1: mov PT_FS(%esp), %fs
20817 +2: mov PT_DS(%esp), %ds
20818 +3: mov PT_ES(%esp), %es
20819 PTGS_TO_GS
20820 ENABLE_INTERRUPTS_SYSEXIT
20821
20822 @@ -466,6 +650,9 @@ sysenter_audit:
20823 movl %eax,%edx /* 2nd arg: syscall number */
20824 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20825 call __audit_syscall_entry
20826 +
20827 + pax_erase_kstack
20828 +
20829 pushl_cfi %ebx
20830 movl PT_EAX(%esp),%eax /* reload syscall number */
20831 jmp sysenter_do_call
20832 @@ -491,10 +678,16 @@ sysexit_audit:
20833
20834 CFI_ENDPROC
20835 .pushsection .fixup,"ax"
20836 -2: movl $0,PT_FS(%esp)
20837 +4: movl $0,PT_FS(%esp)
20838 + jmp 1b
20839 +5: movl $0,PT_DS(%esp)
20840 + jmp 1b
20841 +6: movl $0,PT_ES(%esp)
20842 jmp 1b
20843 .popsection
20844 - _ASM_EXTABLE(1b,2b)
20845 + _ASM_EXTABLE(1b,4b)
20846 + _ASM_EXTABLE(2b,5b)
20847 + _ASM_EXTABLE(3b,6b)
20848 PTGS_TO_GS_EX
20849 ENDPROC(ia32_sysenter_target)
20850
20851 @@ -509,6 +702,11 @@ ENTRY(system_call)
20852 pushl_cfi %eax # save orig_eax
20853 SAVE_ALL
20854 GET_THREAD_INFO(%ebp)
20855 +
20856 +#ifdef CONFIG_PAX_RANDKSTACK
20857 + pax_erase_kstack
20858 +#endif
20859 +
20860 # system call tracing in operation / emulation
20861 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20862 jnz syscall_trace_entry
20863 @@ -527,6 +725,15 @@ syscall_exit:
20864 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20865 jne syscall_exit_work
20866
20867 +restore_all_pax:
20868 +
20869 +#ifdef CONFIG_PAX_RANDKSTACK
20870 + movl %esp, %eax
20871 + call pax_randomize_kstack
20872 +#endif
20873 +
20874 + pax_erase_kstack
20875 +
20876 restore_all:
20877 TRACE_IRQS_IRET
20878 restore_all_notrace:
20879 @@ -583,14 +790,34 @@ ldt_ss:
20880 * compensating for the offset by changing to the ESPFIX segment with
20881 * a base address that matches for the difference.
20882 */
20883 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20884 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20885 mov %esp, %edx /* load kernel esp */
20886 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20887 mov %dx, %ax /* eax: new kernel esp */
20888 sub %eax, %edx /* offset (low word is 0) */
20889 +#ifdef CONFIG_SMP
20890 + movl PER_CPU_VAR(cpu_number), %ebx
20891 + shll $PAGE_SHIFT_asm, %ebx
20892 + addl $cpu_gdt_table, %ebx
20893 +#else
20894 + movl $cpu_gdt_table, %ebx
20895 +#endif
20896 shr $16, %edx
20897 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20898 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20899 +
20900 +#ifdef CONFIG_PAX_KERNEXEC
20901 + mov %cr0, %esi
20902 + btr $16, %esi
20903 + mov %esi, %cr0
20904 +#endif
20905 +
20906 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20907 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20908 +
20909 +#ifdef CONFIG_PAX_KERNEXEC
20910 + bts $16, %esi
20911 + mov %esi, %cr0
20912 +#endif
20913 +
20914 pushl_cfi $__ESPFIX_SS
20915 pushl_cfi %eax /* new kernel esp */
20916 /* Disable interrupts, but do not irqtrace this section: we
20917 @@ -619,20 +846,18 @@ work_resched:
20918 movl TI_flags(%ebp), %ecx
20919 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20920 # than syscall tracing?
20921 - jz restore_all
20922 + jz restore_all_pax
20923 testb $_TIF_NEED_RESCHED, %cl
20924 jnz work_resched
20925
20926 work_notifysig: # deal with pending signals and
20927 # notify-resume requests
20928 + movl %esp, %eax
20929 #ifdef CONFIG_VM86
20930 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20931 - movl %esp, %eax
20932 jne work_notifysig_v86 # returning to kernel-space or
20933 # vm86-space
20934 1:
20935 -#else
20936 - movl %esp, %eax
20937 #endif
20938 TRACE_IRQS_ON
20939 ENABLE_INTERRUPTS(CLBR_NONE)
20940 @@ -653,7 +878,7 @@ work_notifysig_v86:
20941 movl %eax, %esp
20942 jmp 1b
20943 #endif
20944 -END(work_pending)
20945 +ENDPROC(work_pending)
20946
20947 # perform syscall exit tracing
20948 ALIGN
20949 @@ -661,11 +886,14 @@ syscall_trace_entry:
20950 movl $-ENOSYS,PT_EAX(%esp)
20951 movl %esp, %eax
20952 call syscall_trace_enter
20953 +
20954 + pax_erase_kstack
20955 +
20956 /* What it returned is what we'll actually use. */
20957 cmpl $(NR_syscalls), %eax
20958 jnae syscall_call
20959 jmp syscall_exit
20960 -END(syscall_trace_entry)
20961 +ENDPROC(syscall_trace_entry)
20962
20963 # perform syscall exit tracing
20964 ALIGN
20965 @@ -678,21 +906,25 @@ syscall_exit_work:
20966 movl %esp, %eax
20967 call syscall_trace_leave
20968 jmp resume_userspace
20969 -END(syscall_exit_work)
20970 +ENDPROC(syscall_exit_work)
20971 CFI_ENDPROC
20972
20973 RING0_INT_FRAME # can't unwind into user space anyway
20974 syscall_fault:
20975 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20976 + push %ss
20977 + pop %ds
20978 +#endif
20979 ASM_CLAC
20980 GET_THREAD_INFO(%ebp)
20981 movl $-EFAULT,PT_EAX(%esp)
20982 jmp resume_userspace
20983 -END(syscall_fault)
20984 +ENDPROC(syscall_fault)
20985
20986 syscall_badsys:
20987 movl $-ENOSYS,PT_EAX(%esp)
20988 jmp resume_userspace
20989 -END(syscall_badsys)
20990 +ENDPROC(syscall_badsys)
20991 CFI_ENDPROC
20992 /*
20993 * End of kprobes section
20994 @@ -708,8 +940,15 @@ END(syscall_badsys)
20995 * normal stack and adjusts ESP with the matching offset.
20996 */
20997 /* fixup the stack */
20998 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
20999 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21000 +#ifdef CONFIG_SMP
21001 + movl PER_CPU_VAR(cpu_number), %ebx
21002 + shll $PAGE_SHIFT_asm, %ebx
21003 + addl $cpu_gdt_table, %ebx
21004 +#else
21005 + movl $cpu_gdt_table, %ebx
21006 +#endif
21007 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21008 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21009 shl $16, %eax
21010 addl %esp, %eax /* the adjusted stack pointer */
21011 pushl_cfi $__KERNEL_DS
21012 @@ -762,7 +1001,7 @@ vector=vector+1
21013 .endr
21014 2: jmp common_interrupt
21015 .endr
21016 -END(irq_entries_start)
21017 +ENDPROC(irq_entries_start)
21018
21019 .previous
21020 END(interrupt)
21021 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21022 pushl_cfi $do_coprocessor_error
21023 jmp error_code
21024 CFI_ENDPROC
21025 -END(coprocessor_error)
21026 +ENDPROC(coprocessor_error)
21027
21028 ENTRY(simd_coprocessor_error)
21029 RING0_INT_FRAME
21030 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21031 .section .altinstructions,"a"
21032 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21033 .previous
21034 -.section .altinstr_replacement,"ax"
21035 +.section .altinstr_replacement,"a"
21036 663: pushl $do_simd_coprocessor_error
21037 664:
21038 .previous
21039 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21040 #endif
21041 jmp error_code
21042 CFI_ENDPROC
21043 -END(simd_coprocessor_error)
21044 +ENDPROC(simd_coprocessor_error)
21045
21046 ENTRY(device_not_available)
21047 RING0_INT_FRAME
21048 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21049 pushl_cfi $do_device_not_available
21050 jmp error_code
21051 CFI_ENDPROC
21052 -END(device_not_available)
21053 +ENDPROC(device_not_available)
21054
21055 #ifdef CONFIG_PARAVIRT
21056 ENTRY(native_iret)
21057 iret
21058 _ASM_EXTABLE(native_iret, iret_exc)
21059 -END(native_iret)
21060 +ENDPROC(native_iret)
21061
21062 ENTRY(native_irq_enable_sysexit)
21063 sti
21064 sysexit
21065 -END(native_irq_enable_sysexit)
21066 +ENDPROC(native_irq_enable_sysexit)
21067 #endif
21068
21069 ENTRY(overflow)
21070 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21071 pushl_cfi $do_overflow
21072 jmp error_code
21073 CFI_ENDPROC
21074 -END(overflow)
21075 +ENDPROC(overflow)
21076
21077 ENTRY(bounds)
21078 RING0_INT_FRAME
21079 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21080 pushl_cfi $do_bounds
21081 jmp error_code
21082 CFI_ENDPROC
21083 -END(bounds)
21084 +ENDPROC(bounds)
21085
21086 ENTRY(invalid_op)
21087 RING0_INT_FRAME
21088 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21089 pushl_cfi $do_invalid_op
21090 jmp error_code
21091 CFI_ENDPROC
21092 -END(invalid_op)
21093 +ENDPROC(invalid_op)
21094
21095 ENTRY(coprocessor_segment_overrun)
21096 RING0_INT_FRAME
21097 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21098 pushl_cfi $do_coprocessor_segment_overrun
21099 jmp error_code
21100 CFI_ENDPROC
21101 -END(coprocessor_segment_overrun)
21102 +ENDPROC(coprocessor_segment_overrun)
21103
21104 ENTRY(invalid_TSS)
21105 RING0_EC_FRAME
21106 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21107 pushl_cfi $do_invalid_TSS
21108 jmp error_code
21109 CFI_ENDPROC
21110 -END(invalid_TSS)
21111 +ENDPROC(invalid_TSS)
21112
21113 ENTRY(segment_not_present)
21114 RING0_EC_FRAME
21115 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21116 pushl_cfi $do_segment_not_present
21117 jmp error_code
21118 CFI_ENDPROC
21119 -END(segment_not_present)
21120 +ENDPROC(segment_not_present)
21121
21122 ENTRY(stack_segment)
21123 RING0_EC_FRAME
21124 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21125 pushl_cfi $do_stack_segment
21126 jmp error_code
21127 CFI_ENDPROC
21128 -END(stack_segment)
21129 +ENDPROC(stack_segment)
21130
21131 ENTRY(alignment_check)
21132 RING0_EC_FRAME
21133 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21134 pushl_cfi $do_alignment_check
21135 jmp error_code
21136 CFI_ENDPROC
21137 -END(alignment_check)
21138 +ENDPROC(alignment_check)
21139
21140 ENTRY(divide_error)
21141 RING0_INT_FRAME
21142 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21143 pushl_cfi $do_divide_error
21144 jmp error_code
21145 CFI_ENDPROC
21146 -END(divide_error)
21147 +ENDPROC(divide_error)
21148
21149 #ifdef CONFIG_X86_MCE
21150 ENTRY(machine_check)
21151 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21152 pushl_cfi machine_check_vector
21153 jmp error_code
21154 CFI_ENDPROC
21155 -END(machine_check)
21156 +ENDPROC(machine_check)
21157 #endif
21158
21159 ENTRY(spurious_interrupt_bug)
21160 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21161 pushl_cfi $do_spurious_interrupt_bug
21162 jmp error_code
21163 CFI_ENDPROC
21164 -END(spurious_interrupt_bug)
21165 +ENDPROC(spurious_interrupt_bug)
21166 /*
21167 * End of kprobes section
21168 */
21169 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21170
21171 ENTRY(mcount)
21172 ret
21173 -END(mcount)
21174 +ENDPROC(mcount)
21175
21176 ENTRY(ftrace_caller)
21177 cmpl $0, function_trace_stop
21178 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21179 .globl ftrace_stub
21180 ftrace_stub:
21181 ret
21182 -END(ftrace_caller)
21183 +ENDPROC(ftrace_caller)
21184
21185 ENTRY(ftrace_regs_caller)
21186 pushf /* push flags before compare (in cs location) */
21187 @@ -1207,7 +1446,7 @@ trace:
21188 popl %ecx
21189 popl %eax
21190 jmp ftrace_stub
21191 -END(mcount)
21192 +ENDPROC(mcount)
21193 #endif /* CONFIG_DYNAMIC_FTRACE */
21194 #endif /* CONFIG_FUNCTION_TRACER */
21195
21196 @@ -1225,7 +1464,7 @@ ENTRY(ftrace_graph_caller)
21197 popl %ecx
21198 popl %eax
21199 ret
21200 -END(ftrace_graph_caller)
21201 +ENDPROC(ftrace_graph_caller)
21202
21203 .globl return_to_handler
21204 return_to_handler:
21205 @@ -1281,15 +1520,18 @@ error_code:
21206 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21207 REG_TO_PTGS %ecx
21208 SET_KERNEL_GS %ecx
21209 - movl $(__USER_DS), %ecx
21210 + movl $(__KERNEL_DS), %ecx
21211 movl %ecx, %ds
21212 movl %ecx, %es
21213 +
21214 + pax_enter_kernel
21215 +
21216 TRACE_IRQS_OFF
21217 movl %esp,%eax # pt_regs pointer
21218 call *%edi
21219 jmp ret_from_exception
21220 CFI_ENDPROC
21221 -END(page_fault)
21222 +ENDPROC(page_fault)
21223
21224 /*
21225 * Debug traps and NMI can happen at the one SYSENTER instruction
21226 @@ -1332,7 +1574,7 @@ debug_stack_correct:
21227 call do_debug
21228 jmp ret_from_exception
21229 CFI_ENDPROC
21230 -END(debug)
21231 +ENDPROC(debug)
21232
21233 /*
21234 * NMI is doubly nasty. It can happen _while_ we're handling
21235 @@ -1370,6 +1612,9 @@ nmi_stack_correct:
21236 xorl %edx,%edx # zero error code
21237 movl %esp,%eax # pt_regs pointer
21238 call do_nmi
21239 +
21240 + pax_exit_kernel
21241 +
21242 jmp restore_all_notrace
21243 CFI_ENDPROC
21244
21245 @@ -1406,12 +1651,15 @@ nmi_espfix_stack:
21246 FIXUP_ESPFIX_STACK # %eax == %esp
21247 xorl %edx,%edx # zero error code
21248 call do_nmi
21249 +
21250 + pax_exit_kernel
21251 +
21252 RESTORE_REGS
21253 lss 12+4(%esp), %esp # back to espfix stack
21254 CFI_ADJUST_CFA_OFFSET -24
21255 jmp irq_return
21256 CFI_ENDPROC
21257 -END(nmi)
21258 +ENDPROC(nmi)
21259
21260 ENTRY(int3)
21261 RING0_INT_FRAME
21262 @@ -1424,14 +1672,14 @@ ENTRY(int3)
21263 call do_int3
21264 jmp ret_from_exception
21265 CFI_ENDPROC
21266 -END(int3)
21267 +ENDPROC(int3)
21268
21269 ENTRY(general_protection)
21270 RING0_EC_FRAME
21271 pushl_cfi $do_general_protection
21272 jmp error_code
21273 CFI_ENDPROC
21274 -END(general_protection)
21275 +ENDPROC(general_protection)
21276
21277 #ifdef CONFIG_KVM_GUEST
21278 ENTRY(async_page_fault)
21279 @@ -1440,7 +1688,7 @@ ENTRY(async_page_fault)
21280 pushl_cfi $do_async_page_fault
21281 jmp error_code
21282 CFI_ENDPROC
21283 -END(async_page_fault)
21284 +ENDPROC(async_page_fault)
21285 #endif
21286
21287 /*
21288 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21289 index 1b69951..8430a6d 100644
21290 --- a/arch/x86/kernel/entry_64.S
21291 +++ b/arch/x86/kernel/entry_64.S
21292 @@ -59,6 +59,8 @@
21293 #include <asm/context_tracking.h>
21294 #include <asm/smap.h>
21295 #include <linux/err.h>
21296 +#include <asm/pgtable.h>
21297 +#include <asm/alternative-asm.h>
21298
21299 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21300 #include <linux/elf-em.h>
21301 @@ -80,8 +82,9 @@
21302 #ifdef CONFIG_DYNAMIC_FTRACE
21303
21304 ENTRY(function_hook)
21305 + pax_force_retaddr
21306 retq
21307 -END(function_hook)
21308 +ENDPROC(function_hook)
21309
21310 /* skip is set if stack has been adjusted */
21311 .macro ftrace_caller_setup skip=0
21312 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21313 #endif
21314
21315 GLOBAL(ftrace_stub)
21316 + pax_force_retaddr
21317 retq
21318 -END(ftrace_caller)
21319 +ENDPROC(ftrace_caller)
21320
21321 ENTRY(ftrace_regs_caller)
21322 /* Save the current flags before compare (in SS location)*/
21323 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21324 popfq
21325 jmp ftrace_stub
21326
21327 -END(ftrace_regs_caller)
21328 +ENDPROC(ftrace_regs_caller)
21329
21330
21331 #else /* ! CONFIG_DYNAMIC_FTRACE */
21332 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21333 #endif
21334
21335 GLOBAL(ftrace_stub)
21336 + pax_force_retaddr
21337 retq
21338
21339 trace:
21340 @@ -225,12 +230,13 @@ trace:
21341 #endif
21342 subq $MCOUNT_INSN_SIZE, %rdi
21343
21344 + pax_force_fptr ftrace_trace_function
21345 call *ftrace_trace_function
21346
21347 MCOUNT_RESTORE_FRAME
21348
21349 jmp ftrace_stub
21350 -END(function_hook)
21351 +ENDPROC(function_hook)
21352 #endif /* CONFIG_DYNAMIC_FTRACE */
21353 #endif /* CONFIG_FUNCTION_TRACER */
21354
21355 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21356
21357 MCOUNT_RESTORE_FRAME
21358
21359 + pax_force_retaddr
21360 retq
21361 -END(ftrace_graph_caller)
21362 +ENDPROC(ftrace_graph_caller)
21363
21364 GLOBAL(return_to_handler)
21365 subq $24, %rsp
21366 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21367 movq 8(%rsp), %rdx
21368 movq (%rsp), %rax
21369 addq $24, %rsp
21370 + pax_force_fptr %rdi
21371 jmp *%rdi
21372 +ENDPROC(return_to_handler)
21373 #endif
21374
21375
21376 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21377 ENDPROC(native_usergs_sysret64)
21378 #endif /* CONFIG_PARAVIRT */
21379
21380 + .macro ljmpq sel, off
21381 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21382 + .byte 0x48; ljmp *1234f(%rip)
21383 + .pushsection .rodata
21384 + .align 16
21385 + 1234: .quad \off; .word \sel
21386 + .popsection
21387 +#else
21388 + pushq $\sel
21389 + pushq $\off
21390 + lretq
21391 +#endif
21392 + .endm
21393 +
21394 + .macro pax_enter_kernel
21395 + pax_set_fptr_mask
21396 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21397 + call pax_enter_kernel
21398 +#endif
21399 + .endm
21400 +
21401 + .macro pax_exit_kernel
21402 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21403 + call pax_exit_kernel
21404 +#endif
21405 +
21406 + .endm
21407 +
21408 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21409 +ENTRY(pax_enter_kernel)
21410 + pushq %rdi
21411 +
21412 +#ifdef CONFIG_PARAVIRT
21413 + PV_SAVE_REGS(CLBR_RDI)
21414 +#endif
21415 +
21416 +#ifdef CONFIG_PAX_KERNEXEC
21417 + GET_CR0_INTO_RDI
21418 + bts $16,%rdi
21419 + jnc 3f
21420 + mov %cs,%edi
21421 + cmp $__KERNEL_CS,%edi
21422 + jnz 2f
21423 +1:
21424 +#endif
21425 +
21426 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21427 + 661: jmp 111f
21428 + .pushsection .altinstr_replacement, "a"
21429 + 662: ASM_NOP2
21430 + .popsection
21431 + .pushsection .altinstructions, "a"
21432 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21433 + .popsection
21434 + GET_CR3_INTO_RDI
21435 + cmp $0,%dil
21436 + jnz 112f
21437 + mov $__KERNEL_DS,%edi
21438 + mov %edi,%ss
21439 + jmp 111f
21440 +112: cmp $1,%dil
21441 + jz 113f
21442 + ud2
21443 +113: sub $4097,%rdi
21444 + bts $63,%rdi
21445 + SET_RDI_INTO_CR3
21446 + mov $__UDEREF_KERNEL_DS,%edi
21447 + mov %edi,%ss
21448 +111:
21449 +#endif
21450 +
21451 +#ifdef CONFIG_PARAVIRT
21452 + PV_RESTORE_REGS(CLBR_RDI)
21453 +#endif
21454 +
21455 + popq %rdi
21456 + pax_force_retaddr
21457 + retq
21458 +
21459 +#ifdef CONFIG_PAX_KERNEXEC
21460 +2: ljmpq __KERNEL_CS,1b
21461 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21462 +4: SET_RDI_INTO_CR0
21463 + jmp 1b
21464 +#endif
21465 +ENDPROC(pax_enter_kernel)
21466 +
21467 +ENTRY(pax_exit_kernel)
21468 + pushq %rdi
21469 +
21470 +#ifdef CONFIG_PARAVIRT
21471 + PV_SAVE_REGS(CLBR_RDI)
21472 +#endif
21473 +
21474 +#ifdef CONFIG_PAX_KERNEXEC
21475 + mov %cs,%rdi
21476 + cmp $__KERNEXEC_KERNEL_CS,%edi
21477 + jz 2f
21478 + GET_CR0_INTO_RDI
21479 + bts $16,%rdi
21480 + jnc 4f
21481 +1:
21482 +#endif
21483 +
21484 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21485 + 661: jmp 111f
21486 + .pushsection .altinstr_replacement, "a"
21487 + 662: ASM_NOP2
21488 + .popsection
21489 + .pushsection .altinstructions, "a"
21490 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21491 + .popsection
21492 + mov %ss,%edi
21493 + cmp $__UDEREF_KERNEL_DS,%edi
21494 + jnz 111f
21495 + GET_CR3_INTO_RDI
21496 + cmp $0,%dil
21497 + jz 112f
21498 + ud2
21499 +112: add $4097,%rdi
21500 + bts $63,%rdi
21501 + SET_RDI_INTO_CR3
21502 + mov $__KERNEL_DS,%edi
21503 + mov %edi,%ss
21504 +111:
21505 +#endif
21506 +
21507 +#ifdef CONFIG_PARAVIRT
21508 + PV_RESTORE_REGS(CLBR_RDI);
21509 +#endif
21510 +
21511 + popq %rdi
21512 + pax_force_retaddr
21513 + retq
21514 +
21515 +#ifdef CONFIG_PAX_KERNEXEC
21516 +2: GET_CR0_INTO_RDI
21517 + btr $16,%rdi
21518 + jnc 4f
21519 + ljmpq __KERNEL_CS,3f
21520 +3: SET_RDI_INTO_CR0
21521 + jmp 1b
21522 +4: ud2
21523 + jmp 4b
21524 +#endif
21525 +ENDPROC(pax_exit_kernel)
21526 +#endif
21527 +
21528 + .macro pax_enter_kernel_user
21529 + pax_set_fptr_mask
21530 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21531 + call pax_enter_kernel_user
21532 +#endif
21533 + .endm
21534 +
21535 + .macro pax_exit_kernel_user
21536 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21537 + call pax_exit_kernel_user
21538 +#endif
21539 +#ifdef CONFIG_PAX_RANDKSTACK
21540 + pushq %rax
21541 + pushq %r11
21542 + call pax_randomize_kstack
21543 + popq %r11
21544 + popq %rax
21545 +#endif
21546 + .endm
21547 +
21548 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21549 +ENTRY(pax_enter_kernel_user)
21550 + pushq %rdi
21551 + pushq %rbx
21552 +
21553 +#ifdef CONFIG_PARAVIRT
21554 + PV_SAVE_REGS(CLBR_RDI)
21555 +#endif
21556 +
21557 + 661: jmp 111f
21558 + .pushsection .altinstr_replacement, "a"
21559 + 662: ASM_NOP2
21560 + .popsection
21561 + .pushsection .altinstructions, "a"
21562 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21563 + .popsection
21564 + GET_CR3_INTO_RDI
21565 + cmp $1,%dil
21566 + jnz 4f
21567 + sub $4097,%rdi
21568 + bts $63,%rdi
21569 + SET_RDI_INTO_CR3
21570 + jmp 3f
21571 +111:
21572 +
21573 + GET_CR3_INTO_RDI
21574 + mov %rdi,%rbx
21575 + add $__START_KERNEL_map,%rbx
21576 + sub phys_base(%rip),%rbx
21577 +
21578 +#ifdef CONFIG_PARAVIRT
21579 + cmpl $0, pv_info+PARAVIRT_enabled
21580 + jz 1f
21581 + pushq %rdi
21582 + i = 0
21583 + .rept USER_PGD_PTRS
21584 + mov i*8(%rbx),%rsi
21585 + mov $0,%sil
21586 + lea i*8(%rbx),%rdi
21587 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21588 + i = i + 1
21589 + .endr
21590 + popq %rdi
21591 + jmp 2f
21592 +1:
21593 +#endif
21594 +
21595 + i = 0
21596 + .rept USER_PGD_PTRS
21597 + movb $0,i*8(%rbx)
21598 + i = i + 1
21599 + .endr
21600 +
21601 +2: SET_RDI_INTO_CR3
21602 +
21603 +#ifdef CONFIG_PAX_KERNEXEC
21604 + GET_CR0_INTO_RDI
21605 + bts $16,%rdi
21606 + SET_RDI_INTO_CR0
21607 +#endif
21608 +
21609 +3:
21610 +
21611 +#ifdef CONFIG_PARAVIRT
21612 + PV_RESTORE_REGS(CLBR_RDI)
21613 +#endif
21614 +
21615 + popq %rbx
21616 + popq %rdi
21617 + pax_force_retaddr
21618 + retq
21619 +4: ud2
21620 +ENDPROC(pax_enter_kernel_user)
21621 +
21622 +ENTRY(pax_exit_kernel_user)
21623 + pushq %rdi
21624 + pushq %rbx
21625 +
21626 +#ifdef CONFIG_PARAVIRT
21627 + PV_SAVE_REGS(CLBR_RDI)
21628 +#endif
21629 +
21630 + GET_CR3_INTO_RDI
21631 + 661: jmp 1f
21632 + .pushsection .altinstr_replacement, "a"
21633 + 662: ASM_NOP2
21634 + .popsection
21635 + .pushsection .altinstructions, "a"
21636 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21637 + .popsection
21638 + cmp $0,%dil
21639 + jnz 3f
21640 + add $4097,%rdi
21641 + bts $63,%rdi
21642 + SET_RDI_INTO_CR3
21643 + jmp 2f
21644 +1:
21645 +
21646 + mov %rdi,%rbx
21647 +
21648 +#ifdef CONFIG_PAX_KERNEXEC
21649 + GET_CR0_INTO_RDI
21650 + btr $16,%rdi
21651 + jnc 3f
21652 + SET_RDI_INTO_CR0
21653 +#endif
21654 +
21655 + add $__START_KERNEL_map,%rbx
21656 + sub phys_base(%rip),%rbx
21657 +
21658 +#ifdef CONFIG_PARAVIRT
21659 + cmpl $0, pv_info+PARAVIRT_enabled
21660 + jz 1f
21661 + i = 0
21662 + .rept USER_PGD_PTRS
21663 + mov i*8(%rbx),%rsi
21664 + mov $0x67,%sil
21665 + lea i*8(%rbx),%rdi
21666 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21667 + i = i + 1
21668 + .endr
21669 + jmp 2f
21670 +1:
21671 +#endif
21672 +
21673 + i = 0
21674 + .rept USER_PGD_PTRS
21675 + movb $0x67,i*8(%rbx)
21676 + i = i + 1
21677 + .endr
21678 +2:
21679 +
21680 +#ifdef CONFIG_PARAVIRT
21681 + PV_RESTORE_REGS(CLBR_RDI)
21682 +#endif
21683 +
21684 + popq %rbx
21685 + popq %rdi
21686 + pax_force_retaddr
21687 + retq
21688 +3: ud2
21689 +ENDPROC(pax_exit_kernel_user)
21690 +#endif
21691 +
21692 + .macro pax_enter_kernel_nmi
21693 + pax_set_fptr_mask
21694 +
21695 +#ifdef CONFIG_PAX_KERNEXEC
21696 + GET_CR0_INTO_RDI
21697 + bts $16,%rdi
21698 + jc 110f
21699 + SET_RDI_INTO_CR0
21700 + or $2,%ebx
21701 +110:
21702 +#endif
21703 +
21704 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21705 + 661: jmp 111f
21706 + .pushsection .altinstr_replacement, "a"
21707 + 662: ASM_NOP2
21708 + .popsection
21709 + .pushsection .altinstructions, "a"
21710 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21711 + .popsection
21712 + GET_CR3_INTO_RDI
21713 + cmp $0,%dil
21714 + jz 111f
21715 + sub $4097,%rdi
21716 + or $4,%ebx
21717 + bts $63,%rdi
21718 + SET_RDI_INTO_CR3
21719 + mov $__UDEREF_KERNEL_DS,%edi
21720 + mov %edi,%ss
21721 +111:
21722 +#endif
21723 + .endm
21724 +
21725 + .macro pax_exit_kernel_nmi
21726 +#ifdef CONFIG_PAX_KERNEXEC
21727 + btr $1,%ebx
21728 + jnc 110f
21729 + GET_CR0_INTO_RDI
21730 + btr $16,%rdi
21731 + SET_RDI_INTO_CR0
21732 +110:
21733 +#endif
21734 +
21735 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21736 + btr $2,%ebx
21737 + jnc 111f
21738 + GET_CR3_INTO_RDI
21739 + add $4097,%rdi
21740 + bts $63,%rdi
21741 + SET_RDI_INTO_CR3
21742 + mov $__KERNEL_DS,%edi
21743 + mov %edi,%ss
21744 +111:
21745 +#endif
21746 + .endm
21747 +
21748 + .macro pax_erase_kstack
21749 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21750 + call pax_erase_kstack
21751 +#endif
21752 + .endm
21753 +
21754 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21755 +ENTRY(pax_erase_kstack)
21756 + pushq %rdi
21757 + pushq %rcx
21758 + pushq %rax
21759 + pushq %r11
21760 +
21761 + GET_THREAD_INFO(%r11)
21762 + mov TI_lowest_stack(%r11), %rdi
21763 + mov $-0xBEEF, %rax
21764 + std
21765 +
21766 +1: mov %edi, %ecx
21767 + and $THREAD_SIZE_asm - 1, %ecx
21768 + shr $3, %ecx
21769 + repne scasq
21770 + jecxz 2f
21771 +
21772 + cmp $2*8, %ecx
21773 + jc 2f
21774 +
21775 + mov $2*8, %ecx
21776 + repe scasq
21777 + jecxz 2f
21778 + jne 1b
21779 +
21780 +2: cld
21781 + mov %esp, %ecx
21782 + sub %edi, %ecx
21783 +
21784 + cmp $THREAD_SIZE_asm, %rcx
21785 + jb 3f
21786 + ud2
21787 +3:
21788 +
21789 + shr $3, %ecx
21790 + rep stosq
21791 +
21792 + mov TI_task_thread_sp0(%r11), %rdi
21793 + sub $256, %rdi
21794 + mov %rdi, TI_lowest_stack(%r11)
21795 +
21796 + popq %r11
21797 + popq %rax
21798 + popq %rcx
21799 + popq %rdi
21800 + pax_force_retaddr
21801 + ret
21802 +ENDPROC(pax_erase_kstack)
21803 +#endif
21804
21805 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21806 #ifdef CONFIG_TRACE_IRQFLAGS
21807 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21808 .endm
21809
21810 .macro UNFAKE_STACK_FRAME
21811 - addq $8*6, %rsp
21812 - CFI_ADJUST_CFA_OFFSET -(6*8)
21813 + addq $8*6 + ARG_SKIP, %rsp
21814 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21815 .endm
21816
21817 /*
21818 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21819 movq %rsp, %rsi
21820
21821 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21822 - testl $3, CS-RBP(%rsi)
21823 + testb $3, CS-RBP(%rsi)
21824 je 1f
21825 SWAPGS
21826 /*
21827 @@ -498,9 +931,10 @@ ENTRY(save_rest)
21828 movq_cfi r15, R15+16
21829 movq %r11, 8(%rsp) /* return address */
21830 FIXUP_TOP_OF_STACK %r11, 16
21831 + pax_force_retaddr
21832 ret
21833 CFI_ENDPROC
21834 -END(save_rest)
21835 +ENDPROC(save_rest)
21836
21837 /* save complete stack frame */
21838 .pushsection .kprobes.text, "ax"
21839 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
21840 js 1f /* negative -> in kernel */
21841 SWAPGS
21842 xorl %ebx,%ebx
21843 -1: ret
21844 +1: pax_force_retaddr_bts
21845 + ret
21846 CFI_ENDPROC
21847 -END(save_paranoid)
21848 +ENDPROC(save_paranoid)
21849 .popsection
21850
21851 /*
21852 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
21853
21854 RESTORE_REST
21855
21856 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21857 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21858 jz 1f
21859
21860 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21861 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
21862 RESTORE_REST
21863 jmp int_ret_from_sys_call
21864 CFI_ENDPROC
21865 -END(ret_from_fork)
21866 +ENDPROC(ret_from_fork)
21867
21868 /*
21869 * System call entry. Up to 6 arguments in registers are supported.
21870 @@ -608,7 +1043,7 @@ END(ret_from_fork)
21871 ENTRY(system_call)
21872 CFI_STARTPROC simple
21873 CFI_SIGNAL_FRAME
21874 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21875 + CFI_DEF_CFA rsp,0
21876 CFI_REGISTER rip,rcx
21877 /*CFI_REGISTER rflags,r11*/
21878 SWAPGS_UNSAFE_STACK
21879 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
21880
21881 movq %rsp,PER_CPU_VAR(old_rsp)
21882 movq PER_CPU_VAR(kernel_stack),%rsp
21883 + SAVE_ARGS 8*6,0
21884 + pax_enter_kernel_user
21885 +
21886 +#ifdef CONFIG_PAX_RANDKSTACK
21887 + pax_erase_kstack
21888 +#endif
21889 +
21890 /*
21891 * No need to follow this irqs off/on section - it's straight
21892 * and short:
21893 */
21894 ENABLE_INTERRUPTS(CLBR_NONE)
21895 - SAVE_ARGS 8,0
21896 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21897 movq %rcx,RIP-ARGOFFSET(%rsp)
21898 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21899 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21900 + GET_THREAD_INFO(%rcx)
21901 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21902 jnz tracesys
21903 system_call_fastpath:
21904 #if __SYSCALL_MASK == ~0
21905 @@ -640,7 +1082,7 @@ system_call_fastpath:
21906 cmpl $__NR_syscall_max,%eax
21907 #endif
21908 ja badsys
21909 - movq %r10,%rcx
21910 + movq R10-ARGOFFSET(%rsp),%rcx
21911 call *sys_call_table(,%rax,8) # XXX: rip relative
21912 movq %rax,RAX-ARGOFFSET(%rsp)
21913 /*
21914 @@ -654,10 +1096,13 @@ sysret_check:
21915 LOCKDEP_SYS_EXIT
21916 DISABLE_INTERRUPTS(CLBR_NONE)
21917 TRACE_IRQS_OFF
21918 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21919 + GET_THREAD_INFO(%rcx)
21920 + movl TI_flags(%rcx),%edx
21921 andl %edi,%edx
21922 jnz sysret_careful
21923 CFI_REMEMBER_STATE
21924 + pax_exit_kernel_user
21925 + pax_erase_kstack
21926 /*
21927 * sysretq will re-enable interrupts:
21928 */
21929 @@ -709,14 +1154,18 @@ badsys:
21930 * jump back to the normal fast path.
21931 */
21932 auditsys:
21933 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21934 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21935 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21936 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21937 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21938 movq %rax,%rsi /* 2nd arg: syscall number */
21939 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21940 call __audit_syscall_entry
21941 +
21942 + pax_erase_kstack
21943 +
21944 LOAD_ARGS 0 /* reload call-clobbered registers */
21945 + pax_set_fptr_mask
21946 jmp system_call_fastpath
21947
21948 /*
21949 @@ -737,7 +1186,7 @@ sysret_audit:
21950 /* Do syscall tracing */
21951 tracesys:
21952 #ifdef CONFIG_AUDITSYSCALL
21953 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21954 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21955 jz auditsys
21956 #endif
21957 SAVE_REST
21958 @@ -745,12 +1194,16 @@ tracesys:
21959 FIXUP_TOP_OF_STACK %rdi
21960 movq %rsp,%rdi
21961 call syscall_trace_enter
21962 +
21963 + pax_erase_kstack
21964 +
21965 /*
21966 * Reload arg registers from stack in case ptrace changed them.
21967 * We don't reload %rax because syscall_trace_enter() returned
21968 * the value it wants us to use in the table lookup.
21969 */
21970 LOAD_ARGS ARGOFFSET, 1
21971 + pax_set_fptr_mask
21972 RESTORE_REST
21973 #if __SYSCALL_MASK == ~0
21974 cmpq $__NR_syscall_max,%rax
21975 @@ -759,7 +1212,7 @@ tracesys:
21976 cmpl $__NR_syscall_max,%eax
21977 #endif
21978 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21979 - movq %r10,%rcx /* fixup for C */
21980 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21981 call *sys_call_table(,%rax,8)
21982 movq %rax,RAX-ARGOFFSET(%rsp)
21983 /* Use IRET because user could have changed frame */
21984 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
21985 andl %edi,%edx
21986 jnz int_careful
21987 andl $~TS_COMPAT,TI_status(%rcx)
21988 - jmp retint_swapgs
21989 + pax_exit_kernel_user
21990 + pax_erase_kstack
21991 + jmp retint_swapgs_pax
21992
21993 /* Either reschedule or signal or syscall exit tracking needed. */
21994 /* First do a reschedule test. */
21995 @@ -826,7 +1281,7 @@ int_restore_rest:
21996 TRACE_IRQS_OFF
21997 jmp int_with_check
21998 CFI_ENDPROC
21999 -END(system_call)
22000 +ENDPROC(system_call)
22001
22002 .macro FORK_LIKE func
22003 ENTRY(stub_\func)
22004 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
22005 DEFAULT_FRAME 0 8 /* offset 8: return address */
22006 call sys_\func
22007 RESTORE_TOP_OF_STACK %r11, 8
22008 + pax_force_retaddr
22009 ret $REST_SKIP /* pop extended registers */
22010 CFI_ENDPROC
22011 -END(stub_\func)
22012 +ENDPROC(stub_\func)
22013 .endm
22014
22015 .macro FIXED_FRAME label,func
22016 @@ -851,9 +1307,10 @@ ENTRY(\label)
22017 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22018 call \func
22019 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22020 + pax_force_retaddr
22021 ret
22022 CFI_ENDPROC
22023 -END(\label)
22024 +ENDPROC(\label)
22025 .endm
22026
22027 FORK_LIKE clone
22028 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
22029 movq_cfi_restore R12+8, r12
22030 movq_cfi_restore RBP+8, rbp
22031 movq_cfi_restore RBX+8, rbx
22032 + pax_force_retaddr
22033 ret $REST_SKIP /* pop extended registers */
22034 CFI_ENDPROC
22035 -END(ptregscall_common)
22036 +ENDPROC(ptregscall_common)
22037
22038 ENTRY(stub_execve)
22039 CFI_STARTPROC
22040 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
22041 RESTORE_REST
22042 jmp int_ret_from_sys_call
22043 CFI_ENDPROC
22044 -END(stub_execve)
22045 +ENDPROC(stub_execve)
22046
22047 /*
22048 * sigreturn is special because it needs to restore all registers on return.
22049 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
22050 RESTORE_REST
22051 jmp int_ret_from_sys_call
22052 CFI_ENDPROC
22053 -END(stub_rt_sigreturn)
22054 +ENDPROC(stub_rt_sigreturn)
22055
22056 #ifdef CONFIG_X86_X32_ABI
22057 ENTRY(stub_x32_rt_sigreturn)
22058 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
22059 RESTORE_REST
22060 jmp int_ret_from_sys_call
22061 CFI_ENDPROC
22062 -END(stub_x32_rt_sigreturn)
22063 +ENDPROC(stub_x32_rt_sigreturn)
22064
22065 ENTRY(stub_x32_execve)
22066 CFI_STARTPROC
22067 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
22068 RESTORE_REST
22069 jmp int_ret_from_sys_call
22070 CFI_ENDPROC
22071 -END(stub_x32_execve)
22072 +ENDPROC(stub_x32_execve)
22073
22074 #endif
22075
22076 @@ -967,7 +1425,7 @@ vector=vector+1
22077 2: jmp common_interrupt
22078 .endr
22079 CFI_ENDPROC
22080 -END(irq_entries_start)
22081 +ENDPROC(irq_entries_start)
22082
22083 .previous
22084 END(interrupt)
22085 @@ -987,6 +1445,16 @@ END(interrupt)
22086 subq $ORIG_RAX-RBP, %rsp
22087 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22088 SAVE_ARGS_IRQ
22089 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22090 + testb $3, CS(%rdi)
22091 + jnz 1f
22092 + pax_enter_kernel
22093 + jmp 2f
22094 +1: pax_enter_kernel_user
22095 +2:
22096 +#else
22097 + pax_enter_kernel
22098 +#endif
22099 call \func
22100 .endm
22101
22102 @@ -1019,7 +1487,7 @@ ret_from_intr:
22103
22104 exit_intr:
22105 GET_THREAD_INFO(%rcx)
22106 - testl $3,CS-ARGOFFSET(%rsp)
22107 + testb $3,CS-ARGOFFSET(%rsp)
22108 je retint_kernel
22109
22110 /* Interrupt came from user space */
22111 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
22112 * The iretq could re-enable interrupts:
22113 */
22114 DISABLE_INTERRUPTS(CLBR_ANY)
22115 + pax_exit_kernel_user
22116 +retint_swapgs_pax:
22117 TRACE_IRQS_IRETQ
22118 SWAPGS
22119 jmp restore_args
22120
22121 retint_restore_args: /* return to kernel space */
22122 DISABLE_INTERRUPTS(CLBR_ANY)
22123 + pax_exit_kernel
22124 + pax_force_retaddr (RIP-ARGOFFSET)
22125 /*
22126 * The iretq could re-enable interrupts:
22127 */
22128 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
22129 #endif
22130
22131 CFI_ENDPROC
22132 -END(common_interrupt)
22133 +ENDPROC(common_interrupt)
22134 /*
22135 * End of kprobes section
22136 */
22137 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
22138 interrupt \do_sym
22139 jmp ret_from_intr
22140 CFI_ENDPROC
22141 -END(\sym)
22142 +ENDPROC(\sym)
22143 .endm
22144
22145 #ifdef CONFIG_TRACING
22146 @@ -1230,12 +1702,22 @@ ENTRY(\sym)
22147 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22148 call error_entry
22149 DEFAULT_FRAME 0
22150 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22151 + testb $3, CS(%rsp)
22152 + jnz 1f
22153 + pax_enter_kernel
22154 + jmp 2f
22155 +1: pax_enter_kernel_user
22156 +2:
22157 +#else
22158 + pax_enter_kernel
22159 +#endif
22160 movq %rsp,%rdi /* pt_regs pointer */
22161 xorl %esi,%esi /* no error code */
22162 call \do_sym
22163 jmp error_exit /* %ebx: no swapgs flag */
22164 CFI_ENDPROC
22165 -END(\sym)
22166 +ENDPROC(\sym)
22167 .endm
22168
22169 .macro paranoidzeroentry sym do_sym
22170 @@ -1248,15 +1730,25 @@ ENTRY(\sym)
22171 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22172 call save_paranoid
22173 TRACE_IRQS_OFF
22174 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22175 + testb $3, CS(%rsp)
22176 + jnz 1f
22177 + pax_enter_kernel
22178 + jmp 2f
22179 +1: pax_enter_kernel_user
22180 +2:
22181 +#else
22182 + pax_enter_kernel
22183 +#endif
22184 movq %rsp,%rdi /* pt_regs pointer */
22185 xorl %esi,%esi /* no error code */
22186 call \do_sym
22187 jmp paranoid_exit /* %ebx: no swapgs flag */
22188 CFI_ENDPROC
22189 -END(\sym)
22190 +ENDPROC(\sym)
22191 .endm
22192
22193 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22194 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22195 .macro paranoidzeroentry_ist sym do_sym ist
22196 ENTRY(\sym)
22197 INTR_FRAME
22198 @@ -1267,14 +1759,30 @@ ENTRY(\sym)
22199 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22200 call save_paranoid
22201 TRACE_IRQS_OFF_DEBUG
22202 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22203 + testb $3, CS(%rsp)
22204 + jnz 1f
22205 + pax_enter_kernel
22206 + jmp 2f
22207 +1: pax_enter_kernel_user
22208 +2:
22209 +#else
22210 + pax_enter_kernel
22211 +#endif
22212 movq %rsp,%rdi /* pt_regs pointer */
22213 xorl %esi,%esi /* no error code */
22214 +#ifdef CONFIG_SMP
22215 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22216 + lea init_tss(%r12), %r12
22217 +#else
22218 + lea init_tss(%rip), %r12
22219 +#endif
22220 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22221 call \do_sym
22222 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22223 jmp paranoid_exit /* %ebx: no swapgs flag */
22224 CFI_ENDPROC
22225 -END(\sym)
22226 +ENDPROC(\sym)
22227 .endm
22228
22229 .macro errorentry sym do_sym
22230 @@ -1286,13 +1794,23 @@ ENTRY(\sym)
22231 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22232 call error_entry
22233 DEFAULT_FRAME 0
22234 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22235 + testb $3, CS(%rsp)
22236 + jnz 1f
22237 + pax_enter_kernel
22238 + jmp 2f
22239 +1: pax_enter_kernel_user
22240 +2:
22241 +#else
22242 + pax_enter_kernel
22243 +#endif
22244 movq %rsp,%rdi /* pt_regs pointer */
22245 movq ORIG_RAX(%rsp),%rsi /* get error code */
22246 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22247 call \do_sym
22248 jmp error_exit /* %ebx: no swapgs flag */
22249 CFI_ENDPROC
22250 -END(\sym)
22251 +ENDPROC(\sym)
22252 .endm
22253
22254 /* error code is on the stack already */
22255 @@ -1306,13 +1824,23 @@ ENTRY(\sym)
22256 call save_paranoid
22257 DEFAULT_FRAME 0
22258 TRACE_IRQS_OFF
22259 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22260 + testb $3, CS(%rsp)
22261 + jnz 1f
22262 + pax_enter_kernel
22263 + jmp 2f
22264 +1: pax_enter_kernel_user
22265 +2:
22266 +#else
22267 + pax_enter_kernel
22268 +#endif
22269 movq %rsp,%rdi /* pt_regs pointer */
22270 movq ORIG_RAX(%rsp),%rsi /* get error code */
22271 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22272 call \do_sym
22273 jmp paranoid_exit /* %ebx: no swapgs flag */
22274 CFI_ENDPROC
22275 -END(\sym)
22276 +ENDPROC(\sym)
22277 .endm
22278
22279 zeroentry divide_error do_divide_error
22280 @@ -1342,9 +1870,10 @@ gs_change:
22281 2: mfence /* workaround */
22282 SWAPGS
22283 popfq_cfi
22284 + pax_force_retaddr
22285 ret
22286 CFI_ENDPROC
22287 -END(native_load_gs_index)
22288 +ENDPROC(native_load_gs_index)
22289
22290 _ASM_EXTABLE(gs_change,bad_gs)
22291 .section .fixup,"ax"
22292 @@ -1372,9 +1901,10 @@ ENTRY(call_softirq)
22293 CFI_DEF_CFA_REGISTER rsp
22294 CFI_ADJUST_CFA_OFFSET -8
22295 decl PER_CPU_VAR(irq_count)
22296 + pax_force_retaddr
22297 ret
22298 CFI_ENDPROC
22299 -END(call_softirq)
22300 +ENDPROC(call_softirq)
22301
22302 #ifdef CONFIG_XEN
22303 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22304 @@ -1412,7 +1942,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22305 decl PER_CPU_VAR(irq_count)
22306 jmp error_exit
22307 CFI_ENDPROC
22308 -END(xen_do_hypervisor_callback)
22309 +ENDPROC(xen_do_hypervisor_callback)
22310
22311 /*
22312 * Hypervisor uses this for application faults while it executes.
22313 @@ -1471,7 +2001,7 @@ ENTRY(xen_failsafe_callback)
22314 SAVE_ALL
22315 jmp error_exit
22316 CFI_ENDPROC
22317 -END(xen_failsafe_callback)
22318 +ENDPROC(xen_failsafe_callback)
22319
22320 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22321 xen_hvm_callback_vector xen_evtchn_do_upcall
22322 @@ -1523,18 +2053,33 @@ ENTRY(paranoid_exit)
22323 DEFAULT_FRAME
22324 DISABLE_INTERRUPTS(CLBR_NONE)
22325 TRACE_IRQS_OFF_DEBUG
22326 - testl %ebx,%ebx /* swapgs needed? */
22327 + testl $1,%ebx /* swapgs needed? */
22328 jnz paranoid_restore
22329 - testl $3,CS(%rsp)
22330 + testb $3,CS(%rsp)
22331 jnz paranoid_userspace
22332 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22333 + pax_exit_kernel
22334 + TRACE_IRQS_IRETQ 0
22335 + SWAPGS_UNSAFE_STACK
22336 + RESTORE_ALL 8
22337 + pax_force_retaddr_bts
22338 + jmp irq_return
22339 +#endif
22340 paranoid_swapgs:
22341 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22342 + pax_exit_kernel_user
22343 +#else
22344 + pax_exit_kernel
22345 +#endif
22346 TRACE_IRQS_IRETQ 0
22347 SWAPGS_UNSAFE_STACK
22348 RESTORE_ALL 8
22349 jmp irq_return
22350 paranoid_restore:
22351 + pax_exit_kernel
22352 TRACE_IRQS_IRETQ_DEBUG 0
22353 RESTORE_ALL 8
22354 + pax_force_retaddr_bts
22355 jmp irq_return
22356 paranoid_userspace:
22357 GET_THREAD_INFO(%rcx)
22358 @@ -1563,7 +2108,7 @@ paranoid_schedule:
22359 TRACE_IRQS_OFF
22360 jmp paranoid_userspace
22361 CFI_ENDPROC
22362 -END(paranoid_exit)
22363 +ENDPROC(paranoid_exit)
22364
22365 /*
22366 * Exception entry point. This expects an error code/orig_rax on the stack.
22367 @@ -1590,12 +2135,13 @@ ENTRY(error_entry)
22368 movq_cfi r14, R14+8
22369 movq_cfi r15, R15+8
22370 xorl %ebx,%ebx
22371 - testl $3,CS+8(%rsp)
22372 + testb $3,CS+8(%rsp)
22373 je error_kernelspace
22374 error_swapgs:
22375 SWAPGS
22376 error_sti:
22377 TRACE_IRQS_OFF
22378 + pax_force_retaddr_bts
22379 ret
22380
22381 /*
22382 @@ -1622,7 +2168,7 @@ bstep_iret:
22383 movq %rcx,RIP+8(%rsp)
22384 jmp error_swapgs
22385 CFI_ENDPROC
22386 -END(error_entry)
22387 +ENDPROC(error_entry)
22388
22389
22390 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22391 @@ -1633,7 +2179,7 @@ ENTRY(error_exit)
22392 DISABLE_INTERRUPTS(CLBR_NONE)
22393 TRACE_IRQS_OFF
22394 GET_THREAD_INFO(%rcx)
22395 - testl %eax,%eax
22396 + testl $1,%eax
22397 jne retint_kernel
22398 LOCKDEP_SYS_EXIT_IRQ
22399 movl TI_flags(%rcx),%edx
22400 @@ -1642,7 +2188,7 @@ ENTRY(error_exit)
22401 jnz retint_careful
22402 jmp retint_swapgs
22403 CFI_ENDPROC
22404 -END(error_exit)
22405 +ENDPROC(error_exit)
22406
22407 /*
22408 * Test if a given stack is an NMI stack or not.
22409 @@ -1700,9 +2246,11 @@ ENTRY(nmi)
22410 * If %cs was not the kernel segment, then the NMI triggered in user
22411 * space, which means it is definitely not nested.
22412 */
22413 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22414 + je 1f
22415 cmpl $__KERNEL_CS, 16(%rsp)
22416 jne first_nmi
22417 -
22418 +1:
22419 /*
22420 * Check the special variable on the stack to see if NMIs are
22421 * executing.
22422 @@ -1736,8 +2284,7 @@ nested_nmi:
22423
22424 1:
22425 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22426 - leaq -1*8(%rsp), %rdx
22427 - movq %rdx, %rsp
22428 + subq $8, %rsp
22429 CFI_ADJUST_CFA_OFFSET 1*8
22430 leaq -10*8(%rsp), %rdx
22431 pushq_cfi $__KERNEL_DS
22432 @@ -1755,6 +2302,7 @@ nested_nmi_out:
22433 CFI_RESTORE rdx
22434
22435 /* No need to check faults here */
22436 +# pax_force_retaddr_bts
22437 INTERRUPT_RETURN
22438
22439 CFI_RESTORE_STATE
22440 @@ -1871,6 +2419,8 @@ end_repeat_nmi:
22441 */
22442 movq %cr2, %r12
22443
22444 + pax_enter_kernel_nmi
22445 +
22446 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22447 movq %rsp,%rdi
22448 movq $-1,%rsi
22449 @@ -1883,26 +2433,31 @@ end_repeat_nmi:
22450 movq %r12, %cr2
22451 1:
22452
22453 - testl %ebx,%ebx /* swapgs needed? */
22454 + testl $1,%ebx /* swapgs needed? */
22455 jnz nmi_restore
22456 nmi_swapgs:
22457 SWAPGS_UNSAFE_STACK
22458 nmi_restore:
22459 + pax_exit_kernel_nmi
22460 /* Pop the extra iret frame at once */
22461 RESTORE_ALL 6*8
22462 + testb $3, 8(%rsp)
22463 + jnz 1f
22464 + pax_force_retaddr_bts
22465 +1:
22466
22467 /* Clear the NMI executing stack variable */
22468 movq $0, 5*8(%rsp)
22469 jmp irq_return
22470 CFI_ENDPROC
22471 -END(nmi)
22472 +ENDPROC(nmi)
22473
22474 ENTRY(ignore_sysret)
22475 CFI_STARTPROC
22476 mov $-ENOSYS,%eax
22477 sysret
22478 CFI_ENDPROC
22479 -END(ignore_sysret)
22480 +ENDPROC(ignore_sysret)
22481
22482 /*
22483 * End of kprobes section
22484 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22485 index 42a392a..fbbd930 100644
22486 --- a/arch/x86/kernel/ftrace.c
22487 +++ b/arch/x86/kernel/ftrace.c
22488 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22489 {
22490 unsigned char replaced[MCOUNT_INSN_SIZE];
22491
22492 + ip = ktla_ktva(ip);
22493 +
22494 /*
22495 * Note: Due to modules and __init, code can
22496 * disappear and change, we need to protect against faulting
22497 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22498 unsigned char old[MCOUNT_INSN_SIZE], *new;
22499 int ret;
22500
22501 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22502 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22503 new = ftrace_call_replace(ip, (unsigned long)func);
22504
22505 /* See comment above by declaration of modifying_ftrace_code */
22506 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22507 /* Also update the regs callback function */
22508 if (!ret) {
22509 ip = (unsigned long)(&ftrace_regs_call);
22510 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22511 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22512 new = ftrace_call_replace(ip, (unsigned long)func);
22513 ret = ftrace_modify_code(ip, old, new);
22514 }
22515 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22516 * kernel identity mapping to modify code.
22517 */
22518 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22519 - ip = (unsigned long)__va(__pa_symbol(ip));
22520 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22521
22522 return probe_kernel_write((void *)ip, val, size);
22523 }
22524 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22525 unsigned char replaced[MCOUNT_INSN_SIZE];
22526 unsigned char brk = BREAKPOINT_INSTRUCTION;
22527
22528 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22529 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22530 return -EFAULT;
22531
22532 /* Make sure it is what we expect it to be */
22533 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22534 return ret;
22535
22536 fail_update:
22537 - probe_kernel_write((void *)ip, &old_code[0], 1);
22538 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22539 goto out;
22540 }
22541
22542 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22543 {
22544 unsigned char code[MCOUNT_INSN_SIZE];
22545
22546 + ip = ktla_ktva(ip);
22547 +
22548 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22549 return -EFAULT;
22550
22551 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22552 index 55b6761..a6456fc 100644
22553 --- a/arch/x86/kernel/head64.c
22554 +++ b/arch/x86/kernel/head64.c
22555 @@ -67,12 +67,12 @@ again:
22556 pgd = *pgd_p;
22557
22558 /*
22559 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22560 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22561 + * The use of __early_va rather than __va here is critical:
22562 + * __va would point us back into the dynamic
22563 * range and we might end up looping forever...
22564 */
22565 if (pgd)
22566 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22567 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22568 else {
22569 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22570 reset_early_page_tables();
22571 @@ -82,13 +82,13 @@ again:
22572 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22573 for (i = 0; i < PTRS_PER_PUD; i++)
22574 pud_p[i] = 0;
22575 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22576 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22577 }
22578 pud_p += pud_index(address);
22579 pud = *pud_p;
22580
22581 if (pud)
22582 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22583 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22584 else {
22585 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22586 reset_early_page_tables();
22587 @@ -98,7 +98,7 @@ again:
22588 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22589 for (i = 0; i < PTRS_PER_PMD; i++)
22590 pmd_p[i] = 0;
22591 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22592 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22593 }
22594 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22595 pmd_p[pmd_index(address)] = pmd;
22596 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
22597 if (console_loglevel == 10)
22598 early_printk("Kernel alive\n");
22599
22600 - clear_page(init_level4_pgt);
22601 /* set init_level4_pgt kernel high mapping*/
22602 init_level4_pgt[511] = early_level4_pgt[511];
22603
22604 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22605 index 5dd87a8..d68b3f4 100644
22606 --- a/arch/x86/kernel/head_32.S
22607 +++ b/arch/x86/kernel/head_32.S
22608 @@ -26,6 +26,12 @@
22609 /* Physical address */
22610 #define pa(X) ((X) - __PAGE_OFFSET)
22611
22612 +#ifdef CONFIG_PAX_KERNEXEC
22613 +#define ta(X) (X)
22614 +#else
22615 +#define ta(X) ((X) - __PAGE_OFFSET)
22616 +#endif
22617 +
22618 /*
22619 * References to members of the new_cpu_data structure.
22620 */
22621 @@ -55,11 +61,7 @@
22622 * and small than max_low_pfn, otherwise will waste some page table entries
22623 */
22624
22625 -#if PTRS_PER_PMD > 1
22626 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22627 -#else
22628 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22629 -#endif
22630 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22631
22632 /* Number of possible pages in the lowmem region */
22633 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22634 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22635 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22636
22637 /*
22638 + * Real beginning of normal "text" segment
22639 + */
22640 +ENTRY(stext)
22641 +ENTRY(_stext)
22642 +
22643 +/*
22644 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22645 * %esi points to the real-mode code as a 32-bit pointer.
22646 * CS and DS must be 4 GB flat segments, but we don't depend on
22647 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22648 * can.
22649 */
22650 __HEAD
22651 +
22652 +#ifdef CONFIG_PAX_KERNEXEC
22653 + jmp startup_32
22654 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22655 +.fill PAGE_SIZE-5,1,0xcc
22656 +#endif
22657 +
22658 ENTRY(startup_32)
22659 movl pa(stack_start),%ecx
22660
22661 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22662 2:
22663 leal -__PAGE_OFFSET(%ecx),%esp
22664
22665 +#ifdef CONFIG_SMP
22666 + movl $pa(cpu_gdt_table),%edi
22667 + movl $__per_cpu_load,%eax
22668 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22669 + rorl $16,%eax
22670 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22671 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22672 + movl $__per_cpu_end - 1,%eax
22673 + subl $__per_cpu_start,%eax
22674 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22675 +#endif
22676 +
22677 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22678 + movl $NR_CPUS,%ecx
22679 + movl $pa(cpu_gdt_table),%edi
22680 +1:
22681 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22682 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22683 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22684 + addl $PAGE_SIZE_asm,%edi
22685 + loop 1b
22686 +#endif
22687 +
22688 +#ifdef CONFIG_PAX_KERNEXEC
22689 + movl $pa(boot_gdt),%edi
22690 + movl $__LOAD_PHYSICAL_ADDR,%eax
22691 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22692 + rorl $16,%eax
22693 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22694 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22695 + rorl $16,%eax
22696 +
22697 + ljmp $(__BOOT_CS),$1f
22698 +1:
22699 +
22700 + movl $NR_CPUS,%ecx
22701 + movl $pa(cpu_gdt_table),%edi
22702 + addl $__PAGE_OFFSET,%eax
22703 +1:
22704 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22705 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22706 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22707 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22708 + rorl $16,%eax
22709 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22710 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22711 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22712 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22713 + rorl $16,%eax
22714 + addl $PAGE_SIZE_asm,%edi
22715 + loop 1b
22716 +#endif
22717 +
22718 /*
22719 * Clear BSS first so that there are no surprises...
22720 */
22721 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22722 movl %eax, pa(max_pfn_mapped)
22723
22724 /* Do early initialization of the fixmap area */
22725 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22726 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22727 +#ifdef CONFIG_COMPAT_VDSO
22728 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22729 +#else
22730 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22731 +#endif
22732 #else /* Not PAE */
22733
22734 page_pde_offset = (__PAGE_OFFSET >> 20);
22735 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22736 movl %eax, pa(max_pfn_mapped)
22737
22738 /* Do early initialization of the fixmap area */
22739 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22740 - movl %eax,pa(initial_page_table+0xffc)
22741 +#ifdef CONFIG_COMPAT_VDSO
22742 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22743 +#else
22744 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22745 +#endif
22746 #endif
22747
22748 #ifdef CONFIG_PARAVIRT
22749 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22750 cmpl $num_subarch_entries, %eax
22751 jae bad_subarch
22752
22753 - movl pa(subarch_entries)(,%eax,4), %eax
22754 - subl $__PAGE_OFFSET, %eax
22755 - jmp *%eax
22756 + jmp *pa(subarch_entries)(,%eax,4)
22757
22758 bad_subarch:
22759 WEAK(lguest_entry)
22760 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22761 __INITDATA
22762
22763 subarch_entries:
22764 - .long default_entry /* normal x86/PC */
22765 - .long lguest_entry /* lguest hypervisor */
22766 - .long xen_entry /* Xen hypervisor */
22767 - .long default_entry /* Moorestown MID */
22768 + .long ta(default_entry) /* normal x86/PC */
22769 + .long ta(lguest_entry) /* lguest hypervisor */
22770 + .long ta(xen_entry) /* Xen hypervisor */
22771 + .long ta(default_entry) /* Moorestown MID */
22772 num_subarch_entries = (. - subarch_entries) / 4
22773 .previous
22774 #else
22775 @@ -354,6 +426,7 @@ default_entry:
22776 movl pa(mmu_cr4_features),%eax
22777 movl %eax,%cr4
22778
22779 +#ifdef CONFIG_X86_PAE
22780 testb $X86_CR4_PAE, %al # check if PAE is enabled
22781 jz enable_paging
22782
22783 @@ -382,6 +455,9 @@ default_entry:
22784 /* Make changes effective */
22785 wrmsr
22786
22787 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22788 +#endif
22789 +
22790 enable_paging:
22791
22792 /*
22793 @@ -449,14 +525,20 @@ is486:
22794 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22795 movl %eax,%ss # after changing gdt.
22796
22797 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22798 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22799 movl %eax,%ds
22800 movl %eax,%es
22801
22802 movl $(__KERNEL_PERCPU), %eax
22803 movl %eax,%fs # set this cpu's percpu
22804
22805 +#ifdef CONFIG_CC_STACKPROTECTOR
22806 movl $(__KERNEL_STACK_CANARY),%eax
22807 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22808 + movl $(__USER_DS),%eax
22809 +#else
22810 + xorl %eax,%eax
22811 +#endif
22812 movl %eax,%gs
22813
22814 xorl %eax,%eax # Clear LDT
22815 @@ -512,8 +594,11 @@ setup_once:
22816 * relocation. Manually set base address in stack canary
22817 * segment descriptor.
22818 */
22819 - movl $gdt_page,%eax
22820 + movl $cpu_gdt_table,%eax
22821 movl $stack_canary,%ecx
22822 +#ifdef CONFIG_SMP
22823 + addl $__per_cpu_load,%ecx
22824 +#endif
22825 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22826 shrl $16, %ecx
22827 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22828 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22829 /* This is global to keep gas from relaxing the jumps */
22830 ENTRY(early_idt_handler)
22831 cld
22832 - cmpl $2,%ss:early_recursion_flag
22833 + cmpl $1,%ss:early_recursion_flag
22834 je hlt_loop
22835 incl %ss:early_recursion_flag
22836
22837 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22838 pushl (20+6*4)(%esp) /* trapno */
22839 pushl $fault_msg
22840 call printk
22841 -#endif
22842 call dump_stack
22843 +#endif
22844 hlt_loop:
22845 hlt
22846 jmp hlt_loop
22847 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22848 /* This is the default interrupt "handler" :-) */
22849 ALIGN
22850 ignore_int:
22851 - cld
22852 #ifdef CONFIG_PRINTK
22853 + cmpl $2,%ss:early_recursion_flag
22854 + je hlt_loop
22855 + incl %ss:early_recursion_flag
22856 + cld
22857 pushl %eax
22858 pushl %ecx
22859 pushl %edx
22860 @@ -612,9 +700,6 @@ ignore_int:
22861 movl $(__KERNEL_DS),%eax
22862 movl %eax,%ds
22863 movl %eax,%es
22864 - cmpl $2,early_recursion_flag
22865 - je hlt_loop
22866 - incl early_recursion_flag
22867 pushl 16(%esp)
22868 pushl 24(%esp)
22869 pushl 32(%esp)
22870 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22871 /*
22872 * BSS section
22873 */
22874 -__PAGE_ALIGNED_BSS
22875 - .align PAGE_SIZE
22876 #ifdef CONFIG_X86_PAE
22877 +.section .initial_pg_pmd,"a",@progbits
22878 initial_pg_pmd:
22879 .fill 1024*KPMDS,4,0
22880 #else
22881 +.section .initial_page_table,"a",@progbits
22882 ENTRY(initial_page_table)
22883 .fill 1024,4,0
22884 #endif
22885 +.section .initial_pg_fixmap,"a",@progbits
22886 initial_pg_fixmap:
22887 .fill 1024,4,0
22888 +.section .empty_zero_page,"a",@progbits
22889 ENTRY(empty_zero_page)
22890 .fill 4096,1,0
22891 +.section .swapper_pg_dir,"a",@progbits
22892 ENTRY(swapper_pg_dir)
22893 +#ifdef CONFIG_X86_PAE
22894 + .fill 4,8,0
22895 +#else
22896 .fill 1024,4,0
22897 +#endif
22898
22899 /*
22900 * This starts the data section.
22901 */
22902 #ifdef CONFIG_X86_PAE
22903 -__PAGE_ALIGNED_DATA
22904 - /* Page-aligned for the benefit of paravirt? */
22905 - .align PAGE_SIZE
22906 +.section .initial_page_table,"a",@progbits
22907 ENTRY(initial_page_table)
22908 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22909 # if KPMDS == 3
22910 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22911 # error "Kernel PMDs should be 1, 2 or 3"
22912 # endif
22913 .align PAGE_SIZE /* needs to be page-sized too */
22914 +
22915 +#ifdef CONFIG_PAX_PER_CPU_PGD
22916 +ENTRY(cpu_pgd)
22917 + .rept 2*NR_CPUS
22918 + .fill 4,8,0
22919 + .endr
22920 +#endif
22921 +
22922 #endif
22923
22924 .data
22925 .balign 4
22926 ENTRY(stack_start)
22927 - .long init_thread_union+THREAD_SIZE
22928 + .long init_thread_union+THREAD_SIZE-8
22929
22930 __INITRODATA
22931 int_msg:
22932 @@ -722,7 +820,7 @@ fault_msg:
22933 * segment size, and 32-bit linear address value:
22934 */
22935
22936 - .data
22937 +.section .rodata,"a",@progbits
22938 .globl boot_gdt_descr
22939 .globl idt_descr
22940
22941 @@ -731,7 +829,7 @@ fault_msg:
22942 .word 0 # 32 bit align gdt_desc.address
22943 boot_gdt_descr:
22944 .word __BOOT_DS+7
22945 - .long boot_gdt - __PAGE_OFFSET
22946 + .long pa(boot_gdt)
22947
22948 .word 0 # 32-bit align idt_desc.address
22949 idt_descr:
22950 @@ -742,7 +840,7 @@ idt_descr:
22951 .word 0 # 32 bit align gdt_desc.address
22952 ENTRY(early_gdt_descr)
22953 .word GDT_ENTRIES*8-1
22954 - .long gdt_page /* Overwritten for secondary CPUs */
22955 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22956
22957 /*
22958 * The boot_gdt must mirror the equivalent in setup.S and is
22959 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22960 .align L1_CACHE_BYTES
22961 ENTRY(boot_gdt)
22962 .fill GDT_ENTRY_BOOT_CS,8,0
22963 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22964 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22965 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22966 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22967 +
22968 + .align PAGE_SIZE_asm
22969 +ENTRY(cpu_gdt_table)
22970 + .rept NR_CPUS
22971 + .quad 0x0000000000000000 /* NULL descriptor */
22972 + .quad 0x0000000000000000 /* 0x0b reserved */
22973 + .quad 0x0000000000000000 /* 0x13 reserved */
22974 + .quad 0x0000000000000000 /* 0x1b reserved */
22975 +
22976 +#ifdef CONFIG_PAX_KERNEXEC
22977 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22978 +#else
22979 + .quad 0x0000000000000000 /* 0x20 unused */
22980 +#endif
22981 +
22982 + .quad 0x0000000000000000 /* 0x28 unused */
22983 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22984 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22985 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22986 + .quad 0x0000000000000000 /* 0x4b reserved */
22987 + .quad 0x0000000000000000 /* 0x53 reserved */
22988 + .quad 0x0000000000000000 /* 0x5b reserved */
22989 +
22990 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
22991 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
22992 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
22993 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
22994 +
22995 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
22996 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
22997 +
22998 + /*
22999 + * Segments used for calling PnP BIOS have byte granularity.
23000 + * The code segments and data segments have fixed 64k limits,
23001 + * the transfer segment sizes are set at run time.
23002 + */
23003 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23004 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23005 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23006 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23007 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23008 +
23009 + /*
23010 + * The APM segments have byte granularity and their bases
23011 + * are set at run time. All have 64k limits.
23012 + */
23013 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23014 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23015 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23016 +
23017 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23018 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23019 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23020 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23021 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23022 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23023 +
23024 + /* Be sure this is zeroed to avoid false validations in Xen */
23025 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23026 + .endr
23027 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23028 index e1aabdb..73dcad8 100644
23029 --- a/arch/x86/kernel/head_64.S
23030 +++ b/arch/x86/kernel/head_64.S
23031 @@ -20,6 +20,8 @@
23032 #include <asm/processor-flags.h>
23033 #include <asm/percpu.h>
23034 #include <asm/nops.h>
23035 +#include <asm/cpufeature.h>
23036 +#include <asm/alternative-asm.h>
23037
23038 #ifdef CONFIG_PARAVIRT
23039 #include <asm/asm-offsets.h>
23040 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23041 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23042 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23043 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23044 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23045 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23046 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23047 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23048 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23049 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23050
23051 .text
23052 __HEAD
23053 @@ -89,11 +97,23 @@ startup_64:
23054 * Fixup the physical addresses in the page table
23055 */
23056 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23057 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23058 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23059 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23060 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23061 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23062
23063 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23064 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23065 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23066 +#ifndef CONFIG_XEN
23067 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23068 +#endif
23069
23070 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23071 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23072 +
23073 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23074 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23075 +
23076 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23077
23078 /*
23079 * Set up the identity mapping for the switchover. These
23080 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
23081 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23082 1:
23083
23084 - /* Enable PAE mode and PGE */
23085 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23086 + /* Enable PAE mode and PSE/PGE */
23087 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23088 movq %rcx, %cr4
23089
23090 /* Setup early boot stage 4 level pagetables. */
23091 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
23092 movl $MSR_EFER, %ecx
23093 rdmsr
23094 btsl $_EFER_SCE, %eax /* Enable System Call */
23095 - btl $20,%edi /* No Execute supported? */
23096 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23097 jnc 1f
23098 btsl $_EFER_NX, %eax
23099 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23100 + leaq init_level4_pgt(%rip), %rdi
23101 +#ifndef CONFIG_EFI
23102 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
23103 +#endif
23104 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
23105 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
23106 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
23107 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23108 1: wrmsr /* Make changes effective */
23109
23110 /* Setup cr0 */
23111 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
23112 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23113 * address given in m16:64.
23114 */
23115 + pax_set_fptr_mask
23116 movq initial_code(%rip),%rax
23117 pushq $0 # fake return address to stop unwinder
23118 pushq $__KERNEL_CS # set correct cs
23119 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
23120 call dump_stack
23121 #ifdef CONFIG_KALLSYMS
23122 leaq early_idt_ripmsg(%rip),%rdi
23123 - movq 40(%rsp),%rsi # %rip again
23124 + movq 88(%rsp),%rsi # %rip again
23125 call __print_symbol
23126 #endif
23127 #endif /* EARLY_PRINTK */
23128 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
23129 early_recursion_flag:
23130 .long 0
23131
23132 + .section .rodata,"a",@progbits
23133 #ifdef CONFIG_EARLY_PRINTK
23134 early_idt_msg:
23135 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23136 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
23137 NEXT_PAGE(early_dynamic_pgts)
23138 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23139
23140 - .data
23141 + .section .rodata,"a",@progbits
23142
23143 -#ifndef CONFIG_XEN
23144 NEXT_PAGE(init_level4_pgt)
23145 - .fill 512,8,0
23146 -#else
23147 -NEXT_PAGE(init_level4_pgt)
23148 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23149 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23150 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23151 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23152 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23153 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23154 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23155 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23156 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23157 .org init_level4_pgt + L4_START_KERNEL*8, 0
23158 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23159 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23160
23161 +#ifdef CONFIG_PAX_PER_CPU_PGD
23162 +NEXT_PAGE(cpu_pgd)
23163 + .rept 2*NR_CPUS
23164 + .fill 512,8,0
23165 + .endr
23166 +#endif
23167 +
23168 NEXT_PAGE(level3_ident_pgt)
23169 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23170 +#ifdef CONFIG_XEN
23171 .fill 511, 8, 0
23172 +#else
23173 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23174 + .fill 510,8,0
23175 +#endif
23176 +
23177 +NEXT_PAGE(level3_vmalloc_start_pgt)
23178 + .fill 512,8,0
23179 +
23180 +NEXT_PAGE(level3_vmalloc_end_pgt)
23181 + .fill 512,8,0
23182 +
23183 +NEXT_PAGE(level3_vmemmap_pgt)
23184 + .fill L3_VMEMMAP_START,8,0
23185 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23186 +
23187 NEXT_PAGE(level2_ident_pgt)
23188 - /* Since I easily can, map the first 1G.
23189 + /* Since I easily can, map the first 2G.
23190 * Don't set NX because code runs from these pages.
23191 */
23192 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23193 -#endif
23194 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23195
23196 NEXT_PAGE(level3_kernel_pgt)
23197 .fill L3_START_KERNEL,8,0
23198 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
23199 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23200 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23201
23202 +NEXT_PAGE(level2_vmemmap_pgt)
23203 + .fill 512,8,0
23204 +
23205 NEXT_PAGE(level2_kernel_pgt)
23206 /*
23207 * 512 MB kernel mapping. We spend a full page on this pagetable
23208 @@ -488,30 +544,62 @@ NEXT_PAGE(level2_kernel_pgt)
23209 KERNEL_IMAGE_SIZE/PMD_SIZE)
23210
23211 NEXT_PAGE(level2_fixmap_pgt)
23212 - .fill 506,8,0
23213 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23214 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23215 - .fill 5,8,0
23216 + .fill 507,8,0
23217 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23218 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23219 + .fill 4,8,0
23220
23221 -NEXT_PAGE(level1_fixmap_pgt)
23222 +NEXT_PAGE(level1_vsyscall_pgt)
23223 .fill 512,8,0
23224
23225 #undef PMDS
23226
23227 - .data
23228 + .align PAGE_SIZE
23229 +ENTRY(cpu_gdt_table)
23230 + .rept NR_CPUS
23231 + .quad 0x0000000000000000 /* NULL descriptor */
23232 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23233 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23234 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23235 + .quad 0x00cffb000000ffff /* __USER32_CS */
23236 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23237 + .quad 0x00affb000000ffff /* __USER_CS */
23238 +
23239 +#ifdef CONFIG_PAX_KERNEXEC
23240 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23241 +#else
23242 + .quad 0x0 /* unused */
23243 +#endif
23244 +
23245 + .quad 0,0 /* TSS */
23246 + .quad 0,0 /* LDT */
23247 + .quad 0,0,0 /* three TLS descriptors */
23248 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23249 + /* asm/segment.h:GDT_ENTRIES must match this */
23250 +
23251 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23252 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23253 +#else
23254 + .quad 0x0 /* unused */
23255 +#endif
23256 +
23257 + /* zero the remaining page */
23258 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23259 + .endr
23260 +
23261 .align 16
23262 .globl early_gdt_descr
23263 early_gdt_descr:
23264 .word GDT_ENTRIES*8-1
23265 early_gdt_descr_base:
23266 - .quad INIT_PER_CPU_VAR(gdt_page)
23267 + .quad cpu_gdt_table
23268
23269 ENTRY(phys_base)
23270 /* This must match the first entry in level2_kernel_pgt */
23271 .quad 0x0000000000000000
23272
23273 #include "../../x86/xen/xen-head.S"
23274 -
23275 - __PAGE_ALIGNED_BSS
23276 +
23277 + .section .rodata,"a",@progbits
23278 NEXT_PAGE(empty_zero_page)
23279 .skip PAGE_SIZE
23280 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23281 index 0fa6912..b37438b 100644
23282 --- a/arch/x86/kernel/i386_ksyms_32.c
23283 +++ b/arch/x86/kernel/i386_ksyms_32.c
23284 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23285 EXPORT_SYMBOL(cmpxchg8b_emu);
23286 #endif
23287
23288 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23289 +
23290 /* Networking helper routines. */
23291 EXPORT_SYMBOL(csum_partial_copy_generic);
23292 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23293 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23294
23295 EXPORT_SYMBOL(__get_user_1);
23296 EXPORT_SYMBOL(__get_user_2);
23297 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23298
23299 EXPORT_SYMBOL(csum_partial);
23300 EXPORT_SYMBOL(empty_zero_page);
23301 +
23302 +#ifdef CONFIG_PAX_KERNEXEC
23303 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23304 +#endif
23305 +
23306 +#ifdef CONFIG_PAX_PER_CPU_PGD
23307 +EXPORT_SYMBOL(cpu_pgd);
23308 +#endif
23309 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23310 index 5d576ab..1403a03 100644
23311 --- a/arch/x86/kernel/i387.c
23312 +++ b/arch/x86/kernel/i387.c
23313 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23314 static inline bool interrupted_user_mode(void)
23315 {
23316 struct pt_regs *regs = get_irq_regs();
23317 - return regs && user_mode_vm(regs);
23318 + return regs && user_mode(regs);
23319 }
23320
23321 /*
23322 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23323 index 9a5c460..84868423 100644
23324 --- a/arch/x86/kernel/i8259.c
23325 +++ b/arch/x86/kernel/i8259.c
23326 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23327 static void make_8259A_irq(unsigned int irq)
23328 {
23329 disable_irq_nosync(irq);
23330 - io_apic_irqs &= ~(1<<irq);
23331 + io_apic_irqs &= ~(1UL<<irq);
23332 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23333 i8259A_chip.name);
23334 enable_irq(irq);
23335 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23336 "spurious 8259A interrupt: IRQ%d.\n", irq);
23337 spurious_irq_mask |= irqmask;
23338 }
23339 - atomic_inc(&irq_err_count);
23340 + atomic_inc_unchecked(&irq_err_count);
23341 /*
23342 * Theoretically we do not have to handle this IRQ,
23343 * but in Linux this does not cause problems and is
23344 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23345 /* (slave's support for AEOI in flat mode is to be investigated) */
23346 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23347
23348 + pax_open_kernel();
23349 if (auto_eoi)
23350 /*
23351 * In AEOI mode we just have to mask the interrupt
23352 * when acking.
23353 */
23354 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23355 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23356 else
23357 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23358 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23359 + pax_close_kernel();
23360
23361 udelay(100); /* wait for 8259A to initialize */
23362
23363 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23364 index a979b5b..1d6db75 100644
23365 --- a/arch/x86/kernel/io_delay.c
23366 +++ b/arch/x86/kernel/io_delay.c
23367 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23368 * Quirk table for systems that misbehave (lock up, etc.) if port
23369 * 0x80 is used:
23370 */
23371 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23372 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23373 {
23374 .callback = dmi_io_delay_0xed_port,
23375 .ident = "Compaq Presario V6000",
23376 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23377 index 4ddaf66..6292f4e 100644
23378 --- a/arch/x86/kernel/ioport.c
23379 +++ b/arch/x86/kernel/ioport.c
23380 @@ -6,6 +6,7 @@
23381 #include <linux/sched.h>
23382 #include <linux/kernel.h>
23383 #include <linux/capability.h>
23384 +#include <linux/security.h>
23385 #include <linux/errno.h>
23386 #include <linux/types.h>
23387 #include <linux/ioport.h>
23388 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23389
23390 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23391 return -EINVAL;
23392 +#ifdef CONFIG_GRKERNSEC_IO
23393 + if (turn_on && grsec_disable_privio) {
23394 + gr_handle_ioperm();
23395 + return -EPERM;
23396 + }
23397 +#endif
23398 if (turn_on && !capable(CAP_SYS_RAWIO))
23399 return -EPERM;
23400
23401 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23402 * because the ->io_bitmap_max value must match the bitmap
23403 * contents:
23404 */
23405 - tss = &per_cpu(init_tss, get_cpu());
23406 + tss = init_tss + get_cpu();
23407
23408 if (turn_on)
23409 bitmap_clear(t->io_bitmap_ptr, from, num);
23410 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23411 return -EINVAL;
23412 /* Trying to gain more privileges? */
23413 if (level > old) {
23414 +#ifdef CONFIG_GRKERNSEC_IO
23415 + if (grsec_disable_privio) {
23416 + gr_handle_iopl();
23417 + return -EPERM;
23418 + }
23419 +#endif
23420 if (!capable(CAP_SYS_RAWIO))
23421 return -EPERM;
23422 }
23423 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23424 index 3a8185c..3c042ee 100644
23425 --- a/arch/x86/kernel/irq.c
23426 +++ b/arch/x86/kernel/irq.c
23427 @@ -21,7 +21,7 @@
23428 #define CREATE_TRACE_POINTS
23429 #include <asm/trace/irq_vectors.h>
23430
23431 -atomic_t irq_err_count;
23432 +atomic_unchecked_t irq_err_count;
23433
23434 /* Function pointer for generic interrupt vector handling */
23435 void (*x86_platform_ipi_callback)(void) = NULL;
23436 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23437 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23438 seq_printf(p, " Machine check polls\n");
23439 #endif
23440 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23441 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23442 #if defined(CONFIG_X86_IO_APIC)
23443 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23444 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23445 #endif
23446 return 0;
23447 }
23448 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23449
23450 u64 arch_irq_stat(void)
23451 {
23452 - u64 sum = atomic_read(&irq_err_count);
23453 + u64 sum = atomic_read_unchecked(&irq_err_count);
23454 return sum;
23455 }
23456
23457 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23458 index 4186755..784efa0 100644
23459 --- a/arch/x86/kernel/irq_32.c
23460 +++ b/arch/x86/kernel/irq_32.c
23461 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23462 __asm__ __volatile__("andl %%esp,%0" :
23463 "=r" (sp) : "0" (THREAD_SIZE - 1));
23464
23465 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23466 + return sp < STACK_WARN;
23467 }
23468
23469 static void print_stack_overflow(void)
23470 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23471 * per-CPU IRQ handling contexts (thread information and stack)
23472 */
23473 union irq_ctx {
23474 - struct thread_info tinfo;
23475 - u32 stack[THREAD_SIZE/sizeof(u32)];
23476 + unsigned long previous_esp;
23477 + u32 stack[THREAD_SIZE/sizeof(u32)];
23478 } __attribute__((aligned(THREAD_SIZE)));
23479
23480 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23481 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23482 static inline int
23483 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23484 {
23485 - union irq_ctx *curctx, *irqctx;
23486 + union irq_ctx *irqctx;
23487 u32 *isp, arg1, arg2;
23488
23489 - curctx = (union irq_ctx *) current_thread_info();
23490 irqctx = __this_cpu_read(hardirq_ctx);
23491
23492 /*
23493 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23494 * handler) we can't do that and just have to keep using the
23495 * current stack (which is the irq stack already after all)
23496 */
23497 - if (unlikely(curctx == irqctx))
23498 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23499 return 0;
23500
23501 /* build the stack frame on the IRQ stack */
23502 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23503 - irqctx->tinfo.task = curctx->tinfo.task;
23504 - irqctx->tinfo.previous_esp = current_stack_pointer;
23505 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23506 + irqctx->previous_esp = current_stack_pointer;
23507
23508 - /* Copy the preempt_count so that the [soft]irq checks work. */
23509 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23510 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23511 + __set_fs(MAKE_MM_SEG(0));
23512 +#endif
23513
23514 if (unlikely(overflow))
23515 call_on_stack(print_stack_overflow, isp);
23516 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23517 : "0" (irq), "1" (desc), "2" (isp),
23518 "D" (desc->handle_irq)
23519 : "memory", "cc", "ecx");
23520 +
23521 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23522 + __set_fs(current_thread_info()->addr_limit);
23523 +#endif
23524 +
23525 return 1;
23526 }
23527
23528 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23529 */
23530 void irq_ctx_init(int cpu)
23531 {
23532 - union irq_ctx *irqctx;
23533 -
23534 if (per_cpu(hardirq_ctx, cpu))
23535 return;
23536
23537 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23538 - THREADINFO_GFP,
23539 - THREAD_SIZE_ORDER));
23540 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23541 - irqctx->tinfo.cpu = cpu;
23542 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23543 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23544 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23545 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23546
23547 - per_cpu(hardirq_ctx, cpu) = irqctx;
23548 -
23549 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23550 - THREADINFO_GFP,
23551 - THREAD_SIZE_ORDER));
23552 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23553 - irqctx->tinfo.cpu = cpu;
23554 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23555 -
23556 - per_cpu(softirq_ctx, cpu) = irqctx;
23557 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23558 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23559
23560 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23561 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23562 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23563 asmlinkage void do_softirq(void)
23564 {
23565 unsigned long flags;
23566 - struct thread_info *curctx;
23567 union irq_ctx *irqctx;
23568 u32 *isp;
23569
23570 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23571 local_irq_save(flags);
23572
23573 if (local_softirq_pending()) {
23574 - curctx = current_thread_info();
23575 irqctx = __this_cpu_read(softirq_ctx);
23576 - irqctx->tinfo.task = curctx->task;
23577 - irqctx->tinfo.previous_esp = current_stack_pointer;
23578 + irqctx->previous_esp = current_stack_pointer;
23579
23580 /* build the stack frame on the softirq stack */
23581 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23582 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23583 +
23584 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23585 + __set_fs(MAKE_MM_SEG(0));
23586 +#endif
23587
23588 call_on_stack(__do_softirq, isp);
23589 +
23590 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23591 + __set_fs(current_thread_info()->addr_limit);
23592 +#endif
23593 +
23594 /*
23595 * Shouldn't happen, we returned above if in_interrupt():
23596 */
23597 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23598 if (unlikely(!desc))
23599 return false;
23600
23601 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23602 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23603 if (unlikely(overflow))
23604 print_stack_overflow();
23605 desc->handle_irq(irq, desc);
23606 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23607 index d04d3ec..ea4b374 100644
23608 --- a/arch/x86/kernel/irq_64.c
23609 +++ b/arch/x86/kernel/irq_64.c
23610 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23611 u64 estack_top, estack_bottom;
23612 u64 curbase = (u64)task_stack_page(current);
23613
23614 - if (user_mode_vm(regs))
23615 + if (user_mode(regs))
23616 return;
23617
23618 if (regs->sp >= curbase + sizeof(struct thread_info) +
23619 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
23620 index dc1404b..bbc43e7 100644
23621 --- a/arch/x86/kernel/kdebugfs.c
23622 +++ b/arch/x86/kernel/kdebugfs.c
23623 @@ -27,7 +27,7 @@ struct setup_data_node {
23624 u32 len;
23625 };
23626
23627 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
23628 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
23629 size_t count, loff_t *ppos)
23630 {
23631 struct setup_data_node *node = file->private_data;
23632 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23633 index 836f832..a8bda67 100644
23634 --- a/arch/x86/kernel/kgdb.c
23635 +++ b/arch/x86/kernel/kgdb.c
23636 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23637 #ifdef CONFIG_X86_32
23638 switch (regno) {
23639 case GDB_SS:
23640 - if (!user_mode_vm(regs))
23641 + if (!user_mode(regs))
23642 *(unsigned long *)mem = __KERNEL_DS;
23643 break;
23644 case GDB_SP:
23645 - if (!user_mode_vm(regs))
23646 + if (!user_mode(regs))
23647 *(unsigned long *)mem = kernel_stack_pointer(regs);
23648 break;
23649 case GDB_GS:
23650 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23651 bp->attr.bp_addr = breakinfo[breakno].addr;
23652 bp->attr.bp_len = breakinfo[breakno].len;
23653 bp->attr.bp_type = breakinfo[breakno].type;
23654 - info->address = breakinfo[breakno].addr;
23655 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23656 + info->address = ktla_ktva(breakinfo[breakno].addr);
23657 + else
23658 + info->address = breakinfo[breakno].addr;
23659 info->len = breakinfo[breakno].len;
23660 info->type = breakinfo[breakno].type;
23661 val = arch_install_hw_breakpoint(bp);
23662 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23663 case 'k':
23664 /* clear the trace bit */
23665 linux_regs->flags &= ~X86_EFLAGS_TF;
23666 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23667 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23668
23669 /* set the trace bit if we're stepping */
23670 if (remcomInBuffer[0] == 's') {
23671 linux_regs->flags |= X86_EFLAGS_TF;
23672 - atomic_set(&kgdb_cpu_doing_single_step,
23673 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23674 raw_smp_processor_id());
23675 }
23676
23677 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23678
23679 switch (cmd) {
23680 case DIE_DEBUG:
23681 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23682 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23683 if (user_mode(regs))
23684 return single_step_cont(regs, args);
23685 break;
23686 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23687 #endif /* CONFIG_DEBUG_RODATA */
23688
23689 bpt->type = BP_BREAKPOINT;
23690 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23691 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23692 BREAK_INSTR_SIZE);
23693 if (err)
23694 return err;
23695 - err = probe_kernel_write((char *)bpt->bpt_addr,
23696 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23697 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23698 #ifdef CONFIG_DEBUG_RODATA
23699 if (!err)
23700 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23701 return -EBUSY;
23702 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23703 BREAK_INSTR_SIZE);
23704 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23705 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23706 if (err)
23707 return err;
23708 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23709 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23710 if (mutex_is_locked(&text_mutex))
23711 goto knl_write;
23712 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23713 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23714 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23715 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23716 goto knl_write;
23717 return err;
23718 knl_write:
23719 #endif /* CONFIG_DEBUG_RODATA */
23720 - return probe_kernel_write((char *)bpt->bpt_addr,
23721 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23722 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23723 }
23724
23725 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23726 index 211bce4..6e2580a 100644
23727 --- a/arch/x86/kernel/kprobes/core.c
23728 +++ b/arch/x86/kernel/kprobes/core.c
23729 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23730 s32 raddr;
23731 } __packed *insn;
23732
23733 - insn = (struct __arch_relative_insn *)from;
23734 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23735 +
23736 + pax_open_kernel();
23737 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23738 insn->op = op;
23739 + pax_close_kernel();
23740 }
23741
23742 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23743 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23744 kprobe_opcode_t opcode;
23745 kprobe_opcode_t *orig_opcodes = opcodes;
23746
23747 - if (search_exception_tables((unsigned long)opcodes))
23748 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23749 return 0; /* Page fault may occur on this address. */
23750
23751 retry:
23752 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23753 * for the first byte, we can recover the original instruction
23754 * from it and kp->opcode.
23755 */
23756 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23757 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23758 buf[0] = kp->opcode;
23759 - return (unsigned long)buf;
23760 + return ktva_ktla((unsigned long)buf);
23761 }
23762
23763 /*
23764 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23765 /* Another subsystem puts a breakpoint, failed to recover */
23766 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23767 return 0;
23768 + pax_open_kernel();
23769 memcpy(dest, insn.kaddr, insn.length);
23770 + pax_close_kernel();
23771
23772 #ifdef CONFIG_X86_64
23773 if (insn_rip_relative(&insn)) {
23774 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23775 return 0;
23776 }
23777 disp = (u8 *) dest + insn_offset_displacement(&insn);
23778 + pax_open_kernel();
23779 *(s32 *) disp = (s32) newdisp;
23780 + pax_close_kernel();
23781 }
23782 #endif
23783 return insn.length;
23784 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23785 * nor set current_kprobe, because it doesn't use single
23786 * stepping.
23787 */
23788 - regs->ip = (unsigned long)p->ainsn.insn;
23789 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23790 preempt_enable_no_resched();
23791 return;
23792 }
23793 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23794 regs->flags &= ~X86_EFLAGS_IF;
23795 /* single step inline if the instruction is an int3 */
23796 if (p->opcode == BREAKPOINT_INSTRUCTION)
23797 - regs->ip = (unsigned long)p->addr;
23798 + regs->ip = ktla_ktva((unsigned long)p->addr);
23799 else
23800 - regs->ip = (unsigned long)p->ainsn.insn;
23801 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23802 }
23803
23804 /*
23805 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23806 setup_singlestep(p, regs, kcb, 0);
23807 return 1;
23808 }
23809 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23810 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23811 /*
23812 * The breakpoint instruction was removed right
23813 * after we hit it. Another cpu has removed
23814 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23815 " movq %rax, 152(%rsp)\n"
23816 RESTORE_REGS_STRING
23817 " popfq\n"
23818 +#ifdef KERNEXEC_PLUGIN
23819 + " btsq $63,(%rsp)\n"
23820 +#endif
23821 #else
23822 " pushf\n"
23823 SAVE_REGS_STRING
23824 @@ -779,7 +789,7 @@ static void __kprobes
23825 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23826 {
23827 unsigned long *tos = stack_addr(regs);
23828 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23829 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23830 unsigned long orig_ip = (unsigned long)p->addr;
23831 kprobe_opcode_t *insn = p->ainsn.insn;
23832
23833 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23834 struct die_args *args = data;
23835 int ret = NOTIFY_DONE;
23836
23837 - if (args->regs && user_mode_vm(args->regs))
23838 + if (args->regs && user_mode(args->regs))
23839 return ret;
23840
23841 switch (val) {
23842 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23843 index 76dc6f0..66bdfc3 100644
23844 --- a/arch/x86/kernel/kprobes/opt.c
23845 +++ b/arch/x86/kernel/kprobes/opt.c
23846 @@ -79,6 +79,7 @@ found:
23847 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23848 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23849 {
23850 + pax_open_kernel();
23851 #ifdef CONFIG_X86_64
23852 *addr++ = 0x48;
23853 *addr++ = 0xbf;
23854 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23855 *addr++ = 0xb8;
23856 #endif
23857 *(unsigned long *)addr = val;
23858 + pax_close_kernel();
23859 }
23860
23861 static void __used __kprobes kprobes_optinsn_template_holder(void)
23862 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23863 * Verify if the address gap is in 2GB range, because this uses
23864 * a relative jump.
23865 */
23866 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23867 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23868 if (abs(rel) > 0x7fffffff)
23869 return -ERANGE;
23870
23871 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23872 op->optinsn.size = ret;
23873
23874 /* Copy arch-dep-instance from template */
23875 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23876 + pax_open_kernel();
23877 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23878 + pax_close_kernel();
23879
23880 /* Set probe information */
23881 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23882
23883 /* Set probe function call */
23884 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23885 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23886
23887 /* Set returning jmp instruction at the tail of out-of-line buffer */
23888 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23889 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23890 (u8 *)op->kp.addr + op->optinsn.size);
23891
23892 flush_icache_range((unsigned long) buf,
23893 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
23894 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
23895
23896 /* Backup instructions which will be replaced by jump address */
23897 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23898 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23899 RELATIVE_ADDR_SIZE);
23900
23901 insn_buf[0] = RELATIVEJUMP_OPCODE;
23902 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23903 /* This kprobe is really able to run optimized path. */
23904 op = container_of(p, struct optimized_kprobe, kp);
23905 /* Detour through copied instructions */
23906 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23907 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23908 if (!reenter)
23909 reset_current_kprobe();
23910 preempt_enable_no_resched();
23911 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23912 index ebc9873..1b9724b 100644
23913 --- a/arch/x86/kernel/ldt.c
23914 +++ b/arch/x86/kernel/ldt.c
23915 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23916 if (reload) {
23917 #ifdef CONFIG_SMP
23918 preempt_disable();
23919 - load_LDT(pc);
23920 + load_LDT_nolock(pc);
23921 if (!cpumask_equal(mm_cpumask(current->mm),
23922 cpumask_of(smp_processor_id())))
23923 smp_call_function(flush_ldt, current->mm, 1);
23924 preempt_enable();
23925 #else
23926 - load_LDT(pc);
23927 + load_LDT_nolock(pc);
23928 #endif
23929 }
23930 if (oldsize) {
23931 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23932 return err;
23933
23934 for (i = 0; i < old->size; i++)
23935 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23936 + write_ldt_entry(new->ldt, i, old->ldt + i);
23937 return 0;
23938 }
23939
23940 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23941 retval = copy_ldt(&mm->context, &old_mm->context);
23942 mutex_unlock(&old_mm->context.lock);
23943 }
23944 +
23945 + if (tsk == current) {
23946 + mm->context.vdso = 0;
23947 +
23948 +#ifdef CONFIG_X86_32
23949 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23950 + mm->context.user_cs_base = 0UL;
23951 + mm->context.user_cs_limit = ~0UL;
23952 +
23953 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23954 + cpus_clear(mm->context.cpu_user_cs_mask);
23955 +#endif
23956 +
23957 +#endif
23958 +#endif
23959 +
23960 + }
23961 +
23962 return retval;
23963 }
23964
23965 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23966 }
23967 }
23968
23969 +#ifdef CONFIG_PAX_SEGMEXEC
23970 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23971 + error = -EINVAL;
23972 + goto out_unlock;
23973 + }
23974 +#endif
23975 +
23976 fill_ldt(&ldt, &ldt_info);
23977 if (oldmode)
23978 ldt.avl = 0;
23979 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
23980 index 5b19e4d..6476a76 100644
23981 --- a/arch/x86/kernel/machine_kexec_32.c
23982 +++ b/arch/x86/kernel/machine_kexec_32.c
23983 @@ -26,7 +26,7 @@
23984 #include <asm/cacheflush.h>
23985 #include <asm/debugreg.h>
23986
23987 -static void set_idt(void *newidt, __u16 limit)
23988 +static void set_idt(struct desc_struct *newidt, __u16 limit)
23989 {
23990 struct desc_ptr curidt;
23991
23992 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
23993 }
23994
23995
23996 -static void set_gdt(void *newgdt, __u16 limit)
23997 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
23998 {
23999 struct desc_ptr curgdt;
24000
24001 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24002 }
24003
24004 control_page = page_address(image->control_code_page);
24005 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24006 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24007
24008 relocate_kernel_ptr = control_page;
24009 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24010 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24011 index 15c9876..0a43909 100644
24012 --- a/arch/x86/kernel/microcode_core.c
24013 +++ b/arch/x86/kernel/microcode_core.c
24014 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24015 return NOTIFY_OK;
24016 }
24017
24018 -static struct notifier_block __refdata mc_cpu_notifier = {
24019 +static struct notifier_block mc_cpu_notifier = {
24020 .notifier_call = mc_cpu_callback,
24021 };
24022
24023 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24024 index 5fb2ceb..3ae90bb 100644
24025 --- a/arch/x86/kernel/microcode_intel.c
24026 +++ b/arch/x86/kernel/microcode_intel.c
24027 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24028
24029 static int get_ucode_user(void *to, const void *from, size_t n)
24030 {
24031 - return copy_from_user(to, from, n);
24032 + return copy_from_user(to, (const void __force_user *)from, n);
24033 }
24034
24035 static enum ucode_state
24036 request_microcode_user(int cpu, const void __user *buf, size_t size)
24037 {
24038 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24039 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24040 }
24041
24042 static void microcode_fini_cpu(int cpu)
24043 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24044 index 216a4d7..228255a 100644
24045 --- a/arch/x86/kernel/module.c
24046 +++ b/arch/x86/kernel/module.c
24047 @@ -43,15 +43,60 @@ do { \
24048 } while (0)
24049 #endif
24050
24051 -void *module_alloc(unsigned long size)
24052 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24053 {
24054 - if (PAGE_ALIGN(size) > MODULES_LEN)
24055 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24056 return NULL;
24057 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24058 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24059 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24060 -1, __builtin_return_address(0));
24061 }
24062
24063 +void *module_alloc(unsigned long size)
24064 +{
24065 +
24066 +#ifdef CONFIG_PAX_KERNEXEC
24067 + return __module_alloc(size, PAGE_KERNEL);
24068 +#else
24069 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24070 +#endif
24071 +
24072 +}
24073 +
24074 +#ifdef CONFIG_PAX_KERNEXEC
24075 +#ifdef CONFIG_X86_32
24076 +void *module_alloc_exec(unsigned long size)
24077 +{
24078 + struct vm_struct *area;
24079 +
24080 + if (size == 0)
24081 + return NULL;
24082 +
24083 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24084 + return area ? area->addr : NULL;
24085 +}
24086 +EXPORT_SYMBOL(module_alloc_exec);
24087 +
24088 +void module_free_exec(struct module *mod, void *module_region)
24089 +{
24090 + vunmap(module_region);
24091 +}
24092 +EXPORT_SYMBOL(module_free_exec);
24093 +#else
24094 +void module_free_exec(struct module *mod, void *module_region)
24095 +{
24096 + module_free(mod, module_region);
24097 +}
24098 +EXPORT_SYMBOL(module_free_exec);
24099 +
24100 +void *module_alloc_exec(unsigned long size)
24101 +{
24102 + return __module_alloc(size, PAGE_KERNEL_RX);
24103 +}
24104 +EXPORT_SYMBOL(module_alloc_exec);
24105 +#endif
24106 +#endif
24107 +
24108 #ifdef CONFIG_X86_32
24109 int apply_relocate(Elf32_Shdr *sechdrs,
24110 const char *strtab,
24111 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24112 unsigned int i;
24113 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24114 Elf32_Sym *sym;
24115 - uint32_t *location;
24116 + uint32_t *plocation, location;
24117
24118 DEBUGP("Applying relocate section %u to %u\n",
24119 relsec, sechdrs[relsec].sh_info);
24120 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24121 /* This is where to make the change */
24122 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24123 - + rel[i].r_offset;
24124 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24125 + location = (uint32_t)plocation;
24126 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24127 + plocation = ktla_ktva((void *)plocation);
24128 /* This is the symbol it is referring to. Note that all
24129 undefined symbols have been resolved. */
24130 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24131 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24132 switch (ELF32_R_TYPE(rel[i].r_info)) {
24133 case R_386_32:
24134 /* We add the value into the location given */
24135 - *location += sym->st_value;
24136 + pax_open_kernel();
24137 + *plocation += sym->st_value;
24138 + pax_close_kernel();
24139 break;
24140 case R_386_PC32:
24141 /* Add the value, subtract its position */
24142 - *location += sym->st_value - (uint32_t)location;
24143 + pax_open_kernel();
24144 + *plocation += sym->st_value - location;
24145 + pax_close_kernel();
24146 break;
24147 default:
24148 pr_err("%s: Unknown relocation: %u\n",
24149 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24150 case R_X86_64_NONE:
24151 break;
24152 case R_X86_64_64:
24153 + pax_open_kernel();
24154 *(u64 *)loc = val;
24155 + pax_close_kernel();
24156 break;
24157 case R_X86_64_32:
24158 + pax_open_kernel();
24159 *(u32 *)loc = val;
24160 + pax_close_kernel();
24161 if (val != *(u32 *)loc)
24162 goto overflow;
24163 break;
24164 case R_X86_64_32S:
24165 + pax_open_kernel();
24166 *(s32 *)loc = val;
24167 + pax_close_kernel();
24168 if ((s64)val != *(s32 *)loc)
24169 goto overflow;
24170 break;
24171 case R_X86_64_PC32:
24172 val -= (u64)loc;
24173 + pax_open_kernel();
24174 *(u32 *)loc = val;
24175 + pax_close_kernel();
24176 +
24177 #if 0
24178 if ((s64)val != *(s32 *)loc)
24179 goto overflow;
24180 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24181 index 88458fa..349f7a4 100644
24182 --- a/arch/x86/kernel/msr.c
24183 +++ b/arch/x86/kernel/msr.c
24184 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24185 return notifier_from_errno(err);
24186 }
24187
24188 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24189 +static struct notifier_block msr_class_cpu_notifier = {
24190 .notifier_call = msr_class_cpu_callback,
24191 };
24192
24193 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24194 index ba77ebc..65da999 100644
24195 --- a/arch/x86/kernel/nmi.c
24196 +++ b/arch/x86/kernel/nmi.c
24197 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24198 return handled;
24199 }
24200
24201 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24202 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24203 {
24204 struct nmi_desc *desc = nmi_to_desc(type);
24205 unsigned long flags;
24206 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24207 * event confuses some handlers (kdump uses this flag)
24208 */
24209 if (action->flags & NMI_FLAG_FIRST)
24210 - list_add_rcu(&action->list, &desc->head);
24211 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24212 else
24213 - list_add_tail_rcu(&action->list, &desc->head);
24214 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24215
24216 spin_unlock_irqrestore(&desc->lock, flags);
24217 return 0;
24218 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24219 if (!strcmp(n->name, name)) {
24220 WARN(in_nmi(),
24221 "Trying to free NMI (%s) from NMI context!\n", n->name);
24222 - list_del_rcu(&n->list);
24223 + pax_list_del_rcu((struct list_head *)&n->list);
24224 break;
24225 }
24226 }
24227 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24228 dotraplinkage notrace __kprobes void
24229 do_nmi(struct pt_regs *regs, long error_code)
24230 {
24231 +
24232 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24233 + if (!user_mode(regs)) {
24234 + unsigned long cs = regs->cs & 0xFFFF;
24235 + unsigned long ip = ktva_ktla(regs->ip);
24236 +
24237 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24238 + regs->ip = ip;
24239 + }
24240 +#endif
24241 +
24242 nmi_nesting_preprocess(regs);
24243
24244 nmi_enter();
24245 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24246 index 6d9582e..f746287 100644
24247 --- a/arch/x86/kernel/nmi_selftest.c
24248 +++ b/arch/x86/kernel/nmi_selftest.c
24249 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24250 {
24251 /* trap all the unknown NMIs we may generate */
24252 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24253 - __initdata);
24254 + __initconst);
24255 }
24256
24257 static void __init cleanup_nmi_testsuite(void)
24258 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24259 unsigned long timeout;
24260
24261 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24262 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24263 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24264 nmi_fail = FAILURE;
24265 return;
24266 }
24267 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24268 index 676b8c7..870ba04 100644
24269 --- a/arch/x86/kernel/paravirt-spinlocks.c
24270 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24271 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
24272 arch_spin_lock(lock);
24273 }
24274
24275 -struct pv_lock_ops pv_lock_ops = {
24276 +struct pv_lock_ops pv_lock_ops __read_only = {
24277 #ifdef CONFIG_SMP
24278 .spin_is_locked = __ticket_spin_is_locked,
24279 .spin_is_contended = __ticket_spin_is_contended,
24280 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24281 index cd6de64..27c6af0 100644
24282 --- a/arch/x86/kernel/paravirt.c
24283 +++ b/arch/x86/kernel/paravirt.c
24284 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24285 {
24286 return x;
24287 }
24288 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24289 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24290 +#endif
24291
24292 void __init default_banner(void)
24293 {
24294 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24295 if (opfunc == NULL)
24296 /* If there's no function, patch it with a ud2a (BUG) */
24297 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24298 - else if (opfunc == _paravirt_nop)
24299 + else if (opfunc == (void *)_paravirt_nop)
24300 /* If the operation is a nop, then nop the callsite */
24301 ret = paravirt_patch_nop();
24302
24303 /* identity functions just return their single argument */
24304 - else if (opfunc == _paravirt_ident_32)
24305 + else if (opfunc == (void *)_paravirt_ident_32)
24306 ret = paravirt_patch_ident_32(insnbuf, len);
24307 - else if (opfunc == _paravirt_ident_64)
24308 + else if (opfunc == (void *)_paravirt_ident_64)
24309 ret = paravirt_patch_ident_64(insnbuf, len);
24310 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24311 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24312 + ret = paravirt_patch_ident_64(insnbuf, len);
24313 +#endif
24314
24315 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24316 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24317 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24318 if (insn_len > len || start == NULL)
24319 insn_len = len;
24320 else
24321 - memcpy(insnbuf, start, insn_len);
24322 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24323
24324 return insn_len;
24325 }
24326 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24327 return this_cpu_read(paravirt_lazy_mode);
24328 }
24329
24330 -struct pv_info pv_info = {
24331 +struct pv_info pv_info __read_only = {
24332 .name = "bare hardware",
24333 .paravirt_enabled = 0,
24334 .kernel_rpl = 0,
24335 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
24336 #endif
24337 };
24338
24339 -struct pv_init_ops pv_init_ops = {
24340 +struct pv_init_ops pv_init_ops __read_only = {
24341 .patch = native_patch,
24342 };
24343
24344 -struct pv_time_ops pv_time_ops = {
24345 +struct pv_time_ops pv_time_ops __read_only = {
24346 .sched_clock = native_sched_clock,
24347 .steal_clock = native_steal_clock,
24348 };
24349
24350 -struct pv_irq_ops pv_irq_ops = {
24351 +struct pv_irq_ops pv_irq_ops __read_only = {
24352 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24353 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24354 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24355 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
24356 #endif
24357 };
24358
24359 -struct pv_cpu_ops pv_cpu_ops = {
24360 +struct pv_cpu_ops pv_cpu_ops __read_only = {
24361 .cpuid = native_cpuid,
24362 .get_debugreg = native_get_debugreg,
24363 .set_debugreg = native_set_debugreg,
24364 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
24365 .end_context_switch = paravirt_nop,
24366 };
24367
24368 -struct pv_apic_ops pv_apic_ops = {
24369 +struct pv_apic_ops pv_apic_ops __read_only= {
24370 #ifdef CONFIG_X86_LOCAL_APIC
24371 .startup_ipi_hook = paravirt_nop,
24372 #endif
24373 };
24374
24375 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24376 +#ifdef CONFIG_X86_32
24377 +#ifdef CONFIG_X86_PAE
24378 +/* 64-bit pagetable entries */
24379 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24380 +#else
24381 /* 32-bit pagetable entries */
24382 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24383 +#endif
24384 #else
24385 /* 64-bit pagetable entries */
24386 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24387 #endif
24388
24389 -struct pv_mmu_ops pv_mmu_ops = {
24390 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24391
24392 .read_cr2 = native_read_cr2,
24393 .write_cr2 = native_write_cr2,
24394 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24395 .make_pud = PTE_IDENT,
24396
24397 .set_pgd = native_set_pgd,
24398 + .set_pgd_batched = native_set_pgd_batched,
24399 #endif
24400 #endif /* PAGETABLE_LEVELS >= 3 */
24401
24402 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24403 },
24404
24405 .set_fixmap = native_set_fixmap,
24406 +
24407 +#ifdef CONFIG_PAX_KERNEXEC
24408 + .pax_open_kernel = native_pax_open_kernel,
24409 + .pax_close_kernel = native_pax_close_kernel,
24410 +#endif
24411 +
24412 };
24413
24414 EXPORT_SYMBOL_GPL(pv_time_ops);
24415 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24416 index 299d493..2ccb0ee 100644
24417 --- a/arch/x86/kernel/pci-calgary_64.c
24418 +++ b/arch/x86/kernel/pci-calgary_64.c
24419 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24420 tce_space = be64_to_cpu(readq(target));
24421 tce_space = tce_space & TAR_SW_BITS;
24422
24423 - tce_space = tce_space & (~specified_table_size);
24424 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24425 info->tce_space = (u64 *)__va(tce_space);
24426 }
24427 }
24428 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24429 index 35ccf75..7a15747 100644
24430 --- a/arch/x86/kernel/pci-iommu_table.c
24431 +++ b/arch/x86/kernel/pci-iommu_table.c
24432 @@ -2,7 +2,7 @@
24433 #include <asm/iommu_table.h>
24434 #include <linux/string.h>
24435 #include <linux/kallsyms.h>
24436 -
24437 +#include <linux/sched.h>
24438
24439 #define DEBUG 1
24440
24441 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24442 index 6c483ba..d10ce2f 100644
24443 --- a/arch/x86/kernel/pci-swiotlb.c
24444 +++ b/arch/x86/kernel/pci-swiotlb.c
24445 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24446 void *vaddr, dma_addr_t dma_addr,
24447 struct dma_attrs *attrs)
24448 {
24449 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24450 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24451 }
24452
24453 static struct dma_map_ops swiotlb_dma_ops = {
24454 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24455 index 83369e5..52b93f0 100644
24456 --- a/arch/x86/kernel/process.c
24457 +++ b/arch/x86/kernel/process.c
24458 @@ -36,7 +36,8 @@
24459 * section. Since TSS's are completely CPU-local, we want them
24460 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24461 */
24462 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24463 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24464 +EXPORT_SYMBOL(init_tss);
24465
24466 #ifdef CONFIG_X86_64
24467 static DEFINE_PER_CPU(unsigned char, is_idle);
24468 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24469 task_xstate_cachep =
24470 kmem_cache_create("task_xstate", xstate_size,
24471 __alignof__(union thread_xstate),
24472 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24473 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24474 }
24475
24476 /*
24477 @@ -105,7 +106,7 @@ void exit_thread(void)
24478 unsigned long *bp = t->io_bitmap_ptr;
24479
24480 if (bp) {
24481 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24482 + struct tss_struct *tss = init_tss + get_cpu();
24483
24484 t->io_bitmap_ptr = NULL;
24485 clear_thread_flag(TIF_IO_BITMAP);
24486 @@ -125,6 +126,9 @@ void flush_thread(void)
24487 {
24488 struct task_struct *tsk = current;
24489
24490 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24491 + loadsegment(gs, 0);
24492 +#endif
24493 flush_ptrace_hw_breakpoint(tsk);
24494 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24495 drop_init_fpu(tsk);
24496 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24497 void exit_idle(void)
24498 {
24499 /* idle loop has pid 0 */
24500 - if (current->pid)
24501 + if (task_pid_nr(current))
24502 return;
24503 __exit_idle();
24504 }
24505 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24506 return ret;
24507 }
24508 #endif
24509 -void stop_this_cpu(void *dummy)
24510 +__noreturn void stop_this_cpu(void *dummy)
24511 {
24512 local_irq_disable();
24513 /*
24514 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24515 }
24516 early_param("idle", idle_setup);
24517
24518 -unsigned long arch_align_stack(unsigned long sp)
24519 +#ifdef CONFIG_PAX_RANDKSTACK
24520 +void pax_randomize_kstack(struct pt_regs *regs)
24521 {
24522 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24523 - sp -= get_random_int() % 8192;
24524 - return sp & ~0xf;
24525 -}
24526 + struct thread_struct *thread = &current->thread;
24527 + unsigned long time;
24528
24529 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24530 -{
24531 - unsigned long range_end = mm->brk + 0x02000000;
24532 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24533 -}
24534 + if (!randomize_va_space)
24535 + return;
24536 +
24537 + if (v8086_mode(regs))
24538 + return;
24539
24540 + rdtscl(time);
24541 +
24542 + /* P4 seems to return a 0 LSB, ignore it */
24543 +#ifdef CONFIG_MPENTIUM4
24544 + time &= 0x3EUL;
24545 + time <<= 2;
24546 +#elif defined(CONFIG_X86_64)
24547 + time &= 0xFUL;
24548 + time <<= 4;
24549 +#else
24550 + time &= 0x1FUL;
24551 + time <<= 3;
24552 +#endif
24553 +
24554 + thread->sp0 ^= time;
24555 + load_sp0(init_tss + smp_processor_id(), thread);
24556 +
24557 +#ifdef CONFIG_X86_64
24558 + this_cpu_write(kernel_stack, thread->sp0);
24559 +#endif
24560 +}
24561 +#endif
24562 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24563 index f8adefc..4bce3d6 100644
24564 --- a/arch/x86/kernel/process_32.c
24565 +++ b/arch/x86/kernel/process_32.c
24566 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24567 unsigned long thread_saved_pc(struct task_struct *tsk)
24568 {
24569 return ((unsigned long *)tsk->thread.sp)[3];
24570 +//XXX return tsk->thread.eip;
24571 }
24572
24573 void __show_regs(struct pt_regs *regs, int all)
24574 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24575 unsigned long sp;
24576 unsigned short ss, gs;
24577
24578 - if (user_mode_vm(regs)) {
24579 + if (user_mode(regs)) {
24580 sp = regs->sp;
24581 ss = regs->ss & 0xffff;
24582 - gs = get_user_gs(regs);
24583 } else {
24584 sp = kernel_stack_pointer(regs);
24585 savesegment(ss, ss);
24586 - savesegment(gs, gs);
24587 }
24588 + gs = get_user_gs(regs);
24589
24590 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24591 (u16)regs->cs, regs->ip, regs->flags,
24592 - smp_processor_id());
24593 + raw_smp_processor_id());
24594 print_symbol("EIP is at %s\n", regs->ip);
24595
24596 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24597 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24598 int copy_thread(unsigned long clone_flags, unsigned long sp,
24599 unsigned long arg, struct task_struct *p)
24600 {
24601 - struct pt_regs *childregs = task_pt_regs(p);
24602 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24603 struct task_struct *tsk;
24604 int err;
24605
24606 p->thread.sp = (unsigned long) childregs;
24607 p->thread.sp0 = (unsigned long) (childregs+1);
24608 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24609
24610 if (unlikely(p->flags & PF_KTHREAD)) {
24611 /* kernel thread */
24612 memset(childregs, 0, sizeof(struct pt_regs));
24613 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24614 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24615 - childregs->ds = __USER_DS;
24616 - childregs->es = __USER_DS;
24617 + savesegment(gs, childregs->gs);
24618 + childregs->ds = __KERNEL_DS;
24619 + childregs->es = __KERNEL_DS;
24620 childregs->fs = __KERNEL_PERCPU;
24621 childregs->bx = sp; /* function */
24622 childregs->bp = arg;
24623 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24624 struct thread_struct *prev = &prev_p->thread,
24625 *next = &next_p->thread;
24626 int cpu = smp_processor_id();
24627 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24628 + struct tss_struct *tss = init_tss + cpu;
24629 fpu_switch_t fpu;
24630
24631 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24632 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24633 */
24634 lazy_save_gs(prev->gs);
24635
24636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24637 + __set_fs(task_thread_info(next_p)->addr_limit);
24638 +#endif
24639 +
24640 /*
24641 * Load the per-thread Thread-Local Storage descriptor.
24642 */
24643 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24644 */
24645 arch_end_context_switch(next_p);
24646
24647 + this_cpu_write(current_task, next_p);
24648 + this_cpu_write(current_tinfo, &next_p->tinfo);
24649 +
24650 /*
24651 * Restore %gs if needed (which is common)
24652 */
24653 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24654
24655 switch_fpu_finish(next_p, fpu);
24656
24657 - this_cpu_write(current_task, next_p);
24658 -
24659 return prev_p;
24660 }
24661
24662 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24663 } while (count++ < 16);
24664 return 0;
24665 }
24666 -
24667 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24668 index 05646ba..0c2906d 100644
24669 --- a/arch/x86/kernel/process_64.c
24670 +++ b/arch/x86/kernel/process_64.c
24671 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24672 struct pt_regs *childregs;
24673 struct task_struct *me = current;
24674
24675 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24676 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24677 childregs = task_pt_regs(p);
24678 p->thread.sp = (unsigned long) childregs;
24679 p->thread.usersp = me->thread.usersp;
24680 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24681 set_tsk_thread_flag(p, TIF_FORK);
24682 p->fpu_counter = 0;
24683 p->thread.io_bitmap_ptr = NULL;
24684 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24685 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24686 savesegment(es, p->thread.es);
24687 savesegment(ds, p->thread.ds);
24688 + savesegment(ss, p->thread.ss);
24689 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24690 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24691
24692 if (unlikely(p->flags & PF_KTHREAD)) {
24693 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24694 struct thread_struct *prev = &prev_p->thread;
24695 struct thread_struct *next = &next_p->thread;
24696 int cpu = smp_processor_id();
24697 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24698 + struct tss_struct *tss = init_tss + cpu;
24699 unsigned fsindex, gsindex;
24700 fpu_switch_t fpu;
24701
24702 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24703 if (unlikely(next->ds | prev->ds))
24704 loadsegment(ds, next->ds);
24705
24706 + savesegment(ss, prev->ss);
24707 + if (unlikely(next->ss != prev->ss))
24708 + loadsegment(ss, next->ss);
24709
24710 /* We must save %fs and %gs before load_TLS() because
24711 * %fs and %gs may be cleared by load_TLS().
24712 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24713 prev->usersp = this_cpu_read(old_rsp);
24714 this_cpu_write(old_rsp, next->usersp);
24715 this_cpu_write(current_task, next_p);
24716 + this_cpu_write(current_tinfo, &next_p->tinfo);
24717
24718 - this_cpu_write(kernel_stack,
24719 - (unsigned long)task_stack_page(next_p) +
24720 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24721 + this_cpu_write(kernel_stack, next->sp0);
24722
24723 /*
24724 * Now maybe reload the debug registers and handle I/O bitmaps
24725 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24726 if (!p || p == current || p->state == TASK_RUNNING)
24727 return 0;
24728 stack = (unsigned long)task_stack_page(p);
24729 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24730 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24731 return 0;
24732 fp = *(u64 *)(p->thread.sp);
24733 do {
24734 - if (fp < (unsigned long)stack ||
24735 - fp >= (unsigned long)stack+THREAD_SIZE)
24736 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24737 return 0;
24738 ip = *(u64 *)(fp+8);
24739 if (!in_sched_functions(ip))
24740 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24741 index 7461f50..1334029 100644
24742 --- a/arch/x86/kernel/ptrace.c
24743 +++ b/arch/x86/kernel/ptrace.c
24744 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24745 {
24746 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24747 unsigned long sp = (unsigned long)&regs->sp;
24748 - struct thread_info *tinfo;
24749
24750 - if (context == (sp & ~(THREAD_SIZE - 1)))
24751 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24752 return sp;
24753
24754 - tinfo = (struct thread_info *)context;
24755 - if (tinfo->previous_esp)
24756 - return tinfo->previous_esp;
24757 + sp = *(unsigned long *)context;
24758 + if (sp)
24759 + return sp;
24760
24761 return (unsigned long)regs;
24762 }
24763 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24764 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24765 {
24766 int i;
24767 - int dr7 = 0;
24768 + unsigned long dr7 = 0;
24769 struct arch_hw_breakpoint *info;
24770
24771 for (i = 0; i < HBP_NUM; i++) {
24772 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24773 unsigned long addr, unsigned long data)
24774 {
24775 int ret;
24776 - unsigned long __user *datap = (unsigned long __user *)data;
24777 + unsigned long __user *datap = (__force unsigned long __user *)data;
24778
24779 switch (request) {
24780 /* read the word at location addr in the USER area. */
24781 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24782 if ((int) addr < 0)
24783 return -EIO;
24784 ret = do_get_thread_area(child, addr,
24785 - (struct user_desc __user *)data);
24786 + (__force struct user_desc __user *) data);
24787 break;
24788
24789 case PTRACE_SET_THREAD_AREA:
24790 if ((int) addr < 0)
24791 return -EIO;
24792 ret = do_set_thread_area(child, addr,
24793 - (struct user_desc __user *)data, 0);
24794 + (__force struct user_desc __user *) data, 0);
24795 break;
24796 #endif
24797
24798 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24799
24800 #ifdef CONFIG_X86_64
24801
24802 -static struct user_regset x86_64_regsets[] __read_mostly = {
24803 +static user_regset_no_const x86_64_regsets[] __read_only = {
24804 [REGSET_GENERAL] = {
24805 .core_note_type = NT_PRSTATUS,
24806 .n = sizeof(struct user_regs_struct) / sizeof(long),
24807 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24808 #endif /* CONFIG_X86_64 */
24809
24810 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24811 -static struct user_regset x86_32_regsets[] __read_mostly = {
24812 +static user_regset_no_const x86_32_regsets[] __read_only = {
24813 [REGSET_GENERAL] = {
24814 .core_note_type = NT_PRSTATUS,
24815 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24816 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24817 */
24818 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24819
24820 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24821 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24822 {
24823 #ifdef CONFIG_X86_64
24824 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24825 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24826 memset(info, 0, sizeof(*info));
24827 info->si_signo = SIGTRAP;
24828 info->si_code = si_code;
24829 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24830 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24831 }
24832
24833 void user_single_step_siginfo(struct task_struct *tsk,
24834 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24835 # define IS_IA32 0
24836 #endif
24837
24838 +#ifdef CONFIG_GRKERNSEC_SETXID
24839 +extern void gr_delayed_cred_worker(void);
24840 +#endif
24841 +
24842 /*
24843 * We must return the syscall number to actually look up in the table.
24844 * This can be -1L to skip running any syscall at all.
24845 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24846
24847 user_exit();
24848
24849 +#ifdef CONFIG_GRKERNSEC_SETXID
24850 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24851 + gr_delayed_cred_worker();
24852 +#endif
24853 +
24854 /*
24855 * If we stepped into a sysenter/syscall insn, it trapped in
24856 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24857 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24858 */
24859 user_exit();
24860
24861 +#ifdef CONFIG_GRKERNSEC_SETXID
24862 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24863 + gr_delayed_cred_worker();
24864 +#endif
24865 +
24866 audit_syscall_exit(regs);
24867
24868 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24869 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24870 index 2cb9470..ff1fd80 100644
24871 --- a/arch/x86/kernel/pvclock.c
24872 +++ b/arch/x86/kernel/pvclock.c
24873 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24874 return pv_tsc_khz;
24875 }
24876
24877 -static atomic64_t last_value = ATOMIC64_INIT(0);
24878 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24879
24880 void pvclock_resume(void)
24881 {
24882 - atomic64_set(&last_value, 0);
24883 + atomic64_set_unchecked(&last_value, 0);
24884 }
24885
24886 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24887 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24888 * updating at the same time, and one of them could be slightly behind,
24889 * making the assumption that last_value always go forward fail to hold.
24890 */
24891 - last = atomic64_read(&last_value);
24892 + last = atomic64_read_unchecked(&last_value);
24893 do {
24894 if (ret < last)
24895 return last;
24896 - last = atomic64_cmpxchg(&last_value, last, ret);
24897 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24898 } while (unlikely(last != ret));
24899
24900 return ret;
24901 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24902 index 5f4ad27..9d96c99 100644
24903 --- a/arch/x86/kernel/reboot.c
24904 +++ b/arch/x86/kernel/reboot.c
24905 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24906
24907 void __noreturn machine_real_restart(unsigned int type)
24908 {
24909 +
24910 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24911 + struct desc_struct *gdt;
24912 +#endif
24913 +
24914 local_irq_disable();
24915
24916 /*
24917 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24918
24919 /* Jump to the identity-mapped low memory code */
24920 #ifdef CONFIG_X86_32
24921 - asm volatile("jmpl *%0" : :
24922 +
24923 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24924 + gdt = get_cpu_gdt_table(smp_processor_id());
24925 + pax_open_kernel();
24926 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24927 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24928 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24929 + loadsegment(ds, __KERNEL_DS);
24930 + loadsegment(es, __KERNEL_DS);
24931 + loadsegment(ss, __KERNEL_DS);
24932 +#endif
24933 +#ifdef CONFIG_PAX_KERNEXEC
24934 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24935 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24936 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24937 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24938 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24939 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24940 +#endif
24941 + pax_close_kernel();
24942 +#endif
24943 +
24944 + asm volatile("ljmpl *%0" : :
24945 "rm" (real_mode_header->machine_real_restart_asm),
24946 "a" (type));
24947 #else
24948 @@ -458,7 +485,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24949 * try to force a triple fault and then cycle between hitting the keyboard
24950 * controller and doing that
24951 */
24952 -static void native_machine_emergency_restart(void)
24953 +static void __noreturn native_machine_emergency_restart(void)
24954 {
24955 int i;
24956 int attempt = 0;
24957 @@ -567,13 +594,13 @@ void native_machine_shutdown(void)
24958 #endif
24959 }
24960
24961 -static void __machine_emergency_restart(int emergency)
24962 +static void __noreturn __machine_emergency_restart(int emergency)
24963 {
24964 reboot_emergency = emergency;
24965 machine_ops.emergency_restart();
24966 }
24967
24968 -static void native_machine_restart(char *__unused)
24969 +static void __noreturn native_machine_restart(char *__unused)
24970 {
24971 pr_notice("machine restart\n");
24972
24973 @@ -582,7 +609,7 @@ static void native_machine_restart(char *__unused)
24974 __machine_emergency_restart(0);
24975 }
24976
24977 -static void native_machine_halt(void)
24978 +static void __noreturn native_machine_halt(void)
24979 {
24980 /* Stop other cpus and apics */
24981 machine_shutdown();
24982 @@ -592,7 +619,7 @@ static void native_machine_halt(void)
24983 stop_this_cpu(NULL);
24984 }
24985
24986 -static void native_machine_power_off(void)
24987 +static void __noreturn native_machine_power_off(void)
24988 {
24989 if (pm_power_off) {
24990 if (!reboot_force)
24991 @@ -601,9 +628,10 @@ static void native_machine_power_off(void)
24992 }
24993 /* A fallback in case there is no PM info available */
24994 tboot_shutdown(TB_SHUTDOWN_HALT);
24995 + unreachable();
24996 }
24997
24998 -struct machine_ops machine_ops = {
24999 +struct machine_ops machine_ops __read_only = {
25000 .power_off = native_machine_power_off,
25001 .shutdown = native_machine_shutdown,
25002 .emergency_restart = native_machine_emergency_restart,
25003 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25004 index c8e41e9..64049ef 100644
25005 --- a/arch/x86/kernel/reboot_fixups_32.c
25006 +++ b/arch/x86/kernel/reboot_fixups_32.c
25007 @@ -57,7 +57,7 @@ struct device_fixup {
25008 unsigned int vendor;
25009 unsigned int device;
25010 void (*reboot_fixup)(struct pci_dev *);
25011 -};
25012 +} __do_const;
25013
25014 /*
25015 * PCI ids solely used for fixups_table go here
25016 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25017 index 3fd2c69..16ef367 100644
25018 --- a/arch/x86/kernel/relocate_kernel_64.S
25019 +++ b/arch/x86/kernel/relocate_kernel_64.S
25020 @@ -11,6 +11,7 @@
25021 #include <asm/kexec.h>
25022 #include <asm/processor-flags.h>
25023 #include <asm/pgtable_types.h>
25024 +#include <asm/alternative-asm.h>
25025
25026 /*
25027 * Must be relocatable PIC code callable as a C function
25028 @@ -96,8 +97,7 @@ relocate_kernel:
25029
25030 /* jump to identity mapped page */
25031 addq $(identity_mapped - relocate_kernel), %r8
25032 - pushq %r8
25033 - ret
25034 + jmp *%r8
25035
25036 identity_mapped:
25037 /* set return address to 0 if not preserving context */
25038 @@ -167,6 +167,7 @@ identity_mapped:
25039 xorl %r14d, %r14d
25040 xorl %r15d, %r15d
25041
25042 + pax_force_retaddr 0, 1
25043 ret
25044
25045 1:
25046 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25047 index 234e1e3..01cd64d 100644
25048 --- a/arch/x86/kernel/setup.c
25049 +++ b/arch/x86/kernel/setup.c
25050 @@ -110,6 +110,7 @@
25051 #include <asm/mce.h>
25052 #include <asm/alternative.h>
25053 #include <asm/prom.h>
25054 +#include <asm/boot.h>
25055
25056 /*
25057 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25058 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25059 #endif
25060
25061
25062 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25063 -unsigned long mmu_cr4_features;
25064 +#ifdef CONFIG_X86_64
25065 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25066 +#elif defined(CONFIG_X86_PAE)
25067 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25068 #else
25069 -unsigned long mmu_cr4_features = X86_CR4_PAE;
25070 +unsigned long mmu_cr4_features __read_only;
25071 #endif
25072
25073 +void set_in_cr4(unsigned long mask)
25074 +{
25075 + unsigned long cr4 = read_cr4();
25076 +
25077 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25078 + return;
25079 +
25080 + pax_open_kernel();
25081 + mmu_cr4_features |= mask;
25082 + pax_close_kernel();
25083 +
25084 + if (trampoline_cr4_features)
25085 + *trampoline_cr4_features = mmu_cr4_features;
25086 + cr4 |= mask;
25087 + write_cr4(cr4);
25088 +}
25089 +EXPORT_SYMBOL(set_in_cr4);
25090 +
25091 +void clear_in_cr4(unsigned long mask)
25092 +{
25093 + unsigned long cr4 = read_cr4();
25094 +
25095 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25096 + return;
25097 +
25098 + pax_open_kernel();
25099 + mmu_cr4_features &= ~mask;
25100 + pax_close_kernel();
25101 +
25102 + if (trampoline_cr4_features)
25103 + *trampoline_cr4_features = mmu_cr4_features;
25104 + cr4 &= ~mask;
25105 + write_cr4(cr4);
25106 +}
25107 +EXPORT_SYMBOL(clear_in_cr4);
25108 +
25109 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25110 int bootloader_type, bootloader_version;
25111
25112 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25113 * area (640->1Mb) as ram even though it is not.
25114 * take them out.
25115 */
25116 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25117 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25118
25119 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25120 }
25121 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25122 /* called before trim_bios_range() to spare extra sanitize */
25123 static void __init e820_add_kernel_range(void)
25124 {
25125 - u64 start = __pa_symbol(_text);
25126 + u64 start = __pa_symbol(ktla_ktva(_text));
25127 u64 size = __pa_symbol(_end) - start;
25128
25129 /*
25130 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25131
25132 void __init setup_arch(char **cmdline_p)
25133 {
25134 +#ifdef CONFIG_X86_32
25135 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25136 +#else
25137 memblock_reserve(__pa_symbol(_text),
25138 (unsigned long)__bss_stop - (unsigned long)_text);
25139 +#endif
25140
25141 early_reserve_initrd();
25142
25143 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25144
25145 if (!boot_params.hdr.root_flags)
25146 root_mountflags &= ~MS_RDONLY;
25147 - init_mm.start_code = (unsigned long) _text;
25148 - init_mm.end_code = (unsigned long) _etext;
25149 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25150 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25151 init_mm.end_data = (unsigned long) _edata;
25152 init_mm.brk = _brk_end;
25153
25154 - code_resource.start = __pa_symbol(_text);
25155 - code_resource.end = __pa_symbol(_etext)-1;
25156 - data_resource.start = __pa_symbol(_etext);
25157 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25158 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25159 + data_resource.start = __pa_symbol(_sdata);
25160 data_resource.end = __pa_symbol(_edata)-1;
25161 bss_resource.start = __pa_symbol(__bss_start);
25162 bss_resource.end = __pa_symbol(__bss_stop)-1;
25163 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25164 index 5cdff03..80fa283 100644
25165 --- a/arch/x86/kernel/setup_percpu.c
25166 +++ b/arch/x86/kernel/setup_percpu.c
25167 @@ -21,19 +21,17 @@
25168 #include <asm/cpu.h>
25169 #include <asm/stackprotector.h>
25170
25171 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25172 +#ifdef CONFIG_SMP
25173 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25174 EXPORT_PER_CPU_SYMBOL(cpu_number);
25175 +#endif
25176
25177 -#ifdef CONFIG_X86_64
25178 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25179 -#else
25180 -#define BOOT_PERCPU_OFFSET 0
25181 -#endif
25182
25183 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25184 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25185
25186 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25187 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25188 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25189 };
25190 EXPORT_SYMBOL(__per_cpu_offset);
25191 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25192 {
25193 #ifdef CONFIG_NEED_MULTIPLE_NODES
25194 pg_data_t *last = NULL;
25195 - unsigned int cpu;
25196 + int cpu;
25197
25198 for_each_possible_cpu(cpu) {
25199 int node = early_cpu_to_node(cpu);
25200 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25201 {
25202 #ifdef CONFIG_X86_32
25203 struct desc_struct gdt;
25204 + unsigned long base = per_cpu_offset(cpu);
25205
25206 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25207 - 0x2 | DESCTYPE_S, 0x8);
25208 - gdt.s = 1;
25209 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25210 + 0x83 | DESCTYPE_S, 0xC);
25211 write_gdt_entry(get_cpu_gdt_table(cpu),
25212 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25213 #endif
25214 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25215 /* alrighty, percpu areas up and running */
25216 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25217 for_each_possible_cpu(cpu) {
25218 +#ifdef CONFIG_CC_STACKPROTECTOR
25219 +#ifdef CONFIG_X86_32
25220 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25221 +#endif
25222 +#endif
25223 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25224 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25225 per_cpu(cpu_number, cpu) = cpu;
25226 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25227 */
25228 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25229 #endif
25230 +#ifdef CONFIG_CC_STACKPROTECTOR
25231 +#ifdef CONFIG_X86_32
25232 + if (!cpu)
25233 + per_cpu(stack_canary.canary, cpu) = canary;
25234 +#endif
25235 +#endif
25236 /*
25237 * Up to this point, the boot CPU has been using .init.data
25238 * area. Reload any changed state for the boot CPU.
25239 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25240 index d859eea..44e17c4 100644
25241 --- a/arch/x86/kernel/signal.c
25242 +++ b/arch/x86/kernel/signal.c
25243 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25244 * Align the stack pointer according to the i386 ABI,
25245 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25246 */
25247 - sp = ((sp + 4) & -16ul) - 4;
25248 + sp = ((sp - 12) & -16ul) - 4;
25249 #else /* !CONFIG_X86_32 */
25250 sp = round_down(sp, 16) - 8;
25251 #endif
25252 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25253 }
25254
25255 if (current->mm->context.vdso)
25256 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25257 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25258 else
25259 - restorer = &frame->retcode;
25260 + restorer = (void __user *)&frame->retcode;
25261 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25262 restorer = ksig->ka.sa.sa_restorer;
25263
25264 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25265 * reasons and because gdb uses it as a signature to notice
25266 * signal handler stack frames.
25267 */
25268 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25269 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25270
25271 if (err)
25272 return -EFAULT;
25273 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25274 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25275
25276 /* Set up to return from userspace. */
25277 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25278 + if (current->mm->context.vdso)
25279 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25280 + else
25281 + restorer = (void __user *)&frame->retcode;
25282 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25283 restorer = ksig->ka.sa.sa_restorer;
25284 put_user_ex(restorer, &frame->pretcode);
25285 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25286 * reasons and because gdb uses it as a signature to notice
25287 * signal handler stack frames.
25288 */
25289 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25290 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25291 } put_user_catch(err);
25292
25293 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25294 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25295 {
25296 int usig = signr_convert(ksig->sig);
25297 sigset_t *set = sigmask_to_save();
25298 - compat_sigset_t *cset = (compat_sigset_t *) set;
25299 + sigset_t sigcopy;
25300 + compat_sigset_t *cset;
25301 +
25302 + sigcopy = *set;
25303 +
25304 + cset = (compat_sigset_t *) &sigcopy;
25305
25306 /* Set up the stack frame */
25307 if (is_ia32_frame()) {
25308 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25309 } else if (is_x32_frame()) {
25310 return x32_setup_rt_frame(ksig, cset, regs);
25311 } else {
25312 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25313 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25314 }
25315 }
25316
25317 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25318 index cdaa347..f5af55d 100644
25319 --- a/arch/x86/kernel/smp.c
25320 +++ b/arch/x86/kernel/smp.c
25321 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25322
25323 __setup("nonmi_ipi", nonmi_ipi_setup);
25324
25325 -struct smp_ops smp_ops = {
25326 +struct smp_ops smp_ops __read_only = {
25327 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25328 .smp_prepare_cpus = native_smp_prepare_cpus,
25329 .smp_cpus_done = native_smp_cpus_done,
25330 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25331 index aecc98a..0244a53 100644
25332 --- a/arch/x86/kernel/smpboot.c
25333 +++ b/arch/x86/kernel/smpboot.c
25334 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25335
25336 enable_start_cpu0 = 0;
25337
25338 -#ifdef CONFIG_X86_32
25339 - /* switch away from the initial page table */
25340 - load_cr3(swapper_pg_dir);
25341 - __flush_tlb_all();
25342 -#endif
25343 -
25344 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25345 barrier();
25346 +
25347 + /* switch away from the initial page table */
25348 +#ifdef CONFIG_PAX_PER_CPU_PGD
25349 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25350 + __flush_tlb_all();
25351 +#elif defined(CONFIG_X86_32)
25352 + load_cr3(swapper_pg_dir);
25353 + __flush_tlb_all();
25354 +#endif
25355 +
25356 /*
25357 * Check TSC synchronization with the BP:
25358 */
25359 @@ -748,6 +752,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25360 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25361 (THREAD_SIZE + task_stack_page(idle))) - 1);
25362 per_cpu(current_task, cpu) = idle;
25363 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25364
25365 #ifdef CONFIG_X86_32
25366 /* Stack for startup_32 can be just as for start_secondary onwards */
25367 @@ -755,11 +760,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25368 #else
25369 clear_tsk_thread_flag(idle, TIF_FORK);
25370 initial_gs = per_cpu_offset(cpu);
25371 - per_cpu(kernel_stack, cpu) =
25372 - (unsigned long)task_stack_page(idle) -
25373 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25374 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25375 #endif
25376 +
25377 + pax_open_kernel();
25378 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25379 + pax_close_kernel();
25380 +
25381 initial_code = (unsigned long)start_secondary;
25382 stack_start = idle->thread.sp;
25383
25384 @@ -908,6 +915,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25385 /* the FPU context is blank, nobody can own it */
25386 __cpu_disable_lazy_restore(cpu);
25387
25388 +#ifdef CONFIG_PAX_PER_CPU_PGD
25389 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25390 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25391 + KERNEL_PGD_PTRS);
25392 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25393 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25394 + KERNEL_PGD_PTRS);
25395 +#endif
25396 +
25397 err = do_boot_cpu(apicid, cpu, tidle);
25398 if (err) {
25399 pr_debug("do_boot_cpu failed %d\n", err);
25400 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25401 index 9b4d51d..5d28b58 100644
25402 --- a/arch/x86/kernel/step.c
25403 +++ b/arch/x86/kernel/step.c
25404 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25405 struct desc_struct *desc;
25406 unsigned long base;
25407
25408 - seg &= ~7UL;
25409 + seg >>= 3;
25410
25411 mutex_lock(&child->mm->context.lock);
25412 - if (unlikely((seg >> 3) >= child->mm->context.size))
25413 + if (unlikely(seg >= child->mm->context.size))
25414 addr = -1L; /* bogus selector, access would fault */
25415 else {
25416 desc = child->mm->context.ldt + seg;
25417 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25418 addr += base;
25419 }
25420 mutex_unlock(&child->mm->context.lock);
25421 - }
25422 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25423 + addr = ktla_ktva(addr);
25424
25425 return addr;
25426 }
25427 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25428 unsigned char opcode[15];
25429 unsigned long addr = convert_ip_to_linear(child, regs);
25430
25431 + if (addr == -EINVAL)
25432 + return 0;
25433 +
25434 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25435 for (i = 0; i < copied; i++) {
25436 switch (opcode[i]) {
25437 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25438 new file mode 100644
25439 index 0000000..5877189
25440 --- /dev/null
25441 +++ b/arch/x86/kernel/sys_i386_32.c
25442 @@ -0,0 +1,189 @@
25443 +/*
25444 + * This file contains various random system calls that
25445 + * have a non-standard calling sequence on the Linux/i386
25446 + * platform.
25447 + */
25448 +
25449 +#include <linux/errno.h>
25450 +#include <linux/sched.h>
25451 +#include <linux/mm.h>
25452 +#include <linux/fs.h>
25453 +#include <linux/smp.h>
25454 +#include <linux/sem.h>
25455 +#include <linux/msg.h>
25456 +#include <linux/shm.h>
25457 +#include <linux/stat.h>
25458 +#include <linux/syscalls.h>
25459 +#include <linux/mman.h>
25460 +#include <linux/file.h>
25461 +#include <linux/utsname.h>
25462 +#include <linux/ipc.h>
25463 +#include <linux/elf.h>
25464 +
25465 +#include <linux/uaccess.h>
25466 +#include <linux/unistd.h>
25467 +
25468 +#include <asm/syscalls.h>
25469 +
25470 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25471 +{
25472 + unsigned long pax_task_size = TASK_SIZE;
25473 +
25474 +#ifdef CONFIG_PAX_SEGMEXEC
25475 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25476 + pax_task_size = SEGMEXEC_TASK_SIZE;
25477 +#endif
25478 +
25479 + if (flags & MAP_FIXED)
25480 + if (len > pax_task_size || addr > pax_task_size - len)
25481 + return -EINVAL;
25482 +
25483 + return 0;
25484 +}
25485 +
25486 +/*
25487 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25488 + */
25489 +static unsigned long get_align_mask(void)
25490 +{
25491 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25492 + return 0;
25493 +
25494 + if (!(current->flags & PF_RANDOMIZE))
25495 + return 0;
25496 +
25497 + return va_align.mask;
25498 +}
25499 +
25500 +unsigned long
25501 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25502 + unsigned long len, unsigned long pgoff, unsigned long flags)
25503 +{
25504 + struct mm_struct *mm = current->mm;
25505 + struct vm_area_struct *vma;
25506 + unsigned long pax_task_size = TASK_SIZE;
25507 + struct vm_unmapped_area_info info;
25508 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25509 +
25510 +#ifdef CONFIG_PAX_SEGMEXEC
25511 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25512 + pax_task_size = SEGMEXEC_TASK_SIZE;
25513 +#endif
25514 +
25515 + pax_task_size -= PAGE_SIZE;
25516 +
25517 + if (len > pax_task_size)
25518 + return -ENOMEM;
25519 +
25520 + if (flags & MAP_FIXED)
25521 + return addr;
25522 +
25523 +#ifdef CONFIG_PAX_RANDMMAP
25524 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25525 +#endif
25526 +
25527 + if (addr) {
25528 + addr = PAGE_ALIGN(addr);
25529 + if (pax_task_size - len >= addr) {
25530 + vma = find_vma(mm, addr);
25531 + if (check_heap_stack_gap(vma, addr, len, offset))
25532 + return addr;
25533 + }
25534 + }
25535 +
25536 + info.flags = 0;
25537 + info.length = len;
25538 + info.align_mask = filp ? get_align_mask() : 0;
25539 + info.align_offset = pgoff << PAGE_SHIFT;
25540 + info.threadstack_offset = offset;
25541 +
25542 +#ifdef CONFIG_PAX_PAGEEXEC
25543 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25544 + info.low_limit = 0x00110000UL;
25545 + info.high_limit = mm->start_code;
25546 +
25547 +#ifdef CONFIG_PAX_RANDMMAP
25548 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25549 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25550 +#endif
25551 +
25552 + if (info.low_limit < info.high_limit) {
25553 + addr = vm_unmapped_area(&info);
25554 + if (!IS_ERR_VALUE(addr))
25555 + return addr;
25556 + }
25557 + } else
25558 +#endif
25559 +
25560 + info.low_limit = mm->mmap_base;
25561 + info.high_limit = pax_task_size;
25562 +
25563 + return vm_unmapped_area(&info);
25564 +}
25565 +
25566 +unsigned long
25567 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25568 + const unsigned long len, const unsigned long pgoff,
25569 + const unsigned long flags)
25570 +{
25571 + struct vm_area_struct *vma;
25572 + struct mm_struct *mm = current->mm;
25573 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25574 + struct vm_unmapped_area_info info;
25575 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25576 +
25577 +#ifdef CONFIG_PAX_SEGMEXEC
25578 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25579 + pax_task_size = SEGMEXEC_TASK_SIZE;
25580 +#endif
25581 +
25582 + pax_task_size -= PAGE_SIZE;
25583 +
25584 + /* requested length too big for entire address space */
25585 + if (len > pax_task_size)
25586 + return -ENOMEM;
25587 +
25588 + if (flags & MAP_FIXED)
25589 + return addr;
25590 +
25591 +#ifdef CONFIG_PAX_PAGEEXEC
25592 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25593 + goto bottomup;
25594 +#endif
25595 +
25596 +#ifdef CONFIG_PAX_RANDMMAP
25597 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25598 +#endif
25599 +
25600 + /* requesting a specific address */
25601 + if (addr) {
25602 + addr = PAGE_ALIGN(addr);
25603 + if (pax_task_size - len >= addr) {
25604 + vma = find_vma(mm, addr);
25605 + if (check_heap_stack_gap(vma, addr, len, offset))
25606 + return addr;
25607 + }
25608 + }
25609 +
25610 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25611 + info.length = len;
25612 + info.low_limit = PAGE_SIZE;
25613 + info.high_limit = mm->mmap_base;
25614 + info.align_mask = filp ? get_align_mask() : 0;
25615 + info.align_offset = pgoff << PAGE_SHIFT;
25616 + info.threadstack_offset = offset;
25617 +
25618 + addr = vm_unmapped_area(&info);
25619 + if (!(addr & ~PAGE_MASK))
25620 + return addr;
25621 + VM_BUG_ON(addr != -ENOMEM);
25622 +
25623 +bottomup:
25624 + /*
25625 + * A failed mmap() very likely causes application failure,
25626 + * so fall back to the bottom-up function here. This scenario
25627 + * can happen with large stack limits and large mmap()
25628 + * allocations.
25629 + */
25630 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25631 +}
25632 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25633 index 30277e2..5664a29 100644
25634 --- a/arch/x86/kernel/sys_x86_64.c
25635 +++ b/arch/x86/kernel/sys_x86_64.c
25636 @@ -81,8 +81,8 @@ out:
25637 return error;
25638 }
25639
25640 -static void find_start_end(unsigned long flags, unsigned long *begin,
25641 - unsigned long *end)
25642 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25643 + unsigned long *begin, unsigned long *end)
25644 {
25645 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25646 unsigned long new_begin;
25647 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25648 *begin = new_begin;
25649 }
25650 } else {
25651 - *begin = current->mm->mmap_legacy_base;
25652 + *begin = mm->mmap_legacy_base;
25653 *end = TASK_SIZE;
25654 }
25655 }
25656 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25657 struct vm_area_struct *vma;
25658 struct vm_unmapped_area_info info;
25659 unsigned long begin, end;
25660 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25661
25662 if (flags & MAP_FIXED)
25663 return addr;
25664
25665 - find_start_end(flags, &begin, &end);
25666 + find_start_end(mm, flags, &begin, &end);
25667
25668 if (len > end)
25669 return -ENOMEM;
25670
25671 +#ifdef CONFIG_PAX_RANDMMAP
25672 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25673 +#endif
25674 +
25675 if (addr) {
25676 addr = PAGE_ALIGN(addr);
25677 vma = find_vma(mm, addr);
25678 - if (end - len >= addr &&
25679 - (!vma || addr + len <= vma->vm_start))
25680 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25681 return addr;
25682 }
25683
25684 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25685 info.high_limit = end;
25686 info.align_mask = filp ? get_align_mask() : 0;
25687 info.align_offset = pgoff << PAGE_SHIFT;
25688 + info.threadstack_offset = offset;
25689 return vm_unmapped_area(&info);
25690 }
25691
25692 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25693 struct mm_struct *mm = current->mm;
25694 unsigned long addr = addr0;
25695 struct vm_unmapped_area_info info;
25696 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25697
25698 /* requested length too big for entire address space */
25699 if (len > TASK_SIZE)
25700 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25701 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25702 goto bottomup;
25703
25704 +#ifdef CONFIG_PAX_RANDMMAP
25705 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25706 +#endif
25707 +
25708 /* requesting a specific address */
25709 if (addr) {
25710 addr = PAGE_ALIGN(addr);
25711 vma = find_vma(mm, addr);
25712 - if (TASK_SIZE - len >= addr &&
25713 - (!vma || addr + len <= vma->vm_start))
25714 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25715 return addr;
25716 }
25717
25718 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25719 info.high_limit = mm->mmap_base;
25720 info.align_mask = filp ? get_align_mask() : 0;
25721 info.align_offset = pgoff << PAGE_SHIFT;
25722 + info.threadstack_offset = offset;
25723 addr = vm_unmapped_area(&info);
25724 if (!(addr & ~PAGE_MASK))
25725 return addr;
25726 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25727 index addf7b5..f960685 100644
25728 --- a/arch/x86/kernel/tboot.c
25729 +++ b/arch/x86/kernel/tboot.c
25730 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25731
25732 void tboot_shutdown(u32 shutdown_type)
25733 {
25734 - void (*shutdown)(void);
25735 + void (* __noreturn shutdown)(void);
25736
25737 if (!tboot_enabled())
25738 return;
25739 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25740
25741 switch_to_tboot_pt();
25742
25743 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25744 + shutdown = (void *)tboot->shutdown_entry;
25745 shutdown();
25746
25747 /* should not reach here */
25748 @@ -301,7 +301,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
25749 return 0;
25750 }
25751
25752 -static atomic_t ap_wfs_count;
25753 +static atomic_unchecked_t ap_wfs_count;
25754
25755 static int tboot_wait_for_aps(int num_aps)
25756 {
25757 @@ -325,9 +325,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25758 {
25759 switch (action) {
25760 case CPU_DYING:
25761 - atomic_inc(&ap_wfs_count);
25762 + atomic_inc_unchecked(&ap_wfs_count);
25763 if (num_online_cpus() == 1)
25764 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25765 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25766 return NOTIFY_BAD;
25767 break;
25768 }
25769 @@ -413,7 +413,7 @@ static __init int tboot_late_init(void)
25770
25771 tboot_create_trampoline();
25772
25773 - atomic_set(&ap_wfs_count, 0);
25774 + atomic_set_unchecked(&ap_wfs_count, 0);
25775 register_hotcpu_notifier(&tboot_cpu_notifier);
25776
25777 #ifdef CONFIG_DEBUG_FS
25778 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25779 index 24d3c91..d06b473 100644
25780 --- a/arch/x86/kernel/time.c
25781 +++ b/arch/x86/kernel/time.c
25782 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25783 {
25784 unsigned long pc = instruction_pointer(regs);
25785
25786 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25787 + if (!user_mode(regs) && in_lock_functions(pc)) {
25788 #ifdef CONFIG_FRAME_POINTER
25789 - return *(unsigned long *)(regs->bp + sizeof(long));
25790 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25791 #else
25792 unsigned long *sp =
25793 (unsigned long *)kernel_stack_pointer(regs);
25794 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25795 * or above a saved flags. Eflags has bits 22-31 zero,
25796 * kernel addresses don't.
25797 */
25798 +
25799 +#ifdef CONFIG_PAX_KERNEXEC
25800 + return ktla_ktva(sp[0]);
25801 +#else
25802 if (sp[0] >> 22)
25803 return sp[0];
25804 if (sp[1] >> 22)
25805 return sp[1];
25806 #endif
25807 +
25808 +#endif
25809 }
25810 return pc;
25811 }
25812 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25813 index f7fec09..9991981 100644
25814 --- a/arch/x86/kernel/tls.c
25815 +++ b/arch/x86/kernel/tls.c
25816 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25817 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25818 return -EINVAL;
25819
25820 +#ifdef CONFIG_PAX_SEGMEXEC
25821 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25822 + return -EINVAL;
25823 +#endif
25824 +
25825 set_tls_desc(p, idx, &info, 1);
25826
25827 return 0;
25828 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25829
25830 if (kbuf)
25831 info = kbuf;
25832 - else if (__copy_from_user(infobuf, ubuf, count))
25833 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25834 return -EFAULT;
25835 else
25836 info = infobuf;
25837 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25838 index 1c113db..287b42e 100644
25839 --- a/arch/x86/kernel/tracepoint.c
25840 +++ b/arch/x86/kernel/tracepoint.c
25841 @@ -9,11 +9,11 @@
25842 #include <linux/atomic.h>
25843
25844 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25845 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25846 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25847 (unsigned long) trace_idt_table };
25848
25849 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25850 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25851 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25852
25853 static int trace_irq_vector_refcount;
25854 static DEFINE_MUTEX(irq_vector_mutex);
25855 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25856 index 1b23a1c..910de0d 100644
25857 --- a/arch/x86/kernel/traps.c
25858 +++ b/arch/x86/kernel/traps.c
25859 @@ -65,7 +65,7 @@
25860 #include <asm/proto.h>
25861
25862 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25863 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25864 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25865 #else
25866 #include <asm/processor-flags.h>
25867 #include <asm/setup.h>
25868 @@ -74,7 +74,7 @@ asmlinkage int system_call(void);
25869 #endif
25870
25871 /* Must be page-aligned because the real IDT is used in a fixmap. */
25872 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25873 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25874
25875 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25876 EXPORT_SYMBOL_GPL(used_vectors);
25877 @@ -106,11 +106,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25878 }
25879
25880 static int __kprobes
25881 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25882 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25883 struct pt_regs *regs, long error_code)
25884 {
25885 #ifdef CONFIG_X86_32
25886 - if (regs->flags & X86_VM_MASK) {
25887 + if (v8086_mode(regs)) {
25888 /*
25889 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25890 * On nmi (interrupt 2), do_trap should not be called.
25891 @@ -123,12 +123,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25892 return -1;
25893 }
25894 #endif
25895 - if (!user_mode(regs)) {
25896 + if (!user_mode_novm(regs)) {
25897 if (!fixup_exception(regs)) {
25898 tsk->thread.error_code = error_code;
25899 tsk->thread.trap_nr = trapnr;
25900 +
25901 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25902 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25903 + str = "PAX: suspicious stack segment fault";
25904 +#endif
25905 +
25906 die(str, regs, error_code);
25907 }
25908 +
25909 +#ifdef CONFIG_PAX_REFCOUNT
25910 + if (trapnr == 4)
25911 + pax_report_refcount_overflow(regs);
25912 +#endif
25913 +
25914 return 0;
25915 }
25916
25917 @@ -136,7 +148,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25918 }
25919
25920 static void __kprobes
25921 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25922 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25923 long error_code, siginfo_t *info)
25924 {
25925 struct task_struct *tsk = current;
25926 @@ -160,7 +172,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25927 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25928 printk_ratelimit()) {
25929 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25930 - tsk->comm, tsk->pid, str,
25931 + tsk->comm, task_pid_nr(tsk), str,
25932 regs->ip, regs->sp, error_code);
25933 print_vma_addr(" in ", regs->ip);
25934 pr_cont("\n");
25935 @@ -276,7 +288,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25936 conditional_sti(regs);
25937
25938 #ifdef CONFIG_X86_32
25939 - if (regs->flags & X86_VM_MASK) {
25940 + if (v8086_mode(regs)) {
25941 local_irq_enable();
25942 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25943 goto exit;
25944 @@ -284,18 +296,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25945 #endif
25946
25947 tsk = current;
25948 - if (!user_mode(regs)) {
25949 + if (!user_mode_novm(regs)) {
25950 if (fixup_exception(regs))
25951 goto exit;
25952
25953 tsk->thread.error_code = error_code;
25954 tsk->thread.trap_nr = X86_TRAP_GP;
25955 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25956 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25957 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25958 +
25959 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25960 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25961 + die("PAX: suspicious general protection fault", regs, error_code);
25962 + else
25963 +#endif
25964 +
25965 die("general protection fault", regs, error_code);
25966 + }
25967 goto exit;
25968 }
25969
25970 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25971 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25972 + struct mm_struct *mm = tsk->mm;
25973 + unsigned long limit;
25974 +
25975 + down_write(&mm->mmap_sem);
25976 + limit = mm->context.user_cs_limit;
25977 + if (limit < TASK_SIZE) {
25978 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
25979 + up_write(&mm->mmap_sem);
25980 + return;
25981 + }
25982 + up_write(&mm->mmap_sem);
25983 + }
25984 +#endif
25985 +
25986 tsk->thread.error_code = error_code;
25987 tsk->thread.trap_nr = X86_TRAP_GP;
25988
25989 @@ -453,7 +489,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25990 /* It's safe to allow irq's after DR6 has been saved */
25991 preempt_conditional_sti(regs);
25992
25993 - if (regs->flags & X86_VM_MASK) {
25994 + if (v8086_mode(regs)) {
25995 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
25996 X86_TRAP_DB);
25997 preempt_conditional_cli(regs);
25998 @@ -468,7 +504,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25999 * We already checked v86 mode above, so we can check for kernel mode
26000 * by just checking the CPL of CS.
26001 */
26002 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26003 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26004 tsk->thread.debugreg6 &= ~DR_STEP;
26005 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26006 regs->flags &= ~X86_EFLAGS_TF;
26007 @@ -500,7 +536,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26008 return;
26009 conditional_sti(regs);
26010
26011 - if (!user_mode_vm(regs))
26012 + if (!user_mode(regs))
26013 {
26014 if (!fixup_exception(regs)) {
26015 task->thread.error_code = error_code;
26016 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26017 index 2ed8459..7cf329f 100644
26018 --- a/arch/x86/kernel/uprobes.c
26019 +++ b/arch/x86/kernel/uprobes.c
26020 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26021 int ret = NOTIFY_DONE;
26022
26023 /* We are only interested in userspace traps */
26024 - if (regs && !user_mode_vm(regs))
26025 + if (regs && !user_mode(regs))
26026 return NOTIFY_DONE;
26027
26028 switch (val) {
26029 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26030
26031 if (ncopied != rasize) {
26032 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26033 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26034 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26035
26036 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26037 }
26038 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26039 index b9242ba..50c5edd 100644
26040 --- a/arch/x86/kernel/verify_cpu.S
26041 +++ b/arch/x86/kernel/verify_cpu.S
26042 @@ -20,6 +20,7 @@
26043 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26044 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26045 * arch/x86/kernel/head_32.S: processor startup
26046 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26047 *
26048 * verify_cpu, returns the status of longmode and SSE in register %eax.
26049 * 0: Success 1: Failure
26050 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26051 index e8edcf5..27f9344 100644
26052 --- a/arch/x86/kernel/vm86_32.c
26053 +++ b/arch/x86/kernel/vm86_32.c
26054 @@ -44,6 +44,7 @@
26055 #include <linux/ptrace.h>
26056 #include <linux/audit.h>
26057 #include <linux/stddef.h>
26058 +#include <linux/grsecurity.h>
26059
26060 #include <asm/uaccess.h>
26061 #include <asm/io.h>
26062 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26063 do_exit(SIGSEGV);
26064 }
26065
26066 - tss = &per_cpu(init_tss, get_cpu());
26067 + tss = init_tss + get_cpu();
26068 current->thread.sp0 = current->thread.saved_sp0;
26069 current->thread.sysenter_cs = __KERNEL_CS;
26070 load_sp0(tss, &current->thread);
26071 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26072
26073 if (tsk->thread.saved_sp0)
26074 return -EPERM;
26075 +
26076 +#ifdef CONFIG_GRKERNSEC_VM86
26077 + if (!capable(CAP_SYS_RAWIO)) {
26078 + gr_handle_vm86();
26079 + return -EPERM;
26080 + }
26081 +#endif
26082 +
26083 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26084 offsetof(struct kernel_vm86_struct, vm86plus) -
26085 sizeof(info.regs));
26086 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26087 int tmp;
26088 struct vm86plus_struct __user *v86;
26089
26090 +#ifdef CONFIG_GRKERNSEC_VM86
26091 + if (!capable(CAP_SYS_RAWIO)) {
26092 + gr_handle_vm86();
26093 + return -EPERM;
26094 + }
26095 +#endif
26096 +
26097 tsk = current;
26098 switch (cmd) {
26099 case VM86_REQUEST_IRQ:
26100 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26101 tsk->thread.saved_fs = info->regs32->fs;
26102 tsk->thread.saved_gs = get_user_gs(info->regs32);
26103
26104 - tss = &per_cpu(init_tss, get_cpu());
26105 + tss = init_tss + get_cpu();
26106 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26107 if (cpu_has_sep)
26108 tsk->thread.sysenter_cs = 0;
26109 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26110 goto cannot_handle;
26111 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26112 goto cannot_handle;
26113 - intr_ptr = (unsigned long __user *) (i << 2);
26114 + intr_ptr = (__force unsigned long __user *) (i << 2);
26115 if (get_user(segoffs, intr_ptr))
26116 goto cannot_handle;
26117 if ((segoffs >> 16) == BIOSSEG)
26118 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26119 index 10c4f30..65408b9 100644
26120 --- a/arch/x86/kernel/vmlinux.lds.S
26121 +++ b/arch/x86/kernel/vmlinux.lds.S
26122 @@ -26,6 +26,13 @@
26123 #include <asm/page_types.h>
26124 #include <asm/cache.h>
26125 #include <asm/boot.h>
26126 +#include <asm/segment.h>
26127 +
26128 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26129 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26130 +#else
26131 +#define __KERNEL_TEXT_OFFSET 0
26132 +#endif
26133
26134 #undef i386 /* in case the preprocessor is a 32bit one */
26135
26136 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26137
26138 PHDRS {
26139 text PT_LOAD FLAGS(5); /* R_E */
26140 +#ifdef CONFIG_X86_32
26141 + module PT_LOAD FLAGS(5); /* R_E */
26142 +#endif
26143 +#ifdef CONFIG_XEN
26144 + rodata PT_LOAD FLAGS(5); /* R_E */
26145 +#else
26146 + rodata PT_LOAD FLAGS(4); /* R__ */
26147 +#endif
26148 data PT_LOAD FLAGS(6); /* RW_ */
26149 -#ifdef CONFIG_X86_64
26150 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26151 #ifdef CONFIG_SMP
26152 percpu PT_LOAD FLAGS(6); /* RW_ */
26153 #endif
26154 + text.init PT_LOAD FLAGS(5); /* R_E */
26155 + text.exit PT_LOAD FLAGS(5); /* R_E */
26156 init PT_LOAD FLAGS(7); /* RWE */
26157 -#endif
26158 note PT_NOTE FLAGS(0); /* ___ */
26159 }
26160
26161 SECTIONS
26162 {
26163 #ifdef CONFIG_X86_32
26164 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26165 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26166 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26167 #else
26168 - . = __START_KERNEL;
26169 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26170 + . = __START_KERNEL;
26171 #endif
26172
26173 /* Text and read-only data */
26174 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26175 - _text = .;
26176 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26177 /* bootstrapping code */
26178 +#ifdef CONFIG_X86_32
26179 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26180 +#else
26181 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26182 +#endif
26183 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26184 + _text = .;
26185 HEAD_TEXT
26186 . = ALIGN(8);
26187 _stext = .;
26188 @@ -104,13 +124,47 @@ SECTIONS
26189 IRQENTRY_TEXT
26190 *(.fixup)
26191 *(.gnu.warning)
26192 - /* End of text section */
26193 - _etext = .;
26194 } :text = 0x9090
26195
26196 - NOTES :text :note
26197 + . += __KERNEL_TEXT_OFFSET;
26198
26199 - EXCEPTION_TABLE(16) :text = 0x9090
26200 +#ifdef CONFIG_X86_32
26201 + . = ALIGN(PAGE_SIZE);
26202 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26203 +
26204 +#ifdef CONFIG_PAX_KERNEXEC
26205 + MODULES_EXEC_VADDR = .;
26206 + BYTE(0)
26207 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26208 + . = ALIGN(HPAGE_SIZE) - 1;
26209 + MODULES_EXEC_END = .;
26210 +#endif
26211 +
26212 + } :module
26213 +#endif
26214 +
26215 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26216 + /* End of text section */
26217 + BYTE(0)
26218 + _etext = . - __KERNEL_TEXT_OFFSET;
26219 + }
26220 +
26221 +#ifdef CONFIG_X86_32
26222 + . = ALIGN(PAGE_SIZE);
26223 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26224 + . = ALIGN(PAGE_SIZE);
26225 + *(.empty_zero_page)
26226 + *(.initial_pg_fixmap)
26227 + *(.initial_pg_pmd)
26228 + *(.initial_page_table)
26229 + *(.swapper_pg_dir)
26230 + } :rodata
26231 +#endif
26232 +
26233 + . = ALIGN(PAGE_SIZE);
26234 + NOTES :rodata :note
26235 +
26236 + EXCEPTION_TABLE(16) :rodata
26237
26238 #if defined(CONFIG_DEBUG_RODATA)
26239 /* .text should occupy whole number of pages */
26240 @@ -122,16 +176,20 @@ SECTIONS
26241
26242 /* Data */
26243 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26244 +
26245 +#ifdef CONFIG_PAX_KERNEXEC
26246 + . = ALIGN(HPAGE_SIZE);
26247 +#else
26248 + . = ALIGN(PAGE_SIZE);
26249 +#endif
26250 +
26251 /* Start of data section */
26252 _sdata = .;
26253
26254 /* init_task */
26255 INIT_TASK_DATA(THREAD_SIZE)
26256
26257 -#ifdef CONFIG_X86_32
26258 - /* 32 bit has nosave before _edata */
26259 NOSAVE_DATA
26260 -#endif
26261
26262 PAGE_ALIGNED_DATA(PAGE_SIZE)
26263
26264 @@ -172,12 +230,19 @@ SECTIONS
26265 #endif /* CONFIG_X86_64 */
26266
26267 /* Init code and data - will be freed after init */
26268 - . = ALIGN(PAGE_SIZE);
26269 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26270 + BYTE(0)
26271 +
26272 +#ifdef CONFIG_PAX_KERNEXEC
26273 + . = ALIGN(HPAGE_SIZE);
26274 +#else
26275 + . = ALIGN(PAGE_SIZE);
26276 +#endif
26277 +
26278 __init_begin = .; /* paired with __init_end */
26279 - }
26280 + } :init.begin
26281
26282 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26283 +#ifdef CONFIG_SMP
26284 /*
26285 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26286 * output PHDR, so the next output section - .init.text - should
26287 @@ -186,12 +251,27 @@ SECTIONS
26288 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26289 #endif
26290
26291 - INIT_TEXT_SECTION(PAGE_SIZE)
26292 -#ifdef CONFIG_X86_64
26293 - :init
26294 -#endif
26295 + . = ALIGN(PAGE_SIZE);
26296 + init_begin = .;
26297 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26298 + VMLINUX_SYMBOL(_sinittext) = .;
26299 + INIT_TEXT
26300 + VMLINUX_SYMBOL(_einittext) = .;
26301 + . = ALIGN(PAGE_SIZE);
26302 + } :text.init
26303
26304 - INIT_DATA_SECTION(16)
26305 + /*
26306 + * .exit.text is discard at runtime, not link time, to deal with
26307 + * references from .altinstructions and .eh_frame
26308 + */
26309 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26310 + EXIT_TEXT
26311 + . = ALIGN(16);
26312 + } :text.exit
26313 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26314 +
26315 + . = ALIGN(PAGE_SIZE);
26316 + INIT_DATA_SECTION(16) :init
26317
26318 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26319 __x86_cpu_dev_start = .;
26320 @@ -253,19 +333,12 @@ SECTIONS
26321 }
26322
26323 . = ALIGN(8);
26324 - /*
26325 - * .exit.text is discard at runtime, not link time, to deal with
26326 - * references from .altinstructions and .eh_frame
26327 - */
26328 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26329 - EXIT_TEXT
26330 - }
26331
26332 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26333 EXIT_DATA
26334 }
26335
26336 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26337 +#ifndef CONFIG_SMP
26338 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26339 #endif
26340
26341 @@ -284,16 +357,10 @@ SECTIONS
26342 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26343 __smp_locks = .;
26344 *(.smp_locks)
26345 - . = ALIGN(PAGE_SIZE);
26346 __smp_locks_end = .;
26347 + . = ALIGN(PAGE_SIZE);
26348 }
26349
26350 -#ifdef CONFIG_X86_64
26351 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26352 - NOSAVE_DATA
26353 - }
26354 -#endif
26355 -
26356 /* BSS */
26357 . = ALIGN(PAGE_SIZE);
26358 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26359 @@ -309,6 +376,7 @@ SECTIONS
26360 __brk_base = .;
26361 . += 64 * 1024; /* 64k alignment slop space */
26362 *(.brk_reservation) /* areas brk users have reserved */
26363 + . = ALIGN(HPAGE_SIZE);
26364 __brk_limit = .;
26365 }
26366
26367 @@ -335,13 +403,12 @@ SECTIONS
26368 * for the boot processor.
26369 */
26370 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26371 -INIT_PER_CPU(gdt_page);
26372 INIT_PER_CPU(irq_stack_union);
26373
26374 /*
26375 * Build-time check on the image size:
26376 */
26377 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26378 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26379 "kernel image bigger than KERNEL_IMAGE_SIZE");
26380
26381 #ifdef CONFIG_SMP
26382 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26383 index 1f96f93..d5c8f7a 100644
26384 --- a/arch/x86/kernel/vsyscall_64.c
26385 +++ b/arch/x86/kernel/vsyscall_64.c
26386 @@ -56,15 +56,13 @@
26387 DEFINE_VVAR(int, vgetcpu_mode);
26388 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26389
26390 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26391 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26392
26393 static int __init vsyscall_setup(char *str)
26394 {
26395 if (str) {
26396 if (!strcmp("emulate", str))
26397 vsyscall_mode = EMULATE;
26398 - else if (!strcmp("native", str))
26399 - vsyscall_mode = NATIVE;
26400 else if (!strcmp("none", str))
26401 vsyscall_mode = NONE;
26402 else
26403 @@ -323,8 +321,7 @@ do_ret:
26404 return true;
26405
26406 sigsegv:
26407 - force_sig(SIGSEGV, current);
26408 - return true;
26409 + do_group_exit(SIGKILL);
26410 }
26411
26412 /*
26413 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26414 extern char __vvar_page;
26415 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26416
26417 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26418 - vsyscall_mode == NATIVE
26419 - ? PAGE_KERNEL_VSYSCALL
26420 - : PAGE_KERNEL_VVAR);
26421 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26422 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26423 (unsigned long)VSYSCALL_START);
26424
26425 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26426 index b014d94..e775258 100644
26427 --- a/arch/x86/kernel/x8664_ksyms_64.c
26428 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26429 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26430 EXPORT_SYMBOL(copy_user_generic_unrolled);
26431 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26432 EXPORT_SYMBOL(__copy_user_nocache);
26433 -EXPORT_SYMBOL(_copy_from_user);
26434 -EXPORT_SYMBOL(_copy_to_user);
26435
26436 EXPORT_SYMBOL(copy_page);
26437 EXPORT_SYMBOL(clear_page);
26438 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26439 #ifndef CONFIG_PARAVIRT
26440 EXPORT_SYMBOL(native_load_gs_index);
26441 #endif
26442 +
26443 +#ifdef CONFIG_PAX_PER_CPU_PGD
26444 +EXPORT_SYMBOL(cpu_pgd);
26445 +#endif
26446 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26447 index 5f24c71..1dadf09 100644
26448 --- a/arch/x86/kernel/x86_init.c
26449 +++ b/arch/x86/kernel/x86_init.c
26450 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26451 static void default_nmi_init(void) { };
26452 static int default_i8042_detect(void) { return 1; };
26453
26454 -struct x86_platform_ops x86_platform = {
26455 +struct x86_platform_ops x86_platform __read_only = {
26456 .calibrate_tsc = native_calibrate_tsc,
26457 .get_wallclock = mach_get_cmos_time,
26458 .set_wallclock = mach_set_rtc_mmss,
26459 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
26460 };
26461
26462 EXPORT_SYMBOL_GPL(x86_platform);
26463 -struct x86_msi_ops x86_msi = {
26464 +struct x86_msi_ops x86_msi __read_only = {
26465 .setup_msi_irqs = native_setup_msi_irqs,
26466 .compose_msi_msg = native_compose_msi_msg,
26467 .teardown_msi_irq = native_teardown_msi_irq,
26468 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
26469 .setup_hpet_msi = default_setup_hpet_msi,
26470 };
26471
26472 -struct x86_io_apic_ops x86_io_apic_ops = {
26473 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26474 .init = native_io_apic_init_mappings,
26475 .read = native_io_apic_read,
26476 .write = native_io_apic_write,
26477 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26478 index 422fd82..c3687ca 100644
26479 --- a/arch/x86/kernel/xsave.c
26480 +++ b/arch/x86/kernel/xsave.c
26481 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26482 {
26483 int err;
26484
26485 + buf = (struct xsave_struct __user *)____m(buf);
26486 if (use_xsave())
26487 err = xsave_user(buf);
26488 else if (use_fxsr())
26489 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26490 */
26491 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26492 {
26493 + buf = (void __user *)____m(buf);
26494 if (use_xsave()) {
26495 if ((unsigned long)buf % 64 || fx_only) {
26496 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26497 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26498 index a20ecb5..d0e2194 100644
26499 --- a/arch/x86/kvm/cpuid.c
26500 +++ b/arch/x86/kvm/cpuid.c
26501 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26502 struct kvm_cpuid2 *cpuid,
26503 struct kvm_cpuid_entry2 __user *entries)
26504 {
26505 - int r;
26506 + int r, i;
26507
26508 r = -E2BIG;
26509 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26510 goto out;
26511 r = -EFAULT;
26512 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26513 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26514 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26515 goto out;
26516 + for (i = 0; i < cpuid->nent; ++i) {
26517 + struct kvm_cpuid_entry2 cpuid_entry;
26518 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26519 + goto out;
26520 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26521 + }
26522 vcpu->arch.cpuid_nent = cpuid->nent;
26523 kvm_apic_set_version(vcpu);
26524 kvm_x86_ops->cpuid_update(vcpu);
26525 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26526 struct kvm_cpuid2 *cpuid,
26527 struct kvm_cpuid_entry2 __user *entries)
26528 {
26529 - int r;
26530 + int r, i;
26531
26532 r = -E2BIG;
26533 if (cpuid->nent < vcpu->arch.cpuid_nent)
26534 goto out;
26535 r = -EFAULT;
26536 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26537 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26538 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26539 goto out;
26540 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26541 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26542 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26543 + goto out;
26544 + }
26545 return 0;
26546
26547 out:
26548 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26549 index afc1124..3e431f2 100644
26550 --- a/arch/x86/kvm/lapic.c
26551 +++ b/arch/x86/kvm/lapic.c
26552 @@ -55,7 +55,7 @@
26553 #define APIC_BUS_CYCLE_NS 1
26554
26555 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26556 -#define apic_debug(fmt, arg...)
26557 +#define apic_debug(fmt, arg...) do {} while (0)
26558
26559 #define APIC_LVT_NUM 6
26560 /* 14 is the version for Xeon and Pentium 8.4.8*/
26561 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26562 index 7769699..c8aca4a7f 100644
26563 --- a/arch/x86/kvm/paging_tmpl.h
26564 +++ b/arch/x86/kvm/paging_tmpl.h
26565 @@ -208,7 +208,7 @@ retry_walk:
26566 if (unlikely(kvm_is_error_hva(host_addr)))
26567 goto error;
26568
26569 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26570 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26571 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26572 goto error;
26573 walker->ptep_user[walker->level - 1] = ptep_user;
26574 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26575 index c0bc803..6837a50 100644
26576 --- a/arch/x86/kvm/svm.c
26577 +++ b/arch/x86/kvm/svm.c
26578 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26579 int cpu = raw_smp_processor_id();
26580
26581 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26582 +
26583 + pax_open_kernel();
26584 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26585 + pax_close_kernel();
26586 +
26587 load_TR_desc();
26588 }
26589
26590 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26591 #endif
26592 #endif
26593
26594 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26595 + __set_fs(current_thread_info()->addr_limit);
26596 +#endif
26597 +
26598 reload_tss(vcpu);
26599
26600 local_irq_disable();
26601 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26602 index 064d0be..f5f758e 100644
26603 --- a/arch/x86/kvm/vmx.c
26604 +++ b/arch/x86/kvm/vmx.c
26605 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26606 #endif
26607 }
26608
26609 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26610 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26611 {
26612 vmcs_writel(field, vmcs_readl(field) & ~mask);
26613 }
26614
26615 -static void vmcs_set_bits(unsigned long field, u32 mask)
26616 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26617 {
26618 vmcs_writel(field, vmcs_readl(field) | mask);
26619 }
26620 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
26621 struct desc_struct *descs;
26622
26623 descs = (void *)gdt->address;
26624 +
26625 + pax_open_kernel();
26626 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26627 + pax_close_kernel();
26628 +
26629 load_TR_desc();
26630 }
26631
26632 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26633 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26634 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26635
26636 +#ifdef CONFIG_PAX_PER_CPU_PGD
26637 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26638 +#endif
26639 +
26640 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26641 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26642 vmx->loaded_vmcs->cpu = cpu;
26643 @@ -2940,8 +2948,11 @@ static __init int hardware_setup(void)
26644 if (!cpu_has_vmx_flexpriority())
26645 flexpriority_enabled = 0;
26646
26647 - if (!cpu_has_vmx_tpr_shadow())
26648 - kvm_x86_ops->update_cr8_intercept = NULL;
26649 + if (!cpu_has_vmx_tpr_shadow()) {
26650 + pax_open_kernel();
26651 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26652 + pax_close_kernel();
26653 + }
26654
26655 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26656 kvm_disable_largepages();
26657 @@ -2952,13 +2963,15 @@ static __init int hardware_setup(void)
26658 if (!cpu_has_vmx_apicv())
26659 enable_apicv = 0;
26660
26661 + pax_open_kernel();
26662 if (enable_apicv)
26663 - kvm_x86_ops->update_cr8_intercept = NULL;
26664 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26665 else {
26666 - kvm_x86_ops->hwapic_irr_update = NULL;
26667 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26668 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26669 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26670 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26671 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26672 }
26673 + pax_close_kernel();
26674
26675 if (nested)
26676 nested_vmx_setup_ctls_msrs();
26677 @@ -4081,7 +4094,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26678
26679 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26680 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26681 +
26682 +#ifndef CONFIG_PAX_PER_CPU_PGD
26683 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26684 +#endif
26685
26686 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26687 #ifdef CONFIG_X86_64
26688 @@ -4103,7 +4119,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26689 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26690 vmx->host_idt_base = dt.address;
26691
26692 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26693 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26694
26695 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26696 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26697 @@ -7039,6 +7055,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26698 "jmp 2f \n\t"
26699 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26700 "2: "
26701 +
26702 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26703 + "ljmp %[cs],$3f\n\t"
26704 + "3: "
26705 +#endif
26706 +
26707 /* Save guest registers, load host registers, keep flags */
26708 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26709 "pop %0 \n\t"
26710 @@ -7091,6 +7113,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26711 #endif
26712 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26713 [wordsize]"i"(sizeof(ulong))
26714 +
26715 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26716 + ,[cs]"i"(__KERNEL_CS)
26717 +#endif
26718 +
26719 : "cc", "memory"
26720 #ifdef CONFIG_X86_64
26721 , "rax", "rbx", "rdi", "rsi"
26722 @@ -7104,7 +7131,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26723 if (debugctlmsr)
26724 update_debugctlmsr(debugctlmsr);
26725
26726 -#ifndef CONFIG_X86_64
26727 +#ifdef CONFIG_X86_32
26728 /*
26729 * The sysexit path does not restore ds/es, so we must set them to
26730 * a reasonable value ourselves.
26731 @@ -7113,8 +7140,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26732 * may be executed in interrupt context, which saves and restore segments
26733 * around it, nullifying its effect.
26734 */
26735 - loadsegment(ds, __USER_DS);
26736 - loadsegment(es, __USER_DS);
26737 + loadsegment(ds, __KERNEL_DS);
26738 + loadsegment(es, __KERNEL_DS);
26739 + loadsegment(ss, __KERNEL_DS);
26740 +
26741 +#ifdef CONFIG_PAX_KERNEXEC
26742 + loadsegment(fs, __KERNEL_PERCPU);
26743 +#endif
26744 +
26745 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26746 + __set_fs(current_thread_info()->addr_limit);
26747 +#endif
26748 +
26749 #endif
26750
26751 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26752 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26753 index d21bce5..fdae9f1 100644
26754 --- a/arch/x86/kvm/x86.c
26755 +++ b/arch/x86/kvm/x86.c
26756 @@ -1766,8 +1766,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26757 {
26758 struct kvm *kvm = vcpu->kvm;
26759 int lm = is_long_mode(vcpu);
26760 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26761 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26762 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26763 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26764 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26765 : kvm->arch.xen_hvm_config.blob_size_32;
26766 u32 page_num = data & ~PAGE_MASK;
26767 @@ -2650,6 +2650,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26768 if (n < msr_list.nmsrs)
26769 goto out;
26770 r = -EFAULT;
26771 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26772 + goto out;
26773 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26774 num_msrs_to_save * sizeof(u32)))
26775 goto out;
26776 @@ -5344,7 +5346,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26777 };
26778 #endif
26779
26780 -int kvm_arch_init(void *opaque)
26781 +int kvm_arch_init(const void *opaque)
26782 {
26783 int r;
26784 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
26785 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26786 index 6a22c19..1763f04 100644
26787 --- a/arch/x86/lguest/boot.c
26788 +++ b/arch/x86/lguest/boot.c
26789 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26790 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26791 * Launcher to reboot us.
26792 */
26793 -static void lguest_restart(char *reason)
26794 +static __noreturn void lguest_restart(char *reason)
26795 {
26796 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26797 + BUG();
26798 }
26799
26800 /*G:050
26801 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26802 index 00933d5..3a64af9 100644
26803 --- a/arch/x86/lib/atomic64_386_32.S
26804 +++ b/arch/x86/lib/atomic64_386_32.S
26805 @@ -48,6 +48,10 @@ BEGIN(read)
26806 movl (v), %eax
26807 movl 4(v), %edx
26808 RET_ENDP
26809 +BEGIN(read_unchecked)
26810 + movl (v), %eax
26811 + movl 4(v), %edx
26812 +RET_ENDP
26813 #undef v
26814
26815 #define v %esi
26816 @@ -55,6 +59,10 @@ BEGIN(set)
26817 movl %ebx, (v)
26818 movl %ecx, 4(v)
26819 RET_ENDP
26820 +BEGIN(set_unchecked)
26821 + movl %ebx, (v)
26822 + movl %ecx, 4(v)
26823 +RET_ENDP
26824 #undef v
26825
26826 #define v %esi
26827 @@ -70,6 +78,20 @@ RET_ENDP
26828 BEGIN(add)
26829 addl %eax, (v)
26830 adcl %edx, 4(v)
26831 +
26832 +#ifdef CONFIG_PAX_REFCOUNT
26833 + jno 0f
26834 + subl %eax, (v)
26835 + sbbl %edx, 4(v)
26836 + int $4
26837 +0:
26838 + _ASM_EXTABLE(0b, 0b)
26839 +#endif
26840 +
26841 +RET_ENDP
26842 +BEGIN(add_unchecked)
26843 + addl %eax, (v)
26844 + adcl %edx, 4(v)
26845 RET_ENDP
26846 #undef v
26847
26848 @@ -77,6 +99,24 @@ RET_ENDP
26849 BEGIN(add_return)
26850 addl (v), %eax
26851 adcl 4(v), %edx
26852 +
26853 +#ifdef CONFIG_PAX_REFCOUNT
26854 + into
26855 +1234:
26856 + _ASM_EXTABLE(1234b, 2f)
26857 +#endif
26858 +
26859 + movl %eax, (v)
26860 + movl %edx, 4(v)
26861 +
26862 +#ifdef CONFIG_PAX_REFCOUNT
26863 +2:
26864 +#endif
26865 +
26866 +RET_ENDP
26867 +BEGIN(add_return_unchecked)
26868 + addl (v), %eax
26869 + adcl 4(v), %edx
26870 movl %eax, (v)
26871 movl %edx, 4(v)
26872 RET_ENDP
26873 @@ -86,6 +126,20 @@ RET_ENDP
26874 BEGIN(sub)
26875 subl %eax, (v)
26876 sbbl %edx, 4(v)
26877 +
26878 +#ifdef CONFIG_PAX_REFCOUNT
26879 + jno 0f
26880 + addl %eax, (v)
26881 + adcl %edx, 4(v)
26882 + int $4
26883 +0:
26884 + _ASM_EXTABLE(0b, 0b)
26885 +#endif
26886 +
26887 +RET_ENDP
26888 +BEGIN(sub_unchecked)
26889 + subl %eax, (v)
26890 + sbbl %edx, 4(v)
26891 RET_ENDP
26892 #undef v
26893
26894 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26895 sbbl $0, %edx
26896 addl (v), %eax
26897 adcl 4(v), %edx
26898 +
26899 +#ifdef CONFIG_PAX_REFCOUNT
26900 + into
26901 +1234:
26902 + _ASM_EXTABLE(1234b, 2f)
26903 +#endif
26904 +
26905 + movl %eax, (v)
26906 + movl %edx, 4(v)
26907 +
26908 +#ifdef CONFIG_PAX_REFCOUNT
26909 +2:
26910 +#endif
26911 +
26912 +RET_ENDP
26913 +BEGIN(sub_return_unchecked)
26914 + negl %edx
26915 + negl %eax
26916 + sbbl $0, %edx
26917 + addl (v), %eax
26918 + adcl 4(v), %edx
26919 movl %eax, (v)
26920 movl %edx, 4(v)
26921 RET_ENDP
26922 @@ -105,6 +180,20 @@ RET_ENDP
26923 BEGIN(inc)
26924 addl $1, (v)
26925 adcl $0, 4(v)
26926 +
26927 +#ifdef CONFIG_PAX_REFCOUNT
26928 + jno 0f
26929 + subl $1, (v)
26930 + sbbl $0, 4(v)
26931 + int $4
26932 +0:
26933 + _ASM_EXTABLE(0b, 0b)
26934 +#endif
26935 +
26936 +RET_ENDP
26937 +BEGIN(inc_unchecked)
26938 + addl $1, (v)
26939 + adcl $0, 4(v)
26940 RET_ENDP
26941 #undef v
26942
26943 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26944 movl 4(v), %edx
26945 addl $1, %eax
26946 adcl $0, %edx
26947 +
26948 +#ifdef CONFIG_PAX_REFCOUNT
26949 + into
26950 +1234:
26951 + _ASM_EXTABLE(1234b, 2f)
26952 +#endif
26953 +
26954 + movl %eax, (v)
26955 + movl %edx, 4(v)
26956 +
26957 +#ifdef CONFIG_PAX_REFCOUNT
26958 +2:
26959 +#endif
26960 +
26961 +RET_ENDP
26962 +BEGIN(inc_return_unchecked)
26963 + movl (v), %eax
26964 + movl 4(v), %edx
26965 + addl $1, %eax
26966 + adcl $0, %edx
26967 movl %eax, (v)
26968 movl %edx, 4(v)
26969 RET_ENDP
26970 @@ -123,6 +232,20 @@ RET_ENDP
26971 BEGIN(dec)
26972 subl $1, (v)
26973 sbbl $0, 4(v)
26974 +
26975 +#ifdef CONFIG_PAX_REFCOUNT
26976 + jno 0f
26977 + addl $1, (v)
26978 + adcl $0, 4(v)
26979 + int $4
26980 +0:
26981 + _ASM_EXTABLE(0b, 0b)
26982 +#endif
26983 +
26984 +RET_ENDP
26985 +BEGIN(dec_unchecked)
26986 + subl $1, (v)
26987 + sbbl $0, 4(v)
26988 RET_ENDP
26989 #undef v
26990
26991 @@ -132,6 +255,26 @@ BEGIN(dec_return)
26992 movl 4(v), %edx
26993 subl $1, %eax
26994 sbbl $0, %edx
26995 +
26996 +#ifdef CONFIG_PAX_REFCOUNT
26997 + into
26998 +1234:
26999 + _ASM_EXTABLE(1234b, 2f)
27000 +#endif
27001 +
27002 + movl %eax, (v)
27003 + movl %edx, 4(v)
27004 +
27005 +#ifdef CONFIG_PAX_REFCOUNT
27006 +2:
27007 +#endif
27008 +
27009 +RET_ENDP
27010 +BEGIN(dec_return_unchecked)
27011 + movl (v), %eax
27012 + movl 4(v), %edx
27013 + subl $1, %eax
27014 + sbbl $0, %edx
27015 movl %eax, (v)
27016 movl %edx, 4(v)
27017 RET_ENDP
27018 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27019 adcl %edx, %edi
27020 addl (v), %eax
27021 adcl 4(v), %edx
27022 +
27023 +#ifdef CONFIG_PAX_REFCOUNT
27024 + into
27025 +1234:
27026 + _ASM_EXTABLE(1234b, 2f)
27027 +#endif
27028 +
27029 cmpl %eax, %ecx
27030 je 3f
27031 1:
27032 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27033 1:
27034 addl $1, %eax
27035 adcl $0, %edx
27036 +
27037 +#ifdef CONFIG_PAX_REFCOUNT
27038 + into
27039 +1234:
27040 + _ASM_EXTABLE(1234b, 2f)
27041 +#endif
27042 +
27043 movl %eax, (v)
27044 movl %edx, 4(v)
27045 movl $1, %eax
27046 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27047 movl 4(v), %edx
27048 subl $1, %eax
27049 sbbl $0, %edx
27050 +
27051 +#ifdef CONFIG_PAX_REFCOUNT
27052 + into
27053 +1234:
27054 + _ASM_EXTABLE(1234b, 1f)
27055 +#endif
27056 +
27057 js 1f
27058 movl %eax, (v)
27059 movl %edx, 4(v)
27060 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27061 index f5cc9eb..51fa319 100644
27062 --- a/arch/x86/lib/atomic64_cx8_32.S
27063 +++ b/arch/x86/lib/atomic64_cx8_32.S
27064 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27065 CFI_STARTPROC
27066
27067 read64 %ecx
27068 + pax_force_retaddr
27069 ret
27070 CFI_ENDPROC
27071 ENDPROC(atomic64_read_cx8)
27072
27073 +ENTRY(atomic64_read_unchecked_cx8)
27074 + CFI_STARTPROC
27075 +
27076 + read64 %ecx
27077 + pax_force_retaddr
27078 + ret
27079 + CFI_ENDPROC
27080 +ENDPROC(atomic64_read_unchecked_cx8)
27081 +
27082 ENTRY(atomic64_set_cx8)
27083 CFI_STARTPROC
27084
27085 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27086 cmpxchg8b (%esi)
27087 jne 1b
27088
27089 + pax_force_retaddr
27090 ret
27091 CFI_ENDPROC
27092 ENDPROC(atomic64_set_cx8)
27093
27094 +ENTRY(atomic64_set_unchecked_cx8)
27095 + CFI_STARTPROC
27096 +
27097 +1:
27098 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27099 + * are atomic on 586 and newer */
27100 + cmpxchg8b (%esi)
27101 + jne 1b
27102 +
27103 + pax_force_retaddr
27104 + ret
27105 + CFI_ENDPROC
27106 +ENDPROC(atomic64_set_unchecked_cx8)
27107 +
27108 ENTRY(atomic64_xchg_cx8)
27109 CFI_STARTPROC
27110
27111 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27112 cmpxchg8b (%esi)
27113 jne 1b
27114
27115 + pax_force_retaddr
27116 ret
27117 CFI_ENDPROC
27118 ENDPROC(atomic64_xchg_cx8)
27119
27120 -.macro addsub_return func ins insc
27121 -ENTRY(atomic64_\func\()_return_cx8)
27122 +.macro addsub_return func ins insc unchecked=""
27123 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27124 CFI_STARTPROC
27125 SAVE ebp
27126 SAVE ebx
27127 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27128 movl %edx, %ecx
27129 \ins\()l %esi, %ebx
27130 \insc\()l %edi, %ecx
27131 +
27132 +.ifb \unchecked
27133 +#ifdef CONFIG_PAX_REFCOUNT
27134 + into
27135 +2:
27136 + _ASM_EXTABLE(2b, 3f)
27137 +#endif
27138 +.endif
27139 +
27140 LOCK_PREFIX
27141 cmpxchg8b (%ebp)
27142 jne 1b
27143 -
27144 -10:
27145 movl %ebx, %eax
27146 movl %ecx, %edx
27147 +
27148 +.ifb \unchecked
27149 +#ifdef CONFIG_PAX_REFCOUNT
27150 +3:
27151 +#endif
27152 +.endif
27153 +
27154 RESTORE edi
27155 RESTORE esi
27156 RESTORE ebx
27157 RESTORE ebp
27158 + pax_force_retaddr
27159 ret
27160 CFI_ENDPROC
27161 -ENDPROC(atomic64_\func\()_return_cx8)
27162 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27163 .endm
27164
27165 addsub_return add add adc
27166 addsub_return sub sub sbb
27167 +addsub_return add add adc _unchecked
27168 +addsub_return sub sub sbb _unchecked
27169
27170 -.macro incdec_return func ins insc
27171 -ENTRY(atomic64_\func\()_return_cx8)
27172 +.macro incdec_return func ins insc unchecked=""
27173 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27174 CFI_STARTPROC
27175 SAVE ebx
27176
27177 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27178 movl %edx, %ecx
27179 \ins\()l $1, %ebx
27180 \insc\()l $0, %ecx
27181 +
27182 +.ifb \unchecked
27183 +#ifdef CONFIG_PAX_REFCOUNT
27184 + into
27185 +2:
27186 + _ASM_EXTABLE(2b, 3f)
27187 +#endif
27188 +.endif
27189 +
27190 LOCK_PREFIX
27191 cmpxchg8b (%esi)
27192 jne 1b
27193
27194 -10:
27195 movl %ebx, %eax
27196 movl %ecx, %edx
27197 +
27198 +.ifb \unchecked
27199 +#ifdef CONFIG_PAX_REFCOUNT
27200 +3:
27201 +#endif
27202 +.endif
27203 +
27204 RESTORE ebx
27205 + pax_force_retaddr
27206 ret
27207 CFI_ENDPROC
27208 -ENDPROC(atomic64_\func\()_return_cx8)
27209 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27210 .endm
27211
27212 incdec_return inc add adc
27213 incdec_return dec sub sbb
27214 +incdec_return inc add adc _unchecked
27215 +incdec_return dec sub sbb _unchecked
27216
27217 ENTRY(atomic64_dec_if_positive_cx8)
27218 CFI_STARTPROC
27219 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27220 movl %edx, %ecx
27221 subl $1, %ebx
27222 sbb $0, %ecx
27223 +
27224 +#ifdef CONFIG_PAX_REFCOUNT
27225 + into
27226 +1234:
27227 + _ASM_EXTABLE(1234b, 2f)
27228 +#endif
27229 +
27230 js 2f
27231 LOCK_PREFIX
27232 cmpxchg8b (%esi)
27233 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27234 movl %ebx, %eax
27235 movl %ecx, %edx
27236 RESTORE ebx
27237 + pax_force_retaddr
27238 ret
27239 CFI_ENDPROC
27240 ENDPROC(atomic64_dec_if_positive_cx8)
27241 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27242 movl %edx, %ecx
27243 addl %ebp, %ebx
27244 adcl %edi, %ecx
27245 +
27246 +#ifdef CONFIG_PAX_REFCOUNT
27247 + into
27248 +1234:
27249 + _ASM_EXTABLE(1234b, 3f)
27250 +#endif
27251 +
27252 LOCK_PREFIX
27253 cmpxchg8b (%esi)
27254 jne 1b
27255 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27256 CFI_ADJUST_CFA_OFFSET -8
27257 RESTORE ebx
27258 RESTORE ebp
27259 + pax_force_retaddr
27260 ret
27261 4:
27262 cmpl %edx, 4(%esp)
27263 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27264 xorl %ecx, %ecx
27265 addl $1, %ebx
27266 adcl %edx, %ecx
27267 +
27268 +#ifdef CONFIG_PAX_REFCOUNT
27269 + into
27270 +1234:
27271 + _ASM_EXTABLE(1234b, 3f)
27272 +#endif
27273 +
27274 LOCK_PREFIX
27275 cmpxchg8b (%esi)
27276 jne 1b
27277 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27278 movl $1, %eax
27279 3:
27280 RESTORE ebx
27281 + pax_force_retaddr
27282 ret
27283 CFI_ENDPROC
27284 ENDPROC(atomic64_inc_not_zero_cx8)
27285 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27286 index e78b8ee..7e173a8 100644
27287 --- a/arch/x86/lib/checksum_32.S
27288 +++ b/arch/x86/lib/checksum_32.S
27289 @@ -29,7 +29,8 @@
27290 #include <asm/dwarf2.h>
27291 #include <asm/errno.h>
27292 #include <asm/asm.h>
27293 -
27294 +#include <asm/segment.h>
27295 +
27296 /*
27297 * computes a partial checksum, e.g. for TCP/UDP fragments
27298 */
27299 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27300
27301 #define ARGBASE 16
27302 #define FP 12
27303 -
27304 -ENTRY(csum_partial_copy_generic)
27305 +
27306 +ENTRY(csum_partial_copy_generic_to_user)
27307 CFI_STARTPROC
27308 +
27309 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27310 + pushl_cfi %gs
27311 + popl_cfi %es
27312 + jmp csum_partial_copy_generic
27313 +#endif
27314 +
27315 +ENTRY(csum_partial_copy_generic_from_user)
27316 +
27317 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27318 + pushl_cfi %gs
27319 + popl_cfi %ds
27320 +#endif
27321 +
27322 +ENTRY(csum_partial_copy_generic)
27323 subl $4,%esp
27324 CFI_ADJUST_CFA_OFFSET 4
27325 pushl_cfi %edi
27326 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27327 jmp 4f
27328 SRC(1: movw (%esi), %bx )
27329 addl $2, %esi
27330 -DST( movw %bx, (%edi) )
27331 +DST( movw %bx, %es:(%edi) )
27332 addl $2, %edi
27333 addw %bx, %ax
27334 adcl $0, %eax
27335 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27336 SRC(1: movl (%esi), %ebx )
27337 SRC( movl 4(%esi), %edx )
27338 adcl %ebx, %eax
27339 -DST( movl %ebx, (%edi) )
27340 +DST( movl %ebx, %es:(%edi) )
27341 adcl %edx, %eax
27342 -DST( movl %edx, 4(%edi) )
27343 +DST( movl %edx, %es:4(%edi) )
27344
27345 SRC( movl 8(%esi), %ebx )
27346 SRC( movl 12(%esi), %edx )
27347 adcl %ebx, %eax
27348 -DST( movl %ebx, 8(%edi) )
27349 +DST( movl %ebx, %es:8(%edi) )
27350 adcl %edx, %eax
27351 -DST( movl %edx, 12(%edi) )
27352 +DST( movl %edx, %es:12(%edi) )
27353
27354 SRC( movl 16(%esi), %ebx )
27355 SRC( movl 20(%esi), %edx )
27356 adcl %ebx, %eax
27357 -DST( movl %ebx, 16(%edi) )
27358 +DST( movl %ebx, %es:16(%edi) )
27359 adcl %edx, %eax
27360 -DST( movl %edx, 20(%edi) )
27361 +DST( movl %edx, %es:20(%edi) )
27362
27363 SRC( movl 24(%esi), %ebx )
27364 SRC( movl 28(%esi), %edx )
27365 adcl %ebx, %eax
27366 -DST( movl %ebx, 24(%edi) )
27367 +DST( movl %ebx, %es:24(%edi) )
27368 adcl %edx, %eax
27369 -DST( movl %edx, 28(%edi) )
27370 +DST( movl %edx, %es:28(%edi) )
27371
27372 lea 32(%esi), %esi
27373 lea 32(%edi), %edi
27374 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27375 shrl $2, %edx # This clears CF
27376 SRC(3: movl (%esi), %ebx )
27377 adcl %ebx, %eax
27378 -DST( movl %ebx, (%edi) )
27379 +DST( movl %ebx, %es:(%edi) )
27380 lea 4(%esi), %esi
27381 lea 4(%edi), %edi
27382 dec %edx
27383 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27384 jb 5f
27385 SRC( movw (%esi), %cx )
27386 leal 2(%esi), %esi
27387 -DST( movw %cx, (%edi) )
27388 +DST( movw %cx, %es:(%edi) )
27389 leal 2(%edi), %edi
27390 je 6f
27391 shll $16,%ecx
27392 SRC(5: movb (%esi), %cl )
27393 -DST( movb %cl, (%edi) )
27394 +DST( movb %cl, %es:(%edi) )
27395 6: addl %ecx, %eax
27396 adcl $0, %eax
27397 7:
27398 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27399
27400 6001:
27401 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27402 - movl $-EFAULT, (%ebx)
27403 + movl $-EFAULT, %ss:(%ebx)
27404
27405 # zero the complete destination - computing the rest
27406 # is too much work
27407 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27408
27409 6002:
27410 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27411 - movl $-EFAULT,(%ebx)
27412 + movl $-EFAULT,%ss:(%ebx)
27413 jmp 5000b
27414
27415 .previous
27416
27417 + pushl_cfi %ss
27418 + popl_cfi %ds
27419 + pushl_cfi %ss
27420 + popl_cfi %es
27421 popl_cfi %ebx
27422 CFI_RESTORE ebx
27423 popl_cfi %esi
27424 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27425 popl_cfi %ecx # equivalent to addl $4,%esp
27426 ret
27427 CFI_ENDPROC
27428 -ENDPROC(csum_partial_copy_generic)
27429 +ENDPROC(csum_partial_copy_generic_to_user)
27430
27431 #else
27432
27433 /* Version for PentiumII/PPro */
27434
27435 #define ROUND1(x) \
27436 + nop; nop; nop; \
27437 SRC(movl x(%esi), %ebx ) ; \
27438 addl %ebx, %eax ; \
27439 - DST(movl %ebx, x(%edi) ) ;
27440 + DST(movl %ebx, %es:x(%edi)) ;
27441
27442 #define ROUND(x) \
27443 + nop; nop; nop; \
27444 SRC(movl x(%esi), %ebx ) ; \
27445 adcl %ebx, %eax ; \
27446 - DST(movl %ebx, x(%edi) ) ;
27447 + DST(movl %ebx, %es:x(%edi)) ;
27448
27449 #define ARGBASE 12
27450 -
27451 -ENTRY(csum_partial_copy_generic)
27452 +
27453 +ENTRY(csum_partial_copy_generic_to_user)
27454 CFI_STARTPROC
27455 +
27456 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27457 + pushl_cfi %gs
27458 + popl_cfi %es
27459 + jmp csum_partial_copy_generic
27460 +#endif
27461 +
27462 +ENTRY(csum_partial_copy_generic_from_user)
27463 +
27464 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27465 + pushl_cfi %gs
27466 + popl_cfi %ds
27467 +#endif
27468 +
27469 +ENTRY(csum_partial_copy_generic)
27470 pushl_cfi %ebx
27471 CFI_REL_OFFSET ebx, 0
27472 pushl_cfi %edi
27473 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27474 subl %ebx, %edi
27475 lea -1(%esi),%edx
27476 andl $-32,%edx
27477 - lea 3f(%ebx,%ebx), %ebx
27478 + lea 3f(%ebx,%ebx,2), %ebx
27479 testl %esi, %esi
27480 jmp *%ebx
27481 1: addl $64,%esi
27482 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27483 jb 5f
27484 SRC( movw (%esi), %dx )
27485 leal 2(%esi), %esi
27486 -DST( movw %dx, (%edi) )
27487 +DST( movw %dx, %es:(%edi) )
27488 leal 2(%edi), %edi
27489 je 6f
27490 shll $16,%edx
27491 5:
27492 SRC( movb (%esi), %dl )
27493 -DST( movb %dl, (%edi) )
27494 +DST( movb %dl, %es:(%edi) )
27495 6: addl %edx, %eax
27496 adcl $0, %eax
27497 7:
27498 .section .fixup, "ax"
27499 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27500 - movl $-EFAULT, (%ebx)
27501 + movl $-EFAULT, %ss:(%ebx)
27502 # zero the complete destination (computing the rest is too much work)
27503 movl ARGBASE+8(%esp),%edi # dst
27504 movl ARGBASE+12(%esp),%ecx # len
27505 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27506 rep; stosb
27507 jmp 7b
27508 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27509 - movl $-EFAULT, (%ebx)
27510 + movl $-EFAULT, %ss:(%ebx)
27511 jmp 7b
27512 .previous
27513
27514 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27515 + pushl_cfi %ss
27516 + popl_cfi %ds
27517 + pushl_cfi %ss
27518 + popl_cfi %es
27519 +#endif
27520 +
27521 popl_cfi %esi
27522 CFI_RESTORE esi
27523 popl_cfi %edi
27524 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27525 CFI_RESTORE ebx
27526 ret
27527 CFI_ENDPROC
27528 -ENDPROC(csum_partial_copy_generic)
27529 +ENDPROC(csum_partial_copy_generic_to_user)
27530
27531 #undef ROUND
27532 #undef ROUND1
27533 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27534 index f2145cf..cea889d 100644
27535 --- a/arch/x86/lib/clear_page_64.S
27536 +++ b/arch/x86/lib/clear_page_64.S
27537 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27538 movl $4096/8,%ecx
27539 xorl %eax,%eax
27540 rep stosq
27541 + pax_force_retaddr
27542 ret
27543 CFI_ENDPROC
27544 ENDPROC(clear_page_c)
27545 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27546 movl $4096,%ecx
27547 xorl %eax,%eax
27548 rep stosb
27549 + pax_force_retaddr
27550 ret
27551 CFI_ENDPROC
27552 ENDPROC(clear_page_c_e)
27553 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27554 leaq 64(%rdi),%rdi
27555 jnz .Lloop
27556 nop
27557 + pax_force_retaddr
27558 ret
27559 CFI_ENDPROC
27560 .Lclear_page_end:
27561 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27562
27563 #include <asm/cpufeature.h>
27564
27565 - .section .altinstr_replacement,"ax"
27566 + .section .altinstr_replacement,"a"
27567 1: .byte 0xeb /* jmp <disp8> */
27568 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27569 2: .byte 0xeb /* jmp <disp8> */
27570 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27571 index 1e572c5..2a162cd 100644
27572 --- a/arch/x86/lib/cmpxchg16b_emu.S
27573 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27574 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27575
27576 popf
27577 mov $1, %al
27578 + pax_force_retaddr
27579 ret
27580
27581 not_same:
27582 popf
27583 xor %al,%al
27584 + pax_force_retaddr
27585 ret
27586
27587 CFI_ENDPROC
27588 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27589 index 176cca6..1166c50 100644
27590 --- a/arch/x86/lib/copy_page_64.S
27591 +++ b/arch/x86/lib/copy_page_64.S
27592 @@ -9,6 +9,7 @@ copy_page_rep:
27593 CFI_STARTPROC
27594 movl $4096/8, %ecx
27595 rep movsq
27596 + pax_force_retaddr
27597 ret
27598 CFI_ENDPROC
27599 ENDPROC(copy_page_rep)
27600 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27601
27602 ENTRY(copy_page)
27603 CFI_STARTPROC
27604 - subq $2*8, %rsp
27605 - CFI_ADJUST_CFA_OFFSET 2*8
27606 + subq $3*8, %rsp
27607 + CFI_ADJUST_CFA_OFFSET 3*8
27608 movq %rbx, (%rsp)
27609 CFI_REL_OFFSET rbx, 0
27610 movq %r12, 1*8(%rsp)
27611 CFI_REL_OFFSET r12, 1*8
27612 + movq %r13, 2*8(%rsp)
27613 + CFI_REL_OFFSET r13, 2*8
27614
27615 movl $(4096/64)-5, %ecx
27616 .p2align 4
27617 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27618 movq 0x8*2(%rsi), %rdx
27619 movq 0x8*3(%rsi), %r8
27620 movq 0x8*4(%rsi), %r9
27621 - movq 0x8*5(%rsi), %r10
27622 + movq 0x8*5(%rsi), %r13
27623 movq 0x8*6(%rsi), %r11
27624 movq 0x8*7(%rsi), %r12
27625
27626 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27627 movq %rdx, 0x8*2(%rdi)
27628 movq %r8, 0x8*3(%rdi)
27629 movq %r9, 0x8*4(%rdi)
27630 - movq %r10, 0x8*5(%rdi)
27631 + movq %r13, 0x8*5(%rdi)
27632 movq %r11, 0x8*6(%rdi)
27633 movq %r12, 0x8*7(%rdi)
27634
27635 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27636 movq 0x8*2(%rsi), %rdx
27637 movq 0x8*3(%rsi), %r8
27638 movq 0x8*4(%rsi), %r9
27639 - movq 0x8*5(%rsi), %r10
27640 + movq 0x8*5(%rsi), %r13
27641 movq 0x8*6(%rsi), %r11
27642 movq 0x8*7(%rsi), %r12
27643
27644 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27645 movq %rdx, 0x8*2(%rdi)
27646 movq %r8, 0x8*3(%rdi)
27647 movq %r9, 0x8*4(%rdi)
27648 - movq %r10, 0x8*5(%rdi)
27649 + movq %r13, 0x8*5(%rdi)
27650 movq %r11, 0x8*6(%rdi)
27651 movq %r12, 0x8*7(%rdi)
27652
27653 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27654 CFI_RESTORE rbx
27655 movq 1*8(%rsp), %r12
27656 CFI_RESTORE r12
27657 - addq $2*8, %rsp
27658 - CFI_ADJUST_CFA_OFFSET -2*8
27659 + movq 2*8(%rsp), %r13
27660 + CFI_RESTORE r13
27661 + addq $3*8, %rsp
27662 + CFI_ADJUST_CFA_OFFSET -3*8
27663 + pax_force_retaddr
27664 ret
27665 .Lcopy_page_end:
27666 CFI_ENDPROC
27667 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27668
27669 #include <asm/cpufeature.h>
27670
27671 - .section .altinstr_replacement,"ax"
27672 + .section .altinstr_replacement,"a"
27673 1: .byte 0xeb /* jmp <disp8> */
27674 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27675 2:
27676 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27677 index a30ca15..6b3f4e1 100644
27678 --- a/arch/x86/lib/copy_user_64.S
27679 +++ b/arch/x86/lib/copy_user_64.S
27680 @@ -18,31 +18,7 @@
27681 #include <asm/alternative-asm.h>
27682 #include <asm/asm.h>
27683 #include <asm/smap.h>
27684 -
27685 -/*
27686 - * By placing feature2 after feature1 in altinstructions section, we logically
27687 - * implement:
27688 - * If CPU has feature2, jmp to alt2 is used
27689 - * else if CPU has feature1, jmp to alt1 is used
27690 - * else jmp to orig is used.
27691 - */
27692 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27693 -0:
27694 - .byte 0xe9 /* 32bit jump */
27695 - .long \orig-1f /* by default jump to orig */
27696 -1:
27697 - .section .altinstr_replacement,"ax"
27698 -2: .byte 0xe9 /* near jump with 32bit immediate */
27699 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27700 -3: .byte 0xe9 /* near jump with 32bit immediate */
27701 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27702 - .previous
27703 -
27704 - .section .altinstructions,"a"
27705 - altinstruction_entry 0b,2b,\feature1,5,5
27706 - altinstruction_entry 0b,3b,\feature2,5,5
27707 - .previous
27708 - .endm
27709 +#include <asm/pgtable.h>
27710
27711 .macro ALIGN_DESTINATION
27712 #ifdef FIX_ALIGNMENT
27713 @@ -70,52 +46,6 @@
27714 #endif
27715 .endm
27716
27717 -/* Standard copy_to_user with segment limit checking */
27718 -ENTRY(_copy_to_user)
27719 - CFI_STARTPROC
27720 - GET_THREAD_INFO(%rax)
27721 - movq %rdi,%rcx
27722 - addq %rdx,%rcx
27723 - jc bad_to_user
27724 - cmpq TI_addr_limit(%rax),%rcx
27725 - ja bad_to_user
27726 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27727 - copy_user_generic_unrolled,copy_user_generic_string, \
27728 - copy_user_enhanced_fast_string
27729 - CFI_ENDPROC
27730 -ENDPROC(_copy_to_user)
27731 -
27732 -/* Standard copy_from_user with segment limit checking */
27733 -ENTRY(_copy_from_user)
27734 - CFI_STARTPROC
27735 - GET_THREAD_INFO(%rax)
27736 - movq %rsi,%rcx
27737 - addq %rdx,%rcx
27738 - jc bad_from_user
27739 - cmpq TI_addr_limit(%rax),%rcx
27740 - ja bad_from_user
27741 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27742 - copy_user_generic_unrolled,copy_user_generic_string, \
27743 - copy_user_enhanced_fast_string
27744 - CFI_ENDPROC
27745 -ENDPROC(_copy_from_user)
27746 -
27747 - .section .fixup,"ax"
27748 - /* must zero dest */
27749 -ENTRY(bad_from_user)
27750 -bad_from_user:
27751 - CFI_STARTPROC
27752 - movl %edx,%ecx
27753 - xorl %eax,%eax
27754 - rep
27755 - stosb
27756 -bad_to_user:
27757 - movl %edx,%eax
27758 - ret
27759 - CFI_ENDPROC
27760 -ENDPROC(bad_from_user)
27761 - .previous
27762 -
27763 /*
27764 * copy_user_generic_unrolled - memory copy with exception handling.
27765 * This version is for CPUs like P4 that don't have efficient micro
27766 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27767 */
27768 ENTRY(copy_user_generic_unrolled)
27769 CFI_STARTPROC
27770 + ASM_PAX_OPEN_USERLAND
27771 ASM_STAC
27772 cmpl $8,%edx
27773 jb 20f /* less then 8 bytes, go to byte copy loop */
27774 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27775 jz 17f
27776 1: movq (%rsi),%r8
27777 2: movq 1*8(%rsi),%r9
27778 -3: movq 2*8(%rsi),%r10
27779 +3: movq 2*8(%rsi),%rax
27780 4: movq 3*8(%rsi),%r11
27781 5: movq %r8,(%rdi)
27782 6: movq %r9,1*8(%rdi)
27783 -7: movq %r10,2*8(%rdi)
27784 +7: movq %rax,2*8(%rdi)
27785 8: movq %r11,3*8(%rdi)
27786 9: movq 4*8(%rsi),%r8
27787 10: movq 5*8(%rsi),%r9
27788 -11: movq 6*8(%rsi),%r10
27789 +11: movq 6*8(%rsi),%rax
27790 12: movq 7*8(%rsi),%r11
27791 13: movq %r8,4*8(%rdi)
27792 14: movq %r9,5*8(%rdi)
27793 -15: movq %r10,6*8(%rdi)
27794 +15: movq %rax,6*8(%rdi)
27795 16: movq %r11,7*8(%rdi)
27796 leaq 64(%rsi),%rsi
27797 leaq 64(%rdi),%rdi
27798 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27799 jnz 21b
27800 23: xor %eax,%eax
27801 ASM_CLAC
27802 + ASM_PAX_CLOSE_USERLAND
27803 + pax_force_retaddr
27804 ret
27805
27806 .section .fixup,"ax"
27807 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27808 */
27809 ENTRY(copy_user_generic_string)
27810 CFI_STARTPROC
27811 + ASM_PAX_OPEN_USERLAND
27812 ASM_STAC
27813 andl %edx,%edx
27814 jz 4f
27815 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27816 movsb
27817 4: xorl %eax,%eax
27818 ASM_CLAC
27819 + ASM_PAX_CLOSE_USERLAND
27820 + pax_force_retaddr
27821 ret
27822
27823 .section .fixup,"ax"
27824 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27825 */
27826 ENTRY(copy_user_enhanced_fast_string)
27827 CFI_STARTPROC
27828 + ASM_PAX_OPEN_USERLAND
27829 ASM_STAC
27830 andl %edx,%edx
27831 jz 2f
27832 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27833 movsb
27834 2: xorl %eax,%eax
27835 ASM_CLAC
27836 + ASM_PAX_CLOSE_USERLAND
27837 + pax_force_retaddr
27838 ret
27839
27840 .section .fixup,"ax"
27841 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27842 index 6a4f43c..55d26f2 100644
27843 --- a/arch/x86/lib/copy_user_nocache_64.S
27844 +++ b/arch/x86/lib/copy_user_nocache_64.S
27845 @@ -8,6 +8,7 @@
27846
27847 #include <linux/linkage.h>
27848 #include <asm/dwarf2.h>
27849 +#include <asm/alternative-asm.h>
27850
27851 #define FIX_ALIGNMENT 1
27852
27853 @@ -16,6 +17,7 @@
27854 #include <asm/thread_info.h>
27855 #include <asm/asm.h>
27856 #include <asm/smap.h>
27857 +#include <asm/pgtable.h>
27858
27859 .macro ALIGN_DESTINATION
27860 #ifdef FIX_ALIGNMENT
27861 @@ -49,6 +51,16 @@
27862 */
27863 ENTRY(__copy_user_nocache)
27864 CFI_STARTPROC
27865 +
27866 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27867 + mov pax_user_shadow_base,%rcx
27868 + cmp %rcx,%rsi
27869 + jae 1f
27870 + add %rcx,%rsi
27871 +1:
27872 +#endif
27873 +
27874 + ASM_PAX_OPEN_USERLAND
27875 ASM_STAC
27876 cmpl $8,%edx
27877 jb 20f /* less then 8 bytes, go to byte copy loop */
27878 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27879 jz 17f
27880 1: movq (%rsi),%r8
27881 2: movq 1*8(%rsi),%r9
27882 -3: movq 2*8(%rsi),%r10
27883 +3: movq 2*8(%rsi),%rax
27884 4: movq 3*8(%rsi),%r11
27885 5: movnti %r8,(%rdi)
27886 6: movnti %r9,1*8(%rdi)
27887 -7: movnti %r10,2*8(%rdi)
27888 +7: movnti %rax,2*8(%rdi)
27889 8: movnti %r11,3*8(%rdi)
27890 9: movq 4*8(%rsi),%r8
27891 10: movq 5*8(%rsi),%r9
27892 -11: movq 6*8(%rsi),%r10
27893 +11: movq 6*8(%rsi),%rax
27894 12: movq 7*8(%rsi),%r11
27895 13: movnti %r8,4*8(%rdi)
27896 14: movnti %r9,5*8(%rdi)
27897 -15: movnti %r10,6*8(%rdi)
27898 +15: movnti %rax,6*8(%rdi)
27899 16: movnti %r11,7*8(%rdi)
27900 leaq 64(%rsi),%rsi
27901 leaq 64(%rdi),%rdi
27902 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27903 jnz 21b
27904 23: xorl %eax,%eax
27905 ASM_CLAC
27906 + ASM_PAX_CLOSE_USERLAND
27907 sfence
27908 + pax_force_retaddr
27909 ret
27910
27911 .section .fixup,"ax"
27912 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27913 index 2419d5f..953ee51 100644
27914 --- a/arch/x86/lib/csum-copy_64.S
27915 +++ b/arch/x86/lib/csum-copy_64.S
27916 @@ -9,6 +9,7 @@
27917 #include <asm/dwarf2.h>
27918 #include <asm/errno.h>
27919 #include <asm/asm.h>
27920 +#include <asm/alternative-asm.h>
27921
27922 /*
27923 * Checksum copy with exception handling.
27924 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27925 CFI_RESTORE rbp
27926 addq $7*8, %rsp
27927 CFI_ADJUST_CFA_OFFSET -7*8
27928 + pax_force_retaddr 0, 1
27929 ret
27930 CFI_RESTORE_STATE
27931
27932 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27933 index 7609e0e..b449b98 100644
27934 --- a/arch/x86/lib/csum-wrappers_64.c
27935 +++ b/arch/x86/lib/csum-wrappers_64.c
27936 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27937 len -= 2;
27938 }
27939 }
27940 + pax_open_userland();
27941 stac();
27942 - isum = csum_partial_copy_generic((__force const void *)src,
27943 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27944 dst, len, isum, errp, NULL);
27945 clac();
27946 + pax_close_userland();
27947 if (unlikely(*errp))
27948 goto out_err;
27949
27950 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27951 }
27952
27953 *errp = 0;
27954 + pax_open_userland();
27955 stac();
27956 - ret = csum_partial_copy_generic(src, (void __force *)dst,
27957 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27958 len, isum, NULL, errp);
27959 clac();
27960 + pax_close_userland();
27961 return ret;
27962 }
27963 EXPORT_SYMBOL(csum_partial_copy_to_user);
27964 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
27965 index a451235..1daa956 100644
27966 --- a/arch/x86/lib/getuser.S
27967 +++ b/arch/x86/lib/getuser.S
27968 @@ -33,17 +33,40 @@
27969 #include <asm/thread_info.h>
27970 #include <asm/asm.h>
27971 #include <asm/smap.h>
27972 +#include <asm/segment.h>
27973 +#include <asm/pgtable.h>
27974 +#include <asm/alternative-asm.h>
27975 +
27976 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27977 +#define __copyuser_seg gs;
27978 +#else
27979 +#define __copyuser_seg
27980 +#endif
27981
27982 .text
27983 ENTRY(__get_user_1)
27984 CFI_STARTPROC
27985 +
27986 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27987 GET_THREAD_INFO(%_ASM_DX)
27988 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27989 jae bad_get_user
27990 ASM_STAC
27991 -1: movzbl (%_ASM_AX),%edx
27992 +
27993 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27994 + mov pax_user_shadow_base,%_ASM_DX
27995 + cmp %_ASM_DX,%_ASM_AX
27996 + jae 1234f
27997 + add %_ASM_DX,%_ASM_AX
27998 +1234:
27999 +#endif
28000 +
28001 +#endif
28002 +
28003 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28004 xor %eax,%eax
28005 ASM_CLAC
28006 + pax_force_retaddr
28007 ret
28008 CFI_ENDPROC
28009 ENDPROC(__get_user_1)
28010 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28011 ENTRY(__get_user_2)
28012 CFI_STARTPROC
28013 add $1,%_ASM_AX
28014 +
28015 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28016 jc bad_get_user
28017 GET_THREAD_INFO(%_ASM_DX)
28018 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28019 jae bad_get_user
28020 ASM_STAC
28021 -2: movzwl -1(%_ASM_AX),%edx
28022 +
28023 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28024 + mov pax_user_shadow_base,%_ASM_DX
28025 + cmp %_ASM_DX,%_ASM_AX
28026 + jae 1234f
28027 + add %_ASM_DX,%_ASM_AX
28028 +1234:
28029 +#endif
28030 +
28031 +#endif
28032 +
28033 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28034 xor %eax,%eax
28035 ASM_CLAC
28036 + pax_force_retaddr
28037 ret
28038 CFI_ENDPROC
28039 ENDPROC(__get_user_2)
28040 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28041 ENTRY(__get_user_4)
28042 CFI_STARTPROC
28043 add $3,%_ASM_AX
28044 +
28045 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28046 jc bad_get_user
28047 GET_THREAD_INFO(%_ASM_DX)
28048 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28049 jae bad_get_user
28050 ASM_STAC
28051 -3: movl -3(%_ASM_AX),%edx
28052 +
28053 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28054 + mov pax_user_shadow_base,%_ASM_DX
28055 + cmp %_ASM_DX,%_ASM_AX
28056 + jae 1234f
28057 + add %_ASM_DX,%_ASM_AX
28058 +1234:
28059 +#endif
28060 +
28061 +#endif
28062 +
28063 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28064 xor %eax,%eax
28065 ASM_CLAC
28066 + pax_force_retaddr
28067 ret
28068 CFI_ENDPROC
28069 ENDPROC(__get_user_4)
28070 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28071 GET_THREAD_INFO(%_ASM_DX)
28072 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28073 jae bad_get_user
28074 +
28075 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28076 + mov pax_user_shadow_base,%_ASM_DX
28077 + cmp %_ASM_DX,%_ASM_AX
28078 + jae 1234f
28079 + add %_ASM_DX,%_ASM_AX
28080 +1234:
28081 +#endif
28082 +
28083 ASM_STAC
28084 4: movq -7(%_ASM_AX),%rdx
28085 xor %eax,%eax
28086 ASM_CLAC
28087 + pax_force_retaddr
28088 ret
28089 #else
28090 add $7,%_ASM_AX
28091 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28092 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28093 jae bad_get_user_8
28094 ASM_STAC
28095 -4: movl -7(%_ASM_AX),%edx
28096 -5: movl -3(%_ASM_AX),%ecx
28097 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28098 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28099 xor %eax,%eax
28100 ASM_CLAC
28101 + pax_force_retaddr
28102 ret
28103 #endif
28104 CFI_ENDPROC
28105 @@ -113,6 +175,7 @@ bad_get_user:
28106 xor %edx,%edx
28107 mov $(-EFAULT),%_ASM_AX
28108 ASM_CLAC
28109 + pax_force_retaddr
28110 ret
28111 CFI_ENDPROC
28112 END(bad_get_user)
28113 @@ -124,6 +187,7 @@ bad_get_user_8:
28114 xor %ecx,%ecx
28115 mov $(-EFAULT),%_ASM_AX
28116 ASM_CLAC
28117 + pax_force_retaddr
28118 ret
28119 CFI_ENDPROC
28120 END(bad_get_user_8)
28121 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28122 index 54fcffe..7be149e 100644
28123 --- a/arch/x86/lib/insn.c
28124 +++ b/arch/x86/lib/insn.c
28125 @@ -20,8 +20,10 @@
28126
28127 #ifdef __KERNEL__
28128 #include <linux/string.h>
28129 +#include <asm/pgtable_types.h>
28130 #else
28131 #include <string.h>
28132 +#define ktla_ktva(addr) addr
28133 #endif
28134 #include <asm/inat.h>
28135 #include <asm/insn.h>
28136 @@ -53,8 +55,8 @@
28137 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28138 {
28139 memset(insn, 0, sizeof(*insn));
28140 - insn->kaddr = kaddr;
28141 - insn->next_byte = kaddr;
28142 + insn->kaddr = ktla_ktva(kaddr);
28143 + insn->next_byte = ktla_ktva(kaddr);
28144 insn->x86_64 = x86_64 ? 1 : 0;
28145 insn->opnd_bytes = 4;
28146 if (x86_64)
28147 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28148 index 05a95e7..326f2fa 100644
28149 --- a/arch/x86/lib/iomap_copy_64.S
28150 +++ b/arch/x86/lib/iomap_copy_64.S
28151 @@ -17,6 +17,7 @@
28152
28153 #include <linux/linkage.h>
28154 #include <asm/dwarf2.h>
28155 +#include <asm/alternative-asm.h>
28156
28157 /*
28158 * override generic version in lib/iomap_copy.c
28159 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28160 CFI_STARTPROC
28161 movl %edx,%ecx
28162 rep movsd
28163 + pax_force_retaddr
28164 ret
28165 CFI_ENDPROC
28166 ENDPROC(__iowrite32_copy)
28167 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28168 index 56313a3..9b59269 100644
28169 --- a/arch/x86/lib/memcpy_64.S
28170 +++ b/arch/x86/lib/memcpy_64.S
28171 @@ -24,7 +24,7 @@
28172 * This gets patched over the unrolled variant (below) via the
28173 * alternative instructions framework:
28174 */
28175 - .section .altinstr_replacement, "ax", @progbits
28176 + .section .altinstr_replacement, "a", @progbits
28177 .Lmemcpy_c:
28178 movq %rdi, %rax
28179 movq %rdx, %rcx
28180 @@ -33,6 +33,7 @@
28181 rep movsq
28182 movl %edx, %ecx
28183 rep movsb
28184 + pax_force_retaddr
28185 ret
28186 .Lmemcpy_e:
28187 .previous
28188 @@ -44,11 +45,12 @@
28189 * This gets patched over the unrolled variant (below) via the
28190 * alternative instructions framework:
28191 */
28192 - .section .altinstr_replacement, "ax", @progbits
28193 + .section .altinstr_replacement, "a", @progbits
28194 .Lmemcpy_c_e:
28195 movq %rdi, %rax
28196 movq %rdx, %rcx
28197 rep movsb
28198 + pax_force_retaddr
28199 ret
28200 .Lmemcpy_e_e:
28201 .previous
28202 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28203 */
28204 movq 0*8(%rsi), %r8
28205 movq 1*8(%rsi), %r9
28206 - movq 2*8(%rsi), %r10
28207 + movq 2*8(%rsi), %rcx
28208 movq 3*8(%rsi), %r11
28209 leaq 4*8(%rsi), %rsi
28210
28211 movq %r8, 0*8(%rdi)
28212 movq %r9, 1*8(%rdi)
28213 - movq %r10, 2*8(%rdi)
28214 + movq %rcx, 2*8(%rdi)
28215 movq %r11, 3*8(%rdi)
28216 leaq 4*8(%rdi), %rdi
28217 jae .Lcopy_forward_loop
28218 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28219 subq $0x20, %rdx
28220 movq -1*8(%rsi), %r8
28221 movq -2*8(%rsi), %r9
28222 - movq -3*8(%rsi), %r10
28223 + movq -3*8(%rsi), %rcx
28224 movq -4*8(%rsi), %r11
28225 leaq -4*8(%rsi), %rsi
28226 movq %r8, -1*8(%rdi)
28227 movq %r9, -2*8(%rdi)
28228 - movq %r10, -3*8(%rdi)
28229 + movq %rcx, -3*8(%rdi)
28230 movq %r11, -4*8(%rdi)
28231 leaq -4*8(%rdi), %rdi
28232 jae .Lcopy_backward_loop
28233 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28234 */
28235 movq 0*8(%rsi), %r8
28236 movq 1*8(%rsi), %r9
28237 - movq -2*8(%rsi, %rdx), %r10
28238 + movq -2*8(%rsi, %rdx), %rcx
28239 movq -1*8(%rsi, %rdx), %r11
28240 movq %r8, 0*8(%rdi)
28241 movq %r9, 1*8(%rdi)
28242 - movq %r10, -2*8(%rdi, %rdx)
28243 + movq %rcx, -2*8(%rdi, %rdx)
28244 movq %r11, -1*8(%rdi, %rdx)
28245 + pax_force_retaddr
28246 retq
28247 .p2align 4
28248 .Lless_16bytes:
28249 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28250 movq -1*8(%rsi, %rdx), %r9
28251 movq %r8, 0*8(%rdi)
28252 movq %r9, -1*8(%rdi, %rdx)
28253 + pax_force_retaddr
28254 retq
28255 .p2align 4
28256 .Lless_8bytes:
28257 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28258 movl -4(%rsi, %rdx), %r8d
28259 movl %ecx, (%rdi)
28260 movl %r8d, -4(%rdi, %rdx)
28261 + pax_force_retaddr
28262 retq
28263 .p2align 4
28264 .Lless_3bytes:
28265 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28266 movb %cl, (%rdi)
28267
28268 .Lend:
28269 + pax_force_retaddr
28270 retq
28271 CFI_ENDPROC
28272 ENDPROC(memcpy)
28273 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28274 index 65268a6..5aa7815 100644
28275 --- a/arch/x86/lib/memmove_64.S
28276 +++ b/arch/x86/lib/memmove_64.S
28277 @@ -61,13 +61,13 @@ ENTRY(memmove)
28278 5:
28279 sub $0x20, %rdx
28280 movq 0*8(%rsi), %r11
28281 - movq 1*8(%rsi), %r10
28282 + movq 1*8(%rsi), %rcx
28283 movq 2*8(%rsi), %r9
28284 movq 3*8(%rsi), %r8
28285 leaq 4*8(%rsi), %rsi
28286
28287 movq %r11, 0*8(%rdi)
28288 - movq %r10, 1*8(%rdi)
28289 + movq %rcx, 1*8(%rdi)
28290 movq %r9, 2*8(%rdi)
28291 movq %r8, 3*8(%rdi)
28292 leaq 4*8(%rdi), %rdi
28293 @@ -81,10 +81,10 @@ ENTRY(memmove)
28294 4:
28295 movq %rdx, %rcx
28296 movq -8(%rsi, %rdx), %r11
28297 - lea -8(%rdi, %rdx), %r10
28298 + lea -8(%rdi, %rdx), %r9
28299 shrq $3, %rcx
28300 rep movsq
28301 - movq %r11, (%r10)
28302 + movq %r11, (%r9)
28303 jmp 13f
28304 .Lmemmove_end_forward:
28305
28306 @@ -95,14 +95,14 @@ ENTRY(memmove)
28307 7:
28308 movq %rdx, %rcx
28309 movq (%rsi), %r11
28310 - movq %rdi, %r10
28311 + movq %rdi, %r9
28312 leaq -8(%rsi, %rdx), %rsi
28313 leaq -8(%rdi, %rdx), %rdi
28314 shrq $3, %rcx
28315 std
28316 rep movsq
28317 cld
28318 - movq %r11, (%r10)
28319 + movq %r11, (%r9)
28320 jmp 13f
28321
28322 /*
28323 @@ -127,13 +127,13 @@ ENTRY(memmove)
28324 8:
28325 subq $0x20, %rdx
28326 movq -1*8(%rsi), %r11
28327 - movq -2*8(%rsi), %r10
28328 + movq -2*8(%rsi), %rcx
28329 movq -3*8(%rsi), %r9
28330 movq -4*8(%rsi), %r8
28331 leaq -4*8(%rsi), %rsi
28332
28333 movq %r11, -1*8(%rdi)
28334 - movq %r10, -2*8(%rdi)
28335 + movq %rcx, -2*8(%rdi)
28336 movq %r9, -3*8(%rdi)
28337 movq %r8, -4*8(%rdi)
28338 leaq -4*8(%rdi), %rdi
28339 @@ -151,11 +151,11 @@ ENTRY(memmove)
28340 * Move data from 16 bytes to 31 bytes.
28341 */
28342 movq 0*8(%rsi), %r11
28343 - movq 1*8(%rsi), %r10
28344 + movq 1*8(%rsi), %rcx
28345 movq -2*8(%rsi, %rdx), %r9
28346 movq -1*8(%rsi, %rdx), %r8
28347 movq %r11, 0*8(%rdi)
28348 - movq %r10, 1*8(%rdi)
28349 + movq %rcx, 1*8(%rdi)
28350 movq %r9, -2*8(%rdi, %rdx)
28351 movq %r8, -1*8(%rdi, %rdx)
28352 jmp 13f
28353 @@ -167,9 +167,9 @@ ENTRY(memmove)
28354 * Move data from 8 bytes to 15 bytes.
28355 */
28356 movq 0*8(%rsi), %r11
28357 - movq -1*8(%rsi, %rdx), %r10
28358 + movq -1*8(%rsi, %rdx), %r9
28359 movq %r11, 0*8(%rdi)
28360 - movq %r10, -1*8(%rdi, %rdx)
28361 + movq %r9, -1*8(%rdi, %rdx)
28362 jmp 13f
28363 10:
28364 cmpq $4, %rdx
28365 @@ -178,9 +178,9 @@ ENTRY(memmove)
28366 * Move data from 4 bytes to 7 bytes.
28367 */
28368 movl (%rsi), %r11d
28369 - movl -4(%rsi, %rdx), %r10d
28370 + movl -4(%rsi, %rdx), %r9d
28371 movl %r11d, (%rdi)
28372 - movl %r10d, -4(%rdi, %rdx)
28373 + movl %r9d, -4(%rdi, %rdx)
28374 jmp 13f
28375 11:
28376 cmp $2, %rdx
28377 @@ -189,9 +189,9 @@ ENTRY(memmove)
28378 * Move data from 2 bytes to 3 bytes.
28379 */
28380 movw (%rsi), %r11w
28381 - movw -2(%rsi, %rdx), %r10w
28382 + movw -2(%rsi, %rdx), %r9w
28383 movw %r11w, (%rdi)
28384 - movw %r10w, -2(%rdi, %rdx)
28385 + movw %r9w, -2(%rdi, %rdx)
28386 jmp 13f
28387 12:
28388 cmp $1, %rdx
28389 @@ -202,14 +202,16 @@ ENTRY(memmove)
28390 movb (%rsi), %r11b
28391 movb %r11b, (%rdi)
28392 13:
28393 + pax_force_retaddr
28394 retq
28395 CFI_ENDPROC
28396
28397 - .section .altinstr_replacement,"ax"
28398 + .section .altinstr_replacement,"a"
28399 .Lmemmove_begin_forward_efs:
28400 /* Forward moving data. */
28401 movq %rdx, %rcx
28402 rep movsb
28403 + pax_force_retaddr
28404 retq
28405 .Lmemmove_end_forward_efs:
28406 .previous
28407 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28408 index 2dcb380..50a78bc 100644
28409 --- a/arch/x86/lib/memset_64.S
28410 +++ b/arch/x86/lib/memset_64.S
28411 @@ -16,7 +16,7 @@
28412 *
28413 * rax original destination
28414 */
28415 - .section .altinstr_replacement, "ax", @progbits
28416 + .section .altinstr_replacement, "a", @progbits
28417 .Lmemset_c:
28418 movq %rdi,%r9
28419 movq %rdx,%rcx
28420 @@ -30,6 +30,7 @@
28421 movl %edx,%ecx
28422 rep stosb
28423 movq %r9,%rax
28424 + pax_force_retaddr
28425 ret
28426 .Lmemset_e:
28427 .previous
28428 @@ -45,13 +46,14 @@
28429 *
28430 * rax original destination
28431 */
28432 - .section .altinstr_replacement, "ax", @progbits
28433 + .section .altinstr_replacement, "a", @progbits
28434 .Lmemset_c_e:
28435 movq %rdi,%r9
28436 movb %sil,%al
28437 movq %rdx,%rcx
28438 rep stosb
28439 movq %r9,%rax
28440 + pax_force_retaddr
28441 ret
28442 .Lmemset_e_e:
28443 .previous
28444 @@ -59,7 +61,7 @@
28445 ENTRY(memset)
28446 ENTRY(__memset)
28447 CFI_STARTPROC
28448 - movq %rdi,%r10
28449 + movq %rdi,%r11
28450
28451 /* expand byte value */
28452 movzbl %sil,%ecx
28453 @@ -117,7 +119,8 @@ ENTRY(__memset)
28454 jnz .Lloop_1
28455
28456 .Lende:
28457 - movq %r10,%rax
28458 + movq %r11,%rax
28459 + pax_force_retaddr
28460 ret
28461
28462 CFI_RESTORE_STATE
28463 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28464 index c9f2d9b..e7fd2c0 100644
28465 --- a/arch/x86/lib/mmx_32.c
28466 +++ b/arch/x86/lib/mmx_32.c
28467 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28468 {
28469 void *p;
28470 int i;
28471 + unsigned long cr0;
28472
28473 if (unlikely(in_interrupt()))
28474 return __memcpy(to, from, len);
28475 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28476 kernel_fpu_begin();
28477
28478 __asm__ __volatile__ (
28479 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28480 - " prefetch 64(%0)\n"
28481 - " prefetch 128(%0)\n"
28482 - " prefetch 192(%0)\n"
28483 - " prefetch 256(%0)\n"
28484 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28485 + " prefetch 64(%1)\n"
28486 + " prefetch 128(%1)\n"
28487 + " prefetch 192(%1)\n"
28488 + " prefetch 256(%1)\n"
28489 "2: \n"
28490 ".section .fixup, \"ax\"\n"
28491 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28492 + "3: \n"
28493 +
28494 +#ifdef CONFIG_PAX_KERNEXEC
28495 + " movl %%cr0, %0\n"
28496 + " movl %0, %%eax\n"
28497 + " andl $0xFFFEFFFF, %%eax\n"
28498 + " movl %%eax, %%cr0\n"
28499 +#endif
28500 +
28501 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28502 +
28503 +#ifdef CONFIG_PAX_KERNEXEC
28504 + " movl %0, %%cr0\n"
28505 +#endif
28506 +
28507 " jmp 2b\n"
28508 ".previous\n"
28509 _ASM_EXTABLE(1b, 3b)
28510 - : : "r" (from));
28511 + : "=&r" (cr0) : "r" (from) : "ax");
28512
28513 for ( ; i > 5; i--) {
28514 __asm__ __volatile__ (
28515 - "1: prefetch 320(%0)\n"
28516 - "2: movq (%0), %%mm0\n"
28517 - " movq 8(%0), %%mm1\n"
28518 - " movq 16(%0), %%mm2\n"
28519 - " movq 24(%0), %%mm3\n"
28520 - " movq %%mm0, (%1)\n"
28521 - " movq %%mm1, 8(%1)\n"
28522 - " movq %%mm2, 16(%1)\n"
28523 - " movq %%mm3, 24(%1)\n"
28524 - " movq 32(%0), %%mm0\n"
28525 - " movq 40(%0), %%mm1\n"
28526 - " movq 48(%0), %%mm2\n"
28527 - " movq 56(%0), %%mm3\n"
28528 - " movq %%mm0, 32(%1)\n"
28529 - " movq %%mm1, 40(%1)\n"
28530 - " movq %%mm2, 48(%1)\n"
28531 - " movq %%mm3, 56(%1)\n"
28532 + "1: prefetch 320(%1)\n"
28533 + "2: movq (%1), %%mm0\n"
28534 + " movq 8(%1), %%mm1\n"
28535 + " movq 16(%1), %%mm2\n"
28536 + " movq 24(%1), %%mm3\n"
28537 + " movq %%mm0, (%2)\n"
28538 + " movq %%mm1, 8(%2)\n"
28539 + " movq %%mm2, 16(%2)\n"
28540 + " movq %%mm3, 24(%2)\n"
28541 + " movq 32(%1), %%mm0\n"
28542 + " movq 40(%1), %%mm1\n"
28543 + " movq 48(%1), %%mm2\n"
28544 + " movq 56(%1), %%mm3\n"
28545 + " movq %%mm0, 32(%2)\n"
28546 + " movq %%mm1, 40(%2)\n"
28547 + " movq %%mm2, 48(%2)\n"
28548 + " movq %%mm3, 56(%2)\n"
28549 ".section .fixup, \"ax\"\n"
28550 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28551 + "3:\n"
28552 +
28553 +#ifdef CONFIG_PAX_KERNEXEC
28554 + " movl %%cr0, %0\n"
28555 + " movl %0, %%eax\n"
28556 + " andl $0xFFFEFFFF, %%eax\n"
28557 + " movl %%eax, %%cr0\n"
28558 +#endif
28559 +
28560 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28561 +
28562 +#ifdef CONFIG_PAX_KERNEXEC
28563 + " movl %0, %%cr0\n"
28564 +#endif
28565 +
28566 " jmp 2b\n"
28567 ".previous\n"
28568 _ASM_EXTABLE(1b, 3b)
28569 - : : "r" (from), "r" (to) : "memory");
28570 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28571
28572 from += 64;
28573 to += 64;
28574 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28575 static void fast_copy_page(void *to, void *from)
28576 {
28577 int i;
28578 + unsigned long cr0;
28579
28580 kernel_fpu_begin();
28581
28582 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28583 * but that is for later. -AV
28584 */
28585 __asm__ __volatile__(
28586 - "1: prefetch (%0)\n"
28587 - " prefetch 64(%0)\n"
28588 - " prefetch 128(%0)\n"
28589 - " prefetch 192(%0)\n"
28590 - " prefetch 256(%0)\n"
28591 + "1: prefetch (%1)\n"
28592 + " prefetch 64(%1)\n"
28593 + " prefetch 128(%1)\n"
28594 + " prefetch 192(%1)\n"
28595 + " prefetch 256(%1)\n"
28596 "2: \n"
28597 ".section .fixup, \"ax\"\n"
28598 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28599 + "3: \n"
28600 +
28601 +#ifdef CONFIG_PAX_KERNEXEC
28602 + " movl %%cr0, %0\n"
28603 + " movl %0, %%eax\n"
28604 + " andl $0xFFFEFFFF, %%eax\n"
28605 + " movl %%eax, %%cr0\n"
28606 +#endif
28607 +
28608 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28609 +
28610 +#ifdef CONFIG_PAX_KERNEXEC
28611 + " movl %0, %%cr0\n"
28612 +#endif
28613 +
28614 " jmp 2b\n"
28615 ".previous\n"
28616 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28617 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28618
28619 for (i = 0; i < (4096-320)/64; i++) {
28620 __asm__ __volatile__ (
28621 - "1: prefetch 320(%0)\n"
28622 - "2: movq (%0), %%mm0\n"
28623 - " movntq %%mm0, (%1)\n"
28624 - " movq 8(%0), %%mm1\n"
28625 - " movntq %%mm1, 8(%1)\n"
28626 - " movq 16(%0), %%mm2\n"
28627 - " movntq %%mm2, 16(%1)\n"
28628 - " movq 24(%0), %%mm3\n"
28629 - " movntq %%mm3, 24(%1)\n"
28630 - " movq 32(%0), %%mm4\n"
28631 - " movntq %%mm4, 32(%1)\n"
28632 - " movq 40(%0), %%mm5\n"
28633 - " movntq %%mm5, 40(%1)\n"
28634 - " movq 48(%0), %%mm6\n"
28635 - " movntq %%mm6, 48(%1)\n"
28636 - " movq 56(%0), %%mm7\n"
28637 - " movntq %%mm7, 56(%1)\n"
28638 + "1: prefetch 320(%1)\n"
28639 + "2: movq (%1), %%mm0\n"
28640 + " movntq %%mm0, (%2)\n"
28641 + " movq 8(%1), %%mm1\n"
28642 + " movntq %%mm1, 8(%2)\n"
28643 + " movq 16(%1), %%mm2\n"
28644 + " movntq %%mm2, 16(%2)\n"
28645 + " movq 24(%1), %%mm3\n"
28646 + " movntq %%mm3, 24(%2)\n"
28647 + " movq 32(%1), %%mm4\n"
28648 + " movntq %%mm4, 32(%2)\n"
28649 + " movq 40(%1), %%mm5\n"
28650 + " movntq %%mm5, 40(%2)\n"
28651 + " movq 48(%1), %%mm6\n"
28652 + " movntq %%mm6, 48(%2)\n"
28653 + " movq 56(%1), %%mm7\n"
28654 + " movntq %%mm7, 56(%2)\n"
28655 ".section .fixup, \"ax\"\n"
28656 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28657 + "3:\n"
28658 +
28659 +#ifdef CONFIG_PAX_KERNEXEC
28660 + " movl %%cr0, %0\n"
28661 + " movl %0, %%eax\n"
28662 + " andl $0xFFFEFFFF, %%eax\n"
28663 + " movl %%eax, %%cr0\n"
28664 +#endif
28665 +
28666 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28667 +
28668 +#ifdef CONFIG_PAX_KERNEXEC
28669 + " movl %0, %%cr0\n"
28670 +#endif
28671 +
28672 " jmp 2b\n"
28673 ".previous\n"
28674 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28675 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28676
28677 from += 64;
28678 to += 64;
28679 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28680 static void fast_copy_page(void *to, void *from)
28681 {
28682 int i;
28683 + unsigned long cr0;
28684
28685 kernel_fpu_begin();
28686
28687 __asm__ __volatile__ (
28688 - "1: prefetch (%0)\n"
28689 - " prefetch 64(%0)\n"
28690 - " prefetch 128(%0)\n"
28691 - " prefetch 192(%0)\n"
28692 - " prefetch 256(%0)\n"
28693 + "1: prefetch (%1)\n"
28694 + " prefetch 64(%1)\n"
28695 + " prefetch 128(%1)\n"
28696 + " prefetch 192(%1)\n"
28697 + " prefetch 256(%1)\n"
28698 "2: \n"
28699 ".section .fixup, \"ax\"\n"
28700 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28701 + "3: \n"
28702 +
28703 +#ifdef CONFIG_PAX_KERNEXEC
28704 + " movl %%cr0, %0\n"
28705 + " movl %0, %%eax\n"
28706 + " andl $0xFFFEFFFF, %%eax\n"
28707 + " movl %%eax, %%cr0\n"
28708 +#endif
28709 +
28710 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28711 +
28712 +#ifdef CONFIG_PAX_KERNEXEC
28713 + " movl %0, %%cr0\n"
28714 +#endif
28715 +
28716 " jmp 2b\n"
28717 ".previous\n"
28718 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28719 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28720
28721 for (i = 0; i < 4096/64; i++) {
28722 __asm__ __volatile__ (
28723 - "1: prefetch 320(%0)\n"
28724 - "2: movq (%0), %%mm0\n"
28725 - " movq 8(%0), %%mm1\n"
28726 - " movq 16(%0), %%mm2\n"
28727 - " movq 24(%0), %%mm3\n"
28728 - " movq %%mm0, (%1)\n"
28729 - " movq %%mm1, 8(%1)\n"
28730 - " movq %%mm2, 16(%1)\n"
28731 - " movq %%mm3, 24(%1)\n"
28732 - " movq 32(%0), %%mm0\n"
28733 - " movq 40(%0), %%mm1\n"
28734 - " movq 48(%0), %%mm2\n"
28735 - " movq 56(%0), %%mm3\n"
28736 - " movq %%mm0, 32(%1)\n"
28737 - " movq %%mm1, 40(%1)\n"
28738 - " movq %%mm2, 48(%1)\n"
28739 - " movq %%mm3, 56(%1)\n"
28740 + "1: prefetch 320(%1)\n"
28741 + "2: movq (%1), %%mm0\n"
28742 + " movq 8(%1), %%mm1\n"
28743 + " movq 16(%1), %%mm2\n"
28744 + " movq 24(%1), %%mm3\n"
28745 + " movq %%mm0, (%2)\n"
28746 + " movq %%mm1, 8(%2)\n"
28747 + " movq %%mm2, 16(%2)\n"
28748 + " movq %%mm3, 24(%2)\n"
28749 + " movq 32(%1), %%mm0\n"
28750 + " movq 40(%1), %%mm1\n"
28751 + " movq 48(%1), %%mm2\n"
28752 + " movq 56(%1), %%mm3\n"
28753 + " movq %%mm0, 32(%2)\n"
28754 + " movq %%mm1, 40(%2)\n"
28755 + " movq %%mm2, 48(%2)\n"
28756 + " movq %%mm3, 56(%2)\n"
28757 ".section .fixup, \"ax\"\n"
28758 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28759 + "3:\n"
28760 +
28761 +#ifdef CONFIG_PAX_KERNEXEC
28762 + " movl %%cr0, %0\n"
28763 + " movl %0, %%eax\n"
28764 + " andl $0xFFFEFFFF, %%eax\n"
28765 + " movl %%eax, %%cr0\n"
28766 +#endif
28767 +
28768 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28769 +
28770 +#ifdef CONFIG_PAX_KERNEXEC
28771 + " movl %0, %%cr0\n"
28772 +#endif
28773 +
28774 " jmp 2b\n"
28775 ".previous\n"
28776 _ASM_EXTABLE(1b, 3b)
28777 - : : "r" (from), "r" (to) : "memory");
28778 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28779
28780 from += 64;
28781 to += 64;
28782 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28783 index f6d13ee..aca5f0b 100644
28784 --- a/arch/x86/lib/msr-reg.S
28785 +++ b/arch/x86/lib/msr-reg.S
28786 @@ -3,6 +3,7 @@
28787 #include <asm/dwarf2.h>
28788 #include <asm/asm.h>
28789 #include <asm/msr.h>
28790 +#include <asm/alternative-asm.h>
28791
28792 #ifdef CONFIG_X86_64
28793 /*
28794 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28795 CFI_STARTPROC
28796 pushq_cfi %rbx
28797 pushq_cfi %rbp
28798 - movq %rdi, %r10 /* Save pointer */
28799 + movq %rdi, %r9 /* Save pointer */
28800 xorl %r11d, %r11d /* Return value */
28801 movl (%rdi), %eax
28802 movl 4(%rdi), %ecx
28803 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28804 movl 28(%rdi), %edi
28805 CFI_REMEMBER_STATE
28806 1: \op
28807 -2: movl %eax, (%r10)
28808 +2: movl %eax, (%r9)
28809 movl %r11d, %eax /* Return value */
28810 - movl %ecx, 4(%r10)
28811 - movl %edx, 8(%r10)
28812 - movl %ebx, 12(%r10)
28813 - movl %ebp, 20(%r10)
28814 - movl %esi, 24(%r10)
28815 - movl %edi, 28(%r10)
28816 + movl %ecx, 4(%r9)
28817 + movl %edx, 8(%r9)
28818 + movl %ebx, 12(%r9)
28819 + movl %ebp, 20(%r9)
28820 + movl %esi, 24(%r9)
28821 + movl %edi, 28(%r9)
28822 popq_cfi %rbp
28823 popq_cfi %rbx
28824 + pax_force_retaddr
28825 ret
28826 3:
28827 CFI_RESTORE_STATE
28828 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28829 index fc6ba17..d4d989d 100644
28830 --- a/arch/x86/lib/putuser.S
28831 +++ b/arch/x86/lib/putuser.S
28832 @@ -16,7 +16,9 @@
28833 #include <asm/errno.h>
28834 #include <asm/asm.h>
28835 #include <asm/smap.h>
28836 -
28837 +#include <asm/segment.h>
28838 +#include <asm/pgtable.h>
28839 +#include <asm/alternative-asm.h>
28840
28841 /*
28842 * __put_user_X
28843 @@ -30,57 +32,125 @@
28844 * as they get called from within inline assembly.
28845 */
28846
28847 -#define ENTER CFI_STARTPROC ; \
28848 - GET_THREAD_INFO(%_ASM_BX)
28849 -#define EXIT ASM_CLAC ; \
28850 - ret ; \
28851 +#define ENTER CFI_STARTPROC
28852 +#define EXIT ASM_CLAC ; \
28853 + pax_force_retaddr ; \
28854 + ret ; \
28855 CFI_ENDPROC
28856
28857 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28858 +#define _DEST %_ASM_CX,%_ASM_BX
28859 +#else
28860 +#define _DEST %_ASM_CX
28861 +#endif
28862 +
28863 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28864 +#define __copyuser_seg gs;
28865 +#else
28866 +#define __copyuser_seg
28867 +#endif
28868 +
28869 .text
28870 ENTRY(__put_user_1)
28871 ENTER
28872 +
28873 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28874 + GET_THREAD_INFO(%_ASM_BX)
28875 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28876 jae bad_put_user
28877 ASM_STAC
28878 -1: movb %al,(%_ASM_CX)
28879 +
28880 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28881 + mov pax_user_shadow_base,%_ASM_BX
28882 + cmp %_ASM_BX,%_ASM_CX
28883 + jb 1234f
28884 + xor %ebx,%ebx
28885 +1234:
28886 +#endif
28887 +
28888 +#endif
28889 +
28890 +1: __copyuser_seg movb %al,(_DEST)
28891 xor %eax,%eax
28892 EXIT
28893 ENDPROC(__put_user_1)
28894
28895 ENTRY(__put_user_2)
28896 ENTER
28897 +
28898 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28899 + GET_THREAD_INFO(%_ASM_BX)
28900 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28901 sub $1,%_ASM_BX
28902 cmp %_ASM_BX,%_ASM_CX
28903 jae bad_put_user
28904 ASM_STAC
28905 -2: movw %ax,(%_ASM_CX)
28906 +
28907 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28908 + mov pax_user_shadow_base,%_ASM_BX
28909 + cmp %_ASM_BX,%_ASM_CX
28910 + jb 1234f
28911 + xor %ebx,%ebx
28912 +1234:
28913 +#endif
28914 +
28915 +#endif
28916 +
28917 +2: __copyuser_seg movw %ax,(_DEST)
28918 xor %eax,%eax
28919 EXIT
28920 ENDPROC(__put_user_2)
28921
28922 ENTRY(__put_user_4)
28923 ENTER
28924 +
28925 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28926 + GET_THREAD_INFO(%_ASM_BX)
28927 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28928 sub $3,%_ASM_BX
28929 cmp %_ASM_BX,%_ASM_CX
28930 jae bad_put_user
28931 ASM_STAC
28932 -3: movl %eax,(%_ASM_CX)
28933 +
28934 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28935 + mov pax_user_shadow_base,%_ASM_BX
28936 + cmp %_ASM_BX,%_ASM_CX
28937 + jb 1234f
28938 + xor %ebx,%ebx
28939 +1234:
28940 +#endif
28941 +
28942 +#endif
28943 +
28944 +3: __copyuser_seg movl %eax,(_DEST)
28945 xor %eax,%eax
28946 EXIT
28947 ENDPROC(__put_user_4)
28948
28949 ENTRY(__put_user_8)
28950 ENTER
28951 +
28952 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28953 + GET_THREAD_INFO(%_ASM_BX)
28954 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28955 sub $7,%_ASM_BX
28956 cmp %_ASM_BX,%_ASM_CX
28957 jae bad_put_user
28958 ASM_STAC
28959 -4: mov %_ASM_AX,(%_ASM_CX)
28960 +
28961 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28962 + mov pax_user_shadow_base,%_ASM_BX
28963 + cmp %_ASM_BX,%_ASM_CX
28964 + jb 1234f
28965 + xor %ebx,%ebx
28966 +1234:
28967 +#endif
28968 +
28969 +#endif
28970 +
28971 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
28972 #ifdef CONFIG_X86_32
28973 -5: movl %edx,4(%_ASM_CX)
28974 +5: __copyuser_seg movl %edx,4(_DEST)
28975 #endif
28976 xor %eax,%eax
28977 EXIT
28978 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
28979 index 1cad221..de671ee 100644
28980 --- a/arch/x86/lib/rwlock.S
28981 +++ b/arch/x86/lib/rwlock.S
28982 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
28983 FRAME
28984 0: LOCK_PREFIX
28985 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
28986 +
28987 +#ifdef CONFIG_PAX_REFCOUNT
28988 + jno 1234f
28989 + LOCK_PREFIX
28990 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
28991 + int $4
28992 +1234:
28993 + _ASM_EXTABLE(1234b, 1234b)
28994 +#endif
28995 +
28996 1: rep; nop
28997 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
28998 jne 1b
28999 LOCK_PREFIX
29000 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29001 +
29002 +#ifdef CONFIG_PAX_REFCOUNT
29003 + jno 1234f
29004 + LOCK_PREFIX
29005 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29006 + int $4
29007 +1234:
29008 + _ASM_EXTABLE(1234b, 1234b)
29009 +#endif
29010 +
29011 jnz 0b
29012 ENDFRAME
29013 + pax_force_retaddr
29014 ret
29015 CFI_ENDPROC
29016 END(__write_lock_failed)
29017 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29018 FRAME
29019 0: LOCK_PREFIX
29020 READ_LOCK_SIZE(inc) (%__lock_ptr)
29021 +
29022 +#ifdef CONFIG_PAX_REFCOUNT
29023 + jno 1234f
29024 + LOCK_PREFIX
29025 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29026 + int $4
29027 +1234:
29028 + _ASM_EXTABLE(1234b, 1234b)
29029 +#endif
29030 +
29031 1: rep; nop
29032 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29033 js 1b
29034 LOCK_PREFIX
29035 READ_LOCK_SIZE(dec) (%__lock_ptr)
29036 +
29037 +#ifdef CONFIG_PAX_REFCOUNT
29038 + jno 1234f
29039 + LOCK_PREFIX
29040 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29041 + int $4
29042 +1234:
29043 + _ASM_EXTABLE(1234b, 1234b)
29044 +#endif
29045 +
29046 js 0b
29047 ENDFRAME
29048 + pax_force_retaddr
29049 ret
29050 CFI_ENDPROC
29051 END(__read_lock_failed)
29052 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29053 index 5dff5f0..cadebf4 100644
29054 --- a/arch/x86/lib/rwsem.S
29055 +++ b/arch/x86/lib/rwsem.S
29056 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29057 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29058 CFI_RESTORE __ASM_REG(dx)
29059 restore_common_regs
29060 + pax_force_retaddr
29061 ret
29062 CFI_ENDPROC
29063 ENDPROC(call_rwsem_down_read_failed)
29064 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29065 movq %rax,%rdi
29066 call rwsem_down_write_failed
29067 restore_common_regs
29068 + pax_force_retaddr
29069 ret
29070 CFI_ENDPROC
29071 ENDPROC(call_rwsem_down_write_failed)
29072 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29073 movq %rax,%rdi
29074 call rwsem_wake
29075 restore_common_regs
29076 -1: ret
29077 +1: pax_force_retaddr
29078 + ret
29079 CFI_ENDPROC
29080 ENDPROC(call_rwsem_wake)
29081
29082 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29083 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29084 CFI_RESTORE __ASM_REG(dx)
29085 restore_common_regs
29086 + pax_force_retaddr
29087 ret
29088 CFI_ENDPROC
29089 ENDPROC(call_rwsem_downgrade_wake)
29090 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29091 index a63efd6..ccecad8 100644
29092 --- a/arch/x86/lib/thunk_64.S
29093 +++ b/arch/x86/lib/thunk_64.S
29094 @@ -8,6 +8,7 @@
29095 #include <linux/linkage.h>
29096 #include <asm/dwarf2.h>
29097 #include <asm/calling.h>
29098 +#include <asm/alternative-asm.h>
29099
29100 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29101 .macro THUNK name, func, put_ret_addr_in_rdi=0
29102 @@ -41,5 +42,6 @@
29103 SAVE_ARGS
29104 restore:
29105 RESTORE_ARGS
29106 + pax_force_retaddr
29107 ret
29108 CFI_ENDPROC
29109 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29110 index 3eb18ac..6890bc3 100644
29111 --- a/arch/x86/lib/usercopy_32.c
29112 +++ b/arch/x86/lib/usercopy_32.c
29113 @@ -42,11 +42,13 @@ do { \
29114 int __d0; \
29115 might_fault(); \
29116 __asm__ __volatile__( \
29117 + __COPYUSER_SET_ES \
29118 ASM_STAC "\n" \
29119 "0: rep; stosl\n" \
29120 " movl %2,%0\n" \
29121 "1: rep; stosb\n" \
29122 "2: " ASM_CLAC "\n" \
29123 + __COPYUSER_RESTORE_ES \
29124 ".section .fixup,\"ax\"\n" \
29125 "3: lea 0(%2,%0,4),%0\n" \
29126 " jmp 2b\n" \
29127 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29128
29129 #ifdef CONFIG_X86_INTEL_USERCOPY
29130 static unsigned long
29131 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29132 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29133 {
29134 int d0, d1;
29135 __asm__ __volatile__(
29136 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29137 " .align 2,0x90\n"
29138 "3: movl 0(%4), %%eax\n"
29139 "4: movl 4(%4), %%edx\n"
29140 - "5: movl %%eax, 0(%3)\n"
29141 - "6: movl %%edx, 4(%3)\n"
29142 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29143 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29144 "7: movl 8(%4), %%eax\n"
29145 "8: movl 12(%4),%%edx\n"
29146 - "9: movl %%eax, 8(%3)\n"
29147 - "10: movl %%edx, 12(%3)\n"
29148 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29149 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29150 "11: movl 16(%4), %%eax\n"
29151 "12: movl 20(%4), %%edx\n"
29152 - "13: movl %%eax, 16(%3)\n"
29153 - "14: movl %%edx, 20(%3)\n"
29154 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29155 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29156 "15: movl 24(%4), %%eax\n"
29157 "16: movl 28(%4), %%edx\n"
29158 - "17: movl %%eax, 24(%3)\n"
29159 - "18: movl %%edx, 28(%3)\n"
29160 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29161 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29162 "19: movl 32(%4), %%eax\n"
29163 "20: movl 36(%4), %%edx\n"
29164 - "21: movl %%eax, 32(%3)\n"
29165 - "22: movl %%edx, 36(%3)\n"
29166 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29167 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29168 "23: movl 40(%4), %%eax\n"
29169 "24: movl 44(%4), %%edx\n"
29170 - "25: movl %%eax, 40(%3)\n"
29171 - "26: movl %%edx, 44(%3)\n"
29172 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29173 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29174 "27: movl 48(%4), %%eax\n"
29175 "28: movl 52(%4), %%edx\n"
29176 - "29: movl %%eax, 48(%3)\n"
29177 - "30: movl %%edx, 52(%3)\n"
29178 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29179 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29180 "31: movl 56(%4), %%eax\n"
29181 "32: movl 60(%4), %%edx\n"
29182 - "33: movl %%eax, 56(%3)\n"
29183 - "34: movl %%edx, 60(%3)\n"
29184 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29185 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29186 " addl $-64, %0\n"
29187 " addl $64, %4\n"
29188 " addl $64, %3\n"
29189 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29190 " shrl $2, %0\n"
29191 " andl $3, %%eax\n"
29192 " cld\n"
29193 + __COPYUSER_SET_ES
29194 "99: rep; movsl\n"
29195 "36: movl %%eax, %0\n"
29196 "37: rep; movsb\n"
29197 "100:\n"
29198 + __COPYUSER_RESTORE_ES
29199 ".section .fixup,\"ax\"\n"
29200 "101: lea 0(%%eax,%0,4),%0\n"
29201 " jmp 100b\n"
29202 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29203 }
29204
29205 static unsigned long
29206 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29207 +{
29208 + int d0, d1;
29209 + __asm__ __volatile__(
29210 + " .align 2,0x90\n"
29211 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29212 + " cmpl $67, %0\n"
29213 + " jbe 3f\n"
29214 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29215 + " .align 2,0x90\n"
29216 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29217 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29218 + "5: movl %%eax, 0(%3)\n"
29219 + "6: movl %%edx, 4(%3)\n"
29220 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29221 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29222 + "9: movl %%eax, 8(%3)\n"
29223 + "10: movl %%edx, 12(%3)\n"
29224 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29225 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29226 + "13: movl %%eax, 16(%3)\n"
29227 + "14: movl %%edx, 20(%3)\n"
29228 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29229 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29230 + "17: movl %%eax, 24(%3)\n"
29231 + "18: movl %%edx, 28(%3)\n"
29232 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29233 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29234 + "21: movl %%eax, 32(%3)\n"
29235 + "22: movl %%edx, 36(%3)\n"
29236 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29237 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29238 + "25: movl %%eax, 40(%3)\n"
29239 + "26: movl %%edx, 44(%3)\n"
29240 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29241 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29242 + "29: movl %%eax, 48(%3)\n"
29243 + "30: movl %%edx, 52(%3)\n"
29244 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29245 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29246 + "33: movl %%eax, 56(%3)\n"
29247 + "34: movl %%edx, 60(%3)\n"
29248 + " addl $-64, %0\n"
29249 + " addl $64, %4\n"
29250 + " addl $64, %3\n"
29251 + " cmpl $63, %0\n"
29252 + " ja 1b\n"
29253 + "35: movl %0, %%eax\n"
29254 + " shrl $2, %0\n"
29255 + " andl $3, %%eax\n"
29256 + " cld\n"
29257 + "99: rep; "__copyuser_seg" movsl\n"
29258 + "36: movl %%eax, %0\n"
29259 + "37: rep; "__copyuser_seg" movsb\n"
29260 + "100:\n"
29261 + ".section .fixup,\"ax\"\n"
29262 + "101: lea 0(%%eax,%0,4),%0\n"
29263 + " jmp 100b\n"
29264 + ".previous\n"
29265 + _ASM_EXTABLE(1b,100b)
29266 + _ASM_EXTABLE(2b,100b)
29267 + _ASM_EXTABLE(3b,100b)
29268 + _ASM_EXTABLE(4b,100b)
29269 + _ASM_EXTABLE(5b,100b)
29270 + _ASM_EXTABLE(6b,100b)
29271 + _ASM_EXTABLE(7b,100b)
29272 + _ASM_EXTABLE(8b,100b)
29273 + _ASM_EXTABLE(9b,100b)
29274 + _ASM_EXTABLE(10b,100b)
29275 + _ASM_EXTABLE(11b,100b)
29276 + _ASM_EXTABLE(12b,100b)
29277 + _ASM_EXTABLE(13b,100b)
29278 + _ASM_EXTABLE(14b,100b)
29279 + _ASM_EXTABLE(15b,100b)
29280 + _ASM_EXTABLE(16b,100b)
29281 + _ASM_EXTABLE(17b,100b)
29282 + _ASM_EXTABLE(18b,100b)
29283 + _ASM_EXTABLE(19b,100b)
29284 + _ASM_EXTABLE(20b,100b)
29285 + _ASM_EXTABLE(21b,100b)
29286 + _ASM_EXTABLE(22b,100b)
29287 + _ASM_EXTABLE(23b,100b)
29288 + _ASM_EXTABLE(24b,100b)
29289 + _ASM_EXTABLE(25b,100b)
29290 + _ASM_EXTABLE(26b,100b)
29291 + _ASM_EXTABLE(27b,100b)
29292 + _ASM_EXTABLE(28b,100b)
29293 + _ASM_EXTABLE(29b,100b)
29294 + _ASM_EXTABLE(30b,100b)
29295 + _ASM_EXTABLE(31b,100b)
29296 + _ASM_EXTABLE(32b,100b)
29297 + _ASM_EXTABLE(33b,100b)
29298 + _ASM_EXTABLE(34b,100b)
29299 + _ASM_EXTABLE(35b,100b)
29300 + _ASM_EXTABLE(36b,100b)
29301 + _ASM_EXTABLE(37b,100b)
29302 + _ASM_EXTABLE(99b,101b)
29303 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29304 + : "1"(to), "2"(from), "0"(size)
29305 + : "eax", "edx", "memory");
29306 + return size;
29307 +}
29308 +
29309 +static unsigned long __size_overflow(3)
29310 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29311 {
29312 int d0, d1;
29313 __asm__ __volatile__(
29314 " .align 2,0x90\n"
29315 - "0: movl 32(%4), %%eax\n"
29316 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29317 " cmpl $67, %0\n"
29318 " jbe 2f\n"
29319 - "1: movl 64(%4), %%eax\n"
29320 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29321 " .align 2,0x90\n"
29322 - "2: movl 0(%4), %%eax\n"
29323 - "21: movl 4(%4), %%edx\n"
29324 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29325 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29326 " movl %%eax, 0(%3)\n"
29327 " movl %%edx, 4(%3)\n"
29328 - "3: movl 8(%4), %%eax\n"
29329 - "31: movl 12(%4),%%edx\n"
29330 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29331 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29332 " movl %%eax, 8(%3)\n"
29333 " movl %%edx, 12(%3)\n"
29334 - "4: movl 16(%4), %%eax\n"
29335 - "41: movl 20(%4), %%edx\n"
29336 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29337 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29338 " movl %%eax, 16(%3)\n"
29339 " movl %%edx, 20(%3)\n"
29340 - "10: movl 24(%4), %%eax\n"
29341 - "51: movl 28(%4), %%edx\n"
29342 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29343 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29344 " movl %%eax, 24(%3)\n"
29345 " movl %%edx, 28(%3)\n"
29346 - "11: movl 32(%4), %%eax\n"
29347 - "61: movl 36(%4), %%edx\n"
29348 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29349 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29350 " movl %%eax, 32(%3)\n"
29351 " movl %%edx, 36(%3)\n"
29352 - "12: movl 40(%4), %%eax\n"
29353 - "71: movl 44(%4), %%edx\n"
29354 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29355 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29356 " movl %%eax, 40(%3)\n"
29357 " movl %%edx, 44(%3)\n"
29358 - "13: movl 48(%4), %%eax\n"
29359 - "81: movl 52(%4), %%edx\n"
29360 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29361 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29362 " movl %%eax, 48(%3)\n"
29363 " movl %%edx, 52(%3)\n"
29364 - "14: movl 56(%4), %%eax\n"
29365 - "91: movl 60(%4), %%edx\n"
29366 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29367 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29368 " movl %%eax, 56(%3)\n"
29369 " movl %%edx, 60(%3)\n"
29370 " addl $-64, %0\n"
29371 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29372 " shrl $2, %0\n"
29373 " andl $3, %%eax\n"
29374 " cld\n"
29375 - "6: rep; movsl\n"
29376 + "6: rep; "__copyuser_seg" movsl\n"
29377 " movl %%eax,%0\n"
29378 - "7: rep; movsb\n"
29379 + "7: rep; "__copyuser_seg" movsb\n"
29380 "8:\n"
29381 ".section .fixup,\"ax\"\n"
29382 "9: lea 0(%%eax,%0,4),%0\n"
29383 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29384 * hyoshiok@miraclelinux.com
29385 */
29386
29387 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29388 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
29389 const void __user *from, unsigned long size)
29390 {
29391 int d0, d1;
29392
29393 __asm__ __volatile__(
29394 " .align 2,0x90\n"
29395 - "0: movl 32(%4), %%eax\n"
29396 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29397 " cmpl $67, %0\n"
29398 " jbe 2f\n"
29399 - "1: movl 64(%4), %%eax\n"
29400 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29401 " .align 2,0x90\n"
29402 - "2: movl 0(%4), %%eax\n"
29403 - "21: movl 4(%4), %%edx\n"
29404 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29405 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29406 " movnti %%eax, 0(%3)\n"
29407 " movnti %%edx, 4(%3)\n"
29408 - "3: movl 8(%4), %%eax\n"
29409 - "31: movl 12(%4),%%edx\n"
29410 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29411 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29412 " movnti %%eax, 8(%3)\n"
29413 " movnti %%edx, 12(%3)\n"
29414 - "4: movl 16(%4), %%eax\n"
29415 - "41: movl 20(%4), %%edx\n"
29416 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29417 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29418 " movnti %%eax, 16(%3)\n"
29419 " movnti %%edx, 20(%3)\n"
29420 - "10: movl 24(%4), %%eax\n"
29421 - "51: movl 28(%4), %%edx\n"
29422 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29423 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29424 " movnti %%eax, 24(%3)\n"
29425 " movnti %%edx, 28(%3)\n"
29426 - "11: movl 32(%4), %%eax\n"
29427 - "61: movl 36(%4), %%edx\n"
29428 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29429 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29430 " movnti %%eax, 32(%3)\n"
29431 " movnti %%edx, 36(%3)\n"
29432 - "12: movl 40(%4), %%eax\n"
29433 - "71: movl 44(%4), %%edx\n"
29434 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29435 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29436 " movnti %%eax, 40(%3)\n"
29437 " movnti %%edx, 44(%3)\n"
29438 - "13: movl 48(%4), %%eax\n"
29439 - "81: movl 52(%4), %%edx\n"
29440 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29441 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29442 " movnti %%eax, 48(%3)\n"
29443 " movnti %%edx, 52(%3)\n"
29444 - "14: movl 56(%4), %%eax\n"
29445 - "91: movl 60(%4), %%edx\n"
29446 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29447 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29448 " movnti %%eax, 56(%3)\n"
29449 " movnti %%edx, 60(%3)\n"
29450 " addl $-64, %0\n"
29451 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29452 " shrl $2, %0\n"
29453 " andl $3, %%eax\n"
29454 " cld\n"
29455 - "6: rep; movsl\n"
29456 + "6: rep; "__copyuser_seg" movsl\n"
29457 " movl %%eax,%0\n"
29458 - "7: rep; movsb\n"
29459 + "7: rep; "__copyuser_seg" movsb\n"
29460 "8:\n"
29461 ".section .fixup,\"ax\"\n"
29462 "9: lea 0(%%eax,%0,4),%0\n"
29463 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29464 return size;
29465 }
29466
29467 -static unsigned long __copy_user_intel_nocache(void *to,
29468 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
29469 const void __user *from, unsigned long size)
29470 {
29471 int d0, d1;
29472
29473 __asm__ __volatile__(
29474 " .align 2,0x90\n"
29475 - "0: movl 32(%4), %%eax\n"
29476 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29477 " cmpl $67, %0\n"
29478 " jbe 2f\n"
29479 - "1: movl 64(%4), %%eax\n"
29480 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29481 " .align 2,0x90\n"
29482 - "2: movl 0(%4), %%eax\n"
29483 - "21: movl 4(%4), %%edx\n"
29484 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29485 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29486 " movnti %%eax, 0(%3)\n"
29487 " movnti %%edx, 4(%3)\n"
29488 - "3: movl 8(%4), %%eax\n"
29489 - "31: movl 12(%4),%%edx\n"
29490 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29491 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29492 " movnti %%eax, 8(%3)\n"
29493 " movnti %%edx, 12(%3)\n"
29494 - "4: movl 16(%4), %%eax\n"
29495 - "41: movl 20(%4), %%edx\n"
29496 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29497 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29498 " movnti %%eax, 16(%3)\n"
29499 " movnti %%edx, 20(%3)\n"
29500 - "10: movl 24(%4), %%eax\n"
29501 - "51: movl 28(%4), %%edx\n"
29502 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29503 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29504 " movnti %%eax, 24(%3)\n"
29505 " movnti %%edx, 28(%3)\n"
29506 - "11: movl 32(%4), %%eax\n"
29507 - "61: movl 36(%4), %%edx\n"
29508 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29509 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29510 " movnti %%eax, 32(%3)\n"
29511 " movnti %%edx, 36(%3)\n"
29512 - "12: movl 40(%4), %%eax\n"
29513 - "71: movl 44(%4), %%edx\n"
29514 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29515 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29516 " movnti %%eax, 40(%3)\n"
29517 " movnti %%edx, 44(%3)\n"
29518 - "13: movl 48(%4), %%eax\n"
29519 - "81: movl 52(%4), %%edx\n"
29520 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29521 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29522 " movnti %%eax, 48(%3)\n"
29523 " movnti %%edx, 52(%3)\n"
29524 - "14: movl 56(%4), %%eax\n"
29525 - "91: movl 60(%4), %%edx\n"
29526 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29527 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29528 " movnti %%eax, 56(%3)\n"
29529 " movnti %%edx, 60(%3)\n"
29530 " addl $-64, %0\n"
29531 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29532 " shrl $2, %0\n"
29533 " andl $3, %%eax\n"
29534 " cld\n"
29535 - "6: rep; movsl\n"
29536 + "6: rep; "__copyuser_seg" movsl\n"
29537 " movl %%eax,%0\n"
29538 - "7: rep; movsb\n"
29539 + "7: rep; "__copyuser_seg" movsb\n"
29540 "8:\n"
29541 ".section .fixup,\"ax\"\n"
29542 "9: lea 0(%%eax,%0,4),%0\n"
29543 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29544 */
29545 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29546 unsigned long size);
29547 -unsigned long __copy_user_intel(void __user *to, const void *from,
29548 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29549 + unsigned long size);
29550 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29551 unsigned long size);
29552 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29553 const void __user *from, unsigned long size);
29554 #endif /* CONFIG_X86_INTEL_USERCOPY */
29555
29556 /* Generic arbitrary sized copy. */
29557 -#define __copy_user(to, from, size) \
29558 +#define __copy_user(to, from, size, prefix, set, restore) \
29559 do { \
29560 int __d0, __d1, __d2; \
29561 __asm__ __volatile__( \
29562 + set \
29563 " cmp $7,%0\n" \
29564 " jbe 1f\n" \
29565 " movl %1,%0\n" \
29566 " negl %0\n" \
29567 " andl $7,%0\n" \
29568 " subl %0,%3\n" \
29569 - "4: rep; movsb\n" \
29570 + "4: rep; "prefix"movsb\n" \
29571 " movl %3,%0\n" \
29572 " shrl $2,%0\n" \
29573 " andl $3,%3\n" \
29574 " .align 2,0x90\n" \
29575 - "0: rep; movsl\n" \
29576 + "0: rep; "prefix"movsl\n" \
29577 " movl %3,%0\n" \
29578 - "1: rep; movsb\n" \
29579 + "1: rep; "prefix"movsb\n" \
29580 "2:\n" \
29581 + restore \
29582 ".section .fixup,\"ax\"\n" \
29583 "5: addl %3,%0\n" \
29584 " jmp 2b\n" \
29585 @@ -538,14 +650,14 @@ do { \
29586 " negl %0\n" \
29587 " andl $7,%0\n" \
29588 " subl %0,%3\n" \
29589 - "4: rep; movsb\n" \
29590 + "4: rep; "__copyuser_seg"movsb\n" \
29591 " movl %3,%0\n" \
29592 " shrl $2,%0\n" \
29593 " andl $3,%3\n" \
29594 " .align 2,0x90\n" \
29595 - "0: rep; movsl\n" \
29596 + "0: rep; "__copyuser_seg"movsl\n" \
29597 " movl %3,%0\n" \
29598 - "1: rep; movsb\n" \
29599 + "1: rep; "__copyuser_seg"movsb\n" \
29600 "2:\n" \
29601 ".section .fixup,\"ax\"\n" \
29602 "5: addl %3,%0\n" \
29603 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29604 {
29605 stac();
29606 if (movsl_is_ok(to, from, n))
29607 - __copy_user(to, from, n);
29608 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29609 else
29610 - n = __copy_user_intel(to, from, n);
29611 + n = __generic_copy_to_user_intel(to, from, n);
29612 clac();
29613 return n;
29614 }
29615 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29616 {
29617 stac();
29618 if (movsl_is_ok(to, from, n))
29619 - __copy_user(to, from, n);
29620 + __copy_user(to, from, n, __copyuser_seg, "", "");
29621 else
29622 - n = __copy_user_intel((void __user *)to,
29623 - (const void *)from, n);
29624 + n = __generic_copy_from_user_intel(to, from, n);
29625 clac();
29626 return n;
29627 }
29628 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29629 if (n > 64 && cpu_has_xmm2)
29630 n = __copy_user_intel_nocache(to, from, n);
29631 else
29632 - __copy_user(to, from, n);
29633 + __copy_user(to, from, n, __copyuser_seg, "", "");
29634 #else
29635 - __copy_user(to, from, n);
29636 + __copy_user(to, from, n, __copyuser_seg, "", "");
29637 #endif
29638 clac();
29639 return n;
29640 }
29641 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29642
29643 -/**
29644 - * copy_to_user: - Copy a block of data into user space.
29645 - * @to: Destination address, in user space.
29646 - * @from: Source address, in kernel space.
29647 - * @n: Number of bytes to copy.
29648 - *
29649 - * Context: User context only. This function may sleep.
29650 - *
29651 - * Copy data from kernel space to user space.
29652 - *
29653 - * Returns number of bytes that could not be copied.
29654 - * On success, this will be zero.
29655 - */
29656 -unsigned long
29657 -copy_to_user(void __user *to, const void *from, unsigned long n)
29658 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29659 +void __set_fs(mm_segment_t x)
29660 {
29661 - if (access_ok(VERIFY_WRITE, to, n))
29662 - n = __copy_to_user(to, from, n);
29663 - return n;
29664 + switch (x.seg) {
29665 + case 0:
29666 + loadsegment(gs, 0);
29667 + break;
29668 + case TASK_SIZE_MAX:
29669 + loadsegment(gs, __USER_DS);
29670 + break;
29671 + case -1UL:
29672 + loadsegment(gs, __KERNEL_DS);
29673 + break;
29674 + default:
29675 + BUG();
29676 + }
29677 }
29678 -EXPORT_SYMBOL(copy_to_user);
29679 +EXPORT_SYMBOL(__set_fs);
29680
29681 -/**
29682 - * copy_from_user: - Copy a block of data from user space.
29683 - * @to: Destination address, in kernel space.
29684 - * @from: Source address, in user space.
29685 - * @n: Number of bytes to copy.
29686 - *
29687 - * Context: User context only. This function may sleep.
29688 - *
29689 - * Copy data from user space to kernel space.
29690 - *
29691 - * Returns number of bytes that could not be copied.
29692 - * On success, this will be zero.
29693 - *
29694 - * If some data could not be copied, this function will pad the copied
29695 - * data to the requested size using zero bytes.
29696 - */
29697 -unsigned long
29698 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29699 +void set_fs(mm_segment_t x)
29700 {
29701 - if (access_ok(VERIFY_READ, from, n))
29702 - n = __copy_from_user(to, from, n);
29703 - else
29704 - memset(to, 0, n);
29705 - return n;
29706 + current_thread_info()->addr_limit = x;
29707 + __set_fs(x);
29708 }
29709 -EXPORT_SYMBOL(_copy_from_user);
29710 +EXPORT_SYMBOL(set_fs);
29711 +#endif
29712 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29713 index 906fea3..0194a18 100644
29714 --- a/arch/x86/lib/usercopy_64.c
29715 +++ b/arch/x86/lib/usercopy_64.c
29716 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29717 might_fault();
29718 /* no memory constraint because it doesn't change any memory gcc knows
29719 about */
29720 + pax_open_userland();
29721 stac();
29722 asm volatile(
29723 " testq %[size8],%[size8]\n"
29724 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29725 _ASM_EXTABLE(0b,3b)
29726 _ASM_EXTABLE(1b,2b)
29727 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29728 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29729 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29730 [zero] "r" (0UL), [eight] "r" (8UL));
29731 clac();
29732 + pax_close_userland();
29733 return size;
29734 }
29735 EXPORT_SYMBOL(__clear_user);
29736 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29737 }
29738 EXPORT_SYMBOL(clear_user);
29739
29740 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29741 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29742 {
29743 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29744 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29745 - }
29746 - return len;
29747 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29748 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29749 + return len;
29750 }
29751 EXPORT_SYMBOL(copy_in_user);
29752
29753 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29754 * it is not necessary to optimize tail handling.
29755 */
29756 unsigned long
29757 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29758 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29759 {
29760 char c;
29761 unsigned zero_len;
29762
29763 + clac();
29764 + pax_close_userland();
29765 for (; len; --len, to++) {
29766 if (__get_user_nocheck(c, from++, sizeof(char)))
29767 break;
29768 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29769 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29770 if (__put_user_nocheck(c, to++, sizeof(char)))
29771 break;
29772 - clac();
29773 return len;
29774 }
29775 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29776 index 23d8e5f..9ccc13a 100644
29777 --- a/arch/x86/mm/Makefile
29778 +++ b/arch/x86/mm/Makefile
29779 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29780 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29781
29782 obj-$(CONFIG_MEMTEST) += memtest.o
29783 +
29784 +quote:="
29785 +obj-$(CONFIG_X86_64) += uderef_64.o
29786 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29787 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29788 index 903ec1e..c4166b2 100644
29789 --- a/arch/x86/mm/extable.c
29790 +++ b/arch/x86/mm/extable.c
29791 @@ -6,12 +6,24 @@
29792 static inline unsigned long
29793 ex_insn_addr(const struct exception_table_entry *x)
29794 {
29795 - return (unsigned long)&x->insn + x->insn;
29796 + unsigned long reloc = 0;
29797 +
29798 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29799 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29800 +#endif
29801 +
29802 + return (unsigned long)&x->insn + x->insn + reloc;
29803 }
29804 static inline unsigned long
29805 ex_fixup_addr(const struct exception_table_entry *x)
29806 {
29807 - return (unsigned long)&x->fixup + x->fixup;
29808 + unsigned long reloc = 0;
29809 +
29810 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29811 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29812 +#endif
29813 +
29814 + return (unsigned long)&x->fixup + x->fixup + reloc;
29815 }
29816
29817 int fixup_exception(struct pt_regs *regs)
29818 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29819 unsigned long new_ip;
29820
29821 #ifdef CONFIG_PNPBIOS
29822 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29823 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29824 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29825 extern u32 pnp_bios_is_utter_crap;
29826 pnp_bios_is_utter_crap = 1;
29827 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29828 i += 4;
29829 p->fixup -= i;
29830 i += 4;
29831 +
29832 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29833 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29834 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29835 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29836 +#endif
29837 +
29838 }
29839 }
29840
29841 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29842 index 654be4a..a4a3da1 100644
29843 --- a/arch/x86/mm/fault.c
29844 +++ b/arch/x86/mm/fault.c
29845 @@ -14,11 +14,18 @@
29846 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29847 #include <linux/prefetch.h> /* prefetchw */
29848 #include <linux/context_tracking.h> /* exception_enter(), ... */
29849 +#include <linux/unistd.h>
29850 +#include <linux/compiler.h>
29851
29852 #include <asm/traps.h> /* dotraplinkage, ... */
29853 #include <asm/pgalloc.h> /* pgd_*(), ... */
29854 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29855 #include <asm/fixmap.h> /* VSYSCALL_START */
29856 +#include <asm/tlbflush.h>
29857 +
29858 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29859 +#include <asm/stacktrace.h>
29860 +#endif
29861
29862 /*
29863 * Page fault error code bits:
29864 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29865 int ret = 0;
29866
29867 /* kprobe_running() needs smp_processor_id() */
29868 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29869 + if (kprobes_built_in() && !user_mode(regs)) {
29870 preempt_disable();
29871 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29872 ret = 1;
29873 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29874 return !instr_lo || (instr_lo>>1) == 1;
29875 case 0x00:
29876 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29877 - if (probe_kernel_address(instr, opcode))
29878 + if (user_mode(regs)) {
29879 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29880 + return 0;
29881 + } else if (probe_kernel_address(instr, opcode))
29882 return 0;
29883
29884 *prefetch = (instr_lo == 0xF) &&
29885 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29886 while (instr < max_instr) {
29887 unsigned char opcode;
29888
29889 - if (probe_kernel_address(instr, opcode))
29890 + if (user_mode(regs)) {
29891 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29892 + break;
29893 + } else if (probe_kernel_address(instr, opcode))
29894 break;
29895
29896 instr++;
29897 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29898 force_sig_info(si_signo, &info, tsk);
29899 }
29900
29901 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29902 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29903 +#endif
29904 +
29905 +#ifdef CONFIG_PAX_EMUTRAMP
29906 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29907 +#endif
29908 +
29909 +#ifdef CONFIG_PAX_PAGEEXEC
29910 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29911 +{
29912 + pgd_t *pgd;
29913 + pud_t *pud;
29914 + pmd_t *pmd;
29915 +
29916 + pgd = pgd_offset(mm, address);
29917 + if (!pgd_present(*pgd))
29918 + return NULL;
29919 + pud = pud_offset(pgd, address);
29920 + if (!pud_present(*pud))
29921 + return NULL;
29922 + pmd = pmd_offset(pud, address);
29923 + if (!pmd_present(*pmd))
29924 + return NULL;
29925 + return pmd;
29926 +}
29927 +#endif
29928 +
29929 DEFINE_SPINLOCK(pgd_lock);
29930 LIST_HEAD(pgd_list);
29931
29932 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29933 for (address = VMALLOC_START & PMD_MASK;
29934 address >= TASK_SIZE && address < FIXADDR_TOP;
29935 address += PMD_SIZE) {
29936 +
29937 +#ifdef CONFIG_PAX_PER_CPU_PGD
29938 + unsigned long cpu;
29939 +#else
29940 struct page *page;
29941 +#endif
29942
29943 spin_lock(&pgd_lock);
29944 +
29945 +#ifdef CONFIG_PAX_PER_CPU_PGD
29946 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29947 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29948 + pmd_t *ret;
29949 +
29950 + ret = vmalloc_sync_one(pgd, address);
29951 + if (!ret)
29952 + break;
29953 + pgd = get_cpu_pgd(cpu, kernel);
29954 +#else
29955 list_for_each_entry(page, &pgd_list, lru) {
29956 + pgd_t *pgd;
29957 spinlock_t *pgt_lock;
29958 pmd_t *ret;
29959
29960 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29961 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29962
29963 spin_lock(pgt_lock);
29964 - ret = vmalloc_sync_one(page_address(page), address);
29965 + pgd = page_address(page);
29966 +#endif
29967 +
29968 + ret = vmalloc_sync_one(pgd, address);
29969 +
29970 +#ifndef CONFIG_PAX_PER_CPU_PGD
29971 spin_unlock(pgt_lock);
29972 +#endif
29973
29974 if (!ret)
29975 break;
29976 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29977 * an interrupt in the middle of a task switch..
29978 */
29979 pgd_paddr = read_cr3();
29980 +
29981 +#ifdef CONFIG_PAX_PER_CPU_PGD
29982 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
29983 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
29984 +#endif
29985 +
29986 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
29987 if (!pmd_k)
29988 return -1;
29989 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29990 * happen within a race in page table update. In the later
29991 * case just flush:
29992 */
29993 - pgd = pgd_offset(current->active_mm, address);
29994 +
29995 pgd_ref = pgd_offset_k(address);
29996 if (pgd_none(*pgd_ref))
29997 return -1;
29998
29999 +#ifdef CONFIG_PAX_PER_CPU_PGD
30000 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30001 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30002 + if (pgd_none(*pgd)) {
30003 + set_pgd(pgd, *pgd_ref);
30004 + arch_flush_lazy_mmu_mode();
30005 + } else {
30006 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30007 + }
30008 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30009 +#else
30010 + pgd = pgd_offset(current->active_mm, address);
30011 +#endif
30012 +
30013 if (pgd_none(*pgd)) {
30014 set_pgd(pgd, *pgd_ref);
30015 arch_flush_lazy_mmu_mode();
30016 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30017 static int is_errata100(struct pt_regs *regs, unsigned long address)
30018 {
30019 #ifdef CONFIG_X86_64
30020 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30021 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30022 return 1;
30023 #endif
30024 return 0;
30025 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30026 }
30027
30028 static const char nx_warning[] = KERN_CRIT
30029 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30030 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30031
30032 static void
30033 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30034 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30035 if (!oops_may_print())
30036 return;
30037
30038 - if (error_code & PF_INSTR) {
30039 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30040 unsigned int level;
30041
30042 pte_t *pte = lookup_address(address, &level);
30043
30044 if (pte && pte_present(*pte) && !pte_exec(*pte))
30045 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30046 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30047 }
30048
30049 +#ifdef CONFIG_PAX_KERNEXEC
30050 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30051 + if (current->signal->curr_ip)
30052 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30053 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30054 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30055 + else
30056 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30057 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30058 + }
30059 +#endif
30060 +
30061 printk(KERN_ALERT "BUG: unable to handle kernel ");
30062 if (address < PAGE_SIZE)
30063 printk(KERN_CONT "NULL pointer dereference");
30064 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30065 return;
30066 }
30067 #endif
30068 +
30069 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30070 + if (pax_is_fetch_fault(regs, error_code, address)) {
30071 +
30072 +#ifdef CONFIG_PAX_EMUTRAMP
30073 + switch (pax_handle_fetch_fault(regs)) {
30074 + case 2:
30075 + return;
30076 + }
30077 +#endif
30078 +
30079 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30080 + do_group_exit(SIGKILL);
30081 + }
30082 +#endif
30083 +
30084 /* Kernel addresses are always protection faults: */
30085 if (address >= TASK_SIZE)
30086 error_code |= PF_PROT;
30087 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30088 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30089 printk(KERN_ERR
30090 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30091 - tsk->comm, tsk->pid, address);
30092 + tsk->comm, task_pid_nr(tsk), address);
30093 code = BUS_MCEERR_AR;
30094 }
30095 #endif
30096 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30097 return 1;
30098 }
30099
30100 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30101 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30102 +{
30103 + pte_t *pte;
30104 + pmd_t *pmd;
30105 + spinlock_t *ptl;
30106 + unsigned char pte_mask;
30107 +
30108 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30109 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30110 + return 0;
30111 +
30112 + /* PaX: it's our fault, let's handle it if we can */
30113 +
30114 + /* PaX: take a look at read faults before acquiring any locks */
30115 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30116 + /* instruction fetch attempt from a protected page in user mode */
30117 + up_read(&mm->mmap_sem);
30118 +
30119 +#ifdef CONFIG_PAX_EMUTRAMP
30120 + switch (pax_handle_fetch_fault(regs)) {
30121 + case 2:
30122 + return 1;
30123 + }
30124 +#endif
30125 +
30126 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30127 + do_group_exit(SIGKILL);
30128 + }
30129 +
30130 + pmd = pax_get_pmd(mm, address);
30131 + if (unlikely(!pmd))
30132 + return 0;
30133 +
30134 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30135 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30136 + pte_unmap_unlock(pte, ptl);
30137 + return 0;
30138 + }
30139 +
30140 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30141 + /* write attempt to a protected page in user mode */
30142 + pte_unmap_unlock(pte, ptl);
30143 + return 0;
30144 + }
30145 +
30146 +#ifdef CONFIG_SMP
30147 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30148 +#else
30149 + if (likely(address > get_limit(regs->cs)))
30150 +#endif
30151 + {
30152 + set_pte(pte, pte_mkread(*pte));
30153 + __flush_tlb_one(address);
30154 + pte_unmap_unlock(pte, ptl);
30155 + up_read(&mm->mmap_sem);
30156 + return 1;
30157 + }
30158 +
30159 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30160 +
30161 + /*
30162 + * PaX: fill DTLB with user rights and retry
30163 + */
30164 + __asm__ __volatile__ (
30165 + "orb %2,(%1)\n"
30166 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30167 +/*
30168 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30169 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30170 + * page fault when examined during a TLB load attempt. this is true not only
30171 + * for PTEs holding a non-present entry but also present entries that will
30172 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30173 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30174 + * for our target pages since their PTEs are simply not in the TLBs at all.
30175 +
30176 + * the best thing in omitting it is that we gain around 15-20% speed in the
30177 + * fast path of the page fault handler and can get rid of tracing since we
30178 + * can no longer flush unintended entries.
30179 + */
30180 + "invlpg (%0)\n"
30181 +#endif
30182 + __copyuser_seg"testb $0,(%0)\n"
30183 + "xorb %3,(%1)\n"
30184 + :
30185 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30186 + : "memory", "cc");
30187 + pte_unmap_unlock(pte, ptl);
30188 + up_read(&mm->mmap_sem);
30189 + return 1;
30190 +}
30191 +#endif
30192 +
30193 /*
30194 * Handle a spurious fault caused by a stale TLB entry.
30195 *
30196 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
30197 static inline int
30198 access_error(unsigned long error_code, struct vm_area_struct *vma)
30199 {
30200 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30201 + return 1;
30202 +
30203 if (error_code & PF_WRITE) {
30204 /* write, present and write, not present: */
30205 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30206 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30207 if (error_code & PF_USER)
30208 return false;
30209
30210 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30211 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30212 return false;
30213
30214 return true;
30215 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30216 {
30217 struct vm_area_struct *vma;
30218 struct task_struct *tsk;
30219 - unsigned long address;
30220 struct mm_struct *mm;
30221 int fault;
30222 int write = error_code & PF_WRITE;
30223 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
30224 (write ? FAULT_FLAG_WRITE : 0);
30225
30226 - tsk = current;
30227 - mm = tsk->mm;
30228 -
30229 /* Get the faulting address: */
30230 - address = read_cr2();
30231 + unsigned long address = read_cr2();
30232 +
30233 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30234 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30235 + if (!search_exception_tables(regs->ip)) {
30236 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30237 + bad_area_nosemaphore(regs, error_code, address);
30238 + return;
30239 + }
30240 + if (address < pax_user_shadow_base) {
30241 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30242 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30243 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30244 + } else
30245 + address -= pax_user_shadow_base;
30246 + }
30247 +#endif
30248 +
30249 + tsk = current;
30250 + mm = tsk->mm;
30251
30252 /*
30253 * Detect and handle instructions that would cause a page fault for
30254 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30255 * User-mode registers count as a user access even for any
30256 * potential system fault or CPU buglet:
30257 */
30258 - if (user_mode_vm(regs)) {
30259 + if (user_mode(regs)) {
30260 local_irq_enable();
30261 error_code |= PF_USER;
30262 } else {
30263 @@ -1142,6 +1365,11 @@ retry:
30264 might_sleep();
30265 }
30266
30267 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30268 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30269 + return;
30270 +#endif
30271 +
30272 vma = find_vma(mm, address);
30273 if (unlikely(!vma)) {
30274 bad_area(regs, error_code, address);
30275 @@ -1153,18 +1381,24 @@ retry:
30276 bad_area(regs, error_code, address);
30277 return;
30278 }
30279 - if (error_code & PF_USER) {
30280 - /*
30281 - * Accessing the stack below %sp is always a bug.
30282 - * The large cushion allows instructions like enter
30283 - * and pusha to work. ("enter $65535, $31" pushes
30284 - * 32 pointers and then decrements %sp by 65535.)
30285 - */
30286 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30287 - bad_area(regs, error_code, address);
30288 - return;
30289 - }
30290 + /*
30291 + * Accessing the stack below %sp is always a bug.
30292 + * The large cushion allows instructions like enter
30293 + * and pusha to work. ("enter $65535, $31" pushes
30294 + * 32 pointers and then decrements %sp by 65535.)
30295 + */
30296 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30297 + bad_area(regs, error_code, address);
30298 + return;
30299 }
30300 +
30301 +#ifdef CONFIG_PAX_SEGMEXEC
30302 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30303 + bad_area(regs, error_code, address);
30304 + return;
30305 + }
30306 +#endif
30307 +
30308 if (unlikely(expand_stack(vma, address))) {
30309 bad_area(regs, error_code, address);
30310 return;
30311 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30312 __do_page_fault(regs, error_code);
30313 exception_exit(prev_state);
30314 }
30315 +
30316 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30317 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30318 +{
30319 + struct mm_struct *mm = current->mm;
30320 + unsigned long ip = regs->ip;
30321 +
30322 + if (v8086_mode(regs))
30323 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30324 +
30325 +#ifdef CONFIG_PAX_PAGEEXEC
30326 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30327 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30328 + return true;
30329 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30330 + return true;
30331 + return false;
30332 + }
30333 +#endif
30334 +
30335 +#ifdef CONFIG_PAX_SEGMEXEC
30336 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30337 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30338 + return true;
30339 + return false;
30340 + }
30341 +#endif
30342 +
30343 + return false;
30344 +}
30345 +#endif
30346 +
30347 +#ifdef CONFIG_PAX_EMUTRAMP
30348 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30349 +{
30350 + int err;
30351 +
30352 + do { /* PaX: libffi trampoline emulation */
30353 + unsigned char mov, jmp;
30354 + unsigned int addr1, addr2;
30355 +
30356 +#ifdef CONFIG_X86_64
30357 + if ((regs->ip + 9) >> 32)
30358 + break;
30359 +#endif
30360 +
30361 + err = get_user(mov, (unsigned char __user *)regs->ip);
30362 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30363 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30364 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30365 +
30366 + if (err)
30367 + break;
30368 +
30369 + if (mov == 0xB8 && jmp == 0xE9) {
30370 + regs->ax = addr1;
30371 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30372 + return 2;
30373 + }
30374 + } while (0);
30375 +
30376 + do { /* PaX: gcc trampoline emulation #1 */
30377 + unsigned char mov1, mov2;
30378 + unsigned short jmp;
30379 + unsigned int addr1, addr2;
30380 +
30381 +#ifdef CONFIG_X86_64
30382 + if ((regs->ip + 11) >> 32)
30383 + break;
30384 +#endif
30385 +
30386 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30387 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30388 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30389 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30390 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30391 +
30392 + if (err)
30393 + break;
30394 +
30395 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30396 + regs->cx = addr1;
30397 + regs->ax = addr2;
30398 + regs->ip = addr2;
30399 + return 2;
30400 + }
30401 + } while (0);
30402 +
30403 + do { /* PaX: gcc trampoline emulation #2 */
30404 + unsigned char mov, jmp;
30405 + unsigned int addr1, addr2;
30406 +
30407 +#ifdef CONFIG_X86_64
30408 + if ((regs->ip + 9) >> 32)
30409 + break;
30410 +#endif
30411 +
30412 + err = get_user(mov, (unsigned char __user *)regs->ip);
30413 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30414 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30415 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30416 +
30417 + if (err)
30418 + break;
30419 +
30420 + if (mov == 0xB9 && jmp == 0xE9) {
30421 + regs->cx = addr1;
30422 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30423 + return 2;
30424 + }
30425 + } while (0);
30426 +
30427 + return 1; /* PaX in action */
30428 +}
30429 +
30430 +#ifdef CONFIG_X86_64
30431 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30432 +{
30433 + int err;
30434 +
30435 + do { /* PaX: libffi trampoline emulation */
30436 + unsigned short mov1, mov2, jmp1;
30437 + unsigned char stcclc, jmp2;
30438 + unsigned long addr1, addr2;
30439 +
30440 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30441 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30442 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30443 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30444 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30445 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30446 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30447 +
30448 + if (err)
30449 + break;
30450 +
30451 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30452 + regs->r11 = addr1;
30453 + regs->r10 = addr2;
30454 + if (stcclc == 0xF8)
30455 + regs->flags &= ~X86_EFLAGS_CF;
30456 + else
30457 + regs->flags |= X86_EFLAGS_CF;
30458 + regs->ip = addr1;
30459 + return 2;
30460 + }
30461 + } while (0);
30462 +
30463 + do { /* PaX: gcc trampoline emulation #1 */
30464 + unsigned short mov1, mov2, jmp1;
30465 + unsigned char jmp2;
30466 + unsigned int addr1;
30467 + unsigned long addr2;
30468 +
30469 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30470 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30471 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30472 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30473 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30474 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30475 +
30476 + if (err)
30477 + break;
30478 +
30479 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30480 + regs->r11 = addr1;
30481 + regs->r10 = addr2;
30482 + regs->ip = addr1;
30483 + return 2;
30484 + }
30485 + } while (0);
30486 +
30487 + do { /* PaX: gcc trampoline emulation #2 */
30488 + unsigned short mov1, mov2, jmp1;
30489 + unsigned char jmp2;
30490 + unsigned long addr1, addr2;
30491 +
30492 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30493 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30494 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30495 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30496 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30497 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30498 +
30499 + if (err)
30500 + break;
30501 +
30502 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30503 + regs->r11 = addr1;
30504 + regs->r10 = addr2;
30505 + regs->ip = addr1;
30506 + return 2;
30507 + }
30508 + } while (0);
30509 +
30510 + return 1; /* PaX in action */
30511 +}
30512 +#endif
30513 +
30514 +/*
30515 + * PaX: decide what to do with offenders (regs->ip = fault address)
30516 + *
30517 + * returns 1 when task should be killed
30518 + * 2 when gcc trampoline was detected
30519 + */
30520 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30521 +{
30522 + if (v8086_mode(regs))
30523 + return 1;
30524 +
30525 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30526 + return 1;
30527 +
30528 +#ifdef CONFIG_X86_32
30529 + return pax_handle_fetch_fault_32(regs);
30530 +#else
30531 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30532 + return pax_handle_fetch_fault_32(regs);
30533 + else
30534 + return pax_handle_fetch_fault_64(regs);
30535 +#endif
30536 +}
30537 +#endif
30538 +
30539 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30540 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30541 +{
30542 + long i;
30543 +
30544 + printk(KERN_ERR "PAX: bytes at PC: ");
30545 + for (i = 0; i < 20; i++) {
30546 + unsigned char c;
30547 + if (get_user(c, (unsigned char __force_user *)pc+i))
30548 + printk(KERN_CONT "?? ");
30549 + else
30550 + printk(KERN_CONT "%02x ", c);
30551 + }
30552 + printk("\n");
30553 +
30554 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30555 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30556 + unsigned long c;
30557 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30558 +#ifdef CONFIG_X86_32
30559 + printk(KERN_CONT "???????? ");
30560 +#else
30561 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30562 + printk(KERN_CONT "???????? ???????? ");
30563 + else
30564 + printk(KERN_CONT "???????????????? ");
30565 +#endif
30566 + } else {
30567 +#ifdef CONFIG_X86_64
30568 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30569 + printk(KERN_CONT "%08x ", (unsigned int)c);
30570 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30571 + } else
30572 +#endif
30573 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30574 + }
30575 + }
30576 + printk("\n");
30577 +}
30578 +#endif
30579 +
30580 +/**
30581 + * probe_kernel_write(): safely attempt to write to a location
30582 + * @dst: address to write to
30583 + * @src: pointer to the data that shall be written
30584 + * @size: size of the data chunk
30585 + *
30586 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30587 + * happens, handle that and return -EFAULT.
30588 + */
30589 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30590 +{
30591 + long ret;
30592 + mm_segment_t old_fs = get_fs();
30593 +
30594 + set_fs(KERNEL_DS);
30595 + pagefault_disable();
30596 + pax_open_kernel();
30597 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30598 + pax_close_kernel();
30599 + pagefault_enable();
30600 + set_fs(old_fs);
30601 +
30602 + return ret ? -EFAULT : 0;
30603 +}
30604 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30605 index dd74e46..7d26398 100644
30606 --- a/arch/x86/mm/gup.c
30607 +++ b/arch/x86/mm/gup.c
30608 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30609 addr = start;
30610 len = (unsigned long) nr_pages << PAGE_SHIFT;
30611 end = start + len;
30612 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30613 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30614 (void __user *)start, len)))
30615 return 0;
30616
30617 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30618 index 4500142..53a363c 100644
30619 --- a/arch/x86/mm/highmem_32.c
30620 +++ b/arch/x86/mm/highmem_32.c
30621 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30622 idx = type + KM_TYPE_NR*smp_processor_id();
30623 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30624 BUG_ON(!pte_none(*(kmap_pte-idx)));
30625 +
30626 + pax_open_kernel();
30627 set_pte(kmap_pte-idx, mk_pte(page, prot));
30628 + pax_close_kernel();
30629 +
30630 arch_flush_lazy_mmu_mode();
30631
30632 return (void *)vaddr;
30633 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30634 index 7e73e8c..11d3b86 100644
30635 --- a/arch/x86/mm/hugetlbpage.c
30636 +++ b/arch/x86/mm/hugetlbpage.c
30637 @@ -84,23 +84,30 @@ int pud_huge(pud_t pud)
30638 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30639 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30640 unsigned long addr, unsigned long len,
30641 - unsigned long pgoff, unsigned long flags)
30642 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30643 {
30644 struct hstate *h = hstate_file(file);
30645 struct vm_unmapped_area_info info;
30646 -
30647 +
30648 info.flags = 0;
30649 info.length = len;
30650 info.low_limit = TASK_UNMAPPED_BASE;
30651 +
30652 +#ifdef CONFIG_PAX_RANDMMAP
30653 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30654 + info.low_limit += current->mm->delta_mmap;
30655 +#endif
30656 +
30657 info.high_limit = TASK_SIZE;
30658 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30659 info.align_offset = 0;
30660 + info.threadstack_offset = offset;
30661 return vm_unmapped_area(&info);
30662 }
30663
30664 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30665 unsigned long addr0, unsigned long len,
30666 - unsigned long pgoff, unsigned long flags)
30667 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30668 {
30669 struct hstate *h = hstate_file(file);
30670 struct vm_unmapped_area_info info;
30671 @@ -112,6 +119,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30672 info.high_limit = current->mm->mmap_base;
30673 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30674 info.align_offset = 0;
30675 + info.threadstack_offset = offset;
30676 addr = vm_unmapped_area(&info);
30677
30678 /*
30679 @@ -124,6 +132,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30680 VM_BUG_ON(addr != -ENOMEM);
30681 info.flags = 0;
30682 info.low_limit = TASK_UNMAPPED_BASE;
30683 +
30684 +#ifdef CONFIG_PAX_RANDMMAP
30685 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30686 + info.low_limit += current->mm->delta_mmap;
30687 +#endif
30688 +
30689 info.high_limit = TASK_SIZE;
30690 addr = vm_unmapped_area(&info);
30691 }
30692 @@ -138,10 +152,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30693 struct hstate *h = hstate_file(file);
30694 struct mm_struct *mm = current->mm;
30695 struct vm_area_struct *vma;
30696 + unsigned long pax_task_size = TASK_SIZE;
30697 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30698
30699 if (len & ~huge_page_mask(h))
30700 return -EINVAL;
30701 - if (len > TASK_SIZE)
30702 +
30703 +#ifdef CONFIG_PAX_SEGMEXEC
30704 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30705 + pax_task_size = SEGMEXEC_TASK_SIZE;
30706 +#endif
30707 +
30708 + pax_task_size -= PAGE_SIZE;
30709 +
30710 + if (len > pax_task_size)
30711 return -ENOMEM;
30712
30713 if (flags & MAP_FIXED) {
30714 @@ -150,19 +174,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30715 return addr;
30716 }
30717
30718 +#ifdef CONFIG_PAX_RANDMMAP
30719 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30720 +#endif
30721 +
30722 if (addr) {
30723 addr = ALIGN(addr, huge_page_size(h));
30724 vma = find_vma(mm, addr);
30725 - if (TASK_SIZE - len >= addr &&
30726 - (!vma || addr + len <= vma->vm_start))
30727 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30728 return addr;
30729 }
30730 if (mm->get_unmapped_area == arch_get_unmapped_area)
30731 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30732 - pgoff, flags);
30733 + pgoff, flags, offset);
30734 else
30735 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30736 - pgoff, flags);
30737 + pgoff, flags, offset);
30738 }
30739
30740 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30741 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30742 index 04664cd..dae6e5d 100644
30743 --- a/arch/x86/mm/init.c
30744 +++ b/arch/x86/mm/init.c
30745 @@ -4,6 +4,7 @@
30746 #include <linux/swap.h>
30747 #include <linux/memblock.h>
30748 #include <linux/bootmem.h> /* for max_low_pfn */
30749 +#include <linux/tboot.h>
30750
30751 #include <asm/cacheflush.h>
30752 #include <asm/e820.h>
30753 @@ -17,6 +18,8 @@
30754 #include <asm/proto.h>
30755 #include <asm/dma.h> /* for MAX_DMA_PFN */
30756 #include <asm/microcode.h>
30757 +#include <asm/desc.h>
30758 +#include <asm/bios_ebda.h>
30759
30760 #include "mm_internal.h"
30761
30762 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30763 early_ioremap_page_table_range_init();
30764 #endif
30765
30766 +#ifdef CONFIG_PAX_PER_CPU_PGD
30767 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30768 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30769 + KERNEL_PGD_PTRS);
30770 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30771 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30772 + KERNEL_PGD_PTRS);
30773 + load_cr3(get_cpu_pgd(0, kernel));
30774 +#else
30775 load_cr3(swapper_pg_dir);
30776 +#endif
30777 +
30778 __flush_tlb_all();
30779
30780 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30781 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30782 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30783 * mmio resources as well as potential bios/acpi data regions.
30784 */
30785 +
30786 +#ifdef CONFIG_GRKERNSEC_KMEM
30787 +static unsigned int ebda_start __read_only;
30788 +static unsigned int ebda_end __read_only;
30789 +#endif
30790 +
30791 int devmem_is_allowed(unsigned long pagenr)
30792 {
30793 - if (pagenr < 256)
30794 +#ifdef CONFIG_GRKERNSEC_KMEM
30795 + /* allow BDA */
30796 + if (!pagenr)
30797 return 1;
30798 + /* allow EBDA */
30799 + if (pagenr >= ebda_start && pagenr < ebda_end)
30800 + return 1;
30801 + /* if tboot is in use, allow access to its hardcoded serial log range */
30802 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30803 + return 1;
30804 +#else
30805 + if (!pagenr)
30806 + return 1;
30807 +#ifdef CONFIG_VM86
30808 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30809 + return 1;
30810 +#endif
30811 +#endif
30812 +
30813 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30814 + return 1;
30815 +#ifdef CONFIG_GRKERNSEC_KMEM
30816 + /* throw out everything else below 1MB */
30817 + if (pagenr <= 256)
30818 + return 0;
30819 +#endif
30820 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30821 return 0;
30822 if (!page_is_ram(pagenr))
30823 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30824 #endif
30825 }
30826
30827 +#ifdef CONFIG_GRKERNSEC_KMEM
30828 +static inline void gr_init_ebda(void)
30829 +{
30830 + unsigned int ebda_addr;
30831 + unsigned int ebda_size = 0;
30832 +
30833 + ebda_addr = get_bios_ebda();
30834 + if (ebda_addr) {
30835 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30836 + ebda_size <<= 10;
30837 + }
30838 + if (ebda_addr && ebda_size) {
30839 + ebda_start = ebda_addr >> PAGE_SHIFT;
30840 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30841 + } else {
30842 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30843 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30844 + }
30845 +}
30846 +#else
30847 +static inline void gr_init_ebda(void) { }
30848 +#endif
30849 +
30850 void free_initmem(void)
30851 {
30852 +#ifdef CONFIG_PAX_KERNEXEC
30853 +#ifdef CONFIG_X86_32
30854 + /* PaX: limit KERNEL_CS to actual size */
30855 + unsigned long addr, limit;
30856 + struct desc_struct d;
30857 + int cpu;
30858 +#else
30859 + pgd_t *pgd;
30860 + pud_t *pud;
30861 + pmd_t *pmd;
30862 + unsigned long addr, end;
30863 +#endif
30864 +#endif
30865 +
30866 + gr_init_ebda();
30867 +
30868 +#ifdef CONFIG_PAX_KERNEXEC
30869 +#ifdef CONFIG_X86_32
30870 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30871 + limit = (limit - 1UL) >> PAGE_SHIFT;
30872 +
30873 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30874 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30875 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30876 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30877 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30878 + }
30879 +
30880 + /* PaX: make KERNEL_CS read-only */
30881 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30882 + if (!paravirt_enabled())
30883 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30884 +/*
30885 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30886 + pgd = pgd_offset_k(addr);
30887 + pud = pud_offset(pgd, addr);
30888 + pmd = pmd_offset(pud, addr);
30889 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30890 + }
30891 +*/
30892 +#ifdef CONFIG_X86_PAE
30893 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30894 +/*
30895 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30896 + pgd = pgd_offset_k(addr);
30897 + pud = pud_offset(pgd, addr);
30898 + pmd = pmd_offset(pud, addr);
30899 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30900 + }
30901 +*/
30902 +#endif
30903 +
30904 +#ifdef CONFIG_MODULES
30905 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30906 +#endif
30907 +
30908 +#else
30909 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30910 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30911 + pgd = pgd_offset_k(addr);
30912 + pud = pud_offset(pgd, addr);
30913 + pmd = pmd_offset(pud, addr);
30914 + if (!pmd_present(*pmd))
30915 + continue;
30916 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30917 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30918 + else
30919 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30920 + }
30921 +
30922 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30923 + end = addr + KERNEL_IMAGE_SIZE;
30924 + for (; addr < end; addr += PMD_SIZE) {
30925 + pgd = pgd_offset_k(addr);
30926 + pud = pud_offset(pgd, addr);
30927 + pmd = pmd_offset(pud, addr);
30928 + if (!pmd_present(*pmd))
30929 + continue;
30930 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30931 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30932 + }
30933 +#endif
30934 +
30935 + flush_tlb_all();
30936 +#endif
30937 +
30938 free_init_pages("unused kernel",
30939 (unsigned long)(&__init_begin),
30940 (unsigned long)(&__init_end));
30941 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30942 index 4287f1f..3b99c71 100644
30943 --- a/arch/x86/mm/init_32.c
30944 +++ b/arch/x86/mm/init_32.c
30945 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30946 bool __read_mostly __vmalloc_start_set = false;
30947
30948 /*
30949 - * Creates a middle page table and puts a pointer to it in the
30950 - * given global directory entry. This only returns the gd entry
30951 - * in non-PAE compilation mode, since the middle layer is folded.
30952 - */
30953 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30954 -{
30955 - pud_t *pud;
30956 - pmd_t *pmd_table;
30957 -
30958 -#ifdef CONFIG_X86_PAE
30959 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30960 - pmd_table = (pmd_t *)alloc_low_page();
30961 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30962 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30963 - pud = pud_offset(pgd, 0);
30964 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30965 -
30966 - return pmd_table;
30967 - }
30968 -#endif
30969 - pud = pud_offset(pgd, 0);
30970 - pmd_table = pmd_offset(pud, 0);
30971 -
30972 - return pmd_table;
30973 -}
30974 -
30975 -/*
30976 * Create a page table and place a pointer to it in a middle page
30977 * directory entry:
30978 */
30979 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30980 pte_t *page_table = (pte_t *)alloc_low_page();
30981
30982 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
30983 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30984 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
30985 +#else
30986 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
30987 +#endif
30988 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
30989 }
30990
30991 return pte_offset_kernel(pmd, 0);
30992 }
30993
30994 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
30995 +{
30996 + pud_t *pud;
30997 + pmd_t *pmd_table;
30998 +
30999 + pud = pud_offset(pgd, 0);
31000 + pmd_table = pmd_offset(pud, 0);
31001 +
31002 + return pmd_table;
31003 +}
31004 +
31005 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31006 {
31007 int pgd_idx = pgd_index(vaddr);
31008 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31009 int pgd_idx, pmd_idx;
31010 unsigned long vaddr;
31011 pgd_t *pgd;
31012 + pud_t *pud;
31013 pmd_t *pmd;
31014 pte_t *pte = NULL;
31015 unsigned long count = page_table_range_init_count(start, end);
31016 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31017 pgd = pgd_base + pgd_idx;
31018
31019 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31020 - pmd = one_md_table_init(pgd);
31021 - pmd = pmd + pmd_index(vaddr);
31022 + pud = pud_offset(pgd, vaddr);
31023 + pmd = pmd_offset(pud, vaddr);
31024 +
31025 +#ifdef CONFIG_X86_PAE
31026 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31027 +#endif
31028 +
31029 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31030 pmd++, pmd_idx++) {
31031 pte = page_table_kmap_check(one_page_table_init(pmd),
31032 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31033 }
31034 }
31035
31036 -static inline int is_kernel_text(unsigned long addr)
31037 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31038 {
31039 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31040 - return 1;
31041 - return 0;
31042 + if ((start > ktla_ktva((unsigned long)_etext) ||
31043 + end <= ktla_ktva((unsigned long)_stext)) &&
31044 + (start > ktla_ktva((unsigned long)_einittext) ||
31045 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31046 +
31047 +#ifdef CONFIG_ACPI_SLEEP
31048 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31049 +#endif
31050 +
31051 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31052 + return 0;
31053 + return 1;
31054 }
31055
31056 /*
31057 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31058 unsigned long last_map_addr = end;
31059 unsigned long start_pfn, end_pfn;
31060 pgd_t *pgd_base = swapper_pg_dir;
31061 - int pgd_idx, pmd_idx, pte_ofs;
31062 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31063 unsigned long pfn;
31064 pgd_t *pgd;
31065 + pud_t *pud;
31066 pmd_t *pmd;
31067 pte_t *pte;
31068 unsigned pages_2m, pages_4k;
31069 @@ -291,8 +295,13 @@ repeat:
31070 pfn = start_pfn;
31071 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31072 pgd = pgd_base + pgd_idx;
31073 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31074 - pmd = one_md_table_init(pgd);
31075 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31076 + pud = pud_offset(pgd, 0);
31077 + pmd = pmd_offset(pud, 0);
31078 +
31079 +#ifdef CONFIG_X86_PAE
31080 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31081 +#endif
31082
31083 if (pfn >= end_pfn)
31084 continue;
31085 @@ -304,14 +313,13 @@ repeat:
31086 #endif
31087 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31088 pmd++, pmd_idx++) {
31089 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31090 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31091
31092 /*
31093 * Map with big pages if possible, otherwise
31094 * create normal page tables:
31095 */
31096 if (use_pse) {
31097 - unsigned int addr2;
31098 pgprot_t prot = PAGE_KERNEL_LARGE;
31099 /*
31100 * first pass will use the same initial
31101 @@ -322,11 +330,7 @@ repeat:
31102 _PAGE_PSE);
31103
31104 pfn &= PMD_MASK >> PAGE_SHIFT;
31105 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31106 - PAGE_OFFSET + PAGE_SIZE-1;
31107 -
31108 - if (is_kernel_text(addr) ||
31109 - is_kernel_text(addr2))
31110 + if (is_kernel_text(address, address + PMD_SIZE))
31111 prot = PAGE_KERNEL_LARGE_EXEC;
31112
31113 pages_2m++;
31114 @@ -343,7 +347,7 @@ repeat:
31115 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31116 pte += pte_ofs;
31117 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31118 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31119 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31120 pgprot_t prot = PAGE_KERNEL;
31121 /*
31122 * first pass will use the same initial
31123 @@ -351,7 +355,7 @@ repeat:
31124 */
31125 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31126
31127 - if (is_kernel_text(addr))
31128 + if (is_kernel_text(address, address + PAGE_SIZE))
31129 prot = PAGE_KERNEL_EXEC;
31130
31131 pages_4k++;
31132 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31133
31134 pud = pud_offset(pgd, va);
31135 pmd = pmd_offset(pud, va);
31136 - if (!pmd_present(*pmd))
31137 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31138 break;
31139
31140 /* should not be large page here */
31141 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31142
31143 static void __init pagetable_init(void)
31144 {
31145 - pgd_t *pgd_base = swapper_pg_dir;
31146 -
31147 - permanent_kmaps_init(pgd_base);
31148 + permanent_kmaps_init(swapper_pg_dir);
31149 }
31150
31151 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31152 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31153 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31154
31155 /* user-defined highmem size */
31156 @@ -787,10 +789,10 @@ void __init mem_init(void)
31157 ((unsigned long)&__init_end -
31158 (unsigned long)&__init_begin) >> 10,
31159
31160 - (unsigned long)&_etext, (unsigned long)&_edata,
31161 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31162 + (unsigned long)&_sdata, (unsigned long)&_edata,
31163 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31164
31165 - (unsigned long)&_text, (unsigned long)&_etext,
31166 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31167 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31168
31169 /*
31170 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31171 if (!kernel_set_to_readonly)
31172 return;
31173
31174 + start = ktla_ktva(start);
31175 pr_debug("Set kernel text: %lx - %lx for read write\n",
31176 start, start+size);
31177
31178 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31179 if (!kernel_set_to_readonly)
31180 return;
31181
31182 + start = ktla_ktva(start);
31183 pr_debug("Set kernel text: %lx - %lx for read only\n",
31184 start, start+size);
31185
31186 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31187 unsigned long start = PFN_ALIGN(_text);
31188 unsigned long size = PFN_ALIGN(_etext) - start;
31189
31190 + start = ktla_ktva(start);
31191 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31192 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31193 size >> 10);
31194 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31195 index 104d56a..62ba13f1 100644
31196 --- a/arch/x86/mm/init_64.c
31197 +++ b/arch/x86/mm/init_64.c
31198 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31199 * around without checking the pgd every time.
31200 */
31201
31202 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31203 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31204 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31205
31206 int force_personality32;
31207 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31208
31209 for (address = start; address <= end; address += PGDIR_SIZE) {
31210 const pgd_t *pgd_ref = pgd_offset_k(address);
31211 +
31212 +#ifdef CONFIG_PAX_PER_CPU_PGD
31213 + unsigned long cpu;
31214 +#else
31215 struct page *page;
31216 +#endif
31217
31218 if (pgd_none(*pgd_ref))
31219 continue;
31220
31221 spin_lock(&pgd_lock);
31222 +
31223 +#ifdef CONFIG_PAX_PER_CPU_PGD
31224 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31225 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31226 +
31227 + if (pgd_none(*pgd))
31228 + set_pgd(pgd, *pgd_ref);
31229 + else
31230 + BUG_ON(pgd_page_vaddr(*pgd)
31231 + != pgd_page_vaddr(*pgd_ref));
31232 + pgd = pgd_offset_cpu(cpu, kernel, address);
31233 +#else
31234 list_for_each_entry(page, &pgd_list, lru) {
31235 pgd_t *pgd;
31236 spinlock_t *pgt_lock;
31237 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31238 /* the pgt_lock only for Xen */
31239 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31240 spin_lock(pgt_lock);
31241 +#endif
31242
31243 if (pgd_none(*pgd))
31244 set_pgd(pgd, *pgd_ref);
31245 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31246 BUG_ON(pgd_page_vaddr(*pgd)
31247 != pgd_page_vaddr(*pgd_ref));
31248
31249 +#ifndef CONFIG_PAX_PER_CPU_PGD
31250 spin_unlock(pgt_lock);
31251 +#endif
31252 +
31253 }
31254 spin_unlock(&pgd_lock);
31255 }
31256 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31257 {
31258 if (pgd_none(*pgd)) {
31259 pud_t *pud = (pud_t *)spp_getpage();
31260 - pgd_populate(&init_mm, pgd, pud);
31261 + pgd_populate_kernel(&init_mm, pgd, pud);
31262 if (pud != pud_offset(pgd, 0))
31263 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31264 pud, pud_offset(pgd, 0));
31265 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31266 {
31267 if (pud_none(*pud)) {
31268 pmd_t *pmd = (pmd_t *) spp_getpage();
31269 - pud_populate(&init_mm, pud, pmd);
31270 + pud_populate_kernel(&init_mm, pud, pmd);
31271 if (pmd != pmd_offset(pud, 0))
31272 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31273 pmd, pmd_offset(pud, 0));
31274 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31275 pmd = fill_pmd(pud, vaddr);
31276 pte = fill_pte(pmd, vaddr);
31277
31278 + pax_open_kernel();
31279 set_pte(pte, new_pte);
31280 + pax_close_kernel();
31281
31282 /*
31283 * It's enough to flush this one mapping.
31284 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31285 pgd = pgd_offset_k((unsigned long)__va(phys));
31286 if (pgd_none(*pgd)) {
31287 pud = (pud_t *) spp_getpage();
31288 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31289 - _PAGE_USER));
31290 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31291 }
31292 pud = pud_offset(pgd, (unsigned long)__va(phys));
31293 if (pud_none(*pud)) {
31294 pmd = (pmd_t *) spp_getpage();
31295 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31296 - _PAGE_USER));
31297 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31298 }
31299 pmd = pmd_offset(pud, phys);
31300 BUG_ON(!pmd_none(*pmd));
31301 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31302 prot);
31303
31304 spin_lock(&init_mm.page_table_lock);
31305 - pud_populate(&init_mm, pud, pmd);
31306 + pud_populate_kernel(&init_mm, pud, pmd);
31307 spin_unlock(&init_mm.page_table_lock);
31308 }
31309 __flush_tlb_all();
31310 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31311 page_size_mask);
31312
31313 spin_lock(&init_mm.page_table_lock);
31314 - pgd_populate(&init_mm, pgd, pud);
31315 + pgd_populate_kernel(&init_mm, pgd, pud);
31316 spin_unlock(&init_mm.page_table_lock);
31317 pgd_changed = true;
31318 }
31319 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31320 static struct vm_area_struct gate_vma = {
31321 .vm_start = VSYSCALL_START,
31322 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31323 - .vm_page_prot = PAGE_READONLY_EXEC,
31324 - .vm_flags = VM_READ | VM_EXEC
31325 + .vm_page_prot = PAGE_READONLY,
31326 + .vm_flags = VM_READ
31327 };
31328
31329 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31330 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31331
31332 const char *arch_vma_name(struct vm_area_struct *vma)
31333 {
31334 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31335 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31336 return "[vdso]";
31337 if (vma == &gate_vma)
31338 return "[vsyscall]";
31339 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31340 index 7b179b4..6bd17777 100644
31341 --- a/arch/x86/mm/iomap_32.c
31342 +++ b/arch/x86/mm/iomap_32.c
31343 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31344 type = kmap_atomic_idx_push();
31345 idx = type + KM_TYPE_NR * smp_processor_id();
31346 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31347 +
31348 + pax_open_kernel();
31349 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31350 + pax_close_kernel();
31351 +
31352 arch_flush_lazy_mmu_mode();
31353
31354 return (void *)vaddr;
31355 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31356 index 0215e2c..1c62dab 100644
31357 --- a/arch/x86/mm/ioremap.c
31358 +++ b/arch/x86/mm/ioremap.c
31359 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31360 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31361 int is_ram = page_is_ram(pfn);
31362
31363 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31364 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31365 return NULL;
31366 WARN_ON_ONCE(is_ram);
31367 }
31368 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31369 *
31370 * Caller must ensure there is only one unmapping for the same pointer.
31371 */
31372 -void iounmap(volatile void __iomem *addr)
31373 +void iounmap(const volatile void __iomem *addr)
31374 {
31375 struct vm_struct *p, *o;
31376
31377 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31378
31379 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31380 if (page_is_ram(start >> PAGE_SHIFT))
31381 +#ifdef CONFIG_HIGHMEM
31382 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31383 +#endif
31384 return __va(phys);
31385
31386 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31387 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31388 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31389 {
31390 if (page_is_ram(phys >> PAGE_SHIFT))
31391 +#ifdef CONFIG_HIGHMEM
31392 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31393 +#endif
31394 return;
31395
31396 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31397 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31398 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31399
31400 static __initdata int after_paging_init;
31401 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31402 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31403
31404 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31405 {
31406 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31407 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31408
31409 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31410 - memset(bm_pte, 0, sizeof(bm_pte));
31411 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31412 + pmd_populate_user(&init_mm, pmd, bm_pte);
31413
31414 /*
31415 * The boot-ioremap range spans multiple pmds, for which
31416 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31417 index d87dd6d..bf3fa66 100644
31418 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31419 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31420 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31421 * memory (e.g. tracked pages)? For now, we need this to avoid
31422 * invoking kmemcheck for PnP BIOS calls.
31423 */
31424 - if (regs->flags & X86_VM_MASK)
31425 + if (v8086_mode(regs))
31426 return false;
31427 - if (regs->cs != __KERNEL_CS)
31428 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31429 return false;
31430
31431 pte = kmemcheck_pte_lookup(address);
31432 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31433 index 25e7e13..1964579 100644
31434 --- a/arch/x86/mm/mmap.c
31435 +++ b/arch/x86/mm/mmap.c
31436 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31437 * Leave an at least ~128 MB hole with possible stack randomization.
31438 */
31439 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31440 -#define MAX_GAP (TASK_SIZE/6*5)
31441 +#define MAX_GAP (pax_task_size/6*5)
31442
31443 static int mmap_is_legacy(void)
31444 {
31445 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31446 return rnd << PAGE_SHIFT;
31447 }
31448
31449 -static unsigned long mmap_base(void)
31450 +static unsigned long mmap_base(struct mm_struct *mm)
31451 {
31452 unsigned long gap = rlimit(RLIMIT_STACK);
31453 + unsigned long pax_task_size = TASK_SIZE;
31454 +
31455 +#ifdef CONFIG_PAX_SEGMEXEC
31456 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31457 + pax_task_size = SEGMEXEC_TASK_SIZE;
31458 +#endif
31459
31460 if (gap < MIN_GAP)
31461 gap = MIN_GAP;
31462 else if (gap > MAX_GAP)
31463 gap = MAX_GAP;
31464
31465 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31466 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31467 }
31468
31469 /*
31470 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31471 * does, but not when emulating X86_32
31472 */
31473 -static unsigned long mmap_legacy_base(void)
31474 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31475 {
31476 - if (mmap_is_ia32())
31477 + if (mmap_is_ia32()) {
31478 +
31479 +#ifdef CONFIG_PAX_SEGMEXEC
31480 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31481 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31482 + else
31483 +#endif
31484 +
31485 return TASK_UNMAPPED_BASE;
31486 - else
31487 + } else
31488 return TASK_UNMAPPED_BASE + mmap_rnd();
31489 }
31490
31491 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31492 */
31493 void arch_pick_mmap_layout(struct mm_struct *mm)
31494 {
31495 - mm->mmap_legacy_base = mmap_legacy_base();
31496 - mm->mmap_base = mmap_base();
31497 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31498 + mm->mmap_base = mmap_base(mm);
31499 +
31500 +#ifdef CONFIG_PAX_RANDMMAP
31501 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31502 + mm->mmap_legacy_base += mm->delta_mmap;
31503 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31504 + }
31505 +#endif
31506
31507 if (mmap_is_legacy()) {
31508 mm->mmap_base = mm->mmap_legacy_base;
31509 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31510 index 0057a7a..95c7edd 100644
31511 --- a/arch/x86/mm/mmio-mod.c
31512 +++ b/arch/x86/mm/mmio-mod.c
31513 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31514 break;
31515 default:
31516 {
31517 - unsigned char *ip = (unsigned char *)instptr;
31518 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31519 my_trace->opcode = MMIO_UNKNOWN_OP;
31520 my_trace->width = 0;
31521 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31522 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31523 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31524 void __iomem *addr)
31525 {
31526 - static atomic_t next_id;
31527 + static atomic_unchecked_t next_id;
31528 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31529 /* These are page-unaligned. */
31530 struct mmiotrace_map map = {
31531 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31532 .private = trace
31533 },
31534 .phys = offset,
31535 - .id = atomic_inc_return(&next_id)
31536 + .id = atomic_inc_return_unchecked(&next_id)
31537 };
31538 map.map_id = trace->id;
31539
31540 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31541 ioremap_trace_core(offset, size, addr);
31542 }
31543
31544 -static void iounmap_trace_core(volatile void __iomem *addr)
31545 +static void iounmap_trace_core(const volatile void __iomem *addr)
31546 {
31547 struct mmiotrace_map map = {
31548 .phys = 0,
31549 @@ -328,7 +328,7 @@ not_enabled:
31550 }
31551 }
31552
31553 -void mmiotrace_iounmap(volatile void __iomem *addr)
31554 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31555 {
31556 might_sleep();
31557 if (is_enabled()) /* recheck and proper locking in *_core() */
31558 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31559 index 8bf93ba..dbcd670 100644
31560 --- a/arch/x86/mm/numa.c
31561 +++ b/arch/x86/mm/numa.c
31562 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31563 return true;
31564 }
31565
31566 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31567 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31568 {
31569 unsigned long uninitialized_var(pfn_align);
31570 int i, nid;
31571 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31572 index d0b1773..4c3327c 100644
31573 --- a/arch/x86/mm/pageattr-test.c
31574 +++ b/arch/x86/mm/pageattr-test.c
31575 @@ -36,7 +36,7 @@ enum {
31576
31577 static int pte_testbit(pte_t pte)
31578 {
31579 - return pte_flags(pte) & _PAGE_UNUSED1;
31580 + return pte_flags(pte) & _PAGE_CPA_TEST;
31581 }
31582
31583 struct split_state {
31584 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31585 index bb32480..75f2f5e 100644
31586 --- a/arch/x86/mm/pageattr.c
31587 +++ b/arch/x86/mm/pageattr.c
31588 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31589 */
31590 #ifdef CONFIG_PCI_BIOS
31591 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31592 - pgprot_val(forbidden) |= _PAGE_NX;
31593 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31594 #endif
31595
31596 /*
31597 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31598 * Does not cover __inittext since that is gone later on. On
31599 * 64bit we do not enforce !NX on the low mapping
31600 */
31601 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31602 - pgprot_val(forbidden) |= _PAGE_NX;
31603 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31604 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31605
31606 +#ifdef CONFIG_DEBUG_RODATA
31607 /*
31608 * The .rodata section needs to be read-only. Using the pfn
31609 * catches all aliases.
31610 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31611 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31612 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31613 pgprot_val(forbidden) |= _PAGE_RW;
31614 +#endif
31615
31616 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31617 /*
31618 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31619 }
31620 #endif
31621
31622 +#ifdef CONFIG_PAX_KERNEXEC
31623 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31624 + pgprot_val(forbidden) |= _PAGE_RW;
31625 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31626 + }
31627 +#endif
31628 +
31629 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31630
31631 return prot;
31632 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31633 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31634 {
31635 /* change init_mm */
31636 + pax_open_kernel();
31637 set_pte_atomic(kpte, pte);
31638 +
31639 #ifdef CONFIG_X86_32
31640 if (!SHARED_KERNEL_PMD) {
31641 +
31642 +#ifdef CONFIG_PAX_PER_CPU_PGD
31643 + unsigned long cpu;
31644 +#else
31645 struct page *page;
31646 +#endif
31647
31648 +#ifdef CONFIG_PAX_PER_CPU_PGD
31649 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31650 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31651 +#else
31652 list_for_each_entry(page, &pgd_list, lru) {
31653 - pgd_t *pgd;
31654 + pgd_t *pgd = (pgd_t *)page_address(page);
31655 +#endif
31656 +
31657 pud_t *pud;
31658 pmd_t *pmd;
31659
31660 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31661 + pgd += pgd_index(address);
31662 pud = pud_offset(pgd, address);
31663 pmd = pmd_offset(pud, address);
31664 set_pte_atomic((pte_t *)pmd, pte);
31665 }
31666 }
31667 #endif
31668 + pax_close_kernel();
31669 }
31670
31671 static int
31672 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31673 index 6574388..87e9bef 100644
31674 --- a/arch/x86/mm/pat.c
31675 +++ b/arch/x86/mm/pat.c
31676 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31677
31678 if (!entry) {
31679 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31680 - current->comm, current->pid, start, end - 1);
31681 + current->comm, task_pid_nr(current), start, end - 1);
31682 return -EINVAL;
31683 }
31684
31685 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31686
31687 while (cursor < to) {
31688 if (!devmem_is_allowed(pfn)) {
31689 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31690 - current->comm, from, to - 1);
31691 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31692 + current->comm, from, to - 1, cursor);
31693 return 0;
31694 }
31695 cursor += PAGE_SIZE;
31696 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31697 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31698 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31699 "for [mem %#010Lx-%#010Lx]\n",
31700 - current->comm, current->pid,
31701 + current->comm, task_pid_nr(current),
31702 cattr_name(flags),
31703 base, (unsigned long long)(base + size-1));
31704 return -EINVAL;
31705 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31706 flags = lookup_memtype(paddr);
31707 if (want_flags != flags) {
31708 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31709 - current->comm, current->pid,
31710 + current->comm, task_pid_nr(current),
31711 cattr_name(want_flags),
31712 (unsigned long long)paddr,
31713 (unsigned long long)(paddr + size - 1),
31714 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31715 free_memtype(paddr, paddr + size);
31716 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31717 " for [mem %#010Lx-%#010Lx], got %s\n",
31718 - current->comm, current->pid,
31719 + current->comm, task_pid_nr(current),
31720 cattr_name(want_flags),
31721 (unsigned long long)paddr,
31722 (unsigned long long)(paddr + size - 1),
31723 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31724 index 415f6c4..d319983 100644
31725 --- a/arch/x86/mm/pat_rbtree.c
31726 +++ b/arch/x86/mm/pat_rbtree.c
31727 @@ -160,7 +160,7 @@ success:
31728
31729 failure:
31730 printk(KERN_INFO "%s:%d conflicting memory types "
31731 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31732 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31733 end, cattr_name(found_type), cattr_name(match->type));
31734 return -EBUSY;
31735 }
31736 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31737 index 9f0614d..92ae64a 100644
31738 --- a/arch/x86/mm/pf_in.c
31739 +++ b/arch/x86/mm/pf_in.c
31740 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31741 int i;
31742 enum reason_type rv = OTHERS;
31743
31744 - p = (unsigned char *)ins_addr;
31745 + p = (unsigned char *)ktla_ktva(ins_addr);
31746 p += skip_prefix(p, &prf);
31747 p += get_opcode(p, &opcode);
31748
31749 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31750 struct prefix_bits prf;
31751 int i;
31752
31753 - p = (unsigned char *)ins_addr;
31754 + p = (unsigned char *)ktla_ktva(ins_addr);
31755 p += skip_prefix(p, &prf);
31756 p += get_opcode(p, &opcode);
31757
31758 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31759 struct prefix_bits prf;
31760 int i;
31761
31762 - p = (unsigned char *)ins_addr;
31763 + p = (unsigned char *)ktla_ktva(ins_addr);
31764 p += skip_prefix(p, &prf);
31765 p += get_opcode(p, &opcode);
31766
31767 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31768 struct prefix_bits prf;
31769 int i;
31770
31771 - p = (unsigned char *)ins_addr;
31772 + p = (unsigned char *)ktla_ktva(ins_addr);
31773 p += skip_prefix(p, &prf);
31774 p += get_opcode(p, &opcode);
31775 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31776 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31777 struct prefix_bits prf;
31778 int i;
31779
31780 - p = (unsigned char *)ins_addr;
31781 + p = (unsigned char *)ktla_ktva(ins_addr);
31782 p += skip_prefix(p, &prf);
31783 p += get_opcode(p, &opcode);
31784 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31785 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31786 index dfa537a..fd45c64 100644
31787 --- a/arch/x86/mm/pgtable.c
31788 +++ b/arch/x86/mm/pgtable.c
31789 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31790 list_del(&page->lru);
31791 }
31792
31793 -#define UNSHARED_PTRS_PER_PGD \
31794 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31795 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31796 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31797
31798 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31799 +{
31800 + unsigned int count = USER_PGD_PTRS;
31801
31802 + if (!pax_user_shadow_base)
31803 + return;
31804 +
31805 + while (count--)
31806 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31807 +}
31808 +#endif
31809 +
31810 +#ifdef CONFIG_PAX_PER_CPU_PGD
31811 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31812 +{
31813 + unsigned int count = USER_PGD_PTRS;
31814 +
31815 + while (count--) {
31816 + pgd_t pgd;
31817 +
31818 +#ifdef CONFIG_X86_64
31819 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31820 +#else
31821 + pgd = *src++;
31822 +#endif
31823 +
31824 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31825 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31826 +#endif
31827 +
31828 + *dst++ = pgd;
31829 + }
31830 +
31831 +}
31832 +#endif
31833 +
31834 +#ifdef CONFIG_X86_64
31835 +#define pxd_t pud_t
31836 +#define pyd_t pgd_t
31837 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31838 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31839 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31840 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31841 +#define PYD_SIZE PGDIR_SIZE
31842 +#else
31843 +#define pxd_t pmd_t
31844 +#define pyd_t pud_t
31845 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31846 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31847 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31848 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31849 +#define PYD_SIZE PUD_SIZE
31850 +#endif
31851 +
31852 +#ifdef CONFIG_PAX_PER_CPU_PGD
31853 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31854 +static inline void pgd_dtor(pgd_t *pgd) {}
31855 +#else
31856 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31857 {
31858 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31859 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31860 pgd_list_del(pgd);
31861 spin_unlock(&pgd_lock);
31862 }
31863 +#endif
31864
31865 /*
31866 * List of all pgd's needed for non-PAE so it can invalidate entries
31867 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31868 * -- nyc
31869 */
31870
31871 -#ifdef CONFIG_X86_PAE
31872 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31873 /*
31874 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31875 * updating the top-level pagetable entries to guarantee the
31876 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31877 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31878 * and initialize the kernel pmds here.
31879 */
31880 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31881 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31882
31883 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31884 {
31885 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31886 */
31887 flush_tlb_mm(mm);
31888 }
31889 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31890 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31891 #else /* !CONFIG_X86_PAE */
31892
31893 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31894 -#define PREALLOCATED_PMDS 0
31895 +#define PREALLOCATED_PXDS 0
31896
31897 #endif /* CONFIG_X86_PAE */
31898
31899 -static void free_pmds(pmd_t *pmds[])
31900 +static void free_pxds(pxd_t *pxds[])
31901 {
31902 int i;
31903
31904 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31905 - if (pmds[i])
31906 - free_page((unsigned long)pmds[i]);
31907 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31908 + if (pxds[i])
31909 + free_page((unsigned long)pxds[i]);
31910 }
31911
31912 -static int preallocate_pmds(pmd_t *pmds[])
31913 +static int preallocate_pxds(pxd_t *pxds[])
31914 {
31915 int i;
31916 bool failed = false;
31917
31918 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31919 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31920 - if (pmd == NULL)
31921 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31922 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31923 + if (pxd == NULL)
31924 failed = true;
31925 - pmds[i] = pmd;
31926 + pxds[i] = pxd;
31927 }
31928
31929 if (failed) {
31930 - free_pmds(pmds);
31931 + free_pxds(pxds);
31932 return -ENOMEM;
31933 }
31934
31935 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31936 * preallocate which never got a corresponding vma will need to be
31937 * freed manually.
31938 */
31939 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31940 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31941 {
31942 int i;
31943
31944 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31945 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31946 pgd_t pgd = pgdp[i];
31947
31948 if (pgd_val(pgd) != 0) {
31949 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31950 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31951
31952 - pgdp[i] = native_make_pgd(0);
31953 + set_pgd(pgdp + i, native_make_pgd(0));
31954
31955 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31956 - pmd_free(mm, pmd);
31957 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31958 + pxd_free(mm, pxd);
31959 }
31960 }
31961 }
31962
31963 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31964 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31965 {
31966 - pud_t *pud;
31967 + pyd_t *pyd;
31968 int i;
31969
31970 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31971 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31972 return;
31973
31974 - pud = pud_offset(pgd, 0);
31975 -
31976 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
31977 - pmd_t *pmd = pmds[i];
31978 +#ifdef CONFIG_X86_64
31979 + pyd = pyd_offset(mm, 0L);
31980 +#else
31981 + pyd = pyd_offset(pgd, 0L);
31982 +#endif
31983
31984 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
31985 + pxd_t *pxd = pxds[i];
31986 if (i >= KERNEL_PGD_BOUNDARY)
31987 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31988 - sizeof(pmd_t) * PTRS_PER_PMD);
31989 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31990 + sizeof(pxd_t) * PTRS_PER_PMD);
31991
31992 - pud_populate(mm, pud, pmd);
31993 + pyd_populate(mm, pyd, pxd);
31994 }
31995 }
31996
31997 pgd_t *pgd_alloc(struct mm_struct *mm)
31998 {
31999 pgd_t *pgd;
32000 - pmd_t *pmds[PREALLOCATED_PMDS];
32001 + pxd_t *pxds[PREALLOCATED_PXDS];
32002
32003 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32004
32005 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32006
32007 mm->pgd = pgd;
32008
32009 - if (preallocate_pmds(pmds) != 0)
32010 + if (preallocate_pxds(pxds) != 0)
32011 goto out_free_pgd;
32012
32013 if (paravirt_pgd_alloc(mm) != 0)
32014 - goto out_free_pmds;
32015 + goto out_free_pxds;
32016
32017 /*
32018 * Make sure that pre-populating the pmds is atomic with
32019 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32020 spin_lock(&pgd_lock);
32021
32022 pgd_ctor(mm, pgd);
32023 - pgd_prepopulate_pmd(mm, pgd, pmds);
32024 + pgd_prepopulate_pxd(mm, pgd, pxds);
32025
32026 spin_unlock(&pgd_lock);
32027
32028 return pgd;
32029
32030 -out_free_pmds:
32031 - free_pmds(pmds);
32032 +out_free_pxds:
32033 + free_pxds(pxds);
32034 out_free_pgd:
32035 free_page((unsigned long)pgd);
32036 out:
32037 @@ -300,7 +363,7 @@ out:
32038
32039 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32040 {
32041 - pgd_mop_up_pmds(mm, pgd);
32042 + pgd_mop_up_pxds(mm, pgd);
32043 pgd_dtor(pgd);
32044 paravirt_pgd_free(mm, pgd);
32045 free_page((unsigned long)pgd);
32046 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32047 index a69bcb8..19068ab 100644
32048 --- a/arch/x86/mm/pgtable_32.c
32049 +++ b/arch/x86/mm/pgtable_32.c
32050 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32051 return;
32052 }
32053 pte = pte_offset_kernel(pmd, vaddr);
32054 +
32055 + pax_open_kernel();
32056 if (pte_val(pteval))
32057 set_pte_at(&init_mm, vaddr, pte, pteval);
32058 else
32059 pte_clear(&init_mm, vaddr, pte);
32060 + pax_close_kernel();
32061
32062 /*
32063 * It's enough to flush this one mapping.
32064 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32065 index e666cbb..61788c45 100644
32066 --- a/arch/x86/mm/physaddr.c
32067 +++ b/arch/x86/mm/physaddr.c
32068 @@ -10,7 +10,7 @@
32069 #ifdef CONFIG_X86_64
32070
32071 #ifdef CONFIG_DEBUG_VIRTUAL
32072 -unsigned long __phys_addr(unsigned long x)
32073 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32074 {
32075 unsigned long y = x - __START_KERNEL_map;
32076
32077 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32078 #else
32079
32080 #ifdef CONFIG_DEBUG_VIRTUAL
32081 -unsigned long __phys_addr(unsigned long x)
32082 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32083 {
32084 unsigned long phys_addr = x - PAGE_OFFSET;
32085 /* VMALLOC_* aren't constants */
32086 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32087 index 90555bf..f5f1828 100644
32088 --- a/arch/x86/mm/setup_nx.c
32089 +++ b/arch/x86/mm/setup_nx.c
32090 @@ -5,8 +5,10 @@
32091 #include <asm/pgtable.h>
32092 #include <asm/proto.h>
32093
32094 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32095 static int disable_nx;
32096
32097 +#ifndef CONFIG_PAX_PAGEEXEC
32098 /*
32099 * noexec = on|off
32100 *
32101 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32102 return 0;
32103 }
32104 early_param("noexec", noexec_setup);
32105 +#endif
32106 +
32107 +#endif
32108
32109 void x86_configure_nx(void)
32110 {
32111 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32112 if (cpu_has_nx && !disable_nx)
32113 __supported_pte_mask |= _PAGE_NX;
32114 else
32115 +#endif
32116 __supported_pte_mask &= ~_PAGE_NX;
32117 }
32118
32119 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32120 index 282375f..e03a98f 100644
32121 --- a/arch/x86/mm/tlb.c
32122 +++ b/arch/x86/mm/tlb.c
32123 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32124 BUG();
32125 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32126 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32127 +
32128 +#ifndef CONFIG_PAX_PER_CPU_PGD
32129 load_cr3(swapper_pg_dir);
32130 +#endif
32131 +
32132 }
32133 }
32134 EXPORT_SYMBOL_GPL(leave_mm);
32135 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32136 new file mode 100644
32137 index 0000000..dace51c
32138 --- /dev/null
32139 +++ b/arch/x86/mm/uderef_64.c
32140 @@ -0,0 +1,37 @@
32141 +#include <linux/mm.h>
32142 +#include <asm/pgtable.h>
32143 +#include <asm/uaccess.h>
32144 +
32145 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32146 +/* PaX: due to the special call convention these functions must
32147 + * - remain leaf functions under all configurations,
32148 + * - never be called directly, only dereferenced from the wrappers.
32149 + */
32150 +void __pax_open_userland(void)
32151 +{
32152 + unsigned int cpu;
32153 +
32154 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32155 + return;
32156 +
32157 + cpu = raw_get_cpu();
32158 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32159 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32160 + raw_put_cpu_no_resched();
32161 +}
32162 +EXPORT_SYMBOL(__pax_open_userland);
32163 +
32164 +void __pax_close_userland(void)
32165 +{
32166 + unsigned int cpu;
32167 +
32168 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32169 + return;
32170 +
32171 + cpu = raw_get_cpu();
32172 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32173 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32174 + raw_put_cpu_no_resched();
32175 +}
32176 +EXPORT_SYMBOL(__pax_close_userland);
32177 +#endif
32178 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32179 index 877b9a1..a8ecf42 100644
32180 --- a/arch/x86/net/bpf_jit.S
32181 +++ b/arch/x86/net/bpf_jit.S
32182 @@ -9,6 +9,7 @@
32183 */
32184 #include <linux/linkage.h>
32185 #include <asm/dwarf2.h>
32186 +#include <asm/alternative-asm.h>
32187
32188 /*
32189 * Calling convention :
32190 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32191 jle bpf_slow_path_word
32192 mov (SKBDATA,%rsi),%eax
32193 bswap %eax /* ntohl() */
32194 + pax_force_retaddr
32195 ret
32196
32197 sk_load_half:
32198 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32199 jle bpf_slow_path_half
32200 movzwl (SKBDATA,%rsi),%eax
32201 rol $8,%ax # ntohs()
32202 + pax_force_retaddr
32203 ret
32204
32205 sk_load_byte:
32206 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32207 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32208 jle bpf_slow_path_byte
32209 movzbl (SKBDATA,%rsi),%eax
32210 + pax_force_retaddr
32211 ret
32212
32213 /**
32214 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32215 movzbl (SKBDATA,%rsi),%ebx
32216 and $15,%bl
32217 shl $2,%bl
32218 + pax_force_retaddr
32219 ret
32220
32221 /* rsi contains offset and can be scratched */
32222 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32223 js bpf_error
32224 mov -12(%rbp),%eax
32225 bswap %eax
32226 + pax_force_retaddr
32227 ret
32228
32229 bpf_slow_path_half:
32230 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32231 mov -12(%rbp),%ax
32232 rol $8,%ax
32233 movzwl %ax,%eax
32234 + pax_force_retaddr
32235 ret
32236
32237 bpf_slow_path_byte:
32238 bpf_slow_path_common(1)
32239 js bpf_error
32240 movzbl -12(%rbp),%eax
32241 + pax_force_retaddr
32242 ret
32243
32244 bpf_slow_path_byte_msh:
32245 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32246 and $15,%al
32247 shl $2,%al
32248 xchg %eax,%ebx
32249 + pax_force_retaddr
32250 ret
32251
32252 #define sk_negative_common(SIZE) \
32253 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32254 sk_negative_common(4)
32255 mov (%rax), %eax
32256 bswap %eax
32257 + pax_force_retaddr
32258 ret
32259
32260 bpf_slow_path_half_neg:
32261 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32262 mov (%rax),%ax
32263 rol $8,%ax
32264 movzwl %ax,%eax
32265 + pax_force_retaddr
32266 ret
32267
32268 bpf_slow_path_byte_neg:
32269 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32270 .globl sk_load_byte_negative_offset
32271 sk_negative_common(1)
32272 movzbl (%rax), %eax
32273 + pax_force_retaddr
32274 ret
32275
32276 bpf_slow_path_byte_msh_neg:
32277 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32278 and $15,%al
32279 shl $2,%al
32280 xchg %eax,%ebx
32281 + pax_force_retaddr
32282 ret
32283
32284 bpf_error:
32285 @@ -197,4 +210,5 @@ bpf_error:
32286 xor %eax,%eax
32287 mov -8(%rbp),%rbx
32288 leaveq
32289 + pax_force_retaddr
32290 ret
32291 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32292 index 79c216a..08d39cc 100644
32293 --- a/arch/x86/net/bpf_jit_comp.c
32294 +++ b/arch/x86/net/bpf_jit_comp.c
32295 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32296 return ptr + len;
32297 }
32298
32299 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32300 +#define MAX_INSTR_CODE_SIZE 96
32301 +#else
32302 +#define MAX_INSTR_CODE_SIZE 64
32303 +#endif
32304 +
32305 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32306
32307 #define EMIT1(b1) EMIT(b1, 1)
32308 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32309 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32310 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32311 +
32312 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32313 +/* original constant will appear in ecx */
32314 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32315 +do { \
32316 + /* mov ecx, randkey */ \
32317 + EMIT1(0xb9); \
32318 + EMIT(_key, 4); \
32319 + /* xor ecx, randkey ^ off */ \
32320 + EMIT2(0x81, 0xf1); \
32321 + EMIT((_key) ^ (_off), 4); \
32322 +} while (0)
32323 +
32324 +#define EMIT1_off32(b1, _off) \
32325 +do { \
32326 + switch (b1) { \
32327 + case 0x05: /* add eax, imm32 */ \
32328 + case 0x2d: /* sub eax, imm32 */ \
32329 + case 0x25: /* and eax, imm32 */ \
32330 + case 0x0d: /* or eax, imm32 */ \
32331 + case 0xb8: /* mov eax, imm32 */ \
32332 + case 0x35: /* xor eax, imm32 */ \
32333 + case 0x3d: /* cmp eax, imm32 */ \
32334 + case 0xa9: /* test eax, imm32 */ \
32335 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32336 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32337 + break; \
32338 + case 0xbb: /* mov ebx, imm32 */ \
32339 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32340 + /* mov ebx, ecx */ \
32341 + EMIT2(0x89, 0xcb); \
32342 + break; \
32343 + case 0xbe: /* mov esi, imm32 */ \
32344 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32345 + /* mov esi, ecx */ \
32346 + EMIT2(0x89, 0xce); \
32347 + break; \
32348 + case 0xe8: /* call rel imm32, always to known funcs */ \
32349 + EMIT1(b1); \
32350 + EMIT(_off, 4); \
32351 + break; \
32352 + case 0xe9: /* jmp rel imm32 */ \
32353 + EMIT1(b1); \
32354 + EMIT(_off, 4); \
32355 + /* prevent fall-through, we're not called if off = 0 */ \
32356 + EMIT(0xcccccccc, 4); \
32357 + EMIT(0xcccccccc, 4); \
32358 + break; \
32359 + default: \
32360 + BUILD_BUG(); \
32361 + } \
32362 +} while (0)
32363 +
32364 +#define EMIT2_off32(b1, b2, _off) \
32365 +do { \
32366 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32367 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32368 + EMIT(randkey, 4); \
32369 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32370 + EMIT((_off) - randkey, 4); \
32371 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32372 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32373 + /* imul eax, ecx */ \
32374 + EMIT3(0x0f, 0xaf, 0xc1); \
32375 + } else { \
32376 + BUILD_BUG(); \
32377 + } \
32378 +} while (0)
32379 +#else
32380 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32381 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32382 +#endif
32383
32384 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32385 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32386 @@ -91,6 +168,24 @@ do { \
32387 #define X86_JBE 0x76
32388 #define X86_JA 0x77
32389
32390 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32391 +#define APPEND_FLOW_VERIFY() \
32392 +do { \
32393 + /* mov ecx, randkey */ \
32394 + EMIT1(0xb9); \
32395 + EMIT(randkey, 4); \
32396 + /* cmp ecx, randkey */ \
32397 + EMIT2(0x81, 0xf9); \
32398 + EMIT(randkey, 4); \
32399 + /* jz after 8 int 3s */ \
32400 + EMIT2(0x74, 0x08); \
32401 + EMIT(0xcccccccc, 4); \
32402 + EMIT(0xcccccccc, 4); \
32403 +} while (0)
32404 +#else
32405 +#define APPEND_FLOW_VERIFY() do { } while (0)
32406 +#endif
32407 +
32408 #define EMIT_COND_JMP(op, offset) \
32409 do { \
32410 if (is_near(offset)) \
32411 @@ -98,6 +193,7 @@ do { \
32412 else { \
32413 EMIT2(0x0f, op + 0x10); \
32414 EMIT(offset, 4); /* jxx .+off32 */ \
32415 + APPEND_FLOW_VERIFY(); \
32416 } \
32417 } while (0)
32418
32419 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32420 return -1;
32421 }
32422
32423 -struct bpf_binary_header {
32424 - unsigned int pages;
32425 - /* Note : for security reasons, bpf code will follow a randomly
32426 - * sized amount of int3 instructions
32427 - */
32428 - u8 image[];
32429 -};
32430 -
32431 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32432 +/* Note : for security reasons, bpf code will follow a randomly
32433 + * sized amount of int3 instructions
32434 + */
32435 +static u8 *bpf_alloc_binary(unsigned int proglen,
32436 u8 **image_ptr)
32437 {
32438 unsigned int sz, hole;
32439 - struct bpf_binary_header *header;
32440 + u8 *header;
32441
32442 /* Most of BPF filters are really small,
32443 * but if some of them fill a page, allow at least
32444 * 128 extra bytes to insert a random section of int3
32445 */
32446 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32447 - header = module_alloc(sz);
32448 + sz = round_up(proglen + 128, PAGE_SIZE);
32449 + header = module_alloc_exec(sz);
32450 if (!header)
32451 return NULL;
32452
32453 + pax_open_kernel();
32454 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32455 + pax_close_kernel();
32456
32457 - header->pages = sz / PAGE_SIZE;
32458 - hole = sz - (proglen + sizeof(*header));
32459 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32460
32461 /* insert a random number of int3 instructions before BPF code */
32462 - *image_ptr = &header->image[prandom_u32() % hole];
32463 + *image_ptr = &header[prandom_u32() % hole];
32464 return header;
32465 }
32466
32467 void bpf_jit_compile(struct sk_filter *fp)
32468 {
32469 - u8 temp[64];
32470 + u8 temp[MAX_INSTR_CODE_SIZE];
32471 u8 *prog;
32472 unsigned int proglen, oldproglen = 0;
32473 int ilen, i;
32474 int t_offset, f_offset;
32475 u8 t_op, f_op, seen = 0, pass;
32476 u8 *image = NULL;
32477 - struct bpf_binary_header *header = NULL;
32478 + u8 *header = NULL;
32479 u8 *func;
32480 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32481 unsigned int cleanup_addr; /* epilogue code offset */
32482 unsigned int *addrs;
32483 const struct sock_filter *filter = fp->insns;
32484 int flen = fp->len;
32485 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32486 + unsigned int randkey;
32487 +#endif
32488
32489 if (!bpf_jit_enable)
32490 return;
32491 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32492 if (addrs == NULL)
32493 return;
32494
32495 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32496 + randkey = get_random_int();
32497 +#endif
32498 +
32499 /* Before first pass, make a rough estimation of addrs[]
32500 - * each bpf instruction is translated to less than 64 bytes
32501 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32502 */
32503 for (proglen = 0, i = 0; i < flen; i++) {
32504 - proglen += 64;
32505 + proglen += MAX_INSTR_CODE_SIZE;
32506 addrs[i] = proglen;
32507 }
32508 cleanup_addr = proglen; /* epilogue address */
32509 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32510 case BPF_S_ALU_MUL_K: /* A *= K */
32511 if (is_imm8(K))
32512 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32513 - else {
32514 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32515 - EMIT(K, 4);
32516 - }
32517 + else
32518 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32519 break;
32520 case BPF_S_ALU_DIV_X: /* A /= X; */
32521 seen |= SEEN_XREG;
32522 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32523 break;
32524 case BPF_S_ALU_MOD_K: /* A %= K; */
32525 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32526 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32527 + DILUTE_CONST_SEQUENCE(K, randkey);
32528 +#else
32529 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32530 +#endif
32531 EMIT2(0xf7, 0xf1); /* div %ecx */
32532 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32533 break;
32534 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32535 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32536 + DILUTE_CONST_SEQUENCE(K, randkey);
32537 + // imul rax, rcx
32538 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32539 +#else
32540 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32541 EMIT(K, 4);
32542 +#endif
32543 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32544 break;
32545 case BPF_S_ALU_AND_X:
32546 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32547 if (is_imm8(K)) {
32548 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32549 } else {
32550 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32551 - EMIT(K, 4);
32552 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32553 }
32554 } else {
32555 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32556 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32557 if (unlikely(proglen + ilen > oldproglen)) {
32558 pr_err("bpb_jit_compile fatal error\n");
32559 kfree(addrs);
32560 - module_free(NULL, header);
32561 + module_free_exec(NULL, image);
32562 return;
32563 }
32564 + pax_open_kernel();
32565 memcpy(image + proglen, temp, ilen);
32566 + pax_close_kernel();
32567 }
32568 proglen += ilen;
32569 addrs[i] = proglen;
32570 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32571
32572 if (image) {
32573 bpf_flush_icache(header, image + proglen);
32574 - set_memory_ro((unsigned long)header, header->pages);
32575 fp->bpf_func = (void *)image;
32576 }
32577 out:
32578 @@ -776,9 +883,7 @@ void bpf_jit_free(struct sk_filter *fp)
32579 {
32580 if (fp->bpf_func != sk_run_filter) {
32581 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32582 - struct bpf_binary_header *header = (void *)addr;
32583 -
32584 - set_memory_rw(addr, header->pages);
32585 - module_free(NULL, header);
32586 + set_memory_rw(addr, 1);
32587 + module_free_exec(NULL, (void *)addr);
32588 }
32589 }
32590 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32591 index d6aa6e8..266395a 100644
32592 --- a/arch/x86/oprofile/backtrace.c
32593 +++ b/arch/x86/oprofile/backtrace.c
32594 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32595 struct stack_frame_ia32 *fp;
32596 unsigned long bytes;
32597
32598 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32599 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32600 if (bytes != sizeof(bufhead))
32601 return NULL;
32602
32603 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32604 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32605
32606 oprofile_add_trace(bufhead[0].return_address);
32607
32608 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32609 struct stack_frame bufhead[2];
32610 unsigned long bytes;
32611
32612 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32613 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32614 if (bytes != sizeof(bufhead))
32615 return NULL;
32616
32617 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32618 {
32619 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32620
32621 - if (!user_mode_vm(regs)) {
32622 + if (!user_mode(regs)) {
32623 unsigned long stack = kernel_stack_pointer(regs);
32624 if (depth)
32625 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32626 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32627 index 48768df..ba9143c 100644
32628 --- a/arch/x86/oprofile/nmi_int.c
32629 +++ b/arch/x86/oprofile/nmi_int.c
32630 @@ -23,6 +23,7 @@
32631 #include <asm/nmi.h>
32632 #include <asm/msr.h>
32633 #include <asm/apic.h>
32634 +#include <asm/pgtable.h>
32635
32636 #include "op_counter.h"
32637 #include "op_x86_model.h"
32638 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32639 if (ret)
32640 return ret;
32641
32642 - if (!model->num_virt_counters)
32643 - model->num_virt_counters = model->num_counters;
32644 + if (!model->num_virt_counters) {
32645 + pax_open_kernel();
32646 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32647 + pax_close_kernel();
32648 + }
32649
32650 mux_init(ops);
32651
32652 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32653 index b2b9443..be58856 100644
32654 --- a/arch/x86/oprofile/op_model_amd.c
32655 +++ b/arch/x86/oprofile/op_model_amd.c
32656 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32657 num_counters = AMD64_NUM_COUNTERS;
32658 }
32659
32660 - op_amd_spec.num_counters = num_counters;
32661 - op_amd_spec.num_controls = num_counters;
32662 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32663 + pax_open_kernel();
32664 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32665 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32666 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32667 + pax_close_kernel();
32668
32669 return 0;
32670 }
32671 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32672 index d90528e..0127e2b 100644
32673 --- a/arch/x86/oprofile/op_model_ppro.c
32674 +++ b/arch/x86/oprofile/op_model_ppro.c
32675 @@ -19,6 +19,7 @@
32676 #include <asm/msr.h>
32677 #include <asm/apic.h>
32678 #include <asm/nmi.h>
32679 +#include <asm/pgtable.h>
32680
32681 #include "op_x86_model.h"
32682 #include "op_counter.h"
32683 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32684
32685 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32686
32687 - op_arch_perfmon_spec.num_counters = num_counters;
32688 - op_arch_perfmon_spec.num_controls = num_counters;
32689 + pax_open_kernel();
32690 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32691 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32692 + pax_close_kernel();
32693 }
32694
32695 static int arch_perfmon_init(struct oprofile_operations *ignore)
32696 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32697 index 71e8a67..6a313bb 100644
32698 --- a/arch/x86/oprofile/op_x86_model.h
32699 +++ b/arch/x86/oprofile/op_x86_model.h
32700 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32701 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32702 struct op_msrs const * const msrs);
32703 #endif
32704 -};
32705 +} __do_const;
32706
32707 struct op_counter_config;
32708
32709 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32710 index 372e9b8..e775a6c 100644
32711 --- a/arch/x86/pci/irq.c
32712 +++ b/arch/x86/pci/irq.c
32713 @@ -50,7 +50,7 @@ struct irq_router {
32714 struct irq_router_handler {
32715 u16 vendor;
32716 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32717 -};
32718 +} __do_const;
32719
32720 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32721 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32722 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32723 return 0;
32724 }
32725
32726 -static __initdata struct irq_router_handler pirq_routers[] = {
32727 +static __initconst const struct irq_router_handler pirq_routers[] = {
32728 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32729 { PCI_VENDOR_ID_AL, ali_router_probe },
32730 { PCI_VENDOR_ID_ITE, ite_router_probe },
32731 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32732 static void __init pirq_find_router(struct irq_router *r)
32733 {
32734 struct irq_routing_table *rt = pirq_table;
32735 - struct irq_router_handler *h;
32736 + const struct irq_router_handler *h;
32737
32738 #ifdef CONFIG_PCI_BIOS
32739 if (!rt->signature) {
32740 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32741 return 0;
32742 }
32743
32744 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32745 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32746 {
32747 .callback = fix_broken_hp_bios_irq9,
32748 .ident = "HP Pavilion N5400 Series Laptop",
32749 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32750 index 6eb18c4..20d83de 100644
32751 --- a/arch/x86/pci/mrst.c
32752 +++ b/arch/x86/pci/mrst.c
32753 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
32754 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
32755 pci_mmcfg_late_init();
32756 pcibios_enable_irq = mrst_pci_irq_enable;
32757 - pci_root_ops = pci_mrst_ops;
32758 + pax_open_kernel();
32759 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32760 + pax_close_kernel();
32761 pci_soc_mode = 1;
32762 /* Continue with standard init */
32763 return 1;
32764 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32765 index c77b24a..c979855 100644
32766 --- a/arch/x86/pci/pcbios.c
32767 +++ b/arch/x86/pci/pcbios.c
32768 @@ -79,7 +79,7 @@ union bios32 {
32769 static struct {
32770 unsigned long address;
32771 unsigned short segment;
32772 -} bios32_indirect = { 0, __KERNEL_CS };
32773 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32774
32775 /*
32776 * Returns the entry point for the given service, NULL on error
32777 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32778 unsigned long length; /* %ecx */
32779 unsigned long entry; /* %edx */
32780 unsigned long flags;
32781 + struct desc_struct d, *gdt;
32782
32783 local_irq_save(flags);
32784 - __asm__("lcall *(%%edi); cld"
32785 +
32786 + gdt = get_cpu_gdt_table(smp_processor_id());
32787 +
32788 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32789 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32790 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32791 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32792 +
32793 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32794 : "=a" (return_code),
32795 "=b" (address),
32796 "=c" (length),
32797 "=d" (entry)
32798 : "0" (service),
32799 "1" (0),
32800 - "D" (&bios32_indirect));
32801 + "D" (&bios32_indirect),
32802 + "r"(__PCIBIOS_DS)
32803 + : "memory");
32804 +
32805 + pax_open_kernel();
32806 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32807 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32808 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32809 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32810 + pax_close_kernel();
32811 +
32812 local_irq_restore(flags);
32813
32814 switch (return_code) {
32815 - case 0:
32816 - return address + entry;
32817 - case 0x80: /* Not present */
32818 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32819 - return 0;
32820 - default: /* Shouldn't happen */
32821 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32822 - service, return_code);
32823 + case 0: {
32824 + int cpu;
32825 + unsigned char flags;
32826 +
32827 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32828 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32829 + printk(KERN_WARNING "bios32_service: not valid\n");
32830 return 0;
32831 + }
32832 + address = address + PAGE_OFFSET;
32833 + length += 16UL; /* some BIOSs underreport this... */
32834 + flags = 4;
32835 + if (length >= 64*1024*1024) {
32836 + length >>= PAGE_SHIFT;
32837 + flags |= 8;
32838 + }
32839 +
32840 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32841 + gdt = get_cpu_gdt_table(cpu);
32842 + pack_descriptor(&d, address, length, 0x9b, flags);
32843 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32844 + pack_descriptor(&d, address, length, 0x93, flags);
32845 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32846 + }
32847 + return entry;
32848 + }
32849 + case 0x80: /* Not present */
32850 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32851 + return 0;
32852 + default: /* Shouldn't happen */
32853 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32854 + service, return_code);
32855 + return 0;
32856 }
32857 }
32858
32859 static struct {
32860 unsigned long address;
32861 unsigned short segment;
32862 -} pci_indirect = { 0, __KERNEL_CS };
32863 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32864
32865 -static int pci_bios_present;
32866 +static int pci_bios_present __read_only;
32867
32868 static int check_pcibios(void)
32869 {
32870 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32871 unsigned long flags, pcibios_entry;
32872
32873 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32874 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32875 + pci_indirect.address = pcibios_entry;
32876
32877 local_irq_save(flags);
32878 - __asm__(
32879 - "lcall *(%%edi); cld\n\t"
32880 + __asm__("movw %w6, %%ds\n\t"
32881 + "lcall *%%ss:(%%edi); cld\n\t"
32882 + "push %%ss\n\t"
32883 + "pop %%ds\n\t"
32884 "jc 1f\n\t"
32885 "xor %%ah, %%ah\n"
32886 "1:"
32887 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32888 "=b" (ebx),
32889 "=c" (ecx)
32890 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32891 - "D" (&pci_indirect)
32892 + "D" (&pci_indirect),
32893 + "r" (__PCIBIOS_DS)
32894 : "memory");
32895 local_irq_restore(flags);
32896
32897 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32898
32899 switch (len) {
32900 case 1:
32901 - __asm__("lcall *(%%esi); cld\n\t"
32902 + __asm__("movw %w6, %%ds\n\t"
32903 + "lcall *%%ss:(%%esi); cld\n\t"
32904 + "push %%ss\n\t"
32905 + "pop %%ds\n\t"
32906 "jc 1f\n\t"
32907 "xor %%ah, %%ah\n"
32908 "1:"
32909 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32910 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32911 "b" (bx),
32912 "D" ((long)reg),
32913 - "S" (&pci_indirect));
32914 + "S" (&pci_indirect),
32915 + "r" (__PCIBIOS_DS));
32916 /*
32917 * Zero-extend the result beyond 8 bits, do not trust the
32918 * BIOS having done it:
32919 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32920 *value &= 0xff;
32921 break;
32922 case 2:
32923 - __asm__("lcall *(%%esi); cld\n\t"
32924 + __asm__("movw %w6, %%ds\n\t"
32925 + "lcall *%%ss:(%%esi); cld\n\t"
32926 + "push %%ss\n\t"
32927 + "pop %%ds\n\t"
32928 "jc 1f\n\t"
32929 "xor %%ah, %%ah\n"
32930 "1:"
32931 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32932 : "1" (PCIBIOS_READ_CONFIG_WORD),
32933 "b" (bx),
32934 "D" ((long)reg),
32935 - "S" (&pci_indirect));
32936 + "S" (&pci_indirect),
32937 + "r" (__PCIBIOS_DS));
32938 /*
32939 * Zero-extend the result beyond 16 bits, do not trust the
32940 * BIOS having done it:
32941 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32942 *value &= 0xffff;
32943 break;
32944 case 4:
32945 - __asm__("lcall *(%%esi); cld\n\t"
32946 + __asm__("movw %w6, %%ds\n\t"
32947 + "lcall *%%ss:(%%esi); cld\n\t"
32948 + "push %%ss\n\t"
32949 + "pop %%ds\n\t"
32950 "jc 1f\n\t"
32951 "xor %%ah, %%ah\n"
32952 "1:"
32953 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32954 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32955 "b" (bx),
32956 "D" ((long)reg),
32957 - "S" (&pci_indirect));
32958 + "S" (&pci_indirect),
32959 + "r" (__PCIBIOS_DS));
32960 break;
32961 }
32962
32963 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32964
32965 switch (len) {
32966 case 1:
32967 - __asm__("lcall *(%%esi); cld\n\t"
32968 + __asm__("movw %w6, %%ds\n\t"
32969 + "lcall *%%ss:(%%esi); cld\n\t"
32970 + "push %%ss\n\t"
32971 + "pop %%ds\n\t"
32972 "jc 1f\n\t"
32973 "xor %%ah, %%ah\n"
32974 "1:"
32975 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32976 "c" (value),
32977 "b" (bx),
32978 "D" ((long)reg),
32979 - "S" (&pci_indirect));
32980 + "S" (&pci_indirect),
32981 + "r" (__PCIBIOS_DS));
32982 break;
32983 case 2:
32984 - __asm__("lcall *(%%esi); cld\n\t"
32985 + __asm__("movw %w6, %%ds\n\t"
32986 + "lcall *%%ss:(%%esi); cld\n\t"
32987 + "push %%ss\n\t"
32988 + "pop %%ds\n\t"
32989 "jc 1f\n\t"
32990 "xor %%ah, %%ah\n"
32991 "1:"
32992 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32993 "c" (value),
32994 "b" (bx),
32995 "D" ((long)reg),
32996 - "S" (&pci_indirect));
32997 + "S" (&pci_indirect),
32998 + "r" (__PCIBIOS_DS));
32999 break;
33000 case 4:
33001 - __asm__("lcall *(%%esi); cld\n\t"
33002 + __asm__("movw %w6, %%ds\n\t"
33003 + "lcall *%%ss:(%%esi); cld\n\t"
33004 + "push %%ss\n\t"
33005 + "pop %%ds\n\t"
33006 "jc 1f\n\t"
33007 "xor %%ah, %%ah\n"
33008 "1:"
33009 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33010 "c" (value),
33011 "b" (bx),
33012 "D" ((long)reg),
33013 - "S" (&pci_indirect));
33014 + "S" (&pci_indirect),
33015 + "r" (__PCIBIOS_DS));
33016 break;
33017 }
33018
33019 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33020
33021 DBG("PCI: Fetching IRQ routing table... ");
33022 __asm__("push %%es\n\t"
33023 + "movw %w8, %%ds\n\t"
33024 "push %%ds\n\t"
33025 "pop %%es\n\t"
33026 - "lcall *(%%esi); cld\n\t"
33027 + "lcall *%%ss:(%%esi); cld\n\t"
33028 "pop %%es\n\t"
33029 + "push %%ss\n\t"
33030 + "pop %%ds\n"
33031 "jc 1f\n\t"
33032 "xor %%ah, %%ah\n"
33033 "1:"
33034 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33035 "1" (0),
33036 "D" ((long) &opt),
33037 "S" (&pci_indirect),
33038 - "m" (opt)
33039 + "m" (opt),
33040 + "r" (__PCIBIOS_DS)
33041 : "memory");
33042 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33043 if (ret & 0xff00)
33044 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33045 {
33046 int ret;
33047
33048 - __asm__("lcall *(%%esi); cld\n\t"
33049 + __asm__("movw %w5, %%ds\n\t"
33050 + "lcall *%%ss:(%%esi); cld\n\t"
33051 + "push %%ss\n\t"
33052 + "pop %%ds\n"
33053 "jc 1f\n\t"
33054 "xor %%ah, %%ah\n"
33055 "1:"
33056 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33057 : "0" (PCIBIOS_SET_PCI_HW_INT),
33058 "b" ((dev->bus->number << 8) | dev->devfn),
33059 "c" ((irq << 8) | (pin + 10)),
33060 - "S" (&pci_indirect));
33061 + "S" (&pci_indirect),
33062 + "r" (__PCIBIOS_DS));
33063 return !(ret & 0xff00);
33064 }
33065 EXPORT_SYMBOL(pcibios_set_irq_routing);
33066 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33067 index 40e4469..d915bf9 100644
33068 --- a/arch/x86/platform/efi/efi_32.c
33069 +++ b/arch/x86/platform/efi/efi_32.c
33070 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33071 {
33072 struct desc_ptr gdt_descr;
33073
33074 +#ifdef CONFIG_PAX_KERNEXEC
33075 + struct desc_struct d;
33076 +#endif
33077 +
33078 local_irq_save(efi_rt_eflags);
33079
33080 load_cr3(initial_page_table);
33081 __flush_tlb_all();
33082
33083 +#ifdef CONFIG_PAX_KERNEXEC
33084 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33085 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33086 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33087 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33088 +#endif
33089 +
33090 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33091 gdt_descr.size = GDT_SIZE - 1;
33092 load_gdt(&gdt_descr);
33093 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33094 {
33095 struct desc_ptr gdt_descr;
33096
33097 +#ifdef CONFIG_PAX_KERNEXEC
33098 + struct desc_struct d;
33099 +
33100 + memset(&d, 0, sizeof d);
33101 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33102 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33103 +#endif
33104 +
33105 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33106 gdt_descr.size = GDT_SIZE - 1;
33107 load_gdt(&gdt_descr);
33108
33109 +#ifdef CONFIG_PAX_PER_CPU_PGD
33110 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33111 +#else
33112 load_cr3(swapper_pg_dir);
33113 +#endif
33114 +
33115 __flush_tlb_all();
33116
33117 local_irq_restore(efi_rt_eflags);
33118 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33119 index 39a0e7f1..872396e 100644
33120 --- a/arch/x86/platform/efi/efi_64.c
33121 +++ b/arch/x86/platform/efi/efi_64.c
33122 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33123 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33124 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33125 }
33126 +
33127 +#ifdef CONFIG_PAX_PER_CPU_PGD
33128 + load_cr3(swapper_pg_dir);
33129 +#endif
33130 +
33131 __flush_tlb_all();
33132 }
33133
33134 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33135 for (pgd = 0; pgd < n_pgds; pgd++)
33136 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33137 kfree(save_pgd);
33138 +
33139 +#ifdef CONFIG_PAX_PER_CPU_PGD
33140 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33141 +#endif
33142 +
33143 __flush_tlb_all();
33144 local_irq_restore(efi_flags);
33145 early_code_mapping_set_exec(0);
33146 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33147 index fbe66e6..eae5e38 100644
33148 --- a/arch/x86/platform/efi/efi_stub_32.S
33149 +++ b/arch/x86/platform/efi/efi_stub_32.S
33150 @@ -6,7 +6,9 @@
33151 */
33152
33153 #include <linux/linkage.h>
33154 +#include <linux/init.h>
33155 #include <asm/page_types.h>
33156 +#include <asm/segment.h>
33157
33158 /*
33159 * efi_call_phys(void *, ...) is a function with variable parameters.
33160 @@ -20,7 +22,7 @@
33161 * service functions will comply with gcc calling convention, too.
33162 */
33163
33164 -.text
33165 +__INIT
33166 ENTRY(efi_call_phys)
33167 /*
33168 * 0. The function can only be called in Linux kernel. So CS has been
33169 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33170 * The mapping of lower virtual memory has been created in prelog and
33171 * epilog.
33172 */
33173 - movl $1f, %edx
33174 - subl $__PAGE_OFFSET, %edx
33175 - jmp *%edx
33176 +#ifdef CONFIG_PAX_KERNEXEC
33177 + movl $(__KERNEXEC_EFI_DS), %edx
33178 + mov %edx, %ds
33179 + mov %edx, %es
33180 + mov %edx, %ss
33181 + addl $2f,(1f)
33182 + ljmp *(1f)
33183 +
33184 +__INITDATA
33185 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33186 +.previous
33187 +
33188 +2:
33189 + subl $2b,(1b)
33190 +#else
33191 + jmp 1f-__PAGE_OFFSET
33192 1:
33193 +#endif
33194
33195 /*
33196 * 2. Now on the top of stack is the return
33197 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33198 * parameter 2, ..., param n. To make things easy, we save the return
33199 * address of efi_call_phys in a global variable.
33200 */
33201 - popl %edx
33202 - movl %edx, saved_return_addr
33203 - /* get the function pointer into ECX*/
33204 - popl %ecx
33205 - movl %ecx, efi_rt_function_ptr
33206 - movl $2f, %edx
33207 - subl $__PAGE_OFFSET, %edx
33208 - pushl %edx
33209 + popl (saved_return_addr)
33210 + popl (efi_rt_function_ptr)
33211
33212 /*
33213 * 3. Clear PG bit in %CR0.
33214 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33215 /*
33216 * 5. Call the physical function.
33217 */
33218 - jmp *%ecx
33219 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33220
33221 -2:
33222 /*
33223 * 6. After EFI runtime service returns, control will return to
33224 * following instruction. We'd better readjust stack pointer first.
33225 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33226 movl %cr0, %edx
33227 orl $0x80000000, %edx
33228 movl %edx, %cr0
33229 - jmp 1f
33230 -1:
33231 +
33232 /*
33233 * 8. Now restore the virtual mode from flat mode by
33234 * adding EIP with PAGE_OFFSET.
33235 */
33236 - movl $1f, %edx
33237 - jmp *%edx
33238 +#ifdef CONFIG_PAX_KERNEXEC
33239 + movl $(__KERNEL_DS), %edx
33240 + mov %edx, %ds
33241 + mov %edx, %es
33242 + mov %edx, %ss
33243 + ljmp $(__KERNEL_CS),$1f
33244 +#else
33245 + jmp 1f+__PAGE_OFFSET
33246 +#endif
33247 1:
33248
33249 /*
33250 * 9. Balance the stack. And because EAX contain the return value,
33251 * we'd better not clobber it.
33252 */
33253 - leal efi_rt_function_ptr, %edx
33254 - movl (%edx), %ecx
33255 - pushl %ecx
33256 + pushl (efi_rt_function_ptr)
33257
33258 /*
33259 - * 10. Push the saved return address onto the stack and return.
33260 + * 10. Return to the saved return address.
33261 */
33262 - leal saved_return_addr, %edx
33263 - movl (%edx), %ecx
33264 - pushl %ecx
33265 - ret
33266 + jmpl *(saved_return_addr)
33267 ENDPROC(efi_call_phys)
33268 .previous
33269
33270 -.data
33271 +__INITDATA
33272 saved_return_addr:
33273 .long 0
33274 efi_rt_function_ptr:
33275 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33276 index 4c07cca..2c8427d 100644
33277 --- a/arch/x86/platform/efi/efi_stub_64.S
33278 +++ b/arch/x86/platform/efi/efi_stub_64.S
33279 @@ -7,6 +7,7 @@
33280 */
33281
33282 #include <linux/linkage.h>
33283 +#include <asm/alternative-asm.h>
33284
33285 #define SAVE_XMM \
33286 mov %rsp, %rax; \
33287 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33288 call *%rdi
33289 addq $32, %rsp
33290 RESTORE_XMM
33291 + pax_force_retaddr 0, 1
33292 ret
33293 ENDPROC(efi_call0)
33294
33295 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33296 call *%rdi
33297 addq $32, %rsp
33298 RESTORE_XMM
33299 + pax_force_retaddr 0, 1
33300 ret
33301 ENDPROC(efi_call1)
33302
33303 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33304 call *%rdi
33305 addq $32, %rsp
33306 RESTORE_XMM
33307 + pax_force_retaddr 0, 1
33308 ret
33309 ENDPROC(efi_call2)
33310
33311 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33312 call *%rdi
33313 addq $32, %rsp
33314 RESTORE_XMM
33315 + pax_force_retaddr 0, 1
33316 ret
33317 ENDPROC(efi_call3)
33318
33319 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33320 call *%rdi
33321 addq $32, %rsp
33322 RESTORE_XMM
33323 + pax_force_retaddr 0, 1
33324 ret
33325 ENDPROC(efi_call4)
33326
33327 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33328 call *%rdi
33329 addq $48, %rsp
33330 RESTORE_XMM
33331 + pax_force_retaddr 0, 1
33332 ret
33333 ENDPROC(efi_call5)
33334
33335 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33336 call *%rdi
33337 addq $48, %rsp
33338 RESTORE_XMM
33339 + pax_force_retaddr 0, 1
33340 ret
33341 ENDPROC(efi_call6)
33342 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33343 index 47fe66f..6206449 100644
33344 --- a/arch/x86/platform/mrst/mrst.c
33345 +++ b/arch/x86/platform/mrst/mrst.c
33346 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33347 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33348 int sfi_mrtc_num;
33349
33350 -static void mrst_power_off(void)
33351 +static __noreturn void mrst_power_off(void)
33352 {
33353 + BUG();
33354 }
33355
33356 -static void mrst_reboot(void)
33357 +static __noreturn void mrst_reboot(void)
33358 {
33359 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33360 + BUG();
33361 }
33362
33363 /* parse all the mtimer info to a static mtimer array */
33364 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33365 index d6ee929..3637cb5 100644
33366 --- a/arch/x86/platform/olpc/olpc_dt.c
33367 +++ b/arch/x86/platform/olpc/olpc_dt.c
33368 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33369 return res;
33370 }
33371
33372 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33373 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33374 .nextprop = olpc_dt_nextprop,
33375 .getproplen = olpc_dt_getproplen,
33376 .getproperty = olpc_dt_getproperty,
33377 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33378 index 1cf5b30..fd45732 100644
33379 --- a/arch/x86/power/cpu.c
33380 +++ b/arch/x86/power/cpu.c
33381 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33382 static void fix_processor_context(void)
33383 {
33384 int cpu = smp_processor_id();
33385 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33386 -#ifdef CONFIG_X86_64
33387 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33388 - tss_desc tss;
33389 -#endif
33390 + struct tss_struct *t = init_tss + cpu;
33391 +
33392 set_tss_desc(cpu, t); /*
33393 * This just modifies memory; should not be
33394 * necessary. But... This is necessary, because
33395 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33396 */
33397
33398 #ifdef CONFIG_X86_64
33399 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33400 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33401 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33402 -
33403 syscall_init(); /* This sets MSR_*STAR and related */
33404 #endif
33405 load_TR_desc(); /* This does ltr */
33406 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33407 index a44f457..9140171 100644
33408 --- a/arch/x86/realmode/init.c
33409 +++ b/arch/x86/realmode/init.c
33410 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33411 __va(real_mode_header->trampoline_header);
33412
33413 #ifdef CONFIG_X86_32
33414 - trampoline_header->start = __pa_symbol(startup_32_smp);
33415 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33416 +
33417 +#ifdef CONFIG_PAX_KERNEXEC
33418 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33419 +#endif
33420 +
33421 + trampoline_header->boot_cs = __BOOT_CS;
33422 trampoline_header->gdt_limit = __BOOT_DS + 7;
33423 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33424 #else
33425 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33426 *trampoline_cr4_features = read_cr4();
33427
33428 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33429 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33430 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33431 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33432 #endif
33433 }
33434 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33435 index 8869287..d577672 100644
33436 --- a/arch/x86/realmode/rm/Makefile
33437 +++ b/arch/x86/realmode/rm/Makefile
33438 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33439 $(call cc-option, -fno-unit-at-a-time)) \
33440 $(call cc-option, -fno-stack-protector) \
33441 $(call cc-option, -mpreferred-stack-boundary=2)
33442 +ifdef CONSTIFY_PLUGIN
33443 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33444 +endif
33445 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33446 GCOV_PROFILE := n
33447 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33448 index a28221d..93c40f1 100644
33449 --- a/arch/x86/realmode/rm/header.S
33450 +++ b/arch/x86/realmode/rm/header.S
33451 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33452 #endif
33453 /* APM/BIOS reboot */
33454 .long pa_machine_real_restart_asm
33455 -#ifdef CONFIG_X86_64
33456 +#ifdef CONFIG_X86_32
33457 + .long __KERNEL_CS
33458 +#else
33459 .long __KERNEL32_CS
33460 #endif
33461 END(real_mode_header)
33462 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33463 index c1b2791..f9e31c7 100644
33464 --- a/arch/x86/realmode/rm/trampoline_32.S
33465 +++ b/arch/x86/realmode/rm/trampoline_32.S
33466 @@ -25,6 +25,12 @@
33467 #include <asm/page_types.h>
33468 #include "realmode.h"
33469
33470 +#ifdef CONFIG_PAX_KERNEXEC
33471 +#define ta(X) (X)
33472 +#else
33473 +#define ta(X) (pa_ ## X)
33474 +#endif
33475 +
33476 .text
33477 .code16
33478
33479 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33480
33481 cli # We should be safe anyway
33482
33483 - movl tr_start, %eax # where we need to go
33484 -
33485 movl $0xA5A5A5A5, trampoline_status
33486 # write marker for master knows we're running
33487
33488 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33489 movw $1, %dx # protected mode (PE) bit
33490 lmsw %dx # into protected mode
33491
33492 - ljmpl $__BOOT_CS, $pa_startup_32
33493 + ljmpl *(trampoline_header)
33494
33495 .section ".text32","ax"
33496 .code32
33497 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33498 .balign 8
33499 GLOBAL(trampoline_header)
33500 tr_start: .space 4
33501 - tr_gdt_pad: .space 2
33502 + tr_boot_cs: .space 2
33503 tr_gdt: .space 6
33504 END(trampoline_header)
33505
33506 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33507 index bb360dc..d0fd8f8 100644
33508 --- a/arch/x86/realmode/rm/trampoline_64.S
33509 +++ b/arch/x86/realmode/rm/trampoline_64.S
33510 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33511 movl %edx, %gs
33512
33513 movl pa_tr_cr4, %eax
33514 + andl $~X86_CR4_PCIDE, %eax
33515 movl %eax, %cr4 # Enable PAE mode
33516
33517 # Setup trampoline 4 level pagetables
33518 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33519 wrmsr
33520
33521 # Enable paging and in turn activate Long Mode
33522 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33523 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33524 movl %eax, %cr0
33525
33526 /*
33527 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33528 index e812034..c747134 100644
33529 --- a/arch/x86/tools/Makefile
33530 +++ b/arch/x86/tools/Makefile
33531 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33532
33533 $(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
33534
33535 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33536 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33537 hostprogs-y += relocs
33538 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33539 relocs: $(obj)/relocs
33540 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33541 index f7bab68..b6d9886 100644
33542 --- a/arch/x86/tools/relocs.c
33543 +++ b/arch/x86/tools/relocs.c
33544 @@ -1,5 +1,7 @@
33545 /* This is included from relocs_32/64.c */
33546
33547 +#include "../../../include/generated/autoconf.h"
33548 +
33549 #define ElfW(type) _ElfW(ELF_BITS, type)
33550 #define _ElfW(bits, type) __ElfW(bits, type)
33551 #define __ElfW(bits, type) Elf##bits##_##type
33552 @@ -11,6 +13,7 @@
33553 #define Elf_Sym ElfW(Sym)
33554
33555 static Elf_Ehdr ehdr;
33556 +static Elf_Phdr *phdr;
33557
33558 struct relocs {
33559 uint32_t *offset;
33560 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33561 }
33562 }
33563
33564 +static void read_phdrs(FILE *fp)
33565 +{
33566 + unsigned int i;
33567 +
33568 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33569 + if (!phdr) {
33570 + die("Unable to allocate %d program headers\n",
33571 + ehdr.e_phnum);
33572 + }
33573 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33574 + die("Seek to %d failed: %s\n",
33575 + ehdr.e_phoff, strerror(errno));
33576 + }
33577 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33578 + die("Cannot read ELF program headers: %s\n",
33579 + strerror(errno));
33580 + }
33581 + for(i = 0; i < ehdr.e_phnum; i++) {
33582 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33583 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33584 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33585 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33586 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33587 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33588 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33589 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33590 + }
33591 +
33592 +}
33593 +
33594 static void read_shdrs(FILE *fp)
33595 {
33596 - int i;
33597 + unsigned int i;
33598 Elf_Shdr shdr;
33599
33600 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33601 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33602
33603 static void read_strtabs(FILE *fp)
33604 {
33605 - int i;
33606 + unsigned int i;
33607 for (i = 0; i < ehdr.e_shnum; i++) {
33608 struct section *sec = &secs[i];
33609 if (sec->shdr.sh_type != SHT_STRTAB) {
33610 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33611
33612 static void read_symtabs(FILE *fp)
33613 {
33614 - int i,j;
33615 + unsigned int i,j;
33616 for (i = 0; i < ehdr.e_shnum; i++) {
33617 struct section *sec = &secs[i];
33618 if (sec->shdr.sh_type != SHT_SYMTAB) {
33619 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33620 }
33621
33622
33623 -static void read_relocs(FILE *fp)
33624 +static void read_relocs(FILE *fp, int use_real_mode)
33625 {
33626 - int i,j;
33627 + unsigned int i,j;
33628 + uint32_t base;
33629 +
33630 for (i = 0; i < ehdr.e_shnum; i++) {
33631 struct section *sec = &secs[i];
33632 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33633 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33634 die("Cannot read symbol table: %s\n",
33635 strerror(errno));
33636 }
33637 + base = 0;
33638 +
33639 +#ifdef CONFIG_X86_32
33640 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33641 + if (phdr[j].p_type != PT_LOAD )
33642 + continue;
33643 + if (secs[sec->shdr.sh_info].shdr.sh_offset < phdr[j].p_offset || secs[sec->shdr.sh_info].shdr.sh_offset >= phdr[j].p_offset + phdr[j].p_filesz)
33644 + continue;
33645 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33646 + break;
33647 + }
33648 +#endif
33649 +
33650 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33651 Elf_Rel *rel = &sec->reltab[j];
33652 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33653 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33654 rel->r_info = elf_xword_to_cpu(rel->r_info);
33655 #if (SHT_REL_TYPE == SHT_RELA)
33656 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33657 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33658
33659 static void print_absolute_symbols(void)
33660 {
33661 - int i;
33662 + unsigned int i;
33663 const char *format;
33664
33665 if (ELF_BITS == 64)
33666 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33667 for (i = 0; i < ehdr.e_shnum; i++) {
33668 struct section *sec = &secs[i];
33669 char *sym_strtab;
33670 - int j;
33671 + unsigned int j;
33672
33673 if (sec->shdr.sh_type != SHT_SYMTAB) {
33674 continue;
33675 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33676
33677 static void print_absolute_relocs(void)
33678 {
33679 - int i, printed = 0;
33680 + unsigned int i, printed = 0;
33681 const char *format;
33682
33683 if (ELF_BITS == 64)
33684 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33685 struct section *sec_applies, *sec_symtab;
33686 char *sym_strtab;
33687 Elf_Sym *sh_symtab;
33688 - int j;
33689 + unsigned int j;
33690 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33691 continue;
33692 }
33693 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33694 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33695 Elf_Sym *sym, const char *symname))
33696 {
33697 - int i;
33698 + unsigned int i;
33699 /* Walk through the relocations */
33700 for (i = 0; i < ehdr.e_shnum; i++) {
33701 char *sym_strtab;
33702 Elf_Sym *sh_symtab;
33703 struct section *sec_applies, *sec_symtab;
33704 - int j;
33705 + unsigned int j;
33706 struct section *sec = &secs[i];
33707
33708 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33709 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33710 {
33711 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33712 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33713 + char *sym_strtab = sec->link->link->strtab;
33714 +
33715 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33716 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33717 + return 0;
33718 +
33719 +#ifdef CONFIG_PAX_KERNEXEC
33720 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33721 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33722 + return 0;
33723 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33724 + return 0;
33725 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33726 + return 0;
33727 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33728 + return 0;
33729 +#endif
33730
33731 switch (r_type) {
33732 case R_386_NONE:
33733 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33734
33735 static void emit_relocs(int as_text, int use_real_mode)
33736 {
33737 - int i;
33738 + unsigned int i;
33739 int (*write_reloc)(uint32_t, FILE *) = write32;
33740 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33741 const char *symname);
33742 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33743 {
33744 regex_init(use_real_mode);
33745 read_ehdr(fp);
33746 + read_phdrs(fp);
33747 read_shdrs(fp);
33748 read_strtabs(fp);
33749 read_symtabs(fp);
33750 - read_relocs(fp);
33751 + read_relocs(fp, use_real_mode);
33752 if (ELF_BITS == 64)
33753 percpu_init();
33754 if (show_absolute_syms) {
33755 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33756 index 80ffa5b..a33bd15 100644
33757 --- a/arch/x86/um/tls_32.c
33758 +++ b/arch/x86/um/tls_32.c
33759 @@ -260,7 +260,7 @@ out:
33760 if (unlikely(task == current &&
33761 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33762 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33763 - "without flushed TLS.", current->pid);
33764 + "without flushed TLS.", task_pid_nr(current));
33765 }
33766
33767 return 0;
33768 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33769 index fd14be1..e3c79c0 100644
33770 --- a/arch/x86/vdso/Makefile
33771 +++ b/arch/x86/vdso/Makefile
33772 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33773 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33774 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33775
33776 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33777 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33778 GCOV_PROFILE := n
33779
33780 #
33781 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33782 index d6bfb87..876ee18 100644
33783 --- a/arch/x86/vdso/vdso32-setup.c
33784 +++ b/arch/x86/vdso/vdso32-setup.c
33785 @@ -25,6 +25,7 @@
33786 #include <asm/tlbflush.h>
33787 #include <asm/vdso.h>
33788 #include <asm/proto.h>
33789 +#include <asm/mman.h>
33790
33791 enum {
33792 VDSO_DISABLED = 0,
33793 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33794 void enable_sep_cpu(void)
33795 {
33796 int cpu = get_cpu();
33797 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33798 + struct tss_struct *tss = init_tss + cpu;
33799
33800 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33801 put_cpu();
33802 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33803 gate_vma.vm_start = FIXADDR_USER_START;
33804 gate_vma.vm_end = FIXADDR_USER_END;
33805 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33806 - gate_vma.vm_page_prot = __P101;
33807 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33808
33809 return 0;
33810 }
33811 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33812 if (compat)
33813 addr = VDSO_HIGH_BASE;
33814 else {
33815 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33816 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33817 if (IS_ERR_VALUE(addr)) {
33818 ret = addr;
33819 goto up_fail;
33820 }
33821 }
33822
33823 - current->mm->context.vdso = (void *)addr;
33824 + current->mm->context.vdso = addr;
33825
33826 if (compat_uses_vma || !compat) {
33827 /*
33828 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33829 }
33830
33831 current_thread_info()->sysenter_return =
33832 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33833 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33834
33835 up_fail:
33836 if (ret)
33837 - current->mm->context.vdso = NULL;
33838 + current->mm->context.vdso = 0;
33839
33840 up_write(&mm->mmap_sem);
33841
33842 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33843
33844 const char *arch_vma_name(struct vm_area_struct *vma)
33845 {
33846 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33847 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33848 return "[vdso]";
33849 +
33850 +#ifdef CONFIG_PAX_SEGMEXEC
33851 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33852 + return "[vdso]";
33853 +#endif
33854 +
33855 return NULL;
33856 }
33857
33858 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33859 * Check to see if the corresponding task was created in compat vdso
33860 * mode.
33861 */
33862 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33863 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33864 return &gate_vma;
33865 return NULL;
33866 }
33867 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33868 index 431e875..cbb23f3 100644
33869 --- a/arch/x86/vdso/vma.c
33870 +++ b/arch/x86/vdso/vma.c
33871 @@ -16,8 +16,6 @@
33872 #include <asm/vdso.h>
33873 #include <asm/page.h>
33874
33875 -unsigned int __read_mostly vdso_enabled = 1;
33876 -
33877 extern char vdso_start[], vdso_end[];
33878 extern unsigned short vdso_sync_cpuid;
33879
33880 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33881 * unaligned here as a result of stack start randomization.
33882 */
33883 addr = PAGE_ALIGN(addr);
33884 - addr = align_vdso_addr(addr);
33885
33886 return addr;
33887 }
33888 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33889 unsigned size)
33890 {
33891 struct mm_struct *mm = current->mm;
33892 - unsigned long addr;
33893 + unsigned long addr = 0;
33894 int ret;
33895
33896 - if (!vdso_enabled)
33897 - return 0;
33898 -
33899 down_write(&mm->mmap_sem);
33900 +
33901 +#ifdef CONFIG_PAX_RANDMMAP
33902 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33903 +#endif
33904 +
33905 addr = vdso_addr(mm->start_stack, size);
33906 + addr = align_vdso_addr(addr);
33907 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33908 if (IS_ERR_VALUE(addr)) {
33909 ret = addr;
33910 goto up_fail;
33911 }
33912
33913 - current->mm->context.vdso = (void *)addr;
33914 + mm->context.vdso = addr;
33915
33916 ret = install_special_mapping(mm, addr, size,
33917 VM_READ|VM_EXEC|
33918 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33919 pages);
33920 - if (ret) {
33921 - current->mm->context.vdso = NULL;
33922 - goto up_fail;
33923 - }
33924 + if (ret)
33925 + mm->context.vdso = 0;
33926
33927 up_fail:
33928 up_write(&mm->mmap_sem);
33929 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33930 vdsox32_size);
33931 }
33932 #endif
33933 -
33934 -static __init int vdso_setup(char *s)
33935 -{
33936 - vdso_enabled = simple_strtoul(s, NULL, 0);
33937 - return 0;
33938 -}
33939 -__setup("vdso=", vdso_setup);
33940 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33941 index 193097e..7590269 100644
33942 --- a/arch/x86/xen/enlighten.c
33943 +++ b/arch/x86/xen/enlighten.c
33944 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33945
33946 struct shared_info xen_dummy_shared_info;
33947
33948 -void *xen_initial_gdt;
33949 -
33950 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33951 __read_mostly int xen_have_vector_callback;
33952 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33953 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33954 {
33955 unsigned long va = dtr->address;
33956 unsigned int size = dtr->size + 1;
33957 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33958 - unsigned long frames[pages];
33959 + unsigned long frames[65536 / PAGE_SIZE];
33960 int f;
33961
33962 /*
33963 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33964 {
33965 unsigned long va = dtr->address;
33966 unsigned int size = dtr->size + 1;
33967 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33968 - unsigned long frames[pages];
33969 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33970 int f;
33971
33972 /*
33973 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33974 * 8-byte entries, or 16 4k pages..
33975 */
33976
33977 - BUG_ON(size > 65536);
33978 + BUG_ON(size > GDT_SIZE);
33979 BUG_ON(va & ~PAGE_MASK);
33980
33981 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33982 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
33983 return 0;
33984 }
33985
33986 -static void set_xen_basic_apic_ops(void)
33987 +static void __init set_xen_basic_apic_ops(void)
33988 {
33989 apic->read = xen_apic_read;
33990 apic->write = xen_apic_write;
33991 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
33992 #endif
33993 };
33994
33995 -static void xen_reboot(int reason)
33996 +static __noreturn void xen_reboot(int reason)
33997 {
33998 struct sched_shutdown r = { .reason = reason };
33999
34000 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34001 - BUG();
34002 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34003 + BUG();
34004 }
34005
34006 -static void xen_restart(char *msg)
34007 +static __noreturn void xen_restart(char *msg)
34008 {
34009 xen_reboot(SHUTDOWN_reboot);
34010 }
34011
34012 -static void xen_emergency_restart(void)
34013 +static __noreturn void xen_emergency_restart(void)
34014 {
34015 xen_reboot(SHUTDOWN_reboot);
34016 }
34017
34018 -static void xen_machine_halt(void)
34019 +static __noreturn void xen_machine_halt(void)
34020 {
34021 xen_reboot(SHUTDOWN_poweroff);
34022 }
34023
34024 -static void xen_machine_power_off(void)
34025 +static __noreturn void xen_machine_power_off(void)
34026 {
34027 if (pm_power_off)
34028 pm_power_off();
34029 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
34030 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34031
34032 /* Work out if we support NX */
34033 - x86_configure_nx();
34034 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34035 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34036 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34037 + unsigned l, h;
34038 +
34039 + __supported_pte_mask |= _PAGE_NX;
34040 + rdmsr(MSR_EFER, l, h);
34041 + l |= EFER_NX;
34042 + wrmsr(MSR_EFER, l, h);
34043 + }
34044 +#endif
34045
34046 xen_setup_features();
34047
34048 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
34049
34050 machine_ops = xen_machine_ops;
34051
34052 - /*
34053 - * The only reliable way to retain the initial address of the
34054 - * percpu gdt_page is to remember it here, so we can go and
34055 - * mark it RW later, when the initial percpu area is freed.
34056 - */
34057 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34058 -
34059 xen_smp_init();
34060
34061 #ifdef CONFIG_ACPI_NUMA
34062 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34063 index fdc3ba2..3daee39 100644
34064 --- a/arch/x86/xen/mmu.c
34065 +++ b/arch/x86/xen/mmu.c
34066 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34067 /* L3_k[510] -> level2_kernel_pgt
34068 * L3_i[511] -> level2_fixmap_pgt */
34069 convert_pfn_mfn(level3_kernel_pgt);
34070 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34071 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34072 + convert_pfn_mfn(level3_vmemmap_pgt);
34073
34074 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34075 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34076 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34077 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34078 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34079 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34080 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34081 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34082 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34083 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34084 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34085 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34086 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34087 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34088
34089 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34090 pv_mmu_ops.set_pud = xen_set_pud;
34091 #if PAGETABLE_LEVELS == 4
34092 pv_mmu_ops.set_pgd = xen_set_pgd;
34093 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34094 #endif
34095
34096 /* This will work as long as patching hasn't happened yet
34097 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34098 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34099 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34100 .set_pgd = xen_set_pgd_hyper,
34101 + .set_pgd_batched = xen_set_pgd_hyper,
34102
34103 .alloc_pud = xen_alloc_pmd_init,
34104 .release_pud = xen_release_pmd_init,
34105 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34106 index b81c88e..2cbe7b8 100644
34107 --- a/arch/x86/xen/smp.c
34108 +++ b/arch/x86/xen/smp.c
34109 @@ -272,11 +272,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
34110 {
34111 BUG_ON(smp_processor_id() != 0);
34112 native_smp_prepare_boot_cpu();
34113 -
34114 - /* We've switched to the "real" per-cpu gdt, so make sure the
34115 - old memory can be recycled */
34116 - make_lowmem_page_readwrite(xen_initial_gdt);
34117 -
34118 xen_filter_cpu_maps();
34119 xen_setup_vcpu_info_placement();
34120 }
34121 @@ -346,7 +341,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34122 ctxt->user_regs.ss = __KERNEL_DS;
34123 #ifdef CONFIG_X86_32
34124 ctxt->user_regs.fs = __KERNEL_PERCPU;
34125 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34126 + savesegment(gs, ctxt->user_regs.gs);
34127 #else
34128 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34129 #endif
34130 @@ -356,8 +351,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34131
34132 {
34133 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34134 - ctxt->user_regs.ds = __USER_DS;
34135 - ctxt->user_regs.es = __USER_DS;
34136 + ctxt->user_regs.ds = __KERNEL_DS;
34137 + ctxt->user_regs.es = __KERNEL_DS;
34138
34139 xen_copy_trap_info(ctxt->trap_ctxt);
34140
34141 @@ -402,13 +397,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34142 int rc;
34143
34144 per_cpu(current_task, cpu) = idle;
34145 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34146 #ifdef CONFIG_X86_32
34147 irq_ctx_init(cpu);
34148 #else
34149 clear_tsk_thread_flag(idle, TIF_FORK);
34150 - per_cpu(kernel_stack, cpu) =
34151 - (unsigned long)task_stack_page(idle) -
34152 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34153 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34154 #endif
34155 xen_setup_runstate_info(cpu);
34156 xen_setup_timer(cpu);
34157 @@ -678,7 +672,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34158
34159 void __init xen_smp_init(void)
34160 {
34161 - smp_ops = xen_smp_ops;
34162 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34163 xen_fill_possible_map();
34164 xen_init_spinlocks();
34165 }
34166 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34167 index 33ca6e4..0ded929 100644
34168 --- a/arch/x86/xen/xen-asm_32.S
34169 +++ b/arch/x86/xen/xen-asm_32.S
34170 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34171 ESP_OFFSET=4 # bytes pushed onto stack
34172
34173 /*
34174 - * Store vcpu_info pointer for easy access. Do it this way to
34175 - * avoid having to reload %fs
34176 + * Store vcpu_info pointer for easy access.
34177 */
34178 #ifdef CONFIG_SMP
34179 - GET_THREAD_INFO(%eax)
34180 - movl %ss:TI_cpu(%eax), %eax
34181 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34182 - mov %ss:xen_vcpu(%eax), %eax
34183 + push %fs
34184 + mov $(__KERNEL_PERCPU), %eax
34185 + mov %eax, %fs
34186 + mov PER_CPU_VAR(xen_vcpu), %eax
34187 + pop %fs
34188 #else
34189 movl %ss:xen_vcpu, %eax
34190 #endif
34191 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34192 index 7faed58..ba4427c 100644
34193 --- a/arch/x86/xen/xen-head.S
34194 +++ b/arch/x86/xen/xen-head.S
34195 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34196 #ifdef CONFIG_X86_32
34197 mov %esi,xen_start_info
34198 mov $init_thread_union+THREAD_SIZE,%esp
34199 +#ifdef CONFIG_SMP
34200 + movl $cpu_gdt_table,%edi
34201 + movl $__per_cpu_load,%eax
34202 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34203 + rorl $16,%eax
34204 + movb %al,__KERNEL_PERCPU + 4(%edi)
34205 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34206 + movl $__per_cpu_end - 1,%eax
34207 + subl $__per_cpu_start,%eax
34208 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34209 +#endif
34210 #else
34211 mov %rsi,xen_start_info
34212 mov $init_thread_union+THREAD_SIZE,%rsp
34213 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34214 index 86782c5..fa272c8 100644
34215 --- a/arch/x86/xen/xen-ops.h
34216 +++ b/arch/x86/xen/xen-ops.h
34217 @@ -10,8 +10,6 @@
34218 extern const char xen_hypervisor_callback[];
34219 extern const char xen_failsafe_callback[];
34220
34221 -extern void *xen_initial_gdt;
34222 -
34223 struct trap_info;
34224 void xen_copy_trap_info(struct trap_info *traps);
34225
34226 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34227 index 525bd3d..ef888b1 100644
34228 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34229 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34230 @@ -119,9 +119,9 @@
34231 ----------------------------------------------------------------------*/
34232
34233 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34234 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34235 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34236 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34237 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34238
34239 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34240 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34241 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34242 index 2f33760..835e50a 100644
34243 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34244 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34245 @@ -11,6 +11,7 @@
34246 #ifndef _XTENSA_CORE_H
34247 #define _XTENSA_CORE_H
34248
34249 +#include <linux/const.h>
34250
34251 /****************************************************************************
34252 Parameters Useful for Any Code, USER or PRIVILEGED
34253 @@ -112,9 +113,9 @@
34254 ----------------------------------------------------------------------*/
34255
34256 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34257 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34258 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34259 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34260 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34261
34262 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34263 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34264 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34265 index af00795..2bb8105 100644
34266 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34267 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34268 @@ -11,6 +11,7 @@
34269 #ifndef _XTENSA_CORE_CONFIGURATION_H
34270 #define _XTENSA_CORE_CONFIGURATION_H
34271
34272 +#include <linux/const.h>
34273
34274 /****************************************************************************
34275 Parameters Useful for Any Code, USER or PRIVILEGED
34276 @@ -118,9 +119,9 @@
34277 ----------------------------------------------------------------------*/
34278
34279 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34280 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34281 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34282 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34283 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34284
34285 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34286 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34287 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34288 index 290792a..416f287 100644
34289 --- a/block/blk-cgroup.c
34290 +++ b/block/blk-cgroup.c
34291 @@ -808,7 +808,7 @@ static void blkcg_css_free(struct cgroup *cgroup)
34292
34293 static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34294 {
34295 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34296 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34297 struct blkcg *blkcg;
34298 struct cgroup *parent = cgroup->parent;
34299
34300 @@ -823,7 +823,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34301
34302 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34303 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34304 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34305 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34306 done:
34307 spin_lock_init(&blkcg->lock);
34308 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34309 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34310 index 4b8d9b54..a7178c0 100644
34311 --- a/block/blk-iopoll.c
34312 +++ b/block/blk-iopoll.c
34313 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34314 }
34315 EXPORT_SYMBOL(blk_iopoll_complete);
34316
34317 -static void blk_iopoll_softirq(struct softirq_action *h)
34318 +static __latent_entropy void blk_iopoll_softirq(void)
34319 {
34320 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34321 int rearm = 0, budget = blk_iopoll_budget;
34322 diff --git a/block/blk-map.c b/block/blk-map.c
34323 index 623e1cd..ca1e109 100644
34324 --- a/block/blk-map.c
34325 +++ b/block/blk-map.c
34326 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34327 if (!len || !kbuf)
34328 return -EINVAL;
34329
34330 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34331 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34332 if (do_copy)
34333 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34334 else
34335 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34336 index ec9e606..3f38839 100644
34337 --- a/block/blk-softirq.c
34338 +++ b/block/blk-softirq.c
34339 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34340 * Softirq action handler - move entries to local list and loop over them
34341 * while passing them to the queue registered handler.
34342 */
34343 -static void blk_done_softirq(struct softirq_action *h)
34344 +static __latent_entropy void blk_done_softirq(void)
34345 {
34346 struct list_head *cpu_list, local_list;
34347
34348 diff --git a/block/bsg.c b/block/bsg.c
34349 index 420a5a9..23834aa 100644
34350 --- a/block/bsg.c
34351 +++ b/block/bsg.c
34352 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34353 struct sg_io_v4 *hdr, struct bsg_device *bd,
34354 fmode_t has_write_perm)
34355 {
34356 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34357 + unsigned char *cmdptr;
34358 +
34359 if (hdr->request_len > BLK_MAX_CDB) {
34360 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34361 if (!rq->cmd)
34362 return -ENOMEM;
34363 - }
34364 + cmdptr = rq->cmd;
34365 + } else
34366 + cmdptr = tmpcmd;
34367
34368 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34369 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34370 hdr->request_len))
34371 return -EFAULT;
34372
34373 + if (cmdptr != rq->cmd)
34374 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34375 +
34376 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34377 if (blk_verify_command(rq->cmd, has_write_perm))
34378 return -EPERM;
34379 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34380 index 7e5d474..0cf0017 100644
34381 --- a/block/compat_ioctl.c
34382 +++ b/block/compat_ioctl.c
34383 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34384 err |= __get_user(f->spec1, &uf->spec1);
34385 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34386 err |= __get_user(name, &uf->name);
34387 - f->name = compat_ptr(name);
34388 + f->name = (void __force_kernel *)compat_ptr(name);
34389 if (err) {
34390 err = -EFAULT;
34391 goto out;
34392 diff --git a/block/genhd.c b/block/genhd.c
34393 index dadf42b..48dc887 100644
34394 --- a/block/genhd.c
34395 +++ b/block/genhd.c
34396 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34397
34398 /*
34399 * Register device numbers dev..(dev+range-1)
34400 - * range must be nonzero
34401 + * Noop if @range is zero.
34402 * The hash chain is sorted on range, so that subranges can override.
34403 */
34404 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34405 struct kobject *(*probe)(dev_t, int *, void *),
34406 int (*lock)(dev_t, void *), void *data)
34407 {
34408 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34409 + if (range)
34410 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34411 }
34412
34413 EXPORT_SYMBOL(blk_register_region);
34414
34415 +/* undo blk_register_region(), noop if @range is zero */
34416 void blk_unregister_region(dev_t devt, unsigned long range)
34417 {
34418 - kobj_unmap(bdev_map, devt, range);
34419 + if (range)
34420 + kobj_unmap(bdev_map, devt, range);
34421 }
34422
34423 EXPORT_SYMBOL(blk_unregister_region);
34424 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34425 index c85fc89..51e690b 100644
34426 --- a/block/partitions/efi.c
34427 +++ b/block/partitions/efi.c
34428 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34429 if (!gpt)
34430 return NULL;
34431
34432 + if (!le32_to_cpu(gpt->num_partition_entries))
34433 + return NULL;
34434 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34435 + if (!pte)
34436 + return NULL;
34437 +
34438 count = le32_to_cpu(gpt->num_partition_entries) *
34439 le32_to_cpu(gpt->sizeof_partition_entry);
34440 - if (!count)
34441 - return NULL;
34442 - pte = kmalloc(count, GFP_KERNEL);
34443 - if (!pte)
34444 - return NULL;
34445 -
34446 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34447 (u8 *) pte,
34448 count) < count) {
34449 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34450 index a5ffcc9..3cedc9c 100644
34451 --- a/block/scsi_ioctl.c
34452 +++ b/block/scsi_ioctl.c
34453 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34454 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34455 struct sg_io_hdr *hdr, fmode_t mode)
34456 {
34457 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34458 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34459 + unsigned char *cmdptr;
34460 +
34461 + if (rq->cmd != rq->__cmd)
34462 + cmdptr = rq->cmd;
34463 + else
34464 + cmdptr = tmpcmd;
34465 +
34466 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34467 return -EFAULT;
34468 +
34469 + if (cmdptr != rq->cmd)
34470 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34471 +
34472 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34473 return -EPERM;
34474
34475 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34476 int err;
34477 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34478 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34479 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34480 + unsigned char *cmdptr;
34481
34482 if (!sic)
34483 return -EINVAL;
34484 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34485 */
34486 err = -EFAULT;
34487 rq->cmd_len = cmdlen;
34488 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34489 +
34490 + if (rq->cmd != rq->__cmd)
34491 + cmdptr = rq->cmd;
34492 + else
34493 + cmdptr = tmpcmd;
34494 +
34495 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34496 goto error;
34497
34498 + if (rq->cmd != cmdptr)
34499 + memcpy(rq->cmd, cmdptr, cmdlen);
34500 +
34501 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34502 goto error;
34503
34504 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34505 index 7bdd61b..afec999 100644
34506 --- a/crypto/cryptd.c
34507 +++ b/crypto/cryptd.c
34508 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34509
34510 struct cryptd_blkcipher_request_ctx {
34511 crypto_completion_t complete;
34512 -};
34513 +} __no_const;
34514
34515 struct cryptd_hash_ctx {
34516 struct crypto_shash *child;
34517 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34518
34519 struct cryptd_aead_request_ctx {
34520 crypto_completion_t complete;
34521 -};
34522 +} __no_const;
34523
34524 static void cryptd_queue_worker(struct work_struct *work);
34525
34526 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34527 index f8c920c..ab2cb5a 100644
34528 --- a/crypto/pcrypt.c
34529 +++ b/crypto/pcrypt.c
34530 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34531 int ret;
34532
34533 pinst->kobj.kset = pcrypt_kset;
34534 - ret = kobject_add(&pinst->kobj, NULL, name);
34535 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34536 if (!ret)
34537 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34538
34539 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34540 index f220d64..d359ad6 100644
34541 --- a/drivers/acpi/apei/apei-internal.h
34542 +++ b/drivers/acpi/apei/apei-internal.h
34543 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34544 struct apei_exec_ins_type {
34545 u32 flags;
34546 apei_exec_ins_func_t run;
34547 -};
34548 +} __do_const;
34549
34550 struct apei_exec_context {
34551 u32 ip;
34552 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34553 index 33dc6a0..4b24b47 100644
34554 --- a/drivers/acpi/apei/cper.c
34555 +++ b/drivers/acpi/apei/cper.c
34556 @@ -39,12 +39,12 @@
34557 */
34558 u64 cper_next_record_id(void)
34559 {
34560 - static atomic64_t seq;
34561 + static atomic64_unchecked_t seq;
34562
34563 - if (!atomic64_read(&seq))
34564 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34565 + if (!atomic64_read_unchecked(&seq))
34566 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34567
34568 - return atomic64_inc_return(&seq);
34569 + return atomic64_inc_return_unchecked(&seq);
34570 }
34571 EXPORT_SYMBOL_GPL(cper_next_record_id);
34572
34573 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34574 index ec9b57d..9682b3a 100644
34575 --- a/drivers/acpi/apei/ghes.c
34576 +++ b/drivers/acpi/apei/ghes.c
34577 @@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
34578 const struct acpi_hest_generic *generic,
34579 const struct acpi_hest_generic_status *estatus)
34580 {
34581 - static atomic_t seqno;
34582 + static atomic_unchecked_t seqno;
34583 unsigned int curr_seqno;
34584 char pfx_seq[64];
34585
34586 @@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
34587 else
34588 pfx = KERN_ERR;
34589 }
34590 - curr_seqno = atomic_inc_return(&seqno);
34591 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34592 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34593 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34594 pfx_seq, generic->header.source_id);
34595 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34596 index be60399..778b33e8 100644
34597 --- a/drivers/acpi/bgrt.c
34598 +++ b/drivers/acpi/bgrt.c
34599 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
34600 return -ENODEV;
34601
34602 sysfs_bin_attr_init(&image_attr);
34603 - image_attr.private = bgrt_image;
34604 - image_attr.size = bgrt_image_size;
34605 + pax_open_kernel();
34606 + *(void **)&image_attr.private = bgrt_image;
34607 + *(size_t *)&image_attr.size = bgrt_image_size;
34608 + pax_close_kernel();
34609
34610 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34611 if (!bgrt_kobj)
34612 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34613 index cb96296..b81293b 100644
34614 --- a/drivers/acpi/blacklist.c
34615 +++ b/drivers/acpi/blacklist.c
34616 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34617 u32 is_critical_error;
34618 };
34619
34620 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34621 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34622
34623 /*
34624 * POLICY: If *anything* doesn't work, put it on the blacklist.
34625 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
34626 return 0;
34627 }
34628
34629 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34630 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34631 {
34632 .callback = dmi_disable_osi_vista,
34633 .ident = "Fujitsu Siemens",
34634 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34635 index f98dd00..7b69865 100644
34636 --- a/drivers/acpi/processor_idle.c
34637 +++ b/drivers/acpi/processor_idle.c
34638 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34639 {
34640 int i, count = CPUIDLE_DRIVER_STATE_START;
34641 struct acpi_processor_cx *cx;
34642 - struct cpuidle_state *state;
34643 + cpuidle_state_no_const *state;
34644 struct cpuidle_driver *drv = &acpi_idle_driver;
34645
34646 if (!pr->flags.power_setup_done)
34647 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34648 index 05306a5..733d1f0 100644
34649 --- a/drivers/acpi/sysfs.c
34650 +++ b/drivers/acpi/sysfs.c
34651 @@ -423,11 +423,11 @@ static u32 num_counters;
34652 static struct attribute **all_attrs;
34653 static u32 acpi_gpe_count;
34654
34655 -static struct attribute_group interrupt_stats_attr_group = {
34656 +static attribute_group_no_const interrupt_stats_attr_group = {
34657 .name = "interrupts",
34658 };
34659
34660 -static struct kobj_attribute *counter_attrs;
34661 +static kobj_attribute_no_const *counter_attrs;
34662
34663 static void delete_gpe_attr_array(void)
34664 {
34665 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34666 index acfd0f7..e5acb08 100644
34667 --- a/drivers/ata/libahci.c
34668 +++ b/drivers/ata/libahci.c
34669 @@ -1231,7 +1231,7 @@ int ahci_kick_engine(struct ata_port *ap)
34670 }
34671 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34672
34673 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34674 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34675 struct ata_taskfile *tf, int is_cmd, u16 flags,
34676 unsigned long timeout_msec)
34677 {
34678 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34679 index c24354d..335c975 100644
34680 --- a/drivers/ata/libata-core.c
34681 +++ b/drivers/ata/libata-core.c
34682 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34683 static void ata_dev_xfermask(struct ata_device *dev);
34684 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34685
34686 -atomic_t ata_print_id = ATOMIC_INIT(0);
34687 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34688
34689 struct ata_force_param {
34690 const char *name;
34691 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34692 struct ata_port *ap;
34693 unsigned int tag;
34694
34695 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34696 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34697 ap = qc->ap;
34698
34699 qc->flags = 0;
34700 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34701 struct ata_port *ap;
34702 struct ata_link *link;
34703
34704 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34705 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34706 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34707 ap = qc->ap;
34708 link = qc->dev->link;
34709 @@ -5927,6 +5927,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34710 return;
34711
34712 spin_lock(&lock);
34713 + pax_open_kernel();
34714
34715 for (cur = ops->inherits; cur; cur = cur->inherits) {
34716 void **inherit = (void **)cur;
34717 @@ -5940,8 +5941,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34718 if (IS_ERR(*pp))
34719 *pp = NULL;
34720
34721 - ops->inherits = NULL;
34722 + *(struct ata_port_operations **)&ops->inherits = NULL;
34723
34724 + pax_close_kernel();
34725 spin_unlock(&lock);
34726 }
34727
34728 @@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34729
34730 /* give ports names and add SCSI hosts */
34731 for (i = 0; i < host->n_ports; i++) {
34732 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34733 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34734 host->ports[i]->local_port_no = i + 1;
34735 }
34736
34737 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34738 index b1e880a..8cf82e1 100644
34739 --- a/drivers/ata/libata-scsi.c
34740 +++ b/drivers/ata/libata-scsi.c
34741 @@ -4104,7 +4104,7 @@ int ata_sas_port_init(struct ata_port *ap)
34742
34743 if (rc)
34744 return rc;
34745 - ap->print_id = atomic_inc_return(&ata_print_id);
34746 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34747 return 0;
34748 }
34749 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34750 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34751 index 577d902b..cb4781e 100644
34752 --- a/drivers/ata/libata.h
34753 +++ b/drivers/ata/libata.h
34754 @@ -53,7 +53,7 @@ enum {
34755 ATA_DNXFER_QUIET = (1 << 31),
34756 };
34757
34758 -extern atomic_t ata_print_id;
34759 +extern atomic_unchecked_t ata_print_id;
34760 extern int atapi_passthru16;
34761 extern int libata_fua;
34762 extern int libata_noacpi;
34763 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34764 index 848ed32..132f39d 100644
34765 --- a/drivers/ata/pata_arasan_cf.c
34766 +++ b/drivers/ata/pata_arasan_cf.c
34767 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34768 /* Handle platform specific quirks */
34769 if (quirk) {
34770 if (quirk & CF_BROKEN_PIO) {
34771 - ap->ops->set_piomode = NULL;
34772 + pax_open_kernel();
34773 + *(void **)&ap->ops->set_piomode = NULL;
34774 + pax_close_kernel();
34775 ap->pio_mask = 0;
34776 }
34777 if (quirk & CF_BROKEN_MWDMA)
34778 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34779 index f9b983a..887b9d8 100644
34780 --- a/drivers/atm/adummy.c
34781 +++ b/drivers/atm/adummy.c
34782 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34783 vcc->pop(vcc, skb);
34784 else
34785 dev_kfree_skb_any(skb);
34786 - atomic_inc(&vcc->stats->tx);
34787 + atomic_inc_unchecked(&vcc->stats->tx);
34788
34789 return 0;
34790 }
34791 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34792 index 62a7607..cc4be104 100644
34793 --- a/drivers/atm/ambassador.c
34794 +++ b/drivers/atm/ambassador.c
34795 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34796 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34797
34798 // VC layer stats
34799 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34800 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34801
34802 // free the descriptor
34803 kfree (tx_descr);
34804 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34805 dump_skb ("<<<", vc, skb);
34806
34807 // VC layer stats
34808 - atomic_inc(&atm_vcc->stats->rx);
34809 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34810 __net_timestamp(skb);
34811 // end of our responsibility
34812 atm_vcc->push (atm_vcc, skb);
34813 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34814 } else {
34815 PRINTK (KERN_INFO, "dropped over-size frame");
34816 // should we count this?
34817 - atomic_inc(&atm_vcc->stats->rx_drop);
34818 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34819 }
34820
34821 } else {
34822 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34823 }
34824
34825 if (check_area (skb->data, skb->len)) {
34826 - atomic_inc(&atm_vcc->stats->tx_err);
34827 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34828 return -ENOMEM; // ?
34829 }
34830
34831 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34832 index 0e3f8f9..765a7a5 100644
34833 --- a/drivers/atm/atmtcp.c
34834 +++ b/drivers/atm/atmtcp.c
34835 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34836 if (vcc->pop) vcc->pop(vcc,skb);
34837 else dev_kfree_skb(skb);
34838 if (dev_data) return 0;
34839 - atomic_inc(&vcc->stats->tx_err);
34840 + atomic_inc_unchecked(&vcc->stats->tx_err);
34841 return -ENOLINK;
34842 }
34843 size = skb->len+sizeof(struct atmtcp_hdr);
34844 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34845 if (!new_skb) {
34846 if (vcc->pop) vcc->pop(vcc,skb);
34847 else dev_kfree_skb(skb);
34848 - atomic_inc(&vcc->stats->tx_err);
34849 + atomic_inc_unchecked(&vcc->stats->tx_err);
34850 return -ENOBUFS;
34851 }
34852 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34853 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34854 if (vcc->pop) vcc->pop(vcc,skb);
34855 else dev_kfree_skb(skb);
34856 out_vcc->push(out_vcc,new_skb);
34857 - atomic_inc(&vcc->stats->tx);
34858 - atomic_inc(&out_vcc->stats->rx);
34859 + atomic_inc_unchecked(&vcc->stats->tx);
34860 + atomic_inc_unchecked(&out_vcc->stats->rx);
34861 return 0;
34862 }
34863
34864 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34865 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34866 read_unlock(&vcc_sklist_lock);
34867 if (!out_vcc) {
34868 - atomic_inc(&vcc->stats->tx_err);
34869 + atomic_inc_unchecked(&vcc->stats->tx_err);
34870 goto done;
34871 }
34872 skb_pull(skb,sizeof(struct atmtcp_hdr));
34873 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34874 __net_timestamp(new_skb);
34875 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34876 out_vcc->push(out_vcc,new_skb);
34877 - atomic_inc(&vcc->stats->tx);
34878 - atomic_inc(&out_vcc->stats->rx);
34879 + atomic_inc_unchecked(&vcc->stats->tx);
34880 + atomic_inc_unchecked(&out_vcc->stats->rx);
34881 done:
34882 if (vcc->pop) vcc->pop(vcc,skb);
34883 else dev_kfree_skb(skb);
34884 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34885 index b1955ba..b179940 100644
34886 --- a/drivers/atm/eni.c
34887 +++ b/drivers/atm/eni.c
34888 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34889 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34890 vcc->dev->number);
34891 length = 0;
34892 - atomic_inc(&vcc->stats->rx_err);
34893 + atomic_inc_unchecked(&vcc->stats->rx_err);
34894 }
34895 else {
34896 length = ATM_CELL_SIZE-1; /* no HEC */
34897 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34898 size);
34899 }
34900 eff = length = 0;
34901 - atomic_inc(&vcc->stats->rx_err);
34902 + atomic_inc_unchecked(&vcc->stats->rx_err);
34903 }
34904 else {
34905 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34906 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34907 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34908 vcc->dev->number,vcc->vci,length,size << 2,descr);
34909 length = eff = 0;
34910 - atomic_inc(&vcc->stats->rx_err);
34911 + atomic_inc_unchecked(&vcc->stats->rx_err);
34912 }
34913 }
34914 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34915 @@ -767,7 +767,7 @@ rx_dequeued++;
34916 vcc->push(vcc,skb);
34917 pushed++;
34918 }
34919 - atomic_inc(&vcc->stats->rx);
34920 + atomic_inc_unchecked(&vcc->stats->rx);
34921 }
34922 wake_up(&eni_dev->rx_wait);
34923 }
34924 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34925 PCI_DMA_TODEVICE);
34926 if (vcc->pop) vcc->pop(vcc,skb);
34927 else dev_kfree_skb_irq(skb);
34928 - atomic_inc(&vcc->stats->tx);
34929 + atomic_inc_unchecked(&vcc->stats->tx);
34930 wake_up(&eni_dev->tx_wait);
34931 dma_complete++;
34932 }
34933 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34934 index b41c948..a002b17 100644
34935 --- a/drivers/atm/firestream.c
34936 +++ b/drivers/atm/firestream.c
34937 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34938 }
34939 }
34940
34941 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34942 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34943
34944 fs_dprintk (FS_DEBUG_TXMEM, "i");
34945 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34946 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34947 #endif
34948 skb_put (skb, qe->p1 & 0xffff);
34949 ATM_SKB(skb)->vcc = atm_vcc;
34950 - atomic_inc(&atm_vcc->stats->rx);
34951 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34952 __net_timestamp(skb);
34953 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34954 atm_vcc->push (atm_vcc, skb);
34955 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34956 kfree (pe);
34957 }
34958 if (atm_vcc)
34959 - atomic_inc(&atm_vcc->stats->rx_drop);
34960 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34961 break;
34962 case 0x1f: /* Reassembly abort: no buffers. */
34963 /* Silently increment error counter. */
34964 if (atm_vcc)
34965 - atomic_inc(&atm_vcc->stats->rx_drop);
34966 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34967 break;
34968 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34969 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34970 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34971 index 204814e..cede831 100644
34972 --- a/drivers/atm/fore200e.c
34973 +++ b/drivers/atm/fore200e.c
34974 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
34975 #endif
34976 /* check error condition */
34977 if (*entry->status & STATUS_ERROR)
34978 - atomic_inc(&vcc->stats->tx_err);
34979 + atomic_inc_unchecked(&vcc->stats->tx_err);
34980 else
34981 - atomic_inc(&vcc->stats->tx);
34982 + atomic_inc_unchecked(&vcc->stats->tx);
34983 }
34984 }
34985
34986 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34987 if (skb == NULL) {
34988 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
34989
34990 - atomic_inc(&vcc->stats->rx_drop);
34991 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34992 return -ENOMEM;
34993 }
34994
34995 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34996
34997 dev_kfree_skb_any(skb);
34998
34999 - atomic_inc(&vcc->stats->rx_drop);
35000 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35001 return -ENOMEM;
35002 }
35003
35004 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35005
35006 vcc->push(vcc, skb);
35007 - atomic_inc(&vcc->stats->rx);
35008 + atomic_inc_unchecked(&vcc->stats->rx);
35009
35010 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35011
35012 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35013 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35014 fore200e->atm_dev->number,
35015 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35016 - atomic_inc(&vcc->stats->rx_err);
35017 + atomic_inc_unchecked(&vcc->stats->rx_err);
35018 }
35019 }
35020
35021 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35022 goto retry_here;
35023 }
35024
35025 - atomic_inc(&vcc->stats->tx_err);
35026 + atomic_inc_unchecked(&vcc->stats->tx_err);
35027
35028 fore200e->tx_sat++;
35029 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35030 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35031 index 507362a..a845e57 100644
35032 --- a/drivers/atm/he.c
35033 +++ b/drivers/atm/he.c
35034 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35035
35036 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35037 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35038 - atomic_inc(&vcc->stats->rx_drop);
35039 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35040 goto return_host_buffers;
35041 }
35042
35043 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35044 RBRQ_LEN_ERR(he_dev->rbrq_head)
35045 ? "LEN_ERR" : "",
35046 vcc->vpi, vcc->vci);
35047 - atomic_inc(&vcc->stats->rx_err);
35048 + atomic_inc_unchecked(&vcc->stats->rx_err);
35049 goto return_host_buffers;
35050 }
35051
35052 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35053 vcc->push(vcc, skb);
35054 spin_lock(&he_dev->global_lock);
35055
35056 - atomic_inc(&vcc->stats->rx);
35057 + atomic_inc_unchecked(&vcc->stats->rx);
35058
35059 return_host_buffers:
35060 ++pdus_assembled;
35061 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35062 tpd->vcc->pop(tpd->vcc, tpd->skb);
35063 else
35064 dev_kfree_skb_any(tpd->skb);
35065 - atomic_inc(&tpd->vcc->stats->tx_err);
35066 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35067 }
35068 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35069 return;
35070 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35071 vcc->pop(vcc, skb);
35072 else
35073 dev_kfree_skb_any(skb);
35074 - atomic_inc(&vcc->stats->tx_err);
35075 + atomic_inc_unchecked(&vcc->stats->tx_err);
35076 return -EINVAL;
35077 }
35078
35079 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35080 vcc->pop(vcc, skb);
35081 else
35082 dev_kfree_skb_any(skb);
35083 - atomic_inc(&vcc->stats->tx_err);
35084 + atomic_inc_unchecked(&vcc->stats->tx_err);
35085 return -EINVAL;
35086 }
35087 #endif
35088 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35089 vcc->pop(vcc, skb);
35090 else
35091 dev_kfree_skb_any(skb);
35092 - atomic_inc(&vcc->stats->tx_err);
35093 + atomic_inc_unchecked(&vcc->stats->tx_err);
35094 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35095 return -ENOMEM;
35096 }
35097 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35098 vcc->pop(vcc, skb);
35099 else
35100 dev_kfree_skb_any(skb);
35101 - atomic_inc(&vcc->stats->tx_err);
35102 + atomic_inc_unchecked(&vcc->stats->tx_err);
35103 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35104 return -ENOMEM;
35105 }
35106 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35107 __enqueue_tpd(he_dev, tpd, cid);
35108 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35109
35110 - atomic_inc(&vcc->stats->tx);
35111 + atomic_inc_unchecked(&vcc->stats->tx);
35112
35113 return 0;
35114 }
35115 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35116 index 1dc0519..1aadaf7 100644
35117 --- a/drivers/atm/horizon.c
35118 +++ b/drivers/atm/horizon.c
35119 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35120 {
35121 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35122 // VC layer stats
35123 - atomic_inc(&vcc->stats->rx);
35124 + atomic_inc_unchecked(&vcc->stats->rx);
35125 __net_timestamp(skb);
35126 // end of our responsibility
35127 vcc->push (vcc, skb);
35128 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35129 dev->tx_iovec = NULL;
35130
35131 // VC layer stats
35132 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35133 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35134
35135 // free the skb
35136 hrz_kfree_skb (skb);
35137 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35138 index 272f009..a18ba55 100644
35139 --- a/drivers/atm/idt77252.c
35140 +++ b/drivers/atm/idt77252.c
35141 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35142 else
35143 dev_kfree_skb(skb);
35144
35145 - atomic_inc(&vcc->stats->tx);
35146 + atomic_inc_unchecked(&vcc->stats->tx);
35147 }
35148
35149 atomic_dec(&scq->used);
35150 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35151 if ((sb = dev_alloc_skb(64)) == NULL) {
35152 printk("%s: Can't allocate buffers for aal0.\n",
35153 card->name);
35154 - atomic_add(i, &vcc->stats->rx_drop);
35155 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35156 break;
35157 }
35158 if (!atm_charge(vcc, sb->truesize)) {
35159 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35160 card->name);
35161 - atomic_add(i - 1, &vcc->stats->rx_drop);
35162 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35163 dev_kfree_skb(sb);
35164 break;
35165 }
35166 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35167 ATM_SKB(sb)->vcc = vcc;
35168 __net_timestamp(sb);
35169 vcc->push(vcc, sb);
35170 - atomic_inc(&vcc->stats->rx);
35171 + atomic_inc_unchecked(&vcc->stats->rx);
35172
35173 cell += ATM_CELL_PAYLOAD;
35174 }
35175 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35176 "(CDC: %08x)\n",
35177 card->name, len, rpp->len, readl(SAR_REG_CDC));
35178 recycle_rx_pool_skb(card, rpp);
35179 - atomic_inc(&vcc->stats->rx_err);
35180 + atomic_inc_unchecked(&vcc->stats->rx_err);
35181 return;
35182 }
35183 if (stat & SAR_RSQE_CRC) {
35184 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35185 recycle_rx_pool_skb(card, rpp);
35186 - atomic_inc(&vcc->stats->rx_err);
35187 + atomic_inc_unchecked(&vcc->stats->rx_err);
35188 return;
35189 }
35190 if (skb_queue_len(&rpp->queue) > 1) {
35191 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35192 RXPRINTK("%s: Can't alloc RX skb.\n",
35193 card->name);
35194 recycle_rx_pool_skb(card, rpp);
35195 - atomic_inc(&vcc->stats->rx_err);
35196 + atomic_inc_unchecked(&vcc->stats->rx_err);
35197 return;
35198 }
35199 if (!atm_charge(vcc, skb->truesize)) {
35200 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35201 __net_timestamp(skb);
35202
35203 vcc->push(vcc, skb);
35204 - atomic_inc(&vcc->stats->rx);
35205 + atomic_inc_unchecked(&vcc->stats->rx);
35206
35207 return;
35208 }
35209 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35210 __net_timestamp(skb);
35211
35212 vcc->push(vcc, skb);
35213 - atomic_inc(&vcc->stats->rx);
35214 + atomic_inc_unchecked(&vcc->stats->rx);
35215
35216 if (skb->truesize > SAR_FB_SIZE_3)
35217 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35218 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35219 if (vcc->qos.aal != ATM_AAL0) {
35220 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35221 card->name, vpi, vci);
35222 - atomic_inc(&vcc->stats->rx_drop);
35223 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35224 goto drop;
35225 }
35226
35227 if ((sb = dev_alloc_skb(64)) == NULL) {
35228 printk("%s: Can't allocate buffers for AAL0.\n",
35229 card->name);
35230 - atomic_inc(&vcc->stats->rx_err);
35231 + atomic_inc_unchecked(&vcc->stats->rx_err);
35232 goto drop;
35233 }
35234
35235 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35236 ATM_SKB(sb)->vcc = vcc;
35237 __net_timestamp(sb);
35238 vcc->push(vcc, sb);
35239 - atomic_inc(&vcc->stats->rx);
35240 + atomic_inc_unchecked(&vcc->stats->rx);
35241
35242 drop:
35243 skb_pull(queue, 64);
35244 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35245
35246 if (vc == NULL) {
35247 printk("%s: NULL connection in send().\n", card->name);
35248 - atomic_inc(&vcc->stats->tx_err);
35249 + atomic_inc_unchecked(&vcc->stats->tx_err);
35250 dev_kfree_skb(skb);
35251 return -EINVAL;
35252 }
35253 if (!test_bit(VCF_TX, &vc->flags)) {
35254 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35255 - atomic_inc(&vcc->stats->tx_err);
35256 + atomic_inc_unchecked(&vcc->stats->tx_err);
35257 dev_kfree_skb(skb);
35258 return -EINVAL;
35259 }
35260 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35261 break;
35262 default:
35263 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35264 - atomic_inc(&vcc->stats->tx_err);
35265 + atomic_inc_unchecked(&vcc->stats->tx_err);
35266 dev_kfree_skb(skb);
35267 return -EINVAL;
35268 }
35269
35270 if (skb_shinfo(skb)->nr_frags != 0) {
35271 printk("%s: No scatter-gather yet.\n", card->name);
35272 - atomic_inc(&vcc->stats->tx_err);
35273 + atomic_inc_unchecked(&vcc->stats->tx_err);
35274 dev_kfree_skb(skb);
35275 return -EINVAL;
35276 }
35277 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35278
35279 err = queue_skb(card, vc, skb, oam);
35280 if (err) {
35281 - atomic_inc(&vcc->stats->tx_err);
35282 + atomic_inc_unchecked(&vcc->stats->tx_err);
35283 dev_kfree_skb(skb);
35284 return err;
35285 }
35286 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35287 skb = dev_alloc_skb(64);
35288 if (!skb) {
35289 printk("%s: Out of memory in send_oam().\n", card->name);
35290 - atomic_inc(&vcc->stats->tx_err);
35291 + atomic_inc_unchecked(&vcc->stats->tx_err);
35292 return -ENOMEM;
35293 }
35294 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35295 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35296 index 4217f29..88f547a 100644
35297 --- a/drivers/atm/iphase.c
35298 +++ b/drivers/atm/iphase.c
35299 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35300 status = (u_short) (buf_desc_ptr->desc_mode);
35301 if (status & (RX_CER | RX_PTE | RX_OFL))
35302 {
35303 - atomic_inc(&vcc->stats->rx_err);
35304 + atomic_inc_unchecked(&vcc->stats->rx_err);
35305 IF_ERR(printk("IA: bad packet, dropping it");)
35306 if (status & RX_CER) {
35307 IF_ERR(printk(" cause: packet CRC error\n");)
35308 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35309 len = dma_addr - buf_addr;
35310 if (len > iadev->rx_buf_sz) {
35311 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35312 - atomic_inc(&vcc->stats->rx_err);
35313 + atomic_inc_unchecked(&vcc->stats->rx_err);
35314 goto out_free_desc;
35315 }
35316
35317 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35318 ia_vcc = INPH_IA_VCC(vcc);
35319 if (ia_vcc == NULL)
35320 {
35321 - atomic_inc(&vcc->stats->rx_err);
35322 + atomic_inc_unchecked(&vcc->stats->rx_err);
35323 atm_return(vcc, skb->truesize);
35324 dev_kfree_skb_any(skb);
35325 goto INCR_DLE;
35326 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35327 if ((length > iadev->rx_buf_sz) || (length >
35328 (skb->len - sizeof(struct cpcs_trailer))))
35329 {
35330 - atomic_inc(&vcc->stats->rx_err);
35331 + atomic_inc_unchecked(&vcc->stats->rx_err);
35332 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35333 length, skb->len);)
35334 atm_return(vcc, skb->truesize);
35335 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35336
35337 IF_RX(printk("rx_dle_intr: skb push");)
35338 vcc->push(vcc,skb);
35339 - atomic_inc(&vcc->stats->rx);
35340 + atomic_inc_unchecked(&vcc->stats->rx);
35341 iadev->rx_pkt_cnt++;
35342 }
35343 INCR_DLE:
35344 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35345 {
35346 struct k_sonet_stats *stats;
35347 stats = &PRIV(_ia_dev[board])->sonet_stats;
35348 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35349 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35350 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35351 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35352 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35353 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35354 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35355 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35356 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35357 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35358 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35359 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35360 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35361 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35362 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35363 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35364 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35365 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35366 }
35367 ia_cmds.status = 0;
35368 break;
35369 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35370 if ((desc == 0) || (desc > iadev->num_tx_desc))
35371 {
35372 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35373 - atomic_inc(&vcc->stats->tx);
35374 + atomic_inc_unchecked(&vcc->stats->tx);
35375 if (vcc->pop)
35376 vcc->pop(vcc, skb);
35377 else
35378 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35379 ATM_DESC(skb) = vcc->vci;
35380 skb_queue_tail(&iadev->tx_dma_q, skb);
35381
35382 - atomic_inc(&vcc->stats->tx);
35383 + atomic_inc_unchecked(&vcc->stats->tx);
35384 iadev->tx_pkt_cnt++;
35385 /* Increment transaction counter */
35386 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35387
35388 #if 0
35389 /* add flow control logic */
35390 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35391 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35392 if (iavcc->vc_desc_cnt > 10) {
35393 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35394 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35395 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35396 index fa7d701..1e404c7 100644
35397 --- a/drivers/atm/lanai.c
35398 +++ b/drivers/atm/lanai.c
35399 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35400 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35401 lanai_endtx(lanai, lvcc);
35402 lanai_free_skb(lvcc->tx.atmvcc, skb);
35403 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35404 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35405 }
35406
35407 /* Try to fill the buffer - don't call unless there is backlog */
35408 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35409 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35410 __net_timestamp(skb);
35411 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35412 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35413 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35414 out:
35415 lvcc->rx.buf.ptr = end;
35416 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35417 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35418 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35419 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35420 lanai->stats.service_rxnotaal5++;
35421 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35422 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35423 return 0;
35424 }
35425 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35426 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35427 int bytes;
35428 read_unlock(&vcc_sklist_lock);
35429 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35430 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35431 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35432 lvcc->stats.x.aal5.service_trash++;
35433 bytes = (SERVICE_GET_END(s) * 16) -
35434 (((unsigned long) lvcc->rx.buf.ptr) -
35435 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35436 }
35437 if (s & SERVICE_STREAM) {
35438 read_unlock(&vcc_sklist_lock);
35439 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35440 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35441 lvcc->stats.x.aal5.service_stream++;
35442 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35443 "PDU on VCI %d!\n", lanai->number, vci);
35444 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35445 return 0;
35446 }
35447 DPRINTK("got rx crc error on vci %d\n", vci);
35448 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35449 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35450 lvcc->stats.x.aal5.service_rxcrc++;
35451 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35452 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35453 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35454 index 6587dc2..149833d 100644
35455 --- a/drivers/atm/nicstar.c
35456 +++ b/drivers/atm/nicstar.c
35457 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35458 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35459 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35460 card->index);
35461 - atomic_inc(&vcc->stats->tx_err);
35462 + atomic_inc_unchecked(&vcc->stats->tx_err);
35463 dev_kfree_skb_any(skb);
35464 return -EINVAL;
35465 }
35466 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35467 if (!vc->tx) {
35468 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35469 card->index);
35470 - atomic_inc(&vcc->stats->tx_err);
35471 + atomic_inc_unchecked(&vcc->stats->tx_err);
35472 dev_kfree_skb_any(skb);
35473 return -EINVAL;
35474 }
35475 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35476 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35477 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35478 card->index);
35479 - atomic_inc(&vcc->stats->tx_err);
35480 + atomic_inc_unchecked(&vcc->stats->tx_err);
35481 dev_kfree_skb_any(skb);
35482 return -EINVAL;
35483 }
35484
35485 if (skb_shinfo(skb)->nr_frags != 0) {
35486 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35487 - atomic_inc(&vcc->stats->tx_err);
35488 + atomic_inc_unchecked(&vcc->stats->tx_err);
35489 dev_kfree_skb_any(skb);
35490 return -EINVAL;
35491 }
35492 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35493 }
35494
35495 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35496 - atomic_inc(&vcc->stats->tx_err);
35497 + atomic_inc_unchecked(&vcc->stats->tx_err);
35498 dev_kfree_skb_any(skb);
35499 return -EIO;
35500 }
35501 - atomic_inc(&vcc->stats->tx);
35502 + atomic_inc_unchecked(&vcc->stats->tx);
35503
35504 return 0;
35505 }
35506 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35507 printk
35508 ("nicstar%d: Can't allocate buffers for aal0.\n",
35509 card->index);
35510 - atomic_add(i, &vcc->stats->rx_drop);
35511 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35512 break;
35513 }
35514 if (!atm_charge(vcc, sb->truesize)) {
35515 RXPRINTK
35516 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35517 card->index);
35518 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35519 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35520 dev_kfree_skb_any(sb);
35521 break;
35522 }
35523 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35524 ATM_SKB(sb)->vcc = vcc;
35525 __net_timestamp(sb);
35526 vcc->push(vcc, sb);
35527 - atomic_inc(&vcc->stats->rx);
35528 + atomic_inc_unchecked(&vcc->stats->rx);
35529 cell += ATM_CELL_PAYLOAD;
35530 }
35531
35532 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35533 if (iovb == NULL) {
35534 printk("nicstar%d: Out of iovec buffers.\n",
35535 card->index);
35536 - atomic_inc(&vcc->stats->rx_drop);
35537 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35538 recycle_rx_buf(card, skb);
35539 return;
35540 }
35541 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35542 small or large buffer itself. */
35543 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35544 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35545 - atomic_inc(&vcc->stats->rx_err);
35546 + atomic_inc_unchecked(&vcc->stats->rx_err);
35547 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35548 NS_MAX_IOVECS);
35549 NS_PRV_IOVCNT(iovb) = 0;
35550 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35551 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35552 card->index);
35553 which_list(card, skb);
35554 - atomic_inc(&vcc->stats->rx_err);
35555 + atomic_inc_unchecked(&vcc->stats->rx_err);
35556 recycle_rx_buf(card, skb);
35557 vc->rx_iov = NULL;
35558 recycle_iov_buf(card, iovb);
35559 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35560 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35561 card->index);
35562 which_list(card, skb);
35563 - atomic_inc(&vcc->stats->rx_err);
35564 + atomic_inc_unchecked(&vcc->stats->rx_err);
35565 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35566 NS_PRV_IOVCNT(iovb));
35567 vc->rx_iov = NULL;
35568 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35569 printk(" - PDU size mismatch.\n");
35570 else
35571 printk(".\n");
35572 - atomic_inc(&vcc->stats->rx_err);
35573 + atomic_inc_unchecked(&vcc->stats->rx_err);
35574 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35575 NS_PRV_IOVCNT(iovb));
35576 vc->rx_iov = NULL;
35577 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35578 /* skb points to a small buffer */
35579 if (!atm_charge(vcc, skb->truesize)) {
35580 push_rxbufs(card, skb);
35581 - atomic_inc(&vcc->stats->rx_drop);
35582 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35583 } else {
35584 skb_put(skb, len);
35585 dequeue_sm_buf(card, skb);
35586 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35587 ATM_SKB(skb)->vcc = vcc;
35588 __net_timestamp(skb);
35589 vcc->push(vcc, skb);
35590 - atomic_inc(&vcc->stats->rx);
35591 + atomic_inc_unchecked(&vcc->stats->rx);
35592 }
35593 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35594 struct sk_buff *sb;
35595 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35596 if (len <= NS_SMBUFSIZE) {
35597 if (!atm_charge(vcc, sb->truesize)) {
35598 push_rxbufs(card, sb);
35599 - atomic_inc(&vcc->stats->rx_drop);
35600 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35601 } else {
35602 skb_put(sb, len);
35603 dequeue_sm_buf(card, sb);
35604 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35605 ATM_SKB(sb)->vcc = vcc;
35606 __net_timestamp(sb);
35607 vcc->push(vcc, sb);
35608 - atomic_inc(&vcc->stats->rx);
35609 + atomic_inc_unchecked(&vcc->stats->rx);
35610 }
35611
35612 push_rxbufs(card, skb);
35613 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35614
35615 if (!atm_charge(vcc, skb->truesize)) {
35616 push_rxbufs(card, skb);
35617 - atomic_inc(&vcc->stats->rx_drop);
35618 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35619 } else {
35620 dequeue_lg_buf(card, skb);
35621 #ifdef NS_USE_DESTRUCTORS
35622 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35623 ATM_SKB(skb)->vcc = vcc;
35624 __net_timestamp(skb);
35625 vcc->push(vcc, skb);
35626 - atomic_inc(&vcc->stats->rx);
35627 + atomic_inc_unchecked(&vcc->stats->rx);
35628 }
35629
35630 push_rxbufs(card, sb);
35631 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35632 printk
35633 ("nicstar%d: Out of huge buffers.\n",
35634 card->index);
35635 - atomic_inc(&vcc->stats->rx_drop);
35636 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35637 recycle_iovec_rx_bufs(card,
35638 (struct iovec *)
35639 iovb->data,
35640 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35641 card->hbpool.count++;
35642 } else
35643 dev_kfree_skb_any(hb);
35644 - atomic_inc(&vcc->stats->rx_drop);
35645 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35646 } else {
35647 /* Copy the small buffer to the huge buffer */
35648 sb = (struct sk_buff *)iov->iov_base;
35649 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35650 #endif /* NS_USE_DESTRUCTORS */
35651 __net_timestamp(hb);
35652 vcc->push(vcc, hb);
35653 - atomic_inc(&vcc->stats->rx);
35654 + atomic_inc_unchecked(&vcc->stats->rx);
35655 }
35656 }
35657
35658 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35659 index 32784d1..4a8434a 100644
35660 --- a/drivers/atm/solos-pci.c
35661 +++ b/drivers/atm/solos-pci.c
35662 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35663 }
35664 atm_charge(vcc, skb->truesize);
35665 vcc->push(vcc, skb);
35666 - atomic_inc(&vcc->stats->rx);
35667 + atomic_inc_unchecked(&vcc->stats->rx);
35668 break;
35669
35670 case PKT_STATUS:
35671 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35672 vcc = SKB_CB(oldskb)->vcc;
35673
35674 if (vcc) {
35675 - atomic_inc(&vcc->stats->tx);
35676 + atomic_inc_unchecked(&vcc->stats->tx);
35677 solos_pop(vcc, oldskb);
35678 } else {
35679 dev_kfree_skb_irq(oldskb);
35680 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35681 index 0215934..ce9f5b1 100644
35682 --- a/drivers/atm/suni.c
35683 +++ b/drivers/atm/suni.c
35684 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35685
35686
35687 #define ADD_LIMITED(s,v) \
35688 - atomic_add((v),&stats->s); \
35689 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35690 + atomic_add_unchecked((v),&stats->s); \
35691 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35692
35693
35694 static void suni_hz(unsigned long from_timer)
35695 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35696 index 5120a96..e2572bd 100644
35697 --- a/drivers/atm/uPD98402.c
35698 +++ b/drivers/atm/uPD98402.c
35699 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35700 struct sonet_stats tmp;
35701 int error = 0;
35702
35703 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35704 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35705 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35706 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35707 if (zero && !error) {
35708 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35709
35710
35711 #define ADD_LIMITED(s,v) \
35712 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35713 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35714 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35715 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35716 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35717 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35718
35719
35720 static void stat_event(struct atm_dev *dev)
35721 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35722 if (reason & uPD98402_INT_PFM) stat_event(dev);
35723 if (reason & uPD98402_INT_PCO) {
35724 (void) GET(PCOCR); /* clear interrupt cause */
35725 - atomic_add(GET(HECCT),
35726 + atomic_add_unchecked(GET(HECCT),
35727 &PRIV(dev)->sonet_stats.uncorr_hcs);
35728 }
35729 if ((reason & uPD98402_INT_RFO) &&
35730 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35731 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35732 uPD98402_INT_LOS),PIMR); /* enable them */
35733 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35734 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35735 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35736 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35737 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35738 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35739 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35740 return 0;
35741 }
35742
35743 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35744 index 969c3c2..9b72956 100644
35745 --- a/drivers/atm/zatm.c
35746 +++ b/drivers/atm/zatm.c
35747 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35748 }
35749 if (!size) {
35750 dev_kfree_skb_irq(skb);
35751 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35752 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35753 continue;
35754 }
35755 if (!atm_charge(vcc,skb->truesize)) {
35756 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35757 skb->len = size;
35758 ATM_SKB(skb)->vcc = vcc;
35759 vcc->push(vcc,skb);
35760 - atomic_inc(&vcc->stats->rx);
35761 + atomic_inc_unchecked(&vcc->stats->rx);
35762 }
35763 zout(pos & 0xffff,MTA(mbx));
35764 #if 0 /* probably a stupid idea */
35765 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35766 skb_queue_head(&zatm_vcc->backlog,skb);
35767 break;
35768 }
35769 - atomic_inc(&vcc->stats->tx);
35770 + atomic_inc_unchecked(&vcc->stats->tx);
35771 wake_up(&zatm_vcc->tx_wait);
35772 }
35773
35774 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35775 index d414331..b4dd4ba 100644
35776 --- a/drivers/base/bus.c
35777 +++ b/drivers/base/bus.c
35778 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35779 return -EINVAL;
35780
35781 mutex_lock(&subsys->p->mutex);
35782 - list_add_tail(&sif->node, &subsys->p->interfaces);
35783 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35784 if (sif->add_dev) {
35785 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35786 while ((dev = subsys_dev_iter_next(&iter)))
35787 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35788 subsys = sif->subsys;
35789
35790 mutex_lock(&subsys->p->mutex);
35791 - list_del_init(&sif->node);
35792 + pax_list_del_init((struct list_head *)&sif->node);
35793 if (sif->remove_dev) {
35794 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35795 while ((dev = subsys_dev_iter_next(&iter)))
35796 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35797 index 7413d06..79155fa 100644
35798 --- a/drivers/base/devtmpfs.c
35799 +++ b/drivers/base/devtmpfs.c
35800 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35801 if (!thread)
35802 return 0;
35803
35804 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35805 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35806 if (err)
35807 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35808 else
35809 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35810 *err = sys_unshare(CLONE_NEWNS);
35811 if (*err)
35812 goto out;
35813 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35814 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35815 if (*err)
35816 goto out;
35817 - sys_chdir("/.."); /* will traverse into overmounted root */
35818 - sys_chroot(".");
35819 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35820 + sys_chroot((char __force_user *)".");
35821 complete(&setup_done);
35822 while (1) {
35823 spin_lock(&req_lock);
35824 diff --git a/drivers/base/node.c b/drivers/base/node.c
35825 index 7616a77c..8f57f51 100644
35826 --- a/drivers/base/node.c
35827 +++ b/drivers/base/node.c
35828 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35829 struct node_attr {
35830 struct device_attribute attr;
35831 enum node_states state;
35832 -};
35833 +} __do_const;
35834
35835 static ssize_t show_node_state(struct device *dev,
35836 struct device_attribute *attr, char *buf)
35837 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35838 index bfb8955..42c9b9a 100644
35839 --- a/drivers/base/power/domain.c
35840 +++ b/drivers/base/power/domain.c
35841 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35842 {
35843 struct cpuidle_driver *cpuidle_drv;
35844 struct gpd_cpu_data *cpu_data;
35845 - struct cpuidle_state *idle_state;
35846 + cpuidle_state_no_const *idle_state;
35847 int ret = 0;
35848
35849 if (IS_ERR_OR_NULL(genpd) || state < 0)
35850 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35851 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35852 {
35853 struct gpd_cpu_data *cpu_data;
35854 - struct cpuidle_state *idle_state;
35855 + cpuidle_state_no_const *idle_state;
35856 int ret = 0;
35857
35858 if (IS_ERR_OR_NULL(genpd))
35859 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35860 index a53ebd2..8f73eeb 100644
35861 --- a/drivers/base/power/sysfs.c
35862 +++ b/drivers/base/power/sysfs.c
35863 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35864 return -EIO;
35865 }
35866 }
35867 - return sprintf(buf, p);
35868 + return sprintf(buf, "%s", p);
35869 }
35870
35871 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35872 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35873 index 2d56f41..8830f19 100644
35874 --- a/drivers/base/power/wakeup.c
35875 +++ b/drivers/base/power/wakeup.c
35876 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35877 * They need to be modified together atomically, so it's better to use one
35878 * atomic variable to hold them both.
35879 */
35880 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35881 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35882
35883 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35884 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35885
35886 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35887 {
35888 - unsigned int comb = atomic_read(&combined_event_count);
35889 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35890
35891 *cnt = (comb >> IN_PROGRESS_BITS);
35892 *inpr = comb & MAX_IN_PROGRESS;
35893 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35894 ws->start_prevent_time = ws->last_time;
35895
35896 /* Increment the counter of events in progress. */
35897 - cec = atomic_inc_return(&combined_event_count);
35898 + cec = atomic_inc_return_unchecked(&combined_event_count);
35899
35900 trace_wakeup_source_activate(ws->name, cec);
35901 }
35902 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35903 * Increment the counter of registered wakeup events and decrement the
35904 * couter of wakeup events in progress simultaneously.
35905 */
35906 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35907 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35908 trace_wakeup_source_deactivate(ws->name, cec);
35909
35910 split_counters(&cnt, &inpr);
35911 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35912 index e8d11b6..7b1b36f 100644
35913 --- a/drivers/base/syscore.c
35914 +++ b/drivers/base/syscore.c
35915 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35916 void register_syscore_ops(struct syscore_ops *ops)
35917 {
35918 mutex_lock(&syscore_ops_lock);
35919 - list_add_tail(&ops->node, &syscore_ops_list);
35920 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35921 mutex_unlock(&syscore_ops_lock);
35922 }
35923 EXPORT_SYMBOL_GPL(register_syscore_ops);
35924 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35925 void unregister_syscore_ops(struct syscore_ops *ops)
35926 {
35927 mutex_lock(&syscore_ops_lock);
35928 - list_del(&ops->node);
35929 + pax_list_del((struct list_head *)&ops->node);
35930 mutex_unlock(&syscore_ops_lock);
35931 }
35932 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35933 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35934 index 90a4e6b..002d10f 100644
35935 --- a/drivers/block/cciss.c
35936 +++ b/drivers/block/cciss.c
35937 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
35938 while (!list_empty(&h->reqQ)) {
35939 c = list_entry(h->reqQ.next, CommandList_struct, list);
35940 /* can't do anything if fifo is full */
35941 - if ((h->access.fifo_full(h))) {
35942 + if ((h->access->fifo_full(h))) {
35943 dev_warn(&h->pdev->dev, "fifo full\n");
35944 break;
35945 }
35946 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
35947 h->Qdepth--;
35948
35949 /* Tell the controller execute command */
35950 - h->access.submit_command(h, c);
35951 + h->access->submit_command(h, c);
35952
35953 /* Put job onto the completed Q */
35954 addQ(&h->cmpQ, c);
35955 @@ -3447,17 +3447,17 @@ startio:
35956
35957 static inline unsigned long get_next_completion(ctlr_info_t *h)
35958 {
35959 - return h->access.command_completed(h);
35960 + return h->access->command_completed(h);
35961 }
35962
35963 static inline int interrupt_pending(ctlr_info_t *h)
35964 {
35965 - return h->access.intr_pending(h);
35966 + return h->access->intr_pending(h);
35967 }
35968
35969 static inline long interrupt_not_for_us(ctlr_info_t *h)
35970 {
35971 - return ((h->access.intr_pending(h) == 0) ||
35972 + return ((h->access->intr_pending(h) == 0) ||
35973 (h->interrupts_enabled == 0));
35974 }
35975
35976 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
35977 u32 a;
35978
35979 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
35980 - return h->access.command_completed(h);
35981 + return h->access->command_completed(h);
35982
35983 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
35984 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
35985 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
35986 trans_support & CFGTBL_Trans_use_short_tags);
35987
35988 /* Change the access methods to the performant access methods */
35989 - h->access = SA5_performant_access;
35990 + h->access = &SA5_performant_access;
35991 h->transMethod = CFGTBL_Trans_Performant;
35992
35993 return;
35994 @@ -4320,7 +4320,7 @@ static int cciss_pci_init(ctlr_info_t *h)
35995 if (prod_index < 0)
35996 return -ENODEV;
35997 h->product_name = products[prod_index].product_name;
35998 - h->access = *(products[prod_index].access);
35999 + h->access = products[prod_index].access;
36000
36001 if (cciss_board_disabled(h)) {
36002 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36003 @@ -5052,7 +5052,7 @@ reinit_after_soft_reset:
36004 }
36005
36006 /* make sure the board interrupts are off */
36007 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36008 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36009 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36010 if (rc)
36011 goto clean2;
36012 @@ -5102,7 +5102,7 @@ reinit_after_soft_reset:
36013 * fake ones to scoop up any residual completions.
36014 */
36015 spin_lock_irqsave(&h->lock, flags);
36016 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36017 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36018 spin_unlock_irqrestore(&h->lock, flags);
36019 free_irq(h->intr[h->intr_mode], h);
36020 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36021 @@ -5122,9 +5122,9 @@ reinit_after_soft_reset:
36022 dev_info(&h->pdev->dev, "Board READY.\n");
36023 dev_info(&h->pdev->dev,
36024 "Waiting for stale completions to drain.\n");
36025 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36026 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36027 msleep(10000);
36028 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36029 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36030
36031 rc = controller_reset_failed(h->cfgtable);
36032 if (rc)
36033 @@ -5147,7 +5147,7 @@ reinit_after_soft_reset:
36034 cciss_scsi_setup(h);
36035
36036 /* Turn the interrupts on so we can service requests */
36037 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36038 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36039
36040 /* Get the firmware version */
36041 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36042 @@ -5219,7 +5219,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36043 kfree(flush_buf);
36044 if (return_code != IO_OK)
36045 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36046 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36047 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36048 free_irq(h->intr[h->intr_mode], h);
36049 }
36050
36051 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36052 index 7fda30e..eb5dfe0 100644
36053 --- a/drivers/block/cciss.h
36054 +++ b/drivers/block/cciss.h
36055 @@ -101,7 +101,7 @@ struct ctlr_info
36056 /* information about each logical volume */
36057 drive_info_struct *drv[CISS_MAX_LUN];
36058
36059 - struct access_method access;
36060 + struct access_method *access;
36061
36062 /* queue and queue Info */
36063 struct list_head reqQ;
36064 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36065 index 2b94403..fd6ad1f 100644
36066 --- a/drivers/block/cpqarray.c
36067 +++ b/drivers/block/cpqarray.c
36068 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36069 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36070 goto Enomem4;
36071 }
36072 - hba[i]->access.set_intr_mask(hba[i], 0);
36073 + hba[i]->access->set_intr_mask(hba[i], 0);
36074 if (request_irq(hba[i]->intr, do_ida_intr,
36075 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36076 {
36077 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36078 add_timer(&hba[i]->timer);
36079
36080 /* Enable IRQ now that spinlock and rate limit timer are set up */
36081 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36082 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36083
36084 for(j=0; j<NWD; j++) {
36085 struct gendisk *disk = ida_gendisk[i][j];
36086 @@ -694,7 +694,7 @@ DBGINFO(
36087 for(i=0; i<NR_PRODUCTS; i++) {
36088 if (board_id == products[i].board_id) {
36089 c->product_name = products[i].product_name;
36090 - c->access = *(products[i].access);
36091 + c->access = products[i].access;
36092 break;
36093 }
36094 }
36095 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36096 hba[ctlr]->intr = intr;
36097 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36098 hba[ctlr]->product_name = products[j].product_name;
36099 - hba[ctlr]->access = *(products[j].access);
36100 + hba[ctlr]->access = products[j].access;
36101 hba[ctlr]->ctlr = ctlr;
36102 hba[ctlr]->board_id = board_id;
36103 hba[ctlr]->pci_dev = NULL; /* not PCI */
36104 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36105
36106 while((c = h->reqQ) != NULL) {
36107 /* Can't do anything if we're busy */
36108 - if (h->access.fifo_full(h) == 0)
36109 + if (h->access->fifo_full(h) == 0)
36110 return;
36111
36112 /* Get the first entry from the request Q */
36113 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36114 h->Qdepth--;
36115
36116 /* Tell the controller to do our bidding */
36117 - h->access.submit_command(h, c);
36118 + h->access->submit_command(h, c);
36119
36120 /* Get onto the completion Q */
36121 addQ(&h->cmpQ, c);
36122 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36123 unsigned long flags;
36124 __u32 a,a1;
36125
36126 - istat = h->access.intr_pending(h);
36127 + istat = h->access->intr_pending(h);
36128 /* Is this interrupt for us? */
36129 if (istat == 0)
36130 return IRQ_NONE;
36131 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36132 */
36133 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36134 if (istat & FIFO_NOT_EMPTY) {
36135 - while((a = h->access.command_completed(h))) {
36136 + while((a = h->access->command_completed(h))) {
36137 a1 = a; a &= ~3;
36138 if ((c = h->cmpQ) == NULL)
36139 {
36140 @@ -1448,11 +1448,11 @@ static int sendcmd(
36141 /*
36142 * Disable interrupt
36143 */
36144 - info_p->access.set_intr_mask(info_p, 0);
36145 + info_p->access->set_intr_mask(info_p, 0);
36146 /* Make sure there is room in the command FIFO */
36147 /* Actually it should be completely empty at this time. */
36148 for (i = 200000; i > 0; i--) {
36149 - temp = info_p->access.fifo_full(info_p);
36150 + temp = info_p->access->fifo_full(info_p);
36151 if (temp != 0) {
36152 break;
36153 }
36154 @@ -1465,7 +1465,7 @@ DBG(
36155 /*
36156 * Send the cmd
36157 */
36158 - info_p->access.submit_command(info_p, c);
36159 + info_p->access->submit_command(info_p, c);
36160 complete = pollcomplete(ctlr);
36161
36162 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36163 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36164 * we check the new geometry. Then turn interrupts back on when
36165 * we're done.
36166 */
36167 - host->access.set_intr_mask(host, 0);
36168 + host->access->set_intr_mask(host, 0);
36169 getgeometry(ctlr);
36170 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36171 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36172
36173 for(i=0; i<NWD; i++) {
36174 struct gendisk *disk = ida_gendisk[ctlr][i];
36175 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36176 /* Wait (up to 2 seconds) for a command to complete */
36177
36178 for (i = 200000; i > 0; i--) {
36179 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36180 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36181 if (done == 0) {
36182 udelay(10); /* a short fixed delay */
36183 } else
36184 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36185 index be73e9d..7fbf140 100644
36186 --- a/drivers/block/cpqarray.h
36187 +++ b/drivers/block/cpqarray.h
36188 @@ -99,7 +99,7 @@ struct ctlr_info {
36189 drv_info_t drv[NWD];
36190 struct proc_dir_entry *proc;
36191
36192 - struct access_method access;
36193 + struct access_method *access;
36194
36195 cmdlist_t *reqQ;
36196 cmdlist_t *cmpQ;
36197 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36198 index 2d7f608..11245fe 100644
36199 --- a/drivers/block/drbd/drbd_int.h
36200 +++ b/drivers/block/drbd/drbd_int.h
36201 @@ -582,7 +582,7 @@ struct drbd_epoch {
36202 struct drbd_tconn *tconn;
36203 struct list_head list;
36204 unsigned int barrier_nr;
36205 - atomic_t epoch_size; /* increased on every request added. */
36206 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36207 atomic_t active; /* increased on every req. added, and dec on every finished. */
36208 unsigned long flags;
36209 };
36210 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36211 unsigned int al_tr_number;
36212 int al_tr_cycle;
36213 wait_queue_head_t seq_wait;
36214 - atomic_t packet_seq;
36215 + atomic_unchecked_t packet_seq;
36216 unsigned int peer_seq;
36217 spinlock_t peer_seq_lock;
36218 unsigned int minor;
36219 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36220 char __user *uoptval;
36221 int err;
36222
36223 - uoptval = (char __user __force *)optval;
36224 + uoptval = (char __force_user *)optval;
36225
36226 set_fs(KERNEL_DS);
36227 if (level == SOL_SOCKET)
36228 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36229 index 55635ed..40e837c 100644
36230 --- a/drivers/block/drbd/drbd_main.c
36231 +++ b/drivers/block/drbd/drbd_main.c
36232 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36233 p->sector = sector;
36234 p->block_id = block_id;
36235 p->blksize = blksize;
36236 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36237 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36238 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36239 }
36240
36241 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36242 return -EIO;
36243 p->sector = cpu_to_be64(req->i.sector);
36244 p->block_id = (unsigned long)req;
36245 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36246 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36247 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36248 if (mdev->state.conn >= C_SYNC_SOURCE &&
36249 mdev->state.conn <= C_PAUSED_SYNC_T)
36250 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36251 {
36252 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36253
36254 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36255 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36256 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36257 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36258 kfree(tconn->current_epoch);
36259
36260 idr_destroy(&tconn->volumes);
36261 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36262 index 8cc1e64..ba7ffa9 100644
36263 --- a/drivers/block/drbd/drbd_nl.c
36264 +++ b/drivers/block/drbd/drbd_nl.c
36265 @@ -3440,7 +3440,7 @@ out:
36266
36267 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36268 {
36269 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36270 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36271 struct sk_buff *msg;
36272 struct drbd_genlmsghdr *d_out;
36273 unsigned seq;
36274 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36275 return;
36276 }
36277
36278 - seq = atomic_inc_return(&drbd_genl_seq);
36279 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36280 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36281 if (!msg)
36282 goto failed;
36283 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36284 index cc29cd3..d4b058b 100644
36285 --- a/drivers/block/drbd/drbd_receiver.c
36286 +++ b/drivers/block/drbd/drbd_receiver.c
36287 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36288 {
36289 int err;
36290
36291 - atomic_set(&mdev->packet_seq, 0);
36292 + atomic_set_unchecked(&mdev->packet_seq, 0);
36293 mdev->peer_seq = 0;
36294
36295 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36296 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36297 do {
36298 next_epoch = NULL;
36299
36300 - epoch_size = atomic_read(&epoch->epoch_size);
36301 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36302
36303 switch (ev & ~EV_CLEANUP) {
36304 case EV_PUT:
36305 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36306 rv = FE_DESTROYED;
36307 } else {
36308 epoch->flags = 0;
36309 - atomic_set(&epoch->epoch_size, 0);
36310 + atomic_set_unchecked(&epoch->epoch_size, 0);
36311 /* atomic_set(&epoch->active, 0); is already zero */
36312 if (rv == FE_STILL_LIVE)
36313 rv = FE_RECYCLED;
36314 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36315 conn_wait_active_ee_empty(tconn);
36316 drbd_flush(tconn);
36317
36318 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36319 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36320 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36321 if (epoch)
36322 break;
36323 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36324 }
36325
36326 epoch->flags = 0;
36327 - atomic_set(&epoch->epoch_size, 0);
36328 + atomic_set_unchecked(&epoch->epoch_size, 0);
36329 atomic_set(&epoch->active, 0);
36330
36331 spin_lock(&tconn->epoch_lock);
36332 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36333 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36334 list_add(&epoch->list, &tconn->current_epoch->list);
36335 tconn->current_epoch = epoch;
36336 tconn->epochs++;
36337 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36338
36339 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36340 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36341 - atomic_inc(&tconn->current_epoch->epoch_size);
36342 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36343 err2 = drbd_drain_block(mdev, pi->size);
36344 if (!err)
36345 err = err2;
36346 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36347
36348 spin_lock(&tconn->epoch_lock);
36349 peer_req->epoch = tconn->current_epoch;
36350 - atomic_inc(&peer_req->epoch->epoch_size);
36351 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36352 atomic_inc(&peer_req->epoch->active);
36353 spin_unlock(&tconn->epoch_lock);
36354
36355 @@ -4347,7 +4347,7 @@ struct data_cmd {
36356 int expect_payload;
36357 size_t pkt_size;
36358 int (*fn)(struct drbd_tconn *, struct packet_info *);
36359 -};
36360 +} __do_const;
36361
36362 static struct data_cmd drbd_cmd_handler[] = {
36363 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36364 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36365 if (!list_empty(&tconn->current_epoch->list))
36366 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36367 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36368 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36369 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36370 tconn->send.seen_any_write_yet = false;
36371
36372 conn_info(tconn, "Connection closed\n");
36373 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36374 struct asender_cmd {
36375 size_t pkt_size;
36376 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36377 -};
36378 +} __do_const;
36379
36380 static struct asender_cmd asender_tbl[] = {
36381 [P_PING] = { 0, got_Ping },
36382 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36383 index 40e7155..df5c79a 100644
36384 --- a/drivers/block/loop.c
36385 +++ b/drivers/block/loop.c
36386 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36387
36388 file_start_write(file);
36389 set_fs(get_ds());
36390 - bw = file->f_op->write(file, buf, len, &pos);
36391 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36392 set_fs(old_fs);
36393 file_end_write(file);
36394 if (likely(bw == len))
36395 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36396 index f5d0ea1..c62380a 100644
36397 --- a/drivers/block/pktcdvd.c
36398 +++ b/drivers/block/pktcdvd.c
36399 @@ -84,7 +84,7 @@
36400 #define MAX_SPEED 0xffff
36401
36402 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
36403 - ~(sector_t)((pd)->settings.size - 1))
36404 + ~(sector_t)((pd)->settings.size - 1UL))
36405
36406 static DEFINE_MUTEX(pktcdvd_mutex);
36407 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
36408 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
36409 index 60abf59..80789e1 100644
36410 --- a/drivers/bluetooth/btwilink.c
36411 +++ b/drivers/bluetooth/btwilink.c
36412 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
36413
36414 static int bt_ti_probe(struct platform_device *pdev)
36415 {
36416 - static struct ti_st *hst;
36417 + struct ti_st *hst;
36418 struct hci_dev *hdev;
36419 int err;
36420
36421 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36422 index 7332889..9ece19e 100644
36423 --- a/drivers/bus/arm-cci.c
36424 +++ b/drivers/bus/arm-cci.c
36425 @@ -419,7 +419,7 @@ static int __init cci_probe(void)
36426
36427 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36428
36429 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36430 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36431 if (!ports)
36432 return -ENOMEM;
36433
36434 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36435 index 8a3aff7..d7538c2 100644
36436 --- a/drivers/cdrom/cdrom.c
36437 +++ b/drivers/cdrom/cdrom.c
36438 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36439 ENSURE(reset, CDC_RESET);
36440 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36441 cdi->mc_flags = 0;
36442 - cdo->n_minors = 0;
36443 cdi->options = CDO_USE_FFLAGS;
36444
36445 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36446 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36447 else
36448 cdi->cdda_method = CDDA_OLD;
36449
36450 - if (!cdo->generic_packet)
36451 - cdo->generic_packet = cdrom_dummy_generic_packet;
36452 + if (!cdo->generic_packet) {
36453 + pax_open_kernel();
36454 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36455 + pax_close_kernel();
36456 + }
36457
36458 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36459 mutex_lock(&cdrom_mutex);
36460 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36461 if (cdi->exit)
36462 cdi->exit(cdi);
36463
36464 - cdi->ops->n_minors--;
36465 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36466 }
36467
36468 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36469 */
36470 nr = nframes;
36471 do {
36472 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36473 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36474 if (cgc.buffer)
36475 break;
36476
36477 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36478 struct cdrom_device_info *cdi;
36479 int ret;
36480
36481 - ret = scnprintf(info + *pos, max_size - *pos, header);
36482 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36483 if (!ret)
36484 return 1;
36485
36486 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36487 index 5980cb9..6d7bd7e 100644
36488 --- a/drivers/cdrom/gdrom.c
36489 +++ b/drivers/cdrom/gdrom.c
36490 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36491 .audio_ioctl = gdrom_audio_ioctl,
36492 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36493 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36494 - .n_minors = 1,
36495 };
36496
36497 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36498 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36499 index 1421997..33f5d6d 100644
36500 --- a/drivers/char/Kconfig
36501 +++ b/drivers/char/Kconfig
36502 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36503
36504 config DEVKMEM
36505 bool "/dev/kmem virtual device support"
36506 - default y
36507 + default n
36508 + depends on !GRKERNSEC_KMEM
36509 help
36510 Say Y here if you want to support the /dev/kmem device. The
36511 /dev/kmem device is rarely used, but can be used for certain
36512 @@ -570,6 +571,7 @@ config DEVPORT
36513 bool
36514 depends on !M68K
36515 depends on ISA || PCI
36516 + depends on !GRKERNSEC_KMEM
36517 default y
36518
36519 source "drivers/s390/char/Kconfig"
36520 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36521 index a48e05b..6bac831 100644
36522 --- a/drivers/char/agp/compat_ioctl.c
36523 +++ b/drivers/char/agp/compat_ioctl.c
36524 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36525 return -ENOMEM;
36526 }
36527
36528 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36529 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36530 sizeof(*usegment) * ureserve.seg_count)) {
36531 kfree(usegment);
36532 kfree(ksegment);
36533 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36534 index 1b19239..b87b143 100644
36535 --- a/drivers/char/agp/frontend.c
36536 +++ b/drivers/char/agp/frontend.c
36537 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36538 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36539 return -EFAULT;
36540
36541 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36542 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36543 return -EFAULT;
36544
36545 client = agp_find_client_by_pid(reserve.pid);
36546 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36547 if (segment == NULL)
36548 return -ENOMEM;
36549
36550 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36551 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36552 sizeof(struct agp_segment) * reserve.seg_count)) {
36553 kfree(segment);
36554 return -EFAULT;
36555 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36556 index 4f94375..413694e 100644
36557 --- a/drivers/char/genrtc.c
36558 +++ b/drivers/char/genrtc.c
36559 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36560 switch (cmd) {
36561
36562 case RTC_PLL_GET:
36563 + memset(&pll, 0, sizeof(pll));
36564 if (get_rtc_pll(&pll))
36565 return -EINVAL;
36566 else
36567 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36568 index 448ce5e..3a76625 100644
36569 --- a/drivers/char/hpet.c
36570 +++ b/drivers/char/hpet.c
36571 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36572 }
36573
36574 static int
36575 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36576 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36577 struct hpet_info *info)
36578 {
36579 struct hpet_timer __iomem *timer;
36580 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36581 index 86fe45c..c0ea948 100644
36582 --- a/drivers/char/hw_random/intel-rng.c
36583 +++ b/drivers/char/hw_random/intel-rng.c
36584 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36585
36586 if (no_fwh_detect)
36587 return -ENODEV;
36588 - printk(warning);
36589 + printk("%s", warning);
36590 return -EBUSY;
36591 }
36592
36593 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36594 index 4445fa1..7c6de37 100644
36595 --- a/drivers/char/ipmi/ipmi_msghandler.c
36596 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36597 @@ -420,7 +420,7 @@ struct ipmi_smi {
36598 struct proc_dir_entry *proc_dir;
36599 char proc_dir_name[10];
36600
36601 - atomic_t stats[IPMI_NUM_STATS];
36602 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36603
36604 /*
36605 * run_to_completion duplicate of smb_info, smi_info
36606 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36607
36608
36609 #define ipmi_inc_stat(intf, stat) \
36610 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36611 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36612 #define ipmi_get_stat(intf, stat) \
36613 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36614 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36615
36616 static int is_lan_addr(struct ipmi_addr *addr)
36617 {
36618 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36619 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36620 init_waitqueue_head(&intf->waitq);
36621 for (i = 0; i < IPMI_NUM_STATS; i++)
36622 - atomic_set(&intf->stats[i], 0);
36623 + atomic_set_unchecked(&intf->stats[i], 0);
36624
36625 intf->proc_dir = NULL;
36626
36627 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36628 index af4b23f..79806fc 100644
36629 --- a/drivers/char/ipmi/ipmi_si_intf.c
36630 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36631 @@ -275,7 +275,7 @@ struct smi_info {
36632 unsigned char slave_addr;
36633
36634 /* Counters and things for the proc filesystem. */
36635 - atomic_t stats[SI_NUM_STATS];
36636 + atomic_unchecked_t stats[SI_NUM_STATS];
36637
36638 struct task_struct *thread;
36639
36640 @@ -284,9 +284,9 @@ struct smi_info {
36641 };
36642
36643 #define smi_inc_stat(smi, stat) \
36644 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36645 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36646 #define smi_get_stat(smi, stat) \
36647 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36648 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36649
36650 #define SI_MAX_PARMS 4
36651
36652 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
36653 atomic_set(&new_smi->req_events, 0);
36654 new_smi->run_to_completion = 0;
36655 for (i = 0; i < SI_NUM_STATS; i++)
36656 - atomic_set(&new_smi->stats[i], 0);
36657 + atomic_set_unchecked(&new_smi->stats[i], 0);
36658
36659 new_smi->interrupt_disabled = 1;
36660 atomic_set(&new_smi->stop_operation, 0);
36661 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36662 index f895a8c..2bc9147 100644
36663 --- a/drivers/char/mem.c
36664 +++ b/drivers/char/mem.c
36665 @@ -18,6 +18,7 @@
36666 #include <linux/raw.h>
36667 #include <linux/tty.h>
36668 #include <linux/capability.h>
36669 +#include <linux/security.h>
36670 #include <linux/ptrace.h>
36671 #include <linux/device.h>
36672 #include <linux/highmem.h>
36673 @@ -37,6 +38,10 @@
36674
36675 #define DEVPORT_MINOR 4
36676
36677 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36678 +extern const struct file_operations grsec_fops;
36679 +#endif
36680 +
36681 static inline unsigned long size_inside_page(unsigned long start,
36682 unsigned long size)
36683 {
36684 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36685
36686 while (cursor < to) {
36687 if (!devmem_is_allowed(pfn)) {
36688 +#ifdef CONFIG_GRKERNSEC_KMEM
36689 + gr_handle_mem_readwrite(from, to);
36690 +#else
36691 printk(KERN_INFO
36692 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36693 current->comm, from, to);
36694 +#endif
36695 return 0;
36696 }
36697 cursor += PAGE_SIZE;
36698 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36699 }
36700 return 1;
36701 }
36702 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36703 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36704 +{
36705 + return 0;
36706 +}
36707 #else
36708 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36709 {
36710 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36711
36712 while (count > 0) {
36713 unsigned long remaining;
36714 + char *temp;
36715
36716 sz = size_inside_page(p, count);
36717
36718 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36719 if (!ptr)
36720 return -EFAULT;
36721
36722 - remaining = copy_to_user(buf, ptr, sz);
36723 +#ifdef CONFIG_PAX_USERCOPY
36724 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36725 + if (!temp) {
36726 + unxlate_dev_mem_ptr(p, ptr);
36727 + return -ENOMEM;
36728 + }
36729 + memcpy(temp, ptr, sz);
36730 +#else
36731 + temp = ptr;
36732 +#endif
36733 +
36734 + remaining = copy_to_user(buf, temp, sz);
36735 +
36736 +#ifdef CONFIG_PAX_USERCOPY
36737 + kfree(temp);
36738 +#endif
36739 +
36740 unxlate_dev_mem_ptr(p, ptr);
36741 if (remaining)
36742 return -EFAULT;
36743 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36744 size_t count, loff_t *ppos)
36745 {
36746 unsigned long p = *ppos;
36747 - ssize_t low_count, read, sz;
36748 + ssize_t low_count, read, sz, err = 0;
36749 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36750 - int err = 0;
36751
36752 read = 0;
36753 if (p < (unsigned long) high_memory) {
36754 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36755 }
36756 #endif
36757 while (low_count > 0) {
36758 + char *temp;
36759 +
36760 sz = size_inside_page(p, low_count);
36761
36762 /*
36763 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36764 */
36765 kbuf = xlate_dev_kmem_ptr((char *)p);
36766
36767 - if (copy_to_user(buf, kbuf, sz))
36768 +#ifdef CONFIG_PAX_USERCOPY
36769 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36770 + if (!temp)
36771 + return -ENOMEM;
36772 + memcpy(temp, kbuf, sz);
36773 +#else
36774 + temp = kbuf;
36775 +#endif
36776 +
36777 + err = copy_to_user(buf, temp, sz);
36778 +
36779 +#ifdef CONFIG_PAX_USERCOPY
36780 + kfree(temp);
36781 +#endif
36782 +
36783 + if (err)
36784 return -EFAULT;
36785 buf += sz;
36786 p += sz;
36787 @@ -822,6 +869,9 @@ static const struct memdev {
36788 #ifdef CONFIG_PRINTK
36789 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36790 #endif
36791 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36792 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36793 +#endif
36794 };
36795
36796 static int memory_open(struct inode *inode, struct file *filp)
36797 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36798 continue;
36799
36800 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36801 - NULL, devlist[minor].name);
36802 + NULL, "%s", devlist[minor].name);
36803 }
36804
36805 return tty_init();
36806 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36807 index 9df78e2..01ba9ae 100644
36808 --- a/drivers/char/nvram.c
36809 +++ b/drivers/char/nvram.c
36810 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36811
36812 spin_unlock_irq(&rtc_lock);
36813
36814 - if (copy_to_user(buf, contents, tmp - contents))
36815 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36816 return -EFAULT;
36817
36818 *ppos = i;
36819 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36820 index 5c5cc00..ac9edb7 100644
36821 --- a/drivers/char/pcmcia/synclink_cs.c
36822 +++ b/drivers/char/pcmcia/synclink_cs.c
36823 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36824
36825 if (debug_level >= DEBUG_LEVEL_INFO)
36826 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36827 - __FILE__, __LINE__, info->device_name, port->count);
36828 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36829
36830 - WARN_ON(!port->count);
36831 + WARN_ON(!atomic_read(&port->count));
36832
36833 if (tty_port_close_start(port, tty, filp) == 0)
36834 goto cleanup;
36835 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36836 cleanup:
36837 if (debug_level >= DEBUG_LEVEL_INFO)
36838 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36839 - tty->driver->name, port->count);
36840 + tty->driver->name, atomic_read(&port->count));
36841 }
36842
36843 /* Wait until the transmitter is empty.
36844 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36845
36846 if (debug_level >= DEBUG_LEVEL_INFO)
36847 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36848 - __FILE__, __LINE__, tty->driver->name, port->count);
36849 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36850
36851 /* If port is closing, signal caller to try again */
36852 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36853 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36854 goto cleanup;
36855 }
36856 spin_lock(&port->lock);
36857 - port->count++;
36858 + atomic_inc(&port->count);
36859 spin_unlock(&port->lock);
36860 spin_unlock_irqrestore(&info->netlock, flags);
36861
36862 - if (port->count == 1) {
36863 + if (atomic_read(&port->count) == 1) {
36864 /* 1st open on this device, init hardware */
36865 retval = startup(info, tty);
36866 if (retval < 0)
36867 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36868 unsigned short new_crctype;
36869
36870 /* return error if TTY interface open */
36871 - if (info->port.count)
36872 + if (atomic_read(&info->port.count))
36873 return -EBUSY;
36874
36875 switch (encoding)
36876 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36877
36878 /* arbitrate between network and tty opens */
36879 spin_lock_irqsave(&info->netlock, flags);
36880 - if (info->port.count != 0 || info->netcount != 0) {
36881 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36882 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36883 spin_unlock_irqrestore(&info->netlock, flags);
36884 return -EBUSY;
36885 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36886 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36887
36888 /* return error if TTY interface open */
36889 - if (info->port.count)
36890 + if (atomic_read(&info->port.count))
36891 return -EBUSY;
36892
36893 if (cmd != SIOCWANDEV)
36894 diff --git a/drivers/char/random.c b/drivers/char/random.c
36895 index 92e6c67..c640ec3 100644
36896 --- a/drivers/char/random.c
36897 +++ b/drivers/char/random.c
36898 @@ -272,8 +272,13 @@
36899 /*
36900 * Configuration information
36901 */
36902 +#ifdef CONFIG_GRKERNSEC_RANDNET
36903 +#define INPUT_POOL_WORDS 512
36904 +#define OUTPUT_POOL_WORDS 128
36905 +#else
36906 #define INPUT_POOL_WORDS 128
36907 #define OUTPUT_POOL_WORDS 32
36908 +#endif
36909 #define SEC_XFER_SIZE 512
36910 #define EXTRACT_SIZE 10
36911
36912 @@ -313,10 +318,17 @@ static struct poolinfo {
36913 int poolwords;
36914 int tap1, tap2, tap3, tap4, tap5;
36915 } poolinfo_table[] = {
36916 +#ifdef CONFIG_GRKERNSEC_RANDNET
36917 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36918 + { 512, 411, 308, 208, 104, 1 },
36919 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36920 + { 128, 103, 76, 51, 25, 1 },
36921 +#else
36922 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36923 { 128, 103, 76, 51, 25, 1 },
36924 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36925 { 32, 26, 20, 14, 7, 1 },
36926 +#endif
36927 #if 0
36928 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36929 { 2048, 1638, 1231, 819, 411, 1 },
36930 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36931 input_rotate += i ? 7 : 14;
36932 }
36933
36934 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36935 - ACCESS_ONCE(r->add_ptr) = i;
36936 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36937 + ACCESS_ONCE_RW(r->add_ptr) = i;
36938 smp_wmb();
36939
36940 if (out)
36941 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36942
36943 extract_buf(r, tmp);
36944 i = min_t(int, nbytes, EXTRACT_SIZE);
36945 - if (copy_to_user(buf, tmp, i)) {
36946 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36947 ret = -EFAULT;
36948 break;
36949 }
36950 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36951 #include <linux/sysctl.h>
36952
36953 static int min_read_thresh = 8, min_write_thresh;
36954 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36955 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36956 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36957 static char sysctl_bootid[16];
36958
36959 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
36960 static int proc_do_uuid(struct ctl_table *table, int write,
36961 void __user *buffer, size_t *lenp, loff_t *ppos)
36962 {
36963 - struct ctl_table fake_table;
36964 + ctl_table_no_const fake_table;
36965 unsigned char buf[64], tmp_uuid[16], *uuid;
36966
36967 uuid = table->data;
36968 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
36969 index bf2349db..5456d53 100644
36970 --- a/drivers/char/sonypi.c
36971 +++ b/drivers/char/sonypi.c
36972 @@ -54,6 +54,7 @@
36973
36974 #include <asm/uaccess.h>
36975 #include <asm/io.h>
36976 +#include <asm/local.h>
36977
36978 #include <linux/sonypi.h>
36979
36980 @@ -490,7 +491,7 @@ static struct sonypi_device {
36981 spinlock_t fifo_lock;
36982 wait_queue_head_t fifo_proc_list;
36983 struct fasync_struct *fifo_async;
36984 - int open_count;
36985 + local_t open_count;
36986 int model;
36987 struct input_dev *input_jog_dev;
36988 struct input_dev *input_key_dev;
36989 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
36990 static int sonypi_misc_release(struct inode *inode, struct file *file)
36991 {
36992 mutex_lock(&sonypi_device.lock);
36993 - sonypi_device.open_count--;
36994 + local_dec(&sonypi_device.open_count);
36995 mutex_unlock(&sonypi_device.lock);
36996 return 0;
36997 }
36998 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
36999 {
37000 mutex_lock(&sonypi_device.lock);
37001 /* Flush input queue on first open */
37002 - if (!sonypi_device.open_count)
37003 + if (!local_read(&sonypi_device.open_count))
37004 kfifo_reset(&sonypi_device.fifo);
37005 - sonypi_device.open_count++;
37006 + local_inc(&sonypi_device.open_count);
37007 mutex_unlock(&sonypi_device.lock);
37008
37009 return 0;
37010 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37011 index 64420b3..5c40b56 100644
37012 --- a/drivers/char/tpm/tpm_acpi.c
37013 +++ b/drivers/char/tpm/tpm_acpi.c
37014 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37015 virt = acpi_os_map_memory(start, len);
37016 if (!virt) {
37017 kfree(log->bios_event_log);
37018 + log->bios_event_log = NULL;
37019 printk("%s: ERROR - Unable to map memory\n", __func__);
37020 return -EIO;
37021 }
37022
37023 - memcpy_fromio(log->bios_event_log, virt, len);
37024 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37025
37026 acpi_os_unmap_memory(virt, len);
37027 return 0;
37028 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37029 index 84ddc55..1d32f1e 100644
37030 --- a/drivers/char/tpm/tpm_eventlog.c
37031 +++ b/drivers/char/tpm/tpm_eventlog.c
37032 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37033 event = addr;
37034
37035 if ((event->event_type == 0 && event->event_size == 0) ||
37036 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37037 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37038 return NULL;
37039
37040 return addr;
37041 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37042 return NULL;
37043
37044 if ((event->event_type == 0 && event->event_size == 0) ||
37045 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37046 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37047 return NULL;
37048
37049 (*pos)++;
37050 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37051 int i;
37052
37053 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37054 - seq_putc(m, data[i]);
37055 + if (!seq_putc(m, data[i]))
37056 + return -EFAULT;
37057
37058 return 0;
37059 }
37060 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37061 index fc45567..fa2a590 100644
37062 --- a/drivers/char/virtio_console.c
37063 +++ b/drivers/char/virtio_console.c
37064 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37065 if (to_user) {
37066 ssize_t ret;
37067
37068 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37069 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37070 if (ret)
37071 return -EFAULT;
37072 } else {
37073 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37074 if (!port_has_data(port) && !port->host_connected)
37075 return 0;
37076
37077 - return fill_readbuf(port, ubuf, count, true);
37078 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37079 }
37080
37081 static int wait_port_writable(struct port *port, bool nonblock)
37082 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37083 index a33f46f..a720eed 100644
37084 --- a/drivers/clk/clk-composite.c
37085 +++ b/drivers/clk/clk-composite.c
37086 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37087 struct clk *clk;
37088 struct clk_init_data init;
37089 struct clk_composite *composite;
37090 - struct clk_ops *clk_composite_ops;
37091 + clk_ops_no_const *clk_composite_ops;
37092
37093 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37094 if (!composite) {
37095 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37096 index 5bb848c..f1d4fc9 100644
37097 --- a/drivers/clk/socfpga/clk.c
37098 +++ b/drivers/clk/socfpga/clk.c
37099 @@ -22,6 +22,7 @@
37100 #include <linux/clk-provider.h>
37101 #include <linux/io.h>
37102 #include <linux/of.h>
37103 +#include <asm/pgtable.h>
37104
37105 /* Clock Manager offsets */
37106 #define CLKMGR_CTRL 0x0
37107 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37108 streq(clk_name, "periph_pll") ||
37109 streq(clk_name, "sdram_pll")) {
37110 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37111 - clk_pll_ops.enable = clk_gate_ops.enable;
37112 - clk_pll_ops.disable = clk_gate_ops.disable;
37113 + pax_open_kernel();
37114 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37115 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37116 + pax_close_kernel();
37117 }
37118
37119 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37120 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37121 return parent_rate / div;
37122 }
37123
37124 -static struct clk_ops gateclk_ops = {
37125 +static clk_ops_no_const gateclk_ops __read_only = {
37126 .recalc_rate = socfpga_clk_recalc_rate,
37127 .get_parent = socfpga_clk_get_parent,
37128 .set_parent = socfpga_clk_set_parent,
37129 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37130 index 3926402..37b580d 100644
37131 --- a/drivers/cpufreq/acpi-cpufreq.c
37132 +++ b/drivers/cpufreq/acpi-cpufreq.c
37133 @@ -173,7 +173,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37134 return sprintf(buf, "%u\n", boost_enabled);
37135 }
37136
37137 -static struct global_attr global_boost = __ATTR(boost, 0644,
37138 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37139 show_global_boost,
37140 store_global_boost);
37141
37142 @@ -722,8 +722,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37143 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37144 per_cpu(acfreq_data, cpu) = data;
37145
37146 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37147 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37148 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37149 + pax_open_kernel();
37150 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37151 + pax_close_kernel();
37152 + }
37153
37154 result = acpi_processor_register_performance(data->acpi_data, cpu);
37155 if (result)
37156 @@ -851,7 +854,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37157 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37158 break;
37159 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37160 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37161 + pax_open_kernel();
37162 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37163 + pax_close_kernel();
37164 policy->cur = get_cur_freq_on_cpu(cpu);
37165 break;
37166 default:
37167 @@ -862,8 +867,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37168 acpi_processor_notify_smm(THIS_MODULE);
37169
37170 /* Check for APERF/MPERF support in hardware */
37171 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
37172 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37173 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
37174 + pax_open_kernel();
37175 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37176 + pax_close_kernel();
37177 + }
37178
37179 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
37180 for (i = 0; i < perf->state_count; i++)
37181 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37182 index f0a5e2b..0a7ee46 100644
37183 --- a/drivers/cpufreq/cpufreq.c
37184 +++ b/drivers/cpufreq/cpufreq.c
37185 @@ -1959,7 +1959,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37186 return NOTIFY_OK;
37187 }
37188
37189 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37190 +static struct notifier_block cpufreq_cpu_notifier = {
37191 .notifier_call = cpufreq_cpu_callback,
37192 };
37193
37194 @@ -1991,8 +1991,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37195
37196 pr_debug("trying to register driver %s\n", driver_data->name);
37197
37198 - if (driver_data->setpolicy)
37199 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37200 + if (driver_data->setpolicy) {
37201 + pax_open_kernel();
37202 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37203 + pax_close_kernel();
37204 + }
37205
37206 write_lock_irqsave(&cpufreq_driver_lock, flags);
37207 if (cpufreq_driver) {
37208 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37209 index e59afaa..a53a3ff 100644
37210 --- a/drivers/cpufreq/cpufreq_governor.c
37211 +++ b/drivers/cpufreq/cpufreq_governor.c
37212 @@ -191,7 +191,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37213 struct dbs_data *dbs_data;
37214 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37215 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37216 - struct od_ops *od_ops = NULL;
37217 + const struct od_ops *od_ops = NULL;
37218 struct od_dbs_tuners *od_tuners = NULL;
37219 struct cs_dbs_tuners *cs_tuners = NULL;
37220 struct cpu_dbs_common_info *cpu_cdbs;
37221 @@ -257,7 +257,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37222
37223 if ((cdata->governor == GOV_CONSERVATIVE) &&
37224 (!policy->governor->initialized)) {
37225 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37226 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37227
37228 cpufreq_register_notifier(cs_ops->notifier_block,
37229 CPUFREQ_TRANSITION_NOTIFIER);
37230 @@ -277,7 +277,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37231
37232 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37233 (policy->governor->initialized == 1)) {
37234 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37235 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37236
37237 cpufreq_unregister_notifier(cs_ops->notifier_block,
37238 CPUFREQ_TRANSITION_NOTIFIER);
37239 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37240 index d5f12b4..eb30af1 100644
37241 --- a/drivers/cpufreq/cpufreq_governor.h
37242 +++ b/drivers/cpufreq/cpufreq_governor.h
37243 @@ -204,7 +204,7 @@ struct common_dbs_data {
37244 void (*exit)(struct dbs_data *dbs_data);
37245
37246 /* Governor specific ops, see below */
37247 - void *gov_ops;
37248 + const void *gov_ops;
37249 };
37250
37251 /* Governer Per policy data */
37252 @@ -224,7 +224,7 @@ struct od_ops {
37253 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37254 unsigned int freq_next, unsigned int relation);
37255 void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq);
37256 -};
37257 +} __no_const;
37258
37259 struct cs_ops {
37260 struct notifier_block *notifier_block;
37261 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37262 index c087347..989aa2e 100644
37263 --- a/drivers/cpufreq/cpufreq_ondemand.c
37264 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37265 @@ -560,7 +560,7 @@ static void od_exit(struct dbs_data *dbs_data)
37266
37267 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37268
37269 -static struct od_ops od_ops = {
37270 +static struct od_ops od_ops __read_only = {
37271 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37272 .powersave_bias_target = generic_powersave_bias_target,
37273 .freq_increase = dbs_freq_increase,
37274 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37275 (struct cpufreq_policy *, unsigned int, unsigned int),
37276 unsigned int powersave_bias)
37277 {
37278 - od_ops.powersave_bias_target = f;
37279 + pax_open_kernel();
37280 + *(void **)&od_ops.powersave_bias_target = f;
37281 + pax_close_kernel();
37282 od_set_powersave_bias(powersave_bias);
37283 }
37284 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37285
37286 void od_unregister_powersave_bias_handler(void)
37287 {
37288 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37289 + pax_open_kernel();
37290 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37291 + pax_close_kernel();
37292 od_set_powersave_bias(0);
37293 }
37294 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37295 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37296 index d37568c..fbb19a1 100644
37297 --- a/drivers/cpufreq/cpufreq_stats.c
37298 +++ b/drivers/cpufreq/cpufreq_stats.c
37299 @@ -365,7 +365,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37300 }
37301
37302 /* priority=1 so this will get called before cpufreq_remove_dev */
37303 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37304 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37305 .notifier_call = cpufreq_stat_cpu_callback,
37306 .priority = 1,
37307 };
37308 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37309 index 9ee7817..17b658e 100644
37310 --- a/drivers/cpufreq/p4-clockmod.c
37311 +++ b/drivers/cpufreq/p4-clockmod.c
37312 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37313 case 0x0F: /* Core Duo */
37314 case 0x16: /* Celeron Core */
37315 case 0x1C: /* Atom */
37316 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37317 + pax_open_kernel();
37318 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37319 + pax_close_kernel();
37320 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37321 case 0x0D: /* Pentium M (Dothan) */
37322 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37323 + pax_open_kernel();
37324 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37325 + pax_close_kernel();
37326 /* fall through */
37327 case 0x09: /* Pentium M (Banias) */
37328 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37329 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37330
37331 /* on P-4s, the TSC runs with constant frequency independent whether
37332 * throttling is active or not. */
37333 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37334 + pax_open_kernel();
37335 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37336 + pax_close_kernel();
37337
37338 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37339 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37340 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37341 index 880ee29..2445bc6 100644
37342 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37343 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37344 @@ -18,14 +18,12 @@
37345 #include <asm/head.h>
37346 #include <asm/timer.h>
37347
37348 -static struct cpufreq_driver *cpufreq_us3_driver;
37349 -
37350 struct us3_freq_percpu_info {
37351 struct cpufreq_frequency_table table[4];
37352 };
37353
37354 /* Indexed by cpu number. */
37355 -static struct us3_freq_percpu_info *us3_freq_table;
37356 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37357
37358 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37359 * in the Safari config register.
37360 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37361
37362 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37363 {
37364 - if (cpufreq_us3_driver)
37365 - us3_set_cpu_divider_index(policy, 0);
37366 + us3_set_cpu_divider_index(policy->cpu, 0);
37367
37368 return 0;
37369 }
37370
37371 +static int __init us3_freq_init(void);
37372 +static void __exit us3_freq_exit(void);
37373 +
37374 +static struct cpufreq_driver cpufreq_us3_driver = {
37375 + .init = us3_freq_cpu_init,
37376 + .verify = us3_freq_verify,
37377 + .target = us3_freq_target,
37378 + .get = us3_freq_get,
37379 + .exit = us3_freq_cpu_exit,
37380 + .owner = THIS_MODULE,
37381 + .name = "UltraSPARC-III",
37382 +
37383 +};
37384 +
37385 static int __init us3_freq_init(void)
37386 {
37387 unsigned long manuf, impl, ver;
37388 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
37389 (impl == CHEETAH_IMPL ||
37390 impl == CHEETAH_PLUS_IMPL ||
37391 impl == JAGUAR_IMPL ||
37392 - impl == PANTHER_IMPL)) {
37393 - struct cpufreq_driver *driver;
37394 -
37395 - ret = -ENOMEM;
37396 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
37397 - if (!driver)
37398 - goto err_out;
37399 -
37400 - us3_freq_table = kzalloc(
37401 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
37402 - GFP_KERNEL);
37403 - if (!us3_freq_table)
37404 - goto err_out;
37405 -
37406 - driver->init = us3_freq_cpu_init;
37407 - driver->verify = us3_freq_verify;
37408 - driver->target = us3_freq_target;
37409 - driver->get = us3_freq_get;
37410 - driver->exit = us3_freq_cpu_exit;
37411 - driver->owner = THIS_MODULE,
37412 - strcpy(driver->name, "UltraSPARC-III");
37413 -
37414 - cpufreq_us3_driver = driver;
37415 - ret = cpufreq_register_driver(driver);
37416 - if (ret)
37417 - goto err_out;
37418 -
37419 - return 0;
37420 -
37421 -err_out:
37422 - if (driver) {
37423 - kfree(driver);
37424 - cpufreq_us3_driver = NULL;
37425 - }
37426 - kfree(us3_freq_table);
37427 - us3_freq_table = NULL;
37428 - return ret;
37429 - }
37430 + impl == PANTHER_IMPL))
37431 + return cpufreq_register_driver(&cpufreq_us3_driver);
37432
37433 return -ENODEV;
37434 }
37435
37436 static void __exit us3_freq_exit(void)
37437 {
37438 - if (cpufreq_us3_driver) {
37439 - cpufreq_unregister_driver(cpufreq_us3_driver);
37440 - kfree(cpufreq_us3_driver);
37441 - cpufreq_us3_driver = NULL;
37442 - kfree(us3_freq_table);
37443 - us3_freq_table = NULL;
37444 - }
37445 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37446 }
37447
37448 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37449 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37450 index 0915e71..53376ed 100644
37451 --- a/drivers/cpufreq/speedstep-centrino.c
37452 +++ b/drivers/cpufreq/speedstep-centrino.c
37453 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37454 !cpu_has(cpu, X86_FEATURE_EST))
37455 return -ENODEV;
37456
37457 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37458 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37459 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37460 + pax_open_kernel();
37461 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37462 + pax_close_kernel();
37463 + }
37464
37465 if (policy->cpu != 0)
37466 return -ENODEV;
37467 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37468 index fdc432f..98e64e2 100644
37469 --- a/drivers/cpuidle/cpuidle.c
37470 +++ b/drivers/cpuidle/cpuidle.c
37471 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
37472
37473 static void poll_idle_init(struct cpuidle_driver *drv)
37474 {
37475 - struct cpuidle_state *state = &drv->states[0];
37476 + cpuidle_state_no_const *state = &drv->states[0];
37477
37478 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37479 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37480 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37481 index ea2f8e7..70ac501 100644
37482 --- a/drivers/cpuidle/governor.c
37483 +++ b/drivers/cpuidle/governor.c
37484 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37485 mutex_lock(&cpuidle_lock);
37486 if (__cpuidle_find_governor(gov->name) == NULL) {
37487 ret = 0;
37488 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37489 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37490 if (!cpuidle_curr_governor ||
37491 cpuidle_curr_governor->rating < gov->rating)
37492 cpuidle_switch_governor(gov);
37493 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37494 new_gov = cpuidle_replace_governor(gov->rating);
37495 cpuidle_switch_governor(new_gov);
37496 }
37497 - list_del(&gov->governor_list);
37498 + pax_list_del((struct list_head *)&gov->governor_list);
37499 mutex_unlock(&cpuidle_lock);
37500 }
37501
37502 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37503 index 428754a..8bdf9cc 100644
37504 --- a/drivers/cpuidle/sysfs.c
37505 +++ b/drivers/cpuidle/sysfs.c
37506 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37507 NULL
37508 };
37509
37510 -static struct attribute_group cpuidle_attr_group = {
37511 +static attribute_group_no_const cpuidle_attr_group = {
37512 .attrs = cpuidle_default_attrs,
37513 .name = "cpuidle",
37514 };
37515 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37516 index 12fea3e..1e28f47 100644
37517 --- a/drivers/crypto/hifn_795x.c
37518 +++ b/drivers/crypto/hifn_795x.c
37519 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37520 MODULE_PARM_DESC(hifn_pll_ref,
37521 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37522
37523 -static atomic_t hifn_dev_number;
37524 +static atomic_unchecked_t hifn_dev_number;
37525
37526 #define ACRYPTO_OP_DECRYPT 0
37527 #define ACRYPTO_OP_ENCRYPT 1
37528 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37529 goto err_out_disable_pci_device;
37530
37531 snprintf(name, sizeof(name), "hifn%d",
37532 - atomic_inc_return(&hifn_dev_number)-1);
37533 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37534
37535 err = pci_request_regions(pdev, name);
37536 if (err)
37537 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37538 index e94e619..f7e249c 100644
37539 --- a/drivers/devfreq/devfreq.c
37540 +++ b/drivers/devfreq/devfreq.c
37541 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37542 goto err_out;
37543 }
37544
37545 - list_add(&governor->node, &devfreq_governor_list);
37546 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37547
37548 list_for_each_entry(devfreq, &devfreq_list, node) {
37549 int ret = 0;
37550 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37551 }
37552 }
37553
37554 - list_del(&governor->node);
37555 + pax_list_del((struct list_head *)&governor->node);
37556 err_out:
37557 mutex_unlock(&devfreq_list_lock);
37558
37559 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
37560 index 5039fbc..841169f 100644
37561 --- a/drivers/dma/sh/shdma.c
37562 +++ b/drivers/dma/sh/shdma.c
37563 @@ -488,7 +488,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37564 return ret;
37565 }
37566
37567 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37568 +static struct notifier_block sh_dmae_nmi_notifier = {
37569 .notifier_call = sh_dmae_nmi_handler,
37570
37571 /* Run before NMI debug handler and KGDB */
37572 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37573 index 211021d..201d47f 100644
37574 --- a/drivers/edac/edac_device.c
37575 +++ b/drivers/edac/edac_device.c
37576 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37577 */
37578 int edac_device_alloc_index(void)
37579 {
37580 - static atomic_t device_indexes = ATOMIC_INIT(0);
37581 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37582
37583 - return atomic_inc_return(&device_indexes) - 1;
37584 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37585 }
37586 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37587
37588 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37589 index e7c32c4..6397af1 100644
37590 --- a/drivers/edac/edac_mc_sysfs.c
37591 +++ b/drivers/edac/edac_mc_sysfs.c
37592 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
37593 struct dev_ch_attribute {
37594 struct device_attribute attr;
37595 int channel;
37596 -};
37597 +} __do_const;
37598
37599 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37600 struct dev_ch_attribute dev_attr_legacy_##_name = \
37601 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37602 }
37603
37604 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37605 + pax_open_kernel();
37606 if (mci->get_sdram_scrub_rate) {
37607 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37608 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37609 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37610 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37611 }
37612 if (mci->set_sdram_scrub_rate) {
37613 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37614 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37615 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37616 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37617 }
37618 + pax_close_kernel();
37619 err = device_create_file(&mci->dev,
37620 &dev_attr_sdram_scrub_rate);
37621 if (err) {
37622 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37623 index dd370f9..0281629 100644
37624 --- a/drivers/edac/edac_pci.c
37625 +++ b/drivers/edac/edac_pci.c
37626 @@ -29,7 +29,7 @@
37627
37628 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37629 static LIST_HEAD(edac_pci_list);
37630 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37631 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37632
37633 /*
37634 * edac_pci_alloc_ctl_info
37635 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37636 */
37637 int edac_pci_alloc_index(void)
37638 {
37639 - return atomic_inc_return(&pci_indexes) - 1;
37640 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37641 }
37642 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37643
37644 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37645 index e8658e4..22746d6 100644
37646 --- a/drivers/edac/edac_pci_sysfs.c
37647 +++ b/drivers/edac/edac_pci_sysfs.c
37648 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37649 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37650 static int edac_pci_poll_msec = 1000; /* one second workq period */
37651
37652 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37653 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37654 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37655 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37656
37657 static struct kobject *edac_pci_top_main_kobj;
37658 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37659 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37660 void *value;
37661 ssize_t(*show) (void *, char *);
37662 ssize_t(*store) (void *, const char *, size_t);
37663 -};
37664 +} __do_const;
37665
37666 /* Set of show/store abstract level functions for PCI Parity object */
37667 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37668 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37669 edac_printk(KERN_CRIT, EDAC_PCI,
37670 "Signaled System Error on %s\n",
37671 pci_name(dev));
37672 - atomic_inc(&pci_nonparity_count);
37673 + atomic_inc_unchecked(&pci_nonparity_count);
37674 }
37675
37676 if (status & (PCI_STATUS_PARITY)) {
37677 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37678 "Master Data Parity Error on %s\n",
37679 pci_name(dev));
37680
37681 - atomic_inc(&pci_parity_count);
37682 + atomic_inc_unchecked(&pci_parity_count);
37683 }
37684
37685 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37686 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37687 "Detected Parity Error on %s\n",
37688 pci_name(dev));
37689
37690 - atomic_inc(&pci_parity_count);
37691 + atomic_inc_unchecked(&pci_parity_count);
37692 }
37693 }
37694
37695 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37696 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37697 "Signaled System Error on %s\n",
37698 pci_name(dev));
37699 - atomic_inc(&pci_nonparity_count);
37700 + atomic_inc_unchecked(&pci_nonparity_count);
37701 }
37702
37703 if (status & (PCI_STATUS_PARITY)) {
37704 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37705 "Master Data Parity Error on "
37706 "%s\n", pci_name(dev));
37707
37708 - atomic_inc(&pci_parity_count);
37709 + atomic_inc_unchecked(&pci_parity_count);
37710 }
37711
37712 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37713 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37714 "Detected Parity Error on %s\n",
37715 pci_name(dev));
37716
37717 - atomic_inc(&pci_parity_count);
37718 + atomic_inc_unchecked(&pci_parity_count);
37719 }
37720 }
37721 }
37722 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37723 if (!check_pci_errors)
37724 return;
37725
37726 - before_count = atomic_read(&pci_parity_count);
37727 + before_count = atomic_read_unchecked(&pci_parity_count);
37728
37729 /* scan all PCI devices looking for a Parity Error on devices and
37730 * bridges.
37731 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37732 /* Only if operator has selected panic on PCI Error */
37733 if (edac_pci_get_panic_on_pe()) {
37734 /* If the count is different 'after' from 'before' */
37735 - if (before_count != atomic_read(&pci_parity_count))
37736 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37737 panic("EDAC: PCI Parity Error");
37738 }
37739 }
37740 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37741 index 51b7e3a..aa8a3e8 100644
37742 --- a/drivers/edac/mce_amd.h
37743 +++ b/drivers/edac/mce_amd.h
37744 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37745 bool (*mc0_mce)(u16, u8);
37746 bool (*mc1_mce)(u16, u8);
37747 bool (*mc2_mce)(u16, u8);
37748 -};
37749 +} __no_const;
37750
37751 void amd_report_gart_errors(bool);
37752 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37753 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37754 index 57ea7f4..af06b76 100644
37755 --- a/drivers/firewire/core-card.c
37756 +++ b/drivers/firewire/core-card.c
37757 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37758 const struct fw_card_driver *driver,
37759 struct device *device)
37760 {
37761 - static atomic_t index = ATOMIC_INIT(-1);
37762 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37763
37764 - card->index = atomic_inc_return(&index);
37765 + card->index = atomic_inc_return_unchecked(&index);
37766 card->driver = driver;
37767 card->device = device;
37768 card->current_tlabel = 0;
37769 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37770
37771 void fw_core_remove_card(struct fw_card *card)
37772 {
37773 - struct fw_card_driver dummy_driver = dummy_driver_template;
37774 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37775
37776 card->driver->update_phy_reg(card, 4,
37777 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37778 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37779 index de4aa40..49ab1f2 100644
37780 --- a/drivers/firewire/core-device.c
37781 +++ b/drivers/firewire/core-device.c
37782 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37783 struct config_rom_attribute {
37784 struct device_attribute attr;
37785 u32 key;
37786 -};
37787 +} __do_const;
37788
37789 static ssize_t show_immediate(struct device *dev,
37790 struct device_attribute *dattr, char *buf)
37791 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37792 index 28a94c7..58da63a 100644
37793 --- a/drivers/firewire/core-transaction.c
37794 +++ b/drivers/firewire/core-transaction.c
37795 @@ -38,6 +38,7 @@
37796 #include <linux/timer.h>
37797 #include <linux/types.h>
37798 #include <linux/workqueue.h>
37799 +#include <linux/sched.h>
37800
37801 #include <asm/byteorder.h>
37802
37803 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37804 index 515a42c..5ecf3ba 100644
37805 --- a/drivers/firewire/core.h
37806 +++ b/drivers/firewire/core.h
37807 @@ -111,6 +111,7 @@ struct fw_card_driver {
37808
37809 int (*stop_iso)(struct fw_iso_context *ctx);
37810 };
37811 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37812
37813 void fw_card_initialize(struct fw_card *card,
37814 const struct fw_card_driver *driver, struct device *device);
37815 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37816 index 94a58a0..f5eba42 100644
37817 --- a/drivers/firmware/dmi-id.c
37818 +++ b/drivers/firmware/dmi-id.c
37819 @@ -16,7 +16,7 @@
37820 struct dmi_device_attribute{
37821 struct device_attribute dev_attr;
37822 int field;
37823 -};
37824 +} __do_const;
37825 #define to_dmi_dev_attr(_dev_attr) \
37826 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37827
37828 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37829 index 232fa8f..386c255 100644
37830 --- a/drivers/firmware/dmi_scan.c
37831 +++ b/drivers/firmware/dmi_scan.c
37832 @@ -504,11 +504,6 @@ void __init dmi_scan_machine(void)
37833 }
37834 }
37835 else {
37836 - /*
37837 - * no iounmap() for that ioremap(); it would be a no-op, but
37838 - * it's so early in setup that sucker gets confused into doing
37839 - * what it shouldn't if we actually call it.
37840 - */
37841 p = dmi_ioremap(0xF0000, 0x10000);
37842 if (p == NULL)
37843 goto error;
37844 @@ -806,7 +801,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37845 if (buf == NULL)
37846 return -1;
37847
37848 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37849 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37850
37851 iounmap(buf);
37852 return 0;
37853 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37854 index 5145fa3..0d3babd 100644
37855 --- a/drivers/firmware/efi/efi.c
37856 +++ b/drivers/firmware/efi/efi.c
37857 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37858 };
37859
37860 static struct efivars generic_efivars;
37861 -static struct efivar_operations generic_ops;
37862 +static efivar_operations_no_const generic_ops __read_only;
37863
37864 static int generic_ops_register(void)
37865 {
37866 - generic_ops.get_variable = efi.get_variable;
37867 - generic_ops.set_variable = efi.set_variable;
37868 - generic_ops.get_next_variable = efi.get_next_variable;
37869 - generic_ops.query_variable_store = efi_query_variable_store;
37870 + pax_open_kernel();
37871 + *(void **)&generic_ops.get_variable = efi.get_variable;
37872 + *(void **)&generic_ops.set_variable = efi.set_variable;
37873 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37874 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37875 + pax_close_kernel();
37876
37877 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37878 }
37879 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37880 index 8a7432a..28fb839 100644
37881 --- a/drivers/firmware/efi/efivars.c
37882 +++ b/drivers/firmware/efi/efivars.c
37883 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37884 static int
37885 create_efivars_bin_attributes(void)
37886 {
37887 - struct bin_attribute *attr;
37888 + bin_attribute_no_const *attr;
37889 int error;
37890
37891 /* new_var */
37892 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37893 index 2a90ba6..07f3733 100644
37894 --- a/drivers/firmware/google/memconsole.c
37895 +++ b/drivers/firmware/google/memconsole.c
37896 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37897 if (!found_memconsole())
37898 return -ENODEV;
37899
37900 - memconsole_bin_attr.size = memconsole_length;
37901 + pax_open_kernel();
37902 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37903 + pax_close_kernel();
37904
37905 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37906
37907 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37908 index 2729e3d..f9deca1 100644
37909 --- a/drivers/gpio/gpio-ich.c
37910 +++ b/drivers/gpio/gpio-ich.c
37911 @@ -71,7 +71,7 @@ struct ichx_desc {
37912 /* Some chipsets have quirks, let these use their own request/get */
37913 int (*request)(struct gpio_chip *chip, unsigned offset);
37914 int (*get)(struct gpio_chip *chip, unsigned offset);
37915 -};
37916 +} __do_const;
37917
37918 static struct {
37919 spinlock_t lock;
37920 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37921 index 9902732..64b62dd 100644
37922 --- a/drivers/gpio/gpio-vr41xx.c
37923 +++ b/drivers/gpio/gpio-vr41xx.c
37924 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37925 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37926 maskl, pendl, maskh, pendh);
37927
37928 - atomic_inc(&irq_err_count);
37929 + atomic_inc_unchecked(&irq_err_count);
37930
37931 return -EINVAL;
37932 }
37933 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37934 index 6a64749..0767a9f 100644
37935 --- a/drivers/gpu/drm/drm_crtc_helper.c
37936 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37937 @@ -322,7 +322,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37938 struct drm_crtc *tmp;
37939 int crtc_mask = 1;
37940
37941 - WARN(!crtc, "checking null crtc?\n");
37942 + BUG_ON(!crtc);
37943
37944 dev = crtc->dev;
37945
37946 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37947 index 6dd7173..32d755c 100644
37948 --- a/drivers/gpu/drm/drm_drv.c
37949 +++ b/drivers/gpu/drm/drm_drv.c
37950 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
37951 /**
37952 * Copy and IOCTL return string to user space
37953 */
37954 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37955 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37956 {
37957 int len;
37958
37959 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
37960 struct drm_file *file_priv = filp->private_data;
37961 struct drm_device *dev;
37962 const struct drm_ioctl_desc *ioctl = NULL;
37963 - drm_ioctl_t *func;
37964 + drm_ioctl_no_const_t func;
37965 unsigned int nr = DRM_IOCTL_NR(cmd);
37966 int retcode = -EINVAL;
37967 char stack_kdata[128];
37968 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
37969 return -ENODEV;
37970
37971 atomic_inc(&dev->ioctl_count);
37972 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37973 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37974 ++file_priv->ioctl_count;
37975
37976 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37977 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37978 index 3a24385..4e426e0 100644
37979 --- a/drivers/gpu/drm/drm_fops.c
37980 +++ b/drivers/gpu/drm/drm_fops.c
37981 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
37982 }
37983
37984 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
37985 - atomic_set(&dev->counts[i], 0);
37986 + atomic_set_unchecked(&dev->counts[i], 0);
37987
37988 dev->sigdata.lock = NULL;
37989
37990 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
37991 if (drm_device_is_unplugged(dev))
37992 return -ENODEV;
37993
37994 - if (!dev->open_count++)
37995 + if (local_inc_return(&dev->open_count) == 1)
37996 need_setup = 1;
37997 mutex_lock(&dev->struct_mutex);
37998 old_imapping = inode->i_mapping;
37999 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
38000 retcode = drm_open_helper(inode, filp, dev);
38001 if (retcode)
38002 goto err_undo;
38003 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38004 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38005 if (need_setup) {
38006 retcode = drm_setup(dev);
38007 if (retcode)
38008 @@ -166,7 +166,7 @@ err_undo:
38009 iput(container_of(dev->dev_mapping, struct inode, i_data));
38010 dev->dev_mapping = old_mapping;
38011 mutex_unlock(&dev->struct_mutex);
38012 - dev->open_count--;
38013 + local_dec(&dev->open_count);
38014 return retcode;
38015 }
38016 EXPORT_SYMBOL(drm_open);
38017 @@ -456,7 +456,7 @@ int drm_release(struct inode *inode, struct file *filp)
38018
38019 mutex_lock(&drm_global_mutex);
38020
38021 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38022 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38023
38024 if (dev->driver->preclose)
38025 dev->driver->preclose(dev, file_priv);
38026 @@ -465,10 +465,10 @@ int drm_release(struct inode *inode, struct file *filp)
38027 * Begin inline drm_release
38028 */
38029
38030 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38031 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38032 task_pid_nr(current),
38033 (long)old_encode_dev(file_priv->minor->device),
38034 - dev->open_count);
38035 + local_read(&dev->open_count));
38036
38037 /* Release any auth tokens that might point to this file_priv,
38038 (do that under the drm_global_mutex) */
38039 @@ -565,8 +565,8 @@ int drm_release(struct inode *inode, struct file *filp)
38040 * End inline drm_release
38041 */
38042
38043 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38044 - if (!--dev->open_count) {
38045 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38046 + if (local_dec_and_test(&dev->open_count)) {
38047 if (atomic_read(&dev->ioctl_count)) {
38048 DRM_ERROR("Device busy: %d\n",
38049 atomic_read(&dev->ioctl_count));
38050 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38051 index f731116..629842c 100644
38052 --- a/drivers/gpu/drm/drm_global.c
38053 +++ b/drivers/gpu/drm/drm_global.c
38054 @@ -36,7 +36,7 @@
38055 struct drm_global_item {
38056 struct mutex mutex;
38057 void *object;
38058 - int refcount;
38059 + atomic_t refcount;
38060 };
38061
38062 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38063 @@ -49,7 +49,7 @@ void drm_global_init(void)
38064 struct drm_global_item *item = &glob[i];
38065 mutex_init(&item->mutex);
38066 item->object = NULL;
38067 - item->refcount = 0;
38068 + atomic_set(&item->refcount, 0);
38069 }
38070 }
38071
38072 @@ -59,7 +59,7 @@ void drm_global_release(void)
38073 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38074 struct drm_global_item *item = &glob[i];
38075 BUG_ON(item->object != NULL);
38076 - BUG_ON(item->refcount != 0);
38077 + BUG_ON(atomic_read(&item->refcount) != 0);
38078 }
38079 }
38080
38081 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38082 void *object;
38083
38084 mutex_lock(&item->mutex);
38085 - if (item->refcount == 0) {
38086 + if (atomic_read(&item->refcount) == 0) {
38087 item->object = kzalloc(ref->size, GFP_KERNEL);
38088 if (unlikely(item->object == NULL)) {
38089 ret = -ENOMEM;
38090 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38091 goto out_err;
38092
38093 }
38094 - ++item->refcount;
38095 + atomic_inc(&item->refcount);
38096 ref->object = item->object;
38097 object = item->object;
38098 mutex_unlock(&item->mutex);
38099 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38100 struct drm_global_item *item = &glob[ref->global_type];
38101
38102 mutex_lock(&item->mutex);
38103 - BUG_ON(item->refcount == 0);
38104 + BUG_ON(atomic_read(&item->refcount) == 0);
38105 BUG_ON(ref->object != item->object);
38106 - if (--item->refcount == 0) {
38107 + if (atomic_dec_and_test(&item->refcount)) {
38108 ref->release(ref);
38109 item->object = NULL;
38110 }
38111 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38112 index d4b20ce..77a8d41 100644
38113 --- a/drivers/gpu/drm/drm_info.c
38114 +++ b/drivers/gpu/drm/drm_info.c
38115 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38116 struct drm_local_map *map;
38117 struct drm_map_list *r_list;
38118
38119 - /* Hardcoded from _DRM_FRAME_BUFFER,
38120 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38121 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38122 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38123 + static const char * const types[] = {
38124 + [_DRM_FRAME_BUFFER] = "FB",
38125 + [_DRM_REGISTERS] = "REG",
38126 + [_DRM_SHM] = "SHM",
38127 + [_DRM_AGP] = "AGP",
38128 + [_DRM_SCATTER_GATHER] = "SG",
38129 + [_DRM_CONSISTENT] = "PCI",
38130 + [_DRM_GEM] = "GEM" };
38131 const char *type;
38132 int i;
38133
38134 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38135 map = r_list->map;
38136 if (!map)
38137 continue;
38138 - if (map->type < 0 || map->type > 5)
38139 + if (map->type >= ARRAY_SIZE(types))
38140 type = "??";
38141 else
38142 type = types[map->type];
38143 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38144 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38145 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38146 vma->vm_flags & VM_IO ? 'i' : '-',
38147 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38148 + 0);
38149 +#else
38150 vma->vm_pgoff);
38151 +#endif
38152
38153 #if defined(__i386__)
38154 pgprot = pgprot_val(vma->vm_page_prot);
38155 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38156 index 2f4c434..dd12cd2 100644
38157 --- a/drivers/gpu/drm/drm_ioc32.c
38158 +++ b/drivers/gpu/drm/drm_ioc32.c
38159 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38160 request = compat_alloc_user_space(nbytes);
38161 if (!access_ok(VERIFY_WRITE, request, nbytes))
38162 return -EFAULT;
38163 - list = (struct drm_buf_desc *) (request + 1);
38164 + list = (struct drm_buf_desc __user *) (request + 1);
38165
38166 if (__put_user(count, &request->count)
38167 || __put_user(list, &request->list))
38168 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38169 request = compat_alloc_user_space(nbytes);
38170 if (!access_ok(VERIFY_WRITE, request, nbytes))
38171 return -EFAULT;
38172 - list = (struct drm_buf_pub *) (request + 1);
38173 + list = (struct drm_buf_pub __user *) (request + 1);
38174
38175 if (__put_user(count, &request->count)
38176 || __put_user(list, &request->list))
38177 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38178 return 0;
38179 }
38180
38181 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38182 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38183 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38184 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38185 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38186 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38187 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38188 {
38189 unsigned int nr = DRM_IOCTL_NR(cmd);
38190 - drm_ioctl_compat_t *fn;
38191 int ret;
38192
38193 /* Assume that ioctls without an explicit compat routine will just
38194 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38195 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38196 return drm_ioctl(filp, cmd, arg);
38197
38198 - fn = drm_compat_ioctls[nr];
38199 -
38200 - if (fn != NULL)
38201 - ret = (*fn) (filp, cmd, arg);
38202 + if (drm_compat_ioctls[nr] != NULL)
38203 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38204 else
38205 ret = drm_ioctl(filp, cmd, arg);
38206
38207 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
38208 index ffd7a7b..a64643e 100644
38209 --- a/drivers/gpu/drm/drm_ioctl.c
38210 +++ b/drivers/gpu/drm/drm_ioctl.c
38211 @@ -265,7 +265,7 @@ int drm_getstats(struct drm_device *dev, void *data,
38212 stats->data[i].value =
38213 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
38214 else
38215 - stats->data[i].value = atomic_read(&dev->counts[i]);
38216 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
38217 stats->data[i].type = dev->types[i];
38218 }
38219
38220 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38221 index d752c96..fe08455 100644
38222 --- a/drivers/gpu/drm/drm_lock.c
38223 +++ b/drivers/gpu/drm/drm_lock.c
38224 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38225 if (drm_lock_take(&master->lock, lock->context)) {
38226 master->lock.file_priv = file_priv;
38227 master->lock.lock_time = jiffies;
38228 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38229 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38230 break; /* Got lock */
38231 }
38232
38233 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38234 return -EINVAL;
38235 }
38236
38237 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38238 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38239
38240 if (drm_lock_free(&master->lock, lock->context)) {
38241 /* FIXME: Should really bail out here. */
38242 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38243 index 327ca19..684d3c0 100644
38244 --- a/drivers/gpu/drm/drm_stub.c
38245 +++ b/drivers/gpu/drm/drm_stub.c
38246 @@ -495,7 +495,7 @@ void drm_unplug_dev(struct drm_device *dev)
38247
38248 drm_device_set_unplugged(dev);
38249
38250 - if (dev->open_count == 0) {
38251 + if (local_read(&dev->open_count) == 0) {
38252 drm_put_dev(dev);
38253 }
38254 mutex_unlock(&drm_global_mutex);
38255 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38256 index 2290b3b..22056a1 100644
38257 --- a/drivers/gpu/drm/drm_sysfs.c
38258 +++ b/drivers/gpu/drm/drm_sysfs.c
38259 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38260 int drm_sysfs_device_add(struct drm_minor *minor)
38261 {
38262 int err;
38263 - char *minor_str;
38264 + const char *minor_str;
38265
38266 minor->kdev.parent = minor->dev->dev;
38267
38268 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38269 index ada49ed..29275a0 100644
38270 --- a/drivers/gpu/drm/i810/i810_dma.c
38271 +++ b/drivers/gpu/drm/i810/i810_dma.c
38272 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38273 dma->buflist[vertex->idx],
38274 vertex->discard, vertex->used);
38275
38276 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38277 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38278 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38279 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38280 sarea_priv->last_enqueue = dev_priv->counter - 1;
38281 sarea_priv->last_dispatch = (int)hw_status[5];
38282
38283 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38284 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38285 mc->last_render);
38286
38287 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38288 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38289 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38290 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38291 sarea_priv->last_enqueue = dev_priv->counter - 1;
38292 sarea_priv->last_dispatch = (int)hw_status[5];
38293
38294 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38295 index 6e0acad..93c8289 100644
38296 --- a/drivers/gpu/drm/i810/i810_drv.h
38297 +++ b/drivers/gpu/drm/i810/i810_drv.h
38298 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38299 int page_flipping;
38300
38301 wait_queue_head_t irq_queue;
38302 - atomic_t irq_received;
38303 - atomic_t irq_emitted;
38304 + atomic_unchecked_t irq_received;
38305 + atomic_unchecked_t irq_emitted;
38306
38307 int front_offset;
38308 } drm_i810_private_t;
38309 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38310 index 47d6c74..279123f 100644
38311 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38312 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38313 @@ -541,7 +541,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38314 I915_READ(GTIMR));
38315 }
38316 seq_printf(m, "Interrupts received: %d\n",
38317 - atomic_read(&dev_priv->irq_received));
38318 + atomic_read_unchecked(&dev_priv->irq_received));
38319 for_each_ring(ring, dev_priv, i) {
38320 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38321 seq_printf(m,
38322 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38323 index f466980..8f2883f 100644
38324 --- a/drivers/gpu/drm/i915/i915_dma.c
38325 +++ b/drivers/gpu/drm/i915/i915_dma.c
38326 @@ -1260,7 +1260,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38327 bool can_switch;
38328
38329 spin_lock(&dev->count_lock);
38330 - can_switch = (dev->open_count == 0);
38331 + can_switch = (local_read(&dev->open_count) == 0);
38332 spin_unlock(&dev->count_lock);
38333 return can_switch;
38334 }
38335 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38336 index 2f09e80..077876d 100644
38337 --- a/drivers/gpu/drm/i915/i915_drv.h
38338 +++ b/drivers/gpu/drm/i915/i915_drv.h
38339 @@ -1028,7 +1028,7 @@ typedef struct drm_i915_private {
38340 drm_dma_handle_t *status_page_dmah;
38341 struct resource mch_res;
38342
38343 - atomic_t irq_received;
38344 + atomic_unchecked_t irq_received;
38345
38346 /* protects the irq masks */
38347 spinlock_t irq_lock;
38348 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38349 index 87a3227..cd13d8f 100644
38350 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38351 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38352 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38353
38354 static int
38355 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38356 - int count)
38357 + unsigned int count)
38358 {
38359 - int i;
38360 + unsigned int i;
38361 int relocs_total = 0;
38362 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38363
38364 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38365 index 3c59584..500f2e9 100644
38366 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38367 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38368 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38369 (unsigned long)request);
38370 }
38371
38372 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38373 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38374 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38375 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38376 [DRM_I915_GETPARAM] = compat_i915_getparam,
38377 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38378 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38379 {
38380 unsigned int nr = DRM_IOCTL_NR(cmd);
38381 - drm_ioctl_compat_t *fn = NULL;
38382 int ret;
38383
38384 if (nr < DRM_COMMAND_BASE)
38385 return drm_compat_ioctl(filp, cmd, arg);
38386
38387 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38388 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38389 -
38390 - if (fn != NULL)
38391 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38392 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38393 ret = (*fn) (filp, cmd, arg);
38394 - else
38395 + } else
38396 ret = drm_ioctl(filp, cmd, arg);
38397
38398 return ret;
38399 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38400 index 46d46ba..6e49848 100644
38401 --- a/drivers/gpu/drm/i915/i915_irq.c
38402 +++ b/drivers/gpu/drm/i915/i915_irq.c
38403 @@ -975,7 +975,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38404 int pipe;
38405 u32 pipe_stats[I915_MAX_PIPES];
38406
38407 - atomic_inc(&dev_priv->irq_received);
38408 + atomic_inc_unchecked(&dev_priv->irq_received);
38409
38410 while (true) {
38411 iir = I915_READ(VLV_IIR);
38412 @@ -1192,7 +1192,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
38413 irqreturn_t ret = IRQ_NONE;
38414 int i;
38415
38416 - atomic_inc(&dev_priv->irq_received);
38417 + atomic_inc_unchecked(&dev_priv->irq_received);
38418
38419 /* We get interrupts on unclaimed registers, so check for this before we
38420 * do any I915_{READ,WRITE}. */
38421 @@ -1312,7 +1312,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38422 int ret = IRQ_NONE;
38423 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
38424
38425 - atomic_inc(&dev_priv->irq_received);
38426 + atomic_inc_unchecked(&dev_priv->irq_received);
38427
38428 /* disable master interrupt before clearing iir */
38429 de_ier = I915_READ(DEIER);
38430 @@ -2617,7 +2617,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38431 {
38432 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38433
38434 - atomic_set(&dev_priv->irq_received, 0);
38435 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38436
38437 I915_WRITE(HWSTAM, 0xeffe);
38438
38439 @@ -2639,7 +2639,7 @@ static void ivybridge_irq_preinstall(struct drm_device *dev)
38440 {
38441 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38442
38443 - atomic_set(&dev_priv->irq_received, 0);
38444 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38445
38446 I915_WRITE(HWSTAM, 0xeffe);
38447
38448 @@ -2667,7 +2667,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38449 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38450 int pipe;
38451
38452 - atomic_set(&dev_priv->irq_received, 0);
38453 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38454
38455 /* VLV magic */
38456 I915_WRITE(VLV_IMR, 0);
38457 @@ -2979,7 +2979,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38458 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38459 int pipe;
38460
38461 - atomic_set(&dev_priv->irq_received, 0);
38462 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38463
38464 for_each_pipe(pipe)
38465 I915_WRITE(PIPESTAT(pipe), 0);
38466 @@ -3058,7 +3058,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38467 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38468 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38469
38470 - atomic_inc(&dev_priv->irq_received);
38471 + atomic_inc_unchecked(&dev_priv->irq_received);
38472
38473 iir = I915_READ16(IIR);
38474 if (iir == 0)
38475 @@ -3133,7 +3133,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38476 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38477 int pipe;
38478
38479 - atomic_set(&dev_priv->irq_received, 0);
38480 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38481
38482 if (I915_HAS_HOTPLUG(dev)) {
38483 I915_WRITE(PORT_HOTPLUG_EN, 0);
38484 @@ -3232,7 +3232,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38485 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38486 int pipe, ret = IRQ_NONE;
38487
38488 - atomic_inc(&dev_priv->irq_received);
38489 + atomic_inc_unchecked(&dev_priv->irq_received);
38490
38491 iir = I915_READ(IIR);
38492 do {
38493 @@ -3356,7 +3356,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38494 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38495 int pipe;
38496
38497 - atomic_set(&dev_priv->irq_received, 0);
38498 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38499
38500 I915_WRITE(PORT_HOTPLUG_EN, 0);
38501 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38502 @@ -3465,7 +3465,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38503 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38504 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38505
38506 - atomic_inc(&dev_priv->irq_received);
38507 + atomic_inc_unchecked(&dev_priv->irq_received);
38508
38509 iir = I915_READ(IIR);
38510
38511 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38512 index ad2a258..684e615 100644
38513 --- a/drivers/gpu/drm/i915/intel_display.c
38514 +++ b/drivers/gpu/drm/i915/intel_display.c
38515 @@ -9461,13 +9461,13 @@ struct intel_quirk {
38516 int subsystem_vendor;
38517 int subsystem_device;
38518 void (*hook)(struct drm_device *dev);
38519 -};
38520 +} __do_const;
38521
38522 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38523 struct intel_dmi_quirk {
38524 void (*hook)(struct drm_device *dev);
38525 const struct dmi_system_id (*dmi_id_list)[];
38526 -};
38527 +} __do_const;
38528
38529 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38530 {
38531 @@ -9475,18 +9475,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38532 return 1;
38533 }
38534
38535 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38536 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38537 {
38538 - .dmi_id_list = &(const struct dmi_system_id[]) {
38539 - {
38540 - .callback = intel_dmi_reverse_brightness,
38541 - .ident = "NCR Corporation",
38542 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38543 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38544 - },
38545 - },
38546 - { } /* terminating entry */
38547 + .callback = intel_dmi_reverse_brightness,
38548 + .ident = "NCR Corporation",
38549 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38550 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38551 },
38552 + },
38553 + { } /* terminating entry */
38554 +};
38555 +
38556 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38557 + {
38558 + .dmi_id_list = &intel_dmi_quirks_table,
38559 .hook = quirk_invert_brightness,
38560 },
38561 };
38562 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38563 index 54558a0..2d97005 100644
38564 --- a/drivers/gpu/drm/mga/mga_drv.h
38565 +++ b/drivers/gpu/drm/mga/mga_drv.h
38566 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38567 u32 clear_cmd;
38568 u32 maccess;
38569
38570 - atomic_t vbl_received; /**< Number of vblanks received. */
38571 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38572 wait_queue_head_t fence_queue;
38573 - atomic_t last_fence_retired;
38574 + atomic_unchecked_t last_fence_retired;
38575 u32 next_fence_to_post;
38576
38577 unsigned int fb_cpp;
38578 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38579 index 709e90d..89a1c0d 100644
38580 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38581 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38582 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38583 return 0;
38584 }
38585
38586 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38587 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38588 [DRM_MGA_INIT] = compat_mga_init,
38589 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38590 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38591 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38592 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38593 {
38594 unsigned int nr = DRM_IOCTL_NR(cmd);
38595 - drm_ioctl_compat_t *fn = NULL;
38596 int ret;
38597
38598 if (nr < DRM_COMMAND_BASE)
38599 return drm_compat_ioctl(filp, cmd, arg);
38600
38601 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38602 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38603 -
38604 - if (fn != NULL)
38605 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38606 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38607 ret = (*fn) (filp, cmd, arg);
38608 - else
38609 + } else
38610 ret = drm_ioctl(filp, cmd, arg);
38611
38612 return ret;
38613 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38614 index 598c281..60d590e 100644
38615 --- a/drivers/gpu/drm/mga/mga_irq.c
38616 +++ b/drivers/gpu/drm/mga/mga_irq.c
38617 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38618 if (crtc != 0)
38619 return 0;
38620
38621 - return atomic_read(&dev_priv->vbl_received);
38622 + return atomic_read_unchecked(&dev_priv->vbl_received);
38623 }
38624
38625
38626 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38627 /* VBLANK interrupt */
38628 if (status & MGA_VLINEPEN) {
38629 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38630 - atomic_inc(&dev_priv->vbl_received);
38631 + atomic_inc_unchecked(&dev_priv->vbl_received);
38632 drm_handle_vblank(dev, 0);
38633 handled = 1;
38634 }
38635 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38636 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38637 MGA_WRITE(MGA_PRIMEND, prim_end);
38638
38639 - atomic_inc(&dev_priv->last_fence_retired);
38640 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38641 DRM_WAKEUP(&dev_priv->fence_queue);
38642 handled = 1;
38643 }
38644 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38645 * using fences.
38646 */
38647 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38648 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38649 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38650 - *sequence) <= (1 << 23)));
38651
38652 *sequence = cur_fence;
38653 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38654 index 3e72876..d1c15ad 100644
38655 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38656 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38657 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38658 struct bit_table {
38659 const char id;
38660 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38661 -};
38662 +} __no_const;
38663
38664 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38665
38666 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38667 index 41ff7e0..fa854ef 100644
38668 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38669 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38670 @@ -92,7 +92,6 @@ struct nouveau_drm {
38671 struct drm_global_reference mem_global_ref;
38672 struct ttm_bo_global_ref bo_global_ref;
38673 struct ttm_bo_device bdev;
38674 - atomic_t validate_sequence;
38675 int (*move)(struct nouveau_channel *,
38676 struct ttm_buffer_object *,
38677 struct ttm_mem_reg *, struct ttm_mem_reg *);
38678 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38679 index 08214bc..9208577 100644
38680 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38681 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38682 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38683 unsigned long arg)
38684 {
38685 unsigned int nr = DRM_IOCTL_NR(cmd);
38686 - drm_ioctl_compat_t *fn = NULL;
38687 + drm_ioctl_compat_t fn = NULL;
38688 int ret;
38689
38690 if (nr < DRM_COMMAND_BASE)
38691 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38692 index 25d3495..d81aaf6 100644
38693 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38694 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38695 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38696 bool can_switch;
38697
38698 spin_lock(&dev->count_lock);
38699 - can_switch = (dev->open_count == 0);
38700 + can_switch = (local_read(&dev->open_count) == 0);
38701 spin_unlock(&dev->count_lock);
38702 return can_switch;
38703 }
38704 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38705 index 1dfd84c..104896c 100644
38706 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38707 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38708 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38709 }
38710 }
38711
38712 -static struct vm_operations_struct qxl_ttm_vm_ops;
38713 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38714 static const struct vm_operations_struct *ttm_vm_ops;
38715
38716 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38717 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38718 return r;
38719 if (unlikely(ttm_vm_ops == NULL)) {
38720 ttm_vm_ops = vma->vm_ops;
38721 + pax_open_kernel();
38722 qxl_ttm_vm_ops = *ttm_vm_ops;
38723 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38724 + pax_close_kernel();
38725 }
38726 vma->vm_ops = &qxl_ttm_vm_ops;
38727 return 0;
38728 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38729 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38730 {
38731 #if defined(CONFIG_DEBUG_FS)
38732 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38733 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38734 - unsigned i;
38735 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38736 + {
38737 + .name = "qxl_mem_mm",
38738 + .show = &qxl_mm_dump_table,
38739 + },
38740 + {
38741 + .name = "qxl_surf_mm",
38742 + .show = &qxl_mm_dump_table,
38743 + }
38744 + };
38745
38746 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38747 - if (i == 0)
38748 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38749 - else
38750 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38751 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38752 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38753 - qxl_mem_types_list[i].driver_features = 0;
38754 - if (i == 0)
38755 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38756 - else
38757 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38758 + pax_open_kernel();
38759 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38760 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38761 + pax_close_kernel();
38762
38763 - }
38764 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38765 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38766 #else
38767 return 0;
38768 #endif
38769 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38770 index d4660cf..70dbe65 100644
38771 --- a/drivers/gpu/drm/r128/r128_cce.c
38772 +++ b/drivers/gpu/drm/r128/r128_cce.c
38773 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38774
38775 /* GH: Simple idle check.
38776 */
38777 - atomic_set(&dev_priv->idle_count, 0);
38778 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38779
38780 /* We don't support anything other than bus-mastering ring mode,
38781 * but the ring can be in either AGP or PCI space for the ring
38782 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38783 index 930c71b..499aded 100644
38784 --- a/drivers/gpu/drm/r128/r128_drv.h
38785 +++ b/drivers/gpu/drm/r128/r128_drv.h
38786 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38787 int is_pci;
38788 unsigned long cce_buffers_offset;
38789
38790 - atomic_t idle_count;
38791 + atomic_unchecked_t idle_count;
38792
38793 int page_flipping;
38794 int current_page;
38795 u32 crtc_offset;
38796 u32 crtc_offset_cntl;
38797
38798 - atomic_t vbl_received;
38799 + atomic_unchecked_t vbl_received;
38800
38801 u32 color_fmt;
38802 unsigned int front_offset;
38803 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38804 index a954c54..9cc595c 100644
38805 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38806 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38807 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38808 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38809 }
38810
38811 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38812 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38813 [DRM_R128_INIT] = compat_r128_init,
38814 [DRM_R128_DEPTH] = compat_r128_depth,
38815 [DRM_R128_STIPPLE] = compat_r128_stipple,
38816 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
38817 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38818 {
38819 unsigned int nr = DRM_IOCTL_NR(cmd);
38820 - drm_ioctl_compat_t *fn = NULL;
38821 int ret;
38822
38823 if (nr < DRM_COMMAND_BASE)
38824 return drm_compat_ioctl(filp, cmd, arg);
38825
38826 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
38827 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38828 -
38829 - if (fn != NULL)
38830 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
38831 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38832 ret = (*fn) (filp, cmd, arg);
38833 - else
38834 + } else
38835 ret = drm_ioctl(filp, cmd, arg);
38836
38837 return ret;
38838 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
38839 index 2ea4f09..d391371 100644
38840 --- a/drivers/gpu/drm/r128/r128_irq.c
38841 +++ b/drivers/gpu/drm/r128/r128_irq.c
38842 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
38843 if (crtc != 0)
38844 return 0;
38845
38846 - return atomic_read(&dev_priv->vbl_received);
38847 + return atomic_read_unchecked(&dev_priv->vbl_received);
38848 }
38849
38850 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38851 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38852 /* VBLANK interrupt */
38853 if (status & R128_CRTC_VBLANK_INT) {
38854 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
38855 - atomic_inc(&dev_priv->vbl_received);
38856 + atomic_inc_unchecked(&dev_priv->vbl_received);
38857 drm_handle_vblank(dev, 0);
38858 return IRQ_HANDLED;
38859 }
38860 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
38861 index 19bb7e6..de7e2a2 100644
38862 --- a/drivers/gpu/drm/r128/r128_state.c
38863 +++ b/drivers/gpu/drm/r128/r128_state.c
38864 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38865
38866 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38867 {
38868 - if (atomic_read(&dev_priv->idle_count) == 0)
38869 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38870 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38871 else
38872 - atomic_set(&dev_priv->idle_count, 0);
38873 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38874 }
38875
38876 #endif
38877 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38878 index af85299..ed9ac8d 100644
38879 --- a/drivers/gpu/drm/radeon/mkregtable.c
38880 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38881 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
38882 regex_t mask_rex;
38883 regmatch_t match[4];
38884 char buf[1024];
38885 - size_t end;
38886 + long end;
38887 int len;
38888 int done = 0;
38889 int r;
38890 unsigned o;
38891 struct offset *offset;
38892 char last_reg_s[10];
38893 - int last_reg;
38894 + unsigned long last_reg;
38895
38896 if (regcomp
38897 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38898 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38899 index d15f27e..ef11ffc 100644
38900 --- a/drivers/gpu/drm/radeon/radeon_device.c
38901 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38902 @@ -1105,7 +1105,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38903 bool can_switch;
38904
38905 spin_lock(&dev->count_lock);
38906 - can_switch = (dev->open_count == 0);
38907 + can_switch = (local_read(&dev->open_count) == 0);
38908 spin_unlock(&dev->count_lock);
38909 return can_switch;
38910 }
38911 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
38912 index b369d42..8dd04eb 100644
38913 --- a/drivers/gpu/drm/radeon/radeon_drv.h
38914 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
38915 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
38916
38917 /* SW interrupt */
38918 wait_queue_head_t swi_queue;
38919 - atomic_t swi_emitted;
38920 + atomic_unchecked_t swi_emitted;
38921 int vblank_crtc;
38922 uint32_t irq_enable_reg;
38923 uint32_t r500_disp_irq_reg;
38924 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
38925 index c180df8..5fd8186 100644
38926 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
38927 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
38928 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38929 request = compat_alloc_user_space(sizeof(*request));
38930 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
38931 || __put_user(req32.param, &request->param)
38932 - || __put_user((void __user *)(unsigned long)req32.value,
38933 + || __put_user((unsigned long)req32.value,
38934 &request->value))
38935 return -EFAULT;
38936
38937 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38938 #define compat_radeon_cp_setparam NULL
38939 #endif /* X86_64 || IA64 */
38940
38941 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38942 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
38943 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
38944 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
38945 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
38946 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38947 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38948 {
38949 unsigned int nr = DRM_IOCTL_NR(cmd);
38950 - drm_ioctl_compat_t *fn = NULL;
38951 int ret;
38952
38953 if (nr < DRM_COMMAND_BASE)
38954 return drm_compat_ioctl(filp, cmd, arg);
38955
38956 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
38957 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38958 -
38959 - if (fn != NULL)
38960 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
38961 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38962 ret = (*fn) (filp, cmd, arg);
38963 - else
38964 + } else
38965 ret = drm_ioctl(filp, cmd, arg);
38966
38967 return ret;
38968 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
38969 index 8d68e97..9dcfed8 100644
38970 --- a/drivers/gpu/drm/radeon/radeon_irq.c
38971 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
38972 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
38973 unsigned int ret;
38974 RING_LOCALS;
38975
38976 - atomic_inc(&dev_priv->swi_emitted);
38977 - ret = atomic_read(&dev_priv->swi_emitted);
38978 + atomic_inc_unchecked(&dev_priv->swi_emitted);
38979 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
38980
38981 BEGIN_RING(4);
38982 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
38983 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
38984 drm_radeon_private_t *dev_priv =
38985 (drm_radeon_private_t *) dev->dev_private;
38986
38987 - atomic_set(&dev_priv->swi_emitted, 0);
38988 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
38989 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
38990
38991 dev->max_vblank_count = 0x001fffff;
38992 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
38993 index 4d20910..6726b6d 100644
38994 --- a/drivers/gpu/drm/radeon/radeon_state.c
38995 +++ b/drivers/gpu/drm/radeon/radeon_state.c
38996 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
38997 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
38998 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
38999
39000 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39001 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39002 sarea_priv->nbox * sizeof(depth_boxes[0])))
39003 return -EFAULT;
39004
39005 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39006 {
39007 drm_radeon_private_t *dev_priv = dev->dev_private;
39008 drm_radeon_getparam_t *param = data;
39009 - int value;
39010 + int value = 0;
39011
39012 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39013
39014 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39015 index 6c0ce89..57a2529 100644
39016 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39017 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39018 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39019 man->size = size >> PAGE_SHIFT;
39020 }
39021
39022 -static struct vm_operations_struct radeon_ttm_vm_ops;
39023 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39024 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39025
39026 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39027 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39028 }
39029 if (unlikely(ttm_vm_ops == NULL)) {
39030 ttm_vm_ops = vma->vm_ops;
39031 + pax_open_kernel();
39032 radeon_ttm_vm_ops = *ttm_vm_ops;
39033 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39034 + pax_close_kernel();
39035 }
39036 vma->vm_ops = &radeon_ttm_vm_ops;
39037 return 0;
39038 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39039 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39040 {
39041 #if defined(CONFIG_DEBUG_FS)
39042 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39043 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39044 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39045 + {
39046 + .name = "radeon_vram_mm",
39047 + .show = &radeon_mm_dump_table,
39048 + },
39049 + {
39050 + .name = "radeon_gtt_mm",
39051 + .show = &radeon_mm_dump_table,
39052 + },
39053 + {
39054 + .name = "ttm_page_pool",
39055 + .show = &ttm_page_alloc_debugfs,
39056 + },
39057 + {
39058 + .name = "ttm_dma_page_pool",
39059 + .show = &ttm_dma_page_alloc_debugfs,
39060 + },
39061 + };
39062 unsigned i;
39063
39064 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39065 - if (i == 0)
39066 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39067 - else
39068 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39069 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39070 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39071 - radeon_mem_types_list[i].driver_features = 0;
39072 - if (i == 0)
39073 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39074 - else
39075 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39076 -
39077 - }
39078 - /* Add ttm page pool to debugfs */
39079 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39080 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39081 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39082 - radeon_mem_types_list[i].driver_features = 0;
39083 - radeon_mem_types_list[i++].data = NULL;
39084 + pax_open_kernel();
39085 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39086 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39087 + pax_close_kernel();
39088 #ifdef CONFIG_SWIOTLB
39089 - if (swiotlb_nr_tbl()) {
39090 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39091 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39092 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39093 - radeon_mem_types_list[i].driver_features = 0;
39094 - radeon_mem_types_list[i++].data = NULL;
39095 - }
39096 + if (swiotlb_nr_tbl())
39097 + i++;
39098 #endif
39099 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39100
39101 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39102 index d8ddfb3..609de1d 100644
39103 --- a/drivers/gpu/drm/radeon/rs690.c
39104 +++ b/drivers/gpu/drm/radeon/rs690.c
39105 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39106 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39107 rdev->pm.sideport_bandwidth.full)
39108 max_bandwidth = rdev->pm.sideport_bandwidth;
39109 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39110 + read_delay_latency.full = dfixed_const(800 * 1000);
39111 read_delay_latency.full = dfixed_div(read_delay_latency,
39112 rdev->pm.igp_sideport_mclk);
39113 + a.full = dfixed_const(370);
39114 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39115 } else {
39116 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39117 rdev->pm.k8_bandwidth.full)
39118 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39119 index dbc2def..0a9f710 100644
39120 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39121 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39122 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39123 zone->glob = glob;
39124 glob->zone_kernel = zone;
39125 ret = kobject_init_and_add(
39126 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39127 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39128 if (unlikely(ret != 0)) {
39129 kobject_put(&zone->kobj);
39130 return ret;
39131 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39132 zone->glob = glob;
39133 glob->zone_dma32 = zone;
39134 ret = kobject_init_and_add(
39135 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39136 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39137 if (unlikely(ret != 0)) {
39138 kobject_put(&zone->kobj);
39139 return ret;
39140 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39141 index bd2a3b4..122d9ad 100644
39142 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39143 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39144 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
39145 static int ttm_pool_mm_shrink(struct shrinker *shrink,
39146 struct shrink_control *sc)
39147 {
39148 - static atomic_t start_pool = ATOMIC_INIT(0);
39149 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39150 unsigned i;
39151 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39152 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39153 struct ttm_page_pool *pool;
39154 int shrink_pages = sc->nr_to_scan;
39155
39156 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39157 index 97e9d61..bf23c461 100644
39158 --- a/drivers/gpu/drm/udl/udl_fb.c
39159 +++ b/drivers/gpu/drm/udl/udl_fb.c
39160 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39161 fb_deferred_io_cleanup(info);
39162 kfree(info->fbdefio);
39163 info->fbdefio = NULL;
39164 - info->fbops->fb_mmap = udl_fb_mmap;
39165 }
39166
39167 pr_warn("released /dev/fb%d user=%d count=%d\n",
39168 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39169 index 893a650..6190d3b 100644
39170 --- a/drivers/gpu/drm/via/via_drv.h
39171 +++ b/drivers/gpu/drm/via/via_drv.h
39172 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39173 typedef uint32_t maskarray_t[5];
39174
39175 typedef struct drm_via_irq {
39176 - atomic_t irq_received;
39177 + atomic_unchecked_t irq_received;
39178 uint32_t pending_mask;
39179 uint32_t enable_mask;
39180 wait_queue_head_t irq_queue;
39181 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39182 struct timeval last_vblank;
39183 int last_vblank_valid;
39184 unsigned usec_per_vblank;
39185 - atomic_t vbl_received;
39186 + atomic_unchecked_t vbl_received;
39187 drm_via_state_t hc_state;
39188 char pci_buf[VIA_PCI_BUF_SIZE];
39189 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39190 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39191 index ac98964..5dbf512 100644
39192 --- a/drivers/gpu/drm/via/via_irq.c
39193 +++ b/drivers/gpu/drm/via/via_irq.c
39194 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39195 if (crtc != 0)
39196 return 0;
39197
39198 - return atomic_read(&dev_priv->vbl_received);
39199 + return atomic_read_unchecked(&dev_priv->vbl_received);
39200 }
39201
39202 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39203 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39204
39205 status = VIA_READ(VIA_REG_INTERRUPT);
39206 if (status & VIA_IRQ_VBLANK_PENDING) {
39207 - atomic_inc(&dev_priv->vbl_received);
39208 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39209 + atomic_inc_unchecked(&dev_priv->vbl_received);
39210 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39211 do_gettimeofday(&cur_vblank);
39212 if (dev_priv->last_vblank_valid) {
39213 dev_priv->usec_per_vblank =
39214 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39215 dev_priv->last_vblank = cur_vblank;
39216 dev_priv->last_vblank_valid = 1;
39217 }
39218 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39219 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39220 DRM_DEBUG("US per vblank is: %u\n",
39221 dev_priv->usec_per_vblank);
39222 }
39223 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39224
39225 for (i = 0; i < dev_priv->num_irqs; ++i) {
39226 if (status & cur_irq->pending_mask) {
39227 - atomic_inc(&cur_irq->irq_received);
39228 + atomic_inc_unchecked(&cur_irq->irq_received);
39229 DRM_WAKEUP(&cur_irq->irq_queue);
39230 handled = 1;
39231 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39232 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39233 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39234 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39235 masks[irq][4]));
39236 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39237 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39238 } else {
39239 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39240 (((cur_irq_sequence =
39241 - atomic_read(&cur_irq->irq_received)) -
39242 + atomic_read_unchecked(&cur_irq->irq_received)) -
39243 *sequence) <= (1 << 23)));
39244 }
39245 *sequence = cur_irq_sequence;
39246 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39247 }
39248
39249 for (i = 0; i < dev_priv->num_irqs; ++i) {
39250 - atomic_set(&cur_irq->irq_received, 0);
39251 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39252 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39253 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39254 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39255 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39256 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39257 case VIA_IRQ_RELATIVE:
39258 irqwait->request.sequence +=
39259 - atomic_read(&cur_irq->irq_received);
39260 + atomic_read_unchecked(&cur_irq->irq_received);
39261 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39262 case VIA_IRQ_ABSOLUTE:
39263 break;
39264 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39265 index 13aeda7..4a952d1 100644
39266 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39267 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39268 @@ -290,7 +290,7 @@ struct vmw_private {
39269 * Fencing and IRQs.
39270 */
39271
39272 - atomic_t marker_seq;
39273 + atomic_unchecked_t marker_seq;
39274 wait_queue_head_t fence_queue;
39275 wait_queue_head_t fifo_queue;
39276 int fence_queue_waiters; /* Protected by hw_mutex */
39277 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39278 index 3eb1486..0a47ee9 100644
39279 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39280 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39281 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39282 (unsigned int) min,
39283 (unsigned int) fifo->capabilities);
39284
39285 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39286 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39287 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39288 vmw_marker_queue_init(&fifo->marker_queue);
39289 return vmw_fifo_send_fence(dev_priv, &dummy);
39290 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39291 if (reserveable)
39292 iowrite32(bytes, fifo_mem +
39293 SVGA_FIFO_RESERVED);
39294 - return fifo_mem + (next_cmd >> 2);
39295 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39296 } else {
39297 need_bounce = true;
39298 }
39299 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39300
39301 fm = vmw_fifo_reserve(dev_priv, bytes);
39302 if (unlikely(fm == NULL)) {
39303 - *seqno = atomic_read(&dev_priv->marker_seq);
39304 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39305 ret = -ENOMEM;
39306 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39307 false, 3*HZ);
39308 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39309 }
39310
39311 do {
39312 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39313 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39314 } while (*seqno == 0);
39315
39316 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39317 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39318 index c509d40..3b640c3 100644
39319 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39320 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39321 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39322 int ret;
39323
39324 num_clips = arg->num_clips;
39325 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39326 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39327
39328 if (unlikely(num_clips == 0))
39329 return 0;
39330 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39331 int ret;
39332
39333 num_clips = arg->num_clips;
39334 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39335 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39336
39337 if (unlikely(num_clips == 0))
39338 return 0;
39339 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39340 index 4640adb..e1384ed 100644
39341 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39342 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39343 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39344 * emitted. Then the fence is stale and signaled.
39345 */
39346
39347 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39348 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39349 > VMW_FENCE_WRAP);
39350
39351 return ret;
39352 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39353
39354 if (fifo_idle)
39355 down_read(&fifo_state->rwsem);
39356 - signal_seq = atomic_read(&dev_priv->marker_seq);
39357 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39358 ret = 0;
39359
39360 for (;;) {
39361 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39362 index 8a8725c2..afed796 100644
39363 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39364 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39365 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39366 while (!vmw_lag_lt(queue, us)) {
39367 spin_lock(&queue->lock);
39368 if (list_empty(&queue->head))
39369 - seqno = atomic_read(&dev_priv->marker_seq);
39370 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39371 else {
39372 marker = list_first_entry(&queue->head,
39373 struct vmw_marker, head);
39374 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39375 index 5360e5a..c2c0d26 100644
39376 --- a/drivers/gpu/host1x/drm/dc.c
39377 +++ b/drivers/gpu/host1x/drm/dc.c
39378 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39379 }
39380
39381 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39382 - dc->debugfs_files[i].data = dc;
39383 + *(void **)&dc->debugfs_files[i].data = dc;
39384
39385 err = drm_debugfs_create_files(dc->debugfs_files,
39386 ARRAY_SIZE(debugfs_files),
39387 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39388 index 15323da..8431ce9 100644
39389 --- a/drivers/hid/hid-core.c
39390 +++ b/drivers/hid/hid-core.c
39391 @@ -2371,7 +2371,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39392
39393 int hid_add_device(struct hid_device *hdev)
39394 {
39395 - static atomic_t id = ATOMIC_INIT(0);
39396 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39397 int ret;
39398
39399 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39400 @@ -2405,7 +2405,7 @@ int hid_add_device(struct hid_device *hdev)
39401 /* XXX hack, any other cleaner solution after the driver core
39402 * is converted to allow more than 20 bytes as the device name? */
39403 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39404 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39405 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39406
39407 hid_debug_register(hdev, dev_name(&hdev->dev));
39408 ret = device_add(&hdev->dev);
39409 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39410 index c13fb5b..55a3802 100644
39411 --- a/drivers/hid/hid-wiimote-debug.c
39412 +++ b/drivers/hid/hid-wiimote-debug.c
39413 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39414 else if (size == 0)
39415 return -EIO;
39416
39417 - if (copy_to_user(u, buf, size))
39418 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39419 return -EFAULT;
39420
39421 *off += size;
39422 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39423 index 145a4cb..2353a3e 100644
39424 --- a/drivers/hid/uhid.c
39425 +++ b/drivers/hid/uhid.c
39426 @@ -47,7 +47,7 @@ struct uhid_device {
39427 struct mutex report_lock;
39428 wait_queue_head_t report_wait;
39429 atomic_t report_done;
39430 - atomic_t report_id;
39431 + atomic_unchecked_t report_id;
39432 struct uhid_event report_buf;
39433 };
39434
39435 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39436
39437 spin_lock_irqsave(&uhid->qlock, flags);
39438 ev->type = UHID_FEATURE;
39439 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39440 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39441 ev->u.feature.rnum = rnum;
39442 ev->u.feature.rtype = report_type;
39443
39444 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39445 spin_lock_irqsave(&uhid->qlock, flags);
39446
39447 /* id for old report; drop it silently */
39448 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39449 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39450 goto unlock;
39451 if (atomic_read(&uhid->report_done))
39452 goto unlock;
39453 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39454 index 6de6c98..18319e9 100644
39455 --- a/drivers/hv/channel.c
39456 +++ b/drivers/hv/channel.c
39457 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39458 int ret = 0;
39459 int t;
39460
39461 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39462 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39463 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39464 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39465
39466 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39467 if (ret)
39468 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39469 index 88f4096..e50452e 100644
39470 --- a/drivers/hv/hv.c
39471 +++ b/drivers/hv/hv.c
39472 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39473 u64 output_address = (output) ? virt_to_phys(output) : 0;
39474 u32 output_address_hi = output_address >> 32;
39475 u32 output_address_lo = output_address & 0xFFFFFFFF;
39476 - void *hypercall_page = hv_context.hypercall_page;
39477 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39478
39479 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39480 "=a"(hv_status_lo) : "d" (control_hi),
39481 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39482 index deb5c25..ed2d4fd 100644
39483 --- a/drivers/hv/hv_balloon.c
39484 +++ b/drivers/hv/hv_balloon.c
39485 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39486
39487 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39488 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39489 -static atomic_t trans_id = ATOMIC_INIT(0);
39490 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39491
39492 static int dm_ring_size = (5 * PAGE_SIZE);
39493
39494 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
39495 memset(&resp, 0, sizeof(struct dm_hot_add_response));
39496 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
39497 resp.hdr.size = sizeof(struct dm_hot_add_response);
39498 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39499 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39500
39501 #ifdef CONFIG_MEMORY_HOTPLUG
39502 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
39503 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39504 memset(&status, 0, sizeof(struct dm_status));
39505 status.hdr.type = DM_STATUS_REPORT;
39506 status.hdr.size = sizeof(struct dm_status);
39507 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39508 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39509
39510 /*
39511 * The host expects the guest to report free memory.
39512 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39513 * send the status. This can happen if we were interrupted
39514 * after we picked our transaction ID.
39515 */
39516 - if (status.hdr.trans_id != atomic_read(&trans_id))
39517 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39518 return;
39519
39520 vmbus_sendpacket(dm->dev->channel, &status,
39521 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
39522 bl_resp = (struct dm_balloon_response *)send_buffer;
39523 memset(send_buffer, 0, PAGE_SIZE);
39524 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
39525 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39526 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39527 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
39528 bl_resp->more_pages = 1;
39529
39530 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39531
39532 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39533 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39534 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39535 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39536 resp.hdr.size = sizeof(struct dm_unballoon_response);
39537
39538 vmbus_sendpacket(dm_device.dev->channel, &resp,
39539 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39540 memset(&version_req, 0, sizeof(struct dm_version_request));
39541 version_req.hdr.type = DM_VERSION_REQUEST;
39542 version_req.hdr.size = sizeof(struct dm_version_request);
39543 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39544 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39545 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39546 version_req.is_last_attempt = 1;
39547
39548 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39549 memset(&version_req, 0, sizeof(struct dm_version_request));
39550 version_req.hdr.type = DM_VERSION_REQUEST;
39551 version_req.hdr.size = sizeof(struct dm_version_request);
39552 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39553 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39554 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39555 version_req.is_last_attempt = 0;
39556
39557 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39558 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39559 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39560 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39561 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39562 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39563
39564 cap_msg.caps.cap_bits.balloon = 1;
39565 cap_msg.caps.cap_bits.hot_add = 1;
39566 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39567 index d84918f..7f38f9f 100644
39568 --- a/drivers/hv/hyperv_vmbus.h
39569 +++ b/drivers/hv/hyperv_vmbus.h
39570 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39571 struct vmbus_connection {
39572 enum vmbus_connect_state conn_state;
39573
39574 - atomic_t next_gpadl_handle;
39575 + atomic_unchecked_t next_gpadl_handle;
39576
39577 /*
39578 * Represents channel interrupts. Each bit position represents a
39579 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39580 index e8e071f..5b4b245 100644
39581 --- a/drivers/hv/vmbus_drv.c
39582 +++ b/drivers/hv/vmbus_drv.c
39583 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39584 {
39585 int ret = 0;
39586
39587 - static atomic_t device_num = ATOMIC_INIT(0);
39588 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39589
39590 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39591 - atomic_inc_return(&device_num));
39592 + atomic_inc_return_unchecked(&device_num));
39593
39594 child_device_obj->device.bus = &hv_bus;
39595 child_device_obj->device.parent = &hv_acpi_dev->dev;
39596 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39597 index 6351aba..dc4aaf4 100644
39598 --- a/drivers/hwmon/acpi_power_meter.c
39599 +++ b/drivers/hwmon/acpi_power_meter.c
39600 @@ -117,7 +117,7 @@ struct sensor_template {
39601 struct device_attribute *devattr,
39602 const char *buf, size_t count);
39603 int index;
39604 -};
39605 +} __do_const;
39606
39607 /* Averaging interval */
39608 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39609 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39610 struct sensor_template *attrs)
39611 {
39612 struct device *dev = &resource->acpi_dev->dev;
39613 - struct sensor_device_attribute *sensors =
39614 + sensor_device_attribute_no_const *sensors =
39615 &resource->sensors[resource->num_sensors];
39616 int res = 0;
39617
39618 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39619 index 3288f13..71cfb4e 100644
39620 --- a/drivers/hwmon/applesmc.c
39621 +++ b/drivers/hwmon/applesmc.c
39622 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39623 {
39624 struct applesmc_node_group *grp;
39625 struct applesmc_dev_attr *node;
39626 - struct attribute *attr;
39627 + attribute_no_const *attr;
39628 int ret, i;
39629
39630 for (grp = groups; grp->format; grp++) {
39631 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39632 index b25c643..a13460d 100644
39633 --- a/drivers/hwmon/asus_atk0110.c
39634 +++ b/drivers/hwmon/asus_atk0110.c
39635 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39636 struct atk_sensor_data {
39637 struct list_head list;
39638 struct atk_data *data;
39639 - struct device_attribute label_attr;
39640 - struct device_attribute input_attr;
39641 - struct device_attribute limit1_attr;
39642 - struct device_attribute limit2_attr;
39643 + device_attribute_no_const label_attr;
39644 + device_attribute_no_const input_attr;
39645 + device_attribute_no_const limit1_attr;
39646 + device_attribute_no_const limit2_attr;
39647 char label_attr_name[ATTR_NAME_SIZE];
39648 char input_attr_name[ATTR_NAME_SIZE];
39649 char limit1_attr_name[ATTR_NAME_SIZE];
39650 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39651 static struct device_attribute atk_name_attr =
39652 __ATTR(name, 0444, atk_name_show, NULL);
39653
39654 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39655 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39656 sysfs_show_func show)
39657 {
39658 sysfs_attr_init(&attr->attr);
39659 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39660 index 2e5e2dc..5208b31 100644
39661 --- a/drivers/hwmon/coretemp.c
39662 +++ b/drivers/hwmon/coretemp.c
39663 @@ -785,7 +785,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39664 return NOTIFY_OK;
39665 }
39666
39667 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39668 +static struct notifier_block coretemp_cpu_notifier = {
39669 .notifier_call = coretemp_cpu_callback,
39670 };
39671
39672 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39673 index 1429f6e..ee03d59 100644
39674 --- a/drivers/hwmon/ibmaem.c
39675 +++ b/drivers/hwmon/ibmaem.c
39676 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39677 struct aem_rw_sensor_template *rw)
39678 {
39679 struct device *dev = &data->pdev->dev;
39680 - struct sensor_device_attribute *sensors = data->sensors;
39681 + sensor_device_attribute_no_const *sensors = data->sensors;
39682 int err;
39683
39684 /* Set up read-only sensors */
39685 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39686 index 708081b..fe2d4ab 100644
39687 --- a/drivers/hwmon/iio_hwmon.c
39688 +++ b/drivers/hwmon/iio_hwmon.c
39689 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39690 {
39691 struct device *dev = &pdev->dev;
39692 struct iio_hwmon_state *st;
39693 - struct sensor_device_attribute *a;
39694 + sensor_device_attribute_no_const *a;
39695 int ret, i;
39696 int in_i = 1, temp_i = 1, curr_i = 1;
39697 enum iio_chan_type type;
39698 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39699 index 9add6092..ee7ba3f 100644
39700 --- a/drivers/hwmon/pmbus/pmbus_core.c
39701 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39702 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39703 return 0;
39704 }
39705
39706 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39707 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39708 const char *name,
39709 umode_t mode,
39710 ssize_t (*show)(struct device *dev,
39711 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39712 dev_attr->store = store;
39713 }
39714
39715 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39716 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39717 const char *name,
39718 umode_t mode,
39719 ssize_t (*show)(struct device *dev,
39720 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39721 u16 reg, u8 mask)
39722 {
39723 struct pmbus_boolean *boolean;
39724 - struct sensor_device_attribute *a;
39725 + sensor_device_attribute_no_const *a;
39726
39727 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39728 if (!boolean)
39729 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39730 bool update, bool readonly)
39731 {
39732 struct pmbus_sensor *sensor;
39733 - struct device_attribute *a;
39734 + device_attribute_no_const *a;
39735
39736 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39737 if (!sensor)
39738 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39739 const char *lstring, int index)
39740 {
39741 struct pmbus_label *label;
39742 - struct device_attribute *a;
39743 + device_attribute_no_const *a;
39744
39745 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39746 if (!label)
39747 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39748 index 2507f90..1645765 100644
39749 --- a/drivers/hwmon/sht15.c
39750 +++ b/drivers/hwmon/sht15.c
39751 @@ -169,7 +169,7 @@ struct sht15_data {
39752 int supply_uv;
39753 bool supply_uv_valid;
39754 struct work_struct update_supply_work;
39755 - atomic_t interrupt_handled;
39756 + atomic_unchecked_t interrupt_handled;
39757 };
39758
39759 /**
39760 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39761 ret = gpio_direction_input(data->pdata->gpio_data);
39762 if (ret)
39763 return ret;
39764 - atomic_set(&data->interrupt_handled, 0);
39765 + atomic_set_unchecked(&data->interrupt_handled, 0);
39766
39767 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39768 if (gpio_get_value(data->pdata->gpio_data) == 0) {
39769 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
39770 /* Only relevant if the interrupt hasn't occurred. */
39771 - if (!atomic_read(&data->interrupt_handled))
39772 + if (!atomic_read_unchecked(&data->interrupt_handled))
39773 schedule_work(&data->read_work);
39774 }
39775 ret = wait_event_timeout(data->wait_queue,
39776 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
39777
39778 /* First disable the interrupt */
39779 disable_irq_nosync(irq);
39780 - atomic_inc(&data->interrupt_handled);
39781 + atomic_inc_unchecked(&data->interrupt_handled);
39782 /* Then schedule a reading work struct */
39783 if (data->state != SHT15_READING_NOTHING)
39784 schedule_work(&data->read_work);
39785 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
39786 * If not, then start the interrupt again - care here as could
39787 * have gone low in meantime so verify it hasn't!
39788 */
39789 - atomic_set(&data->interrupt_handled, 0);
39790 + atomic_set_unchecked(&data->interrupt_handled, 0);
39791 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39792 /* If still not occurred or another handler was scheduled */
39793 if (gpio_get_value(data->pdata->gpio_data)
39794 - || atomic_read(&data->interrupt_handled))
39795 + || atomic_read_unchecked(&data->interrupt_handled))
39796 return;
39797 }
39798
39799 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
39800 index 38944e9..ae9e5ed 100644
39801 --- a/drivers/hwmon/via-cputemp.c
39802 +++ b/drivers/hwmon/via-cputemp.c
39803 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
39804 return NOTIFY_OK;
39805 }
39806
39807 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
39808 +static struct notifier_block via_cputemp_cpu_notifier = {
39809 .notifier_call = via_cputemp_cpu_callback,
39810 };
39811
39812 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
39813 index 07f01ac..d79ad3d 100644
39814 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
39815 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
39816 @@ -43,7 +43,7 @@
39817 extern struct i2c_adapter amd756_smbus;
39818
39819 static struct i2c_adapter *s4882_adapter;
39820 -static struct i2c_algorithm *s4882_algo;
39821 +static i2c_algorithm_no_const *s4882_algo;
39822
39823 /* Wrapper access functions for multiplexed SMBus */
39824 static DEFINE_MUTEX(amd756_lock);
39825 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
39826 index 2ca268d..c6acbdf 100644
39827 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
39828 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
39829 @@ -41,7 +41,7 @@
39830 extern struct i2c_adapter *nforce2_smbus;
39831
39832 static struct i2c_adapter *s4985_adapter;
39833 -static struct i2c_algorithm *s4985_algo;
39834 +static i2c_algorithm_no_const *s4985_algo;
39835
39836 /* Wrapper access functions for multiplexed SMBus */
39837 static DEFINE_MUTEX(nforce2_lock);
39838 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
39839 index c3ccdea..5b3dc1a 100644
39840 --- a/drivers/i2c/i2c-dev.c
39841 +++ b/drivers/i2c/i2c-dev.c
39842 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
39843 break;
39844 }
39845
39846 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
39847 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
39848 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
39849 if (IS_ERR(rdwr_pa[i].buf)) {
39850 res = PTR_ERR(rdwr_pa[i].buf);
39851 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
39852 index 0b510ba..4fbb5085 100644
39853 --- a/drivers/ide/ide-cd.c
39854 +++ b/drivers/ide/ide-cd.c
39855 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
39856 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
39857 if ((unsigned long)buf & alignment
39858 || blk_rq_bytes(rq) & q->dma_pad_mask
39859 - || object_is_on_stack(buf))
39860 + || object_starts_on_stack(buf))
39861 drive->dma = 0;
39862 }
39863 }
39864 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
39865 index e145931..08bfc59 100644
39866 --- a/drivers/iio/industrialio-core.c
39867 +++ b/drivers/iio/industrialio-core.c
39868 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
39869 }
39870
39871 static
39872 -int __iio_device_attr_init(struct device_attribute *dev_attr,
39873 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
39874 const char *postfix,
39875 struct iio_chan_spec const *chan,
39876 ssize_t (*readfunc)(struct device *dev,
39877 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
39878 index 784b97c..c9ceadf 100644
39879 --- a/drivers/infiniband/core/cm.c
39880 +++ b/drivers/infiniband/core/cm.c
39881 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
39882
39883 struct cm_counter_group {
39884 struct kobject obj;
39885 - atomic_long_t counter[CM_ATTR_COUNT];
39886 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
39887 };
39888
39889 struct cm_counter_attribute {
39890 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
39891 struct ib_mad_send_buf *msg = NULL;
39892 int ret;
39893
39894 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39895 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39896 counter[CM_REQ_COUNTER]);
39897
39898 /* Quick state check to discard duplicate REQs. */
39899 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
39900 if (!cm_id_priv)
39901 return;
39902
39903 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39904 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39905 counter[CM_REP_COUNTER]);
39906 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
39907 if (ret)
39908 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
39909 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
39910 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
39911 spin_unlock_irq(&cm_id_priv->lock);
39912 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39913 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39914 counter[CM_RTU_COUNTER]);
39915 goto out;
39916 }
39917 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
39918 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
39919 dreq_msg->local_comm_id);
39920 if (!cm_id_priv) {
39921 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39922 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39923 counter[CM_DREQ_COUNTER]);
39924 cm_issue_drep(work->port, work->mad_recv_wc);
39925 return -EINVAL;
39926 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
39927 case IB_CM_MRA_REP_RCVD:
39928 break;
39929 case IB_CM_TIMEWAIT:
39930 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39931 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39932 counter[CM_DREQ_COUNTER]);
39933 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39934 goto unlock;
39935 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
39936 cm_free_msg(msg);
39937 goto deref;
39938 case IB_CM_DREQ_RCVD:
39939 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39940 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39941 counter[CM_DREQ_COUNTER]);
39942 goto unlock;
39943 default:
39944 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
39945 ib_modify_mad(cm_id_priv->av.port->mad_agent,
39946 cm_id_priv->msg, timeout)) {
39947 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
39948 - atomic_long_inc(&work->port->
39949 + atomic_long_inc_unchecked(&work->port->
39950 counter_group[CM_RECV_DUPLICATES].
39951 counter[CM_MRA_COUNTER]);
39952 goto out;
39953 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
39954 break;
39955 case IB_CM_MRA_REQ_RCVD:
39956 case IB_CM_MRA_REP_RCVD:
39957 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39958 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39959 counter[CM_MRA_COUNTER]);
39960 /* fall through */
39961 default:
39962 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
39963 case IB_CM_LAP_IDLE:
39964 break;
39965 case IB_CM_MRA_LAP_SENT:
39966 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39967 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39968 counter[CM_LAP_COUNTER]);
39969 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39970 goto unlock;
39971 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
39972 cm_free_msg(msg);
39973 goto deref;
39974 case IB_CM_LAP_RCVD:
39975 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39976 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39977 counter[CM_LAP_COUNTER]);
39978 goto unlock;
39979 default:
39980 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
39981 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
39982 if (cur_cm_id_priv) {
39983 spin_unlock_irq(&cm.lock);
39984 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39985 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39986 counter[CM_SIDR_REQ_COUNTER]);
39987 goto out; /* Duplicate message. */
39988 }
39989 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
39990 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
39991 msg->retries = 1;
39992
39993 - atomic_long_add(1 + msg->retries,
39994 + atomic_long_add_unchecked(1 + msg->retries,
39995 &port->counter_group[CM_XMIT].counter[attr_index]);
39996 if (msg->retries)
39997 - atomic_long_add(msg->retries,
39998 + atomic_long_add_unchecked(msg->retries,
39999 &port->counter_group[CM_XMIT_RETRIES].
40000 counter[attr_index]);
40001
40002 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40003 }
40004
40005 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40006 - atomic_long_inc(&port->counter_group[CM_RECV].
40007 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40008 counter[attr_id - CM_ATTR_ID_OFFSET]);
40009
40010 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40011 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40012 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40013
40014 return sprintf(buf, "%ld\n",
40015 - atomic_long_read(&group->counter[cm_attr->index]));
40016 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40017 }
40018
40019 static const struct sysfs_ops cm_counter_ops = {
40020 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40021 index 9f5ad7c..588cd84 100644
40022 --- a/drivers/infiniband/core/fmr_pool.c
40023 +++ b/drivers/infiniband/core/fmr_pool.c
40024 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40025
40026 struct task_struct *thread;
40027
40028 - atomic_t req_ser;
40029 - atomic_t flush_ser;
40030 + atomic_unchecked_t req_ser;
40031 + atomic_unchecked_t flush_ser;
40032
40033 wait_queue_head_t force_wait;
40034 };
40035 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40036 struct ib_fmr_pool *pool = pool_ptr;
40037
40038 do {
40039 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40040 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40041 ib_fmr_batch_release(pool);
40042
40043 - atomic_inc(&pool->flush_ser);
40044 + atomic_inc_unchecked(&pool->flush_ser);
40045 wake_up_interruptible(&pool->force_wait);
40046
40047 if (pool->flush_function)
40048 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40049 }
40050
40051 set_current_state(TASK_INTERRUPTIBLE);
40052 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40053 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40054 !kthread_should_stop())
40055 schedule();
40056 __set_current_state(TASK_RUNNING);
40057 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40058 pool->dirty_watermark = params->dirty_watermark;
40059 pool->dirty_len = 0;
40060 spin_lock_init(&pool->pool_lock);
40061 - atomic_set(&pool->req_ser, 0);
40062 - atomic_set(&pool->flush_ser, 0);
40063 + atomic_set_unchecked(&pool->req_ser, 0);
40064 + atomic_set_unchecked(&pool->flush_ser, 0);
40065 init_waitqueue_head(&pool->force_wait);
40066
40067 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40068 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40069 }
40070 spin_unlock_irq(&pool->pool_lock);
40071
40072 - serial = atomic_inc_return(&pool->req_ser);
40073 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40074 wake_up_process(pool->thread);
40075
40076 if (wait_event_interruptible(pool->force_wait,
40077 - atomic_read(&pool->flush_ser) - serial >= 0))
40078 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40079 return -EINTR;
40080
40081 return 0;
40082 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40083 } else {
40084 list_add_tail(&fmr->list, &pool->dirty_list);
40085 if (++pool->dirty_len >= pool->dirty_watermark) {
40086 - atomic_inc(&pool->req_ser);
40087 + atomic_inc_unchecked(&pool->req_ser);
40088 wake_up_process(pool->thread);
40089 }
40090 }
40091 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40092 index 4cb8eb2..146bf60 100644
40093 --- a/drivers/infiniband/hw/cxgb4/mem.c
40094 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40095 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40096 int err;
40097 struct fw_ri_tpte tpt;
40098 u32 stag_idx;
40099 - static atomic_t key;
40100 + static atomic_unchecked_t key;
40101
40102 if (c4iw_fatal_error(rdev))
40103 return -EIO;
40104 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40105 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40106 rdev->stats.stag.max = rdev->stats.stag.cur;
40107 mutex_unlock(&rdev->stats.lock);
40108 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40109 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40110 }
40111 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40112 __func__, stag_state, type, pdid, stag_idx);
40113 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40114 index 79b3dbc..96e5fcc 100644
40115 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40116 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40117 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40118 struct ib_atomic_eth *ateth;
40119 struct ipath_ack_entry *e;
40120 u64 vaddr;
40121 - atomic64_t *maddr;
40122 + atomic64_unchecked_t *maddr;
40123 u64 sdata;
40124 u32 rkey;
40125 u8 next;
40126 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40127 IB_ACCESS_REMOTE_ATOMIC)))
40128 goto nack_acc_unlck;
40129 /* Perform atomic OP and save result. */
40130 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40131 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40132 sdata = be64_to_cpu(ateth->swap_data);
40133 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40134 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40135 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40136 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40137 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40138 be64_to_cpu(ateth->compare_data),
40139 sdata);
40140 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40141 index 1f95bba..9530f87 100644
40142 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40143 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40144 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40145 unsigned long flags;
40146 struct ib_wc wc;
40147 u64 sdata;
40148 - atomic64_t *maddr;
40149 + atomic64_unchecked_t *maddr;
40150 enum ib_wc_status send_status;
40151
40152 /*
40153 @@ -382,11 +382,11 @@ again:
40154 IB_ACCESS_REMOTE_ATOMIC)))
40155 goto acc_err;
40156 /* Perform atomic OP and save result. */
40157 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40158 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40159 sdata = wqe->wr.wr.atomic.compare_add;
40160 *(u64 *) sqp->s_sge.sge.vaddr =
40161 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40162 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40163 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40164 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40165 sdata, wqe->wr.wr.atomic.swap);
40166 goto send_comp;
40167 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40168 index f2a3f48..673ec79 100644
40169 --- a/drivers/infiniband/hw/mlx4/mad.c
40170 +++ b/drivers/infiniband/hw/mlx4/mad.c
40171 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40172
40173 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40174 {
40175 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40176 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40177 cpu_to_be64(0xff00000000000000LL);
40178 }
40179
40180 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40181 index 25b2cdf..099ff97 100644
40182 --- a/drivers/infiniband/hw/mlx4/mcg.c
40183 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40184 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40185 {
40186 char name[20];
40187
40188 - atomic_set(&ctx->tid, 0);
40189 + atomic_set_unchecked(&ctx->tid, 0);
40190 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40191 ctx->mcg_wq = create_singlethread_workqueue(name);
40192 if (!ctx->mcg_wq)
40193 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40194 index f61ec26..ebf72cf 100644
40195 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40196 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40197 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
40198 struct list_head mcg_mgid0_list;
40199 struct workqueue_struct *mcg_wq;
40200 struct mlx4_ib_demux_pv_ctx **tun;
40201 - atomic_t tid;
40202 + atomic_unchecked_t tid;
40203 int flushing; /* flushing the work queue */
40204 };
40205
40206 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40207 index 9d3e5c1..d9afe4a 100644
40208 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40209 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40210 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40211 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40212 }
40213
40214 -int mthca_QUERY_FW(struct mthca_dev *dev)
40215 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40216 {
40217 struct mthca_mailbox *mailbox;
40218 u32 *outbox;
40219 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40220 index ed9a989..e0c5871 100644
40221 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40222 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40223 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40224 return key;
40225 }
40226
40227 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40228 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40229 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40230 {
40231 struct mthca_mailbox *mailbox;
40232 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40233 index 4291410..d2ab1fb 100644
40234 --- a/drivers/infiniband/hw/nes/nes.c
40235 +++ b/drivers/infiniband/hw/nes/nes.c
40236 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40237 LIST_HEAD(nes_adapter_list);
40238 static LIST_HEAD(nes_dev_list);
40239
40240 -atomic_t qps_destroyed;
40241 +atomic_unchecked_t qps_destroyed;
40242
40243 static unsigned int ee_flsh_adapter;
40244 static unsigned int sysfs_nonidx_addr;
40245 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40246 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40247 struct nes_adapter *nesadapter = nesdev->nesadapter;
40248
40249 - atomic_inc(&qps_destroyed);
40250 + atomic_inc_unchecked(&qps_destroyed);
40251
40252 /* Free the control structures */
40253
40254 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40255 index 33cc589..3bd6538 100644
40256 --- a/drivers/infiniband/hw/nes/nes.h
40257 +++ b/drivers/infiniband/hw/nes/nes.h
40258 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40259 extern unsigned int wqm_quanta;
40260 extern struct list_head nes_adapter_list;
40261
40262 -extern atomic_t cm_connects;
40263 -extern atomic_t cm_accepts;
40264 -extern atomic_t cm_disconnects;
40265 -extern atomic_t cm_closes;
40266 -extern atomic_t cm_connecteds;
40267 -extern atomic_t cm_connect_reqs;
40268 -extern atomic_t cm_rejects;
40269 -extern atomic_t mod_qp_timouts;
40270 -extern atomic_t qps_created;
40271 -extern atomic_t qps_destroyed;
40272 -extern atomic_t sw_qps_destroyed;
40273 +extern atomic_unchecked_t cm_connects;
40274 +extern atomic_unchecked_t cm_accepts;
40275 +extern atomic_unchecked_t cm_disconnects;
40276 +extern atomic_unchecked_t cm_closes;
40277 +extern atomic_unchecked_t cm_connecteds;
40278 +extern atomic_unchecked_t cm_connect_reqs;
40279 +extern atomic_unchecked_t cm_rejects;
40280 +extern atomic_unchecked_t mod_qp_timouts;
40281 +extern atomic_unchecked_t qps_created;
40282 +extern atomic_unchecked_t qps_destroyed;
40283 +extern atomic_unchecked_t sw_qps_destroyed;
40284 extern u32 mh_detected;
40285 extern u32 mh_pauses_sent;
40286 extern u32 cm_packets_sent;
40287 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40288 extern u32 cm_packets_received;
40289 extern u32 cm_packets_dropped;
40290 extern u32 cm_packets_retrans;
40291 -extern atomic_t cm_listens_created;
40292 -extern atomic_t cm_listens_destroyed;
40293 +extern atomic_unchecked_t cm_listens_created;
40294 +extern atomic_unchecked_t cm_listens_destroyed;
40295 extern u32 cm_backlog_drops;
40296 -extern atomic_t cm_loopbacks;
40297 -extern atomic_t cm_nodes_created;
40298 -extern atomic_t cm_nodes_destroyed;
40299 -extern atomic_t cm_accel_dropped_pkts;
40300 -extern atomic_t cm_resets_recvd;
40301 -extern atomic_t pau_qps_created;
40302 -extern atomic_t pau_qps_destroyed;
40303 +extern atomic_unchecked_t cm_loopbacks;
40304 +extern atomic_unchecked_t cm_nodes_created;
40305 +extern atomic_unchecked_t cm_nodes_destroyed;
40306 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40307 +extern atomic_unchecked_t cm_resets_recvd;
40308 +extern atomic_unchecked_t pau_qps_created;
40309 +extern atomic_unchecked_t pau_qps_destroyed;
40310
40311 extern u32 int_mod_timer_init;
40312 extern u32 int_mod_cq_depth_256;
40313 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40314 index 24b9f1a..00fd004 100644
40315 --- a/drivers/infiniband/hw/nes/nes_cm.c
40316 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40317 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40318 u32 cm_packets_retrans;
40319 u32 cm_packets_created;
40320 u32 cm_packets_received;
40321 -atomic_t cm_listens_created;
40322 -atomic_t cm_listens_destroyed;
40323 +atomic_unchecked_t cm_listens_created;
40324 +atomic_unchecked_t cm_listens_destroyed;
40325 u32 cm_backlog_drops;
40326 -atomic_t cm_loopbacks;
40327 -atomic_t cm_nodes_created;
40328 -atomic_t cm_nodes_destroyed;
40329 -atomic_t cm_accel_dropped_pkts;
40330 -atomic_t cm_resets_recvd;
40331 +atomic_unchecked_t cm_loopbacks;
40332 +atomic_unchecked_t cm_nodes_created;
40333 +atomic_unchecked_t cm_nodes_destroyed;
40334 +atomic_unchecked_t cm_accel_dropped_pkts;
40335 +atomic_unchecked_t cm_resets_recvd;
40336
40337 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40338 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40339 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40340
40341 static struct nes_cm_core *g_cm_core;
40342
40343 -atomic_t cm_connects;
40344 -atomic_t cm_accepts;
40345 -atomic_t cm_disconnects;
40346 -atomic_t cm_closes;
40347 -atomic_t cm_connecteds;
40348 -atomic_t cm_connect_reqs;
40349 -atomic_t cm_rejects;
40350 +atomic_unchecked_t cm_connects;
40351 +atomic_unchecked_t cm_accepts;
40352 +atomic_unchecked_t cm_disconnects;
40353 +atomic_unchecked_t cm_closes;
40354 +atomic_unchecked_t cm_connecteds;
40355 +atomic_unchecked_t cm_connect_reqs;
40356 +atomic_unchecked_t cm_rejects;
40357
40358 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40359 {
40360 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40361 kfree(listener);
40362 listener = NULL;
40363 ret = 0;
40364 - atomic_inc(&cm_listens_destroyed);
40365 + atomic_inc_unchecked(&cm_listens_destroyed);
40366 } else {
40367 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40368 }
40369 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40370 cm_node->rem_mac);
40371
40372 add_hte_node(cm_core, cm_node);
40373 - atomic_inc(&cm_nodes_created);
40374 + atomic_inc_unchecked(&cm_nodes_created);
40375
40376 return cm_node;
40377 }
40378 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40379 }
40380
40381 atomic_dec(&cm_core->node_cnt);
40382 - atomic_inc(&cm_nodes_destroyed);
40383 + atomic_inc_unchecked(&cm_nodes_destroyed);
40384 nesqp = cm_node->nesqp;
40385 if (nesqp) {
40386 nesqp->cm_node = NULL;
40387 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40388
40389 static void drop_packet(struct sk_buff *skb)
40390 {
40391 - atomic_inc(&cm_accel_dropped_pkts);
40392 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40393 dev_kfree_skb_any(skb);
40394 }
40395
40396 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40397 {
40398
40399 int reset = 0; /* whether to send reset in case of err.. */
40400 - atomic_inc(&cm_resets_recvd);
40401 + atomic_inc_unchecked(&cm_resets_recvd);
40402 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40403 " refcnt=%d\n", cm_node, cm_node->state,
40404 atomic_read(&cm_node->ref_count));
40405 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40406 rem_ref_cm_node(cm_node->cm_core, cm_node);
40407 return NULL;
40408 }
40409 - atomic_inc(&cm_loopbacks);
40410 + atomic_inc_unchecked(&cm_loopbacks);
40411 loopbackremotenode->loopbackpartner = cm_node;
40412 loopbackremotenode->tcp_cntxt.rcv_wscale =
40413 NES_CM_DEFAULT_RCV_WND_SCALE;
40414 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40415 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40416 else {
40417 rem_ref_cm_node(cm_core, cm_node);
40418 - atomic_inc(&cm_accel_dropped_pkts);
40419 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40420 dev_kfree_skb_any(skb);
40421 }
40422 break;
40423 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40424
40425 if ((cm_id) && (cm_id->event_handler)) {
40426 if (issue_disconn) {
40427 - atomic_inc(&cm_disconnects);
40428 + atomic_inc_unchecked(&cm_disconnects);
40429 cm_event.event = IW_CM_EVENT_DISCONNECT;
40430 cm_event.status = disconn_status;
40431 cm_event.local_addr = cm_id->local_addr;
40432 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40433 }
40434
40435 if (issue_close) {
40436 - atomic_inc(&cm_closes);
40437 + atomic_inc_unchecked(&cm_closes);
40438 nes_disconnect(nesqp, 1);
40439
40440 cm_id->provider_data = nesqp;
40441 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40442
40443 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40444 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40445 - atomic_inc(&cm_accepts);
40446 + atomic_inc_unchecked(&cm_accepts);
40447
40448 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40449 netdev_refcnt_read(nesvnic->netdev));
40450 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40451 struct nes_cm_core *cm_core;
40452 u8 *start_buff;
40453
40454 - atomic_inc(&cm_rejects);
40455 + atomic_inc_unchecked(&cm_rejects);
40456 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40457 loopback = cm_node->loopbackpartner;
40458 cm_core = cm_node->cm_core;
40459 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40460 ntohl(cm_id->local_addr.sin_addr.s_addr),
40461 ntohs(cm_id->local_addr.sin_port));
40462
40463 - atomic_inc(&cm_connects);
40464 + atomic_inc_unchecked(&cm_connects);
40465 nesqp->active_conn = 1;
40466
40467 /* cache the cm_id in the qp */
40468 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40469 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40470 return err;
40471 }
40472 - atomic_inc(&cm_listens_created);
40473 + atomic_inc_unchecked(&cm_listens_created);
40474 }
40475
40476 cm_id->add_ref(cm_id);
40477 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40478
40479 if (nesqp->destroyed)
40480 return;
40481 - atomic_inc(&cm_connecteds);
40482 + atomic_inc_unchecked(&cm_connecteds);
40483 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40484 " local port 0x%04X. jiffies = %lu.\n",
40485 nesqp->hwqp.qp_id,
40486 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40487
40488 cm_id->add_ref(cm_id);
40489 ret = cm_id->event_handler(cm_id, &cm_event);
40490 - atomic_inc(&cm_closes);
40491 + atomic_inc_unchecked(&cm_closes);
40492 cm_event.event = IW_CM_EVENT_CLOSE;
40493 cm_event.status = 0;
40494 cm_event.provider_data = cm_id->provider_data;
40495 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40496 return;
40497 cm_id = cm_node->cm_id;
40498
40499 - atomic_inc(&cm_connect_reqs);
40500 + atomic_inc_unchecked(&cm_connect_reqs);
40501 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40502 cm_node, cm_id, jiffies);
40503
40504 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40505 return;
40506 cm_id = cm_node->cm_id;
40507
40508 - atomic_inc(&cm_connect_reqs);
40509 + atomic_inc_unchecked(&cm_connect_reqs);
40510 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40511 cm_node, cm_id, jiffies);
40512
40513 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40514 index 4166452..fc952c3 100644
40515 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40516 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40517 @@ -40,8 +40,8 @@
40518 #include "nes.h"
40519 #include "nes_mgt.h"
40520
40521 -atomic_t pau_qps_created;
40522 -atomic_t pau_qps_destroyed;
40523 +atomic_unchecked_t pau_qps_created;
40524 +atomic_unchecked_t pau_qps_destroyed;
40525
40526 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40527 {
40528 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40529 {
40530 struct sk_buff *skb;
40531 unsigned long flags;
40532 - atomic_inc(&pau_qps_destroyed);
40533 + atomic_inc_unchecked(&pau_qps_destroyed);
40534
40535 /* Free packets that have not yet been forwarded */
40536 /* Lock is acquired by skb_dequeue when removing the skb */
40537 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40538 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40539 skb_queue_head_init(&nesqp->pau_list);
40540 spin_lock_init(&nesqp->pau_lock);
40541 - atomic_inc(&pau_qps_created);
40542 + atomic_inc_unchecked(&pau_qps_created);
40543 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40544 }
40545
40546 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40547 index 49eb511..a774366 100644
40548 --- a/drivers/infiniband/hw/nes/nes_nic.c
40549 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40550 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40551 target_stat_values[++index] = mh_detected;
40552 target_stat_values[++index] = mh_pauses_sent;
40553 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40554 - target_stat_values[++index] = atomic_read(&cm_connects);
40555 - target_stat_values[++index] = atomic_read(&cm_accepts);
40556 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40557 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40558 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40559 - target_stat_values[++index] = atomic_read(&cm_rejects);
40560 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40561 - target_stat_values[++index] = atomic_read(&qps_created);
40562 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40563 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40564 - target_stat_values[++index] = atomic_read(&cm_closes);
40565 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40566 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40567 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40568 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40569 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40570 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40571 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40572 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40573 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40574 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40575 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40576 target_stat_values[++index] = cm_packets_sent;
40577 target_stat_values[++index] = cm_packets_bounced;
40578 target_stat_values[++index] = cm_packets_created;
40579 target_stat_values[++index] = cm_packets_received;
40580 target_stat_values[++index] = cm_packets_dropped;
40581 target_stat_values[++index] = cm_packets_retrans;
40582 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40583 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40584 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40585 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40586 target_stat_values[++index] = cm_backlog_drops;
40587 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40588 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40589 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40590 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40591 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40592 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40593 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40594 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40595 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40596 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40597 target_stat_values[++index] = nesadapter->free_4kpbl;
40598 target_stat_values[++index] = nesadapter->free_256pbl;
40599 target_stat_values[++index] = int_mod_timer_init;
40600 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40601 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40602 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40603 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40604 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40605 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40606 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40607 }
40608
40609 /**
40610 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40611 index 5b53ca5..443da3c 100644
40612 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40613 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40614 @@ -46,9 +46,9 @@
40615
40616 #include <rdma/ib_umem.h>
40617
40618 -atomic_t mod_qp_timouts;
40619 -atomic_t qps_created;
40620 -atomic_t sw_qps_destroyed;
40621 +atomic_unchecked_t mod_qp_timouts;
40622 +atomic_unchecked_t qps_created;
40623 +atomic_unchecked_t sw_qps_destroyed;
40624
40625 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40626
40627 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40628 if (init_attr->create_flags)
40629 return ERR_PTR(-EINVAL);
40630
40631 - atomic_inc(&qps_created);
40632 + atomic_inc_unchecked(&qps_created);
40633 switch (init_attr->qp_type) {
40634 case IB_QPT_RC:
40635 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40636 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40637 struct iw_cm_event cm_event;
40638 int ret = 0;
40639
40640 - atomic_inc(&sw_qps_destroyed);
40641 + atomic_inc_unchecked(&sw_qps_destroyed);
40642 nesqp->destroyed = 1;
40643
40644 /* Blow away the connection if it exists. */
40645 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40646 index 4a9af79..b993f75 100644
40647 --- a/drivers/infiniband/hw/qib/qib.h
40648 +++ b/drivers/infiniband/hw/qib/qib.h
40649 @@ -52,6 +52,7 @@
40650 #include <linux/kref.h>
40651 #include <linux/sched.h>
40652 #include <linux/kthread.h>
40653 +#include <linux/slab.h>
40654
40655 #include "qib_common.h"
40656 #include "qib_verbs.h"
40657 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40658 index da739d9..da1c7f4 100644
40659 --- a/drivers/input/gameport/gameport.c
40660 +++ b/drivers/input/gameport/gameport.c
40661 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40662 */
40663 static void gameport_init_port(struct gameport *gameport)
40664 {
40665 - static atomic_t gameport_no = ATOMIC_INIT(0);
40666 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40667
40668 __module_get(THIS_MODULE);
40669
40670 mutex_init(&gameport->drv_mutex);
40671 device_initialize(&gameport->dev);
40672 dev_set_name(&gameport->dev, "gameport%lu",
40673 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40674 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40675 gameport->dev.bus = &gameport_bus;
40676 gameport->dev.release = gameport_release_port;
40677 if (gameport->parent)
40678 diff --git a/drivers/input/input.c b/drivers/input/input.c
40679 index c044699..174d71a 100644
40680 --- a/drivers/input/input.c
40681 +++ b/drivers/input/input.c
40682 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
40683 */
40684 int input_register_device(struct input_dev *dev)
40685 {
40686 - static atomic_t input_no = ATOMIC_INIT(0);
40687 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
40688 struct input_devres *devres = NULL;
40689 struct input_handler *handler;
40690 unsigned int packet_size;
40691 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
40692 dev->setkeycode = input_default_setkeycode;
40693
40694 dev_set_name(&dev->dev, "input%ld",
40695 - (unsigned long) atomic_inc_return(&input_no) - 1);
40696 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
40697
40698 error = device_add(&dev->dev);
40699 if (error)
40700 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
40701 index 04c69af..5f92d00 100644
40702 --- a/drivers/input/joystick/sidewinder.c
40703 +++ b/drivers/input/joystick/sidewinder.c
40704 @@ -30,6 +30,7 @@
40705 #include <linux/kernel.h>
40706 #include <linux/module.h>
40707 #include <linux/slab.h>
40708 +#include <linux/sched.h>
40709 #include <linux/init.h>
40710 #include <linux/input.h>
40711 #include <linux/gameport.h>
40712 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
40713 index 75e3b10..fb390fd 100644
40714 --- a/drivers/input/joystick/xpad.c
40715 +++ b/drivers/input/joystick/xpad.c
40716 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
40717
40718 static int xpad_led_probe(struct usb_xpad *xpad)
40719 {
40720 - static atomic_t led_seq = ATOMIC_INIT(0);
40721 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
40722 long led_no;
40723 struct xpad_led *led;
40724 struct led_classdev *led_cdev;
40725 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
40726 if (!led)
40727 return -ENOMEM;
40728
40729 - led_no = (long)atomic_inc_return(&led_seq) - 1;
40730 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
40731
40732 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
40733 led->xpad = xpad;
40734 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
40735 index e204f26..8459f15 100644
40736 --- a/drivers/input/misc/ims-pcu.c
40737 +++ b/drivers/input/misc/ims-pcu.c
40738 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
40739
40740 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40741 {
40742 - static atomic_t device_no = ATOMIC_INIT(0);
40743 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
40744
40745 const struct ims_pcu_device_info *info;
40746 u8 device_id;
40747 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40748 }
40749
40750 /* Device appears to be operable, complete initialization */
40751 - pcu->device_no = atomic_inc_return(&device_no) - 1;
40752 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
40753
40754 error = ims_pcu_setup_backlight(pcu);
40755 if (error)
40756 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
40757 index 2f0b39d..7370f13 100644
40758 --- a/drivers/input/mouse/psmouse.h
40759 +++ b/drivers/input/mouse/psmouse.h
40760 @@ -116,7 +116,7 @@ struct psmouse_attribute {
40761 ssize_t (*set)(struct psmouse *psmouse, void *data,
40762 const char *buf, size_t count);
40763 bool protect;
40764 -};
40765 +} __do_const;
40766 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
40767
40768 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
40769 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
40770 index 4c842c3..590b0bf 100644
40771 --- a/drivers/input/mousedev.c
40772 +++ b/drivers/input/mousedev.c
40773 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
40774
40775 spin_unlock_irq(&client->packet_lock);
40776
40777 - if (copy_to_user(buffer, data, count))
40778 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
40779 return -EFAULT;
40780
40781 return count;
40782 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
40783 index 25fc597..558bf3b3 100644
40784 --- a/drivers/input/serio/serio.c
40785 +++ b/drivers/input/serio/serio.c
40786 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
40787 */
40788 static void serio_init_port(struct serio *serio)
40789 {
40790 - static atomic_t serio_no = ATOMIC_INIT(0);
40791 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
40792
40793 __module_get(THIS_MODULE);
40794
40795 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
40796 mutex_init(&serio->drv_mutex);
40797 device_initialize(&serio->dev);
40798 dev_set_name(&serio->dev, "serio%ld",
40799 - (long)atomic_inc_return(&serio_no) - 1);
40800 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
40801 serio->dev.bus = &serio_bus;
40802 serio->dev.release = serio_release_port;
40803 serio->dev.groups = serio_device_attr_groups;
40804 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
40805 index 59df2e7..8f1cafb 100644
40806 --- a/drivers/input/serio/serio_raw.c
40807 +++ b/drivers/input/serio/serio_raw.c
40808 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
40809
40810 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40811 {
40812 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
40813 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
40814 struct serio_raw *serio_raw;
40815 int err;
40816
40817 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40818 }
40819
40820 snprintf(serio_raw->name, sizeof(serio_raw->name),
40821 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
40822 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
40823 kref_init(&serio_raw->kref);
40824 INIT_LIST_HEAD(&serio_raw->client_list);
40825 init_waitqueue_head(&serio_raw->wait);
40826 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
40827 index fbe9ca7..dbee61d 100644
40828 --- a/drivers/iommu/iommu.c
40829 +++ b/drivers/iommu/iommu.c
40830 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
40831 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
40832 {
40833 bus_register_notifier(bus, &iommu_bus_nb);
40834 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
40835 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
40836 }
40837
40838 /**
40839 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
40840 index 39f81ae..2660096 100644
40841 --- a/drivers/iommu/irq_remapping.c
40842 +++ b/drivers/iommu/irq_remapping.c
40843 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
40844 void panic_if_irq_remap(const char *msg)
40845 {
40846 if (irq_remapping_enabled)
40847 - panic(msg);
40848 + panic("%s", msg);
40849 }
40850
40851 static void ir_ack_apic_edge(struct irq_data *data)
40852 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
40853
40854 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
40855 {
40856 - chip->irq_print_chip = ir_print_prefix;
40857 - chip->irq_ack = ir_ack_apic_edge;
40858 - chip->irq_eoi = ir_ack_apic_level;
40859 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
40860 + pax_open_kernel();
40861 + *(void **)&chip->irq_print_chip = ir_print_prefix;
40862 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
40863 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
40864 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
40865 + pax_close_kernel();
40866 }
40867
40868 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
40869 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
40870 index ee7c503..5d4ce08 100644
40871 --- a/drivers/irqchip/irq-gic.c
40872 +++ b/drivers/irqchip/irq-gic.c
40873 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
40874 * Supported arch specific GIC irq extension.
40875 * Default make them NULL.
40876 */
40877 -struct irq_chip gic_arch_extn = {
40878 +irq_chip_no_const gic_arch_extn = {
40879 .irq_eoi = NULL,
40880 .irq_mask = NULL,
40881 .irq_unmask = NULL,
40882 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
40883 chained_irq_exit(chip, desc);
40884 }
40885
40886 -static struct irq_chip gic_chip = {
40887 +static irq_chip_no_const gic_chip __read_only = {
40888 .name = "GIC",
40889 .irq_mask = gic_mask_irq,
40890 .irq_unmask = gic_unmask_irq,
40891 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
40892 index ac6f72b..81150f2 100644
40893 --- a/drivers/isdn/capi/capi.c
40894 +++ b/drivers/isdn/capi/capi.c
40895 @@ -81,8 +81,8 @@ struct capiminor {
40896
40897 struct capi20_appl *ap;
40898 u32 ncci;
40899 - atomic_t datahandle;
40900 - atomic_t msgid;
40901 + atomic_unchecked_t datahandle;
40902 + atomic_unchecked_t msgid;
40903
40904 struct tty_port port;
40905 int ttyinstop;
40906 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
40907 capimsg_setu16(s, 2, mp->ap->applid);
40908 capimsg_setu8 (s, 4, CAPI_DATA_B3);
40909 capimsg_setu8 (s, 5, CAPI_RESP);
40910 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
40911 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
40912 capimsg_setu32(s, 8, mp->ncci);
40913 capimsg_setu16(s, 12, datahandle);
40914 }
40915 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
40916 mp->outbytes -= len;
40917 spin_unlock_bh(&mp->outlock);
40918
40919 - datahandle = atomic_inc_return(&mp->datahandle);
40920 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
40921 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
40922 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
40923 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
40924 capimsg_setu16(skb->data, 2, mp->ap->applid);
40925 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
40926 capimsg_setu8 (skb->data, 5, CAPI_REQ);
40927 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
40928 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
40929 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
40930 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
40931 capimsg_setu16(skb->data, 16, len); /* Data length */
40932 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
40933 index 600c79b..3752bab 100644
40934 --- a/drivers/isdn/gigaset/interface.c
40935 +++ b/drivers/isdn/gigaset/interface.c
40936 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
40937 }
40938 tty->driver_data = cs;
40939
40940 - ++cs->port.count;
40941 + atomic_inc(&cs->port.count);
40942
40943 - if (cs->port.count == 1) {
40944 + if (atomic_read(&cs->port.count) == 1) {
40945 tty_port_tty_set(&cs->port, tty);
40946 cs->port.low_latency = 1;
40947 }
40948 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
40949
40950 if (!cs->connected)
40951 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
40952 - else if (!cs->port.count)
40953 + else if (!atomic_read(&cs->port.count))
40954 dev_warn(cs->dev, "%s: device not opened\n", __func__);
40955 - else if (!--cs->port.count)
40956 + else if (!atomic_dec_return(&cs->port.count))
40957 tty_port_tty_set(&cs->port, NULL);
40958
40959 mutex_unlock(&cs->mutex);
40960 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
40961 index d0a41cb..f0cdb8c 100644
40962 --- a/drivers/isdn/gigaset/usb-gigaset.c
40963 +++ b/drivers/isdn/gigaset/usb-gigaset.c
40964 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
40965 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
40966 memcpy(cs->hw.usb->bchars, buf, 6);
40967 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
40968 - 0, 0, &buf, 6, 2000);
40969 + 0, 0, buf, 6, 2000);
40970 }
40971
40972 static void gigaset_freebcshw(struct bc_state *bcs)
40973 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
40974 index 4d9b195..455075c 100644
40975 --- a/drivers/isdn/hardware/avm/b1.c
40976 +++ b/drivers/isdn/hardware/avm/b1.c
40977 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
40978 }
40979 if (left) {
40980 if (t4file->user) {
40981 - if (copy_from_user(buf, dp, left))
40982 + if (left > sizeof buf || copy_from_user(buf, dp, left))
40983 return -EFAULT;
40984 } else {
40985 memcpy(buf, dp, left);
40986 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
40987 }
40988 if (left) {
40989 if (config->user) {
40990 - if (copy_from_user(buf, dp, left))
40991 + if (left > sizeof buf || copy_from_user(buf, dp, left))
40992 return -EFAULT;
40993 } else {
40994 memcpy(buf, dp, left);
40995 diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
40996 index 1063bab..36817e0 100644
40997 --- a/drivers/isdn/hisax/amd7930_fn.c
40998 +++ b/drivers/isdn/hisax/amd7930_fn.c
40999 @@ -314,7 +314,7 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag)
41000
41001 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx);
41002 QuickHex(t, cs->rcvbuf, cs->rcvidx);
41003 - debugl1(cs, cs->dlog);
41004 + debugl1(cs, "%s", cs->dlog);
41005 }
41006 /* moves received data in sk-buffer */
41007 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
41008 @@ -406,7 +406,7 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs)
41009
41010 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count);
41011 QuickHex(t, deb_ptr, count);
41012 - debugl1(cs, cs->dlog);
41013 + debugl1(cs, "%s", cs->dlog);
41014 }
41015 /* AMD interrupts on */
41016 AmdIrqOn(cs);
41017 diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
41018 index ee9b9a0..d1427bd 100644
41019 --- a/drivers/isdn/hisax/avm_pci.c
41020 +++ b/drivers/isdn/hisax/avm_pci.c
41021 @@ -285,7 +285,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count)
41022 t += sprintf(t, "hdlc_empty_fifo %c cnt %d",
41023 bcs->channel ? 'B' : 'A', count);
41024 QuickHex(t, p, count);
41025 - debugl1(cs, bcs->blog);
41026 + debugl1(cs, "%s", bcs->blog);
41027 }
41028 }
41029
41030 @@ -345,7 +345,7 @@ hdlc_fill_fifo(struct BCState *bcs)
41031 t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
41032 bcs->channel ? 'B' : 'A', count);
41033 QuickHex(t, p, count);
41034 - debugl1(cs, bcs->blog);
41035 + debugl1(cs, "%s", bcs->blog);
41036 }
41037 }
41038
41039 diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
41040 index bf04d2a..b33f53b 100644
41041 --- a/drivers/isdn/hisax/config.c
41042 +++ b/drivers/isdn/hisax/config.c
41043 @@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
41044 ptr--;
41045 *ptr++ = '\n';
41046 *ptr = 0;
41047 - HiSax_putstatus(cs, NULL, cs->dlog);
41048 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41049 } else
41050 HiSax_putstatus(cs, "LogEcho: ",
41051 "warning Frame too big (%d)",
41052 diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
41053 index 8d0cf6e..4fc90de 100644
41054 --- a/drivers/isdn/hisax/diva.c
41055 +++ b/drivers/isdn/hisax/diva.c
41056 @@ -427,7 +427,7 @@ Memhscx_empty_fifo(struct BCState *bcs, int count)
41057 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41058 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41059 QuickHex(t, ptr, count);
41060 - debugl1(cs, bcs->blog);
41061 + debugl1(cs, "%s", bcs->blog);
41062 }
41063 }
41064
41065 @@ -469,7 +469,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
41066 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41067 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41068 QuickHex(t, ptr, count);
41069 - debugl1(cs, bcs->blog);
41070 + debugl1(cs, "%s", bcs->blog);
41071 }
41072 }
41073
41074 diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
41075 index 1df6f9a..2be1c8a 100644
41076 --- a/drivers/isdn/hisax/elsa.c
41077 +++ b/drivers/isdn/hisax/elsa.c
41078 @@ -535,7 +535,7 @@ check_arcofi(struct IsdnCardState *cs)
41079 t = tmp;
41080 t += sprintf(tmp, "Arcofi data");
41081 QuickHex(t, p, cs->dc.isac.mon_rxp);
41082 - debugl1(cs, tmp);
41083 + debugl1(cs, "%s", tmp);
41084 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
41085 switch (cs->dc.isac.mon_rx[1]) {
41086 case 0x80:
41087 diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
41088 index d4c98d3..3f84dd8 100644
41089 --- a/drivers/isdn/hisax/elsa_ser.c
41090 +++ b/drivers/isdn/hisax/elsa_ser.c
41091 @@ -344,7 +344,7 @@ static inline void receive_chars(struct IsdnCardState *cs,
41092
41093 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt);
41094 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt);
41095 - debugl1(cs, tmp);
41096 + debugl1(cs, "%s", tmp);
41097 }
41098 cs->hw.elsa.rcvcnt = 0;
41099 }
41100 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
41101 index 3ccd724..497bd02 100644
41102 --- a/drivers/isdn/hisax/hfc_pci.c
41103 +++ b/drivers/isdn/hisax/hfc_pci.c
41104 @@ -901,7 +901,7 @@ Begin:
41105 ptr--;
41106 *ptr++ = '\n';
41107 *ptr = 0;
41108 - HiSax_putstatus(cs, NULL, cs->dlog);
41109 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41110 } else
41111 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
41112 }
41113 diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
41114 index dc4574f..fa1fefd 100644
41115 --- a/drivers/isdn/hisax/hfc_sx.c
41116 +++ b/drivers/isdn/hisax/hfc_sx.c
41117 @@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs)
41118 ptr--;
41119 *ptr++ = '\n';
41120 *ptr = 0;
41121 - HiSax_putstatus(cs, NULL, cs->dlog);
41122 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41123 } else
41124 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
41125 }
41126 diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
41127 index f398d48..a8d6188 100644
41128 --- a/drivers/isdn/hisax/hscx_irq.c
41129 +++ b/drivers/isdn/hisax/hscx_irq.c
41130 @@ -75,7 +75,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
41131 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41132 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41133 QuickHex(t, ptr, count);
41134 - debugl1(cs, bcs->blog);
41135 + debugl1(cs, "%s", bcs->blog);
41136 }
41137 }
41138
41139 @@ -115,7 +115,7 @@ hscx_fill_fifo(struct BCState *bcs)
41140 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41141 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41142 QuickHex(t, ptr, count);
41143 - debugl1(cs, bcs->blog);
41144 + debugl1(cs, "%s", bcs->blog);
41145 }
41146 }
41147
41148 diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
41149 index db5321f..51dae91 100644
41150 --- a/drivers/isdn/hisax/icc.c
41151 +++ b/drivers/isdn/hisax/icc.c
41152 @@ -134,7 +134,7 @@ icc_empty_fifo(struct IsdnCardState *cs, int count)
41153
41154 t += sprintf(t, "icc_empty_fifo cnt %d", count);
41155 QuickHex(t, ptr, count);
41156 - debugl1(cs, cs->dlog);
41157 + debugl1(cs, "%s", cs->dlog);
41158 }
41159 }
41160
41161 @@ -176,7 +176,7 @@ icc_fill_fifo(struct IsdnCardState *cs)
41162
41163 t += sprintf(t, "icc_fill_fifo cnt %d", count);
41164 QuickHex(t, ptr, count);
41165 - debugl1(cs, cs->dlog);
41166 + debugl1(cs, "%s", cs->dlog);
41167 }
41168 }
41169
41170 diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
41171 index 74feb5c..5faa5de 100644
41172 --- a/drivers/isdn/hisax/ipacx.c
41173 +++ b/drivers/isdn/hisax/ipacx.c
41174 @@ -260,7 +260,7 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
41175
41176 t += sprintf(t, "dch_empty_fifo() cnt %d", count);
41177 QuickHex(t, ptr, count);
41178 - debugl1(cs, cs->dlog);
41179 + debugl1(cs, "%s", cs->dlog);
41180 }
41181 }
41182
41183 @@ -307,7 +307,7 @@ dch_fill_fifo(struct IsdnCardState *cs)
41184
41185 t += sprintf(t, "dch_fill_fifo() cnt %d", count);
41186 QuickHex(t, ptr, count);
41187 - debugl1(cs, cs->dlog);
41188 + debugl1(cs, "%s", cs->dlog);
41189 }
41190 }
41191
41192 @@ -539,7 +539,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
41193
41194 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count);
41195 QuickHex(t, ptr, count);
41196 - debugl1(cs, bcs->blog);
41197 + debugl1(cs, "%s", bcs->blog);
41198 }
41199 }
41200
41201 @@ -582,7 +582,7 @@ bch_fill_fifo(struct BCState *bcs)
41202
41203 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
41204 QuickHex(t, ptr, count);
41205 - debugl1(cs, bcs->blog);
41206 + debugl1(cs, "%s", bcs->blog);
41207 }
41208 }
41209
41210 diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
41211 index a365ccc..7fdf78f 100644
41212 --- a/drivers/isdn/hisax/isac.c
41213 +++ b/drivers/isdn/hisax/isac.c
41214 @@ -137,7 +137,7 @@ isac_empty_fifo(struct IsdnCardState *cs, int count)
41215
41216 t += sprintf(t, "isac_empty_fifo cnt %d", count);
41217 QuickHex(t, ptr, count);
41218 - debugl1(cs, cs->dlog);
41219 + debugl1(cs, "%s", cs->dlog);
41220 }
41221 }
41222
41223 @@ -179,7 +179,7 @@ isac_fill_fifo(struct IsdnCardState *cs)
41224
41225 t += sprintf(t, "isac_fill_fifo cnt %d", count);
41226 QuickHex(t, ptr, count);
41227 - debugl1(cs, cs->dlog);
41228 + debugl1(cs, "%s", cs->dlog);
41229 }
41230 }
41231
41232 diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
41233 index 7fdf347..f4956c7 100644
41234 --- a/drivers/isdn/hisax/isar.c
41235 +++ b/drivers/isdn/hisax/isar.c
41236 @@ -74,7 +74,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
41237 t = tmp;
41238 t += sprintf(t, "sendmbox cnt %d", len);
41239 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
41240 - debugl1(cs, tmp);
41241 + debugl1(cs, "%s", tmp);
41242 i -= 64;
41243 }
41244 }
41245 @@ -105,7 +105,7 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
41246 t = tmp;
41247 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb);
41248 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
41249 - debugl1(cs, tmp);
41250 + debugl1(cs, "%s", tmp);
41251 i -= 64;
41252 }
41253 }
41254 @@ -1248,7 +1248,7 @@ isar_int_main(struct IsdnCardState *cs)
41255 tp += sprintf(debbuf, "msg iis(%x) msb(%x)",
41256 ireg->iis, ireg->cmsb);
41257 QuickHex(tp, (u_char *)ireg->par, ireg->clsb);
41258 - debugl1(cs, debbuf);
41259 + debugl1(cs, "%s", debbuf);
41260 }
41261 break;
41262 case ISAR_IIS_INVMSG:
41263 diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
41264 index f946c58..e2ae787 100644
41265 --- a/drivers/isdn/hisax/jade.c
41266 +++ b/drivers/isdn/hisax/jade.c
41267 @@ -81,10 +81,7 @@ modejade(struct BCState *bcs, int mode, int bc)
41268 int jade = bcs->hw.hscx.hscx;
41269
41270 if (cs->debug & L1_DEB_HSCX) {
41271 - char tmp[40];
41272 - sprintf(tmp, "jade %c mode %d ichan %d",
41273 - 'A' + jade, mode, bc);
41274 - debugl1(cs, tmp);
41275 + debugl1(cs, "jade %c mode %d ichan %d", 'A' + jade, mode, bc);
41276 }
41277 bcs->mode = mode;
41278 bcs->channel = bc;
41279 @@ -257,23 +254,18 @@ void
41280 clear_pending_jade_ints(struct IsdnCardState *cs)
41281 {
41282 int val;
41283 - char tmp[64];
41284
41285 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
41286 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
41287
41288 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
41289 - sprintf(tmp, "jade B ISTA %x", val);
41290 - debugl1(cs, tmp);
41291 + debugl1(cs, "jade B ISTA %x", val);
41292 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
41293 - sprintf(tmp, "jade A ISTA %x", val);
41294 - debugl1(cs, tmp);
41295 + debugl1(cs, "jade A ISTA %x", val);
41296 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
41297 - sprintf(tmp, "jade B STAR %x", val);
41298 - debugl1(cs, tmp);
41299 + debugl1(cs, "jade B STAR %x", val);
41300 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
41301 - sprintf(tmp, "jade A STAR %x", val);
41302 - debugl1(cs, tmp);
41303 + debugl1(cs, "jade A STAR %x", val);
41304 /* Unmask ints */
41305 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
41306 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
41307 diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c
41308 index f521fc8..b930da9 100644
41309 --- a/drivers/isdn/hisax/jade_irq.c
41310 +++ b/drivers/isdn/hisax/jade_irq.c
41311 @@ -65,7 +65,7 @@ jade_empty_fifo(struct BCState *bcs, int count)
41312 t += sprintf(t, "jade_empty_fifo %c cnt %d",
41313 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41314 QuickHex(t, ptr, count);
41315 - debugl1(cs, bcs->blog);
41316 + debugl1(cs, "%s", bcs->blog);
41317 }
41318 }
41319
41320 @@ -105,7 +105,7 @@ jade_fill_fifo(struct BCState *bcs)
41321 t += sprintf(t, "jade_fill_fifo %c cnt %d",
41322 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41323 QuickHex(t, ptr, count);
41324 - debugl1(cs, bcs->blog);
41325 + debugl1(cs, "%s", bcs->blog);
41326 }
41327 }
41328
41329 diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
41330 index 4c1bca5..875402e 100644
41331 --- a/drivers/isdn/hisax/l3_1tr6.c
41332 +++ b/drivers/isdn/hisax/l3_1tr6.c
41333 @@ -63,7 +63,7 @@ l3_1tr6_error(struct l3_process *pc, u_char *msg, struct sk_buff *skb)
41334 {
41335 dev_kfree_skb(skb);
41336 if (pc->st->l3.debug & L3_DEB_WARN)
41337 - l3_debug(pc->st, msg);
41338 + l3_debug(pc->st, "%s", msg);
41339 l3_1tr6_release_req(pc, 0, NULL);
41340 }
41341
41342 @@ -161,7 +161,6 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41343 {
41344 u_char *p;
41345 int bcfound = 0;
41346 - char tmp[80];
41347 struct sk_buff *skb = arg;
41348
41349 /* Channel Identification */
41350 @@ -214,10 +213,9 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41351 /* Signal all services, linklevel takes care of Service-Indicator */
41352 if (bcfound) {
41353 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
41354 - sprintf(tmp, "non-digital call: %s -> %s",
41355 + l3_debug(pc->st, "non-digital call: %s -> %s",
41356 pc->para.setup.phone,
41357 pc->para.setup.eazmsn);
41358 - l3_debug(pc->st, tmp);
41359 }
41360 newl3state(pc, 6);
41361 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
41362 @@ -301,7 +299,7 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41363 {
41364 u_char *p;
41365 int i, tmpcharge = 0;
41366 - char a_charge[8], tmp[32];
41367 + char a_charge[8];
41368 struct sk_buff *skb = arg;
41369
41370 p = skb->data;
41371 @@ -316,8 +314,8 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41372 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41373 }
41374 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41375 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41376 - l3_debug(pc->st, tmp);
41377 + l3_debug(pc->st, "charging info %d",
41378 + pc->para.chargeinfo);
41379 }
41380 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41381 l3_debug(pc->st, "charging info not found");
41382 @@ -399,7 +397,7 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41383 struct sk_buff *skb = arg;
41384 u_char *p;
41385 int i, tmpcharge = 0;
41386 - char a_charge[8], tmp[32];
41387 + char a_charge[8];
41388
41389 StopAllL3Timer(pc);
41390 p = skb->data;
41391 @@ -414,8 +412,8 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41392 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41393 }
41394 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41395 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41396 - l3_debug(pc->st, tmp);
41397 + l3_debug(pc->st, "charging info %d",
41398 + pc->para.chargeinfo);
41399 }
41400 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41401 l3_debug(pc->st, "charging info not found");
41402 @@ -746,7 +744,6 @@ up1tr6(struct PStack *st, int pr, void *arg)
41403 int i, mt, cr;
41404 struct l3_process *proc;
41405 struct sk_buff *skb = arg;
41406 - char tmp[80];
41407
41408 switch (pr) {
41409 case (DL_DATA | INDICATION):
41410 @@ -762,26 +759,23 @@ up1tr6(struct PStack *st, int pr, void *arg)
41411 }
41412 if (skb->len < 4) {
41413 if (st->l3.debug & L3_DEB_PROTERR) {
41414 - sprintf(tmp, "up1tr6 len only %d", skb->len);
41415 - l3_debug(st, tmp);
41416 + l3_debug(st, "up1tr6 len only %d", skb->len);
41417 }
41418 dev_kfree_skb(skb);
41419 return;
41420 }
41421 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
41422 if (st->l3.debug & L3_DEB_PROTERR) {
41423 - sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d",
41424 + l3_debug(st, "up1tr6%sunexpected discriminator %x message len %d",
41425 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41426 skb->data[0], skb->len);
41427 - l3_debug(st, tmp);
41428 }
41429 dev_kfree_skb(skb);
41430 return;
41431 }
41432 if (skb->data[1] != 1) {
41433 if (st->l3.debug & L3_DEB_PROTERR) {
41434 - sprintf(tmp, "up1tr6 CR len not 1");
41435 - l3_debug(st, tmp);
41436 + l3_debug(st, "up1tr6 CR len not 1");
41437 }
41438 dev_kfree_skb(skb);
41439 return;
41440 @@ -791,9 +785,8 @@ up1tr6(struct PStack *st, int pr, void *arg)
41441 if (skb->data[0] == PROTO_DIS_N0) {
41442 dev_kfree_skb(skb);
41443 if (st->l3.debug & L3_DEB_STATE) {
41444 - sprintf(tmp, "up1tr6%s N0 mt %x unhandled",
41445 + l3_debug(st, "up1tr6%s N0 mt %x unhandled",
41446 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt);
41447 - l3_debug(st, tmp);
41448 }
41449 } else if (skb->data[0] == PROTO_DIS_N1) {
41450 if (!(proc = getl3proc(st, cr))) {
41451 @@ -801,8 +794,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41452 if (cr < 128) {
41453 if (!(proc = new_l3_process(st, cr))) {
41454 if (st->l3.debug & L3_DEB_PROTERR) {
41455 - sprintf(tmp, "up1tr6 no roc mem");
41456 - l3_debug(st, tmp);
41457 + l3_debug(st, "up1tr6 no roc mem");
41458 }
41459 dev_kfree_skb(skb);
41460 return;
41461 @@ -821,8 +813,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41462 } else {
41463 if (!(proc = new_l3_process(st, cr))) {
41464 if (st->l3.debug & L3_DEB_PROTERR) {
41465 - sprintf(tmp, "up1tr6 no roc mem");
41466 - l3_debug(st, tmp);
41467 + l3_debug(st, "up1tr6 no roc mem");
41468 }
41469 dev_kfree_skb(skb);
41470 return;
41471 @@ -837,18 +828,16 @@ up1tr6(struct PStack *st, int pr, void *arg)
41472 if (i == ARRAY_SIZE(datastln1)) {
41473 dev_kfree_skb(skb);
41474 if (st->l3.debug & L3_DEB_STATE) {
41475 - sprintf(tmp, "up1tr6%sstate %d mt %x unhandled",
41476 + l3_debug(st, "up1tr6%sstate %d mt %x unhandled",
41477 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41478 proc->state, mt);
41479 - l3_debug(st, tmp);
41480 }
41481 return;
41482 } else {
41483 if (st->l3.debug & L3_DEB_STATE) {
41484 - sprintf(tmp, "up1tr6%sstate %d mt %x",
41485 + l3_debug(st, "up1tr6%sstate %d mt %x",
41486 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41487 proc->state, mt);
41488 - l3_debug(st, tmp);
41489 }
41490 datastln1[i].rout(proc, pr, skb);
41491 }
41492 @@ -861,7 +850,6 @@ down1tr6(struct PStack *st, int pr, void *arg)
41493 int i, cr;
41494 struct l3_process *proc;
41495 struct Channel *chan;
41496 - char tmp[80];
41497
41498 if ((DL_ESTABLISH | REQUEST) == pr) {
41499 l3_msg(st, pr, NULL);
41500 @@ -888,15 +876,13 @@ down1tr6(struct PStack *st, int pr, void *arg)
41501 break;
41502 if (i == ARRAY_SIZE(downstl)) {
41503 if (st->l3.debug & L3_DEB_STATE) {
41504 - sprintf(tmp, "down1tr6 state %d prim %d unhandled",
41505 + l3_debug(st, "down1tr6 state %d prim %d unhandled",
41506 proc->state, pr);
41507 - l3_debug(st, tmp);
41508 }
41509 } else {
41510 if (st->l3.debug & L3_DEB_STATE) {
41511 - sprintf(tmp, "down1tr6 state %d prim %d",
41512 + l3_debug(st, "down1tr6 state %d prim %d",
41513 proc->state, pr);
41514 - l3_debug(st, tmp);
41515 }
41516 downstl[i].rout(proc, pr, arg);
41517 }
41518 diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
41519 index b646eed..233e432 100644
41520 --- a/drivers/isdn/hisax/netjet.c
41521 +++ b/drivers/isdn/hisax/netjet.c
41522 @@ -176,7 +176,7 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s
41523 else
41524 j = i;
41525 QuickHex(t, p, j);
41526 - debugl1(cs, tmp);
41527 + debugl1(cs, "%s", tmp);
41528 p += j;
41529 i -= j;
41530 t = tmp;
41531 diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
41532 index 041bf52..af1b020 100644
41533 --- a/drivers/isdn/hisax/q931.c
41534 +++ b/drivers/isdn/hisax/q931.c
41535 @@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size)
41536 dp--;
41537 *dp++ = '\n';
41538 *dp = 0;
41539 - HiSax_putstatus(cs, NULL, cs->dlog);
41540 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41541 } else
41542 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
41543 }
41544 @@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41545 }
41546 if (finish) {
41547 *dp = 0;
41548 - HiSax_putstatus(cs, NULL, cs->dlog);
41549 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41550 return;
41551 }
41552 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
41553 @@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41554 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
41555 }
41556 *dp = 0;
41557 - HiSax_putstatus(cs, NULL, cs->dlog);
41558 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41559 }
41560 diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
41561 index d8cac69..a858955 100644
41562 --- a/drivers/isdn/hisax/w6692.c
41563 +++ b/drivers/isdn/hisax/w6692.c
41564 @@ -154,7 +154,7 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
41565
41566 t += sprintf(t, "W6692_empty_fifo cnt %d", count);
41567 QuickHex(t, ptr, count);
41568 - debugl1(cs, cs->dlog);
41569 + debugl1(cs, "%s", cs->dlog);
41570 }
41571 }
41572
41573 @@ -196,7 +196,7 @@ W6692_fill_fifo(struct IsdnCardState *cs)
41574
41575 t += sprintf(t, "W6692_fill_fifo cnt %d", count);
41576 QuickHex(t, ptr, count);
41577 - debugl1(cs, cs->dlog);
41578 + debugl1(cs, "%s", cs->dlog);
41579 }
41580 }
41581
41582 @@ -226,7 +226,7 @@ W6692B_empty_fifo(struct BCState *bcs, int count)
41583 t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
41584 bcs->channel + '1', count);
41585 QuickHex(t, ptr, count);
41586 - debugl1(cs, bcs->blog);
41587 + debugl1(cs, "%s", bcs->blog);
41588 }
41589 }
41590
41591 @@ -264,7 +264,7 @@ W6692B_fill_fifo(struct BCState *bcs)
41592 t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
41593 bcs->channel + '1', count);
41594 QuickHex(t, ptr, count);
41595 - debugl1(cs, bcs->blog);
41596 + debugl1(cs, "%s", bcs->blog);
41597 }
41598 }
41599
41600 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41601 index 9bb12ba..d4262f7 100644
41602 --- a/drivers/isdn/i4l/isdn_common.c
41603 +++ b/drivers/isdn/i4l/isdn_common.c
41604 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41605 } else
41606 return -EINVAL;
41607 case IIOCDBGVAR:
41608 + if (!capable(CAP_SYS_RAWIO))
41609 + return -EPERM;
41610 if (arg) {
41611 if (copy_to_user(argp, &dev, sizeof(ulong)))
41612 return -EFAULT;
41613 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41614 index 3c5f249..5fac4d0 100644
41615 --- a/drivers/isdn/i4l/isdn_tty.c
41616 +++ b/drivers/isdn/i4l/isdn_tty.c
41617 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41618
41619 #ifdef ISDN_DEBUG_MODEM_OPEN
41620 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41621 - port->count);
41622 + atomic_read(&port->count));
41623 #endif
41624 - port->count++;
41625 + atomic_inc(&port->count);
41626 port->tty = tty;
41627 /*
41628 * Start up serial port
41629 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41630 #endif
41631 return;
41632 }
41633 - if ((tty->count == 1) && (port->count != 1)) {
41634 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41635 /*
41636 * Uh, oh. tty->count is 1, which means that the tty
41637 * structure will be freed. Info->count should always
41638 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41639 * serial port won't be shutdown.
41640 */
41641 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41642 - "info->count is %d\n", port->count);
41643 - port->count = 1;
41644 + "info->count is %d\n", atomic_read(&port->count));
41645 + atomic_set(&port->count, 1);
41646 }
41647 - if (--port->count < 0) {
41648 + if (atomic_dec_return(&port->count) < 0) {
41649 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41650 - info->line, port->count);
41651 - port->count = 0;
41652 + info->line, atomic_read(&port->count));
41653 + atomic_set(&port->count, 0);
41654 }
41655 - if (port->count) {
41656 + if (atomic_read(&port->count)) {
41657 #ifdef ISDN_DEBUG_MODEM_OPEN
41658 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41659 #endif
41660 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41661 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41662 return;
41663 isdn_tty_shutdown(info);
41664 - port->count = 0;
41665 + atomic_set(&port->count, 0);
41666 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41667 port->tty = NULL;
41668 wake_up_interruptible(&port->open_wait);
41669 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41670 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41671 modem_info *info = &dev->mdm.info[i];
41672
41673 - if (info->port.count == 0)
41674 + if (atomic_read(&info->port.count) == 0)
41675 continue;
41676 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41677 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41678 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41679 index e74df7c..03a03ba 100644
41680 --- a/drivers/isdn/icn/icn.c
41681 +++ b/drivers/isdn/icn/icn.c
41682 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41683 if (count > len)
41684 count = len;
41685 if (user) {
41686 - if (copy_from_user(msg, buf, count))
41687 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41688 return -EFAULT;
41689 } else
41690 memcpy(msg, buf, count);
41691 diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
41692 index baf2686..02125e6 100644
41693 --- a/drivers/isdn/isdnloop/isdnloop.c
41694 +++ b/drivers/isdn/isdnloop/isdnloop.c
41695 @@ -1083,8 +1083,10 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41696 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41697 return -ENOMEM;
41698 }
41699 - for (i = 0; i < 3; i++)
41700 - strcpy(card->s0num[i], sdef.num[i]);
41701 + for (i = 0; i < 3; i++) {
41702 + strlcpy(card->s0num[i], sdef.num[i],
41703 + sizeof(card->s0num[0]));
41704 + }
41705 break;
41706 case ISDN_PTYPE_1TR6:
41707 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
41708 @@ -1097,7 +1099,7 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41709 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41710 return -ENOMEM;
41711 }
41712 - strcpy(card->s0num[0], sdef.num[0]);
41713 + strlcpy(card->s0num[0], sdef.num[0], sizeof(card->s0num[0]));
41714 card->s0num[1][0] = '\0';
41715 card->s0num[2][0] = '\0';
41716 break;
41717 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41718 index 6a8405d..0bd1c7e 100644
41719 --- a/drivers/leds/leds-clevo-mail.c
41720 +++ b/drivers/leds/leds-clevo-mail.c
41721 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41722 * detected as working, but in reality it is not) as low as
41723 * possible.
41724 */
41725 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
41726 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
41727 {
41728 .callback = clevo_mail_led_dmi_callback,
41729 .ident = "Clevo D410J",
41730 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41731 index 64e204e..c6bf189 100644
41732 --- a/drivers/leds/leds-ss4200.c
41733 +++ b/drivers/leds/leds-ss4200.c
41734 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41735 * detected as working, but in reality it is not) as low as
41736 * possible.
41737 */
41738 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
41739 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
41740 {
41741 .callback = ss4200_led_dmi_callback,
41742 .ident = "Intel SS4200-E",
41743 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41744 index 0bf1e4e..b4bf44e 100644
41745 --- a/drivers/lguest/core.c
41746 +++ b/drivers/lguest/core.c
41747 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41748 * The end address needs +1 because __get_vm_area allocates an
41749 * extra guard page, so we need space for that.
41750 */
41751 +
41752 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41753 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41754 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41755 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41756 +#else
41757 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41758 VM_ALLOC, switcher_addr, switcher_addr
41759 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41760 +#endif
41761 +
41762 if (!switcher_vma) {
41763 err = -ENOMEM;
41764 printk("lguest: could not map switcher pages high\n");
41765 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41766 * Now the Switcher is mapped at the right address, we can't fail!
41767 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41768 */
41769 - memcpy(switcher_vma->addr, start_switcher_text,
41770 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41771 end_switcher_text - start_switcher_text);
41772
41773 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41774 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41775 index a35d8d1..59fb772 100644
41776 --- a/drivers/lguest/page_tables.c
41777 +++ b/drivers/lguest/page_tables.c
41778 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41779 /*:*/
41780
41781 #ifdef CONFIG_X86_PAE
41782 -static void release_pmd(pmd_t *spmd)
41783 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41784 {
41785 /* If the entry's not present, there's nothing to release. */
41786 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41787 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41788 index 5169239..47cb4db 100644
41789 --- a/drivers/lguest/x86/core.c
41790 +++ b/drivers/lguest/x86/core.c
41791 @@ -59,7 +59,7 @@ static struct {
41792 /* Offset from where switcher.S was compiled to where we've copied it */
41793 static unsigned long switcher_offset(void)
41794 {
41795 - return switcher_addr - (unsigned long)start_switcher_text;
41796 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41797 }
41798
41799 /* This cpu's struct lguest_pages (after the Switcher text page) */
41800 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
41801 * These copies are pretty cheap, so we do them unconditionally: */
41802 /* Save the current Host top-level page directory.
41803 */
41804 +
41805 +#ifdef CONFIG_PAX_PER_CPU_PGD
41806 + pages->state.host_cr3 = read_cr3();
41807 +#else
41808 pages->state.host_cr3 = __pa(current->mm->pgd);
41809 +#endif
41810 +
41811 /*
41812 * Set up the Guest's page tables to see this CPU's pages (and no
41813 * other CPU's pages).
41814 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
41815 * compiled-in switcher code and the high-mapped copy we just made.
41816 */
41817 for (i = 0; i < IDT_ENTRIES; i++)
41818 - default_idt_entries[i] += switcher_offset();
41819 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
41820
41821 /*
41822 * Set up the Switcher's per-cpu areas.
41823 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
41824 * it will be undisturbed when we switch. To change %cs and jump we
41825 * need this structure to feed to Intel's "lcall" instruction.
41826 */
41827 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
41828 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
41829 lguest_entry.segment = LGUEST_CS;
41830
41831 /*
41832 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
41833 index 40634b0..4f5855e 100644
41834 --- a/drivers/lguest/x86/switcher_32.S
41835 +++ b/drivers/lguest/x86/switcher_32.S
41836 @@ -87,6 +87,7 @@
41837 #include <asm/page.h>
41838 #include <asm/segment.h>
41839 #include <asm/lguest.h>
41840 +#include <asm/processor-flags.h>
41841
41842 // We mark the start of the code to copy
41843 // It's placed in .text tho it's never run here
41844 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
41845 // Changes type when we load it: damn Intel!
41846 // For after we switch over our page tables
41847 // That entry will be read-only: we'd crash.
41848 +
41849 +#ifdef CONFIG_PAX_KERNEXEC
41850 + mov %cr0, %edx
41851 + xor $X86_CR0_WP, %edx
41852 + mov %edx, %cr0
41853 +#endif
41854 +
41855 movl $(GDT_ENTRY_TSS*8), %edx
41856 ltr %dx
41857
41858 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
41859 // Let's clear it again for our return.
41860 // The GDT descriptor of the Host
41861 // Points to the table after two "size" bytes
41862 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
41863 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
41864 // Clear "used" from type field (byte 5, bit 2)
41865 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
41866 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
41867 +
41868 +#ifdef CONFIG_PAX_KERNEXEC
41869 + mov %cr0, %eax
41870 + xor $X86_CR0_WP, %eax
41871 + mov %eax, %cr0
41872 +#endif
41873
41874 // Once our page table's switched, the Guest is live!
41875 // The Host fades as we run this final step.
41876 @@ -295,13 +309,12 @@ deliver_to_host:
41877 // I consulted gcc, and it gave
41878 // These instructions, which I gladly credit:
41879 leal (%edx,%ebx,8), %eax
41880 - movzwl (%eax),%edx
41881 - movl 4(%eax), %eax
41882 - xorw %ax, %ax
41883 - orl %eax, %edx
41884 + movl 4(%eax), %edx
41885 + movw (%eax), %dx
41886 // Now the address of the handler's in %edx
41887 // We call it now: its "iret" drops us home.
41888 - jmp *%edx
41889 + ljmp $__KERNEL_CS, $1f
41890 +1: jmp *%edx
41891
41892 // Every interrupt can come to us here
41893 // But we must truly tell each apart.
41894 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
41895 index 0003992..854bbce 100644
41896 --- a/drivers/md/bcache/closure.h
41897 +++ b/drivers/md/bcache/closure.h
41898 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
41899 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
41900 struct workqueue_struct *wq)
41901 {
41902 - BUG_ON(object_is_on_stack(cl));
41903 + BUG_ON(object_starts_on_stack(cl));
41904 closure_set_ip(cl);
41905 cl->fn = fn;
41906 cl->wq = wq;
41907 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
41908 index 547c4c5..5be1de4 100644
41909 --- a/drivers/md/bcache/super.c
41910 +++ b/drivers/md/bcache/super.c
41911 @@ -1644,7 +1644,7 @@ err_unlock_gc:
41912 err:
41913 closure_sync(&op.cl);
41914 /* XXX: test this, it's broken */
41915 - bch_cache_set_error(c, err);
41916 + bch_cache_set_error(c, "%s", err);
41917 }
41918
41919 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
41920 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
41921 index a7fd821..9dcf6c3 100644
41922 --- a/drivers/md/bitmap.c
41923 +++ b/drivers/md/bitmap.c
41924 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
41925 chunk_kb ? "KB" : "B");
41926 if (bitmap->storage.file) {
41927 seq_printf(seq, ", file: ");
41928 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
41929 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
41930 }
41931
41932 seq_printf(seq, "\n");
41933 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
41934 index f1b7586..a49c4bd 100644
41935 --- a/drivers/md/dm-ioctl.c
41936 +++ b/drivers/md/dm-ioctl.c
41937 @@ -1739,7 +1739,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
41938 cmd == DM_LIST_VERSIONS_CMD)
41939 return 0;
41940
41941 - if ((cmd == DM_DEV_CREATE_CMD)) {
41942 + if (cmd == DM_DEV_CREATE_CMD) {
41943 if (!*param->name) {
41944 DMWARN("name not supplied when creating device");
41945 return -EINVAL;
41946 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
41947 index 699b5be..eac0a15 100644
41948 --- a/drivers/md/dm-raid1.c
41949 +++ b/drivers/md/dm-raid1.c
41950 @@ -40,7 +40,7 @@ enum dm_raid1_error {
41951
41952 struct mirror {
41953 struct mirror_set *ms;
41954 - atomic_t error_count;
41955 + atomic_unchecked_t error_count;
41956 unsigned long error_type;
41957 struct dm_dev *dev;
41958 sector_t offset;
41959 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
41960 struct mirror *m;
41961
41962 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
41963 - if (!atomic_read(&m->error_count))
41964 + if (!atomic_read_unchecked(&m->error_count))
41965 return m;
41966
41967 return NULL;
41968 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
41969 * simple way to tell if a device has encountered
41970 * errors.
41971 */
41972 - atomic_inc(&m->error_count);
41973 + atomic_inc_unchecked(&m->error_count);
41974
41975 if (test_and_set_bit(error_type, &m->error_type))
41976 return;
41977 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
41978 struct mirror *m = get_default_mirror(ms);
41979
41980 do {
41981 - if (likely(!atomic_read(&m->error_count)))
41982 + if (likely(!atomic_read_unchecked(&m->error_count)))
41983 return m;
41984
41985 if (m-- == ms->mirror)
41986 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
41987 {
41988 struct mirror *default_mirror = get_default_mirror(m->ms);
41989
41990 - return !atomic_read(&default_mirror->error_count);
41991 + return !atomic_read_unchecked(&default_mirror->error_count);
41992 }
41993
41994 static int mirror_available(struct mirror_set *ms, struct bio *bio)
41995 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
41996 */
41997 if (likely(region_in_sync(ms, region, 1)))
41998 m = choose_mirror(ms, bio->bi_sector);
41999 - else if (m && atomic_read(&m->error_count))
42000 + else if (m && atomic_read_unchecked(&m->error_count))
42001 m = NULL;
42002
42003 if (likely(m))
42004 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42005 }
42006
42007 ms->mirror[mirror].ms = ms;
42008 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42009 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42010 ms->mirror[mirror].error_type = 0;
42011 ms->mirror[mirror].offset = offset;
42012
42013 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42014 */
42015 static char device_status_char(struct mirror *m)
42016 {
42017 - if (!atomic_read(&(m->error_count)))
42018 + if (!atomic_read_unchecked(&(m->error_count)))
42019 return 'A';
42020
42021 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42022 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42023 index d907ca6..cfb8384 100644
42024 --- a/drivers/md/dm-stripe.c
42025 +++ b/drivers/md/dm-stripe.c
42026 @@ -20,7 +20,7 @@ struct stripe {
42027 struct dm_dev *dev;
42028 sector_t physical_start;
42029
42030 - atomic_t error_count;
42031 + atomic_unchecked_t error_count;
42032 };
42033
42034 struct stripe_c {
42035 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42036 kfree(sc);
42037 return r;
42038 }
42039 - atomic_set(&(sc->stripe[i].error_count), 0);
42040 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42041 }
42042
42043 ti->private = sc;
42044 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42045 DMEMIT("%d ", sc->stripes);
42046 for (i = 0; i < sc->stripes; i++) {
42047 DMEMIT("%s ", sc->stripe[i].dev->name);
42048 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42049 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42050 'D' : 'A';
42051 }
42052 buffer[i] = '\0';
42053 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42054 */
42055 for (i = 0; i < sc->stripes; i++)
42056 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42057 - atomic_inc(&(sc->stripe[i].error_count));
42058 - if (atomic_read(&(sc->stripe[i].error_count)) <
42059 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42060 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42061 DM_IO_ERROR_THRESHOLD)
42062 schedule_work(&sc->trigger_event);
42063 }
42064 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42065 index f221812..6cfda2f 100644
42066 --- a/drivers/md/dm-table.c
42067 +++ b/drivers/md/dm-table.c
42068 @@ -286,7 +286,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
42069 static int open_dev(struct dm_dev_internal *d, dev_t dev,
42070 struct mapped_device *md)
42071 {
42072 - static char *_claim_ptr = "I belong to device-mapper";
42073 + static char _claim_ptr[] = "I belong to device-mapper";
42074 struct block_device *bdev;
42075
42076 int r;
42077 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42078 if (!dev_size)
42079 return 0;
42080
42081 - if ((start >= dev_size) || (start + len > dev_size)) {
42082 + if ((start >= dev_size) || (len > dev_size - start)) {
42083 DMWARN("%s: %s too small for target: "
42084 "start=%llu, len=%llu, dev_size=%llu",
42085 dm_device_name(ti->table->md), bdevname(bdev, b),
42086 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42087 index 60bce43..9b997d0 100644
42088 --- a/drivers/md/dm-thin-metadata.c
42089 +++ b/drivers/md/dm-thin-metadata.c
42090 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42091 {
42092 pmd->info.tm = pmd->tm;
42093 pmd->info.levels = 2;
42094 - pmd->info.value_type.context = pmd->data_sm;
42095 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42096 pmd->info.value_type.size = sizeof(__le64);
42097 pmd->info.value_type.inc = data_block_inc;
42098 pmd->info.value_type.dec = data_block_dec;
42099 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42100
42101 pmd->bl_info.tm = pmd->tm;
42102 pmd->bl_info.levels = 1;
42103 - pmd->bl_info.value_type.context = pmd->data_sm;
42104 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42105 pmd->bl_info.value_type.size = sizeof(__le64);
42106 pmd->bl_info.value_type.inc = data_block_inc;
42107 pmd->bl_info.value_type.dec = data_block_dec;
42108 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42109 index 995e1fc..2468cec 100644
42110 --- a/drivers/md/dm.c
42111 +++ b/drivers/md/dm.c
42112 @@ -178,9 +178,9 @@ struct mapped_device {
42113 /*
42114 * Event handling.
42115 */
42116 - atomic_t event_nr;
42117 + atomic_unchecked_t event_nr;
42118 wait_queue_head_t eventq;
42119 - atomic_t uevent_seq;
42120 + atomic_unchecked_t uevent_seq;
42121 struct list_head uevent_list;
42122 spinlock_t uevent_lock; /* Protect access to uevent_list */
42123
42124 @@ -1916,8 +1916,8 @@ static struct mapped_device *alloc_dev(int minor)
42125 spin_lock_init(&md->deferred_lock);
42126 atomic_set(&md->holders, 1);
42127 atomic_set(&md->open_count, 0);
42128 - atomic_set(&md->event_nr, 0);
42129 - atomic_set(&md->uevent_seq, 0);
42130 + atomic_set_unchecked(&md->event_nr, 0);
42131 + atomic_set_unchecked(&md->uevent_seq, 0);
42132 INIT_LIST_HEAD(&md->uevent_list);
42133 spin_lock_init(&md->uevent_lock);
42134
42135 @@ -2068,7 +2068,7 @@ static void event_callback(void *context)
42136
42137 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42138
42139 - atomic_inc(&md->event_nr);
42140 + atomic_inc_unchecked(&md->event_nr);
42141 wake_up(&md->eventq);
42142 }
42143
42144 @@ -2727,18 +2727,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42145
42146 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42147 {
42148 - return atomic_add_return(1, &md->uevent_seq);
42149 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42150 }
42151
42152 uint32_t dm_get_event_nr(struct mapped_device *md)
42153 {
42154 - return atomic_read(&md->event_nr);
42155 + return atomic_read_unchecked(&md->event_nr);
42156 }
42157
42158 int dm_wait_event(struct mapped_device *md, int event_nr)
42159 {
42160 return wait_event_interruptible(md->eventq,
42161 - (event_nr != atomic_read(&md->event_nr)));
42162 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42163 }
42164
42165 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42166 diff --git a/drivers/md/md.c b/drivers/md/md.c
42167 index 866f489..9bf9ba3 100644
42168 --- a/drivers/md/md.c
42169 +++ b/drivers/md/md.c
42170 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42171 * start build, activate spare
42172 */
42173 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42174 -static atomic_t md_event_count;
42175 +static atomic_unchecked_t md_event_count;
42176 void md_new_event(struct mddev *mddev)
42177 {
42178 - atomic_inc(&md_event_count);
42179 + atomic_inc_unchecked(&md_event_count);
42180 wake_up(&md_event_waiters);
42181 }
42182 EXPORT_SYMBOL_GPL(md_new_event);
42183 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42184 */
42185 static void md_new_event_inintr(struct mddev *mddev)
42186 {
42187 - atomic_inc(&md_event_count);
42188 + atomic_inc_unchecked(&md_event_count);
42189 wake_up(&md_event_waiters);
42190 }
42191
42192 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42193 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42194 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42195 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42196 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42197 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42198
42199 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42200 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42201 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42202 else
42203 sb->resync_offset = cpu_to_le64(0);
42204
42205 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42206 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42207
42208 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42209 sb->size = cpu_to_le64(mddev->dev_sectors);
42210 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42211 static ssize_t
42212 errors_show(struct md_rdev *rdev, char *page)
42213 {
42214 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42215 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42216 }
42217
42218 static ssize_t
42219 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42220 char *e;
42221 unsigned long n = simple_strtoul(buf, &e, 10);
42222 if (*buf && (*e == 0 || *e == '\n')) {
42223 - atomic_set(&rdev->corrected_errors, n);
42224 + atomic_set_unchecked(&rdev->corrected_errors, n);
42225 return len;
42226 }
42227 return -EINVAL;
42228 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42229 rdev->sb_loaded = 0;
42230 rdev->bb_page = NULL;
42231 atomic_set(&rdev->nr_pending, 0);
42232 - atomic_set(&rdev->read_errors, 0);
42233 - atomic_set(&rdev->corrected_errors, 0);
42234 + atomic_set_unchecked(&rdev->read_errors, 0);
42235 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42236
42237 INIT_LIST_HEAD(&rdev->same_set);
42238 init_waitqueue_head(&rdev->blocked_wait);
42239 @@ -7024,7 +7024,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42240
42241 spin_unlock(&pers_lock);
42242 seq_printf(seq, "\n");
42243 - seq->poll_event = atomic_read(&md_event_count);
42244 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42245 return 0;
42246 }
42247 if (v == (void*)2) {
42248 @@ -7127,7 +7127,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42249 return error;
42250
42251 seq = file->private_data;
42252 - seq->poll_event = atomic_read(&md_event_count);
42253 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42254 return error;
42255 }
42256
42257 @@ -7141,7 +7141,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42258 /* always allow read */
42259 mask = POLLIN | POLLRDNORM;
42260
42261 - if (seq->poll_event != atomic_read(&md_event_count))
42262 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42263 mask |= POLLERR | POLLPRI;
42264 return mask;
42265 }
42266 @@ -7185,7 +7185,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42267 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42268 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42269 (int)part_stat_read(&disk->part0, sectors[1]) -
42270 - atomic_read(&disk->sync_io);
42271 + atomic_read_unchecked(&disk->sync_io);
42272 /* sync IO will cause sync_io to increase before the disk_stats
42273 * as sync_io is counted when a request starts, and
42274 * disk_stats is counted when it completes.
42275 diff --git a/drivers/md/md.h b/drivers/md/md.h
42276 index 20f02c0..fd8c821 100644
42277 --- a/drivers/md/md.h
42278 +++ b/drivers/md/md.h
42279 @@ -94,13 +94,13 @@ struct md_rdev {
42280 * only maintained for arrays that
42281 * support hot removal
42282 */
42283 - atomic_t read_errors; /* number of consecutive read errors that
42284 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42285 * we have tried to ignore.
42286 */
42287 struct timespec last_read_error; /* monotonic time since our
42288 * last read error
42289 */
42290 - atomic_t corrected_errors; /* number of corrected read errors,
42291 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42292 * for reporting to userspace and storing
42293 * in superblock.
42294 */
42295 @@ -442,7 +442,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42296
42297 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42298 {
42299 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42300 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42301 }
42302
42303 struct md_personality
42304 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42305 index 3e6d115..ffecdeb 100644
42306 --- a/drivers/md/persistent-data/dm-space-map.h
42307 +++ b/drivers/md/persistent-data/dm-space-map.h
42308 @@ -71,6 +71,7 @@ struct dm_space_map {
42309 dm_sm_threshold_fn fn,
42310 void *context);
42311 };
42312 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42313
42314 /*----------------------------------------------------------------*/
42315
42316 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42317 index aacf6bf..67d63f2 100644
42318 --- a/drivers/md/raid1.c
42319 +++ b/drivers/md/raid1.c
42320 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42321 if (r1_sync_page_io(rdev, sect, s,
42322 bio->bi_io_vec[idx].bv_page,
42323 READ) != 0)
42324 - atomic_add(s, &rdev->corrected_errors);
42325 + atomic_add_unchecked(s, &rdev->corrected_errors);
42326 }
42327 sectors -= s;
42328 sect += s;
42329 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42330 test_bit(In_sync, &rdev->flags)) {
42331 if (r1_sync_page_io(rdev, sect, s,
42332 conf->tmppage, READ)) {
42333 - atomic_add(s, &rdev->corrected_errors);
42334 + atomic_add_unchecked(s, &rdev->corrected_errors);
42335 printk(KERN_INFO
42336 "md/raid1:%s: read error corrected "
42337 "(%d sectors at %llu on %s)\n",
42338 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42339 index 73dc8a3..bdd515a 100644
42340 --- a/drivers/md/raid10.c
42341 +++ b/drivers/md/raid10.c
42342 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
42343 /* The write handler will notice the lack of
42344 * R10BIO_Uptodate and record any errors etc
42345 */
42346 - atomic_add(r10_bio->sectors,
42347 + atomic_add_unchecked(r10_bio->sectors,
42348 &conf->mirrors[d].rdev->corrected_errors);
42349
42350 /* for reconstruct, we always reschedule after a read.
42351 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42352 {
42353 struct timespec cur_time_mon;
42354 unsigned long hours_since_last;
42355 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42356 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42357
42358 ktime_get_ts(&cur_time_mon);
42359
42360 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42361 * overflowing the shift of read_errors by hours_since_last.
42362 */
42363 if (hours_since_last >= 8 * sizeof(read_errors))
42364 - atomic_set(&rdev->read_errors, 0);
42365 + atomic_set_unchecked(&rdev->read_errors, 0);
42366 else
42367 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42368 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42369 }
42370
42371 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42372 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42373 return;
42374
42375 check_decay_read_errors(mddev, rdev);
42376 - atomic_inc(&rdev->read_errors);
42377 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42378 + atomic_inc_unchecked(&rdev->read_errors);
42379 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42380 char b[BDEVNAME_SIZE];
42381 bdevname(rdev->bdev, b);
42382
42383 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42384 "md/raid10:%s: %s: Raid device exceeded "
42385 "read_error threshold [cur %d:max %d]\n",
42386 mdname(mddev), b,
42387 - atomic_read(&rdev->read_errors), max_read_errors);
42388 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42389 printk(KERN_NOTICE
42390 "md/raid10:%s: %s: Failing raid device\n",
42391 mdname(mddev), b);
42392 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42393 sect +
42394 choose_data_offset(r10_bio, rdev)),
42395 bdevname(rdev->bdev, b));
42396 - atomic_add(s, &rdev->corrected_errors);
42397 + atomic_add_unchecked(s, &rdev->corrected_errors);
42398 }
42399
42400 rdev_dec_pending(rdev, mddev);
42401 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42402 index d825059..d5e4ec7 100644
42403 --- a/drivers/md/raid5.c
42404 +++ b/drivers/md/raid5.c
42405 @@ -1776,21 +1776,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42406 mdname(conf->mddev), STRIPE_SECTORS,
42407 (unsigned long long)s,
42408 bdevname(rdev->bdev, b));
42409 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42410 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42411 clear_bit(R5_ReadError, &sh->dev[i].flags);
42412 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42413 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42414 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42415
42416 - if (atomic_read(&rdev->read_errors))
42417 - atomic_set(&rdev->read_errors, 0);
42418 + if (atomic_read_unchecked(&rdev->read_errors))
42419 + atomic_set_unchecked(&rdev->read_errors, 0);
42420 } else {
42421 const char *bdn = bdevname(rdev->bdev, b);
42422 int retry = 0;
42423 int set_bad = 0;
42424
42425 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42426 - atomic_inc(&rdev->read_errors);
42427 + atomic_inc_unchecked(&rdev->read_errors);
42428 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42429 printk_ratelimited(
42430 KERN_WARNING
42431 @@ -1818,7 +1818,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42432 mdname(conf->mddev),
42433 (unsigned long long)s,
42434 bdn);
42435 - } else if (atomic_read(&rdev->read_errors)
42436 + } else if (atomic_read_unchecked(&rdev->read_errors)
42437 > conf->max_nr_stripes)
42438 printk(KERN_WARNING
42439 "md/raid:%s: Too many read errors, failing device %s.\n",
42440 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42441 index 401ef64..836e563 100644
42442 --- a/drivers/media/dvb-core/dvbdev.c
42443 +++ b/drivers/media/dvb-core/dvbdev.c
42444 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42445 const struct dvb_device *template, void *priv, int type)
42446 {
42447 struct dvb_device *dvbdev;
42448 - struct file_operations *dvbdevfops;
42449 + file_operations_no_const *dvbdevfops;
42450 struct device *clsdev;
42451 int minor;
42452 int id;
42453 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42454 index 9b6c3bb..baeb5c7 100644
42455 --- a/drivers/media/dvb-frontends/dib3000.h
42456 +++ b/drivers/media/dvb-frontends/dib3000.h
42457 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42458 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42459 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42460 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42461 -};
42462 +} __no_const;
42463
42464 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42465 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42466 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42467 index ecf21d9..b992428d 100644
42468 --- a/drivers/media/pci/cx88/cx88-video.c
42469 +++ b/drivers/media/pci/cx88/cx88-video.c
42470 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42471
42472 /* ------------------------------------------------------------------ */
42473
42474 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42475 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42476 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42477 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42478 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42479 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42480
42481 module_param_array(video_nr, int, NULL, 0444);
42482 module_param_array(vbi_nr, int, NULL, 0444);
42483 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42484 index c08ae3e..eb59af1 100644
42485 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42486 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42487 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42488 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42489
42490 /* ivtv instance counter */
42491 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42492 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42493
42494 /* Parameter declarations */
42495 static int cardtype[IVTV_MAX_CARDS];
42496 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42497 index dfd0a21..6bbb465 100644
42498 --- a/drivers/media/platform/omap/omap_vout.c
42499 +++ b/drivers/media/platform/omap/omap_vout.c
42500 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42501 OMAP_VIDEO2,
42502 };
42503
42504 -static struct videobuf_queue_ops video_vbq_ops;
42505 /* Variables configurable through module params*/
42506 static u32 video1_numbuffers = 3;
42507 static u32 video2_numbuffers = 3;
42508 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42509 {
42510 struct videobuf_queue *q;
42511 struct omap_vout_device *vout = NULL;
42512 + static struct videobuf_queue_ops video_vbq_ops = {
42513 + .buf_setup = omap_vout_buffer_setup,
42514 + .buf_prepare = omap_vout_buffer_prepare,
42515 + .buf_release = omap_vout_buffer_release,
42516 + .buf_queue = omap_vout_buffer_queue,
42517 + };
42518
42519 vout = video_drvdata(file);
42520 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42521 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42522 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42523
42524 q = &vout->vbq;
42525 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42526 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42527 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42528 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42529 spin_lock_init(&vout->vbq_lock);
42530
42531 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42532 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42533 index 04e6490..2df65bf 100644
42534 --- a/drivers/media/platform/s5p-tv/mixer.h
42535 +++ b/drivers/media/platform/s5p-tv/mixer.h
42536 @@ -156,7 +156,7 @@ struct mxr_layer {
42537 /** layer index (unique identifier) */
42538 int idx;
42539 /** callbacks for layer methods */
42540 - struct mxr_layer_ops ops;
42541 + struct mxr_layer_ops *ops;
42542 /** format array */
42543 const struct mxr_format **fmt_array;
42544 /** size of format array */
42545 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42546 index b93a21f..2535195 100644
42547 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42548 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42549 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42550 {
42551 struct mxr_layer *layer;
42552 int ret;
42553 - struct mxr_layer_ops ops = {
42554 + static struct mxr_layer_ops ops = {
42555 .release = mxr_graph_layer_release,
42556 .buffer_set = mxr_graph_buffer_set,
42557 .stream_set = mxr_graph_stream_set,
42558 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42559 index b713403..53cb5ad 100644
42560 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42561 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42562 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42563 layer->update_buf = next;
42564 }
42565
42566 - layer->ops.buffer_set(layer, layer->update_buf);
42567 + layer->ops->buffer_set(layer, layer->update_buf);
42568
42569 if (done && done != layer->shadow_buf)
42570 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42571 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42572 index 641b1f0..49cff30 100644
42573 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42574 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42575 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42576 layer->geo.src.height = layer->geo.src.full_height;
42577
42578 mxr_geometry_dump(mdev, &layer->geo);
42579 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42580 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42581 mxr_geometry_dump(mdev, &layer->geo);
42582 }
42583
42584 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42585 layer->geo.dst.full_width = mbus_fmt.width;
42586 layer->geo.dst.full_height = mbus_fmt.height;
42587 layer->geo.dst.field = mbus_fmt.field;
42588 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42589 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42590
42591 mxr_geometry_dump(mdev, &layer->geo);
42592 }
42593 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42594 /* set source size to highest accepted value */
42595 geo->src.full_width = max(geo->dst.full_width, pix->width);
42596 geo->src.full_height = max(geo->dst.full_height, pix->height);
42597 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42598 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42599 mxr_geometry_dump(mdev, &layer->geo);
42600 /* set cropping to total visible screen */
42601 geo->src.width = pix->width;
42602 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42603 geo->src.x_offset = 0;
42604 geo->src.y_offset = 0;
42605 /* assure consistency of geometry */
42606 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42607 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42608 mxr_geometry_dump(mdev, &layer->geo);
42609 /* set full size to lowest possible value */
42610 geo->src.full_width = 0;
42611 geo->src.full_height = 0;
42612 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42613 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42614 mxr_geometry_dump(mdev, &layer->geo);
42615
42616 /* returning results */
42617 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42618 target->width = s->r.width;
42619 target->height = s->r.height;
42620
42621 - layer->ops.fix_geometry(layer, stage, s->flags);
42622 + layer->ops->fix_geometry(layer, stage, s->flags);
42623
42624 /* retrieve update selection rectangle */
42625 res.left = target->x_offset;
42626 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42627 mxr_output_get(mdev);
42628
42629 mxr_layer_update_output(layer);
42630 - layer->ops.format_set(layer);
42631 + layer->ops->format_set(layer);
42632 /* enabling layer in hardware */
42633 spin_lock_irqsave(&layer->enq_slock, flags);
42634 layer->state = MXR_LAYER_STREAMING;
42635 spin_unlock_irqrestore(&layer->enq_slock, flags);
42636
42637 - layer->ops.stream_set(layer, MXR_ENABLE);
42638 + layer->ops->stream_set(layer, MXR_ENABLE);
42639 mxr_streamer_get(mdev);
42640
42641 return 0;
42642 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42643 spin_unlock_irqrestore(&layer->enq_slock, flags);
42644
42645 /* disabling layer in hardware */
42646 - layer->ops.stream_set(layer, MXR_DISABLE);
42647 + layer->ops->stream_set(layer, MXR_DISABLE);
42648 /* remove one streamer */
42649 mxr_streamer_put(mdev);
42650 /* allow changes in output configuration */
42651 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42652
42653 void mxr_layer_release(struct mxr_layer *layer)
42654 {
42655 - if (layer->ops.release)
42656 - layer->ops.release(layer);
42657 + if (layer->ops->release)
42658 + layer->ops->release(layer);
42659 }
42660
42661 void mxr_base_layer_release(struct mxr_layer *layer)
42662 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42663
42664 layer->mdev = mdev;
42665 layer->idx = idx;
42666 - layer->ops = *ops;
42667 + layer->ops = ops;
42668
42669 spin_lock_init(&layer->enq_slock);
42670 INIT_LIST_HEAD(&layer->enq_list);
42671 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42672 index 3d13a63..da31bf1 100644
42673 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42674 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42675 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42676 {
42677 struct mxr_layer *layer;
42678 int ret;
42679 - struct mxr_layer_ops ops = {
42680 + static struct mxr_layer_ops ops = {
42681 .release = mxr_vp_layer_release,
42682 .buffer_set = mxr_vp_buffer_set,
42683 .stream_set = mxr_vp_stream_set,
42684 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42685 index 545c04c..a14bded 100644
42686 --- a/drivers/media/radio/radio-cadet.c
42687 +++ b/drivers/media/radio/radio-cadet.c
42688 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42689 unsigned char readbuf[RDS_BUFFER];
42690 int i = 0;
42691
42692 + if (count > RDS_BUFFER)
42693 + return -EFAULT;
42694 mutex_lock(&dev->lock);
42695 if (dev->rdsstat == 0)
42696 cadet_start_rds(dev);
42697 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42698 while (i < count && dev->rdsin != dev->rdsout)
42699 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42700
42701 - if (i && copy_to_user(data, readbuf, i))
42702 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42703 i = -EFAULT;
42704 unlock:
42705 mutex_unlock(&dev->lock);
42706 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42707 index bd4d3a7..ffc0b9d 100644
42708 --- a/drivers/media/radio/radio-maxiradio.c
42709 +++ b/drivers/media/radio/radio-maxiradio.c
42710 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42711 /* TEA5757 pin mappings */
42712 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42713
42714 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42715 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42716
42717 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42718 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42719 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42720 index 8fa18ab..caee70f 100644
42721 --- a/drivers/media/radio/radio-shark.c
42722 +++ b/drivers/media/radio/radio-shark.c
42723 @@ -79,7 +79,7 @@ struct shark_device {
42724 u32 last_val;
42725 };
42726
42727 -static atomic_t shark_instance = ATOMIC_INIT(0);
42728 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42729
42730 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42731 {
42732 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42733 index 9fb6697..f167415 100644
42734 --- a/drivers/media/radio/radio-shark2.c
42735 +++ b/drivers/media/radio/radio-shark2.c
42736 @@ -74,7 +74,7 @@ struct shark_device {
42737 u8 *transfer_buffer;
42738 };
42739
42740 -static atomic_t shark_instance = ATOMIC_INIT(0);
42741 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42742
42743 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42744 {
42745 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42746 index 9c9084c..a9e8dfb 100644
42747 --- a/drivers/media/radio/radio-si476x.c
42748 +++ b/drivers/media/radio/radio-si476x.c
42749 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42750 struct si476x_radio *radio;
42751 struct v4l2_ctrl *ctrl;
42752
42753 - static atomic_t instance = ATOMIC_INIT(0);
42754 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42755
42756 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42757 if (!radio)
42758 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42759 index 1cf382a..c22998c 100644
42760 --- a/drivers/media/rc/rc-main.c
42761 +++ b/drivers/media/rc/rc-main.c
42762 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42763 int rc_register_device(struct rc_dev *dev)
42764 {
42765 static bool raw_init = false; /* raw decoders loaded? */
42766 - static atomic_t devno = ATOMIC_INIT(0);
42767 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42768 struct rc_map *rc_map;
42769 const char *path;
42770 int rc;
42771 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
42772 */
42773 mutex_lock(&dev->lock);
42774
42775 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42776 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42777 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42778 dev_set_drvdata(&dev->dev, dev);
42779 rc = device_add(&dev->dev);
42780 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42781 index 3940bb0..fb3952a 100644
42782 --- a/drivers/media/usb/dvb-usb/cxusb.c
42783 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42784 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42785
42786 struct dib0700_adapter_state {
42787 int (*set_param_save) (struct dvb_frontend *);
42788 -};
42789 +} __no_const;
42790
42791 static int dib7070_set_param_override(struct dvb_frontend *fe)
42792 {
42793 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42794 index 6e237b6..dc25556 100644
42795 --- a/drivers/media/usb/dvb-usb/dw2102.c
42796 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42797 @@ -118,7 +118,7 @@ struct su3000_state {
42798
42799 struct s6x0_state {
42800 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42801 -};
42802 +} __no_const;
42803
42804 /* debug */
42805 static int dvb_usb_dw2102_debug;
42806 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42807 index 8f7a6a4..59502dd 100644
42808 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42809 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42810 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
42811 __u32 reserved;
42812 };
42813
42814 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42815 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42816 enum v4l2_memory memory)
42817 {
42818 void __user *up_pln;
42819 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42820 return 0;
42821 }
42822
42823 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42824 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42825 enum v4l2_memory memory)
42826 {
42827 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
42828 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
42829 put_user(kp->start_block, &up->start_block) ||
42830 put_user(kp->blocks, &up->blocks) ||
42831 put_user(tmp, &up->edid) ||
42832 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
42833 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
42834 return -EFAULT;
42835 return 0;
42836 }
42837 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
42838 index 02d1b63..5fd6b16 100644
42839 --- a/drivers/media/v4l2-core/v4l2-device.c
42840 +++ b/drivers/media/v4l2-core/v4l2-device.c
42841 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
42842 EXPORT_SYMBOL_GPL(v4l2_device_put);
42843
42844 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
42845 - atomic_t *instance)
42846 + atomic_unchecked_t *instance)
42847 {
42848 - int num = atomic_inc_return(instance) - 1;
42849 + int num = atomic_inc_return_unchecked(instance) - 1;
42850 int len = strlen(basename);
42851
42852 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
42853 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
42854 index 68e6b5e..d8b923e 100644
42855 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
42856 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
42857 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
42858 struct file *file, void *fh, void *p);
42859 } u;
42860 void (*debug)(const void *arg, bool write_only);
42861 -};
42862 +} __do_const;
42863 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
42864
42865 /* This control needs a priority check */
42866 #define INFO_FL_PRIO (1 << 0)
42867 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
42868 struct video_device *vfd = video_devdata(file);
42869 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
42870 bool write_only = false;
42871 - struct v4l2_ioctl_info default_info;
42872 + v4l2_ioctl_info_no_const default_info;
42873 const struct v4l2_ioctl_info *info;
42874 void *fh = file->private_data;
42875 struct v4l2_fh *vfh = NULL;
42876 @@ -2194,7 +2195,7 @@ done:
42877 }
42878
42879 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42880 - void * __user *user_ptr, void ***kernel_ptr)
42881 + void __user **user_ptr, void ***kernel_ptr)
42882 {
42883 int ret = 0;
42884
42885 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42886 ret = -EINVAL;
42887 break;
42888 }
42889 - *user_ptr = (void __user *)buf->m.planes;
42890 + *user_ptr = (void __force_user *)buf->m.planes;
42891 *kernel_ptr = (void *)&buf->m.planes;
42892 *array_size = sizeof(struct v4l2_plane) * buf->length;
42893 ret = 1;
42894 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42895 ret = -EINVAL;
42896 break;
42897 }
42898 - *user_ptr = (void __user *)ctrls->controls;
42899 + *user_ptr = (void __force_user *)ctrls->controls;
42900 *kernel_ptr = (void *)&ctrls->controls;
42901 *array_size = sizeof(struct v4l2_ext_control)
42902 * ctrls->count;
42903 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
42904 index 767ff4d..c69d259 100644
42905 --- a/drivers/message/fusion/mptbase.c
42906 +++ b/drivers/message/fusion/mptbase.c
42907 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42908 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
42909 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
42910
42911 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42912 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
42913 +#else
42914 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
42915 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
42916 +#endif
42917 +
42918 /*
42919 * Rounding UP to nearest 4-kB boundary here...
42920 */
42921 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42922 ioc->facts.GlobalCredits);
42923
42924 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
42925 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42926 + NULL, NULL);
42927 +#else
42928 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
42929 +#endif
42930 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
42931 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
42932 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
42933 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
42934 index dd239bd..689c4f7 100644
42935 --- a/drivers/message/fusion/mptsas.c
42936 +++ b/drivers/message/fusion/mptsas.c
42937 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
42938 return 0;
42939 }
42940
42941 +static inline void
42942 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42943 +{
42944 + if (phy_info->port_details) {
42945 + phy_info->port_details->rphy = rphy;
42946 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42947 + ioc->name, rphy));
42948 + }
42949 +
42950 + if (rphy) {
42951 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42952 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42953 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42954 + ioc->name, rphy, rphy->dev.release));
42955 + }
42956 +}
42957 +
42958 /* no mutex */
42959 static void
42960 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
42961 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
42962 return NULL;
42963 }
42964
42965 -static inline void
42966 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42967 -{
42968 - if (phy_info->port_details) {
42969 - phy_info->port_details->rphy = rphy;
42970 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42971 - ioc->name, rphy));
42972 - }
42973 -
42974 - if (rphy) {
42975 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42976 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42977 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42978 - ioc->name, rphy, rphy->dev.release));
42979 - }
42980 -}
42981 -
42982 static inline struct sas_port *
42983 mptsas_get_port(struct mptsas_phyinfo *phy_info)
42984 {
42985 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
42986 index 727819c..ad74694 100644
42987 --- a/drivers/message/fusion/mptscsih.c
42988 +++ b/drivers/message/fusion/mptscsih.c
42989 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
42990
42991 h = shost_priv(SChost);
42992
42993 - if (h) {
42994 - if (h->info_kbuf == NULL)
42995 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42996 - return h->info_kbuf;
42997 - h->info_kbuf[0] = '\0';
42998 + if (!h)
42999 + return NULL;
43000
43001 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43002 - h->info_kbuf[size-1] = '\0';
43003 - }
43004 + if (h->info_kbuf == NULL)
43005 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43006 + return h->info_kbuf;
43007 + h->info_kbuf[0] = '\0';
43008 +
43009 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43010 + h->info_kbuf[size-1] = '\0';
43011
43012 return h->info_kbuf;
43013 }
43014 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43015 index b7d87cd..3fb36da 100644
43016 --- a/drivers/message/i2o/i2o_proc.c
43017 +++ b/drivers/message/i2o/i2o_proc.c
43018 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43019 "Array Controller Device"
43020 };
43021
43022 -static char *chtostr(char *tmp, u8 *chars, int n)
43023 -{
43024 - tmp[0] = 0;
43025 - return strncat(tmp, (char *)chars, n);
43026 -}
43027 -
43028 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43029 char *group)
43030 {
43031 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
43032 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
43033 {
43034 struct i2o_controller *c = (struct i2o_controller *)seq->private;
43035 - static u32 work32[5];
43036 - static u8 *work8 = (u8 *) work32;
43037 - static u16 *work16 = (u16 *) work32;
43038 + u32 work32[5];
43039 + u8 *work8 = (u8 *) work32;
43040 + u16 *work16 = (u16 *) work32;
43041 int token;
43042 u32 hwcap;
43043
43044 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43045 } *result;
43046
43047 i2o_exec_execute_ddm_table ddm_table;
43048 - char tmp[28 + 1];
43049
43050 result = kmalloc(sizeof(*result), GFP_KERNEL);
43051 if (!result)
43052 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43053
43054 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43055 seq_printf(seq, "%-#8x", ddm_table.module_id);
43056 - seq_printf(seq, "%-29s",
43057 - chtostr(tmp, ddm_table.module_name_version, 28));
43058 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43059 seq_printf(seq, "%9d ", ddm_table.data_size);
43060 seq_printf(seq, "%8d", ddm_table.code_size);
43061
43062 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43063
43064 i2o_driver_result_table *result;
43065 i2o_driver_store_table *dst;
43066 - char tmp[28 + 1];
43067
43068 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43069 if (result == NULL)
43070 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43071
43072 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43073 seq_printf(seq, "%-#8x", dst->module_id);
43074 - seq_printf(seq, "%-29s",
43075 - chtostr(tmp, dst->module_name_version, 28));
43076 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43077 + seq_printf(seq, "%-.28s", dst->module_name_version);
43078 + seq_printf(seq, "%-.8s", dst->date);
43079 seq_printf(seq, "%8d ", dst->module_size);
43080 seq_printf(seq, "%8d ", dst->mpb_size);
43081 seq_printf(seq, "0x%04x", dst->module_flags);
43082 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
43083 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43084 {
43085 struct i2o_device *d = (struct i2o_device *)seq->private;
43086 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43087 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43088 // == (allow) 512d bytes (max)
43089 - static u16 *work16 = (u16 *) work32;
43090 + u16 *work16 = (u16 *) work32;
43091 int token;
43092 - char tmp[16 + 1];
43093
43094 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43095
43096 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43097 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43098 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43099 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43100 - seq_printf(seq, "Vendor info : %s\n",
43101 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43102 - seq_printf(seq, "Product info : %s\n",
43103 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43104 - seq_printf(seq, "Description : %s\n",
43105 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43106 - seq_printf(seq, "Product rev. : %s\n",
43107 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43108 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43109 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43110 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43111 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43112
43113 seq_printf(seq, "Serial number : ");
43114 print_serial_number(seq, (u8 *) (work32 + 16),
43115 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43116 u8 pad[256]; // allow up to 256 byte (max) serial number
43117 } result;
43118
43119 - char tmp[24 + 1];
43120 -
43121 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43122
43123 if (token < 0) {
43124 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43125 }
43126
43127 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43128 - seq_printf(seq, "Module name : %s\n",
43129 - chtostr(tmp, result.module_name, 24));
43130 - seq_printf(seq, "Module revision : %s\n",
43131 - chtostr(tmp, result.module_rev, 8));
43132 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43133 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43134
43135 seq_printf(seq, "Serial number : ");
43136 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43137 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43138 u8 instance_number[4];
43139 } result;
43140
43141 - char tmp[64 + 1];
43142 -
43143 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43144
43145 if (token < 0) {
43146 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43147 return 0;
43148 }
43149
43150 - seq_printf(seq, "Device name : %s\n",
43151 - chtostr(tmp, result.device_name, 64));
43152 - seq_printf(seq, "Service name : %s\n",
43153 - chtostr(tmp, result.service_name, 64));
43154 - seq_printf(seq, "Physical name : %s\n",
43155 - chtostr(tmp, result.physical_location, 64));
43156 - seq_printf(seq, "Instance number : %s\n",
43157 - chtostr(tmp, result.instance_number, 4));
43158 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43159 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43160 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43161 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43162
43163 return 0;
43164 }
43165 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43166 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
43167 {
43168 struct i2o_device *d = (struct i2o_device *)seq->private;
43169 - static u32 work32[12];
43170 - static u16 *work16 = (u16 *) work32;
43171 - static u8 *work8 = (u8 *) work32;
43172 + u32 work32[12];
43173 + u16 *work16 = (u16 *) work32;
43174 + u8 *work8 = (u8 *) work32;
43175 int token;
43176
43177 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
43178 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43179 index a8c08f3..155fe3d 100644
43180 --- a/drivers/message/i2o/iop.c
43181 +++ b/drivers/message/i2o/iop.c
43182 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43183
43184 spin_lock_irqsave(&c->context_list_lock, flags);
43185
43186 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43187 - atomic_inc(&c->context_list_counter);
43188 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43189 + atomic_inc_unchecked(&c->context_list_counter);
43190
43191 - entry->context = atomic_read(&c->context_list_counter);
43192 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43193
43194 list_add(&entry->list, &c->context_list);
43195
43196 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43197
43198 #if BITS_PER_LONG == 64
43199 spin_lock_init(&c->context_list_lock);
43200 - atomic_set(&c->context_list_counter, 0);
43201 + atomic_set_unchecked(&c->context_list_counter, 0);
43202 INIT_LIST_HEAD(&c->context_list);
43203 #endif
43204
43205 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43206 index fcbb2e9..2635e11 100644
43207 --- a/drivers/mfd/janz-cmodio.c
43208 +++ b/drivers/mfd/janz-cmodio.c
43209 @@ -13,6 +13,7 @@
43210
43211 #include <linux/kernel.h>
43212 #include <linux/module.h>
43213 +#include <linux/slab.h>
43214 #include <linux/init.h>
43215 #include <linux/pci.h>
43216 #include <linux/interrupt.h>
43217 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
43218 index 8042b32..cba3166 100644
43219 --- a/drivers/mfd/max8925-i2c.c
43220 +++ b/drivers/mfd/max8925-i2c.c
43221 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
43222 const struct i2c_device_id *id)
43223 {
43224 struct max8925_platform_data *pdata = client->dev.platform_data;
43225 - static struct max8925_chip *chip;
43226 + struct max8925_chip *chip;
43227 struct device_node *node = client->dev.of_node;
43228
43229 if (node && !pdata) {
43230 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
43231 index d792772..cd73ba3 100644
43232 --- a/drivers/mfd/tps65910.c
43233 +++ b/drivers/mfd/tps65910.c
43234 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
43235 struct tps65910_platform_data *pdata)
43236 {
43237 int ret = 0;
43238 - static struct regmap_irq_chip *tps6591x_irqs_chip;
43239 + struct regmap_irq_chip *tps6591x_irqs_chip;
43240
43241 if (!irq) {
43242 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
43243 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43244 index 9aa6d1e..1631bfc 100644
43245 --- a/drivers/mfd/twl4030-irq.c
43246 +++ b/drivers/mfd/twl4030-irq.c
43247 @@ -35,6 +35,7 @@
43248 #include <linux/of.h>
43249 #include <linux/irqdomain.h>
43250 #include <linux/i2c/twl.h>
43251 +#include <asm/pgtable.h>
43252
43253 #include "twl-core.h"
43254
43255 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43256 * Install an irq handler for each of the SIH modules;
43257 * clone dummy irq_chip since PIH can't *do* anything
43258 */
43259 - twl4030_irq_chip = dummy_irq_chip;
43260 - twl4030_irq_chip.name = "twl4030";
43261 + pax_open_kernel();
43262 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43263 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43264
43265 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43266 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43267 + pax_close_kernel();
43268
43269 for (i = irq_base; i < irq_end; i++) {
43270 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43271 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43272 index 277a8db..0e0b754 100644
43273 --- a/drivers/mfd/twl6030-irq.c
43274 +++ b/drivers/mfd/twl6030-irq.c
43275 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43276 * install an irq handler for each of the modules;
43277 * clone dummy irq_chip since PIH can't *do* anything
43278 */
43279 - twl6030_irq_chip = dummy_irq_chip;
43280 - twl6030_irq_chip.name = "twl6030";
43281 - twl6030_irq_chip.irq_set_type = NULL;
43282 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43283 + pax_open_kernel();
43284 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43285 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43286 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43287 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43288 + pax_close_kernel();
43289
43290 for (i = irq_base; i < irq_end; i++) {
43291 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43292 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43293 index f32550a..e3e52a2 100644
43294 --- a/drivers/misc/c2port/core.c
43295 +++ b/drivers/misc/c2port/core.c
43296 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43297 mutex_init(&c2dev->mutex);
43298
43299 /* Create binary file */
43300 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43301 + pax_open_kernel();
43302 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43303 + pax_close_kernel();
43304 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43305 if (unlikely(ret))
43306 goto error_device_create_bin_file;
43307 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43308 index 36f5d52..32311c3 100644
43309 --- a/drivers/misc/kgdbts.c
43310 +++ b/drivers/misc/kgdbts.c
43311 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43312 char before[BREAK_INSTR_SIZE];
43313 char after[BREAK_INSTR_SIZE];
43314
43315 - probe_kernel_read(before, (char *)kgdbts_break_test,
43316 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43317 BREAK_INSTR_SIZE);
43318 init_simple_test();
43319 ts.tst = plant_and_detach_test;
43320 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43321 /* Activate test with initial breakpoint */
43322 if (!is_early)
43323 kgdb_breakpoint();
43324 - probe_kernel_read(after, (char *)kgdbts_break_test,
43325 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43326 BREAK_INSTR_SIZE);
43327 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43328 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43329 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43330 index 036effe..b3a6336 100644
43331 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43332 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43333 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43334 * the lid is closed. This leads to interrupts as soon as a little move
43335 * is done.
43336 */
43337 - atomic_inc(&lis3->count);
43338 + atomic_inc_unchecked(&lis3->count);
43339
43340 wake_up_interruptible(&lis3->misc_wait);
43341 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43342 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43343 if (lis3->pm_dev)
43344 pm_runtime_get_sync(lis3->pm_dev);
43345
43346 - atomic_set(&lis3->count, 0);
43347 + atomic_set_unchecked(&lis3->count, 0);
43348 return 0;
43349 }
43350
43351 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43352 add_wait_queue(&lis3->misc_wait, &wait);
43353 while (true) {
43354 set_current_state(TASK_INTERRUPTIBLE);
43355 - data = atomic_xchg(&lis3->count, 0);
43356 + data = atomic_xchg_unchecked(&lis3->count, 0);
43357 if (data)
43358 break;
43359
43360 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43361 struct lis3lv02d, miscdev);
43362
43363 poll_wait(file, &lis3->misc_wait, wait);
43364 - if (atomic_read(&lis3->count))
43365 + if (atomic_read_unchecked(&lis3->count))
43366 return POLLIN | POLLRDNORM;
43367 return 0;
43368 }
43369 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43370 index c439c82..1f20f57 100644
43371 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43372 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43373 @@ -297,7 +297,7 @@ struct lis3lv02d {
43374 struct input_polled_dev *idev; /* input device */
43375 struct platform_device *pdev; /* platform device */
43376 struct regulator_bulk_data regulators[2];
43377 - atomic_t count; /* interrupt count after last read */
43378 + atomic_unchecked_t count; /* interrupt count after last read */
43379 union axis_conversion ac; /* hw -> logical axis */
43380 int mapped_btns[3];
43381
43382 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43383 index 2f30bad..c4c13d0 100644
43384 --- a/drivers/misc/sgi-gru/gruhandles.c
43385 +++ b/drivers/misc/sgi-gru/gruhandles.c
43386 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43387 unsigned long nsec;
43388
43389 nsec = CLKS2NSEC(clks);
43390 - atomic_long_inc(&mcs_op_statistics[op].count);
43391 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43392 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43393 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43394 if (mcs_op_statistics[op].max < nsec)
43395 mcs_op_statistics[op].max = nsec;
43396 }
43397 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43398 index 4f76359..cdfcb2e 100644
43399 --- a/drivers/misc/sgi-gru/gruprocfs.c
43400 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43401 @@ -32,9 +32,9 @@
43402
43403 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43404
43405 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43406 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43407 {
43408 - unsigned long val = atomic_long_read(v);
43409 + unsigned long val = atomic_long_read_unchecked(v);
43410
43411 seq_printf(s, "%16lu %s\n", val, id);
43412 }
43413 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43414
43415 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43416 for (op = 0; op < mcsop_last; op++) {
43417 - count = atomic_long_read(&mcs_op_statistics[op].count);
43418 - total = atomic_long_read(&mcs_op_statistics[op].total);
43419 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43420 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43421 max = mcs_op_statistics[op].max;
43422 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43423 count ? total / count : 0, max);
43424 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43425 index 5c3ce24..4915ccb 100644
43426 --- a/drivers/misc/sgi-gru/grutables.h
43427 +++ b/drivers/misc/sgi-gru/grutables.h
43428 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43429 * GRU statistics.
43430 */
43431 struct gru_stats_s {
43432 - atomic_long_t vdata_alloc;
43433 - atomic_long_t vdata_free;
43434 - atomic_long_t gts_alloc;
43435 - atomic_long_t gts_free;
43436 - atomic_long_t gms_alloc;
43437 - atomic_long_t gms_free;
43438 - atomic_long_t gts_double_allocate;
43439 - atomic_long_t assign_context;
43440 - atomic_long_t assign_context_failed;
43441 - atomic_long_t free_context;
43442 - atomic_long_t load_user_context;
43443 - atomic_long_t load_kernel_context;
43444 - atomic_long_t lock_kernel_context;
43445 - atomic_long_t unlock_kernel_context;
43446 - atomic_long_t steal_user_context;
43447 - atomic_long_t steal_kernel_context;
43448 - atomic_long_t steal_context_failed;
43449 - atomic_long_t nopfn;
43450 - atomic_long_t asid_new;
43451 - atomic_long_t asid_next;
43452 - atomic_long_t asid_wrap;
43453 - atomic_long_t asid_reuse;
43454 - atomic_long_t intr;
43455 - atomic_long_t intr_cbr;
43456 - atomic_long_t intr_tfh;
43457 - atomic_long_t intr_spurious;
43458 - atomic_long_t intr_mm_lock_failed;
43459 - atomic_long_t call_os;
43460 - atomic_long_t call_os_wait_queue;
43461 - atomic_long_t user_flush_tlb;
43462 - atomic_long_t user_unload_context;
43463 - atomic_long_t user_exception;
43464 - atomic_long_t set_context_option;
43465 - atomic_long_t check_context_retarget_intr;
43466 - atomic_long_t check_context_unload;
43467 - atomic_long_t tlb_dropin;
43468 - atomic_long_t tlb_preload_page;
43469 - atomic_long_t tlb_dropin_fail_no_asid;
43470 - atomic_long_t tlb_dropin_fail_upm;
43471 - atomic_long_t tlb_dropin_fail_invalid;
43472 - atomic_long_t tlb_dropin_fail_range_active;
43473 - atomic_long_t tlb_dropin_fail_idle;
43474 - atomic_long_t tlb_dropin_fail_fmm;
43475 - atomic_long_t tlb_dropin_fail_no_exception;
43476 - atomic_long_t tfh_stale_on_fault;
43477 - atomic_long_t mmu_invalidate_range;
43478 - atomic_long_t mmu_invalidate_page;
43479 - atomic_long_t flush_tlb;
43480 - atomic_long_t flush_tlb_gru;
43481 - atomic_long_t flush_tlb_gru_tgh;
43482 - atomic_long_t flush_tlb_gru_zero_asid;
43483 + atomic_long_unchecked_t vdata_alloc;
43484 + atomic_long_unchecked_t vdata_free;
43485 + atomic_long_unchecked_t gts_alloc;
43486 + atomic_long_unchecked_t gts_free;
43487 + atomic_long_unchecked_t gms_alloc;
43488 + atomic_long_unchecked_t gms_free;
43489 + atomic_long_unchecked_t gts_double_allocate;
43490 + atomic_long_unchecked_t assign_context;
43491 + atomic_long_unchecked_t assign_context_failed;
43492 + atomic_long_unchecked_t free_context;
43493 + atomic_long_unchecked_t load_user_context;
43494 + atomic_long_unchecked_t load_kernel_context;
43495 + atomic_long_unchecked_t lock_kernel_context;
43496 + atomic_long_unchecked_t unlock_kernel_context;
43497 + atomic_long_unchecked_t steal_user_context;
43498 + atomic_long_unchecked_t steal_kernel_context;
43499 + atomic_long_unchecked_t steal_context_failed;
43500 + atomic_long_unchecked_t nopfn;
43501 + atomic_long_unchecked_t asid_new;
43502 + atomic_long_unchecked_t asid_next;
43503 + atomic_long_unchecked_t asid_wrap;
43504 + atomic_long_unchecked_t asid_reuse;
43505 + atomic_long_unchecked_t intr;
43506 + atomic_long_unchecked_t intr_cbr;
43507 + atomic_long_unchecked_t intr_tfh;
43508 + atomic_long_unchecked_t intr_spurious;
43509 + atomic_long_unchecked_t intr_mm_lock_failed;
43510 + atomic_long_unchecked_t call_os;
43511 + atomic_long_unchecked_t call_os_wait_queue;
43512 + atomic_long_unchecked_t user_flush_tlb;
43513 + atomic_long_unchecked_t user_unload_context;
43514 + atomic_long_unchecked_t user_exception;
43515 + atomic_long_unchecked_t set_context_option;
43516 + atomic_long_unchecked_t check_context_retarget_intr;
43517 + atomic_long_unchecked_t check_context_unload;
43518 + atomic_long_unchecked_t tlb_dropin;
43519 + atomic_long_unchecked_t tlb_preload_page;
43520 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43521 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43522 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43523 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43524 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43525 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43526 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43527 + atomic_long_unchecked_t tfh_stale_on_fault;
43528 + atomic_long_unchecked_t mmu_invalidate_range;
43529 + atomic_long_unchecked_t mmu_invalidate_page;
43530 + atomic_long_unchecked_t flush_tlb;
43531 + atomic_long_unchecked_t flush_tlb_gru;
43532 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43533 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43534
43535 - atomic_long_t copy_gpa;
43536 - atomic_long_t read_gpa;
43537 + atomic_long_unchecked_t copy_gpa;
43538 + atomic_long_unchecked_t read_gpa;
43539
43540 - atomic_long_t mesq_receive;
43541 - atomic_long_t mesq_receive_none;
43542 - atomic_long_t mesq_send;
43543 - atomic_long_t mesq_send_failed;
43544 - atomic_long_t mesq_noop;
43545 - atomic_long_t mesq_send_unexpected_error;
43546 - atomic_long_t mesq_send_lb_overflow;
43547 - atomic_long_t mesq_send_qlimit_reached;
43548 - atomic_long_t mesq_send_amo_nacked;
43549 - atomic_long_t mesq_send_put_nacked;
43550 - atomic_long_t mesq_page_overflow;
43551 - atomic_long_t mesq_qf_locked;
43552 - atomic_long_t mesq_qf_noop_not_full;
43553 - atomic_long_t mesq_qf_switch_head_failed;
43554 - atomic_long_t mesq_qf_unexpected_error;
43555 - atomic_long_t mesq_noop_unexpected_error;
43556 - atomic_long_t mesq_noop_lb_overflow;
43557 - atomic_long_t mesq_noop_qlimit_reached;
43558 - atomic_long_t mesq_noop_amo_nacked;
43559 - atomic_long_t mesq_noop_put_nacked;
43560 - atomic_long_t mesq_noop_page_overflow;
43561 + atomic_long_unchecked_t mesq_receive;
43562 + atomic_long_unchecked_t mesq_receive_none;
43563 + atomic_long_unchecked_t mesq_send;
43564 + atomic_long_unchecked_t mesq_send_failed;
43565 + atomic_long_unchecked_t mesq_noop;
43566 + atomic_long_unchecked_t mesq_send_unexpected_error;
43567 + atomic_long_unchecked_t mesq_send_lb_overflow;
43568 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43569 + atomic_long_unchecked_t mesq_send_amo_nacked;
43570 + atomic_long_unchecked_t mesq_send_put_nacked;
43571 + atomic_long_unchecked_t mesq_page_overflow;
43572 + atomic_long_unchecked_t mesq_qf_locked;
43573 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43574 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43575 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43576 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43577 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43578 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43579 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43580 + atomic_long_unchecked_t mesq_noop_put_nacked;
43581 + atomic_long_unchecked_t mesq_noop_page_overflow;
43582
43583 };
43584
43585 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43586 tghop_invalidate, mcsop_last};
43587
43588 struct mcs_op_statistic {
43589 - atomic_long_t count;
43590 - atomic_long_t total;
43591 + atomic_long_unchecked_t count;
43592 + atomic_long_unchecked_t total;
43593 unsigned long max;
43594 };
43595
43596 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43597
43598 #define STAT(id) do { \
43599 if (gru_options & OPT_STATS) \
43600 - atomic_long_inc(&gru_stats.id); \
43601 + atomic_long_inc_unchecked(&gru_stats.id); \
43602 } while (0)
43603
43604 #ifdef CONFIG_SGI_GRU_DEBUG
43605 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43606 index c862cd4..0d176fe 100644
43607 --- a/drivers/misc/sgi-xp/xp.h
43608 +++ b/drivers/misc/sgi-xp/xp.h
43609 @@ -288,7 +288,7 @@ struct xpc_interface {
43610 xpc_notify_func, void *);
43611 void (*received) (short, int, void *);
43612 enum xp_retval (*partid_to_nasids) (short, void *);
43613 -};
43614 +} __no_const;
43615
43616 extern struct xpc_interface xpc_interface;
43617
43618 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43619 index b94d5f7..7f494c5 100644
43620 --- a/drivers/misc/sgi-xp/xpc.h
43621 +++ b/drivers/misc/sgi-xp/xpc.h
43622 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43623 void (*received_payload) (struct xpc_channel *, void *);
43624 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43625 };
43626 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43627
43628 /* struct xpc_partition act_state values (for XPC HB) */
43629
43630 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43631 /* found in xpc_main.c */
43632 extern struct device *xpc_part;
43633 extern struct device *xpc_chan;
43634 -extern struct xpc_arch_operations xpc_arch_ops;
43635 +extern xpc_arch_operations_no_const xpc_arch_ops;
43636 extern int xpc_disengage_timelimit;
43637 extern int xpc_disengage_timedout;
43638 extern int xpc_activate_IRQ_rcvd;
43639 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43640 index 82dc574..8539ab2 100644
43641 --- a/drivers/misc/sgi-xp/xpc_main.c
43642 +++ b/drivers/misc/sgi-xp/xpc_main.c
43643 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43644 .notifier_call = xpc_system_die,
43645 };
43646
43647 -struct xpc_arch_operations xpc_arch_ops;
43648 +xpc_arch_operations_no_const xpc_arch_ops;
43649
43650 /*
43651 * Timer function to enforce the timelimit on the partition disengage.
43652 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43653
43654 if (((die_args->trapnr == X86_TRAP_MF) ||
43655 (die_args->trapnr == X86_TRAP_XF)) &&
43656 - !user_mode_vm(die_args->regs))
43657 + !user_mode(die_args->regs))
43658 xpc_die_deactivate();
43659
43660 break;
43661 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43662 index 837fc73..acb5862 100644
43663 --- a/drivers/mmc/core/mmc_ops.c
43664 +++ b/drivers/mmc/core/mmc_ops.c
43665 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43666 void *data_buf;
43667 int is_on_stack;
43668
43669 - is_on_stack = object_is_on_stack(buf);
43670 + is_on_stack = object_starts_on_stack(buf);
43671 if (is_on_stack) {
43672 /*
43673 * dma onto stack is unsafe/nonportable, but callers to this
43674 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43675 index 81b2994..dce857e 100644
43676 --- a/drivers/mmc/host/dw_mmc.h
43677 +++ b/drivers/mmc/host/dw_mmc.h
43678 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43679 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43680 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43681 int (*parse_dt)(struct dw_mci *host);
43682 -};
43683 +} __do_const;
43684 #endif /* _DW_MMC_H_ */
43685 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43686 index c3785ed..1984c44 100644
43687 --- a/drivers/mmc/host/mmci.c
43688 +++ b/drivers/mmc/host/mmci.c
43689 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43690 }
43691
43692 if (variant->busy_detect) {
43693 - mmci_ops.card_busy = mmci_card_busy;
43694 + pax_open_kernel();
43695 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43696 + pax_close_kernel();
43697 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43698 }
43699
43700 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43701 index 926aaf6..8e153e2 100644
43702 --- a/drivers/mmc/host/sdhci-s3c.c
43703 +++ b/drivers/mmc/host/sdhci-s3c.c
43704 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43705 * we can use overriding functions instead of default.
43706 */
43707 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43708 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43709 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43710 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43711 + pax_open_kernel();
43712 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43713 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43714 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43715 + pax_close_kernel();
43716 }
43717
43718 /* It supports additional host capabilities if needed */
43719 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
43720 index 096993f..f02c23b 100644
43721 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
43722 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
43723 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43724 size_t totlen = 0, thislen;
43725 int ret = 0;
43726 size_t buflen = 0;
43727 - static char *buffer;
43728 + char *buffer;
43729
43730 if (!ECCBUF_SIZE) {
43731 /* We should fall back to a general writev implementation.
43732 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43733 index 0c8bb6b..6f35deb 100644
43734 --- a/drivers/mtd/nand/denali.c
43735 +++ b/drivers/mtd/nand/denali.c
43736 @@ -24,6 +24,7 @@
43737 #include <linux/slab.h>
43738 #include <linux/mtd/mtd.h>
43739 #include <linux/module.h>
43740 +#include <linux/slab.h>
43741
43742 #include "denali.h"
43743
43744 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43745 index 51b9d6a..52af9a7 100644
43746 --- a/drivers/mtd/nftlmount.c
43747 +++ b/drivers/mtd/nftlmount.c
43748 @@ -24,6 +24,7 @@
43749 #include <asm/errno.h>
43750 #include <linux/delay.h>
43751 #include <linux/slab.h>
43752 +#include <linux/sched.h>
43753 #include <linux/mtd/mtd.h>
43754 #include <linux/mtd/nand.h>
43755 #include <linux/mtd/nftl.h>
43756 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43757 index f9d5615..99dd95f 100644
43758 --- a/drivers/mtd/sm_ftl.c
43759 +++ b/drivers/mtd/sm_ftl.c
43760 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43761 #define SM_CIS_VENDOR_OFFSET 0x59
43762 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43763 {
43764 - struct attribute_group *attr_group;
43765 + attribute_group_no_const *attr_group;
43766 struct attribute **attributes;
43767 struct sm_sysfs_attribute *vendor_attribute;
43768
43769 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43770 index 5e31046..82f8ddc 100644
43771 --- a/drivers/net/bonding/bond_main.c
43772 +++ b/drivers/net/bonding/bond_main.c
43773 @@ -4839,7 +4839,7 @@ static unsigned int bond_get_num_tx_queues(void)
43774 return tx_queues;
43775 }
43776
43777 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43778 +static struct rtnl_link_ops bond_link_ops = {
43779 .kind = "bond",
43780 .priv_size = sizeof(struct bonding),
43781 .setup = bond_setup,
43782 @@ -4964,8 +4964,8 @@ static void __exit bonding_exit(void)
43783
43784 bond_destroy_debugfs();
43785
43786 - rtnl_link_unregister(&bond_link_ops);
43787 unregister_pernet_subsys(&bond_net_ops);
43788 + rtnl_link_unregister(&bond_link_ops);
43789
43790 #ifdef CONFIG_NET_POLL_CONTROLLER
43791 /*
43792 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43793 index e1d2643..7f4133b 100644
43794 --- a/drivers/net/ethernet/8390/ax88796.c
43795 +++ b/drivers/net/ethernet/8390/ax88796.c
43796 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43797 if (ax->plat->reg_offsets)
43798 ei_local->reg_offset = ax->plat->reg_offsets;
43799 else {
43800 + resource_size_t _mem_size = mem_size;
43801 + do_div(_mem_size, 0x18);
43802 ei_local->reg_offset = ax->reg_offsets;
43803 for (ret = 0; ret < 0x18; ret++)
43804 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43805 + ax->reg_offsets[ret] = _mem_size * ret;
43806 }
43807
43808 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43809 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43810 index c07a6d0..ca88c45 100644
43811 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43812 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43813 @@ -1137,7 +1137,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43814 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43815 {
43816 /* RX_MODE controlling object */
43817 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43818 + bnx2x_init_rx_mode_obj(bp);
43819
43820 /* multicast configuration controlling object */
43821 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43822 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43823 index 8f03c98..dd0ef10 100644
43824 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43825 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43826 @@ -2345,15 +2345,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43827 return rc;
43828 }
43829
43830 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43831 - struct bnx2x_rx_mode_obj *o)
43832 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43833 {
43834 if (CHIP_IS_E1x(bp)) {
43835 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43836 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43837 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43838 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43839 } else {
43840 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43841 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43842 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43843 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43844 }
43845 }
43846
43847 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43848 index 798dfe9..05d0a44 100644
43849 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43850 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43851 @@ -1311,8 +1311,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43852
43853 /********************* RX MODE ****************/
43854
43855 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43856 - struct bnx2x_rx_mode_obj *o);
43857 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43858
43859 /**
43860 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43861 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43862 index cd63d11..b67dd78 100644
43863 --- a/drivers/net/ethernet/broadcom/tg3.h
43864 +++ b/drivers/net/ethernet/broadcom/tg3.h
43865 @@ -147,6 +147,7 @@
43866 #define CHIPREV_ID_5750_A0 0x4000
43867 #define CHIPREV_ID_5750_A1 0x4001
43868 #define CHIPREV_ID_5750_A3 0x4003
43869 +#define CHIPREV_ID_5750_C1 0x4201
43870 #define CHIPREV_ID_5750_C2 0x4202
43871 #define CHIPREV_ID_5752_A0_HW 0x5000
43872 #define CHIPREV_ID_5752_A0 0x6000
43873 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43874 index 8cffcdf..aadf043 100644
43875 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43876 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43877 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
43878 */
43879 struct l2t_skb_cb {
43880 arp_failure_handler_func arp_failure_handler;
43881 -};
43882 +} __no_const;
43883
43884 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
43885
43886 diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c
43887 index 9c89dc8..725ecc3 100644
43888 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c
43889 +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c
43890 @@ -1599,7 +1599,7 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
43891 flits = skb_transport_offset(skb) / 8;
43892 sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
43893 sgl_flits = make_sgl(skb, sgp, skb_transport_header(skb),
43894 - skb->tail - skb->transport_header,
43895 + skb_tail_pointer(skb) - skb_transport_header(skb),
43896 adap->pdev);
43897 if (need_skb_unmap()) {
43898 setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
43899 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43900 index 5a3256b..60f16d8 100644
43901 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43902 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43903 @@ -2177,7 +2177,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
43904
43905 int i;
43906 struct adapter *ap = netdev2adap(dev);
43907 - static const unsigned int *reg_ranges;
43908 + const unsigned int *reg_ranges;
43909 int arr_size = 0, buf_size = 0;
43910
43911 if (is_t4(ap->chip)) {
43912 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
43913 index 4c83003..2a2a5b9 100644
43914 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
43915 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
43916 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43917 for (i=0; i<ETH_ALEN; i++) {
43918 tmp.addr[i] = dev->dev_addr[i];
43919 }
43920 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43921 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43922 break;
43923
43924 case DE4X5_SET_HWADDR: /* Set the hardware address */
43925 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43926 spin_lock_irqsave(&lp->lock, flags);
43927 memcpy(&statbuf, &lp->pktStats, ioc->len);
43928 spin_unlock_irqrestore(&lp->lock, flags);
43929 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
43930 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
43931 return -EFAULT;
43932 break;
43933 }
43934 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
43935 index 3d91a5e..1014702 100644
43936 --- a/drivers/net/ethernet/emulex/benet/be_main.c
43937 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
43938 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
43939
43940 if (wrapped)
43941 newacc += 65536;
43942 - ACCESS_ONCE(*acc) = newacc;
43943 + ACCESS_ONCE_RW(*acc) = newacc;
43944 }
43945
43946 void populate_erx_stats(struct be_adapter *adapter,
43947 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
43948 index 934e1ae..b262e6b 100644
43949 --- a/drivers/net/ethernet/faraday/ftgmac100.c
43950 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
43951 @@ -31,6 +31,8 @@
43952 #include <linux/netdevice.h>
43953 #include <linux/phy.h>
43954 #include <linux/platform_device.h>
43955 +#include <linux/interrupt.h>
43956 +#include <linux/irqreturn.h>
43957 #include <net/ip.h>
43958
43959 #include "ftgmac100.h"
43960 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
43961 index 4658f4c..407d155 100644
43962 --- a/drivers/net/ethernet/faraday/ftmac100.c
43963 +++ b/drivers/net/ethernet/faraday/ftmac100.c
43964 @@ -31,6 +31,8 @@
43965 #include <linux/module.h>
43966 #include <linux/netdevice.h>
43967 #include <linux/platform_device.h>
43968 +#include <linux/interrupt.h>
43969 +#include <linux/irqreturn.h>
43970
43971 #include "ftmac100.h"
43972
43973 diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
43974 index 85fe7b5..e2da180 100644
43975 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
43976 +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
43977 @@ -2637,6 +2637,8 @@ static int igb_set_eee(struct net_device *netdev,
43978 (hw->phy.media_type != e1000_media_type_copper))
43979 return -EOPNOTSUPP;
43980
43981 + memset(&eee_curr, 0, sizeof(struct ethtool_eee));
43982 +
43983 ret_val = igb_get_eee(netdev, &eee_curr);
43984 if (ret_val)
43985 return ret_val;
43986 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43987 index 331987d..3be1135 100644
43988 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43989 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43990 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
43991 }
43992
43993 /* update the base incval used to calculate frequency adjustment */
43994 - ACCESS_ONCE(adapter->base_incval) = incval;
43995 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
43996 smp_mb();
43997
43998 /* need lock to prevent incorrect read while modifying cyclecounter */
43999 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44000 index fbe5363..266b4e3 100644
44001 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44002 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44003 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44004 struct __vxge_hw_fifo *fifo;
44005 struct vxge_hw_fifo_config *config;
44006 u32 txdl_size, txdl_per_memblock;
44007 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44008 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44009 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44010 + };
44011 +
44012 struct __vxge_hw_virtualpath *vpath;
44013
44014 if ((vp == NULL) || (attr == NULL)) {
44015 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44016 goto exit;
44017 }
44018
44019 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44020 -
44021 fifo->mempool =
44022 __vxge_hw_mempool_create(vpath->hldev,
44023 fifo->config->memblock_size,
44024 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44025 index 345d987..af69721 100644
44026 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44027 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44028 @@ -2011,7 +2011,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
44029 op_mode = QLC_83XX_DEFAULT_OPMODE;
44030
44031 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
44032 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44033 + pax_open_kernel();
44034 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44035 + pax_close_kernel();
44036 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44037 } else {
44038 return -EIO;
44039 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44040 index 599d1fd..59868fe 100644
44041 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44042 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44043 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44044 case QLCNIC_NON_PRIV_FUNC:
44045 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44046 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44047 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44048 + pax_open_kernel();
44049 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44050 + pax_close_kernel();
44051 break;
44052 case QLCNIC_PRIV_FUNC:
44053 ahw->op_mode = QLCNIC_PRIV_FUNC;
44054 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44055 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44056 + pax_open_kernel();
44057 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44058 + pax_close_kernel();
44059 break;
44060 case QLCNIC_MGMT_FUNC:
44061 ahw->op_mode = QLCNIC_MGMT_FUNC;
44062 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44063 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44064 + pax_open_kernel();
44065 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44066 + pax_close_kernel();
44067 break;
44068 default:
44069 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44070 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44071 index 79e54ef..dec4019 100644
44072 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44073 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44074 @@ -1105,7 +1105,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
44075 struct qlcnic_dump_entry *entry;
44076 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
44077 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
44078 - static const struct qlcnic_dump_operations *fw_dump_ops;
44079 + const struct qlcnic_dump_operations *fw_dump_ops;
44080 struct device *dev = &adapter->pdev->dev;
44081 struct qlcnic_hardware_context *ahw;
44082 void *temp_buffer;
44083 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44084 index 7ba68e0..618c73d 100644
44085 --- a/drivers/net/ethernet/realtek/r8169.c
44086 +++ b/drivers/net/ethernet/realtek/r8169.c
44087 @@ -759,22 +759,22 @@ struct rtl8169_private {
44088 struct mdio_ops {
44089 void (*write)(struct rtl8169_private *, int, int);
44090 int (*read)(struct rtl8169_private *, int);
44091 - } mdio_ops;
44092 + } __no_const mdio_ops;
44093
44094 struct pll_power_ops {
44095 void (*down)(struct rtl8169_private *);
44096 void (*up)(struct rtl8169_private *);
44097 - } pll_power_ops;
44098 + } __no_const pll_power_ops;
44099
44100 struct jumbo_ops {
44101 void (*enable)(struct rtl8169_private *);
44102 void (*disable)(struct rtl8169_private *);
44103 - } jumbo_ops;
44104 + } __no_const jumbo_ops;
44105
44106 struct csi_ops {
44107 void (*write)(struct rtl8169_private *, int, int);
44108 u32 (*read)(struct rtl8169_private *, int);
44109 - } csi_ops;
44110 + } __no_const csi_ops;
44111
44112 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44113 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44114 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44115 index b495394..0748c54 100644
44116 --- a/drivers/net/ethernet/sfc/ptp.c
44117 +++ b/drivers/net/ethernet/sfc/ptp.c
44118 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44119 (u32)((u64)ptp->start.dma_addr >> 32));
44120
44121 /* Clear flag that signals MC ready */
44122 - ACCESS_ONCE(*start) = 0;
44123 + ACCESS_ONCE_RW(*start) = 0;
44124 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44125 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44126
44127 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44128 index 50617c5..b13724c 100644
44129 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44130 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44131 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44132
44133 writel(value, ioaddr + MMC_CNTRL);
44134
44135 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44136 - MMC_CNTRL, value);
44137 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44138 +// MMC_CNTRL, value);
44139 }
44140
44141 /* To mask all all interrupts.*/
44142 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44143 index e6fe0d8..2b7d752 100644
44144 --- a/drivers/net/hyperv/hyperv_net.h
44145 +++ b/drivers/net/hyperv/hyperv_net.h
44146 @@ -101,7 +101,7 @@ struct rndis_device {
44147
44148 enum rndis_device_state state;
44149 bool link_state;
44150 - atomic_t new_req_id;
44151 + atomic_unchecked_t new_req_id;
44152
44153 spinlock_t request_lock;
44154 struct list_head req_list;
44155 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44156 index 0775f0a..d4fb316 100644
44157 --- a/drivers/net/hyperv/rndis_filter.c
44158 +++ b/drivers/net/hyperv/rndis_filter.c
44159 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44160 * template
44161 */
44162 set = &rndis_msg->msg.set_req;
44163 - set->req_id = atomic_inc_return(&dev->new_req_id);
44164 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44165
44166 /* Add to the request list */
44167 spin_lock_irqsave(&dev->request_lock, flags);
44168 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44169
44170 /* Setup the rndis set */
44171 halt = &request->request_msg.msg.halt_req;
44172 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44173 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44174
44175 /* Ignore return since this msg is optional. */
44176 rndis_filter_send_request(dev, request);
44177 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44178 index bf0d55e..82bcfbd1 100644
44179 --- a/drivers/net/ieee802154/fakehard.c
44180 +++ b/drivers/net/ieee802154/fakehard.c
44181 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44182 phy->transmit_power = 0xbf;
44183
44184 dev->netdev_ops = &fake_ops;
44185 - dev->ml_priv = &fake_mlme;
44186 + dev->ml_priv = (void *)&fake_mlme;
44187
44188 priv = netdev_priv(dev);
44189 priv->phy = phy;
44190 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44191 index 16b43bf..ead0c35 100644
44192 --- a/drivers/net/macvlan.c
44193 +++ b/drivers/net/macvlan.c
44194 @@ -934,13 +934,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44195 int macvlan_link_register(struct rtnl_link_ops *ops)
44196 {
44197 /* common fields */
44198 - ops->priv_size = sizeof(struct macvlan_dev);
44199 - ops->validate = macvlan_validate;
44200 - ops->maxtype = IFLA_MACVLAN_MAX;
44201 - ops->policy = macvlan_policy;
44202 - ops->changelink = macvlan_changelink;
44203 - ops->get_size = macvlan_get_size;
44204 - ops->fill_info = macvlan_fill_info;
44205 + pax_open_kernel();
44206 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44207 + *(void **)&ops->validate = macvlan_validate;
44208 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44209 + *(const void **)&ops->policy = macvlan_policy;
44210 + *(void **)&ops->changelink = macvlan_changelink;
44211 + *(void **)&ops->get_size = macvlan_get_size;
44212 + *(void **)&ops->fill_info = macvlan_fill_info;
44213 + pax_close_kernel();
44214
44215 return rtnl_link_register(ops);
44216 };
44217 @@ -996,7 +998,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44218 return NOTIFY_DONE;
44219 }
44220
44221 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44222 +static struct notifier_block macvlan_notifier_block = {
44223 .notifier_call = macvlan_device_event,
44224 };
44225
44226 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44227 index ea53abb..2e4d087 100644
44228 --- a/drivers/net/macvtap.c
44229 +++ b/drivers/net/macvtap.c
44230 @@ -1286,7 +1286,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44231 return NOTIFY_DONE;
44232 }
44233
44234 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44235 +static struct notifier_block macvtap_notifier_block = {
44236 .notifier_call = macvtap_device_event,
44237 };
44238
44239 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44240 index daec9b0..6428fcb 100644
44241 --- a/drivers/net/phy/mdio-bitbang.c
44242 +++ b/drivers/net/phy/mdio-bitbang.c
44243 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44244 struct mdiobb_ctrl *ctrl = bus->priv;
44245
44246 module_put(ctrl->ops->owner);
44247 + mdiobus_unregister(bus);
44248 mdiobus_free(bus);
44249 }
44250 EXPORT_SYMBOL(free_mdio_bitbang);
44251 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44252 index 72ff14b..11d442d 100644
44253 --- a/drivers/net/ppp/ppp_generic.c
44254 +++ b/drivers/net/ppp/ppp_generic.c
44255 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44256 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44257 struct ppp_stats stats;
44258 struct ppp_comp_stats cstats;
44259 - char *vers;
44260
44261 switch (cmd) {
44262 case SIOCGPPPSTATS:
44263 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44264 break;
44265
44266 case SIOCGPPPVER:
44267 - vers = PPP_VERSION;
44268 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44269 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44270 break;
44271 err = 0;
44272 break;
44273 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44274 index 1252d9c..80e660b 100644
44275 --- a/drivers/net/slip/slhc.c
44276 +++ b/drivers/net/slip/slhc.c
44277 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44278 register struct tcphdr *thp;
44279 register struct iphdr *ip;
44280 register struct cstate *cs;
44281 - int len, hdrlen;
44282 + long len, hdrlen;
44283 unsigned char *cp = icp;
44284
44285 /* We've got a compressed packet; read the change byte */
44286 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44287 index bff7e0b..7315137 100644
44288 --- a/drivers/net/team/team.c
44289 +++ b/drivers/net/team/team.c
44290 @@ -2702,7 +2702,7 @@ static int team_device_event(struct notifier_block *unused,
44291 return NOTIFY_DONE;
44292 }
44293
44294 -static struct notifier_block team_notifier_block __read_mostly = {
44295 +static struct notifier_block team_notifier_block = {
44296 .notifier_call = team_device_event,
44297 };
44298
44299 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44300 index 68b9aa3..b3c20f3 100644
44301 --- a/drivers/net/tun.c
44302 +++ b/drivers/net/tun.c
44303 @@ -1874,7 +1874,7 @@ unlock:
44304 }
44305
44306 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44307 - unsigned long arg, int ifreq_len)
44308 + unsigned long arg, size_t ifreq_len)
44309 {
44310 struct tun_file *tfile = file->private_data;
44311 struct tun_struct *tun;
44312 @@ -1886,6 +1886,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44313 int vnet_hdr_sz;
44314 int ret;
44315
44316 + if (ifreq_len > sizeof ifr)
44317 + return -EFAULT;
44318 +
44319 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44320 if (copy_from_user(&ifr, argp, ifreq_len))
44321 return -EFAULT;
44322 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44323 index 86292e6..8d34433 100644
44324 --- a/drivers/net/usb/hso.c
44325 +++ b/drivers/net/usb/hso.c
44326 @@ -71,7 +71,7 @@
44327 #include <asm/byteorder.h>
44328 #include <linux/serial_core.h>
44329 #include <linux/serial.h>
44330 -
44331 +#include <asm/local.h>
44332
44333 #define MOD_AUTHOR "Option Wireless"
44334 #define MOD_DESCRIPTION "USB High Speed Option driver"
44335 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44336 struct urb *urb;
44337
44338 urb = serial->rx_urb[0];
44339 - if (serial->port.count > 0) {
44340 + if (atomic_read(&serial->port.count) > 0) {
44341 count = put_rxbuf_data(urb, serial);
44342 if (count == -1)
44343 return;
44344 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44345 DUMP1(urb->transfer_buffer, urb->actual_length);
44346
44347 /* Anyone listening? */
44348 - if (serial->port.count == 0)
44349 + if (atomic_read(&serial->port.count) == 0)
44350 return;
44351
44352 if (status == 0) {
44353 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44354 tty_port_tty_set(&serial->port, tty);
44355
44356 /* check for port already opened, if not set the termios */
44357 - serial->port.count++;
44358 - if (serial->port.count == 1) {
44359 + if (atomic_inc_return(&serial->port.count) == 1) {
44360 serial->rx_state = RX_IDLE;
44361 /* Force default termio settings */
44362 _hso_serial_set_termios(tty, NULL);
44363 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44364 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44365 if (result) {
44366 hso_stop_serial_device(serial->parent);
44367 - serial->port.count--;
44368 + atomic_dec(&serial->port.count);
44369 kref_put(&serial->parent->ref, hso_serial_ref_free);
44370 }
44371 } else {
44372 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44373
44374 /* reset the rts and dtr */
44375 /* do the actual close */
44376 - serial->port.count--;
44377 + atomic_dec(&serial->port.count);
44378
44379 - if (serial->port.count <= 0) {
44380 - serial->port.count = 0;
44381 + if (atomic_read(&serial->port.count) <= 0) {
44382 + atomic_set(&serial->port.count, 0);
44383 tty_port_tty_set(&serial->port, NULL);
44384 if (!usb_gone)
44385 hso_stop_serial_device(serial->parent);
44386 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44387
44388 /* the actual setup */
44389 spin_lock_irqsave(&serial->serial_lock, flags);
44390 - if (serial->port.count)
44391 + if (atomic_read(&serial->port.count))
44392 _hso_serial_set_termios(tty, old);
44393 else
44394 tty->termios = *old;
44395 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44396 D1("Pending read interrupt on port %d\n", i);
44397 spin_lock(&serial->serial_lock);
44398 if (serial->rx_state == RX_IDLE &&
44399 - serial->port.count > 0) {
44400 + atomic_read(&serial->port.count) > 0) {
44401 /* Setup and send a ctrl req read on
44402 * port i */
44403 if (!serial->rx_urb_filled[0]) {
44404 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44405 /* Start all serial ports */
44406 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44407 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44408 - if (dev2ser(serial_table[i])->port.count) {
44409 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44410 result =
44411 hso_start_serial_device(serial_table[i], GFP_NOIO);
44412 hso_kick_transmit(dev2ser(serial_table[i]));
44413 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44414 index a79e9d3..78cd4fa 100644
44415 --- a/drivers/net/usb/sierra_net.c
44416 +++ b/drivers/net/usb/sierra_net.c
44417 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44418 /* atomic counter partially included in MAC address to make sure 2 devices
44419 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44420 */
44421 -static atomic_t iface_counter = ATOMIC_INIT(0);
44422 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44423
44424 /*
44425 * SYNC Timer Delay definition used to set the expiry time
44426 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44427 dev->net->netdev_ops = &sierra_net_device_ops;
44428
44429 /* change MAC addr to include, ifacenum, and to be unique */
44430 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44431 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44432 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44433
44434 /* we will have to manufacture ethernet headers, prepare template */
44435 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44436 index 8a05d77..ba8b9c5 100644
44437 --- a/drivers/net/vxlan.c
44438 +++ b/drivers/net/vxlan.c
44439 @@ -1870,7 +1870,7 @@ nla_put_failure:
44440 return -EMSGSIZE;
44441 }
44442
44443 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44444 +static struct rtnl_link_ops vxlan_link_ops = {
44445 .kind = "vxlan",
44446 .maxtype = IFLA_VXLAN_MAX,
44447 .policy = vxlan_policy,
44448 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44449 index 0b60295..b8bfa5b 100644
44450 --- a/drivers/net/wimax/i2400m/rx.c
44451 +++ b/drivers/net/wimax/i2400m/rx.c
44452 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44453 if (i2400m->rx_roq == NULL)
44454 goto error_roq_alloc;
44455
44456 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44457 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44458 GFP_KERNEL);
44459 if (rd == NULL) {
44460 result = -ENOMEM;
44461 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44462 index d0adbaf..6cedbf0 100644
44463 --- a/drivers/net/wireless/airo.c
44464 +++ b/drivers/net/wireless/airo.c
44465 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44466 struct airo_info *ai = dev->ml_priv;
44467 int ridcode;
44468 int enabled;
44469 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44470 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44471 unsigned char *iobuf;
44472
44473 /* Only super-user can write RIDs */
44474 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44475 index 34c8a33..3261fdc 100644
44476 --- a/drivers/net/wireless/at76c50x-usb.c
44477 +++ b/drivers/net/wireless/at76c50x-usb.c
44478 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44479 }
44480
44481 /* Convert timeout from the DFU status to jiffies */
44482 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44483 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44484 {
44485 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44486 | (s->poll_timeout[1] << 8)
44487 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
44488 index 2b3426b..1f564be 100644
44489 --- a/drivers/net/wireless/ath/ath10k/core.c
44490 +++ b/drivers/net/wireless/ath/ath10k/core.c
44491 @@ -507,7 +507,9 @@ EXPORT_SYMBOL(ath10k_core_destroy);
44492
44493 int ath10k_core_register(struct ath10k *ar)
44494 {
44495 - struct ath10k_htc_ops htc_ops;
44496 + static struct ath10k_htc_ops htc_ops = {
44497 + .target_send_suspend_complete = ath10k_send_suspend_complete,
44498 + };
44499 struct bmi_target_info target_info;
44500 int status;
44501
44502 @@ -536,8 +538,6 @@ int ath10k_core_register(struct ath10k *ar)
44503 if (status)
44504 goto err;
44505
44506 - htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete;
44507 -
44508 ar->htc = ath10k_htc_create(ar, &htc_ops);
44509 if (IS_ERR(ar->htc)) {
44510 status = PTR_ERR(ar->htc);
44511 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44512 index 74363c9..237b926 100644
44513 --- a/drivers/net/wireless/ath/ath10k/htc.c
44514 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44515 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44516 struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44517 struct ath10k_htc_ops *htc_ops)
44518 {
44519 - struct ath10k_hif_cb htc_callbacks;
44520 + static struct ath10k_hif_cb htc_callbacks = {
44521 + .rx_completion = ath10k_htc_rx_completion_handler,
44522 + .tx_completion = ath10k_htc_tx_completion_handler,
44523 + };
44524 struct ath10k_htc_ep *ep = NULL;
44525 struct ath10k_htc *htc = NULL;
44526
44527 @@ -979,8 +982,6 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44528 ath10k_htc_reset_endpoint_states(htc);
44529
44530 /* setup HIF layer callbacks */
44531 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44532 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44533 htc->ar = ar;
44534
44535 /* Get HIF default pipe for HTC message exchange */
44536 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44537 index 8d78253..bebbb68 100644
44538 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44539 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44540 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44541 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44542 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44543
44544 - ACCESS_ONCE(ads->ds_link) = i->link;
44545 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44546 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44547 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44548
44549 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44550 ctl6 = SM(i->keytype, AR_EncrType);
44551 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44552
44553 if ((i->is_first || i->is_last) &&
44554 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44555 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44556 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44557 | set11nTries(i->rates, 1)
44558 | set11nTries(i->rates, 2)
44559 | set11nTries(i->rates, 3)
44560 | (i->dur_update ? AR_DurUpdateEna : 0)
44561 | SM(0, AR_BurstDur);
44562
44563 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44564 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44565 | set11nRate(i->rates, 1)
44566 | set11nRate(i->rates, 2)
44567 | set11nRate(i->rates, 3);
44568 } else {
44569 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44570 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44571 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44572 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44573 }
44574
44575 if (!i->is_first) {
44576 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44577 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44578 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44579 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44580 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44581 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44582 return;
44583 }
44584
44585 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44586 break;
44587 }
44588
44589 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44590 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44591 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44592 | SM(i->txpower, AR_XmitPower)
44593 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44594 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44595 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44596 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44597
44598 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44599 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44600 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44601 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44602
44603 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44604 return;
44605
44606 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44607 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44608 | set11nPktDurRTSCTS(i->rates, 1);
44609
44610 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44611 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44612 | set11nPktDurRTSCTS(i->rates, 3);
44613
44614 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44615 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44616 | set11nRateFlags(i->rates, 1)
44617 | set11nRateFlags(i->rates, 2)
44618 | set11nRateFlags(i->rates, 3)
44619 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44620 index 5163abd..3ada4c2 100644
44621 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44622 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44623 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44624 (i->qcu << AR_TxQcuNum_S) | desc_len;
44625
44626 checksum += val;
44627 - ACCESS_ONCE(ads->info) = val;
44628 + ACCESS_ONCE_RW(ads->info) = val;
44629
44630 checksum += i->link;
44631 - ACCESS_ONCE(ads->link) = i->link;
44632 + ACCESS_ONCE_RW(ads->link) = i->link;
44633
44634 checksum += i->buf_addr[0];
44635 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44636 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44637 checksum += i->buf_addr[1];
44638 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44639 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44640 checksum += i->buf_addr[2];
44641 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44642 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44643 checksum += i->buf_addr[3];
44644 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44645 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44646
44647 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44648 - ACCESS_ONCE(ads->ctl3) = val;
44649 + ACCESS_ONCE_RW(ads->ctl3) = val;
44650 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44651 - ACCESS_ONCE(ads->ctl5) = val;
44652 + ACCESS_ONCE_RW(ads->ctl5) = val;
44653 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44654 - ACCESS_ONCE(ads->ctl7) = val;
44655 + ACCESS_ONCE_RW(ads->ctl7) = val;
44656 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44657 - ACCESS_ONCE(ads->ctl9) = val;
44658 + ACCESS_ONCE_RW(ads->ctl9) = val;
44659
44660 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44661 - ACCESS_ONCE(ads->ctl10) = checksum;
44662 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44663
44664 if (i->is_first || i->is_last) {
44665 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44666 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44667 | set11nTries(i->rates, 1)
44668 | set11nTries(i->rates, 2)
44669 | set11nTries(i->rates, 3)
44670 | (i->dur_update ? AR_DurUpdateEna : 0)
44671 | SM(0, AR_BurstDur);
44672
44673 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44674 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44675 | set11nRate(i->rates, 1)
44676 | set11nRate(i->rates, 2)
44677 | set11nRate(i->rates, 3);
44678 } else {
44679 - ACCESS_ONCE(ads->ctl13) = 0;
44680 - ACCESS_ONCE(ads->ctl14) = 0;
44681 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44682 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44683 }
44684
44685 ads->ctl20 = 0;
44686 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44687
44688 ctl17 = SM(i->keytype, AR_EncrType);
44689 if (!i->is_first) {
44690 - ACCESS_ONCE(ads->ctl11) = 0;
44691 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44692 - ACCESS_ONCE(ads->ctl15) = 0;
44693 - ACCESS_ONCE(ads->ctl16) = 0;
44694 - ACCESS_ONCE(ads->ctl17) = ctl17;
44695 - ACCESS_ONCE(ads->ctl18) = 0;
44696 - ACCESS_ONCE(ads->ctl19) = 0;
44697 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44698 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44699 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44700 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44701 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44702 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44703 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44704 return;
44705 }
44706
44707 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44708 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44709 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44710 | SM(i->txpower, AR_XmitPower)
44711 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44712 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44713 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44714 ctl12 |= SM(val, AR_PAPRDChainMask);
44715
44716 - ACCESS_ONCE(ads->ctl12) = ctl12;
44717 - ACCESS_ONCE(ads->ctl17) = ctl17;
44718 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44719 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44720
44721 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44722 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44723 | set11nPktDurRTSCTS(i->rates, 1);
44724
44725 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44726 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44727 | set11nPktDurRTSCTS(i->rates, 3);
44728
44729 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44730 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44731 | set11nRateFlags(i->rates, 1)
44732 | set11nRateFlags(i->rates, 2)
44733 | set11nRateFlags(i->rates, 3)
44734 | SM(i->rtscts_rate, AR_RTSCTSRate);
44735
44736 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44737 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44738 }
44739
44740 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44741 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44742 index cd74b3a..6a28d24 100644
44743 --- a/drivers/net/wireless/ath/ath9k/hw.h
44744 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44745 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
44746
44747 /* ANI */
44748 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44749 -};
44750 +} __no_const;
44751
44752 /**
44753 * struct ath_spec_scan - parameters for Atheros spectral scan
44754 @@ -721,7 +721,7 @@ struct ath_hw_ops {
44755 struct ath_spec_scan *param);
44756 void (*spectral_scan_trigger)(struct ath_hw *ah);
44757 void (*spectral_scan_wait)(struct ath_hw *ah);
44758 -};
44759 +} __no_const;
44760
44761 struct ath_nf_limits {
44762 s16 max;
44763 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
44764 index 92190da..f3a4c4c 100644
44765 --- a/drivers/net/wireless/b43/phy_lp.c
44766 +++ b/drivers/net/wireless/b43/phy_lp.c
44767 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
44768 {
44769 struct ssb_bus *bus = dev->dev->sdev->bus;
44770
44771 - static const struct b206x_channel *chandata = NULL;
44772 + const struct b206x_channel *chandata = NULL;
44773 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
44774 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
44775 u16 old_comm15, scale;
44776 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44777 index 9581d07..84f6a76 100644
44778 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44779 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44780 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44781 */
44782 if (il3945_mod_params.disable_hw_scan) {
44783 D_INFO("Disabling hw_scan\n");
44784 - il3945_mac_ops.hw_scan = NULL;
44785 + pax_open_kernel();
44786 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44787 + pax_close_kernel();
44788 }
44789
44790 D_INFO("*** LOAD DRIVER ***\n");
44791 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44792 index d532948..e0d8bb1 100644
44793 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44794 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44795 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44796 {
44797 struct iwl_priv *priv = file->private_data;
44798 char buf[64];
44799 - int buf_size;
44800 + size_t buf_size;
44801 u32 offset, len;
44802
44803 memset(buf, 0, sizeof(buf));
44804 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44805 struct iwl_priv *priv = file->private_data;
44806
44807 char buf[8];
44808 - int buf_size;
44809 + size_t buf_size;
44810 u32 reset_flag;
44811
44812 memset(buf, 0, sizeof(buf));
44813 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44814 {
44815 struct iwl_priv *priv = file->private_data;
44816 char buf[8];
44817 - int buf_size;
44818 + size_t buf_size;
44819 int ht40;
44820
44821 memset(buf, 0, sizeof(buf));
44822 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44823 {
44824 struct iwl_priv *priv = file->private_data;
44825 char buf[8];
44826 - int buf_size;
44827 + size_t buf_size;
44828 int value;
44829
44830 memset(buf, 0, sizeof(buf));
44831 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44832 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44833 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44834
44835 -static const char *fmt_value = " %-30s %10u\n";
44836 -static const char *fmt_hex = " %-30s 0x%02X\n";
44837 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44838 -static const char *fmt_header =
44839 +static const char fmt_value[] = " %-30s %10u\n";
44840 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44841 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44842 +static const char fmt_header[] =
44843 "%-32s current cumulative delta max\n";
44844
44845 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44846 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44847 {
44848 struct iwl_priv *priv = file->private_data;
44849 char buf[8];
44850 - int buf_size;
44851 + size_t buf_size;
44852 int clear;
44853
44854 memset(buf, 0, sizeof(buf));
44855 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44856 {
44857 struct iwl_priv *priv = file->private_data;
44858 char buf[8];
44859 - int buf_size;
44860 + size_t buf_size;
44861 int trace;
44862
44863 memset(buf, 0, sizeof(buf));
44864 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44865 {
44866 struct iwl_priv *priv = file->private_data;
44867 char buf[8];
44868 - int buf_size;
44869 + size_t buf_size;
44870 int missed;
44871
44872 memset(buf, 0, sizeof(buf));
44873 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44874
44875 struct iwl_priv *priv = file->private_data;
44876 char buf[8];
44877 - int buf_size;
44878 + size_t buf_size;
44879 int plcp;
44880
44881 memset(buf, 0, sizeof(buf));
44882 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44883
44884 struct iwl_priv *priv = file->private_data;
44885 char buf[8];
44886 - int buf_size;
44887 + size_t buf_size;
44888 int flush;
44889
44890 memset(buf, 0, sizeof(buf));
44891 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44892
44893 struct iwl_priv *priv = file->private_data;
44894 char buf[8];
44895 - int buf_size;
44896 + size_t buf_size;
44897 int rts;
44898
44899 if (!priv->cfg->ht_params)
44900 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44901 {
44902 struct iwl_priv *priv = file->private_data;
44903 char buf[8];
44904 - int buf_size;
44905 + size_t buf_size;
44906
44907 memset(buf, 0, sizeof(buf));
44908 buf_size = min(count, sizeof(buf) - 1);
44909 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44910 struct iwl_priv *priv = file->private_data;
44911 u32 event_log_flag;
44912 char buf[8];
44913 - int buf_size;
44914 + size_t buf_size;
44915
44916 /* check that the interface is up */
44917 if (!iwl_is_ready(priv))
44918 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44919 struct iwl_priv *priv = file->private_data;
44920 char buf[8];
44921 u32 calib_disabled;
44922 - int buf_size;
44923 + size_t buf_size;
44924
44925 memset(buf, 0, sizeof(buf));
44926 buf_size = min(count, sizeof(buf) - 1);
44927 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44928 index 1531a4f..21d2641 100644
44929 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44930 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
44931 @@ -1180,7 +1180,7 @@ static void iwl_option_config(struct iwl_priv *priv)
44932 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44933 {
44934 struct iwl_nvm_data *data = priv->nvm_data;
44935 - char *debug_msg;
44936 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44937
44938 if (data->sku_cap_11n_enable &&
44939 !priv->cfg->ht_params) {
44940 @@ -1194,7 +1194,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44941 return -EINVAL;
44942 }
44943
44944 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44945 IWL_DEBUG_INFO(priv, debug_msg,
44946 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
44947 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
44948 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
44949 index 390e2f0..75cfbaf 100644
44950 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
44951 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
44952 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
44953 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
44954
44955 char buf[8];
44956 - int buf_size;
44957 + size_t buf_size;
44958 u32 reset_flag;
44959
44960 memset(buf, 0, sizeof(buf));
44961 @@ -1371,7 +1371,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
44962 {
44963 struct iwl_trans *trans = file->private_data;
44964 char buf[8];
44965 - int buf_size;
44966 + size_t buf_size;
44967 int csr;
44968
44969 memset(buf, 0, sizeof(buf));
44970 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
44971 index cb34c78..9fec0dc 100644
44972 --- a/drivers/net/wireless/mac80211_hwsim.c
44973 +++ b/drivers/net/wireless/mac80211_hwsim.c
44974 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
44975
44976 if (channels > 1) {
44977 hwsim_if_comb.num_different_channels = channels;
44978 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44979 - mac80211_hwsim_ops.cancel_hw_scan =
44980 - mac80211_hwsim_cancel_hw_scan;
44981 - mac80211_hwsim_ops.sw_scan_start = NULL;
44982 - mac80211_hwsim_ops.sw_scan_complete = NULL;
44983 - mac80211_hwsim_ops.remain_on_channel =
44984 - mac80211_hwsim_roc;
44985 - mac80211_hwsim_ops.cancel_remain_on_channel =
44986 - mac80211_hwsim_croc;
44987 - mac80211_hwsim_ops.add_chanctx =
44988 - mac80211_hwsim_add_chanctx;
44989 - mac80211_hwsim_ops.remove_chanctx =
44990 - mac80211_hwsim_remove_chanctx;
44991 - mac80211_hwsim_ops.change_chanctx =
44992 - mac80211_hwsim_change_chanctx;
44993 - mac80211_hwsim_ops.assign_vif_chanctx =
44994 - mac80211_hwsim_assign_vif_chanctx;
44995 - mac80211_hwsim_ops.unassign_vif_chanctx =
44996 - mac80211_hwsim_unassign_vif_chanctx;
44997 + pax_open_kernel();
44998 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44999 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45000 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45001 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45002 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45003 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45004 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45005 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45006 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45007 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45008 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45009 + pax_close_kernel();
45010 }
45011
45012 spin_lock_init(&hwsim_radio_lock);
45013 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45014 index 8169a85..7fa3b47 100644
45015 --- a/drivers/net/wireless/rndis_wlan.c
45016 +++ b/drivers/net/wireless/rndis_wlan.c
45017 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45018
45019 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45020
45021 - if (rts_threshold < 0 || rts_threshold > 2347)
45022 + if (rts_threshold > 2347)
45023 rts_threshold = 2347;
45024
45025 tmp = cpu_to_le32(rts_threshold);
45026 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45027 index ee3fc57..ed5ddc9 100644
45028 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45029 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45030 @@ -386,7 +386,7 @@ struct rt2x00_intf {
45031 * for hardware which doesn't support hardware
45032 * sequence counting.
45033 */
45034 - atomic_t seqno;
45035 + atomic_unchecked_t seqno;
45036 };
45037
45038 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45039 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45040 index aa95c6c..a59dd67 100644
45041 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45042 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45043 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45044 * sequence counter given by mac80211.
45045 */
45046 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45047 - seqno = atomic_add_return(0x10, &intf->seqno);
45048 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45049 else
45050 - seqno = atomic_read(&intf->seqno);
45051 + seqno = atomic_read_unchecked(&intf->seqno);
45052
45053 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45054 hdr->seq_ctrl |= cpu_to_le16(seqno);
45055 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45056 index e2b3d9c..67a5184 100644
45057 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45058 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45059 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45060
45061 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45062
45063 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45064 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45065 + pax_open_kernel();
45066 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45067 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45068 + pax_close_kernel();
45069
45070 wl1251_info("using dedicated interrupt line");
45071 } else {
45072 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45073 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45074 + pax_open_kernel();
45075 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45076 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45077 + pax_close_kernel();
45078
45079 wl1251_info("using SDIO interrupt");
45080 }
45081 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45082 index 1c627da..69f7d17 100644
45083 --- a/drivers/net/wireless/ti/wl12xx/main.c
45084 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45085 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45086 sizeof(wl->conf.mem));
45087
45088 /* read data preparation is only needed by wl127x */
45089 - wl->ops->prepare_read = wl127x_prepare_read;
45090 + pax_open_kernel();
45091 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45092 + pax_close_kernel();
45093
45094 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45095 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45096 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45097 sizeof(wl->conf.mem));
45098
45099 /* read data preparation is only needed by wl127x */
45100 - wl->ops->prepare_read = wl127x_prepare_read;
45101 + pax_open_kernel();
45102 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45103 + pax_close_kernel();
45104
45105 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45106 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45107 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45108 index 7aa0eb8..5a9ef38 100644
45109 --- a/drivers/net/wireless/ti/wl18xx/main.c
45110 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45111 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45112 }
45113
45114 if (!checksum_param) {
45115 - wl18xx_ops.set_rx_csum = NULL;
45116 - wl18xx_ops.init_vif = NULL;
45117 + pax_open_kernel();
45118 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45119 + *(void **)&wl18xx_ops.init_vif = NULL;
45120 + pax_close_kernel();
45121 }
45122
45123 /* Enable 11a Band only if we have 5G antennas */
45124 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45125 index 7ef0b4a..ff65c28 100644
45126 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45127 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45128 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45129 {
45130 struct zd_usb *usb = urb->context;
45131 struct zd_usb_interrupt *intr = &usb->intr;
45132 - int len;
45133 + unsigned int len;
45134 u16 int_num;
45135
45136 ZD_ASSERT(in_interrupt());
45137 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
45138 index 59f95d8..53e0e7f 100644
45139 --- a/drivers/nfc/nfcwilink.c
45140 +++ b/drivers/nfc/nfcwilink.c
45141 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
45142
45143 static int nfcwilink_probe(struct platform_device *pdev)
45144 {
45145 - static struct nfcwilink *drv;
45146 + struct nfcwilink *drv;
45147 int rc;
45148 __u32 protocols;
45149
45150 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45151 index d93b2b6..ae50401 100644
45152 --- a/drivers/oprofile/buffer_sync.c
45153 +++ b/drivers/oprofile/buffer_sync.c
45154 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45155 if (cookie == NO_COOKIE)
45156 offset = pc;
45157 if (cookie == INVALID_COOKIE) {
45158 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45159 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45160 offset = pc;
45161 }
45162 if (cookie != last_cookie) {
45163 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45164 /* add userspace sample */
45165
45166 if (!mm) {
45167 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45168 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45169 return 0;
45170 }
45171
45172 cookie = lookup_dcookie(mm, s->eip, &offset);
45173
45174 if (cookie == INVALID_COOKIE) {
45175 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45176 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45177 return 0;
45178 }
45179
45180 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45181 /* ignore backtraces if failed to add a sample */
45182 if (state == sb_bt_start) {
45183 state = sb_bt_ignore;
45184 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45185 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45186 }
45187 }
45188 release_mm(mm);
45189 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45190 index c0cc4e7..44d4e54 100644
45191 --- a/drivers/oprofile/event_buffer.c
45192 +++ b/drivers/oprofile/event_buffer.c
45193 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45194 }
45195
45196 if (buffer_pos == buffer_size) {
45197 - atomic_inc(&oprofile_stats.event_lost_overflow);
45198 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45199 return;
45200 }
45201
45202 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45203 index ed2c3ec..deda85a 100644
45204 --- a/drivers/oprofile/oprof.c
45205 +++ b/drivers/oprofile/oprof.c
45206 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45207 if (oprofile_ops.switch_events())
45208 return;
45209
45210 - atomic_inc(&oprofile_stats.multiplex_counter);
45211 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45212 start_switch_worker();
45213 }
45214
45215 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45216 index 84a208d..d61b0a1 100644
45217 --- a/drivers/oprofile/oprofile_files.c
45218 +++ b/drivers/oprofile/oprofile_files.c
45219 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45220
45221 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45222
45223 -static ssize_t timeout_read(struct file *file, char __user *buf,
45224 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45225 size_t count, loff_t *offset)
45226 {
45227 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45228 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45229 index 917d28e..d62d981 100644
45230 --- a/drivers/oprofile/oprofile_stats.c
45231 +++ b/drivers/oprofile/oprofile_stats.c
45232 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45233 cpu_buf->sample_invalid_eip = 0;
45234 }
45235
45236 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45237 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45238 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45239 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45240 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45241 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45242 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45243 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45244 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45245 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45246 }
45247
45248
45249 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45250 index 38b6fc0..b5cbfce 100644
45251 --- a/drivers/oprofile/oprofile_stats.h
45252 +++ b/drivers/oprofile/oprofile_stats.h
45253 @@ -13,11 +13,11 @@
45254 #include <linux/atomic.h>
45255
45256 struct oprofile_stat_struct {
45257 - atomic_t sample_lost_no_mm;
45258 - atomic_t sample_lost_no_mapping;
45259 - atomic_t bt_lost_no_mapping;
45260 - atomic_t event_lost_overflow;
45261 - atomic_t multiplex_counter;
45262 + atomic_unchecked_t sample_lost_no_mm;
45263 + atomic_unchecked_t sample_lost_no_mapping;
45264 + atomic_unchecked_t bt_lost_no_mapping;
45265 + atomic_unchecked_t event_lost_overflow;
45266 + atomic_unchecked_t multiplex_counter;
45267 };
45268
45269 extern struct oprofile_stat_struct oprofile_stats;
45270 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45271 index 7c12d9c..9f5e825 100644
45272 --- a/drivers/oprofile/oprofilefs.c
45273 +++ b/drivers/oprofile/oprofilefs.c
45274 @@ -177,8 +177,8 @@ int oprofilefs_create_ro_ulong(struct super_block *sb, struct dentry *root,
45275
45276 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
45277 {
45278 - atomic_t *val = file->private_data;
45279 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
45280 + atomic_unchecked_t *val = file->private_data;
45281 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
45282 }
45283
45284
45285 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45286
45287
45288 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45289 - char const *name, atomic_t *val)
45290 + char const *name, atomic_unchecked_t *val)
45291 {
45292 return __oprofilefs_create_file(sb, root, name,
45293 &atomic_ro_fops, 0444, val);
45294 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45295 index 61be1d9..dec05d7 100644
45296 --- a/drivers/oprofile/timer_int.c
45297 +++ b/drivers/oprofile/timer_int.c
45298 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45299 return NOTIFY_OK;
45300 }
45301
45302 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45303 +static struct notifier_block oprofile_cpu_notifier = {
45304 .notifier_call = oprofile_cpu_notify,
45305 };
45306
45307 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45308 index 92ed045..62d39bd7 100644
45309 --- a/drivers/parport/procfs.c
45310 +++ b/drivers/parport/procfs.c
45311 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45312
45313 *ppos += len;
45314
45315 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45316 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45317 }
45318
45319 #ifdef CONFIG_PARPORT_1284
45320 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45321
45322 *ppos += len;
45323
45324 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45325 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45326 }
45327 #endif /* IEEE1284.3 support. */
45328
45329 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45330 index c35e8ad..fc33beb 100644
45331 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45332 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45333 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45334 goto init_cleanup;
45335 }
45336
45337 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45338 + pax_open_kernel();
45339 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45340 + pax_close_kernel();
45341 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45342
45343 return retval;
45344 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45345 index a6a71c4..c91097b 100644
45346 --- a/drivers/pci/hotplug/cpcihp_generic.c
45347 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45348 @@ -73,7 +73,6 @@ static u16 port;
45349 static unsigned int enum_bit;
45350 static u8 enum_mask;
45351
45352 -static struct cpci_hp_controller_ops generic_hpc_ops;
45353 static struct cpci_hp_controller generic_hpc;
45354
45355 static int __init validate_parameters(void)
45356 @@ -139,6 +138,10 @@ static int query_enum(void)
45357 return ((value & enum_mask) == enum_mask);
45358 }
45359
45360 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45361 + .query_enum = query_enum,
45362 +};
45363 +
45364 static int __init cpcihp_generic_init(void)
45365 {
45366 int status;
45367 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45368 pci_dev_put(dev);
45369
45370 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45371 - generic_hpc_ops.query_enum = query_enum;
45372 generic_hpc.ops = &generic_hpc_ops;
45373
45374 status = cpci_hp_register_controller(&generic_hpc);
45375 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45376 index 449b4bb..257e2e8 100644
45377 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45378 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45379 @@ -59,7 +59,6 @@
45380 /* local variables */
45381 static bool debug;
45382 static bool poll;
45383 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45384 static struct cpci_hp_controller zt5550_hpc;
45385
45386 /* Primary cPCI bus bridge device */
45387 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45388 return 0;
45389 }
45390
45391 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45392 + .query_enum = zt5550_hc_query_enum,
45393 +};
45394 +
45395 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45396 {
45397 int status;
45398 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45399 dbg("returned from zt5550_hc_config");
45400
45401 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45402 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45403 zt5550_hpc.ops = &zt5550_hpc_ops;
45404 if(!poll) {
45405 zt5550_hpc.irq = hc_dev->irq;
45406 zt5550_hpc.irq_flags = IRQF_SHARED;
45407 zt5550_hpc.dev_id = hc_dev;
45408
45409 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45410 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45411 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45412 + pax_open_kernel();
45413 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45414 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45415 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45416 + pax_open_kernel();
45417 } else {
45418 info("using ENUM# polling mode");
45419 }
45420 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45421 index 76ba8a1..20ca857 100644
45422 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45423 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45424 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45425
45426 void compaq_nvram_init (void __iomem *rom_start)
45427 {
45428 +
45429 +#ifndef CONFIG_PAX_KERNEXEC
45430 if (rom_start) {
45431 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45432 }
45433 +#endif
45434 +
45435 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45436
45437 /* initialize our int15 lock */
45438 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45439 index ec20f74..c1d961e 100644
45440 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45441 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45442 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45443 return -EINVAL;
45444 }
45445
45446 - slot->ops->owner = owner;
45447 - slot->ops->mod_name = mod_name;
45448 + pax_open_kernel();
45449 + *(struct module **)&slot->ops->owner = owner;
45450 + *(const char **)&slot->ops->mod_name = mod_name;
45451 + pax_close_kernel();
45452
45453 mutex_lock(&pci_hp_mutex);
45454 /*
45455 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45456 index 7d72c5e..edce02c 100644
45457 --- a/drivers/pci/hotplug/pciehp_core.c
45458 +++ b/drivers/pci/hotplug/pciehp_core.c
45459 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45460 struct slot *slot = ctrl->slot;
45461 struct hotplug_slot *hotplug = NULL;
45462 struct hotplug_slot_info *info = NULL;
45463 - struct hotplug_slot_ops *ops = NULL;
45464 + hotplug_slot_ops_no_const *ops = NULL;
45465 char name[SLOT_NAME_SIZE];
45466 int retval = -ENOMEM;
45467
45468 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45469 index c0dbe1f..94cf3d8 100644
45470 --- a/drivers/pci/pci-sysfs.c
45471 +++ b/drivers/pci/pci-sysfs.c
45472 @@ -1073,7 +1073,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45473 {
45474 /* allocate attribute structure, piggyback attribute name */
45475 int name_len = write_combine ? 13 : 10;
45476 - struct bin_attribute *res_attr;
45477 + bin_attribute_no_const *res_attr;
45478 int retval;
45479
45480 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45481 @@ -1258,7 +1258,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45482 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45483 {
45484 int retval;
45485 - struct bin_attribute *attr;
45486 + bin_attribute_no_const *attr;
45487
45488 /* If the device has VPD, try to expose it in sysfs. */
45489 if (dev->vpd) {
45490 @@ -1305,7 +1305,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45491 {
45492 int retval;
45493 int rom_size = 0;
45494 - struct bin_attribute *attr;
45495 + bin_attribute_no_const *attr;
45496
45497 if (!sysfs_initialized)
45498 return -EACCES;
45499 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45500 index d1182c4..2a138ec 100644
45501 --- a/drivers/pci/pci.h
45502 +++ b/drivers/pci/pci.h
45503 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45504 struct pci_vpd {
45505 unsigned int len;
45506 const struct pci_vpd_ops *ops;
45507 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45508 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45509 };
45510
45511 int pci_vpd_pci22_init(struct pci_dev *dev);
45512 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45513 index 403a443..034e050 100644
45514 --- a/drivers/pci/pcie/aspm.c
45515 +++ b/drivers/pci/pcie/aspm.c
45516 @@ -27,9 +27,9 @@
45517 #define MODULE_PARAM_PREFIX "pcie_aspm."
45518
45519 /* Note: those are not register definitions */
45520 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45521 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45522 -#define ASPM_STATE_L1 (4) /* L1 state */
45523 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45524 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45525 +#define ASPM_STATE_L1 (4U) /* L1 state */
45526 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45527 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45528
45529 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45530 index 46ada5c..20da716 100644
45531 --- a/drivers/pci/probe.c
45532 +++ b/drivers/pci/probe.c
45533 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45534 struct pci_bus_region region, inverted_region;
45535 bool bar_too_big = false, bar_disabled = false;
45536
45537 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45538 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45539
45540 /* No printks while decoding is disabled! */
45541 if (!dev->mmio_always_on) {
45542 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45543 index cdc7836..528635c 100644
45544 --- a/drivers/pci/proc.c
45545 +++ b/drivers/pci/proc.c
45546 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45547 static int __init pci_proc_init(void)
45548 {
45549 struct pci_dev *dev = NULL;
45550 +
45551 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45552 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45553 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45554 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45555 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45556 +#endif
45557 +#else
45558 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45559 +#endif
45560 proc_create("devices", 0, proc_bus_pci_dir,
45561 &proc_bus_pci_dev_operations);
45562 proc_initialized = 1;
45563 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45564 index 3e5b4497..dcdfb70 100644
45565 --- a/drivers/platform/x86/chromeos_laptop.c
45566 +++ b/drivers/platform/x86/chromeos_laptop.c
45567 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45568 return 0;
45569 }
45570
45571 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45572 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45573 {
45574 .ident = "Samsung Series 5 550 - Touchpad",
45575 .matches = {
45576 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45577 index 62f8030..c7f2a45 100644
45578 --- a/drivers/platform/x86/msi-laptop.c
45579 +++ b/drivers/platform/x86/msi-laptop.c
45580 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45581
45582 if (!quirks->ec_read_only) {
45583 /* allow userland write sysfs file */
45584 - dev_attr_bluetooth.store = store_bluetooth;
45585 - dev_attr_wlan.store = store_wlan;
45586 - dev_attr_threeg.store = store_threeg;
45587 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45588 - dev_attr_wlan.attr.mode |= S_IWUSR;
45589 - dev_attr_threeg.attr.mode |= S_IWUSR;
45590 + pax_open_kernel();
45591 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45592 + *(void **)&dev_attr_wlan.store = store_wlan;
45593 + *(void **)&dev_attr_threeg.store = store_threeg;
45594 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45595 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45596 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45597 + pax_close_kernel();
45598 }
45599
45600 /* disable hardware control by fn key */
45601 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
45602 index 70222f2..8c8ce66 100644
45603 --- a/drivers/platform/x86/msi-wmi.c
45604 +++ b/drivers/platform/x86/msi-wmi.c
45605 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
45606 static void msi_wmi_notify(u32 value, void *context)
45607 {
45608 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
45609 - static struct key_entry *key;
45610 + struct key_entry *key;
45611 union acpi_object *obj;
45612 acpi_status status;
45613
45614 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45615 index 3a1b6bf..b453930 100644
45616 --- a/drivers/platform/x86/sony-laptop.c
45617 +++ b/drivers/platform/x86/sony-laptop.c
45618 @@ -2486,7 +2486,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45619 }
45620
45621 /* High speed charging function */
45622 -static struct device_attribute *hsc_handle;
45623 +static device_attribute_no_const *hsc_handle;
45624
45625 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45626 struct device_attribute *attr,
45627 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45628 index 54d31c0..3f896d3 100644
45629 --- a/drivers/platform/x86/thinkpad_acpi.c
45630 +++ b/drivers/platform/x86/thinkpad_acpi.c
45631 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
45632 return 0;
45633 }
45634
45635 -void static hotkey_mask_warn_incomplete_mask(void)
45636 +static void hotkey_mask_warn_incomplete_mask(void)
45637 {
45638 /* log only what the user can fix... */
45639 const u32 wantedmask = hotkey_driver_mask &
45640 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45641 }
45642 }
45643
45644 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45645 - struct tp_nvram_state *newn,
45646 - const u32 event_mask)
45647 -{
45648 -
45649 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45650 do { \
45651 if ((event_mask & (1 << __scancode)) && \
45652 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45653 tpacpi_hotkey_send_key(__scancode); \
45654 } while (0)
45655
45656 - void issue_volchange(const unsigned int oldvol,
45657 - const unsigned int newvol)
45658 - {
45659 - unsigned int i = oldvol;
45660 +static void issue_volchange(const unsigned int oldvol,
45661 + const unsigned int newvol,
45662 + const u32 event_mask)
45663 +{
45664 + unsigned int i = oldvol;
45665
45666 - while (i > newvol) {
45667 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45668 - i--;
45669 - }
45670 - while (i < newvol) {
45671 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45672 - i++;
45673 - }
45674 + while (i > newvol) {
45675 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45676 + i--;
45677 }
45678 + while (i < newvol) {
45679 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45680 + i++;
45681 + }
45682 +}
45683
45684 - void issue_brightnesschange(const unsigned int oldbrt,
45685 - const unsigned int newbrt)
45686 - {
45687 - unsigned int i = oldbrt;
45688 +static void issue_brightnesschange(const unsigned int oldbrt,
45689 + const unsigned int newbrt,
45690 + const u32 event_mask)
45691 +{
45692 + unsigned int i = oldbrt;
45693
45694 - while (i > newbrt) {
45695 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45696 - i--;
45697 - }
45698 - while (i < newbrt) {
45699 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45700 - i++;
45701 - }
45702 + while (i > newbrt) {
45703 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45704 + i--;
45705 + }
45706 + while (i < newbrt) {
45707 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45708 + i++;
45709 }
45710 +}
45711
45712 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45713 + struct tp_nvram_state *newn,
45714 + const u32 event_mask)
45715 +{
45716 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45717 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45718 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45719 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45720 oldn->volume_level != newn->volume_level) {
45721 /* recently muted, or repeated mute keypress, or
45722 * multiple presses ending in mute */
45723 - issue_volchange(oldn->volume_level, newn->volume_level);
45724 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45725 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45726 }
45727 } else {
45728 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45729 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45730 }
45731 if (oldn->volume_level != newn->volume_level) {
45732 - issue_volchange(oldn->volume_level, newn->volume_level);
45733 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45734 } else if (oldn->volume_toggle != newn->volume_toggle) {
45735 /* repeated vol up/down keypress at end of scale ? */
45736 if (newn->volume_level == 0)
45737 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45738 /* handle brightness */
45739 if (oldn->brightness_level != newn->brightness_level) {
45740 issue_brightnesschange(oldn->brightness_level,
45741 - newn->brightness_level);
45742 + newn->brightness_level,
45743 + event_mask);
45744 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45745 /* repeated key presses that didn't change state */
45746 if (newn->brightness_level == 0)
45747 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45748 && !tp_features.bright_unkfw)
45749 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45750 }
45751 +}
45752
45753 #undef TPACPI_COMPARE_KEY
45754 #undef TPACPI_MAY_SEND_KEY
45755 -}
45756
45757 /*
45758 * Polling driver
45759 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45760 index 769d265..a3a05ca 100644
45761 --- a/drivers/pnp/pnpbios/bioscalls.c
45762 +++ b/drivers/pnp/pnpbios/bioscalls.c
45763 @@ -58,7 +58,7 @@ do { \
45764 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45765 } while(0)
45766
45767 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45768 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45769 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45770
45771 /*
45772 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45773
45774 cpu = get_cpu();
45775 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45776 +
45777 + pax_open_kernel();
45778 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45779 + pax_close_kernel();
45780
45781 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45782 spin_lock_irqsave(&pnp_bios_lock, flags);
45783 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45784 :"memory");
45785 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45786
45787 + pax_open_kernel();
45788 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45789 + pax_close_kernel();
45790 +
45791 put_cpu();
45792
45793 /* If we get here and this is set then the PnP BIOS faulted on us. */
45794 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45795 return status;
45796 }
45797
45798 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45799 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45800 {
45801 int i;
45802
45803 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45804 pnp_bios_callpoint.offset = header->fields.pm16offset;
45805 pnp_bios_callpoint.segment = PNP_CS16;
45806
45807 + pax_open_kernel();
45808 +
45809 for_each_possible_cpu(i) {
45810 struct desc_struct *gdt = get_cpu_gdt_table(i);
45811 if (!gdt)
45812 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45813 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45814 (unsigned long)__va(header->fields.pm16dseg));
45815 }
45816 +
45817 + pax_close_kernel();
45818 }
45819 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45820 index d95e101..67f0c3f 100644
45821 --- a/drivers/pnp/resource.c
45822 +++ b/drivers/pnp/resource.c
45823 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45824 return 1;
45825
45826 /* check if the resource is valid */
45827 - if (*irq < 0 || *irq > 15)
45828 + if (*irq > 15)
45829 return 0;
45830
45831 /* check if the resource is reserved */
45832 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45833 return 1;
45834
45835 /* check if the resource is valid */
45836 - if (*dma < 0 || *dma == 4 || *dma > 7)
45837 + if (*dma == 4 || *dma > 7)
45838 return 0;
45839
45840 /* check if the resource is reserved */
45841 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45842 index 0c52e2a..3421ab7 100644
45843 --- a/drivers/power/pda_power.c
45844 +++ b/drivers/power/pda_power.c
45845 @@ -37,7 +37,11 @@ static int polling;
45846
45847 #if IS_ENABLED(CONFIG_USB_PHY)
45848 static struct usb_phy *transceiver;
45849 -static struct notifier_block otg_nb;
45850 +static int otg_handle_notification(struct notifier_block *nb,
45851 + unsigned long event, void *unused);
45852 +static struct notifier_block otg_nb = {
45853 + .notifier_call = otg_handle_notification
45854 +};
45855 #endif
45856
45857 static struct regulator *ac_draw;
45858 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45859
45860 #if IS_ENABLED(CONFIG_USB_PHY)
45861 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45862 - otg_nb.notifier_call = otg_handle_notification;
45863 ret = usb_register_notifier(transceiver, &otg_nb);
45864 if (ret) {
45865 dev_err(dev, "failure to register otg notifier\n");
45866 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45867 index cc439fd..8fa30df 100644
45868 --- a/drivers/power/power_supply.h
45869 +++ b/drivers/power/power_supply.h
45870 @@ -16,12 +16,12 @@ struct power_supply;
45871
45872 #ifdef CONFIG_SYSFS
45873
45874 -extern void power_supply_init_attrs(struct device_type *dev_type);
45875 +extern void power_supply_init_attrs(void);
45876 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45877
45878 #else
45879
45880 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45881 +static inline void power_supply_init_attrs(void) {}
45882 #define power_supply_uevent NULL
45883
45884 #endif /* CONFIG_SYSFS */
45885 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45886 index 3b2d5df..3207114 100644
45887 --- a/drivers/power/power_supply_core.c
45888 +++ b/drivers/power/power_supply_core.c
45889 @@ -24,7 +24,10 @@
45890 struct class *power_supply_class;
45891 EXPORT_SYMBOL_GPL(power_supply_class);
45892
45893 -static struct device_type power_supply_dev_type;
45894 +extern const struct attribute_group *power_supply_attr_groups[];
45895 +static struct device_type power_supply_dev_type = {
45896 + .groups = power_supply_attr_groups,
45897 +};
45898
45899 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45900 struct power_supply *supply)
45901 @@ -558,7 +561,7 @@ static int __init power_supply_class_init(void)
45902 return PTR_ERR(power_supply_class);
45903
45904 power_supply_class->dev_uevent = power_supply_uevent;
45905 - power_supply_init_attrs(&power_supply_dev_type);
45906 + power_supply_init_attrs();
45907
45908 return 0;
45909 }
45910 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45911 index 29178f7..c65f324 100644
45912 --- a/drivers/power/power_supply_sysfs.c
45913 +++ b/drivers/power/power_supply_sysfs.c
45914 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45915 .is_visible = power_supply_attr_is_visible,
45916 };
45917
45918 -static const struct attribute_group *power_supply_attr_groups[] = {
45919 +const struct attribute_group *power_supply_attr_groups[] = {
45920 &power_supply_attr_group,
45921 NULL,
45922 };
45923
45924 -void power_supply_init_attrs(struct device_type *dev_type)
45925 +void power_supply_init_attrs(void)
45926 {
45927 int i;
45928
45929 - dev_type->groups = power_supply_attr_groups;
45930 -
45931 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45932 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45933 }
45934 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45935 index 288c75a..065bc84 100644
45936 --- a/drivers/regulator/core.c
45937 +++ b/drivers/regulator/core.c
45938 @@ -3544,7 +3544,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45939 {
45940 const struct regulation_constraints *constraints = NULL;
45941 const struct regulator_init_data *init_data;
45942 - static atomic_t regulator_no = ATOMIC_INIT(0);
45943 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45944 struct regulator_dev *rdev;
45945 struct device *dev;
45946 int ret, i;
45947 @@ -3614,7 +3614,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45948 rdev->dev.of_node = config->of_node;
45949 rdev->dev.parent = dev;
45950 dev_set_name(&rdev->dev, "regulator.%d",
45951 - atomic_inc_return(&regulator_no) - 1);
45952 + atomic_inc_return_unchecked(&regulator_no) - 1);
45953 ret = device_register(&rdev->dev);
45954 if (ret != 0) {
45955 put_device(&rdev->dev);
45956 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45957 index d428ef9..fdc0357 100644
45958 --- a/drivers/regulator/max8660.c
45959 +++ b/drivers/regulator/max8660.c
45960 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
45961 max8660->shadow_regs[MAX8660_OVER1] = 5;
45962 } else {
45963 /* Otherwise devices can be toggled via software */
45964 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45965 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45966 + pax_open_kernel();
45967 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
45968 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
45969 + pax_close_kernel();
45970 }
45971
45972 /*
45973 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
45974 index 0c5195a..637a453d 100644
45975 --- a/drivers/regulator/max8973-regulator.c
45976 +++ b/drivers/regulator/max8973-regulator.c
45977 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
45978 if (!pdata || !pdata->enable_ext_control) {
45979 max->desc.enable_reg = MAX8973_VOUT;
45980 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
45981 - max->ops.enable = regulator_enable_regmap;
45982 - max->ops.disable = regulator_disable_regmap;
45983 - max->ops.is_enabled = regulator_is_enabled_regmap;
45984 + pax_open_kernel();
45985 + *(void **)&max->ops.enable = regulator_enable_regmap;
45986 + *(void **)&max->ops.disable = regulator_disable_regmap;
45987 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
45988 + pax_close_kernel();
45989 }
45990
45991 if (pdata) {
45992 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
45993 index 1037e07..e64dea1 100644
45994 --- a/drivers/regulator/mc13892-regulator.c
45995 +++ b/drivers/regulator/mc13892-regulator.c
45996 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
45997 }
45998 mc13xxx_unlock(mc13892);
45999
46000 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46001 + pax_open_kernel();
46002 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46003 = mc13892_vcam_set_mode;
46004 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46005 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46006 = mc13892_vcam_get_mode;
46007 + pax_close_kernel();
46008
46009 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46010 ARRAY_SIZE(mc13892_regulators));
46011 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46012 index be06d71..264aee9 100644
46013 --- a/drivers/rtc/rtc-cmos.c
46014 +++ b/drivers/rtc/rtc-cmos.c
46015 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46016 hpet_rtc_timer_init();
46017
46018 /* export at least the first block of NVRAM */
46019 - nvram.size = address_space - NVRAM_OFFSET;
46020 + pax_open_kernel();
46021 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46022 + pax_close_kernel();
46023 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46024 if (retval < 0) {
46025 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46026 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46027 index d049393..bb20be0 100644
46028 --- a/drivers/rtc/rtc-dev.c
46029 +++ b/drivers/rtc/rtc-dev.c
46030 @@ -16,6 +16,7 @@
46031 #include <linux/module.h>
46032 #include <linux/rtc.h>
46033 #include <linux/sched.h>
46034 +#include <linux/grsecurity.h>
46035 #include "rtc-core.h"
46036
46037 static dev_t rtc_devt;
46038 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46039 if (copy_from_user(&tm, uarg, sizeof(tm)))
46040 return -EFAULT;
46041
46042 + gr_log_timechange();
46043 +
46044 return rtc_set_time(rtc, &tm);
46045
46046 case RTC_PIE_ON:
46047 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46048 index ca18fd1..055e42d 100644
46049 --- a/drivers/rtc/rtc-ds1307.c
46050 +++ b/drivers/rtc/rtc-ds1307.c
46051 @@ -107,7 +107,7 @@ struct ds1307 {
46052 u8 offset; /* register's offset */
46053 u8 regs[11];
46054 u16 nvram_offset;
46055 - struct bin_attribute *nvram;
46056 + bin_attribute_no_const *nvram;
46057 enum ds_type type;
46058 unsigned long flags;
46059 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46060 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46061 index fcb0329..d77b7f2 100644
46062 --- a/drivers/rtc/rtc-m48t59.c
46063 +++ b/drivers/rtc/rtc-m48t59.c
46064 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46065 if (IS_ERR(m48t59->rtc))
46066 return PTR_ERR(m48t59->rtc);
46067
46068 - m48t59_nvram_attr.size = pdata->offset;
46069 + pax_open_kernel();
46070 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46071 + pax_close_kernel();
46072
46073 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46074 if (ret)
46075 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
46076 index 14b5f8d..cc9bd26 100644
46077 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
46078 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
46079 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
46080 for (bit = 0; bit < 8; bit++) {
46081
46082 if ((pci_status[i] & (0x1 << bit)) != 0) {
46083 - static const char *s;
46084 + const char *s;
46085
46086 s = pci_status_strings[bit];
46087 if (i == 7/*TARG*/ && bit == 3)
46088 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
46089
46090 for (bit = 0; bit < 8; bit++) {
46091
46092 - if ((split_status[i] & (0x1 << bit)) != 0) {
46093 - static const char *s;
46094 -
46095 - s = split_status_strings[bit];
46096 - printk(s, ahd_name(ahd),
46097 + if ((split_status[i] & (0x1 << bit)) != 0)
46098 + printk(split_status_strings[bit], ahd_name(ahd),
46099 split_status_source[i]);
46100 - }
46101
46102 if (i > 1)
46103 continue;
46104
46105 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
46106 - static const char *s;
46107 -
46108 - s = split_status_strings[bit];
46109 - printk(s, ahd_name(ahd), "SG");
46110 - }
46111 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
46112 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
46113 }
46114 }
46115 /*
46116 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46117 index e693af6..2e525b6 100644
46118 --- a/drivers/scsi/bfa/bfa_fcpim.h
46119 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46120 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46121
46122 struct bfa_itn_s {
46123 bfa_isr_func_t isr;
46124 -};
46125 +} __no_const;
46126
46127 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46128 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46129 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46130 index 90814fe..4384138 100644
46131 --- a/drivers/scsi/bfa/bfa_ioc.h
46132 +++ b/drivers/scsi/bfa/bfa_ioc.h
46133 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46134 bfa_ioc_disable_cbfn_t disable_cbfn;
46135 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46136 bfa_ioc_reset_cbfn_t reset_cbfn;
46137 -};
46138 +} __no_const;
46139
46140 /*
46141 * IOC event notification mechanism.
46142 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46143 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46144 enum bfi_ioc_state fwstate);
46145 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46146 -};
46147 +} __no_const;
46148
46149 /*
46150 * Queue element to wait for room in request queue. FIFO order is
46151 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46152 index c9382d6..6619864 100644
46153 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46154 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46155 @@ -33,8 +33,8 @@
46156 */
46157 #include "libfcoe.h"
46158
46159 -static atomic_t ctlr_num;
46160 -static atomic_t fcf_num;
46161 +static atomic_unchecked_t ctlr_num;
46162 +static atomic_unchecked_t fcf_num;
46163
46164 /*
46165 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46166 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46167 if (!ctlr)
46168 goto out;
46169
46170 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46171 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46172 ctlr->f = f;
46173 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46174 INIT_LIST_HEAD(&ctlr->fcfs);
46175 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46176 fcf->dev.parent = &ctlr->dev;
46177 fcf->dev.bus = &fcoe_bus_type;
46178 fcf->dev.type = &fcoe_fcf_device_type;
46179 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46180 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46181 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46182
46183 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46184 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46185 {
46186 int error;
46187
46188 - atomic_set(&ctlr_num, 0);
46189 - atomic_set(&fcf_num, 0);
46190 + atomic_set_unchecked(&ctlr_num, 0);
46191 + atomic_set_unchecked(&fcf_num, 0);
46192
46193 error = bus_register(&fcoe_bus_type);
46194 if (error)
46195 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46196 index df0c3c7..b00e1d0 100644
46197 --- a/drivers/scsi/hosts.c
46198 +++ b/drivers/scsi/hosts.c
46199 @@ -42,7 +42,7 @@
46200 #include "scsi_logging.h"
46201
46202
46203 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46204 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46205
46206
46207 static void scsi_host_cls_release(struct device *dev)
46208 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46209 * subtract one because we increment first then return, but we need to
46210 * know what the next host number was before increment
46211 */
46212 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46213 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46214 shost->dma_channel = 0xff;
46215
46216 /* These three are default values which can be overridden */
46217 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46218 index 7f4f790..b75b92a 100644
46219 --- a/drivers/scsi/hpsa.c
46220 +++ b/drivers/scsi/hpsa.c
46221 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46222 unsigned long flags;
46223
46224 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46225 - return h->access.command_completed(h, q);
46226 + return h->access->command_completed(h, q);
46227
46228 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46229 a = rq->head[rq->current_entry];
46230 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
46231 while (!list_empty(&h->reqQ)) {
46232 c = list_entry(h->reqQ.next, struct CommandList, list);
46233 /* can't do anything if fifo is full */
46234 - if ((h->access.fifo_full(h))) {
46235 + if ((h->access->fifo_full(h))) {
46236 dev_warn(&h->pdev->dev, "fifo full\n");
46237 break;
46238 }
46239 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
46240
46241 /* Tell the controller execute command */
46242 spin_unlock_irqrestore(&h->lock, flags);
46243 - h->access.submit_command(h, c);
46244 + h->access->submit_command(h, c);
46245 spin_lock_irqsave(&h->lock, flags);
46246 }
46247 spin_unlock_irqrestore(&h->lock, flags);
46248 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
46249
46250 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46251 {
46252 - return h->access.command_completed(h, q);
46253 + return h->access->command_completed(h, q);
46254 }
46255
46256 static inline bool interrupt_pending(struct ctlr_info *h)
46257 {
46258 - return h->access.intr_pending(h);
46259 + return h->access->intr_pending(h);
46260 }
46261
46262 static inline long interrupt_not_for_us(struct ctlr_info *h)
46263 {
46264 - return (h->access.intr_pending(h) == 0) ||
46265 + return (h->access->intr_pending(h) == 0) ||
46266 (h->interrupts_enabled == 0);
46267 }
46268
46269 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46270 if (prod_index < 0)
46271 return -ENODEV;
46272 h->product_name = products[prod_index].product_name;
46273 - h->access = *(products[prod_index].access);
46274 + h->access = products[prod_index].access;
46275
46276 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46277 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46278 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46279
46280 assert_spin_locked(&lockup_detector_lock);
46281 remove_ctlr_from_lockup_detector_list(h);
46282 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46283 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46284 spin_lock_irqsave(&h->lock, flags);
46285 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46286 spin_unlock_irqrestore(&h->lock, flags);
46287 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
46288 }
46289
46290 /* make sure the board interrupts are off */
46291 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46292 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46293
46294 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46295 goto clean2;
46296 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
46297 * fake ones to scoop up any residual completions.
46298 */
46299 spin_lock_irqsave(&h->lock, flags);
46300 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46301 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46302 spin_unlock_irqrestore(&h->lock, flags);
46303 free_irqs(h);
46304 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46305 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
46306 dev_info(&h->pdev->dev, "Board READY.\n");
46307 dev_info(&h->pdev->dev,
46308 "Waiting for stale completions to drain.\n");
46309 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46310 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46311 msleep(10000);
46312 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46313 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46314
46315 rc = controller_reset_failed(h->cfgtable);
46316 if (rc)
46317 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
46318 }
46319
46320 /* Turn the interrupts on so we can service requests */
46321 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46322 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46323
46324 hpsa_hba_inquiry(h);
46325 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46326 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46327 * To write all data in the battery backed cache to disks
46328 */
46329 hpsa_flush_cache(h);
46330 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46331 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46332 hpsa_free_irqs_and_disable_msix(h);
46333 }
46334
46335 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46336 return;
46337 }
46338 /* Change the access methods to the performant access methods */
46339 - h->access = SA5_performant_access;
46340 + h->access = &SA5_performant_access;
46341 h->transMethod = CFGTBL_Trans_Performant;
46342 }
46343
46344 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46345 index 9816479..c5d4e97 100644
46346 --- a/drivers/scsi/hpsa.h
46347 +++ b/drivers/scsi/hpsa.h
46348 @@ -79,7 +79,7 @@ struct ctlr_info {
46349 unsigned int msix_vector;
46350 unsigned int msi_vector;
46351 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46352 - struct access_method access;
46353 + struct access_method *access;
46354
46355 /* queue and queue Info */
46356 struct list_head reqQ;
46357 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46358 index 5879929..32b241d 100644
46359 --- a/drivers/scsi/libfc/fc_exch.c
46360 +++ b/drivers/scsi/libfc/fc_exch.c
46361 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46362 u16 pool_max_index;
46363
46364 struct {
46365 - atomic_t no_free_exch;
46366 - atomic_t no_free_exch_xid;
46367 - atomic_t xid_not_found;
46368 - atomic_t xid_busy;
46369 - atomic_t seq_not_found;
46370 - atomic_t non_bls_resp;
46371 + atomic_unchecked_t no_free_exch;
46372 + atomic_unchecked_t no_free_exch_xid;
46373 + atomic_unchecked_t xid_not_found;
46374 + atomic_unchecked_t xid_busy;
46375 + atomic_unchecked_t seq_not_found;
46376 + atomic_unchecked_t non_bls_resp;
46377 } stats;
46378 };
46379
46380 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46381 /* allocate memory for exchange */
46382 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46383 if (!ep) {
46384 - atomic_inc(&mp->stats.no_free_exch);
46385 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46386 goto out;
46387 }
46388 memset(ep, 0, sizeof(*ep));
46389 @@ -797,7 +797,7 @@ out:
46390 return ep;
46391 err:
46392 spin_unlock_bh(&pool->lock);
46393 - atomic_inc(&mp->stats.no_free_exch_xid);
46394 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46395 mempool_free(ep, mp->ep_pool);
46396 return NULL;
46397 }
46398 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46399 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46400 ep = fc_exch_find(mp, xid);
46401 if (!ep) {
46402 - atomic_inc(&mp->stats.xid_not_found);
46403 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46404 reject = FC_RJT_OX_ID;
46405 goto out;
46406 }
46407 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46408 ep = fc_exch_find(mp, xid);
46409 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46410 if (ep) {
46411 - atomic_inc(&mp->stats.xid_busy);
46412 + atomic_inc_unchecked(&mp->stats.xid_busy);
46413 reject = FC_RJT_RX_ID;
46414 goto rel;
46415 }
46416 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46417 }
46418 xid = ep->xid; /* get our XID */
46419 } else if (!ep) {
46420 - atomic_inc(&mp->stats.xid_not_found);
46421 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46422 reject = FC_RJT_RX_ID; /* XID not found */
46423 goto out;
46424 }
46425 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46426 } else {
46427 sp = &ep->seq;
46428 if (sp->id != fh->fh_seq_id) {
46429 - atomic_inc(&mp->stats.seq_not_found);
46430 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46431 if (f_ctl & FC_FC_END_SEQ) {
46432 /*
46433 * Update sequence_id based on incoming last
46434 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46435
46436 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46437 if (!ep) {
46438 - atomic_inc(&mp->stats.xid_not_found);
46439 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46440 goto out;
46441 }
46442 if (ep->esb_stat & ESB_ST_COMPLETE) {
46443 - atomic_inc(&mp->stats.xid_not_found);
46444 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46445 goto rel;
46446 }
46447 if (ep->rxid == FC_XID_UNKNOWN)
46448 ep->rxid = ntohs(fh->fh_rx_id);
46449 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46450 - atomic_inc(&mp->stats.xid_not_found);
46451 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46452 goto rel;
46453 }
46454 if (ep->did != ntoh24(fh->fh_s_id) &&
46455 ep->did != FC_FID_FLOGI) {
46456 - atomic_inc(&mp->stats.xid_not_found);
46457 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46458 goto rel;
46459 }
46460 sof = fr_sof(fp);
46461 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46462 sp->ssb_stat |= SSB_ST_RESP;
46463 sp->id = fh->fh_seq_id;
46464 } else if (sp->id != fh->fh_seq_id) {
46465 - atomic_inc(&mp->stats.seq_not_found);
46466 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46467 goto rel;
46468 }
46469
46470 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46471 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46472
46473 if (!sp)
46474 - atomic_inc(&mp->stats.xid_not_found);
46475 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46476 else
46477 - atomic_inc(&mp->stats.non_bls_resp);
46478 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46479
46480 fc_frame_free(fp);
46481 }
46482 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46483
46484 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46485 mp = ema->mp;
46486 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46487 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46488 st->fc_no_free_exch_xid +=
46489 - atomic_read(&mp->stats.no_free_exch_xid);
46490 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46491 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46492 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46493 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46494 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46495 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46496 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46497 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46498 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46499 }
46500 }
46501 EXPORT_SYMBOL(fc_exch_update_stats);
46502 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46503 index 161c98e..6d563b3 100644
46504 --- a/drivers/scsi/libsas/sas_ata.c
46505 +++ b/drivers/scsi/libsas/sas_ata.c
46506 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46507 .postreset = ata_std_postreset,
46508 .error_handler = ata_std_error_handler,
46509 .post_internal_cmd = sas_ata_post_internal,
46510 - .qc_defer = ata_std_qc_defer,
46511 + .qc_defer = ata_std_qc_defer,
46512 .qc_prep = ata_noop_qc_prep,
46513 .qc_issue = sas_ata_qc_issue,
46514 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46515 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46516 index 93f222d..73e977b 100644
46517 --- a/drivers/scsi/lpfc/lpfc.h
46518 +++ b/drivers/scsi/lpfc/lpfc.h
46519 @@ -431,7 +431,7 @@ struct lpfc_vport {
46520 struct dentry *debug_nodelist;
46521 struct dentry *vport_debugfs_root;
46522 struct lpfc_debugfs_trc *disc_trc;
46523 - atomic_t disc_trc_cnt;
46524 + atomic_unchecked_t disc_trc_cnt;
46525 #endif
46526 uint8_t stat_data_enabled;
46527 uint8_t stat_data_blocked;
46528 @@ -865,8 +865,8 @@ struct lpfc_hba {
46529 struct timer_list fabric_block_timer;
46530 unsigned long bit_flags;
46531 #define FABRIC_COMANDS_BLOCKED 0
46532 - atomic_t num_rsrc_err;
46533 - atomic_t num_cmd_success;
46534 + atomic_unchecked_t num_rsrc_err;
46535 + atomic_unchecked_t num_cmd_success;
46536 unsigned long last_rsrc_error_time;
46537 unsigned long last_ramp_down_time;
46538 unsigned long last_ramp_up_time;
46539 @@ -902,7 +902,7 @@ struct lpfc_hba {
46540
46541 struct dentry *debug_slow_ring_trc;
46542 struct lpfc_debugfs_trc *slow_ring_trc;
46543 - atomic_t slow_ring_trc_cnt;
46544 + atomic_unchecked_t slow_ring_trc_cnt;
46545 /* iDiag debugfs sub-directory */
46546 struct dentry *idiag_root;
46547 struct dentry *idiag_pci_cfg;
46548 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46549 index 60084e6..0e2e700 100644
46550 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46551 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46552 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46553
46554 #include <linux/debugfs.h>
46555
46556 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46557 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46558 static unsigned long lpfc_debugfs_start_time = 0L;
46559
46560 /* iDiag */
46561 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46562 lpfc_debugfs_enable = 0;
46563
46564 len = 0;
46565 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46566 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46567 (lpfc_debugfs_max_disc_trc - 1);
46568 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46569 dtp = vport->disc_trc + i;
46570 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46571 lpfc_debugfs_enable = 0;
46572
46573 len = 0;
46574 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46575 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46576 (lpfc_debugfs_max_slow_ring_trc - 1);
46577 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46578 dtp = phba->slow_ring_trc + i;
46579 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46580 !vport || !vport->disc_trc)
46581 return;
46582
46583 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46584 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46585 (lpfc_debugfs_max_disc_trc - 1);
46586 dtp = vport->disc_trc + index;
46587 dtp->fmt = fmt;
46588 dtp->data1 = data1;
46589 dtp->data2 = data2;
46590 dtp->data3 = data3;
46591 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46592 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46593 dtp->jif = jiffies;
46594 #endif
46595 return;
46596 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46597 !phba || !phba->slow_ring_trc)
46598 return;
46599
46600 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46601 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46602 (lpfc_debugfs_max_slow_ring_trc - 1);
46603 dtp = phba->slow_ring_trc + index;
46604 dtp->fmt = fmt;
46605 dtp->data1 = data1;
46606 dtp->data2 = data2;
46607 dtp->data3 = data3;
46608 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46609 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46610 dtp->jif = jiffies;
46611 #endif
46612 return;
46613 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46614 "slow_ring buffer\n");
46615 goto debug_failed;
46616 }
46617 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46618 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46619 memset(phba->slow_ring_trc, 0,
46620 (sizeof(struct lpfc_debugfs_trc) *
46621 lpfc_debugfs_max_slow_ring_trc));
46622 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46623 "buffer\n");
46624 goto debug_failed;
46625 }
46626 - atomic_set(&vport->disc_trc_cnt, 0);
46627 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46628
46629 snprintf(name, sizeof(name), "discovery_trace");
46630 vport->debug_disc_trc =
46631 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46632 index e0b20fa..30c2c0d 100644
46633 --- a/drivers/scsi/lpfc/lpfc_init.c
46634 +++ b/drivers/scsi/lpfc/lpfc_init.c
46635 @@ -10936,8 +10936,10 @@ lpfc_init(void)
46636 "misc_register returned with status %d", error);
46637
46638 if (lpfc_enable_npiv) {
46639 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46640 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46641 + pax_open_kernel();
46642 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46643 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46644 + pax_close_kernel();
46645 }
46646 lpfc_transport_template =
46647 fc_attach_transport(&lpfc_transport_functions);
46648 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46649 index 243de1d..f40e3e5 100644
46650 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46651 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46652 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46653 uint32_t evt_posted;
46654
46655 spin_lock_irqsave(&phba->hbalock, flags);
46656 - atomic_inc(&phba->num_rsrc_err);
46657 + atomic_inc_unchecked(&phba->num_rsrc_err);
46658 phba->last_rsrc_error_time = jiffies;
46659
46660 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46661 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46662 unsigned long flags;
46663 struct lpfc_hba *phba = vport->phba;
46664 uint32_t evt_posted;
46665 - atomic_inc(&phba->num_cmd_success);
46666 + atomic_inc_unchecked(&phba->num_cmd_success);
46667
46668 if (vport->cfg_lun_queue_depth <= queue_depth)
46669 return;
46670 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46671 unsigned long num_rsrc_err, num_cmd_success;
46672 int i;
46673
46674 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46675 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46676 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46677 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46678
46679 /*
46680 * The error and success command counters are global per
46681 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46682 }
46683 }
46684 lpfc_destroy_vport_work_array(phba, vports);
46685 - atomic_set(&phba->num_rsrc_err, 0);
46686 - atomic_set(&phba->num_cmd_success, 0);
46687 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46688 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46689 }
46690
46691 /**
46692 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46693 }
46694 }
46695 lpfc_destroy_vport_work_array(phba, vports);
46696 - atomic_set(&phba->num_rsrc_err, 0);
46697 - atomic_set(&phba->num_cmd_success, 0);
46698 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46699 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46700 }
46701
46702 /**
46703 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46704 index 5100476..3d89a9e 100644
46705 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46706 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46707 @@ -1542,7 +1542,7 @@ _scsih_get_resync(struct device *dev)
46708 {
46709 struct scsi_device *sdev = to_scsi_device(dev);
46710 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46711 - static struct _raid_device *raid_device;
46712 + struct _raid_device *raid_device;
46713 unsigned long flags;
46714 Mpi2RaidVolPage0_t vol_pg0;
46715 Mpi2ConfigReply_t mpi_reply;
46716 @@ -1594,7 +1594,7 @@ _scsih_get_state(struct device *dev)
46717 {
46718 struct scsi_device *sdev = to_scsi_device(dev);
46719 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46720 - static struct _raid_device *raid_device;
46721 + struct _raid_device *raid_device;
46722 unsigned long flags;
46723 Mpi2RaidVolPage0_t vol_pg0;
46724 Mpi2ConfigReply_t mpi_reply;
46725 @@ -6622,7 +6622,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
46726 struct fw_event_work *fw_event)
46727 {
46728 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
46729 - static struct _raid_device *raid_device;
46730 + struct _raid_device *raid_device;
46731 unsigned long flags;
46732 u16 handle;
46733
46734 @@ -7093,7 +7093,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
46735 u64 sas_address;
46736 struct _sas_device *sas_device;
46737 struct _sas_node *expander_device;
46738 - static struct _raid_device *raid_device;
46739 + struct _raid_device *raid_device;
46740 u8 retry_count;
46741 unsigned long flags;
46742
46743 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46744 index 1eb7b028..b2a6080 100644
46745 --- a/drivers/scsi/pmcraid.c
46746 +++ b/drivers/scsi/pmcraid.c
46747 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46748 res->scsi_dev = scsi_dev;
46749 scsi_dev->hostdata = res;
46750 res->change_detected = 0;
46751 - atomic_set(&res->read_failures, 0);
46752 - atomic_set(&res->write_failures, 0);
46753 + atomic_set_unchecked(&res->read_failures, 0);
46754 + atomic_set_unchecked(&res->write_failures, 0);
46755 rc = 0;
46756 }
46757 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46758 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46759
46760 /* If this was a SCSI read/write command keep count of errors */
46761 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46762 - atomic_inc(&res->read_failures);
46763 + atomic_inc_unchecked(&res->read_failures);
46764 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46765 - atomic_inc(&res->write_failures);
46766 + atomic_inc_unchecked(&res->write_failures);
46767
46768 if (!RES_IS_GSCSI(res->cfg_entry) &&
46769 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46770 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46771 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46772 * hrrq_id assigned here in queuecommand
46773 */
46774 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46775 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46776 pinstance->num_hrrq;
46777 cmd->cmd_done = pmcraid_io_done;
46778
46779 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46780 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46781 * hrrq_id assigned here in queuecommand
46782 */
46783 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46784 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46785 pinstance->num_hrrq;
46786
46787 if (request_size) {
46788 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46789
46790 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46791 /* add resources only after host is added into system */
46792 - if (!atomic_read(&pinstance->expose_resources))
46793 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46794 return;
46795
46796 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46797 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46798 init_waitqueue_head(&pinstance->reset_wait_q);
46799
46800 atomic_set(&pinstance->outstanding_cmds, 0);
46801 - atomic_set(&pinstance->last_message_id, 0);
46802 - atomic_set(&pinstance->expose_resources, 0);
46803 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46804 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46805
46806 INIT_LIST_HEAD(&pinstance->free_res_q);
46807 INIT_LIST_HEAD(&pinstance->used_res_q);
46808 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46809 /* Schedule worker thread to handle CCN and take care of adding and
46810 * removing devices to OS
46811 */
46812 - atomic_set(&pinstance->expose_resources, 1);
46813 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46814 schedule_work(&pinstance->worker_q);
46815 return rc;
46816
46817 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46818 index e1d150f..6c6df44 100644
46819 --- a/drivers/scsi/pmcraid.h
46820 +++ b/drivers/scsi/pmcraid.h
46821 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46822 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46823
46824 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46825 - atomic_t last_message_id;
46826 + atomic_unchecked_t last_message_id;
46827
46828 /* configuration table */
46829 struct pmcraid_config_table *cfg_table;
46830 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46831 atomic_t outstanding_cmds;
46832
46833 /* should add/delete resources to mid-layer now ?*/
46834 - atomic_t expose_resources;
46835 + atomic_unchecked_t expose_resources;
46836
46837
46838
46839 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46840 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46841 };
46842 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46843 - atomic_t read_failures; /* count of failed READ commands */
46844 - atomic_t write_failures; /* count of failed WRITE commands */
46845 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46846 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46847
46848 /* To indicate add/delete/modify during CCN */
46849 u8 change_detected;
46850 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46851 index d7a99ae..801df70 100644
46852 --- a/drivers/scsi/qla2xxx/qla_attr.c
46853 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46854 @@ -2004,7 +2004,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46855 return 0;
46856 }
46857
46858 -struct fc_function_template qla2xxx_transport_functions = {
46859 +fc_function_template_no_const qla2xxx_transport_functions = {
46860
46861 .show_host_node_name = 1,
46862 .show_host_port_name = 1,
46863 @@ -2051,7 +2051,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46864 .bsg_timeout = qla24xx_bsg_timeout,
46865 };
46866
46867 -struct fc_function_template qla2xxx_transport_vport_functions = {
46868 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46869
46870 .show_host_node_name = 1,
46871 .show_host_port_name = 1,
46872 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46873 index 2d98232..a84298e 100644
46874 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46875 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46876 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46877 struct device_attribute;
46878 extern struct device_attribute *qla2x00_host_attrs[];
46879 struct fc_function_template;
46880 -extern struct fc_function_template qla2xxx_transport_functions;
46881 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46882 +extern fc_function_template_no_const qla2xxx_transport_functions;
46883 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46884 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46885 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46886 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46887 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46888 index 3e21e9f..426ba79 100644
46889 --- a/drivers/scsi/qla2xxx/qla_os.c
46890 +++ b/drivers/scsi/qla2xxx/qla_os.c
46891 @@ -1570,8 +1570,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46892 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46893 /* Ok, a 64bit DMA mask is applicable. */
46894 ha->flags.enable_64bit_addressing = 1;
46895 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46896 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46897 + pax_open_kernel();
46898 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46899 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46900 + pax_close_kernel();
46901 return;
46902 }
46903 }
46904 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46905 index ddf16a8..80f4dd0 100644
46906 --- a/drivers/scsi/qla4xxx/ql4_def.h
46907 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46908 @@ -291,7 +291,7 @@ struct ddb_entry {
46909 * (4000 only) */
46910 atomic_t relogin_timer; /* Max Time to wait for
46911 * relogin to complete */
46912 - atomic_t relogin_retry_count; /* Num of times relogin has been
46913 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46914 * retried */
46915 uint32_t default_time2wait; /* Default Min time between
46916 * relogins (+aens) */
46917 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46918 index b246b3c..897004d 100644
46919 --- a/drivers/scsi/qla4xxx/ql4_os.c
46920 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46921 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46922 */
46923 if (!iscsi_is_session_online(cls_sess)) {
46924 /* Reset retry relogin timer */
46925 - atomic_inc(&ddb_entry->relogin_retry_count);
46926 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46927 DEBUG2(ql4_printk(KERN_INFO, ha,
46928 "%s: index[%d] relogin timed out-retrying"
46929 " relogin (%d), retry (%d)\n", __func__,
46930 ddb_entry->fw_ddb_index,
46931 - atomic_read(&ddb_entry->relogin_retry_count),
46932 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46933 ddb_entry->default_time2wait + 4));
46934 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46935 atomic_set(&ddb_entry->retry_relogin_timer,
46936 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46937
46938 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46939 atomic_set(&ddb_entry->relogin_timer, 0);
46940 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46941 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46942 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46943 ddb_entry->default_relogin_timeout =
46944 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46945 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46946 index eaa808e..95f8841 100644
46947 --- a/drivers/scsi/scsi.c
46948 +++ b/drivers/scsi/scsi.c
46949 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46950 unsigned long timeout;
46951 int rtn = 0;
46952
46953 - atomic_inc(&cmd->device->iorequest_cnt);
46954 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46955
46956 /* check if the device is still usable */
46957 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46958 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46959 index 124392f..75eb43e 100644
46960 --- a/drivers/scsi/scsi_lib.c
46961 +++ b/drivers/scsi/scsi_lib.c
46962 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46963 shost = sdev->host;
46964 scsi_init_cmd_errh(cmd);
46965 cmd->result = DID_NO_CONNECT << 16;
46966 - atomic_inc(&cmd->device->iorequest_cnt);
46967 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46968
46969 /*
46970 * SCSI request completion path will do scsi_device_unbusy(),
46971 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46972
46973 INIT_LIST_HEAD(&cmd->eh_entry);
46974
46975 - atomic_inc(&cmd->device->iodone_cnt);
46976 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46977 if (cmd->result)
46978 - atomic_inc(&cmd->device->ioerr_cnt);
46979 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46980
46981 disposition = scsi_decide_disposition(cmd);
46982 if (disposition != SUCCESS &&
46983 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46984 index 7e50061..71db7a6 100644
46985 --- a/drivers/scsi/scsi_sysfs.c
46986 +++ b/drivers/scsi/scsi_sysfs.c
46987 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46988 char *buf) \
46989 { \
46990 struct scsi_device *sdev = to_scsi_device(dev); \
46991 - unsigned long long count = atomic_read(&sdev->field); \
46992 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46993 return snprintf(buf, 20, "0x%llx\n", count); \
46994 } \
46995 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46996 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46997 index 84a1fdf..693b0d6 100644
46998 --- a/drivers/scsi/scsi_tgt_lib.c
46999 +++ b/drivers/scsi/scsi_tgt_lib.c
47000 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
47001 int err;
47002
47003 dprintk("%lx %u\n", uaddr, len);
47004 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
47005 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
47006 if (err) {
47007 /*
47008 * TODO: need to fixup sg_tablesize, max_segment_size,
47009 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
47010 index 4628fd5..a94a1c2 100644
47011 --- a/drivers/scsi/scsi_transport_fc.c
47012 +++ b/drivers/scsi/scsi_transport_fc.c
47013 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47014 * Netlink Infrastructure
47015 */
47016
47017 -static atomic_t fc_event_seq;
47018 +static atomic_unchecked_t fc_event_seq;
47019
47020 /**
47021 * fc_get_event_number - Obtain the next sequential FC event number
47022 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47023 u32
47024 fc_get_event_number(void)
47025 {
47026 - return atomic_add_return(1, &fc_event_seq);
47027 + return atomic_add_return_unchecked(1, &fc_event_seq);
47028 }
47029 EXPORT_SYMBOL(fc_get_event_number);
47030
47031 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47032 {
47033 int error;
47034
47035 - atomic_set(&fc_event_seq, 0);
47036 + atomic_set_unchecked(&fc_event_seq, 0);
47037
47038 error = transport_class_register(&fc_host_class);
47039 if (error)
47040 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47041 char *cp;
47042
47043 *val = simple_strtoul(buf, &cp, 0);
47044 - if ((*cp && (*cp != '\n')) || (*val < 0))
47045 + if (*cp && (*cp != '\n'))
47046 return -EINVAL;
47047 /*
47048 * Check for overflow; dev_loss_tmo is u32
47049 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47050 index abf7c40..c3240ed 100644
47051 --- a/drivers/scsi/scsi_transport_iscsi.c
47052 +++ b/drivers/scsi/scsi_transport_iscsi.c
47053 @@ -80,7 +80,7 @@ struct iscsi_internal {
47054 struct transport_container session_cont;
47055 };
47056
47057 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47058 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47059 static struct workqueue_struct *iscsi_eh_timer_workq;
47060
47061 static DEFINE_IDA(iscsi_sess_ida);
47062 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47063 int err;
47064
47065 ihost = shost->shost_data;
47066 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47067 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47068
47069 if (target_id == ISCSI_MAX_TARGET) {
47070 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47071 @@ -3956,7 +3956,7 @@ static __init int iscsi_transport_init(void)
47072 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47073 ISCSI_TRANSPORT_VERSION);
47074
47075 - atomic_set(&iscsi_session_nr, 0);
47076 + atomic_set_unchecked(&iscsi_session_nr, 0);
47077
47078 err = class_register(&iscsi_transport_class);
47079 if (err)
47080 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47081 index f379c7f..e8fc69c 100644
47082 --- a/drivers/scsi/scsi_transport_srp.c
47083 +++ b/drivers/scsi/scsi_transport_srp.c
47084 @@ -33,7 +33,7 @@
47085 #include "scsi_transport_srp_internal.h"
47086
47087 struct srp_host_attrs {
47088 - atomic_t next_port_id;
47089 + atomic_unchecked_t next_port_id;
47090 };
47091 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47092
47093 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47094 struct Scsi_Host *shost = dev_to_shost(dev);
47095 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47096
47097 - atomic_set(&srp_host->next_port_id, 0);
47098 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47099 return 0;
47100 }
47101
47102 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47103 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47104 rport->roles = ids->roles;
47105
47106 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47107 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47108 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47109
47110 transport_setup_device(&rport->dev);
47111 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47112 index 83e9070..9cb646f 100644
47113 --- a/drivers/scsi/sd.c
47114 +++ b/drivers/scsi/sd.c
47115 @@ -2933,7 +2933,7 @@ static int sd_probe(struct device *dev)
47116 sdkp->disk = gd;
47117 sdkp->index = index;
47118 atomic_set(&sdkp->openers, 0);
47119 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47120 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47121
47122 if (!sdp->request_queue->rq_timeout) {
47123 if (sdp->type != TYPE_MOD)
47124 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47125 index df5e961..df6b97f 100644
47126 --- a/drivers/scsi/sg.c
47127 +++ b/drivers/scsi/sg.c
47128 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47129 sdp->disk->disk_name,
47130 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47131 NULL,
47132 - (char *)arg);
47133 + (char __user *)arg);
47134 case BLKTRACESTART:
47135 return blk_trace_startstop(sdp->device->request_queue, 1);
47136 case BLKTRACESTOP:
47137 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47138 index 978dda2..cb19aa0 100644
47139 --- a/drivers/spi/spi.c
47140 +++ b/drivers/spi/spi.c
47141 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
47142 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47143
47144 /* portable code must never pass more than 32 bytes */
47145 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47146 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47147
47148 static u8 *buf;
47149
47150 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47151 index ee3a57f..18368c1 100644
47152 --- a/drivers/staging/android/timed_output.c
47153 +++ b/drivers/staging/android/timed_output.c
47154 @@ -25,7 +25,7 @@
47155 #include "timed_output.h"
47156
47157 static struct class *timed_output_class;
47158 -static atomic_t device_count;
47159 +static atomic_unchecked_t device_count;
47160
47161 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47162 char *buf)
47163 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
47164 timed_output_class = class_create(THIS_MODULE, "timed_output");
47165 if (IS_ERR(timed_output_class))
47166 return PTR_ERR(timed_output_class);
47167 - atomic_set(&device_count, 0);
47168 + atomic_set_unchecked(&device_count, 0);
47169 }
47170
47171 return 0;
47172 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47173 if (ret < 0)
47174 return ret;
47175
47176 - tdev->index = atomic_inc_return(&device_count);
47177 + tdev->index = atomic_inc_return_unchecked(&device_count);
47178 tdev->dev = device_create(timed_output_class, NULL,
47179 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47180 if (IS_ERR(tdev->dev))
47181 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47182 index 3675020..e80d92c 100644
47183 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47184 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47185 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47186
47187 static int solo_sysfs_init(struct solo_dev *solo_dev)
47188 {
47189 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47190 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47191 struct device *dev = &solo_dev->dev;
47192 const char *driver;
47193 int i;
47194 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47195 index 3335941..2b26186 100644
47196 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47197 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47198 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47199
47200 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47201 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47202 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47203 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47204 if (p2m_id < 0)
47205 p2m_id = -p2m_id;
47206 }
47207 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47208 index 6f91d2e..3f011d2 100644
47209 --- a/drivers/staging/media/solo6x10/solo6x10.h
47210 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47211 @@ -238,7 +238,7 @@ struct solo_dev {
47212
47213 /* P2M DMA Engine */
47214 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47215 - atomic_t p2m_count;
47216 + atomic_unchecked_t p2m_count;
47217 int p2m_jiffies;
47218 unsigned int p2m_timeouts;
47219
47220 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47221 index 34afc16..ffe44dd 100644
47222 --- a/drivers/staging/octeon/ethernet-rx.c
47223 +++ b/drivers/staging/octeon/ethernet-rx.c
47224 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47225 /* Increment RX stats for virtual ports */
47226 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47227 #ifdef CONFIG_64BIT
47228 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47229 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47230 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47231 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47232 #else
47233 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47234 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47235 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47236 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47237 #endif
47238 }
47239 netif_receive_skb(skb);
47240 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47241 dev->name);
47242 */
47243 #ifdef CONFIG_64BIT
47244 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47245 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47246 #else
47247 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47248 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47249 #endif
47250 dev_kfree_skb_irq(skb);
47251 }
47252 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47253 index c3a90e7..023619a 100644
47254 --- a/drivers/staging/octeon/ethernet.c
47255 +++ b/drivers/staging/octeon/ethernet.c
47256 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47257 * since the RX tasklet also increments it.
47258 */
47259 #ifdef CONFIG_64BIT
47260 - atomic64_add(rx_status.dropped_packets,
47261 - (atomic64_t *)&priv->stats.rx_dropped);
47262 + atomic64_add_unchecked(rx_status.dropped_packets,
47263 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47264 #else
47265 - atomic_add(rx_status.dropped_packets,
47266 - (atomic_t *)&priv->stats.rx_dropped);
47267 + atomic_add_unchecked(rx_status.dropped_packets,
47268 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47269 #endif
47270 }
47271
47272 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47273 index dc23395..cf7e9b1 100644
47274 --- a/drivers/staging/rtl8712/rtl871x_io.h
47275 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47276 @@ -108,7 +108,7 @@ struct _io_ops {
47277 u8 *pmem);
47278 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47279 u8 *pmem);
47280 -};
47281 +} __no_const;
47282
47283 struct io_req {
47284 struct list_head list;
47285 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47286 index 1f5088b..0e59820 100644
47287 --- a/drivers/staging/sbe-2t3e3/netdev.c
47288 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47289 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47290 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47291
47292 if (rlen)
47293 - if (copy_to_user(data, &resp, rlen))
47294 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47295 return -EFAULT;
47296
47297 return 0;
47298 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47299 index a863a98..d272795 100644
47300 --- a/drivers/staging/usbip/vhci.h
47301 +++ b/drivers/staging/usbip/vhci.h
47302 @@ -83,7 +83,7 @@ struct vhci_hcd {
47303 unsigned resuming:1;
47304 unsigned long re_timeout;
47305
47306 - atomic_t seqnum;
47307 + atomic_unchecked_t seqnum;
47308
47309 /*
47310 * NOTE:
47311 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47312 index d7974cb..d78076b 100644
47313 --- a/drivers/staging/usbip/vhci_hcd.c
47314 +++ b/drivers/staging/usbip/vhci_hcd.c
47315 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47316
47317 spin_lock(&vdev->priv_lock);
47318
47319 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47320 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47321 if (priv->seqnum == 0xffff)
47322 dev_info(&urb->dev->dev, "seqnum max\n");
47323
47324 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47325 return -ENOMEM;
47326 }
47327
47328 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47329 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47330 if (unlink->seqnum == 0xffff)
47331 pr_info("seqnum max\n");
47332
47333 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47334 vdev->rhport = rhport;
47335 }
47336
47337 - atomic_set(&vhci->seqnum, 0);
47338 + atomic_set_unchecked(&vhci->seqnum, 0);
47339 spin_lock_init(&vhci->lock);
47340
47341 hcd->power_budget = 0; /* no limit */
47342 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47343 index d07fcb5..358e1e1 100644
47344 --- a/drivers/staging/usbip/vhci_rx.c
47345 +++ b/drivers/staging/usbip/vhci_rx.c
47346 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47347 if (!urb) {
47348 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47349 pr_info("max seqnum %d\n",
47350 - atomic_read(&the_controller->seqnum));
47351 + atomic_read_unchecked(&the_controller->seqnum));
47352 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47353 return;
47354 }
47355 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47356 index 57a08c5..5b4bb7c 100644
47357 --- a/drivers/staging/vt6655/hostap.c
47358 +++ b/drivers/staging/vt6655/hostap.c
47359 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47360 *
47361 */
47362
47363 +static net_device_ops_no_const apdev_netdev_ops;
47364 +
47365 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47366 {
47367 PSDevice apdev_priv;
47368 struct net_device *dev = pDevice->dev;
47369 int ret;
47370 - const struct net_device_ops apdev_netdev_ops = {
47371 - .ndo_start_xmit = pDevice->tx_80211,
47372 - };
47373
47374 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47375
47376 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47377 *apdev_priv = *pDevice;
47378 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47379
47380 + /* only half broken now */
47381 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47382 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47383
47384 pDevice->apdev->type = ARPHRD_IEEE80211;
47385 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47386 index c699a30..b90a5fd 100644
47387 --- a/drivers/staging/vt6656/hostap.c
47388 +++ b/drivers/staging/vt6656/hostap.c
47389 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47390 *
47391 */
47392
47393 +static net_device_ops_no_const apdev_netdev_ops;
47394 +
47395 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47396 {
47397 struct vnt_private *apdev_priv;
47398 struct net_device *dev = pDevice->dev;
47399 int ret;
47400 - const struct net_device_ops apdev_netdev_ops = {
47401 - .ndo_start_xmit = pDevice->tx_80211,
47402 - };
47403
47404 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47405
47406 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47407 *apdev_priv = *pDevice;
47408 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47409
47410 + /* only half broken now */
47411 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47412 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47413
47414 pDevice->apdev->type = ARPHRD_IEEE80211;
47415 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47416 index d128ce2..fc1f9a1 100644
47417 --- a/drivers/staging/zcache/tmem.h
47418 +++ b/drivers/staging/zcache/tmem.h
47419 @@ -225,7 +225,7 @@ struct tmem_pamops {
47420 bool (*is_remote)(void *);
47421 int (*replace_in_obj)(void *, struct tmem_obj *);
47422 #endif
47423 -};
47424 +} __no_const;
47425 extern void tmem_register_pamops(struct tmem_pamops *m);
47426
47427 /* memory allocation methods provided by the host implementation */
47428 @@ -234,7 +234,7 @@ struct tmem_hostops {
47429 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47430 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47431 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47432 -};
47433 +} __no_const;
47434 extern void tmem_register_hostops(struct tmem_hostops *m);
47435
47436 /* core tmem accessor functions */
47437 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47438 index e51b09a..5ebac31 100644
47439 --- a/drivers/target/sbp/sbp_target.c
47440 +++ b/drivers/target/sbp/sbp_target.c
47441 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47442
47443 #define SESSION_MAINTENANCE_INTERVAL HZ
47444
47445 -static atomic_t login_id = ATOMIC_INIT(0);
47446 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47447
47448 static void session_maintenance_work(struct work_struct *);
47449 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47450 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47451 login->lun = se_lun;
47452 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47453 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47454 - login->login_id = atomic_inc_return(&login_id);
47455 + login->login_id = atomic_inc_return_unchecked(&login_id);
47456
47457 login->tgt_agt = sbp_target_agent_register(login);
47458 if (IS_ERR(login->tgt_agt)) {
47459 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47460 index 8f4142f..b127f7d 100644
47461 --- a/drivers/target/target_core_device.c
47462 +++ b/drivers/target/target_core_device.c
47463 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47464 spin_lock_init(&dev->se_port_lock);
47465 spin_lock_init(&dev->se_tmr_lock);
47466 spin_lock_init(&dev->qf_cmd_lock);
47467 - atomic_set(&dev->dev_ordered_id, 0);
47468 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47469 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47470 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47471 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47472 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47473 index d8e49d7..6fcfdec 100644
47474 --- a/drivers/target/target_core_transport.c
47475 +++ b/drivers/target/target_core_transport.c
47476 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47477 * Used to determine when ORDERED commands should go from
47478 * Dormant to Active status.
47479 */
47480 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47481 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47482 smp_mb__after_atomic_inc();
47483 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47484 cmd->se_ordered_id, cmd->sam_task_attr,
47485 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47486 index 33f83fe..d80f8e1 100644
47487 --- a/drivers/tty/cyclades.c
47488 +++ b/drivers/tty/cyclades.c
47489 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47490 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47491 info->port.count);
47492 #endif
47493 - info->port.count++;
47494 + atomic_inc(&info->port.count);
47495 #ifdef CY_DEBUG_COUNT
47496 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47497 - current->pid, info->port.count);
47498 + current->pid, atomic_read(&info->port.count));
47499 #endif
47500
47501 /*
47502 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47503 for (j = 0; j < cy_card[i].nports; j++) {
47504 info = &cy_card[i].ports[j];
47505
47506 - if (info->port.count) {
47507 + if (atomic_read(&info->port.count)) {
47508 /* XXX is the ldisc num worth this? */
47509 struct tty_struct *tty;
47510 struct tty_ldisc *ld;
47511 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47512 index eb255e8..f637a57 100644
47513 --- a/drivers/tty/hvc/hvc_console.c
47514 +++ b/drivers/tty/hvc/hvc_console.c
47515 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47516
47517 spin_lock_irqsave(&hp->port.lock, flags);
47518 /* Check and then increment for fast path open. */
47519 - if (hp->port.count++ > 0) {
47520 + if (atomic_inc_return(&hp->port.count) > 1) {
47521 spin_unlock_irqrestore(&hp->port.lock, flags);
47522 hvc_kick();
47523 return 0;
47524 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47525
47526 spin_lock_irqsave(&hp->port.lock, flags);
47527
47528 - if (--hp->port.count == 0) {
47529 + if (atomic_dec_return(&hp->port.count) == 0) {
47530 spin_unlock_irqrestore(&hp->port.lock, flags);
47531 /* We are done with the tty pointer now. */
47532 tty_port_tty_set(&hp->port, NULL);
47533 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47534 */
47535 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47536 } else {
47537 - if (hp->port.count < 0)
47538 + if (atomic_read(&hp->port.count) < 0)
47539 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47540 - hp->vtermno, hp->port.count);
47541 + hp->vtermno, atomic_read(&hp->port.count));
47542 spin_unlock_irqrestore(&hp->port.lock, flags);
47543 }
47544 }
47545 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47546 * open->hangup case this can be called after the final close so prevent
47547 * that from happening for now.
47548 */
47549 - if (hp->port.count <= 0) {
47550 + if (atomic_read(&hp->port.count) <= 0) {
47551 spin_unlock_irqrestore(&hp->port.lock, flags);
47552 return;
47553 }
47554
47555 - hp->port.count = 0;
47556 + atomic_set(&hp->port.count, 0);
47557 spin_unlock_irqrestore(&hp->port.lock, flags);
47558 tty_port_tty_set(&hp->port, NULL);
47559
47560 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47561 return -EPIPE;
47562
47563 /* FIXME what's this (unprotected) check for? */
47564 - if (hp->port.count <= 0)
47565 + if (atomic_read(&hp->port.count) <= 0)
47566 return -EIO;
47567
47568 spin_lock_irqsave(&hp->lock, flags);
47569 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47570 index 81e939e..95ead10 100644
47571 --- a/drivers/tty/hvc/hvcs.c
47572 +++ b/drivers/tty/hvc/hvcs.c
47573 @@ -83,6 +83,7 @@
47574 #include <asm/hvcserver.h>
47575 #include <asm/uaccess.h>
47576 #include <asm/vio.h>
47577 +#include <asm/local.h>
47578
47579 /*
47580 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47581 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47582
47583 spin_lock_irqsave(&hvcsd->lock, flags);
47584
47585 - if (hvcsd->port.count > 0) {
47586 + if (atomic_read(&hvcsd->port.count) > 0) {
47587 spin_unlock_irqrestore(&hvcsd->lock, flags);
47588 printk(KERN_INFO "HVCS: vterm state unchanged. "
47589 "The hvcs device node is still in use.\n");
47590 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47591 }
47592 }
47593
47594 - hvcsd->port.count = 0;
47595 + atomic_set(&hvcsd->port.count, 0);
47596 hvcsd->port.tty = tty;
47597 tty->driver_data = hvcsd;
47598
47599 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47600 unsigned long flags;
47601
47602 spin_lock_irqsave(&hvcsd->lock, flags);
47603 - hvcsd->port.count++;
47604 + atomic_inc(&hvcsd->port.count);
47605 hvcsd->todo_mask |= HVCS_SCHED_READ;
47606 spin_unlock_irqrestore(&hvcsd->lock, flags);
47607
47608 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47609 hvcsd = tty->driver_data;
47610
47611 spin_lock_irqsave(&hvcsd->lock, flags);
47612 - if (--hvcsd->port.count == 0) {
47613 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47614
47615 vio_disable_interrupts(hvcsd->vdev);
47616
47617 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47618
47619 free_irq(irq, hvcsd);
47620 return;
47621 - } else if (hvcsd->port.count < 0) {
47622 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47623 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47624 " is missmanaged.\n",
47625 - hvcsd->vdev->unit_address, hvcsd->port.count);
47626 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47627 }
47628
47629 spin_unlock_irqrestore(&hvcsd->lock, flags);
47630 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47631
47632 spin_lock_irqsave(&hvcsd->lock, flags);
47633 /* Preserve this so that we know how many kref refs to put */
47634 - temp_open_count = hvcsd->port.count;
47635 + temp_open_count = atomic_read(&hvcsd->port.count);
47636
47637 /*
47638 * Don't kref put inside the spinlock because the destruction
47639 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47640 tty->driver_data = NULL;
47641 hvcsd->port.tty = NULL;
47642
47643 - hvcsd->port.count = 0;
47644 + atomic_set(&hvcsd->port.count, 0);
47645
47646 /* This will drop any buffered data on the floor which is OK in a hangup
47647 * scenario. */
47648 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47649 * the middle of a write operation? This is a crummy place to do this
47650 * but we want to keep it all in the spinlock.
47651 */
47652 - if (hvcsd->port.count <= 0) {
47653 + if (atomic_read(&hvcsd->port.count) <= 0) {
47654 spin_unlock_irqrestore(&hvcsd->lock, flags);
47655 return -ENODEV;
47656 }
47657 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47658 {
47659 struct hvcs_struct *hvcsd = tty->driver_data;
47660
47661 - if (!hvcsd || hvcsd->port.count <= 0)
47662 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47663 return 0;
47664
47665 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47666 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47667 index 4190199..48f2920 100644
47668 --- a/drivers/tty/hvc/hvsi.c
47669 +++ b/drivers/tty/hvc/hvsi.c
47670 @@ -85,7 +85,7 @@ struct hvsi_struct {
47671 int n_outbuf;
47672 uint32_t vtermno;
47673 uint32_t virq;
47674 - atomic_t seqno; /* HVSI packet sequence number */
47675 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47676 uint16_t mctrl;
47677 uint8_t state; /* HVSI protocol state */
47678 uint8_t flags;
47679 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47680
47681 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47682 packet.hdr.len = sizeof(struct hvsi_query_response);
47683 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47684 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47685 packet.verb = VSV_SEND_VERSION_NUMBER;
47686 packet.u.version = HVSI_VERSION;
47687 packet.query_seqno = query_seqno+1;
47688 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47689
47690 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47691 packet.hdr.len = sizeof(struct hvsi_query);
47692 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47693 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47694 packet.verb = verb;
47695
47696 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47697 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47698 int wrote;
47699
47700 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47701 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47702 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47703 packet.hdr.len = sizeof(struct hvsi_control);
47704 packet.verb = VSV_SET_MODEM_CTL;
47705 packet.mask = HVSI_TSDTR;
47706 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47707 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47708
47709 packet.hdr.type = VS_DATA_PACKET_HEADER;
47710 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47711 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47712 packet.hdr.len = count + sizeof(struct hvsi_header);
47713 memcpy(&packet.data, buf, count);
47714
47715 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47716 struct hvsi_control packet __ALIGNED__;
47717
47718 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47719 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47720 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47721 packet.hdr.len = 6;
47722 packet.verb = VSV_CLOSE_PROTOCOL;
47723
47724 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47725 index ac27671..0f627ee 100644
47726 --- a/drivers/tty/hvc/hvsi_lib.c
47727 +++ b/drivers/tty/hvc/hvsi_lib.c
47728 @@ -9,7 +9,7 @@
47729
47730 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47731 {
47732 - packet->seqno = atomic_inc_return(&pv->seqno);
47733 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47734
47735 /* Assumes that always succeeds, works in practice */
47736 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47737 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47738
47739 /* Reset state */
47740 pv->established = 0;
47741 - atomic_set(&pv->seqno, 0);
47742 + atomic_set_unchecked(&pv->seqno, 0);
47743
47744 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47745
47746 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47747 pv->mctrl_update = 0;
47748 q.hdr.type = VS_QUERY_PACKET_HEADER;
47749 q.hdr.len = sizeof(struct hvsi_query);
47750 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47751 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47752 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47753 rc = hvsi_send_packet(pv, &q.hdr);
47754 if (rc <= 0) {
47755 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47756 index 8fd72ff..34a0bed 100644
47757 --- a/drivers/tty/ipwireless/tty.c
47758 +++ b/drivers/tty/ipwireless/tty.c
47759 @@ -29,6 +29,7 @@
47760 #include <linux/tty_driver.h>
47761 #include <linux/tty_flip.h>
47762 #include <linux/uaccess.h>
47763 +#include <asm/local.h>
47764
47765 #include "tty.h"
47766 #include "network.h"
47767 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47768 mutex_unlock(&tty->ipw_tty_mutex);
47769 return -ENODEV;
47770 }
47771 - if (tty->port.count == 0)
47772 + if (atomic_read(&tty->port.count) == 0)
47773 tty->tx_bytes_queued = 0;
47774
47775 - tty->port.count++;
47776 + atomic_inc(&tty->port.count);
47777
47778 tty->port.tty = linux_tty;
47779 linux_tty->driver_data = tty;
47780 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47781
47782 static void do_ipw_close(struct ipw_tty *tty)
47783 {
47784 - tty->port.count--;
47785 -
47786 - if (tty->port.count == 0) {
47787 + if (atomic_dec_return(&tty->port.count) == 0) {
47788 struct tty_struct *linux_tty = tty->port.tty;
47789
47790 if (linux_tty != NULL) {
47791 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47792 return;
47793
47794 mutex_lock(&tty->ipw_tty_mutex);
47795 - if (tty->port.count == 0) {
47796 + if (atomic_read(&tty->port.count) == 0) {
47797 mutex_unlock(&tty->ipw_tty_mutex);
47798 return;
47799 }
47800 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47801
47802 mutex_lock(&tty->ipw_tty_mutex);
47803
47804 - if (!tty->port.count) {
47805 + if (!atomic_read(&tty->port.count)) {
47806 mutex_unlock(&tty->ipw_tty_mutex);
47807 return;
47808 }
47809 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47810 return -ENODEV;
47811
47812 mutex_lock(&tty->ipw_tty_mutex);
47813 - if (!tty->port.count) {
47814 + if (!atomic_read(&tty->port.count)) {
47815 mutex_unlock(&tty->ipw_tty_mutex);
47816 return -EINVAL;
47817 }
47818 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47819 if (!tty)
47820 return -ENODEV;
47821
47822 - if (!tty->port.count)
47823 + if (!atomic_read(&tty->port.count))
47824 return -EINVAL;
47825
47826 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47827 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47828 if (!tty)
47829 return 0;
47830
47831 - if (!tty->port.count)
47832 + if (!atomic_read(&tty->port.count))
47833 return 0;
47834
47835 return tty->tx_bytes_queued;
47836 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47837 if (!tty)
47838 return -ENODEV;
47839
47840 - if (!tty->port.count)
47841 + if (!atomic_read(&tty->port.count))
47842 return -EINVAL;
47843
47844 return get_control_lines(tty);
47845 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47846 if (!tty)
47847 return -ENODEV;
47848
47849 - if (!tty->port.count)
47850 + if (!atomic_read(&tty->port.count))
47851 return -EINVAL;
47852
47853 return set_control_lines(tty, set, clear);
47854 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47855 if (!tty)
47856 return -ENODEV;
47857
47858 - if (!tty->port.count)
47859 + if (!atomic_read(&tty->port.count))
47860 return -EINVAL;
47861
47862 /* FIXME: Exactly how is the tty object locked here .. */
47863 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47864 * are gone */
47865 mutex_lock(&ttyj->ipw_tty_mutex);
47866 }
47867 - while (ttyj->port.count)
47868 + while (atomic_read(&ttyj->port.count))
47869 do_ipw_close(ttyj);
47870 ipwireless_disassociate_network_ttys(network,
47871 ttyj->channel_idx);
47872 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47873 index 1deaca4..c8582d4 100644
47874 --- a/drivers/tty/moxa.c
47875 +++ b/drivers/tty/moxa.c
47876 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47877 }
47878
47879 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47880 - ch->port.count++;
47881 + atomic_inc(&ch->port.count);
47882 tty->driver_data = ch;
47883 tty_port_tty_set(&ch->port, tty);
47884 mutex_lock(&ch->port.mutex);
47885 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47886 index 6422390..49003ac8 100644
47887 --- a/drivers/tty/n_gsm.c
47888 +++ b/drivers/tty/n_gsm.c
47889 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47890 spin_lock_init(&dlci->lock);
47891 mutex_init(&dlci->mutex);
47892 dlci->fifo = &dlci->_fifo;
47893 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47894 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47895 kfree(dlci);
47896 return NULL;
47897 }
47898 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47899 struct gsm_dlci *dlci = tty->driver_data;
47900 struct tty_port *port = &dlci->port;
47901
47902 - port->count++;
47903 + atomic_inc(&port->count);
47904 dlci_get(dlci);
47905 dlci_get(dlci->gsm->dlci[0]);
47906 mux_get(dlci->gsm);
47907 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47908 index 4bf0fc0..433bd58 100644
47909 --- a/drivers/tty/n_tty.c
47910 +++ b/drivers/tty/n_tty.c
47911 @@ -2217,6 +2217,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47912 {
47913 *ops = tty_ldisc_N_TTY;
47914 ops->owner = NULL;
47915 - ops->refcount = ops->flags = 0;
47916 + atomic_set(&ops->refcount, 0);
47917 + ops->flags = 0;
47918 }
47919 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47920 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47921 index abfd990..5ab5da9 100644
47922 --- a/drivers/tty/pty.c
47923 +++ b/drivers/tty/pty.c
47924 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
47925 panic("Couldn't register Unix98 pts driver");
47926
47927 /* Now create the /dev/ptmx special device */
47928 + pax_open_kernel();
47929 tty_default_fops(&ptmx_fops);
47930 - ptmx_fops.open = ptmx_open;
47931 + *(void **)&ptmx_fops.open = ptmx_open;
47932 + pax_close_kernel();
47933
47934 cdev_init(&ptmx_cdev, &ptmx_fops);
47935 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47936 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47937 index 354564e..fe50d9a 100644
47938 --- a/drivers/tty/rocket.c
47939 +++ b/drivers/tty/rocket.c
47940 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47941 tty->driver_data = info;
47942 tty_port_tty_set(port, tty);
47943
47944 - if (port->count++ == 0) {
47945 + if (atomic_inc_return(&port->count) == 1) {
47946 atomic_inc(&rp_num_ports_open);
47947
47948 #ifdef ROCKET_DEBUG_OPEN
47949 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47950 #endif
47951 }
47952 #ifdef ROCKET_DEBUG_OPEN
47953 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47954 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47955 #endif
47956
47957 /*
47958 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47959 spin_unlock_irqrestore(&info->port.lock, flags);
47960 return;
47961 }
47962 - if (info->port.count)
47963 + if (atomic_read(&info->port.count))
47964 atomic_dec(&rp_num_ports_open);
47965 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47966 spin_unlock_irqrestore(&info->port.lock, flags);
47967 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47968 index e2520ab..034e20b 100644
47969 --- a/drivers/tty/serial/ioc4_serial.c
47970 +++ b/drivers/tty/serial/ioc4_serial.c
47971 @@ -437,7 +437,7 @@ struct ioc4_soft {
47972 } is_intr_info[MAX_IOC4_INTR_ENTS];
47973
47974 /* Number of entries active in the above array */
47975 - atomic_t is_num_intrs;
47976 + atomic_unchecked_t is_num_intrs;
47977 } is_intr_type[IOC4_NUM_INTR_TYPES];
47978
47979 /* is_ir_lock must be held while
47980 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47981 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47982 || (type == IOC4_OTHER_INTR_TYPE)));
47983
47984 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47985 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
47986 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
47987
47988 /* Save off the lower level interrupt handler */
47989 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
47990
47991 soft = arg;
47992 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
47993 - num_intrs = (int)atomic_read(
47994 + num_intrs = (int)atomic_read_unchecked(
47995 &soft->is_intr_type[intr_type].is_num_intrs);
47996
47997 this_mir = this_ir = pending_intrs(soft, intr_type);
47998 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
47999 index 1002054..dd644a8 100644
48000 --- a/drivers/tty/serial/kgdboc.c
48001 +++ b/drivers/tty/serial/kgdboc.c
48002 @@ -24,8 +24,9 @@
48003 #define MAX_CONFIG_LEN 40
48004
48005 static struct kgdb_io kgdboc_io_ops;
48006 +static struct kgdb_io kgdboc_io_ops_console;
48007
48008 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48009 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48010 static int configured = -1;
48011
48012 static char config[MAX_CONFIG_LEN];
48013 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48014 kgdboc_unregister_kbd();
48015 if (configured == 1)
48016 kgdb_unregister_io_module(&kgdboc_io_ops);
48017 + else if (configured == 2)
48018 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48019 }
48020
48021 static int configure_kgdboc(void)
48022 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48023 int err;
48024 char *cptr = config;
48025 struct console *cons;
48026 + int is_console = 0;
48027
48028 err = kgdboc_option_setup(config);
48029 if (err || !strlen(config) || isspace(config[0]))
48030 goto noconfig;
48031
48032 err = -ENODEV;
48033 - kgdboc_io_ops.is_console = 0;
48034 kgdb_tty_driver = NULL;
48035
48036 kgdboc_use_kms = 0;
48037 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48038 int idx;
48039 if (cons->device && cons->device(cons, &idx) == p &&
48040 idx == tty_line) {
48041 - kgdboc_io_ops.is_console = 1;
48042 + is_console = 1;
48043 break;
48044 }
48045 cons = cons->next;
48046 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48047 kgdb_tty_line = tty_line;
48048
48049 do_register:
48050 - err = kgdb_register_io_module(&kgdboc_io_ops);
48051 + if (is_console) {
48052 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48053 + configured = 2;
48054 + } else {
48055 + err = kgdb_register_io_module(&kgdboc_io_ops);
48056 + configured = 1;
48057 + }
48058 if (err)
48059 goto noconfig;
48060
48061 @@ -205,8 +214,6 @@ do_register:
48062 if (err)
48063 goto nmi_con_failed;
48064
48065 - configured = 1;
48066 -
48067 return 0;
48068
48069 nmi_con_failed:
48070 @@ -223,7 +230,7 @@ noconfig:
48071 static int __init init_kgdboc(void)
48072 {
48073 /* Already configured? */
48074 - if (configured == 1)
48075 + if (configured >= 1)
48076 return 0;
48077
48078 return configure_kgdboc();
48079 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48080 if (config[len - 1] == '\n')
48081 config[len - 1] = '\0';
48082
48083 - if (configured == 1)
48084 + if (configured >= 1)
48085 cleanup_kgdboc();
48086
48087 /* Go and configure with the new params. */
48088 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48089 .post_exception = kgdboc_post_exp_handler,
48090 };
48091
48092 +static struct kgdb_io kgdboc_io_ops_console = {
48093 + .name = "kgdboc",
48094 + .read_char = kgdboc_get_char,
48095 + .write_char = kgdboc_put_char,
48096 + .pre_exception = kgdboc_pre_exp_handler,
48097 + .post_exception = kgdboc_post_exp_handler,
48098 + .is_console = 1
48099 +};
48100 +
48101 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48102 /* This is only available if kgdboc is a built in for early debugging */
48103 static int __init kgdboc_early_init(char *opt)
48104 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48105 index 2c6cfb3..048274e 100644
48106 --- a/drivers/tty/serial/msm_serial.c
48107 +++ b/drivers/tty/serial/msm_serial.c
48108 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
48109 .cons = MSM_CONSOLE,
48110 };
48111
48112 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48113 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48114
48115 static int __init msm_serial_probe(struct platform_device *pdev)
48116 {
48117 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48118 int irq;
48119
48120 if (pdev->id == -1)
48121 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48122 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48123
48124 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48125 return -ENXIO;
48126 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48127 index 376079b..d8de7aa 100644
48128 --- a/drivers/tty/serial/samsung.c
48129 +++ b/drivers/tty/serial/samsung.c
48130 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48131 }
48132 }
48133
48134 +static int s3c64xx_serial_startup(struct uart_port *port);
48135 static int s3c24xx_serial_startup(struct uart_port *port)
48136 {
48137 struct s3c24xx_uart_port *ourport = to_ourport(port);
48138 int ret;
48139
48140 + /* Startup sequence is different for s3c64xx and higher SoC's */
48141 + if (s3c24xx_serial_has_interrupt_mask(port))
48142 + return s3c64xx_serial_startup(port);
48143 +
48144 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48145 port->mapbase, port->membase);
48146
48147 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48148 /* setup info for port */
48149 port->dev = &platdev->dev;
48150
48151 - /* Startup sequence is different for s3c64xx and higher SoC's */
48152 - if (s3c24xx_serial_has_interrupt_mask(port))
48153 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48154 -
48155 port->uartclk = 1;
48156
48157 if (cfg->uart_flags & UPF_CONS_FLOW) {
48158 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48159 index 28cdd28..56f1d60 100644
48160 --- a/drivers/tty/serial/serial_core.c
48161 +++ b/drivers/tty/serial/serial_core.c
48162 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48163 uart_flush_buffer(tty);
48164 uart_shutdown(tty, state);
48165 spin_lock_irqsave(&port->lock, flags);
48166 - port->count = 0;
48167 + atomic_set(&port->count, 0);
48168 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48169 spin_unlock_irqrestore(&port->lock, flags);
48170 tty_port_tty_set(port, NULL);
48171 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48172 goto end;
48173 }
48174
48175 - port->count++;
48176 + atomic_inc(&port->count);
48177 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48178 retval = -ENXIO;
48179 goto err_dec_count;
48180 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48181 /*
48182 * Make sure the device is in D0 state.
48183 */
48184 - if (port->count == 1)
48185 + if (atomic_read(&port->count) == 1)
48186 uart_change_pm(state, UART_PM_STATE_ON);
48187
48188 /*
48189 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48190 end:
48191 return retval;
48192 err_dec_count:
48193 - port->count--;
48194 + atomic_inc(&port->count);
48195 mutex_unlock(&port->mutex);
48196 goto end;
48197 }
48198 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48199 index 8eaf1ab..85c030d 100644
48200 --- a/drivers/tty/synclink.c
48201 +++ b/drivers/tty/synclink.c
48202 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48203
48204 if (debug_level >= DEBUG_LEVEL_INFO)
48205 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48206 - __FILE__,__LINE__, info->device_name, info->port.count);
48207 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48208
48209 if (tty_port_close_start(&info->port, tty, filp) == 0)
48210 goto cleanup;
48211 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48212 cleanup:
48213 if (debug_level >= DEBUG_LEVEL_INFO)
48214 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48215 - tty->driver->name, info->port.count);
48216 + tty->driver->name, atomic_read(&info->port.count));
48217
48218 } /* end of mgsl_close() */
48219
48220 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48221
48222 mgsl_flush_buffer(tty);
48223 shutdown(info);
48224 -
48225 - info->port.count = 0;
48226 +
48227 + atomic_set(&info->port.count, 0);
48228 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48229 info->port.tty = NULL;
48230
48231 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48232
48233 if (debug_level >= DEBUG_LEVEL_INFO)
48234 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48235 - __FILE__,__LINE__, tty->driver->name, port->count );
48236 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48237
48238 spin_lock_irqsave(&info->irq_spinlock, flags);
48239 if (!tty_hung_up_p(filp)) {
48240 extra_count = true;
48241 - port->count--;
48242 + atomic_dec(&port->count);
48243 }
48244 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48245 port->blocked_open++;
48246 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48247
48248 if (debug_level >= DEBUG_LEVEL_INFO)
48249 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48250 - __FILE__,__LINE__, tty->driver->name, port->count );
48251 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48252
48253 tty_unlock(tty);
48254 schedule();
48255 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48256
48257 /* FIXME: Racy on hangup during close wait */
48258 if (extra_count)
48259 - port->count++;
48260 + atomic_inc(&port->count);
48261 port->blocked_open--;
48262
48263 if (debug_level >= DEBUG_LEVEL_INFO)
48264 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48265 - __FILE__,__LINE__, tty->driver->name, port->count );
48266 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48267
48268 if (!retval)
48269 port->flags |= ASYNC_NORMAL_ACTIVE;
48270 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48271
48272 if (debug_level >= DEBUG_LEVEL_INFO)
48273 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48274 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48275 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48276
48277 /* If port is closing, signal caller to try again */
48278 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48279 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48280 spin_unlock_irqrestore(&info->netlock, flags);
48281 goto cleanup;
48282 }
48283 - info->port.count++;
48284 + atomic_inc(&info->port.count);
48285 spin_unlock_irqrestore(&info->netlock, flags);
48286
48287 - if (info->port.count == 1) {
48288 + if (atomic_read(&info->port.count) == 1) {
48289 /* 1st open on this device, init hardware */
48290 retval = startup(info);
48291 if (retval < 0)
48292 @@ -3446,8 +3446,8 @@ cleanup:
48293 if (retval) {
48294 if (tty->count == 1)
48295 info->port.tty = NULL; /* tty layer will release tty struct */
48296 - if(info->port.count)
48297 - info->port.count--;
48298 + if (atomic_read(&info->port.count))
48299 + atomic_dec(&info->port.count);
48300 }
48301
48302 return retval;
48303 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48304 unsigned short new_crctype;
48305
48306 /* return error if TTY interface open */
48307 - if (info->port.count)
48308 + if (atomic_read(&info->port.count))
48309 return -EBUSY;
48310
48311 switch (encoding)
48312 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48313
48314 /* arbitrate between network and tty opens */
48315 spin_lock_irqsave(&info->netlock, flags);
48316 - if (info->port.count != 0 || info->netcount != 0) {
48317 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48318 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48319 spin_unlock_irqrestore(&info->netlock, flags);
48320 return -EBUSY;
48321 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48322 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48323
48324 /* return error if TTY interface open */
48325 - if (info->port.count)
48326 + if (atomic_read(&info->port.count))
48327 return -EBUSY;
48328
48329 if (cmd != SIOCWANDEV)
48330 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48331 index 1abf946..1ee34fc 100644
48332 --- a/drivers/tty/synclink_gt.c
48333 +++ b/drivers/tty/synclink_gt.c
48334 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48335 tty->driver_data = info;
48336 info->port.tty = tty;
48337
48338 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48339 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48340
48341 /* If port is closing, signal caller to try again */
48342 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48343 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48344 mutex_unlock(&info->port.mutex);
48345 goto cleanup;
48346 }
48347 - info->port.count++;
48348 + atomic_inc(&info->port.count);
48349 spin_unlock_irqrestore(&info->netlock, flags);
48350
48351 - if (info->port.count == 1) {
48352 + if (atomic_read(&info->port.count) == 1) {
48353 /* 1st open on this device, init hardware */
48354 retval = startup(info);
48355 if (retval < 0) {
48356 @@ -715,8 +715,8 @@ cleanup:
48357 if (retval) {
48358 if (tty->count == 1)
48359 info->port.tty = NULL; /* tty layer will release tty struct */
48360 - if(info->port.count)
48361 - info->port.count--;
48362 + if(atomic_read(&info->port.count))
48363 + atomic_dec(&info->port.count);
48364 }
48365
48366 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48367 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48368
48369 if (sanity_check(info, tty->name, "close"))
48370 return;
48371 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48372 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48373
48374 if (tty_port_close_start(&info->port, tty, filp) == 0)
48375 goto cleanup;
48376 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48377 tty_port_close_end(&info->port, tty);
48378 info->port.tty = NULL;
48379 cleanup:
48380 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48381 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48382 }
48383
48384 static void hangup(struct tty_struct *tty)
48385 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48386 shutdown(info);
48387
48388 spin_lock_irqsave(&info->port.lock, flags);
48389 - info->port.count = 0;
48390 + atomic_set(&info->port.count, 0);
48391 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48392 info->port.tty = NULL;
48393 spin_unlock_irqrestore(&info->port.lock, flags);
48394 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48395 unsigned short new_crctype;
48396
48397 /* return error if TTY interface open */
48398 - if (info->port.count)
48399 + if (atomic_read(&info->port.count))
48400 return -EBUSY;
48401
48402 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48403 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48404
48405 /* arbitrate between network and tty opens */
48406 spin_lock_irqsave(&info->netlock, flags);
48407 - if (info->port.count != 0 || info->netcount != 0) {
48408 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48409 DBGINFO(("%s hdlc_open busy\n", dev->name));
48410 spin_unlock_irqrestore(&info->netlock, flags);
48411 return -EBUSY;
48412 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48413 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48414
48415 /* return error if TTY interface open */
48416 - if (info->port.count)
48417 + if (atomic_read(&info->port.count))
48418 return -EBUSY;
48419
48420 if (cmd != SIOCWANDEV)
48421 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48422 if (port == NULL)
48423 continue;
48424 spin_lock(&port->lock);
48425 - if ((port->port.count || port->netcount) &&
48426 + if ((atomic_read(&port->port.count) || port->netcount) &&
48427 port->pending_bh && !port->bh_running &&
48428 !port->bh_requested) {
48429 DBGISR(("%s bh queued\n", port->device_name));
48430 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48431 spin_lock_irqsave(&info->lock, flags);
48432 if (!tty_hung_up_p(filp)) {
48433 extra_count = true;
48434 - port->count--;
48435 + atomic_dec(&port->count);
48436 }
48437 spin_unlock_irqrestore(&info->lock, flags);
48438 port->blocked_open++;
48439 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48440 remove_wait_queue(&port->open_wait, &wait);
48441
48442 if (extra_count)
48443 - port->count++;
48444 + atomic_inc(&port->count);
48445 port->blocked_open--;
48446
48447 if (!retval)
48448 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48449 index dc6e969..5dc8786 100644
48450 --- a/drivers/tty/synclinkmp.c
48451 +++ b/drivers/tty/synclinkmp.c
48452 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48453
48454 if (debug_level >= DEBUG_LEVEL_INFO)
48455 printk("%s(%d):%s open(), old ref count = %d\n",
48456 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48457 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48458
48459 /* If port is closing, signal caller to try again */
48460 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48461 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48462 spin_unlock_irqrestore(&info->netlock, flags);
48463 goto cleanup;
48464 }
48465 - info->port.count++;
48466 + atomic_inc(&info->port.count);
48467 spin_unlock_irqrestore(&info->netlock, flags);
48468
48469 - if (info->port.count == 1) {
48470 + if (atomic_read(&info->port.count) == 1) {
48471 /* 1st open on this device, init hardware */
48472 retval = startup(info);
48473 if (retval < 0)
48474 @@ -796,8 +796,8 @@ cleanup:
48475 if (retval) {
48476 if (tty->count == 1)
48477 info->port.tty = NULL; /* tty layer will release tty struct */
48478 - if(info->port.count)
48479 - info->port.count--;
48480 + if(atomic_read(&info->port.count))
48481 + atomic_dec(&info->port.count);
48482 }
48483
48484 return retval;
48485 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48486
48487 if (debug_level >= DEBUG_LEVEL_INFO)
48488 printk("%s(%d):%s close() entry, count=%d\n",
48489 - __FILE__,__LINE__, info->device_name, info->port.count);
48490 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48491
48492 if (tty_port_close_start(&info->port, tty, filp) == 0)
48493 goto cleanup;
48494 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48495 cleanup:
48496 if (debug_level >= DEBUG_LEVEL_INFO)
48497 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48498 - tty->driver->name, info->port.count);
48499 + tty->driver->name, atomic_read(&info->port.count));
48500 }
48501
48502 /* Called by tty_hangup() when a hangup is signaled.
48503 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48504 shutdown(info);
48505
48506 spin_lock_irqsave(&info->port.lock, flags);
48507 - info->port.count = 0;
48508 + atomic_set(&info->port.count, 0);
48509 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48510 info->port.tty = NULL;
48511 spin_unlock_irqrestore(&info->port.lock, flags);
48512 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48513 unsigned short new_crctype;
48514
48515 /* return error if TTY interface open */
48516 - if (info->port.count)
48517 + if (atomic_read(&info->port.count))
48518 return -EBUSY;
48519
48520 switch (encoding)
48521 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48522
48523 /* arbitrate between network and tty opens */
48524 spin_lock_irqsave(&info->netlock, flags);
48525 - if (info->port.count != 0 || info->netcount != 0) {
48526 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48527 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48528 spin_unlock_irqrestore(&info->netlock, flags);
48529 return -EBUSY;
48530 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48531 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48532
48533 /* return error if TTY interface open */
48534 - if (info->port.count)
48535 + if (atomic_read(&info->port.count))
48536 return -EBUSY;
48537
48538 if (cmd != SIOCWANDEV)
48539 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48540 * do not request bottom half processing if the
48541 * device is not open in a normal mode.
48542 */
48543 - if ( port && (port->port.count || port->netcount) &&
48544 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48545 port->pending_bh && !port->bh_running &&
48546 !port->bh_requested ) {
48547 if ( debug_level >= DEBUG_LEVEL_ISR )
48548 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48549
48550 if (debug_level >= DEBUG_LEVEL_INFO)
48551 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48552 - __FILE__,__LINE__, tty->driver->name, port->count );
48553 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48554
48555 spin_lock_irqsave(&info->lock, flags);
48556 if (!tty_hung_up_p(filp)) {
48557 extra_count = true;
48558 - port->count--;
48559 + atomic_dec(&port->count);
48560 }
48561 spin_unlock_irqrestore(&info->lock, flags);
48562 port->blocked_open++;
48563 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48564
48565 if (debug_level >= DEBUG_LEVEL_INFO)
48566 printk("%s(%d):%s block_til_ready() count=%d\n",
48567 - __FILE__,__LINE__, tty->driver->name, port->count );
48568 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48569
48570 tty_unlock(tty);
48571 schedule();
48572 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48573 remove_wait_queue(&port->open_wait, &wait);
48574
48575 if (extra_count)
48576 - port->count++;
48577 + atomic_inc(&port->count);
48578 port->blocked_open--;
48579
48580 if (debug_level >= DEBUG_LEVEL_INFO)
48581 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48582 - __FILE__,__LINE__, tty->driver->name, port->count );
48583 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48584
48585 if (!retval)
48586 port->flags |= ASYNC_NORMAL_ACTIVE;
48587 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48588 index d5cc3ac..3263411 100644
48589 --- a/drivers/tty/sysrq.c
48590 +++ b/drivers/tty/sysrq.c
48591 @@ -1033,7 +1033,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48592 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48593 size_t count, loff_t *ppos)
48594 {
48595 - if (count) {
48596 + if (count && capable(CAP_SYS_ADMIN)) {
48597 char c;
48598
48599 if (get_user(c, buf))
48600 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48601 index 20689b9..7fd3a31 100644
48602 --- a/drivers/tty/tty_io.c
48603 +++ b/drivers/tty/tty_io.c
48604 @@ -3468,7 +3468,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48605
48606 void tty_default_fops(struct file_operations *fops)
48607 {
48608 - *fops = tty_fops;
48609 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48610 }
48611
48612 /*
48613 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48614 index 1afe192..73d2c20 100644
48615 --- a/drivers/tty/tty_ldisc.c
48616 +++ b/drivers/tty/tty_ldisc.c
48617 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48618 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48619 tty_ldiscs[disc] = new_ldisc;
48620 new_ldisc->num = disc;
48621 - new_ldisc->refcount = 0;
48622 + atomic_set(&new_ldisc->refcount, 0);
48623 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48624
48625 return ret;
48626 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48627 return -EINVAL;
48628
48629 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48630 - if (tty_ldiscs[disc]->refcount)
48631 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48632 ret = -EBUSY;
48633 else
48634 tty_ldiscs[disc] = NULL;
48635 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48636 if (ldops) {
48637 ret = ERR_PTR(-EAGAIN);
48638 if (try_module_get(ldops->owner)) {
48639 - ldops->refcount++;
48640 + atomic_inc(&ldops->refcount);
48641 ret = ldops;
48642 }
48643 }
48644 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48645 unsigned long flags;
48646
48647 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48648 - ldops->refcount--;
48649 + atomic_dec(&ldops->refcount);
48650 module_put(ldops->owner);
48651 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48652 }
48653 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48654 /* unreleased reader reference(s) will cause this WARN */
48655 WARN_ON(!atomic_dec_and_test(&ld->users));
48656
48657 - ld->ops->refcount--;
48658 + atomic_dec(&ld->ops->refcount);
48659 module_put(ld->ops->owner);
48660 kfree(ld);
48661 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48662 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48663 index f597e88..b7f68ed 100644
48664 --- a/drivers/tty/tty_port.c
48665 +++ b/drivers/tty/tty_port.c
48666 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48667 unsigned long flags;
48668
48669 spin_lock_irqsave(&port->lock, flags);
48670 - port->count = 0;
48671 + atomic_set(&port->count, 0);
48672 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48673 tty = port->tty;
48674 if (tty)
48675 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48676 /* The port lock protects the port counts */
48677 spin_lock_irqsave(&port->lock, flags);
48678 if (!tty_hung_up_p(filp))
48679 - port->count--;
48680 + atomic_dec(&port->count);
48681 port->blocked_open++;
48682 spin_unlock_irqrestore(&port->lock, flags);
48683
48684 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48685 we must not mess that up further */
48686 spin_lock_irqsave(&port->lock, flags);
48687 if (!tty_hung_up_p(filp))
48688 - port->count++;
48689 + atomic_inc(&port->count);
48690 port->blocked_open--;
48691 if (retval == 0)
48692 port->flags |= ASYNC_NORMAL_ACTIVE;
48693 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48694 return 0;
48695 }
48696
48697 - if (tty->count == 1 && port->count != 1) {
48698 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48699 printk(KERN_WARNING
48700 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48701 - port->count);
48702 - port->count = 1;
48703 + atomic_read(&port->count));
48704 + atomic_set(&port->count, 1);
48705 }
48706 - if (--port->count < 0) {
48707 + if (atomic_dec_return(&port->count) < 0) {
48708 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48709 - port->count);
48710 - port->count = 0;
48711 + atomic_read(&port->count));
48712 + atomic_set(&port->count, 0);
48713 }
48714
48715 - if (port->count) {
48716 + if (atomic_read(&port->count)) {
48717 spin_unlock_irqrestore(&port->lock, flags);
48718 if (port->ops->drop)
48719 port->ops->drop(port);
48720 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48721 {
48722 spin_lock_irq(&port->lock);
48723 if (!tty_hung_up_p(filp))
48724 - ++port->count;
48725 + atomic_inc(&port->count);
48726 spin_unlock_irq(&port->lock);
48727 tty_port_tty_set(port, tty);
48728
48729 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48730 index a9af1b9a..1e08e7f 100644
48731 --- a/drivers/tty/vt/keyboard.c
48732 +++ b/drivers/tty/vt/keyboard.c
48733 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48734 kbd->kbdmode == VC_OFF) &&
48735 value != KVAL(K_SAK))
48736 return; /* SAK is allowed even in raw mode */
48737 +
48738 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48739 + {
48740 + void *func = fn_handler[value];
48741 + if (func == fn_show_state || func == fn_show_ptregs ||
48742 + func == fn_show_mem)
48743 + return;
48744 + }
48745 +#endif
48746 +
48747 fn_handler[value](vc);
48748 }
48749
48750 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48751 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48752 return -EFAULT;
48753
48754 - if (!capable(CAP_SYS_TTY_CONFIG))
48755 - perm = 0;
48756 -
48757 switch (cmd) {
48758 case KDGKBENT:
48759 /* Ensure another thread doesn't free it under us */
48760 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48761 spin_unlock_irqrestore(&kbd_event_lock, flags);
48762 return put_user(val, &user_kbe->kb_value);
48763 case KDSKBENT:
48764 + if (!capable(CAP_SYS_TTY_CONFIG))
48765 + perm = 0;
48766 +
48767 if (!perm)
48768 return -EPERM;
48769 if (!i && v == K_NOSUCHMAP) {
48770 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48771 int i, j, k;
48772 int ret;
48773
48774 - if (!capable(CAP_SYS_TTY_CONFIG))
48775 - perm = 0;
48776 -
48777 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48778 if (!kbs) {
48779 ret = -ENOMEM;
48780 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48781 kfree(kbs);
48782 return ((p && *p) ? -EOVERFLOW : 0);
48783 case KDSKBSENT:
48784 + if (!capable(CAP_SYS_TTY_CONFIG))
48785 + perm = 0;
48786 +
48787 if (!perm) {
48788 ret = -EPERM;
48789 goto reterr;
48790 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48791 index 4bf4bb2..52ae8c7 100644
48792 --- a/drivers/uio/uio.c
48793 +++ b/drivers/uio/uio.c
48794 @@ -25,6 +25,7 @@
48795 #include <linux/kobject.h>
48796 #include <linux/cdev.h>
48797 #include <linux/uio_driver.h>
48798 +#include <asm/local.h>
48799
48800 #define UIO_MAX_DEVICES (1U << MINORBITS)
48801
48802 @@ -32,10 +33,10 @@ struct uio_device {
48803 struct module *owner;
48804 struct device *dev;
48805 int minor;
48806 - atomic_t event;
48807 + atomic_unchecked_t event;
48808 struct fasync_struct *async_queue;
48809 wait_queue_head_t wait;
48810 - int vma_count;
48811 + local_t vma_count;
48812 struct uio_info *info;
48813 struct kobject *map_dir;
48814 struct kobject *portio_dir;
48815 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
48816 struct device_attribute *attr, char *buf)
48817 {
48818 struct uio_device *idev = dev_get_drvdata(dev);
48819 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48820 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48821 }
48822
48823 static struct device_attribute uio_class_attributes[] = {
48824 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
48825 {
48826 struct uio_device *idev = info->uio_dev;
48827
48828 - atomic_inc(&idev->event);
48829 + atomic_inc_unchecked(&idev->event);
48830 wake_up_interruptible(&idev->wait);
48831 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48832 }
48833 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48834 }
48835
48836 listener->dev = idev;
48837 - listener->event_count = atomic_read(&idev->event);
48838 + listener->event_count = atomic_read_unchecked(&idev->event);
48839 filep->private_data = listener;
48840
48841 if (idev->info->open) {
48842 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48843 return -EIO;
48844
48845 poll_wait(filep, &idev->wait, wait);
48846 - if (listener->event_count != atomic_read(&idev->event))
48847 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48848 return POLLIN | POLLRDNORM;
48849 return 0;
48850 }
48851 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48852 do {
48853 set_current_state(TASK_INTERRUPTIBLE);
48854
48855 - event_count = atomic_read(&idev->event);
48856 + event_count = atomic_read_unchecked(&idev->event);
48857 if (event_count != listener->event_count) {
48858 if (copy_to_user(buf, &event_count, count))
48859 retval = -EFAULT;
48860 @@ -584,9 +585,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
48861 static int uio_find_mem_index(struct vm_area_struct *vma)
48862 {
48863 struct uio_device *idev = vma->vm_private_data;
48864 + unsigned long size;
48865
48866 if (vma->vm_pgoff < MAX_UIO_MAPS) {
48867 - if (idev->info->mem[vma->vm_pgoff].size == 0)
48868 + size = idev->info->mem[vma->vm_pgoff].size;
48869 + if (size == 0)
48870 + return -1;
48871 + if (vma->vm_end - vma->vm_start > size)
48872 return -1;
48873 return (int)vma->vm_pgoff;
48874 }
48875 @@ -596,13 +601,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
48876 static void uio_vma_open(struct vm_area_struct *vma)
48877 {
48878 struct uio_device *idev = vma->vm_private_data;
48879 - idev->vma_count++;
48880 + local_inc(&idev->vma_count);
48881 }
48882
48883 static void uio_vma_close(struct vm_area_struct *vma)
48884 {
48885 struct uio_device *idev = vma->vm_private_data;
48886 - idev->vma_count--;
48887 + local_dec(&idev->vma_count);
48888 }
48889
48890 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
48891 @@ -830,7 +835,7 @@ int __uio_register_device(struct module *owner,
48892 idev->owner = owner;
48893 idev->info = info;
48894 init_waitqueue_head(&idev->wait);
48895 - atomic_set(&idev->event, 0);
48896 + atomic_set_unchecked(&idev->event, 0);
48897
48898 ret = uio_get_minor(idev);
48899 if (ret)
48900 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48901 index 8a7eb77..c00402f 100644
48902 --- a/drivers/usb/atm/cxacru.c
48903 +++ b/drivers/usb/atm/cxacru.c
48904 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48905 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48906 if (ret < 2)
48907 return -EINVAL;
48908 - if (index < 0 || index > 0x7f)
48909 + if (index > 0x7f)
48910 return -EINVAL;
48911 pos += tmp;
48912
48913 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48914 index 5e0d33a..cc10579 100644
48915 --- a/drivers/usb/atm/usbatm.c
48916 +++ b/drivers/usb/atm/usbatm.c
48917 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48918 if (printk_ratelimit())
48919 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48920 __func__, vpi, vci);
48921 - atomic_inc(&vcc->stats->rx_err);
48922 + atomic_inc_unchecked(&vcc->stats->rx_err);
48923 return;
48924 }
48925
48926 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48927 if (length > ATM_MAX_AAL5_PDU) {
48928 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48929 __func__, length, vcc);
48930 - atomic_inc(&vcc->stats->rx_err);
48931 + atomic_inc_unchecked(&vcc->stats->rx_err);
48932 goto out;
48933 }
48934
48935 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48936 if (sarb->len < pdu_length) {
48937 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48938 __func__, pdu_length, sarb->len, vcc);
48939 - atomic_inc(&vcc->stats->rx_err);
48940 + atomic_inc_unchecked(&vcc->stats->rx_err);
48941 goto out;
48942 }
48943
48944 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48945 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48946 __func__, vcc);
48947 - atomic_inc(&vcc->stats->rx_err);
48948 + atomic_inc_unchecked(&vcc->stats->rx_err);
48949 goto out;
48950 }
48951
48952 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48953 if (printk_ratelimit())
48954 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48955 __func__, length);
48956 - atomic_inc(&vcc->stats->rx_drop);
48957 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48958 goto out;
48959 }
48960
48961 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48962
48963 vcc->push(vcc, skb);
48964
48965 - atomic_inc(&vcc->stats->rx);
48966 + atomic_inc_unchecked(&vcc->stats->rx);
48967 out:
48968 skb_trim(sarb, 0);
48969 }
48970 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
48971 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
48972
48973 usbatm_pop(vcc, skb);
48974 - atomic_inc(&vcc->stats->tx);
48975 + atomic_inc_unchecked(&vcc->stats->tx);
48976
48977 skb = skb_dequeue(&instance->sndqueue);
48978 }
48979 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
48980 if (!left--)
48981 return sprintf(page,
48982 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
48983 - atomic_read(&atm_dev->stats.aal5.tx),
48984 - atomic_read(&atm_dev->stats.aal5.tx_err),
48985 - atomic_read(&atm_dev->stats.aal5.rx),
48986 - atomic_read(&atm_dev->stats.aal5.rx_err),
48987 - atomic_read(&atm_dev->stats.aal5.rx_drop));
48988 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
48989 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
48990 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
48991 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
48992 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
48993
48994 if (!left--) {
48995 if (instance->disconnected)
48996 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
48997 index 2a3bbdf..91d72cf 100644
48998 --- a/drivers/usb/core/devices.c
48999 +++ b/drivers/usb/core/devices.c
49000 @@ -126,7 +126,7 @@ static const char format_endpt[] =
49001 * time it gets called.
49002 */
49003 static struct device_connect_event {
49004 - atomic_t count;
49005 + atomic_unchecked_t count;
49006 wait_queue_head_t wait;
49007 } device_event = {
49008 .count = ATOMIC_INIT(1),
49009 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49010
49011 void usbfs_conn_disc_event(void)
49012 {
49013 - atomic_add(2, &device_event.count);
49014 + atomic_add_unchecked(2, &device_event.count);
49015 wake_up(&device_event.wait);
49016 }
49017
49018 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49019
49020 poll_wait(file, &device_event.wait, wait);
49021
49022 - event_count = atomic_read(&device_event.count);
49023 + event_count = atomic_read_unchecked(&device_event.count);
49024 if (file->f_version != event_count) {
49025 file->f_version = event_count;
49026 return POLLIN | POLLRDNORM;
49027 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49028 index 014dc99..4d25fd7 100644
49029 --- a/drivers/usb/core/hcd.c
49030 +++ b/drivers/usb/core/hcd.c
49031 @@ -1551,7 +1551,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49032 */
49033 usb_get_urb(urb);
49034 atomic_inc(&urb->use_count);
49035 - atomic_inc(&urb->dev->urbnum);
49036 + atomic_inc_unchecked(&urb->dev->urbnum);
49037 usbmon_urb_submit(&hcd->self, urb);
49038
49039 /* NOTE requirements on root-hub callers (usbfs and the hub
49040 @@ -1578,7 +1578,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49041 urb->hcpriv = NULL;
49042 INIT_LIST_HEAD(&urb->urb_list);
49043 atomic_dec(&urb->use_count);
49044 - atomic_dec(&urb->dev->urbnum);
49045 + atomic_dec_unchecked(&urb->dev->urbnum);
49046 if (atomic_read(&urb->reject))
49047 wake_up(&usb_kill_urb_queue);
49048 usb_put_urb(urb);
49049 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49050 index 17c3785..deffb11 100644
49051 --- a/drivers/usb/core/hub.c
49052 +++ b/drivers/usb/core/hub.c
49053 @@ -27,6 +27,7 @@
49054 #include <linux/freezer.h>
49055 #include <linux/random.h>
49056 #include <linux/pm_qos.h>
49057 +#include <linux/grsecurity.h>
49058
49059 #include <asm/uaccess.h>
49060 #include <asm/byteorder.h>
49061 @@ -4421,6 +4422,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49062 goto done;
49063 return;
49064 }
49065 +
49066 + if (gr_handle_new_usb())
49067 + goto done;
49068 +
49069 if (hub_is_superspeed(hub->hdev))
49070 unit_load = 150;
49071 else
49072 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49073 index e7ee1e4..1dfc9ea4 100644
49074 --- a/drivers/usb/core/message.c
49075 +++ b/drivers/usb/core/message.c
49076 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49077 * method can wait for it to complete. Since you don't have a handle on the
49078 * URB used, you can't cancel the request.
49079 */
49080 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49081 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49082 __u8 requesttype, __u16 value, __u16 index, void *data,
49083 __u16 size, int timeout)
49084 {
49085 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49086 index d9284b9..17023c7 100644
49087 --- a/drivers/usb/core/sysfs.c
49088 +++ b/drivers/usb/core/sysfs.c
49089 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
49090 struct usb_device *udev;
49091
49092 udev = to_usb_device(dev);
49093 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49094 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49095 }
49096 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
49097
49098 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49099 index 7dad603..350f7a9 100644
49100 --- a/drivers/usb/core/usb.c
49101 +++ b/drivers/usb/core/usb.c
49102 @@ -422,7 +422,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49103 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49104 dev->state = USB_STATE_ATTACHED;
49105 dev->lpm_disable_count = 1;
49106 - atomic_set(&dev->urbnum, 0);
49107 + atomic_set_unchecked(&dev->urbnum, 0);
49108
49109 INIT_LIST_HEAD(&dev->ep0.urb_list);
49110 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49111 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49112 index 14d28d6..5f511ac 100644
49113 --- a/drivers/usb/dwc3/gadget.c
49114 +++ b/drivers/usb/dwc3/gadget.c
49115 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49116 if (!usb_endpoint_xfer_isoc(desc))
49117 return 0;
49118
49119 - memset(&trb_link, 0, sizeof(trb_link));
49120 -
49121 /* Link TRB for ISOC. The HWO bit is never reset */
49122 trb_st_hw = &dep->trb_pool[0];
49123
49124 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49125 index 5e29dde..eca992f 100644
49126 --- a/drivers/usb/early/ehci-dbgp.c
49127 +++ b/drivers/usb/early/ehci-dbgp.c
49128 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49129
49130 #ifdef CONFIG_KGDB
49131 static struct kgdb_io kgdbdbgp_io_ops;
49132 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49133 +static struct kgdb_io kgdbdbgp_io_ops_console;
49134 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49135 #else
49136 #define dbgp_kgdb_mode (0)
49137 #endif
49138 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49139 .write_char = kgdbdbgp_write_char,
49140 };
49141
49142 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49143 + .name = "kgdbdbgp",
49144 + .read_char = kgdbdbgp_read_char,
49145 + .write_char = kgdbdbgp_write_char,
49146 + .is_console = 1
49147 +};
49148 +
49149 static int kgdbdbgp_wait_time;
49150
49151 static int __init kgdbdbgp_parse_config(char *str)
49152 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49153 ptr++;
49154 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49155 }
49156 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49157 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49158 + if (early_dbgp_console.index != -1)
49159 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49160 + else
49161 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49162
49163 return 0;
49164 }
49165 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49166 index b369292..9f3ba40 100644
49167 --- a/drivers/usb/gadget/u_serial.c
49168 +++ b/drivers/usb/gadget/u_serial.c
49169 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49170 spin_lock_irq(&port->port_lock);
49171
49172 /* already open? Great. */
49173 - if (port->port.count) {
49174 + if (atomic_read(&port->port.count)) {
49175 status = 0;
49176 - port->port.count++;
49177 + atomic_inc(&port->port.count);
49178
49179 /* currently opening/closing? wait ... */
49180 } else if (port->openclose) {
49181 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49182 tty->driver_data = port;
49183 port->port.tty = tty;
49184
49185 - port->port.count = 1;
49186 + atomic_set(&port->port.count, 1);
49187 port->openclose = false;
49188
49189 /* if connected, start the I/O stream */
49190 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49191
49192 spin_lock_irq(&port->port_lock);
49193
49194 - if (port->port.count != 1) {
49195 - if (port->port.count == 0)
49196 + if (atomic_read(&port->port.count) != 1) {
49197 + if (atomic_read(&port->port.count) == 0)
49198 WARN_ON(1);
49199 else
49200 - --port->port.count;
49201 + atomic_dec(&port->port.count);
49202 goto exit;
49203 }
49204
49205 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49206 * and sleep if necessary
49207 */
49208 port->openclose = true;
49209 - port->port.count = 0;
49210 + atomic_set(&port->port.count, 0);
49211
49212 gser = port->port_usb;
49213 if (gser && gser->disconnect)
49214 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49215 int cond;
49216
49217 spin_lock_irq(&port->port_lock);
49218 - cond = (port->port.count == 0) && !port->openclose;
49219 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49220 spin_unlock_irq(&port->port_lock);
49221 return cond;
49222 }
49223 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49224 /* if it's already open, start I/O ... and notify the serial
49225 * protocol about open/close status (connect/disconnect).
49226 */
49227 - if (port->port.count) {
49228 + if (atomic_read(&port->port.count)) {
49229 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49230 gs_start_io(port);
49231 if (gser->connect)
49232 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49233
49234 port->port_usb = NULL;
49235 gser->ioport = NULL;
49236 - if (port->port.count > 0 || port->openclose) {
49237 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49238 wake_up_interruptible(&port->drain_wait);
49239 if (port->port.tty)
49240 tty_hangup(port->port.tty);
49241 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49242
49243 /* finally, free any unused/unusable I/O buffers */
49244 spin_lock_irqsave(&port->port_lock, flags);
49245 - if (port->port.count == 0 && !port->openclose)
49246 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49247 gs_buf_free(&port->port_write_buf);
49248 gs_free_requests(gser->out, &port->read_pool, NULL);
49249 gs_free_requests(gser->out, &port->read_queue, NULL);
49250 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49251 index ba6a5d6..f88f7f3 100644
49252 --- a/drivers/usb/misc/appledisplay.c
49253 +++ b/drivers/usb/misc/appledisplay.c
49254 @@ -83,7 +83,7 @@ struct appledisplay {
49255 spinlock_t lock;
49256 };
49257
49258 -static atomic_t count_displays = ATOMIC_INIT(0);
49259 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49260 static struct workqueue_struct *wq;
49261
49262 static void appledisplay_complete(struct urb *urb)
49263 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49264
49265 /* Register backlight device */
49266 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49267 - atomic_inc_return(&count_displays) - 1);
49268 + atomic_inc_return_unchecked(&count_displays) - 1);
49269 memset(&props, 0, sizeof(struct backlight_properties));
49270 props.type = BACKLIGHT_RAW;
49271 props.max_brightness = 0xff;
49272 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49273 index afb50ea..6b837ab 100644
49274 --- a/drivers/usb/serial/console.c
49275 +++ b/drivers/usb/serial/console.c
49276 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49277
49278 info->port = port;
49279
49280 - ++port->port.count;
49281 + atomic_inc(&port->port.count);
49282 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49283 if (serial->type->set_termios) {
49284 /*
49285 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49286 }
49287 /* Now that any required fake tty operations are completed restore
49288 * the tty port count */
49289 - --port->port.count;
49290 + atomic_dec(&port->port.count);
49291 /* The console is special in terms of closing the device so
49292 * indicate this port is now acting as a system console. */
49293 port->port.console = 1;
49294 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49295 free_tty:
49296 kfree(tty);
49297 reset_open_count:
49298 - port->port.count = 0;
49299 + atomic_set(&port->port.count, 0);
49300 usb_autopm_put_interface(serial->interface);
49301 error_get_interface:
49302 usb_serial_put(serial);
49303 @@ -198,7 +198,7 @@ static int usb_console_setup(struct console *co, char *options)
49304 static void usb_console_write(struct console *co,
49305 const char *buf, unsigned count)
49306 {
49307 - static struct usbcons_info *info = &usbcons_info;
49308 + struct usbcons_info *info = &usbcons_info;
49309 struct usb_serial_port *port = info->port;
49310 struct usb_serial *serial;
49311 int retval = -ENODEV;
49312 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49313 index 75f70f0..d467e1a 100644
49314 --- a/drivers/usb/storage/usb.h
49315 +++ b/drivers/usb/storage/usb.h
49316 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49317 __u8 useProtocol;
49318 __u8 useTransport;
49319 int (*initFunction)(struct us_data *);
49320 -};
49321 +} __do_const;
49322
49323
49324 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49325 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49326 index d6bea3e..60b250e 100644
49327 --- a/drivers/usb/wusbcore/wa-hc.h
49328 +++ b/drivers/usb/wusbcore/wa-hc.h
49329 @@ -192,7 +192,7 @@ struct wahc {
49330 struct list_head xfer_delayed_list;
49331 spinlock_t xfer_list_lock;
49332 struct work_struct xfer_work;
49333 - atomic_t xfer_id_count;
49334 + atomic_unchecked_t xfer_id_count;
49335 };
49336
49337
49338 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49339 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49340 spin_lock_init(&wa->xfer_list_lock);
49341 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49342 - atomic_set(&wa->xfer_id_count, 1);
49343 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49344 }
49345
49346 /**
49347 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49348 index d3493ca..0c33b7e 100644
49349 --- a/drivers/usb/wusbcore/wa-xfer.c
49350 +++ b/drivers/usb/wusbcore/wa-xfer.c
49351 @@ -297,7 +297,7 @@ out:
49352 */
49353 static void wa_xfer_id_init(struct wa_xfer *xfer)
49354 {
49355 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49356 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49357 }
49358
49359 /*
49360 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49361 index 842f450..d1d7409 100644
49362 --- a/drivers/vfio/vfio.c
49363 +++ b/drivers/vfio/vfio.c
49364 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49365 return 0;
49366
49367 /* TODO Prevent device auto probing */
49368 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49369 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49370 iommu_group_id(group->iommu_group));
49371
49372 return 0;
49373 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49374 index 5174eba..86e764a 100644
49375 --- a/drivers/vhost/vringh.c
49376 +++ b/drivers/vhost/vringh.c
49377 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49378
49379 static inline int putu16_kern(u16 *p, u16 val)
49380 {
49381 - ACCESS_ONCE(*p) = val;
49382 + ACCESS_ONCE_RW(*p) = val;
49383 return 0;
49384 }
49385
49386 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
49387 index e43401a..dd49b3f 100644
49388 --- a/drivers/video/arcfb.c
49389 +++ b/drivers/video/arcfb.c
49390 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
49391 return -ENOSPC;
49392
49393 err = 0;
49394 - if ((count + p) > fbmemlength) {
49395 + if (count > (fbmemlength - p)) {
49396 count = fbmemlength - p;
49397 err = -ENOSPC;
49398 }
49399 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49400 index a4dfe8c..297ddd9 100644
49401 --- a/drivers/video/aty/aty128fb.c
49402 +++ b/drivers/video/aty/aty128fb.c
49403 @@ -149,7 +149,7 @@ enum {
49404 };
49405
49406 /* Must match above enum */
49407 -static char * const r128_family[] = {
49408 +static const char * const r128_family[] = {
49409 "AGP",
49410 "PCI",
49411 "PRO AGP",
49412 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49413 index 9b0f12c..024673d 100644
49414 --- a/drivers/video/aty/atyfb_base.c
49415 +++ b/drivers/video/aty/atyfb_base.c
49416 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49417 par->accel_flags = var->accel_flags; /* hack */
49418
49419 if (var->accel_flags) {
49420 - info->fbops->fb_sync = atyfb_sync;
49421 + pax_open_kernel();
49422 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49423 + pax_close_kernel();
49424 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49425 } else {
49426 - info->fbops->fb_sync = NULL;
49427 + pax_open_kernel();
49428 + *(void **)&info->fbops->fb_sync = NULL;
49429 + pax_close_kernel();
49430 info->flags |= FBINFO_HWACCEL_DISABLED;
49431 }
49432
49433 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49434 index 95ec042..e6affdd 100644
49435 --- a/drivers/video/aty/mach64_cursor.c
49436 +++ b/drivers/video/aty/mach64_cursor.c
49437 @@ -7,6 +7,7 @@
49438 #include <linux/string.h>
49439
49440 #include <asm/io.h>
49441 +#include <asm/pgtable.h>
49442
49443 #ifdef __sparc__
49444 #include <asm/fbio.h>
49445 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49446 info->sprite.buf_align = 16; /* and 64 lines tall. */
49447 info->sprite.flags = FB_PIXMAP_IO;
49448
49449 - info->fbops->fb_cursor = atyfb_cursor;
49450 + pax_open_kernel();
49451 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49452 + pax_close_kernel();
49453
49454 return 0;
49455 }
49456 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49457 index bca6ccc..252107e 100644
49458 --- a/drivers/video/backlight/kb3886_bl.c
49459 +++ b/drivers/video/backlight/kb3886_bl.c
49460 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49461 static unsigned long kb3886bl_flags;
49462 #define KB3886BL_SUSPENDED 0x01
49463
49464 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49465 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49466 {
49467 .ident = "Sahara Touch-iT",
49468 .matches = {
49469 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49470 index 900aa4e..6d49418 100644
49471 --- a/drivers/video/fb_defio.c
49472 +++ b/drivers/video/fb_defio.c
49473 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49474
49475 BUG_ON(!fbdefio);
49476 mutex_init(&fbdefio->lock);
49477 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49478 + pax_open_kernel();
49479 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49480 + pax_close_kernel();
49481 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49482 INIT_LIST_HEAD(&fbdefio->pagelist);
49483 if (fbdefio->delay == 0) /* set a default of 1 s */
49484 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49485 page->mapping = NULL;
49486 }
49487
49488 - info->fbops->fb_mmap = NULL;
49489 + *(void **)&info->fbops->fb_mmap = NULL;
49490 mutex_destroy(&fbdefio->lock);
49491 }
49492 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49493 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49494 index 5c3960d..15cf8fc 100644
49495 --- a/drivers/video/fbcmap.c
49496 +++ b/drivers/video/fbcmap.c
49497 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49498 rc = -ENODEV;
49499 goto out;
49500 }
49501 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49502 - !info->fbops->fb_setcmap)) {
49503 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49504 rc = -EINVAL;
49505 goto out1;
49506 }
49507 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49508 index 36e1fe2..c744820 100644
49509 --- a/drivers/video/fbmem.c
49510 +++ b/drivers/video/fbmem.c
49511 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49512 image->dx += image->width + 8;
49513 }
49514 } else if (rotate == FB_ROTATE_UD) {
49515 - for (x = 0; x < num && image->dx >= 0; x++) {
49516 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49517 info->fbops->fb_imageblit(info, image);
49518 image->dx -= image->width + 8;
49519 }
49520 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49521 image->dy += image->height + 8;
49522 }
49523 } else if (rotate == FB_ROTATE_CCW) {
49524 - for (x = 0; x < num && image->dy >= 0; x++) {
49525 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49526 info->fbops->fb_imageblit(info, image);
49527 image->dy -= image->height + 8;
49528 }
49529 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49530 return -EFAULT;
49531 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49532 return -EINVAL;
49533 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49534 + if (con2fb.framebuffer >= FB_MAX)
49535 return -EINVAL;
49536 if (!registered_fb[con2fb.framebuffer])
49537 request_module("fb%d", con2fb.framebuffer);
49538 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49539 index d4d2c5f..ebbd113 100644
49540 --- a/drivers/video/hyperv_fb.c
49541 +++ b/drivers/video/hyperv_fb.c
49542 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49543 static inline int synthvid_send(struct hv_device *hdev,
49544 struct synthvid_msg *msg)
49545 {
49546 - static atomic64_t request_id = ATOMIC64_INIT(0);
49547 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49548 int ret;
49549
49550 msg->pipe_hdr.type = PIPE_MSG_DATA;
49551 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49552
49553 ret = vmbus_sendpacket(hdev->channel, msg,
49554 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49555 - atomic64_inc_return(&request_id),
49556 + atomic64_inc_return_unchecked(&request_id),
49557 VM_PKT_DATA_INBAND, 0);
49558
49559 if (ret)
49560 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49561 index 7672d2e..b56437f 100644
49562 --- a/drivers/video/i810/i810_accel.c
49563 +++ b/drivers/video/i810/i810_accel.c
49564 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49565 }
49566 }
49567 printk("ringbuffer lockup!!!\n");
49568 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49569 i810_report_error(mmio);
49570 par->dev_flags |= LOCKUP;
49571 info->pixmap.scan_align = 1;
49572 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49573 index 285d552..eafa544 100644
49574 --- a/drivers/video/logo/logo_linux_clut224.ppm
49575 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49576 @@ -1,883 +1,1123 @@
49577 P3
49578 80 80
49579 255
49580 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49581 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 33 49 54 59 85 92 73 97 106
49582 -83 116 129 105 131 142 115 114 122 74 88 93 20 29 31 0 0 0 0 0 0 0 0 0
49583 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49584 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 10 10 10
49585 -10 10 10 6 6 6 6 6 6 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49586 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49587 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49588 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49589 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49590 -
49591 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49592 -0 0 0 0 0 0 2 3 3 17 23 26 50 67 72 73 97 106 59 85 92 73 97 106
49593 -105 131 142 124 127 131 105 131 142 105 131 142 53 75 83 6 8 8 0 0 0 0 0 0
49594 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49595 -0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 26 26 26 30 30 30 34 34 34
49596 -30 30 30 30 30 30 26 26 26 18 18 18 14 14 14 10 10 10 6 6 6 0 0 0
49597 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49598 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49599 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49600 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49601 -
49602 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0
49603 -0 0 0 1 1 1 26 35 39 59 85 92 59 85 92 59 85 92 29 43 47 53 75 83
49604 -108 122 132 132 98 104 108 122 132 105 131 142 101 101 101 43 45 48 6 8 8 0 0 0
49605 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49606 -6 6 6 14 14 14 26 26 26 42 42 42 54 54 54 66 66 66 78 78 78 78 78 78
49607 -78 78 78 74 74 74 66 66 66 54 54 54 42 42 42 26 26 26 18 18 18 10 10 10
49608 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49609 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49610 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49611 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49612 -
49613 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0
49614 -11 15 17 27 40 45 59 85 92 59 85 92 27 40 45 31 45 49 73 97 106 93 121 133
49615 -108 122 132 108 122 132 105 131 142 108 122 132 105 131 142 73 97 106 26 35 39 0 0 0
49616 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49617 -22 22 22 42 42 42 66 66 66 86 86 86 66 66 66 38 38 38 38 38 38 22 22 22
49618 -26 26 26 34 34 34 54 54 54 66 66 66 86 86 86 70 70 70 46 46 46 26 26 26
49619 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49620 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49621 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49622 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49623 -
49624 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 7 12 13 21 31 35 42 59 64
49625 -53 75 83 53 75 83 50 67 72 42 59 64 32 40 45 42 59 64 73 97 106 116 116 116
49626 -132 98 104 116 116 116 108 122 132 117 104 110 105 131 142 83 116 129 50 67 72 7 12 13
49627 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49628 -50 50 50 82 82 82 58 58 58 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49629 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 54 54 54 86 86 86 66 66 66
49630 -38 38 38 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49631 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49632 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49633 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49634 -
49635 -0 0 0 1 1 1 6 8 8 15 22 25 26 35 39 36 54 60 53 75 83 59 85 92
49636 -59 85 92 48 63 69 15 22 25 12 17 20 52 67 79 94 94 94 132 98 104 132 98 104
49637 -117 104 110 108 122 132 108 122 132 115 114 122 105 131 142 77 105 114 59 85 92 36 54 60
49638 -7 12 13 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49639 -78 78 78 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49640 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 70 70 70
49641 -78 78 78 46 46 46 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49642 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49643 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49644 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49645 -
49646 -0 0 0 15 22 25 29 43 47 36 54 60 42 59 64 42 59 64 48 63 69 21 31 35
49647 -6 8 8 29 43 47 36 50 56 43 45 48 79 78 84 132 98 104 165 78 79 132 98 104
49648 -108 122 132 117 104 110 117 104 110 108 122 132 77 105 114 73 97 106 95 131 149 78 102 129
49649 -36 50 56 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 42 42 42 82 82 82
49650 -26 26 26 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49651 -2 2 6 2 2 6 2 2 6 14 14 14 46 46 46 34 34 34 6 6 6 2 2 6
49652 -42 42 42 78 78 78 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49653 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49654 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49655 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49656 -
49657 -27 40 45 53 75 83 48 63 69 24 31 37 6 8 12 0 0 0 18 25 28 26 35 39
49658 -12 17 20 26 35 39 65 78 84 112 81 86 152 81 83 137 83 86 132 98 104 117 104 110
49659 -117 104 110 132 98 104 132 98 104 115 114 122 73 97 106 53 75 83 95 131 149 93 124 152
49660 -68 78 128 15 22 25 0 0 0 0 0 0 10 10 10 30 30 30 66 66 66 58 58 58
49661 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49662 -2 2 6 2 2 6 2 2 6 26 26 26 86 86 86 101 101 101 46 46 46 10 10 10
49663 -2 2 6 58 58 58 70 70 70 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
49664 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49665 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49666 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49667 -
49668 -36 50 56 21 30 33 4 7 7 0 0 0 1 1 1 17 12 12 69 31 31 68 59 64
49669 -57 59 63 21 31 35 32 40 45 86 73 69 152 81 83 152 81 83 117 104 110 132 98 104
49670 -152 81 83 132 98 104 108 122 132 77 105 114 77 105 114 93 121 133 95 131 149 93 124 152
49671 -95 131 149 53 75 83 11 15 17 0 0 0 14 14 14 42 42 42 86 86 86 10 10 10
49672 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49673 -2 2 6 2 2 6 2 2 6 30 30 30 94 94 94 94 94 94 58 58 58 26 26 26
49674 -2 2 6 6 6 6 78 78 78 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0
49675 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49676 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49677 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49678 -
49679 -17 23 26 2 3 3 0 0 0 17 12 12 69 31 31 123 55 55 123 55 55 152 81 83
49680 -86 73 69 17 23 26 7 12 13 45 54 57 101 101 101 137 83 86 132 98 104 132 98 104
49681 -137 83 86 117 104 110 77 105 114 42 59 64 50 67 72 78 102 129 91 117 157 91 117 157
49682 -95 131 149 83 116 129 40 48 73 6 6 6 22 22 22 62 62 62 62 62 62 2 2 6
49683 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49684 -2 2 6 2 2 6 2 2 6 26 26 26 54 54 54 38 38 38 18 18 18 10 10 10
49685 -2 2 6 2 2 6 34 34 34 82 82 82 38 38 38 14 14 14 0 0 0 0 0 0
49686 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49687 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49688 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49689 -
49690 -1 1 1 1 2 2 2 3 3 28 12 12 123 55 55 174 79 79 174 79 79 174 79 79
49691 -152 81 83 68 59 64 26 35 39 27 40 45 79 78 84 137 83 86 165 78 79 137 83 86
49692 -94 94 94 48 63 69 36 50 56 50 67 72 73 97 106 93 121 133 93 124 152 93 124 152
49693 -95 131 149 91 118 149 78 102 129 27 40 45 30 30 30 78 78 78 30 30 30 2 2 6
49694 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49695 -2 2 6 2 2 6 2 2 6 10 10 10 10 10 10 2 2 6 2 2 6 2 2 6
49696 -2 2 6 2 2 6 2 2 6 78 78 78 50 50 50 18 18 18 6 6 6 0 0 0
49697 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49698 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49699 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49700 -
49701 -4 5 3 24 53 24 19 31 15 8 7 3 90 61 47 165 78 79 174 79 79 174 79 79
49702 -174 79 79 137 83 86 60 52 57 7 12 13 17 23 26 70 70 70 132 98 104 112 81 86
49703 -79 78 84 31 45 49 15 22 25 53 75 83 91 118 149 86 106 160 91 117 157 93 124 152
49704 -91 117 157 93 124 152 95 131 149 53 75 83 50 50 50 86 86 86 14 14 14 2 2 6
49705 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49706 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49707 -2 2 6 2 2 6 2 2 6 54 54 54 66 66 66 26 26 26 6 6 6 0 0 0
49708 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49709 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49710 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49711 -
49712 -19 31 15 34 76 34 34 76 34 19 31 15 28 12 12 123 55 55 174 79 79 174 79 79
49713 -174 79 79 165 78 79 112 81 86 32 40 45 15 22 25 38 53 58 65 78 84 29 31 32
49714 -21 30 33 42 59 64 60 80 103 78 102 129 87 112 149 84 96 162 91 117 157 93 124 152
49715 -91 117 157 93 124 152 93 121 133 59 85 92 57 68 71 82 85 86 2 2 6 2 2 6
49716 -2 2 6 6 6 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49717 -2 2 6 2 2 6 2 2 6 6 6 6 14 14 14 10 10 10 2 2 6 2 2 6
49718 -2 2 6 2 2 6 2 2 6 18 18 18 82 82 82 34 34 34 10 10 10 0 0 0
49719 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49720 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49721 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49722 -
49723 -34 76 34 40 89 40 40 89 40 34 76 34 8 15 6 48 26 18 123 55 55 174 79 79
49724 -174 79 79 174 79 79 137 83 86 68 59 64 32 40 45 21 30 33 31 45 49 21 31 35
49725 -12 17 20 48 63 69 78 102 129 81 88 166 84 96 162 91 117 157 93 124 152 91 117 157
49726 -93 124 152 95 131 149 83 116 129 59 85 92 57 68 71 86 86 86 2 2 6 2 2 6
49727 -6 6 6 6 6 6 22 22 22 34 34 34 6 6 6 2 2 6 2 2 6 2 2 6
49728 -2 2 6 2 2 6 18 18 18 34 34 34 10 10 10 50 50 50 22 22 22 2 2 6
49729 -2 2 6 2 2 6 2 2 6 10 10 10 86 86 86 42 42 42 14 14 14 0 0 0
49730 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49731 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49732 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49733 -
49734 -40 89 40 40 89 40 40 89 40 40 89 40 24 53 24 6 6 6 69 31 31 123 55 55
49735 -123 55 55 90 61 47 69 31 31 36 32 33 21 31 35 7 12 13 18 25 28 48 63 69
49736 -60 80 103 68 78 128 84 101 153 84 96 162 84 96 162 91 117 157 91 117 157 84 96 162
49737 -91 117 157 73 97 106 48 63 69 50 67 72 57 59 63 86 86 86 2 2 6 2 2 6
49738 -38 38 38 116 116 116 94 94 94 22 22 22 22 22 22 2 2 6 2 2 6 2 2 6
49739 -14 14 14 86 86 86 124 131 137 170 170 170 151 151 151 38 38 38 26 26 26 6 6 6
49740 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 46 46 46 14 14 14 0 0 0
49741 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49742 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49743 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49744 -
49745 -34 76 34 40 89 40 40 89 40 40 89 40 34 76 34 19 31 15 17 12 12 48 26 18
49746 -48 26 18 8 7 3 10 10 22 23 29 47 51 61 92 42 59 64 21 30 33 34 45 54
49747 -68 78 128 81 88 166 81 82 173 86 106 160 86 106 160 84 96 162 86 106 160 87 112 149
49748 -91 118 149 77 105 114 52 67 79 32 40 45 50 50 50 86 86 86 2 2 6 14 14 14
49749 -124 131 137 198 198 198 195 195 195 116 116 116 10 10 10 2 2 6 2 2 6 6 6 6
49750 -101 98 89 187 187 187 210 210 210 218 218 218 214 214 214 124 131 137 14 14 14 6 6 6
49751 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 50 50 50 18 18 18 6 6 6
49752 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49753 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49754 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49755 -
49756 -19 31 15 34 76 34 40 89 40 40 89 40 40 89 40 24 53 24 8 7 3 0 0 0
49757 -6 8 12 28 32 52 51 61 92 54 54 122 74 77 160 68 78 128 26 35 39 6 8 8
49758 -34 45 54 68 78 128 84 96 162 86 106 160 86 106 160 81 88 166 84 96 162 87 112 149
49759 -73 97 106 36 50 56 33 49 54 18 18 18 46 46 46 86 86 86 2 2 6 54 54 54
49760 -218 218 218 195 195 195 226 226 226 246 246 246 58 58 58 2 2 6 2 2 6 30 30 30
49761 -210 210 210 253 253 253 170 170 170 124 127 131 221 221 221 234 234 234 74 74 74 2 2 6
49762 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49763 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49764 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49765 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49766 -
49767 -4 5 3 24 53 24 40 89 40 40 89 40 34 76 34 12 22 15 4 5 3 4 5 3
49768 -13 17 26 54 54 122 78 78 174 78 78 174 78 78 174 74 77 160 51 61 92 21 31 35
49769 -26 35 39 53 75 83 84 101 153 81 82 173 81 88 166 84 101 153 60 80 103 60 80 103
49770 -53 75 83 38 53 58 42 59 64 22 22 22 46 46 46 82 82 82 2 2 6 106 106 106
49771 -170 170 170 26 26 26 86 86 86 226 226 226 124 127 131 10 10 10 14 14 14 46 46 46
49772 -231 231 231 190 190 190 6 6 6 70 70 70 90 90 90 238 238 238 151 151 151 2 2 6
49773 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49774 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49775 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49776 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49777 -
49778 -1 2 2 8 15 6 24 53 24 34 76 34 19 31 15 8 15 6 63 55 20 63 55 20
49779 -18 18 18 40 48 73 74 77 160 78 78 174 78 78 174 81 82 173 74 77 160 52 67 79
49780 -17 23 26 21 31 35 60 80 103 81 88 166 74 77 160 78 102 129 36 54 60 12 17 20
49781 -42 59 64 48 63 69 21 31 35 18 18 18 42 42 42 86 86 86 6 6 6 116 116 116
49782 -106 106 106 6 6 6 70 70 70 151 151 151 124 127 131 18 18 18 38 38 38 54 54 54
49783 -221 221 221 106 106 106 2 2 6 14 14 14 46 46 46 190 190 190 198 198 198 2 2 6
49784 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49785 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49786 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49787 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49788 -
49789 -11 15 17 0 0 0 12 22 15 19 31 15 8 15 6 63 55 20 149 139 69 149 139 69
49790 -63 55 20 10 10 22 54 54 122 78 78 174 78 78 174 78 78 174 81 82 173 68 78 128
49791 -24 31 37 6 6 6 36 50 56 60 80 103 51 61 92 42 59 64 36 50 56 31 45 49
49792 -29 43 47 27 40 45 6 8 8 14 14 14 42 42 42 94 94 94 14 14 14 101 101 101
49793 -124 127 131 2 2 6 18 18 18 116 116 116 106 107 48 121 92 8 121 92 8 98 70 6
49794 -170 170 170 106 106 106 2 2 6 2 2 6 2 2 6 195 195 195 195 195 195 6 6 6
49795 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49796 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49797 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49798 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49799 -
49800 -26 35 39 3 5 6 1 1 1 2 3 3 35 31 12 133 118 54 175 176 80 175 176 80
49801 -133 118 54 35 31 12 23 29 47 54 54 122 78 78 174 78 78 174 74 77 160 68 78 128
49802 -51 61 92 31 45 49 26 35 39 36 50 56 29 43 47 7 12 13 21 30 33 42 59 64
49803 -18 25 28 7 12 13 1 1 1 10 10 10 38 38 38 90 90 90 14 14 14 58 58 58
49804 -210 210 210 26 26 26 62 42 6 154 114 10 226 170 11 237 188 10 220 174 15 184 138 11
49805 -220 174 15 174 140 55 35 31 12 2 2 6 70 70 70 246 246 246 124 131 137 2 2 6
49806 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 66 66 66 26 26 26 6 6 6
49807 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49808 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49809 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49810 -
49811 -27 40 45 17 23 26 2 3 3 1 1 1 56 77 35 165 152 80 175 176 80 175 176 80
49812 -175 176 80 106 107 48 22 22 22 28 32 52 54 54 122 54 54 122 51 61 92 28 32 52
49813 -20 27 34 31 45 49 11 15 17 7 12 13 36 50 56 31 45 49 29 43 47 36 50 56
49814 -6 8 8 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 14 14 14 10 10 10
49815 -195 195 195 198 179 130 192 133 9 220 174 15 239 182 13 237 188 10 232 195 16 239 207 25
49816 -237 201 50 241 208 19 232 195 16 184 138 11 198 179 130 208 206 196 42 42 42 2 2 6
49817 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 74 74 74 30 30 30 6 6 6
49818 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49819 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49820 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49821 -
49822 -15 22 25 26 35 39 15 22 25 0 0 0 35 31 12 133 118 54 175 176 80 175 176 80
49823 -175 176 80 165 152 80 56 77 35 6 8 12 23 29 47 13 17 26 2 2 6 0 0 0
49824 -1 2 2 26 35 39 26 35 39 26 35 39 42 59 64 42 59 64 20 29 31 6 8 8
49825 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 86 86 86 14 14 14 2 2 6
49826 -121 92 8 192 133 9 219 162 10 239 182 13 237 188 10 232 195 16 241 208 19 237 201 50
49827 -237 201 50 239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 121 92 8 2 2 6
49828 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 82 82 82 34 34 34 10 10 10
49829 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49830 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49831 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49832 -
49833 -1 2 2 15 22 25 31 45 49 6 8 12 4 5 3 63 55 20 149 139 69 175 176 80
49834 -175 176 80 175 176 80 106 107 48 20 16 6 1 1 1 0 0 0 2 3 3 11 15 17
49835 -21 30 33 36 50 56 36 50 56 24 31 37 15 22 25 6 8 8 0 0 0 0 0 0
49836 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 82 82 82 30 30 30 62 42 6
49837 -180 123 7 206 145 10 230 174 11 239 182 13 237 188 10 238 202 15 241 208 19 237 201 50
49838 -239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 220 174 15 184 138 11 6 6 6
49839 -2 2 6 2 2 6 2 2 6 2 2 6 26 26 26 94 94 94 42 42 42 14 14 14
49840 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49841 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49842 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49843 -
49844 -0 0 0 1 2 2 29 43 47 26 35 39 3 5 6 8 7 3 106 107 48 165 152 80
49845 -175 176 80 149 139 69 63 55 20 4 5 3 2 3 3 12 17 20 26 35 39 26 35 39
49846 -17 23 26 7 12 13 6 8 8 3 5 6 1 2 2 0 0 0 0 0 0 0 0 0
49847 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 50 50 50 104 69 6
49848 -192 133 9 216 158 10 236 178 12 237 188 10 232 195 16 241 208 19 237 201 50 237 201 50
49849 -241 208 19 241 208 19 241 208 19 204 160 10 200 144 11 216 158 10 156 118 10 2 2 6
49850 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 90 90 90 54 54 54 18 18 18
49851 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49852 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49853 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49854 -
49855 -0 0 0 0 0 0 12 17 20 27 40 45 18 25 28 1 1 1 35 31 12 106 107 48
49856 -149 139 69 56 77 35 8 7 3 1 2 2 12 17 20 26 35 39 21 31 35 11 15 17
49857 -3 5 6 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49858 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 46 46 46 22 22 22
49859 -137 92 6 204 160 10 239 182 13 237 188 10 238 202 15 241 208 19 241 208 19 241 208 19
49860 -241 208 19 204 160 10 184 138 11 210 150 10 216 158 10 210 150 10 98 70 6 2 2 6
49861 -6 6 6 54 54 54 14 14 14 2 2 6 2 2 6 62 62 62 74 74 74 30 30 30
49862 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49863 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49864 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49865 -
49866 -0 0 0 0 0 0 1 1 1 15 22 25 33 49 54 12 17 20 2 3 3 35 31 12
49867 -56 77 35 20 16 6 1 1 1 18 25 28 21 31 35 11 15 17 1 1 1 0 0 0
49868 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49869 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 78 78 78 50 50 50 6 6 6
49870 -88 55 22 139 102 15 190 146 13 230 187 11 239 207 25 232 195 16 220 174 15 190 146 13
49871 -171 120 8 192 133 9 210 150 10 213 154 11 185 146 40 165 152 80 101 98 89 2 2 6
49872 -2 2 6 78 78 78 116 116 116 58 58 58 2 2 6 22 22 22 90 90 90 46 46 46
49873 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49874 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49875 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49876 -
49877 -0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 29 43 47 3 5 6 2 3 3
49878 -8 7 3 1 1 1 17 23 26 31 45 49 15 22 25 0 0 0 0 0 0 0 0 0
49879 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49880 -0 0 0 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 50 50 50 6 6 6
49881 -124 127 131 168 158 138 156 107 11 171 120 8 204 160 10 184 138 11 197 138 11 200 144 11
49882 -206 145 10 206 145 10 197 138 11 198 179 130 195 195 195 198 198 198 170 170 170 14 14 14
49883 -2 2 6 22 22 22 116 116 116 116 116 116 22 22 22 2 2 6 74 74 74 70 70 70
49884 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49885 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49886 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49887 -
49888 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 31 45 49 26 35 39 3 5 6
49889 -0 0 0 7 12 13 27 40 45 18 25 28 0 0 0 0 0 0 0 0 0 0 0 0
49890 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49891 -0 0 0 0 0 0 6 6 6 18 18 18 50 50 50 101 101 101 26 26 26 10 10 10
49892 -124 131 137 190 190 190 168 158 138 156 107 11 197 138 11 200 144 11 197 138 11 192 133 9
49893 -180 123 7 185 146 40 198 179 130 187 187 187 202 202 202 221 221 221 214 214 214 66 66 66
49894 -2 2 6 2 2 6 50 50 50 62 62 62 6 6 6 2 2 6 10 10 10 90 90 90
49895 -50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49896 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49897 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49898 -
49899 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 15 22 25 36 54 60 18 25 28
49900 -0 0 0 21 30 33 27 40 45 2 3 3 0 0 0 0 0 0 0 0 0 0 0 0
49901 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49902 -0 0 0 0 0 0 10 10 10 34 34 34 74 74 74 74 74 74 2 2 6 6 6 6
49903 -151 151 151 198 198 198 190 190 190 168 158 138 148 132 55 156 107 11 156 107 11 169 125 40
49904 -168 158 138 187 187 187 190 190 190 210 210 210 246 246 246 253 253 253 253 253 253 180 180 180
49905 -6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62
49906 -74 74 74 34 34 34 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49907 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49908 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49909 -
49910 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 35 52 58
49911 -18 25 28 35 52 58 17 23 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49912 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49913 -0 0 0 10 10 10 22 22 22 54 54 54 94 94 94 18 18 18 2 2 6 46 46 46
49914 -234 234 234 221 221 221 190 190 190 190 190 190 190 190 190 187 187 187 187 187 187 190 190 190
49915 -190 190 190 195 195 195 214 214 214 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49916 -82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 14 14 14
49917 -86 86 86 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49918 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49919 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49920 -
49921 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 12 13 33 49 54
49922 -52 72 81 36 54 60 6 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49923 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49924 -6 6 6 18 18 18 46 46 46 90 90 90 46 46 46 18 18 18 6 6 6 180 180 180
49925 -253 253 253 246 246 246 202 202 202 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190
49926 -202 202 202 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49927 -202 202 202 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49928 -42 42 42 86 86 86 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49929 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49930 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49931 -
49932 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20
49933 -36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49934 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
49935 -14 14 14 38 38 38 74 74 74 66 66 66 2 2 6 6 6 6 90 90 90 250 250 250
49936 -253 253 253 253 253 253 238 238 238 198 198 198 190 190 190 190 190 190 195 195 195 221 221 221
49937 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49938 -253 253 253 82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49939 -2 2 6 78 78 78 70 70 70 34 34 34 14 14 14 6 6 6 0 0 0 0 0 0
49940 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49941 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49942 -
49943 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49944 -21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49945 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
49946 -34 34 34 66 66 66 78 78 78 6 6 6 2 2 6 18 18 18 218 218 218 253 253 253
49947 -253 253 253 253 253 253 253 253 253 246 246 246 226 226 226 231 231 231 246 246 246 253 253 253
49948 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49949 -253 253 253 180 180 180 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49950 -2 2 6 18 18 18 90 90 90 62 62 62 30 30 30 10 10 10 0 0 0 0 0 0
49951 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49952 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49953 -
49954 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49955 -12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49956 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49957 -58 58 58 90 90 90 18 18 18 2 2 6 2 2 6 106 106 106 253 253 253 253 253 253
49958 -253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253
49959 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49960 -253 253 253 231 231 231 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49961 -2 2 6 2 2 6 18 18 18 94 94 94 54 54 54 26 26 26 10 10 10 0 0 0
49962 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49963 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49964 -
49965 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49966 -0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0
49967 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49968 -90 90 90 26 26 26 2 2 6 2 2 6 14 14 14 195 195 195 250 250 250 253 253 253
49969 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49970 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49971 -250 250 250 242 242 242 54 54 54 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49972 -2 2 6 2 2 6 2 2 6 38 38 38 86 86 86 50 50 50 22 22 22 6 6 6
49973 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49974 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49975 -
49976 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49977 -0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0
49978 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 38 38 38 82 82 82
49979 -34 34 34 2 2 6 2 2 6 2 2 6 42 42 42 195 195 195 246 246 246 253 253 253
49980 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 242 242 242 250 250 250 253 253 253
49981 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 246 246 246 238 238 238
49982 -226 226 226 231 231 231 101 101 101 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49983 -2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 82 82 82 42 42 42 14 14 14
49984 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49985 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49986 -
49987 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49988 -0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0
49989 -0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 62 62 62 66 66 66
49990 -2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 170 170 170 202 202 202 234 234 234
49991 -246 246 246 250 250 250 250 250 250 238 238 238 226 226 226 231 231 231 238 238 238 250 250 250
49992 -250 250 250 250 250 250 246 246 246 231 231 231 214 214 214 202 202 202 202 202 202 202 202 202
49993 -198 198 198 202 202 202 180 180 180 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6
49994 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 30 30 30
49995 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49996 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49997 -
49998 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49999 -0 0 0 0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0
50000 -0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 82 82 82 18 18 18
50001 -2 2 6 2 2 6 2 2 6 10 10 10 94 94 94 180 180 180 218 218 218 242 242 242
50002 -250 250 250 253 253 253 253 253 253 250 250 250 234 234 234 253 253 253 253 253 253 253 253 253
50003 -253 253 253 253 253 253 253 253 253 246 246 246 238 238 238 226 226 226 210 210 210 202 202 202
50004 -195 195 195 195 195 195 210 210 210 151 151 151 6 6 6 14 14 14 50 50 50 14 14 14
50005 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 86 86 86 46 46 46
50006 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50007 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50008 -
50009 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50010 -0 0 0 0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0
50011 -0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 54 54 54 70 70 70 2 2 6
50012 -2 2 6 10 10 10 2 2 6 22 22 22 170 170 170 231 231 231 250 250 250 253 253 253
50013 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 253 253 253 253 253 253 253 253 253
50014 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246
50015 -231 231 231 202 202 202 198 198 198 226 226 226 94 94 94 2 2 6 6 6 6 38 38 38
50016 -30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66
50017 -26 26 26 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50018 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50019 -
50020 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50021 -0 0 0 0 0 0 0 0 0 0 0 0 6 8 8 33 49 54 29 43 47 6 8 12
50022 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 74 74 74 50 50 50 2 2 6
50023 -26 26 26 26 26 26 2 2 6 106 106 106 238 238 238 253 253 253 253 253 253 253 253 253
50024 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50025 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50026 -253 253 253 246 246 246 218 218 218 202 202 202 210 210 210 14 14 14 2 2 6 2 2 6
50027 -30 30 30 22 22 22 2 2 6 2 2 6 2 2 6 2 2 6 18 18 18 86 86 86
50028 -42 42 42 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50029 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50030 -
50031 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50032 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20 33 49 54 17 23 26
50033 -0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 90 90 90 22 22 22 2 2 6
50034 -42 42 42 2 2 6 18 18 18 218 218 218 253 253 253 253 253 253 253 253 253 253 253 253
50035 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50036 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50037 -253 253 253 253 253 253 250 250 250 221 221 221 218 218 218 101 101 101 2 2 6 14 14 14
50038 -18 18 18 38 38 38 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 78 78 78
50039 -58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50040 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50041 -
50042 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50043 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 22 25 36 54 60
50044 -0 0 0 0 0 0 0 0 0 18 18 18 54 54 54 82 82 82 2 2 6 26 26 26
50045 -22 22 22 2 2 6 124 127 131 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50046 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50047 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50048 -253 253 253 253 253 253 253 253 253 250 250 250 238 238 238 198 198 198 6 6 6 38 38 38
50049 -58 58 58 26 26 26 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 46 46 46
50050 -78 78 78 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50051 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50052 -
50053 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50054 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 30 33
50055 -36 54 60 0 0 0 0 0 0 30 30 30 74 74 74 58 58 58 2 2 6 42 42 42
50056 -2 2 6 22 22 22 231 231 231 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50057 -253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50058 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50059 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246 46 46 46 38 38 38
50060 -42 42 42 14 14 14 38 38 38 14 14 14 2 2 6 2 2 6 2 2 6 6 6 6
50061 -86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50062 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50063 -
50064 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50065 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50066 -36 54 60 0 0 0 0 0 0 42 42 42 90 90 90 18 18 18 18 18 18 26 26 26
50067 -2 2 6 116 116 116 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50068 -253 253 253 253 253 253 250 250 250 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50069 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50070 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 94 94 94 6 6 6
50071 -2 2 6 2 2 6 10 10 10 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6
50072 -74 74 74 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50073 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50074 -
50075 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50076 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50077 -0 0 0 36 54 60 26 26 26 66 66 66 82 82 82 2 2 6 38 38 38 6 6 6
50078 -14 14 14 210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50079 -253 253 253 253 253 253 246 246 246 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50080 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50081 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 2 2 6
50082 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50083 -42 42 42 74 74 74 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50084 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50085 -
50086 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50087 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50088 -6 6 6 36 54 60 21 30 33 90 90 90 26 26 26 6 6 6 42 42 42 2 2 6
50089 -74 74 74 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50090 -253 253 253 253 253 253 242 242 242 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50091 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50092 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 180 180 180 2 2 6
50093 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50094 -10 10 10 86 86 86 38 38 38 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50095 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50096 -
50097 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50098 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50099 -10 10 10 26 26 26 36 54 60 82 82 82 2 2 6 22 22 22 18 18 18 2 2 6
50100 -151 151 151 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50101 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50102 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50103 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50104 -2 2 6 2 2 6 2 2 6 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6
50105 -6 6 6 86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0
50106 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50107 -
50108 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50109 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50110 -18 18 18 46 46 46 86 86 86 36 54 60 2 2 6 34 34 34 10 10 10 6 6 6
50111 -210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50112 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50113 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50114 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 221 221 221 6 6 6
50115 -2 2 6 2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50116 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50117 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50118 -
50119 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50120 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50121 -26 26 26 66 66 66 62 62 62 2 2 6 2 2 6 38 38 38 10 10 10 26 26 26
50122 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50123 -253 253 253 253 253 253 231 231 231 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50124 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50125 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 231 231 231 6 6 6
50126 -2 2 6 2 2 6 10 10 10 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50127 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50128 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50129 -
50130 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50131 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50132 -38 38 38 78 78 78 6 6 6 2 2 6 2 2 6 46 46 46 14 14 14 42 42 42
50133 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50134 -253 253 253 253 253 253 231 231 231 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50135 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50136 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 10 10 10
50137 -2 2 6 2 2 6 22 22 22 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6
50138 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50139 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50140 -
50141 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50142 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50143 -50 50 50 74 74 74 2 2 6 2 2 6 14 14 14 70 70 70 34 34 34 62 62 62
50144 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50145 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50146 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50147 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 14 14 14
50148 -2 2 6 2 2 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50149 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50150 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50151 -
50152 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50153 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50154 -54 54 54 62 62 62 2 2 6 2 2 6 2 2 6 30 30 30 46 46 46 70 70 70
50155 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50156 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50157 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50158 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 226 226 226 10 10 10
50159 -2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50160 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50161 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50162 -
50163 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50164 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50165 -58 58 58 62 62 62 2 2 6 2 2 6 2 2 6 2 2 6 30 30 30 78 78 78
50166 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50167 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50168 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50169 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50170 -22 22 22 34 34 34 20 16 6 22 22 22 26 26 26 18 18 18 6 6 6 2 2 6
50171 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50172 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50173 -
50174 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50175 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 26 26 26
50176 -62 62 62 106 106 106 63 55 20 184 138 11 204 160 10 121 92 8 6 6 6 62 62 62
50177 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50178 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50179 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50180 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 18 18 18
50181 -14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 18 18 18 66 66 66 38 38 38
50182 -6 6 6 94 94 94 50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50183 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50184 -
50185 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50186 -0 0 0 0 0 0 0 0 0 6 6 6 10 10 10 10 10 10 18 18 18 38 38 38
50187 -78 78 78 138 132 106 216 158 10 242 186 14 246 190 14 246 190 14 156 118 10 10 10 10
50188 -90 90 90 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50189 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50190 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50191 -253 253 253 253 253 253 253 253 253 246 230 190 214 187 87 214 187 87 185 146 40 35 31 12
50192 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 46 46 46
50193 -26 26 26 106 106 106 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50194 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50195 -
50196 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50197 -0 0 0 6 6 6 14 14 14 22 22 22 30 30 30 38 38 38 50 50 50 70 70 70
50198 -106 106 106 185 146 40 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 154 114 10
50199 -6 6 6 74 74 74 226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50200 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50201 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50202 -253 253 253 253 253 253 253 253 253 237 201 50 241 196 14 241 208 19 232 195 16 35 31 12
50203 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 30 30 30 26 26 26
50204 -204 160 10 165 152 80 66 66 66 26 26 26 6 6 6 0 0 0 0 0 0 0 0 0
50205 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50206 -
50207 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50208 -6 6 6 18 18 18 38 38 38 58 58 58 78 78 78 86 86 86 101 101 101 124 127 131
50209 -174 140 55 210 150 10 234 174 13 246 186 14 246 190 14 246 190 14 246 190 14 237 188 10
50210 -98 70 6 2 2 6 46 46 46 198 198 198 253 253 253 253 253 253 253 253 253 253 253 253
50211 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50212 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50213 -253 253 253 253 253 253 253 253 253 214 187 87 242 186 14 241 196 14 204 160 10 20 16 6
50214 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 121 92 8
50215 -238 202 15 232 195 16 82 82 82 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
50216 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50217 -
50218 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50219 -14 14 14 38 38 38 70 70 70 148 132 55 185 146 40 200 144 11 197 138 11 197 138 11
50220 -213 154 11 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50221 -220 174 15 35 31 12 2 2 6 22 22 22 151 151 151 250 250 250 253 253 253 253 253 253
50222 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50223 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50224 -253 253 253 250 250 250 242 242 242 214 187 87 239 182 13 237 188 10 213 154 11 35 31 12
50225 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 42 6 220 174 15
50226 -237 188 10 237 188 10 113 101 86 42 42 42 14 14 14 0 0 0 0 0 0 0 0 0
50227 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50228 -
50229 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50230 -22 22 22 54 54 54 148 132 55 213 154 11 226 170 11 230 174 11 226 170 11 226 170 11
50231 -236 178 12 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50232 -241 196 14 184 138 11 10 10 10 2 2 6 6 6 6 116 116 116 242 242 242 253 253 253
50233 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50234 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50235 -253 253 253 231 231 231 198 198 198 213 164 39 236 178 12 236 178 12 210 150 10 137 92 6
50236 -20 16 6 2 2 6 2 2 6 2 2 6 6 6 6 62 42 6 200 144 11 236 178 12
50237 -239 182 13 239 182 13 124 112 88 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0
50238 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50239 -
50240 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50241 -30 30 30 70 70 70 169 125 40 226 170 11 239 182 13 242 186 14 242 186 14 246 186 14
50242 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50243 -246 190 14 232 195 16 98 70 6 2 2 6 2 2 6 2 2 6 66 66 66 221 221 221
50244 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50245 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50246 -253 253 253 202 202 202 198 198 198 213 164 39 230 174 11 230 174 11 216 158 10 192 133 9
50247 -163 110 8 120 80 7 98 70 6 120 80 7 167 114 7 197 138 11 226 170 11 239 182 13
50248 -242 186 14 242 186 14 165 152 80 78 78 78 34 34 34 14 14 14 6 6 6 0 0 0
50249 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50250 -
50251 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50252 -30 30 30 78 78 78 185 146 40 226 170 11 239 182 13 246 190 14 246 190 14 246 190 14
50253 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50254 -246 190 14 241 196 14 204 160 10 20 16 6 2 2 6 2 2 6 2 2 6 38 38 38
50255 -218 218 218 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50256 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50257 -250 250 250 202 202 202 198 198 198 213 164 39 226 170 11 236 178 12 224 166 10 210 150 10
50258 -200 144 11 197 138 11 192 133 9 197 138 11 210 150 10 226 170 11 242 186 14 246 190 14
50259 -246 190 14 246 186 14 220 174 15 124 112 88 62 62 62 30 30 30 14 14 14 6 6 6
50260 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50261 -
50262 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50263 -30 30 30 78 78 78 174 140 55 224 166 10 239 182 13 246 190 14 246 190 14 246 190 14
50264 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50265 -246 190 14 246 190 14 241 196 14 139 102 15 2 2 6 2 2 6 2 2 6 2 2 6
50266 -78 78 78 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50267 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50268 -250 250 250 214 214 214 198 198 198 185 146 40 219 162 10 236 178 12 234 174 13 224 166 10
50269 -216 158 10 213 154 11 213 154 11 216 158 10 226 170 11 239 182 13 246 190 14 246 190 14
50270 -246 190 14 246 190 14 242 186 14 213 164 39 101 101 101 58 58 58 30 30 30 14 14 14
50271 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50272 -
50273 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50274 -30 30 30 74 74 74 174 140 55 216 158 10 236 178 12 246 190 14 246 190 14 246 190 14
50275 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50276 -246 190 14 246 190 14 241 196 14 230 187 11 62 42 6 2 2 6 2 2 6 2 2 6
50277 -22 22 22 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50278 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50279 -253 253 253 226 226 226 187 187 187 169 125 40 216 158 10 236 178 12 239 182 13 236 178 12
50280 -230 174 11 226 170 11 226 170 11 230 174 11 236 178 12 242 186 14 246 190 14 246 190 14
50281 -246 190 14 246 190 14 246 186 14 239 182 13 213 164 39 106 106 106 66 66 66 34 34 34
50282 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50283 -
50284 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50285 -26 26 26 70 70 70 149 139 69 213 154 11 236 178 12 246 190 14 246 190 14 246 190 14
50286 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50287 -246 190 14 246 190 14 246 190 14 241 196 14 190 146 13 20 16 6 2 2 6 2 2 6
50288 -46 46 46 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50289 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50290 -253 253 253 221 221 221 86 86 86 156 107 11 216 158 10 236 178 12 242 186 14 246 186 14
50291 -242 186 14 239 182 13 239 182 13 242 186 14 242 186 14 246 186 14 246 190 14 246 190 14
50292 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 220 174 15 149 139 69 66 66 66
50293 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50294 -
50295 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50296 -26 26 26 70 70 70 149 139 69 210 150 10 236 178 12 246 190 14 246 190 14 246 190 14
50297 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50298 -246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 121 92 8 34 34 34 106 106 106
50299 -221 221 221 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50300 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50301 -242 242 242 82 82 82 20 16 6 163 110 8 216 158 10 236 178 12 242 186 14 246 190 14
50302 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50303 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 149 139 69
50304 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50305 -
50306 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50307 -30 30 30 78 78 78 149 139 69 210 150 10 236 178 12 246 186 14 246 190 14 246 190 14
50308 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50309 -246 190 14 246 190 14 246 190 14 246 190 14 241 196 14 220 174 15 198 179 130 253 253 253
50310 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50311 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 218 218 218
50312 -58 58 58 2 2 6 20 16 6 167 114 7 216 158 10 236 178 12 246 186 14 246 190 14
50313 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50314 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 242 186 14 185 146 40
50315 -54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50316 -
50317 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50318 -38 38 38 86 86 86 169 125 40 213 154 11 236 178 12 246 186 14 246 190 14 246 190 14
50319 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50320 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 190 146 13 214 214 214
50321 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50322 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 170 170 170 26 26 26
50323 -2 2 6 2 2 6 35 31 12 163 110 8 219 162 10 239 182 13 246 186 14 246 190 14
50324 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50325 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 224 166 10 149 139 69
50326 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50327 -
50328 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50329 -50 50 50 113 101 86 192 133 9 224 166 10 242 186 14 246 190 14 246 190 14 246 190 14
50330 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50331 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 230 187 11 204 160 10 133 118 54
50332 -226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50333 -253 253 253 253 253 253 253 253 253 253 253 253 198 198 198 66 66 66 2 2 6 2 2 6
50334 -2 2 6 2 2 6 62 42 6 156 107 11 219 162 10 239 182 13 246 186 14 246 190 14
50335 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50336 -246 190 14 246 190 14 246 190 14 242 186 14 234 174 13 213 154 11 148 132 55 66 66 66
50337 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50338 -
50339 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50340 -58 58 58 148 132 55 206 145 10 234 174 13 242 186 14 246 186 14 246 190 14 246 190 14
50341 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50342 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 204 160 10 163 110 8
50343 -62 42 6 124 131 137 218 218 218 250 250 250 253 253 253 253 253 253 253 253 253 250 250 250
50344 -242 242 242 210 210 210 151 151 151 66 66 66 6 6 6 2 2 6 2 2 6 2 2 6
50345 -2 2 6 2 2 6 62 42 6 163 110 8 216 158 10 236 178 12 246 190 14 246 190 14
50346 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50347 -246 190 14 239 182 13 230 174 11 216 158 10 185 146 40 124 112 88 70 70 70 38 38 38
50348 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50349 -
50350 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50351 -62 62 62 169 125 40 206 145 10 224 166 10 236 178 12 239 182 13 242 186 14 242 186 14
50352 -246 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50353 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 236 178 12 216 158 10 171 120 8
50354 -85 57 6 2 2 6 6 6 6 30 30 30 54 54 54 62 62 62 50 50 50 38 38 38
50355 -14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50356 -2 2 6 6 6 6 85 57 6 167 114 7 213 154 11 236 178 12 246 190 14 246 190 14
50357 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 239 182 13 239 182 13
50358 -230 174 11 210 150 10 174 140 55 124 112 88 82 82 82 54 54 54 34 34 34 18 18 18
50359 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50360 -
50361 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50362 -50 50 50 169 125 40 192 133 9 200 144 11 216 158 10 219 162 10 224 166 10 226 170 11
50363 -230 174 11 236 178 12 239 182 13 239 182 13 242 186 14 246 186 14 246 190 14 246 190 14
50364 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 230 174 11 210 150 10 163 110 8
50365 -104 69 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50366 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50367 -2 2 6 6 6 6 85 57 6 167 114 7 206 145 10 230 174 11 242 186 14 246 190 14
50368 -246 190 14 246 190 14 246 186 14 242 186 14 239 182 13 230 174 11 224 166 10 213 154 11
50369 -169 125 40 124 112 88 86 86 86 58 58 58 38 38 38 22 22 22 10 10 10 6 6 6
50370 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50371 -
50372 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50373 -34 34 34 70 70 70 133 118 54 169 125 40 167 114 7 180 123 7 192 133 9 197 138 11
50374 -200 144 11 206 145 10 213 154 11 219 162 10 224 166 10 230 174 11 239 182 13 242 186 14
50375 -246 186 14 246 186 14 246 186 14 246 186 14 239 182 13 216 158 10 184 138 11 152 99 6
50376 -104 69 6 20 16 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50377 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50378 -2 2 6 6 6 6 85 57 6 152 99 6 192 133 9 219 162 10 236 178 12 239 182 13
50379 -246 186 14 242 186 14 239 182 13 236 178 12 224 166 10 206 145 10 192 133 9 148 132 55
50380 -94 94 94 62 62 62 42 42 42 22 22 22 14 14 14 6 6 6 0 0 0 0 0 0
50381 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50382 -
50383 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50384 -18 18 18 34 34 34 58 58 58 78 78 78 101 98 89 124 112 88 133 118 54 156 107 11
50385 -163 110 8 167 114 7 171 120 8 180 123 7 184 138 11 197 138 11 210 150 10 219 162 10
50386 -226 170 11 236 178 12 236 178 12 234 174 13 219 162 10 197 138 11 163 110 8 134 84 6
50387 -85 57 6 10 10 10 2 2 6 2 2 6 18 18 18 38 38 38 38 38 38 38 38 38
50388 -38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 26 26 26 2 2 6
50389 -2 2 6 6 6 6 62 42 6 137 92 6 171 120 8 200 144 11 219 162 10 230 174 11
50390 -234 174 13 230 174 11 219 162 10 210 150 10 192 133 9 163 110 8 124 112 88 82 82 82
50391 -50 50 50 30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50392 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50393 -
50394 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50395 -6 6 6 14 14 14 22 22 22 34 34 34 42 42 42 58 58 58 74 74 74 86 86 86
50396 -101 98 89 113 101 86 133 118 54 121 92 8 137 92 6 152 99 6 163 110 8 180 123 7
50397 -184 138 11 197 138 11 206 145 10 200 144 11 180 123 7 156 107 11 134 84 6 104 69 6
50398 -62 42 6 54 54 54 106 106 106 101 98 89 86 86 86 82 82 82 78 78 78 78 78 78
50399 -78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 82 82 82 86 86 86 94 94 94
50400 -106 106 106 101 101 101 90 61 47 120 80 7 156 107 11 180 123 7 192 133 9 200 144 11
50401 -206 145 10 200 144 11 192 133 9 171 120 8 139 102 15 113 101 86 70 70 70 42 42 42
50402 -22 22 22 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50403 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50404 -
50405 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50406 -0 0 0 0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 30 30 30 38 38 38
50407 -50 50 50 62 62 62 74 74 74 90 90 90 101 98 89 113 101 86 121 92 8 120 80 7
50408 -137 92 6 152 99 6 152 99 6 152 99 6 134 84 6 120 80 7 98 70 6 88 55 22
50409 -101 98 89 82 82 82 58 58 58 46 46 46 38 38 38 34 34 34 34 34 34 34 34 34
50410 -34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 38 38 38 42 42 42
50411 -54 54 54 82 82 82 94 86 71 85 57 6 134 84 6 156 107 11 167 114 7 171 120 8
50412 -171 120 8 167 114 7 152 99 6 121 92 8 101 98 89 62 62 62 34 34 34 18 18 18
50413 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50414 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50415 -
50416 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50417 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10
50418 -18 18 18 22 22 22 30 30 30 42 42 42 50 50 50 66 66 66 86 86 86 101 98 89
50419 -94 86 71 98 70 6 104 69 6 104 69 6 104 69 6 85 57 6 88 55 22 90 90 90
50420 -62 62 62 38 38 38 22 22 22 14 14 14 10 10 10 10 10 10 10 10 10 10 10 10
50421 -10 10 10 10 10 10 6 6 6 10 10 10 10 10 10 10 10 10 10 10 10 14 14 14
50422 -22 22 22 42 42 42 70 70 70 94 86 71 85 57 6 104 69 6 120 80 7 137 92 6
50423 -134 84 6 120 80 7 94 86 71 86 86 86 58 58 58 30 30 30 14 14 14 6 6 6
50424 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50425 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50426 -
50427 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50428 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50429 -0 0 0 6 6 6 10 10 10 14 14 14 18 18 18 26 26 26 38 38 38 54 54 54
50430 -70 70 70 86 86 86 94 86 71 94 86 71 94 86 71 86 86 86 74 74 74 50 50 50
50431 -30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50432 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50433 -6 6 6 18 18 18 34 34 34 58 58 58 82 82 82 94 86 71 94 86 71 94 86 71
50434 -94 86 71 94 86 71 74 74 74 50 50 50 26 26 26 14 14 14 6 6 6 0 0 0
50435 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50436 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50437 -
50438 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50439 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50440 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 14 14 14 18 18 18
50441 -30 30 30 38 38 38 46 46 46 54 54 54 50 50 50 42 42 42 30 30 30 18 18 18
50442 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50443 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50444 -0 0 0 6 6 6 14 14 14 26 26 26 38 38 38 50 50 50 58 58 58 58 58 58
50445 -54 54 54 42 42 42 30 30 30 18 18 18 10 10 10 0 0 0 0 0 0 0 0 0
50446 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50447 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50448 -
50449 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50450 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50451 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50452 -6 6 6 10 10 10 14 14 14 18 18 18 18 18 18 14 14 14 10 10 10 6 6 6
50453 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50454 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50455 -0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 18 18 18 22 22 22 22 22 22
50456 -18 18 18 14 14 14 10 10 10 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50457 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50458 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50459 -
50460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50473 +4 4 4 4 4 4
50474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50487 +4 4 4 4 4 4
50488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50501 +4 4 4 4 4 4
50502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50515 +4 4 4 4 4 4
50516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50529 +4 4 4 4 4 4
50530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50543 +4 4 4 4 4 4
50544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50548 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
50549 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
50550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50553 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
50554 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50555 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
50556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50557 +4 4 4 4 4 4
50558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50562 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
50563 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
50564 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50567 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
50568 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
50569 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
50570 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50571 +4 4 4 4 4 4
50572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50576 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
50577 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
50578 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50581 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
50582 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
50583 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
50584 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
50585 +4 4 4 4 4 4
50586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50589 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
50590 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
50591 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
50592 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
50593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50594 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50595 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
50596 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
50597 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
50598 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
50599 +4 4 4 4 4 4
50600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50603 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
50604 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
50605 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
50606 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
50607 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
50608 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
50609 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
50610 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
50611 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
50612 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
50613 +4 4 4 4 4 4
50614 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
50617 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
50618 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
50619 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
50620 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
50621 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
50622 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
50623 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
50624 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
50625 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
50626 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
50627 +4 4 4 4 4 4
50628 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50630 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
50631 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
50632 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
50633 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
50634 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
50635 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
50636 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
50637 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
50638 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
50639 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
50640 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
50641 +4 4 4 4 4 4
50642 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50644 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
50645 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
50646 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
50647 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
50648 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
50649 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
50650 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
50651 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
50652 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
50653 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
50654 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
50655 +4 4 4 4 4 4
50656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50658 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
50659 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
50660 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
50661 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
50662 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
50663 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
50664 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
50665 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
50666 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
50667 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
50668 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50669 +4 4 4 4 4 4
50670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50672 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
50673 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
50674 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
50675 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
50676 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
50677 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
50678 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
50679 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
50680 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
50681 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
50682 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
50683 +4 4 4 4 4 4
50684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50685 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
50686 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
50687 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
50688 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
50689 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
50690 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
50691 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
50692 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
50693 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
50694 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
50695 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
50696 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
50697 +4 4 4 4 4 4
50698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50699 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
50700 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
50701 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
50702 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
50703 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
50704 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
50705 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
50706 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
50707 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
50708 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
50709 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
50710 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
50711 +0 0 0 4 4 4
50712 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50713 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
50714 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
50715 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
50716 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
50717 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
50718 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
50719 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
50720 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
50721 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
50722 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
50723 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
50724 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
50725 +2 0 0 0 0 0
50726 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
50727 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
50728 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
50729 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
50730 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
50731 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
50732 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
50733 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
50734 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
50735 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
50736 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
50737 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
50738 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
50739 +37 38 37 0 0 0
50740 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50741 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
50742 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
50743 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
50744 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
50745 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
50746 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
50747 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
50748 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
50749 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
50750 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
50751 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
50752 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
50753 +85 115 134 4 0 0
50754 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
50755 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
50756 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
50757 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
50758 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
50759 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
50760 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
50761 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
50762 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
50763 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
50764 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
50765 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
50766 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
50767 +60 73 81 4 0 0
50768 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
50769 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
50770 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
50771 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
50772 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
50773 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
50774 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
50775 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
50776 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
50777 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
50778 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
50779 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
50780 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
50781 +16 19 21 4 0 0
50782 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
50783 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
50784 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
50785 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
50786 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
50787 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
50788 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
50789 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
50790 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
50791 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
50792 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
50793 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
50794 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
50795 +4 0 0 4 3 3
50796 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
50797 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
50798 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
50799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
50800 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
50801 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
50802 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
50803 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
50804 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
50805 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
50806 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
50807 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
50808 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
50809 +3 2 2 4 4 4
50810 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
50811 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
50812 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
50813 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50814 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
50815 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
50816 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50817 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
50818 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
50819 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
50820 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
50821 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
50822 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
50823 +4 4 4 4 4 4
50824 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
50825 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
50826 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
50827 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
50828 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
50829 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
50830 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
50831 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
50832 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
50833 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
50834 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
50835 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
50836 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
50837 +4 4 4 4 4 4
50838 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
50839 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
50840 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
50841 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
50842 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
50843 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50844 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
50845 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
50846 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
50847 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
50848 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
50849 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
50850 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
50851 +5 5 5 5 5 5
50852 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
50853 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
50854 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
50855 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
50856 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
50857 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50858 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
50859 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
50860 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
50861 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
50862 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
50863 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
50864 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
50865 +5 5 5 4 4 4
50866 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
50867 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
50868 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
50869 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
50870 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50871 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
50872 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
50873 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
50874 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
50875 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
50876 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
50877 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
50878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50879 +4 4 4 4 4 4
50880 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
50881 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
50882 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
50883 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
50884 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
50885 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50886 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50887 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
50888 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
50889 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
50890 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
50891 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
50892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50893 +4 4 4 4 4 4
50894 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
50895 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
50896 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
50897 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
50898 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50899 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
50900 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
50901 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
50902 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
50903 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
50904 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
50905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50907 +4 4 4 4 4 4
50908 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
50909 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
50910 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
50911 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
50912 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50913 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50914 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50915 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
50916 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
50917 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
50918 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
50919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50921 +4 4 4 4 4 4
50922 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
50923 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
50924 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
50925 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
50926 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50927 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
50928 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50929 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
50930 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
50931 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
50932 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50935 +4 4 4 4 4 4
50936 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
50937 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
50938 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
50939 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
50940 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50941 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
50942 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
50943 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
50944 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
50945 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
50946 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
50947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50949 +4 4 4 4 4 4
50950 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
50951 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
50952 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
50953 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
50954 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50955 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
50956 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
50957 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
50958 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
50959 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
50960 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
50961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50963 +4 4 4 4 4 4
50964 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
50965 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
50966 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
50967 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50968 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
50969 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
50970 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
50971 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
50972 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
50973 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
50974 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50977 +4 4 4 4 4 4
50978 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
50979 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
50980 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
50981 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
50982 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50983 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
50984 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
50985 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
50986 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
50987 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
50988 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50991 +4 4 4 4 4 4
50992 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
50993 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
50994 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
50995 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50996 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50997 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
50998 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
50999 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
51000 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
51001 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51002 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51005 +4 4 4 4 4 4
51006 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51007 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51008 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51009 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51010 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51011 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51012 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51013 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51014 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51015 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51016 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51019 +4 4 4 4 4 4
51020 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51021 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51022 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51023 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51024 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51025 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51026 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51027 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51028 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51029 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51030 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51033 +4 4 4 4 4 4
51034 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51035 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51036 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51037 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51038 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51039 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51040 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51041 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51042 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51043 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51044 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51047 +4 4 4 4 4 4
51048 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51049 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51050 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51051 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51052 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51053 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51054 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51055 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51056 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51057 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51058 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51059 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51061 +4 4 4 4 4 4
51062 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51063 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51064 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51065 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51066 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51067 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51068 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51069 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51070 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51071 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51072 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51075 +4 4 4 4 4 4
51076 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51077 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51078 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51079 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51080 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51081 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51082 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51083 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51084 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51085 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51086 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51089 +4 4 4 4 4 4
51090 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51091 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51092 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51093 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51094 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51095 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51096 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51097 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51098 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51099 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51100 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51103 +4 4 4 4 4 4
51104 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51105 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51106 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51107 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51108 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51109 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51110 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51111 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51112 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51113 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51114 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51117 +4 4 4 4 4 4
51118 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51119 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51120 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51121 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51122 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51123 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51124 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51125 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51126 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51127 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51128 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51131 +4 4 4 4 4 4
51132 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51133 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51134 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51135 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51136 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51137 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51138 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51139 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51140 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51141 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51142 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51145 +4 4 4 4 4 4
51146 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51147 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51148 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51149 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51150 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51151 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51152 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51153 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51154 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51155 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51156 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51158 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51159 +4 4 4 4 4 4
51160 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51161 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51162 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51163 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51164 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51165 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51166 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51167 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51168 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51169 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51170 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51172 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51173 +4 4 4 4 4 4
51174 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51175 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51176 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51177 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51178 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51179 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51180 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51181 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51182 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51183 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51184 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51186 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51187 +4 4 4 4 4 4
51188 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51189 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51190 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51191 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51192 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51193 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51194 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51195 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51196 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51197 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51198 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51200 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51201 +4 4 4 4 4 4
51202 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51203 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51204 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51205 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51206 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51207 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51208 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51209 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51210 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51211 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51212 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51214 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51215 +4 4 4 4 4 4
51216 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51217 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51218 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51219 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51220 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51221 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51222 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51223 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51224 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51225 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51226 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51227 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51228 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51229 +4 4 4 4 4 4
51230 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51231 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51232 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51233 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51234 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51235 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51236 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51237 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51238 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51239 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51240 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51241 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51242 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51243 +4 4 4 4 4 4
51244 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51245 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51246 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51247 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51248 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51249 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51250 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51251 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51252 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51253 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51254 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51255 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51256 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51257 +4 4 4 4 4 4
51258 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51259 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51260 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51261 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51262 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51263 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51264 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51265 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51266 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51267 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51268 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51269 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51270 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51271 +4 4 4 4 4 4
51272 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51273 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51274 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51275 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51276 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51277 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51278 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51279 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51280 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51281 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51282 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51283 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51284 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51285 +4 4 4 4 4 4
51286 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51287 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51288 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51289 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51290 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51291 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51292 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51293 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51294 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51295 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51296 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51297 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51298 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51299 +4 4 4 4 4 4
51300 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51301 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51302 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51303 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51304 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51305 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51306 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51307 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51308 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51309 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51311 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51312 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51313 +4 4 4 4 4 4
51314 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51315 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51316 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51317 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51318 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51319 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51320 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51321 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51322 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51323 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51325 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51326 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51327 +4 4 4 4 4 4
51328 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51329 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51330 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51331 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51332 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51333 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51334 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51335 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51336 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51339 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51340 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51341 +4 4 4 4 4 4
51342 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51343 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51344 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51345 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51346 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51347 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51348 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51349 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51350 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51352 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51353 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51354 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51355 +4 4 4 4 4 4
51356 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51357 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51358 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51359 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51360 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51361 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51362 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51363 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51364 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51366 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51369 +4 4 4 4 4 4
51370 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51371 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51372 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51373 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51374 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51375 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51376 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51377 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51380 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51383 +4 4 4 4 4 4
51384 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51385 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51386 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51387 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51388 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51389 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51390 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51391 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51394 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51397 +4 4 4 4 4 4
51398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51399 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51400 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51401 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51402 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51403 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51404 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51405 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51411 +4 4 4 4 4 4
51412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51413 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51414 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51415 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51416 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51417 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51418 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51419 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51421 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51425 +4 4 4 4 4 4
51426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51427 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51428 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51429 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51430 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51431 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51432 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51433 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51435 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51439 +4 4 4 4 4 4
51440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51442 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51443 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51444 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51445 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51446 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51447 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51453 +4 4 4 4 4 4
51454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51457 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51458 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51459 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51460 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
51461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51467 +4 4 4 4 4 4
51468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51471 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51472 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51473 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51474 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
51475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51481 +4 4 4 4 4 4
51482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51485 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51486 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51487 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51488 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51495 +4 4 4 4 4 4
51496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51499 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51500 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51501 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51502 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51509 +4 4 4 4 4 4
51510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51514 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51515 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51516 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51523 +4 4 4 4 4 4
51524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51528 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51529 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51530 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51537 +4 4 4 4 4 4
51538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51542 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
51543 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
51544 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51551 +4 4 4 4 4 4
51552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51556 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
51557 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
51558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51565 +4 4 4 4 4 4
51566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51570 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51571 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
51572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51576 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51577 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51579 +4 4 4 4 4 4
51580 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
51581 index fe92eed..106e085 100644
51582 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
51583 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
51584 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
51585 struct mb862xxfb_par *par = info->par;
51586
51587 if (info->var.bits_per_pixel == 32) {
51588 - info->fbops->fb_fillrect = cfb_fillrect;
51589 - info->fbops->fb_copyarea = cfb_copyarea;
51590 - info->fbops->fb_imageblit = cfb_imageblit;
51591 + pax_open_kernel();
51592 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51593 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51594 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51595 + pax_close_kernel();
51596 } else {
51597 outreg(disp, GC_L0EM, 3);
51598 - info->fbops->fb_fillrect = mb86290fb_fillrect;
51599 - info->fbops->fb_copyarea = mb86290fb_copyarea;
51600 - info->fbops->fb_imageblit = mb86290fb_imageblit;
51601 + pax_open_kernel();
51602 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
51603 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
51604 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
51605 + pax_close_kernel();
51606 }
51607 outreg(draw, GDC_REG_DRAW_BASE, 0);
51608 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
51609 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
51610 index ff22871..b129bed 100644
51611 --- a/drivers/video/nvidia/nvidia.c
51612 +++ b/drivers/video/nvidia/nvidia.c
51613 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
51614 info->fix.line_length = (info->var.xres_virtual *
51615 info->var.bits_per_pixel) >> 3;
51616 if (info->var.accel_flags) {
51617 - info->fbops->fb_imageblit = nvidiafb_imageblit;
51618 - info->fbops->fb_fillrect = nvidiafb_fillrect;
51619 - info->fbops->fb_copyarea = nvidiafb_copyarea;
51620 - info->fbops->fb_sync = nvidiafb_sync;
51621 + pax_open_kernel();
51622 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
51623 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
51624 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
51625 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
51626 + pax_close_kernel();
51627 info->pixmap.scan_align = 4;
51628 info->flags &= ~FBINFO_HWACCEL_DISABLED;
51629 info->flags |= FBINFO_READS_FAST;
51630 NVResetGraphics(info);
51631 } else {
51632 - info->fbops->fb_imageblit = cfb_imageblit;
51633 - info->fbops->fb_fillrect = cfb_fillrect;
51634 - info->fbops->fb_copyarea = cfb_copyarea;
51635 - info->fbops->fb_sync = NULL;
51636 + pax_open_kernel();
51637 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51638 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51639 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51640 + *(void **)&info->fbops->fb_sync = NULL;
51641 + pax_close_kernel();
51642 info->pixmap.scan_align = 1;
51643 info->flags |= FBINFO_HWACCEL_DISABLED;
51644 info->flags &= ~FBINFO_READS_FAST;
51645 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
51646 info->pixmap.size = 8 * 1024;
51647 info->pixmap.flags = FB_PIXMAP_SYSTEM;
51648
51649 - if (!hwcur)
51650 - info->fbops->fb_cursor = NULL;
51651 + if (!hwcur) {
51652 + pax_open_kernel();
51653 + *(void **)&info->fbops->fb_cursor = NULL;
51654 + pax_close_kernel();
51655 + }
51656
51657 info->var.accel_flags = (!noaccel);
51658
51659 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
51660 index 05c2dc3..ea1f391 100644
51661 --- a/drivers/video/s1d13xxxfb.c
51662 +++ b/drivers/video/s1d13xxxfb.c
51663 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
51664
51665 switch(prod_id) {
51666 case S1D13506_PROD_ID: /* activate acceleration */
51667 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51668 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51669 + pax_open_kernel();
51670 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51671 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51672 + pax_close_kernel();
51673 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
51674 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
51675 break;
51676 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
51677 index e188ada..aac63c8 100644
51678 --- a/drivers/video/smscufx.c
51679 +++ b/drivers/video/smscufx.c
51680 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
51681 fb_deferred_io_cleanup(info);
51682 kfree(info->fbdefio);
51683 info->fbdefio = NULL;
51684 - info->fbops->fb_mmap = ufx_ops_mmap;
51685 + pax_open_kernel();
51686 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
51687 + pax_close_kernel();
51688 }
51689
51690 pr_debug("released /dev/fb%d user=%d count=%d",
51691 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
51692 index d2e5bc3..4cb05d1 100644
51693 --- a/drivers/video/udlfb.c
51694 +++ b/drivers/video/udlfb.c
51695 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
51696 dlfb_urb_completion(urb);
51697
51698 error:
51699 - atomic_add(bytes_sent, &dev->bytes_sent);
51700 - atomic_add(bytes_identical, &dev->bytes_identical);
51701 - atomic_add(width*height*2, &dev->bytes_rendered);
51702 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51703 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51704 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
51705 end_cycles = get_cycles();
51706 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51707 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51708 >> 10)), /* Kcycles */
51709 &dev->cpu_kcycles_used);
51710
51711 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
51712 dlfb_urb_completion(urb);
51713
51714 error:
51715 - atomic_add(bytes_sent, &dev->bytes_sent);
51716 - atomic_add(bytes_identical, &dev->bytes_identical);
51717 - atomic_add(bytes_rendered, &dev->bytes_rendered);
51718 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51719 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51720 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
51721 end_cycles = get_cycles();
51722 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51723 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51724 >> 10)), /* Kcycles */
51725 &dev->cpu_kcycles_used);
51726 }
51727 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
51728 fb_deferred_io_cleanup(info);
51729 kfree(info->fbdefio);
51730 info->fbdefio = NULL;
51731 - info->fbops->fb_mmap = dlfb_ops_mmap;
51732 + pax_open_kernel();
51733 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
51734 + pax_close_kernel();
51735 }
51736
51737 pr_warn("released /dev/fb%d user=%d count=%d\n",
51738 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
51739 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51740 struct dlfb_data *dev = fb_info->par;
51741 return snprintf(buf, PAGE_SIZE, "%u\n",
51742 - atomic_read(&dev->bytes_rendered));
51743 + atomic_read_unchecked(&dev->bytes_rendered));
51744 }
51745
51746 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51747 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51748 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51749 struct dlfb_data *dev = fb_info->par;
51750 return snprintf(buf, PAGE_SIZE, "%u\n",
51751 - atomic_read(&dev->bytes_identical));
51752 + atomic_read_unchecked(&dev->bytes_identical));
51753 }
51754
51755 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51756 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51757 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51758 struct dlfb_data *dev = fb_info->par;
51759 return snprintf(buf, PAGE_SIZE, "%u\n",
51760 - atomic_read(&dev->bytes_sent));
51761 + atomic_read_unchecked(&dev->bytes_sent));
51762 }
51763
51764 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51765 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51766 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51767 struct dlfb_data *dev = fb_info->par;
51768 return snprintf(buf, PAGE_SIZE, "%u\n",
51769 - atomic_read(&dev->cpu_kcycles_used));
51770 + atomic_read_unchecked(&dev->cpu_kcycles_used));
51771 }
51772
51773 static ssize_t edid_show(
51774 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
51775 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51776 struct dlfb_data *dev = fb_info->par;
51777
51778 - atomic_set(&dev->bytes_rendered, 0);
51779 - atomic_set(&dev->bytes_identical, 0);
51780 - atomic_set(&dev->bytes_sent, 0);
51781 - atomic_set(&dev->cpu_kcycles_used, 0);
51782 + atomic_set_unchecked(&dev->bytes_rendered, 0);
51783 + atomic_set_unchecked(&dev->bytes_identical, 0);
51784 + atomic_set_unchecked(&dev->bytes_sent, 0);
51785 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
51786
51787 return count;
51788 }
51789 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
51790 index 7aec6f3..e3b2d55 100644
51791 --- a/drivers/video/uvesafb.c
51792 +++ b/drivers/video/uvesafb.c
51793 @@ -19,6 +19,7 @@
51794 #include <linux/io.h>
51795 #include <linux/mutex.h>
51796 #include <linux/slab.h>
51797 +#include <linux/moduleloader.h>
51798 #include <video/edid.h>
51799 #include <video/uvesafb.h>
51800 #ifdef CONFIG_X86
51801 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
51802 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
51803 par->pmi_setpal = par->ypan = 0;
51804 } else {
51805 +
51806 +#ifdef CONFIG_PAX_KERNEXEC
51807 +#ifdef CONFIG_MODULES
51808 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
51809 +#endif
51810 + if (!par->pmi_code) {
51811 + par->pmi_setpal = par->ypan = 0;
51812 + return 0;
51813 + }
51814 +#endif
51815 +
51816 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
51817 + task->t.regs.edi);
51818 +
51819 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51820 + pax_open_kernel();
51821 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
51822 + pax_close_kernel();
51823 +
51824 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
51825 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
51826 +#else
51827 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
51828 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
51829 +#endif
51830 +
51831 printk(KERN_INFO "uvesafb: protected mode interface info at "
51832 "%04x:%04x\n",
51833 (u16)task->t.regs.es, (u16)task->t.regs.edi);
51834 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
51835 par->ypan = ypan;
51836
51837 if (par->pmi_setpal || par->ypan) {
51838 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
51839 if (__supported_pte_mask & _PAGE_NX) {
51840 par->pmi_setpal = par->ypan = 0;
51841 printk(KERN_WARNING "uvesafb: NX protection is active, "
51842 "better not use the PMI.\n");
51843 - } else {
51844 + } else
51845 +#endif
51846 uvesafb_vbe_getpmi(task, par);
51847 - }
51848 }
51849 #else
51850 /* The protected mode interface is not available on non-x86. */
51851 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51852 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
51853
51854 /* Disable blanking if the user requested so. */
51855 - if (!blank)
51856 - info->fbops->fb_blank = NULL;
51857 + if (!blank) {
51858 + pax_open_kernel();
51859 + *(void **)&info->fbops->fb_blank = NULL;
51860 + pax_close_kernel();
51861 + }
51862
51863 /*
51864 * Find out how much IO memory is required for the mode with
51865 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51866 info->flags = FBINFO_FLAG_DEFAULT |
51867 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
51868
51869 - if (!par->ypan)
51870 - info->fbops->fb_pan_display = NULL;
51871 + if (!par->ypan) {
51872 + pax_open_kernel();
51873 + *(void **)&info->fbops->fb_pan_display = NULL;
51874 + pax_close_kernel();
51875 + }
51876 }
51877
51878 static void uvesafb_init_mtrr(struct fb_info *info)
51879 @@ -1796,6 +1826,11 @@ out:
51880 if (par->vbe_modes)
51881 kfree(par->vbe_modes);
51882
51883 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51884 + if (par->pmi_code)
51885 + module_free_exec(NULL, par->pmi_code);
51886 +#endif
51887 +
51888 framebuffer_release(info);
51889 return err;
51890 }
51891 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
51892 kfree(par->vbe_state_orig);
51893 if (par->vbe_state_saved)
51894 kfree(par->vbe_state_saved);
51895 +
51896 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51897 + if (par->pmi_code)
51898 + module_free_exec(NULL, par->pmi_code);
51899 +#endif
51900 +
51901 }
51902
51903 framebuffer_release(info);
51904 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
51905 index 501b340..d80aa17 100644
51906 --- a/drivers/video/vesafb.c
51907 +++ b/drivers/video/vesafb.c
51908 @@ -9,6 +9,7 @@
51909 */
51910
51911 #include <linux/module.h>
51912 +#include <linux/moduleloader.h>
51913 #include <linux/kernel.h>
51914 #include <linux/errno.h>
51915 #include <linux/string.h>
51916 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
51917 static int vram_total __initdata; /* Set total amount of memory */
51918 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
51919 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
51920 -static void (*pmi_start)(void) __read_mostly;
51921 -static void (*pmi_pal) (void) __read_mostly;
51922 +static void (*pmi_start)(void) __read_only;
51923 +static void (*pmi_pal) (void) __read_only;
51924 static int depth __read_mostly;
51925 static int vga_compat __read_mostly;
51926 /* --------------------------------------------------------------------- */
51927 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
51928 unsigned int size_vmode;
51929 unsigned int size_remap;
51930 unsigned int size_total;
51931 + void *pmi_code = NULL;
51932
51933 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
51934 return -ENODEV;
51935 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
51936 size_remap = size_total;
51937 vesafb_fix.smem_len = size_remap;
51938
51939 -#ifndef __i386__
51940 - screen_info.vesapm_seg = 0;
51941 -#endif
51942 -
51943 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
51944 printk(KERN_WARNING
51945 "vesafb: cannot reserve video memory at 0x%lx\n",
51946 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
51947 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
51948 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
51949
51950 +#ifdef __i386__
51951 +
51952 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51953 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
51954 + if (!pmi_code)
51955 +#elif !defined(CONFIG_PAX_KERNEXEC)
51956 + if (0)
51957 +#endif
51958 +
51959 +#endif
51960 + screen_info.vesapm_seg = 0;
51961 +
51962 if (screen_info.vesapm_seg) {
51963 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
51964 - screen_info.vesapm_seg,screen_info.vesapm_off);
51965 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
51966 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
51967 }
51968
51969 if (screen_info.vesapm_seg < 0xc000)
51970 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
51971
51972 if (ypan || pmi_setpal) {
51973 unsigned short *pmi_base;
51974 +
51975 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
51976 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
51977 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
51978 +
51979 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51980 + pax_open_kernel();
51981 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
51982 +#else
51983 + pmi_code = pmi_base;
51984 +#endif
51985 +
51986 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
51987 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
51988 +
51989 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51990 + pmi_start = ktva_ktla(pmi_start);
51991 + pmi_pal = ktva_ktla(pmi_pal);
51992 + pax_close_kernel();
51993 +#endif
51994 +
51995 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
51996 if (pmi_base[3]) {
51997 printk(KERN_INFO "vesafb: pmi: ports = ");
51998 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
51999 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
52000 (ypan ? FBINFO_HWACCEL_YPAN : 0);
52001
52002 - if (!ypan)
52003 - info->fbops->fb_pan_display = NULL;
52004 + if (!ypan) {
52005 + pax_open_kernel();
52006 + *(void **)&info->fbops->fb_pan_display = NULL;
52007 + pax_close_kernel();
52008 + }
52009
52010 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52011 err = -ENOMEM;
52012 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52013 info->node, info->fix.id);
52014 return 0;
52015 err:
52016 +
52017 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52018 + module_free_exec(NULL, pmi_code);
52019 +#endif
52020 +
52021 if (info->screen_base)
52022 iounmap(info->screen_base);
52023 framebuffer_release(info);
52024 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52025 index 88714ae..16c2e11 100644
52026 --- a/drivers/video/via/via_clock.h
52027 +++ b/drivers/video/via/via_clock.h
52028 @@ -56,7 +56,7 @@ struct via_clock {
52029
52030 void (*set_engine_pll_state)(u8 state);
52031 void (*set_engine_pll)(struct via_pll_config config);
52032 -};
52033 +} __no_const;
52034
52035
52036 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52037 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52038 index fef20db..d28b1ab 100644
52039 --- a/drivers/xen/xenfs/xenstored.c
52040 +++ b/drivers/xen/xenfs/xenstored.c
52041 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52042 static int xsd_kva_open(struct inode *inode, struct file *file)
52043 {
52044 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52045 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52046 + NULL);
52047 +#else
52048 xen_store_interface);
52049 +#endif
52050 +
52051 if (!file->private_data)
52052 return -ENOMEM;
52053 return 0;
52054 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52055 index 9ff073f..05cef23 100644
52056 --- a/fs/9p/vfs_addr.c
52057 +++ b/fs/9p/vfs_addr.c
52058 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52059
52060 retval = v9fs_file_write_internal(inode,
52061 v9inode->writeback_fid,
52062 - (__force const char __user *)buffer,
52063 + (const char __force_user *)buffer,
52064 len, &offset, 0);
52065 if (retval > 0)
52066 retval = 0;
52067 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52068 index 25b018e..b941525 100644
52069 --- a/fs/9p/vfs_inode.c
52070 +++ b/fs/9p/vfs_inode.c
52071 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52072 void
52073 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52074 {
52075 - char *s = nd_get_link(nd);
52076 + const char *s = nd_get_link(nd);
52077
52078 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52079 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52080 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52081 index 370b24c..ff0be7b 100644
52082 --- a/fs/Kconfig.binfmt
52083 +++ b/fs/Kconfig.binfmt
52084 @@ -103,7 +103,7 @@ config HAVE_AOUT
52085
52086 config BINFMT_AOUT
52087 tristate "Kernel support for a.out and ECOFF binaries"
52088 - depends on HAVE_AOUT
52089 + depends on HAVE_AOUT && BROKEN
52090 ---help---
52091 A.out (Assembler.OUTput) is a set of formats for libraries and
52092 executables used in the earliest versions of UNIX. Linux used
52093 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52094 index 789bc25..fafaeea 100644
52095 --- a/fs/afs/inode.c
52096 +++ b/fs/afs/inode.c
52097 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52098 struct afs_vnode *vnode;
52099 struct super_block *sb;
52100 struct inode *inode;
52101 - static atomic_t afs_autocell_ino;
52102 + static atomic_unchecked_t afs_autocell_ino;
52103
52104 _enter("{%x:%u},%*.*s,",
52105 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52106 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52107 data.fid.unique = 0;
52108 data.fid.vnode = 0;
52109
52110 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52111 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52112 afs_iget5_autocell_test, afs_iget5_set,
52113 &data);
52114 if (!inode) {
52115 diff --git a/fs/aio.c b/fs/aio.c
52116 index 9b5ca11..c530886 100644
52117 --- a/fs/aio.c
52118 +++ b/fs/aio.c
52119 @@ -162,7 +162,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52120 size += sizeof(struct io_event) * nr_events;
52121 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
52122
52123 - if (nr_pages < 0)
52124 + if (nr_pages <= 0)
52125 return -EINVAL;
52126
52127 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
52128 @@ -952,6 +952,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
52129 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52130 {
52131 ssize_t ret;
52132 + struct iovec iovstack;
52133
52134 kiocb->ki_nr_segs = kiocb->ki_nbytes;
52135
52136 @@ -959,17 +960,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52137 if (compat)
52138 ret = compat_rw_copy_check_uvector(rw,
52139 (struct compat_iovec __user *)kiocb->ki_buf,
52140 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52141 + kiocb->ki_nr_segs, 1, &iovstack,
52142 &kiocb->ki_iovec);
52143 else
52144 #endif
52145 ret = rw_copy_check_uvector(rw,
52146 (struct iovec __user *)kiocb->ki_buf,
52147 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52148 + kiocb->ki_nr_segs, 1, &iovstack,
52149 &kiocb->ki_iovec);
52150 if (ret < 0)
52151 return ret;
52152
52153 + if (kiocb->ki_iovec == &iovstack) {
52154 + kiocb->ki_inline_vec = iovstack;
52155 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
52156 + }
52157 +
52158 /* ki_nbytes now reflect bytes instead of segs */
52159 kiocb->ki_nbytes = ret;
52160 return 0;
52161 diff --git a/fs/attr.c b/fs/attr.c
52162 index 1449adb..a2038c2 100644
52163 --- a/fs/attr.c
52164 +++ b/fs/attr.c
52165 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52166 unsigned long limit;
52167
52168 limit = rlimit(RLIMIT_FSIZE);
52169 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52170 if (limit != RLIM_INFINITY && offset > limit)
52171 goto out_sig;
52172 if (offset > inode->i_sb->s_maxbytes)
52173 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52174 index 3db70da..7aeec5b 100644
52175 --- a/fs/autofs4/waitq.c
52176 +++ b/fs/autofs4/waitq.c
52177 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52178 {
52179 unsigned long sigpipe, flags;
52180 mm_segment_t fs;
52181 - const char *data = (const char *)addr;
52182 + const char __user *data = (const char __force_user *)addr;
52183 ssize_t wr = 0;
52184
52185 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52186 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52187 return 1;
52188 }
52189
52190 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52191 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52192 +#endif
52193 +
52194 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52195 enum autofs_notify notify)
52196 {
52197 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52198
52199 /* If this is a direct mount request create a dummy name */
52200 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52201 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52202 + /* this name does get written to userland via autofs4_write() */
52203 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52204 +#else
52205 qstr.len = sprintf(name, "%p", dentry);
52206 +#endif
52207 else {
52208 qstr.len = autofs4_getpath(sbi, dentry, &name);
52209 if (!qstr.len) {
52210 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52211 index 2722387..c8dd2a7 100644
52212 --- a/fs/befs/endian.h
52213 +++ b/fs/befs/endian.h
52214 @@ -11,7 +11,7 @@
52215
52216 #include <asm/byteorder.h>
52217
52218 -static inline u64
52219 +static inline u64 __intentional_overflow(-1)
52220 fs64_to_cpu(const struct super_block *sb, fs64 n)
52221 {
52222 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52223 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52224 return (__force fs64)cpu_to_be64(n);
52225 }
52226
52227 -static inline u32
52228 +static inline u32 __intentional_overflow(-1)
52229 fs32_to_cpu(const struct super_block *sb, fs32 n)
52230 {
52231 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52232 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52233 index e9c75e2..1baece1 100644
52234 --- a/fs/befs/linuxvfs.c
52235 +++ b/fs/befs/linuxvfs.c
52236 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52237 {
52238 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52239 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52240 - char *link = nd_get_link(nd);
52241 + const char *link = nd_get_link(nd);
52242 if (!IS_ERR(link))
52243 kfree(link);
52244 }
52245 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52246 index 89dec7f..361b0d75 100644
52247 --- a/fs/binfmt_aout.c
52248 +++ b/fs/binfmt_aout.c
52249 @@ -16,6 +16,7 @@
52250 #include <linux/string.h>
52251 #include <linux/fs.h>
52252 #include <linux/file.h>
52253 +#include <linux/security.h>
52254 #include <linux/stat.h>
52255 #include <linux/fcntl.h>
52256 #include <linux/ptrace.h>
52257 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52258 #endif
52259 # define START_STACK(u) ((void __user *)u.start_stack)
52260
52261 + memset(&dump, 0, sizeof(dump));
52262 +
52263 fs = get_fs();
52264 set_fs(KERNEL_DS);
52265 has_dumped = 1;
52266 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52267
52268 /* If the size of the dump file exceeds the rlimit, then see what would happen
52269 if we wrote the stack, but not the data area. */
52270 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52271 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52272 dump.u_dsize = 0;
52273
52274 /* Make sure we have enough room to write the stack and data areas. */
52275 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52276 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52277 dump.u_ssize = 0;
52278
52279 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52280 rlim = rlimit(RLIMIT_DATA);
52281 if (rlim >= RLIM_INFINITY)
52282 rlim = ~0;
52283 +
52284 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52285 if (ex.a_data + ex.a_bss > rlim)
52286 return -ENOMEM;
52287
52288 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52289
52290 install_exec_creds(bprm);
52291
52292 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52293 + current->mm->pax_flags = 0UL;
52294 +#endif
52295 +
52296 +#ifdef CONFIG_PAX_PAGEEXEC
52297 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52298 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52299 +
52300 +#ifdef CONFIG_PAX_EMUTRAMP
52301 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52302 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52303 +#endif
52304 +
52305 +#ifdef CONFIG_PAX_MPROTECT
52306 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52307 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52308 +#endif
52309 +
52310 + }
52311 +#endif
52312 +
52313 if (N_MAGIC(ex) == OMAGIC) {
52314 unsigned long text_addr, map_size;
52315 loff_t pos;
52316 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52317 }
52318
52319 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52320 - PROT_READ | PROT_WRITE | PROT_EXEC,
52321 + PROT_READ | PROT_WRITE,
52322 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52323 fd_offset + ex.a_text);
52324 if (error != N_DATADDR(ex)) {
52325 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52326 index 4c94a79..f428019 100644
52327 --- a/fs/binfmt_elf.c
52328 +++ b/fs/binfmt_elf.c
52329 @@ -34,6 +34,7 @@
52330 #include <linux/utsname.h>
52331 #include <linux/coredump.h>
52332 #include <linux/sched.h>
52333 +#include <linux/xattr.h>
52334 #include <asm/uaccess.h>
52335 #include <asm/param.h>
52336 #include <asm/page.h>
52337 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52338 #define elf_core_dump NULL
52339 #endif
52340
52341 +#ifdef CONFIG_PAX_MPROTECT
52342 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52343 +#endif
52344 +
52345 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52346 +static void elf_handle_mmap(struct file *file);
52347 +#endif
52348 +
52349 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52350 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52351 #else
52352 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52353 .load_binary = load_elf_binary,
52354 .load_shlib = load_elf_library,
52355 .core_dump = elf_core_dump,
52356 +
52357 +#ifdef CONFIG_PAX_MPROTECT
52358 + .handle_mprotect= elf_handle_mprotect,
52359 +#endif
52360 +
52361 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52362 + .handle_mmap = elf_handle_mmap,
52363 +#endif
52364 +
52365 .min_coredump = ELF_EXEC_PAGESIZE,
52366 };
52367
52368 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52369
52370 static int set_brk(unsigned long start, unsigned long end)
52371 {
52372 + unsigned long e = end;
52373 +
52374 start = ELF_PAGEALIGN(start);
52375 end = ELF_PAGEALIGN(end);
52376 if (end > start) {
52377 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52378 if (BAD_ADDR(addr))
52379 return addr;
52380 }
52381 - current->mm->start_brk = current->mm->brk = end;
52382 + current->mm->start_brk = current->mm->brk = e;
52383 return 0;
52384 }
52385
52386 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52387 elf_addr_t __user *u_rand_bytes;
52388 const char *k_platform = ELF_PLATFORM;
52389 const char *k_base_platform = ELF_BASE_PLATFORM;
52390 - unsigned char k_rand_bytes[16];
52391 + u32 k_rand_bytes[4];
52392 int items;
52393 elf_addr_t *elf_info;
52394 int ei_index = 0;
52395 const struct cred *cred = current_cred();
52396 struct vm_area_struct *vma;
52397 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52398
52399 /*
52400 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52401 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52402 * Generate 16 random bytes for userspace PRNG seeding.
52403 */
52404 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52405 - u_rand_bytes = (elf_addr_t __user *)
52406 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52407 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52408 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52409 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52410 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52411 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52412 + u_rand_bytes = (elf_addr_t __user *) p;
52413 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52414 return -EFAULT;
52415
52416 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52417 return -EFAULT;
52418 current->mm->env_end = p;
52419
52420 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52421 +
52422 /* Put the elf_info on the stack in the right place. */
52423 sp = (elf_addr_t __user *)envp + 1;
52424 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52425 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52426 return -EFAULT;
52427 return 0;
52428 }
52429 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52430 an ELF header */
52431
52432 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52433 - struct file *interpreter, unsigned long *interp_map_addr,
52434 - unsigned long no_base)
52435 + struct file *interpreter, unsigned long no_base)
52436 {
52437 struct elf_phdr *elf_phdata;
52438 struct elf_phdr *eppnt;
52439 - unsigned long load_addr = 0;
52440 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52441 int load_addr_set = 0;
52442 unsigned long last_bss = 0, elf_bss = 0;
52443 - unsigned long error = ~0UL;
52444 + unsigned long error = -EINVAL;
52445 unsigned long total_size;
52446 int retval, i, size;
52447
52448 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52449 goto out_close;
52450 }
52451
52452 +#ifdef CONFIG_PAX_SEGMEXEC
52453 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52454 + pax_task_size = SEGMEXEC_TASK_SIZE;
52455 +#endif
52456 +
52457 eppnt = elf_phdata;
52458 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52459 if (eppnt->p_type == PT_LOAD) {
52460 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52461 map_addr = elf_map(interpreter, load_addr + vaddr,
52462 eppnt, elf_prot, elf_type, total_size);
52463 total_size = 0;
52464 - if (!*interp_map_addr)
52465 - *interp_map_addr = map_addr;
52466 error = map_addr;
52467 if (BAD_ADDR(map_addr))
52468 goto out_close;
52469 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52470 k = load_addr + eppnt->p_vaddr;
52471 if (BAD_ADDR(k) ||
52472 eppnt->p_filesz > eppnt->p_memsz ||
52473 - eppnt->p_memsz > TASK_SIZE ||
52474 - TASK_SIZE - eppnt->p_memsz < k) {
52475 + eppnt->p_memsz > pax_task_size ||
52476 + pax_task_size - eppnt->p_memsz < k) {
52477 error = -ENOMEM;
52478 goto out_close;
52479 }
52480 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52481 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52482
52483 /* Map the last of the bss segment */
52484 - error = vm_brk(elf_bss, last_bss - elf_bss);
52485 - if (BAD_ADDR(error))
52486 - goto out_close;
52487 + if (last_bss > elf_bss) {
52488 + error = vm_brk(elf_bss, last_bss - elf_bss);
52489 + if (BAD_ADDR(error))
52490 + goto out_close;
52491 + }
52492 }
52493
52494 error = load_addr;
52495 @@ -538,6 +569,315 @@ out:
52496 return error;
52497 }
52498
52499 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52500 +#ifdef CONFIG_PAX_SOFTMODE
52501 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52502 +{
52503 + unsigned long pax_flags = 0UL;
52504 +
52505 +#ifdef CONFIG_PAX_PAGEEXEC
52506 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52507 + pax_flags |= MF_PAX_PAGEEXEC;
52508 +#endif
52509 +
52510 +#ifdef CONFIG_PAX_SEGMEXEC
52511 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52512 + pax_flags |= MF_PAX_SEGMEXEC;
52513 +#endif
52514 +
52515 +#ifdef CONFIG_PAX_EMUTRAMP
52516 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52517 + pax_flags |= MF_PAX_EMUTRAMP;
52518 +#endif
52519 +
52520 +#ifdef CONFIG_PAX_MPROTECT
52521 + if (elf_phdata->p_flags & PF_MPROTECT)
52522 + pax_flags |= MF_PAX_MPROTECT;
52523 +#endif
52524 +
52525 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52526 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52527 + pax_flags |= MF_PAX_RANDMMAP;
52528 +#endif
52529 +
52530 + return pax_flags;
52531 +}
52532 +#endif
52533 +
52534 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52535 +{
52536 + unsigned long pax_flags = 0UL;
52537 +
52538 +#ifdef CONFIG_PAX_PAGEEXEC
52539 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52540 + pax_flags |= MF_PAX_PAGEEXEC;
52541 +#endif
52542 +
52543 +#ifdef CONFIG_PAX_SEGMEXEC
52544 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52545 + pax_flags |= MF_PAX_SEGMEXEC;
52546 +#endif
52547 +
52548 +#ifdef CONFIG_PAX_EMUTRAMP
52549 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52550 + pax_flags |= MF_PAX_EMUTRAMP;
52551 +#endif
52552 +
52553 +#ifdef CONFIG_PAX_MPROTECT
52554 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
52555 + pax_flags |= MF_PAX_MPROTECT;
52556 +#endif
52557 +
52558 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52559 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
52560 + pax_flags |= MF_PAX_RANDMMAP;
52561 +#endif
52562 +
52563 + return pax_flags;
52564 +}
52565 +#endif
52566 +
52567 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52568 +#ifdef CONFIG_PAX_SOFTMODE
52569 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
52570 +{
52571 + unsigned long pax_flags = 0UL;
52572 +
52573 +#ifdef CONFIG_PAX_PAGEEXEC
52574 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
52575 + pax_flags |= MF_PAX_PAGEEXEC;
52576 +#endif
52577 +
52578 +#ifdef CONFIG_PAX_SEGMEXEC
52579 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
52580 + pax_flags |= MF_PAX_SEGMEXEC;
52581 +#endif
52582 +
52583 +#ifdef CONFIG_PAX_EMUTRAMP
52584 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52585 + pax_flags |= MF_PAX_EMUTRAMP;
52586 +#endif
52587 +
52588 +#ifdef CONFIG_PAX_MPROTECT
52589 + if (pax_flags_softmode & MF_PAX_MPROTECT)
52590 + pax_flags |= MF_PAX_MPROTECT;
52591 +#endif
52592 +
52593 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52594 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
52595 + pax_flags |= MF_PAX_RANDMMAP;
52596 +#endif
52597 +
52598 + return pax_flags;
52599 +}
52600 +#endif
52601 +
52602 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
52603 +{
52604 + unsigned long pax_flags = 0UL;
52605 +
52606 +#ifdef CONFIG_PAX_PAGEEXEC
52607 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
52608 + pax_flags |= MF_PAX_PAGEEXEC;
52609 +#endif
52610 +
52611 +#ifdef CONFIG_PAX_SEGMEXEC
52612 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
52613 + pax_flags |= MF_PAX_SEGMEXEC;
52614 +#endif
52615 +
52616 +#ifdef CONFIG_PAX_EMUTRAMP
52617 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
52618 + pax_flags |= MF_PAX_EMUTRAMP;
52619 +#endif
52620 +
52621 +#ifdef CONFIG_PAX_MPROTECT
52622 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
52623 + pax_flags |= MF_PAX_MPROTECT;
52624 +#endif
52625 +
52626 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52627 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
52628 + pax_flags |= MF_PAX_RANDMMAP;
52629 +#endif
52630 +
52631 + return pax_flags;
52632 +}
52633 +#endif
52634 +
52635 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52636 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
52637 +{
52638 + unsigned long pax_flags = 0UL;
52639 +
52640 +#ifdef CONFIG_PAX_EI_PAX
52641 +
52642 +#ifdef CONFIG_PAX_PAGEEXEC
52643 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
52644 + pax_flags |= MF_PAX_PAGEEXEC;
52645 +#endif
52646 +
52647 +#ifdef CONFIG_PAX_SEGMEXEC
52648 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
52649 + pax_flags |= MF_PAX_SEGMEXEC;
52650 +#endif
52651 +
52652 +#ifdef CONFIG_PAX_EMUTRAMP
52653 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
52654 + pax_flags |= MF_PAX_EMUTRAMP;
52655 +#endif
52656 +
52657 +#ifdef CONFIG_PAX_MPROTECT
52658 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
52659 + pax_flags |= MF_PAX_MPROTECT;
52660 +#endif
52661 +
52662 +#ifdef CONFIG_PAX_ASLR
52663 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
52664 + pax_flags |= MF_PAX_RANDMMAP;
52665 +#endif
52666 +
52667 +#else
52668 +
52669 +#ifdef CONFIG_PAX_PAGEEXEC
52670 + pax_flags |= MF_PAX_PAGEEXEC;
52671 +#endif
52672 +
52673 +#ifdef CONFIG_PAX_SEGMEXEC
52674 + pax_flags |= MF_PAX_SEGMEXEC;
52675 +#endif
52676 +
52677 +#ifdef CONFIG_PAX_MPROTECT
52678 + pax_flags |= MF_PAX_MPROTECT;
52679 +#endif
52680 +
52681 +#ifdef CONFIG_PAX_RANDMMAP
52682 + if (randomize_va_space)
52683 + pax_flags |= MF_PAX_RANDMMAP;
52684 +#endif
52685 +
52686 +#endif
52687 +
52688 + return pax_flags;
52689 +}
52690 +
52691 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
52692 +{
52693 +
52694 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52695 + unsigned long i;
52696 +
52697 + for (i = 0UL; i < elf_ex->e_phnum; i++)
52698 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
52699 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
52700 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
52701 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
52702 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
52703 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
52704 + return ~0UL;
52705 +
52706 +#ifdef CONFIG_PAX_SOFTMODE
52707 + if (pax_softmode)
52708 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
52709 + else
52710 +#endif
52711 +
52712 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
52713 + break;
52714 + }
52715 +#endif
52716 +
52717 + return ~0UL;
52718 +}
52719 +
52720 +static unsigned long pax_parse_xattr_pax(struct file * const file)
52721 +{
52722 +
52723 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52724 + ssize_t xattr_size, i;
52725 + unsigned char xattr_value[sizeof("pemrs") - 1];
52726 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
52727 +
52728 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
52729 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
52730 + return ~0UL;
52731 +
52732 + for (i = 0; i < xattr_size; i++)
52733 + switch (xattr_value[i]) {
52734 + default:
52735 + return ~0UL;
52736 +
52737 +#define parse_flag(option1, option2, flag) \
52738 + case option1: \
52739 + if (pax_flags_hardmode & MF_PAX_##flag) \
52740 + return ~0UL; \
52741 + pax_flags_hardmode |= MF_PAX_##flag; \
52742 + break; \
52743 + case option2: \
52744 + if (pax_flags_softmode & MF_PAX_##flag) \
52745 + return ~0UL; \
52746 + pax_flags_softmode |= MF_PAX_##flag; \
52747 + break;
52748 +
52749 + parse_flag('p', 'P', PAGEEXEC);
52750 + parse_flag('e', 'E', EMUTRAMP);
52751 + parse_flag('m', 'M', MPROTECT);
52752 + parse_flag('r', 'R', RANDMMAP);
52753 + parse_flag('s', 'S', SEGMEXEC);
52754 +
52755 +#undef parse_flag
52756 + }
52757 +
52758 + if (pax_flags_hardmode & pax_flags_softmode)
52759 + return ~0UL;
52760 +
52761 +#ifdef CONFIG_PAX_SOFTMODE
52762 + if (pax_softmode)
52763 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
52764 + else
52765 +#endif
52766 +
52767 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
52768 +#else
52769 + return ~0UL;
52770 +#endif
52771 +
52772 +}
52773 +
52774 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
52775 +{
52776 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
52777 +
52778 + pax_flags = pax_parse_ei_pax(elf_ex);
52779 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
52780 + xattr_pax_flags = pax_parse_xattr_pax(file);
52781 +
52782 + if (pt_pax_flags == ~0UL)
52783 + pt_pax_flags = xattr_pax_flags;
52784 + else if (xattr_pax_flags == ~0UL)
52785 + xattr_pax_flags = pt_pax_flags;
52786 + if (pt_pax_flags != xattr_pax_flags)
52787 + return -EINVAL;
52788 + if (pt_pax_flags != ~0UL)
52789 + pax_flags = pt_pax_flags;
52790 +
52791 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
52792 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52793 + if ((__supported_pte_mask & _PAGE_NX))
52794 + pax_flags &= ~MF_PAX_SEGMEXEC;
52795 + else
52796 + pax_flags &= ~MF_PAX_PAGEEXEC;
52797 + }
52798 +#endif
52799 +
52800 + if (0 > pax_check_flags(&pax_flags))
52801 + return -EINVAL;
52802 +
52803 + current->mm->pax_flags = pax_flags;
52804 + return 0;
52805 +}
52806 +#endif
52807 +
52808 /*
52809 * These are the functions used to load ELF style executables and shared
52810 * libraries. There is no binary dependent code anywhere else.
52811 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
52812 {
52813 unsigned int random_variable = 0;
52814
52815 +#ifdef CONFIG_PAX_RANDUSTACK
52816 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
52817 + return stack_top - current->mm->delta_stack;
52818 +#endif
52819 +
52820 if ((current->flags & PF_RANDOMIZE) &&
52821 !(current->personality & ADDR_NO_RANDOMIZE)) {
52822 random_variable = get_random_int() & STACK_RND_MASK;
52823 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
52824 unsigned long load_addr = 0, load_bias = 0;
52825 int load_addr_set = 0;
52826 char * elf_interpreter = NULL;
52827 - unsigned long error;
52828 + unsigned long error = 0;
52829 struct elf_phdr *elf_ppnt, *elf_phdata;
52830 unsigned long elf_bss, elf_brk;
52831 int retval, i;
52832 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
52833 unsigned long start_code, end_code, start_data, end_data;
52834 unsigned long reloc_func_desc __maybe_unused = 0;
52835 int executable_stack = EXSTACK_DEFAULT;
52836 - unsigned long def_flags = 0;
52837 struct pt_regs *regs = current_pt_regs();
52838 struct {
52839 struct elfhdr elf_ex;
52840 struct elfhdr interp_elf_ex;
52841 } *loc;
52842 + unsigned long pax_task_size = TASK_SIZE;
52843
52844 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
52845 if (!loc) {
52846 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
52847 goto out_free_dentry;
52848
52849 /* OK, This is the point of no return */
52850 - current->mm->def_flags = def_flags;
52851 +
52852 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52853 + current->mm->pax_flags = 0UL;
52854 +#endif
52855 +
52856 +#ifdef CONFIG_PAX_DLRESOLVE
52857 + current->mm->call_dl_resolve = 0UL;
52858 +#endif
52859 +
52860 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
52861 + current->mm->call_syscall = 0UL;
52862 +#endif
52863 +
52864 +#ifdef CONFIG_PAX_ASLR
52865 + current->mm->delta_mmap = 0UL;
52866 + current->mm->delta_stack = 0UL;
52867 +#endif
52868 +
52869 + current->mm->def_flags = 0;
52870 +
52871 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52872 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
52873 + send_sig(SIGKILL, current, 0);
52874 + goto out_free_dentry;
52875 + }
52876 +#endif
52877 +
52878 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52879 + pax_set_initial_flags(bprm);
52880 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
52881 + if (pax_set_initial_flags_func)
52882 + (pax_set_initial_flags_func)(bprm);
52883 +#endif
52884 +
52885 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
52886 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
52887 + current->mm->context.user_cs_limit = PAGE_SIZE;
52888 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
52889 + }
52890 +#endif
52891 +
52892 +#ifdef CONFIG_PAX_SEGMEXEC
52893 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
52894 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
52895 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
52896 + pax_task_size = SEGMEXEC_TASK_SIZE;
52897 + current->mm->def_flags |= VM_NOHUGEPAGE;
52898 + }
52899 +#endif
52900 +
52901 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
52902 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52903 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
52904 + put_cpu();
52905 + }
52906 +#endif
52907
52908 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
52909 may depend on the personality. */
52910 SET_PERSONALITY(loc->elf_ex);
52911 +
52912 +#ifdef CONFIG_PAX_ASLR
52913 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52914 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
52915 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
52916 + }
52917 +#endif
52918 +
52919 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
52920 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52921 + executable_stack = EXSTACK_DISABLE_X;
52922 + current->personality &= ~READ_IMPLIES_EXEC;
52923 + } else
52924 +#endif
52925 +
52926 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
52927 current->personality |= READ_IMPLIES_EXEC;
52928
52929 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
52930 #else
52931 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
52932 #endif
52933 +
52934 +#ifdef CONFIG_PAX_RANDMMAP
52935 + /* PaX: randomize base address at the default exe base if requested */
52936 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
52937 +#ifdef CONFIG_SPARC64
52938 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
52939 +#else
52940 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
52941 +#endif
52942 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
52943 + elf_flags |= MAP_FIXED;
52944 + }
52945 +#endif
52946 +
52947 }
52948
52949 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
52950 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
52951 * allowed task size. Note that p_filesz must always be
52952 * <= p_memsz so it is only necessary to check p_memsz.
52953 */
52954 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52955 - elf_ppnt->p_memsz > TASK_SIZE ||
52956 - TASK_SIZE - elf_ppnt->p_memsz < k) {
52957 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52958 + elf_ppnt->p_memsz > pax_task_size ||
52959 + pax_task_size - elf_ppnt->p_memsz < k) {
52960 /* set_brk can never work. Avoid overflows. */
52961 send_sig(SIGKILL, current, 0);
52962 retval = -EINVAL;
52963 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
52964 goto out_free_dentry;
52965 }
52966 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
52967 - send_sig(SIGSEGV, current, 0);
52968 - retval = -EFAULT; /* Nobody gets to see this, but.. */
52969 - goto out_free_dentry;
52970 + /*
52971 + * This bss-zeroing can fail if the ELF
52972 + * file specifies odd protections. So
52973 + * we don't check the return value
52974 + */
52975 }
52976
52977 +#ifdef CONFIG_PAX_RANDMMAP
52978 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52979 + unsigned long start, size, flags;
52980 + vm_flags_t vm_flags;
52981 +
52982 + start = ELF_PAGEALIGN(elf_brk);
52983 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
52984 + flags = MAP_FIXED | MAP_PRIVATE;
52985 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
52986 +
52987 + down_write(&current->mm->mmap_sem);
52988 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
52989 + retval = -ENOMEM;
52990 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
52991 +// if (current->personality & ADDR_NO_RANDOMIZE)
52992 +// vm_flags |= VM_READ | VM_MAYREAD;
52993 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
52994 + retval = IS_ERR_VALUE(start) ? start : 0;
52995 + }
52996 + up_write(&current->mm->mmap_sem);
52997 + if (retval == 0)
52998 + retval = set_brk(start + size, start + size + PAGE_SIZE);
52999 + if (retval < 0) {
53000 + send_sig(SIGKILL, current, 0);
53001 + goto out_free_dentry;
53002 + }
53003 + }
53004 +#endif
53005 +
53006 if (elf_interpreter) {
53007 - unsigned long interp_map_addr = 0;
53008 -
53009 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53010 interpreter,
53011 - &interp_map_addr,
53012 load_bias);
53013 if (!IS_ERR((void *)elf_entry)) {
53014 /*
53015 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53016 * Decide what to dump of a segment, part, all or none.
53017 */
53018 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53019 - unsigned long mm_flags)
53020 + unsigned long mm_flags, long signr)
53021 {
53022 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53023
53024 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53025 if (vma->vm_file == NULL)
53026 return 0;
53027
53028 - if (FILTER(MAPPED_PRIVATE))
53029 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53030 goto whole;
53031
53032 /*
53033 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53034 {
53035 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53036 int i = 0;
53037 - do
53038 + do {
53039 i += 2;
53040 - while (auxv[i - 2] != AT_NULL);
53041 + } while (auxv[i - 2] != AT_NULL);
53042 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53043 }
53044
53045 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53046 {
53047 mm_segment_t old_fs = get_fs();
53048 set_fs(KERNEL_DS);
53049 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53050 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53051 set_fs(old_fs);
53052 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53053 }
53054 @@ -2023,14 +2480,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53055 }
53056
53057 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53058 - unsigned long mm_flags)
53059 + struct coredump_params *cprm)
53060 {
53061 struct vm_area_struct *vma;
53062 size_t size = 0;
53063
53064 for (vma = first_vma(current, gate_vma); vma != NULL;
53065 vma = next_vma(vma, gate_vma))
53066 - size += vma_dump_size(vma, mm_flags);
53067 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53068 return size;
53069 }
53070
53071 @@ -2123,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53072
53073 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53074
53075 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53076 + offset += elf_core_vma_data_size(gate_vma, cprm);
53077 offset += elf_core_extra_data_size();
53078 e_shoff = offset;
53079
53080 @@ -2137,10 +2594,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53081 offset = dataoff;
53082
53083 size += sizeof(*elf);
53084 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53085 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53086 goto end_coredump;
53087
53088 size += sizeof(*phdr4note);
53089 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53090 if (size > cprm->limit
53091 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53092 goto end_coredump;
53093 @@ -2154,7 +2613,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53094 phdr.p_offset = offset;
53095 phdr.p_vaddr = vma->vm_start;
53096 phdr.p_paddr = 0;
53097 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53098 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53099 phdr.p_memsz = vma->vm_end - vma->vm_start;
53100 offset += phdr.p_filesz;
53101 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53102 @@ -2165,6 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53103 phdr.p_align = ELF_EXEC_PAGESIZE;
53104
53105 size += sizeof(phdr);
53106 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53107 if (size > cprm->limit
53108 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53109 goto end_coredump;
53110 @@ -2189,7 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53111 unsigned long addr;
53112 unsigned long end;
53113
53114 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53115 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53116
53117 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53118 struct page *page;
53119 @@ -2198,6 +2658,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53120 page = get_dump_page(addr);
53121 if (page) {
53122 void *kaddr = kmap(page);
53123 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53124 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53125 !dump_write(cprm->file, kaddr,
53126 PAGE_SIZE);
53127 @@ -2215,6 +2676,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53128
53129 if (e_phnum == PN_XNUM) {
53130 size += sizeof(*shdr4extnum);
53131 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53132 if (size > cprm->limit
53133 || !dump_write(cprm->file, shdr4extnum,
53134 sizeof(*shdr4extnum)))
53135 @@ -2235,6 +2697,167 @@ out:
53136
53137 #endif /* CONFIG_ELF_CORE */
53138
53139 +#ifdef CONFIG_PAX_MPROTECT
53140 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53141 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53142 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53143 + *
53144 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53145 + * basis because we want to allow the common case and not the special ones.
53146 + */
53147 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53148 +{
53149 + struct elfhdr elf_h;
53150 + struct elf_phdr elf_p;
53151 + unsigned long i;
53152 + unsigned long oldflags;
53153 + bool is_textrel_rw, is_textrel_rx, is_relro;
53154 +
53155 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53156 + return;
53157 +
53158 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53159 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53160 +
53161 +#ifdef CONFIG_PAX_ELFRELOCS
53162 + /* possible TEXTREL */
53163 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53164 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53165 +#else
53166 + is_textrel_rw = false;
53167 + is_textrel_rx = false;
53168 +#endif
53169 +
53170 + /* possible RELRO */
53171 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53172 +
53173 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53174 + return;
53175 +
53176 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53177 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53178 +
53179 +#ifdef CONFIG_PAX_ETEXECRELOCS
53180 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53181 +#else
53182 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53183 +#endif
53184 +
53185 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53186 + !elf_check_arch(&elf_h) ||
53187 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53188 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53189 + return;
53190 +
53191 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53192 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53193 + return;
53194 + switch (elf_p.p_type) {
53195 + case PT_DYNAMIC:
53196 + if (!is_textrel_rw && !is_textrel_rx)
53197 + continue;
53198 + i = 0UL;
53199 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53200 + elf_dyn dyn;
53201 +
53202 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53203 + break;
53204 + if (dyn.d_tag == DT_NULL)
53205 + break;
53206 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53207 + gr_log_textrel(vma);
53208 + if (is_textrel_rw)
53209 + vma->vm_flags |= VM_MAYWRITE;
53210 + else
53211 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53212 + vma->vm_flags &= ~VM_MAYWRITE;
53213 + break;
53214 + }
53215 + i++;
53216 + }
53217 + is_textrel_rw = false;
53218 + is_textrel_rx = false;
53219 + continue;
53220 +
53221 + case PT_GNU_RELRO:
53222 + if (!is_relro)
53223 + continue;
53224 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53225 + vma->vm_flags &= ~VM_MAYWRITE;
53226 + is_relro = false;
53227 + continue;
53228 +
53229 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53230 + case PT_PAX_FLAGS: {
53231 + const char *msg_mprotect = "", *msg_emutramp = "";
53232 + char *buffer_lib, *buffer_exe;
53233 +
53234 + if (elf_p.p_flags & PF_NOMPROTECT)
53235 + msg_mprotect = "MPROTECT disabled";
53236 +
53237 +#ifdef CONFIG_PAX_EMUTRAMP
53238 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53239 + msg_emutramp = "EMUTRAMP enabled";
53240 +#endif
53241 +
53242 + if (!msg_mprotect[0] && !msg_emutramp[0])
53243 + continue;
53244 +
53245 + if (!printk_ratelimit())
53246 + continue;
53247 +
53248 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53249 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53250 + if (buffer_lib && buffer_exe) {
53251 + char *path_lib, *path_exe;
53252 +
53253 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53254 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53255 +
53256 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53257 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53258 +
53259 + }
53260 + free_page((unsigned long)buffer_exe);
53261 + free_page((unsigned long)buffer_lib);
53262 + continue;
53263 + }
53264 +#endif
53265 +
53266 + }
53267 + }
53268 +}
53269 +#endif
53270 +
53271 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53272 +
53273 +extern int grsec_enable_log_rwxmaps;
53274 +
53275 +static void elf_handle_mmap(struct file *file)
53276 +{
53277 + struct elfhdr elf_h;
53278 + struct elf_phdr elf_p;
53279 + unsigned long i;
53280 +
53281 + if (!grsec_enable_log_rwxmaps)
53282 + return;
53283 +
53284 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53285 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53286 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53287 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53288 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53289 + return;
53290 +
53291 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53292 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53293 + return;
53294 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53295 + gr_log_ptgnustack(file);
53296 + }
53297 +}
53298 +#endif
53299 +
53300 static int __init init_elf_binfmt(void)
53301 {
53302 register_binfmt(&elf_format);
53303 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53304 index d50bbe5..af3b649 100644
53305 --- a/fs/binfmt_flat.c
53306 +++ b/fs/binfmt_flat.c
53307 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53308 realdatastart = (unsigned long) -ENOMEM;
53309 printk("Unable to allocate RAM for process data, errno %d\n",
53310 (int)-realdatastart);
53311 + down_write(&current->mm->mmap_sem);
53312 vm_munmap(textpos, text_len);
53313 + up_write(&current->mm->mmap_sem);
53314 ret = realdatastart;
53315 goto err;
53316 }
53317 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53318 }
53319 if (IS_ERR_VALUE(result)) {
53320 printk("Unable to read data+bss, errno %d\n", (int)-result);
53321 + down_write(&current->mm->mmap_sem);
53322 vm_munmap(textpos, text_len);
53323 vm_munmap(realdatastart, len);
53324 + up_write(&current->mm->mmap_sem);
53325 ret = result;
53326 goto err;
53327 }
53328 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53329 }
53330 if (IS_ERR_VALUE(result)) {
53331 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53332 + down_write(&current->mm->mmap_sem);
53333 vm_munmap(textpos, text_len + data_len + extra +
53334 MAX_SHARED_LIBS * sizeof(unsigned long));
53335 + up_write(&current->mm->mmap_sem);
53336 ret = result;
53337 goto err;
53338 }
53339 diff --git a/fs/bio.c b/fs/bio.c
53340 index 5e7507d..418c639 100644
53341 --- a/fs/bio.c
53342 +++ b/fs/bio.c
53343 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53344 /*
53345 * Overflow, abort
53346 */
53347 - if (end < start)
53348 + if (end < start || end - start > INT_MAX - nr_pages)
53349 return ERR_PTR(-EINVAL);
53350
53351 nr_pages += end - start;
53352 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53353 /*
53354 * Overflow, abort
53355 */
53356 - if (end < start)
53357 + if (end < start || end - start > INT_MAX - nr_pages)
53358 return ERR_PTR(-EINVAL);
53359
53360 nr_pages += end - start;
53361 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53362 const int read = bio_data_dir(bio) == READ;
53363 struct bio_map_data *bmd = bio->bi_private;
53364 int i;
53365 - char *p = bmd->sgvecs[0].iov_base;
53366 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53367
53368 bio_for_each_segment_all(bvec, bio, i) {
53369 char *addr = page_address(bvec->bv_page);
53370 diff --git a/fs/block_dev.c b/fs/block_dev.c
53371 index c7bda5c..2121e94 100644
53372 --- a/fs/block_dev.c
53373 +++ b/fs/block_dev.c
53374 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53375 else if (bdev->bd_contains == bdev)
53376 return true; /* is a whole device which isn't held */
53377
53378 - else if (whole->bd_holder == bd_may_claim)
53379 + else if (whole->bd_holder == (void *)bd_may_claim)
53380 return true; /* is a partition of a device that is being partitioned */
53381 else if (whole->bd_holder != NULL)
53382 return false; /* is a partition of a held device */
53383 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53384 index ed50460..fe84385 100644
53385 --- a/fs/btrfs/ctree.c
53386 +++ b/fs/btrfs/ctree.c
53387 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53388 free_extent_buffer(buf);
53389 add_root_to_dirty_list(root);
53390 } else {
53391 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53392 - parent_start = parent->start;
53393 - else
53394 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53395 + if (parent)
53396 + parent_start = parent->start;
53397 + else
53398 + parent_start = 0;
53399 + } else
53400 parent_start = 0;
53401
53402 WARN_ON(trans->transid != btrfs_header_generation(parent));
53403 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53404 index 3755109..e3d457f 100644
53405 --- a/fs/btrfs/delayed-inode.c
53406 +++ b/fs/btrfs/delayed-inode.c
53407 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53408
53409 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53410 {
53411 - int seq = atomic_inc_return(&delayed_root->items_seq);
53412 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53413 if ((atomic_dec_return(&delayed_root->items) <
53414 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53415 waitqueue_active(&delayed_root->wait))
53416 @@ -1377,7 +1377,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53417 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53418 int seq, int count)
53419 {
53420 - int val = atomic_read(&delayed_root->items_seq);
53421 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53422
53423 if (val < seq || val >= seq + count)
53424 return 1;
53425 @@ -1394,7 +1394,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53426 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53427 return;
53428
53429 - seq = atomic_read(&delayed_root->items_seq);
53430 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53431
53432 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53433 int ret;
53434 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53435 index a4b38f9..f86a509 100644
53436 --- a/fs/btrfs/delayed-inode.h
53437 +++ b/fs/btrfs/delayed-inode.h
53438 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53439 */
53440 struct list_head prepare_list;
53441 atomic_t items; /* for delayed items */
53442 - atomic_t items_seq; /* for delayed items */
53443 + atomic_unchecked_t items_seq; /* for delayed items */
53444 int nodes; /* for delayed nodes */
53445 wait_queue_head_t wait;
53446 };
53447 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53448 struct btrfs_delayed_root *delayed_root)
53449 {
53450 atomic_set(&delayed_root->items, 0);
53451 - atomic_set(&delayed_root->items_seq, 0);
53452 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53453 delayed_root->nodes = 0;
53454 spin_lock_init(&delayed_root->lock);
53455 init_waitqueue_head(&delayed_root->wait);
53456 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53457 index 9877a2a..7ebf9ab 100644
53458 --- a/fs/btrfs/ioctl.c
53459 +++ b/fs/btrfs/ioctl.c
53460 @@ -3097,9 +3097,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53461 for (i = 0; i < num_types; i++) {
53462 struct btrfs_space_info *tmp;
53463
53464 + /* Don't copy in more than we allocated */
53465 if (!slot_count)
53466 break;
53467
53468 + slot_count--;
53469 +
53470 info = NULL;
53471 rcu_read_lock();
53472 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53473 @@ -3121,10 +3124,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53474 memcpy(dest, &space, sizeof(space));
53475 dest++;
53476 space_args.total_spaces++;
53477 - slot_count--;
53478 }
53479 - if (!slot_count)
53480 - break;
53481 }
53482 up_read(&info->groups_sem);
53483 }
53484 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53485 index 8eb6191..eda91e2 100644
53486 --- a/fs/btrfs/super.c
53487 +++ b/fs/btrfs/super.c
53488 @@ -264,7 +264,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53489 function, line, errstr);
53490 return;
53491 }
53492 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53493 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53494 /* Wake up anybody who may be waiting on this transaction */
53495 wake_up(&root->fs_info->transaction_wait);
53496 wake_up(&root->fs_info->transaction_blocked_wait);
53497 diff --git a/fs/buffer.c b/fs/buffer.c
53498 index 4d74335..7bd000a 100644
53499 --- a/fs/buffer.c
53500 +++ b/fs/buffer.c
53501 @@ -1005,9 +1005,19 @@ grow_dev_page(struct block_device *bdev, sector_t block,
53502 struct buffer_head *bh;
53503 sector_t end_block;
53504 int ret = 0; /* Will call free_more_memory() */
53505 + gfp_t gfp_mask;
53506
53507 - page = find_or_create_page(inode->i_mapping, index,
53508 - (mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS)|__GFP_MOVABLE);
53509 + gfp_mask = mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS;
53510 + gfp_mask |= __GFP_MOVABLE;
53511 + /*
53512 + * XXX: __getblk_slow() can not really deal with failure and
53513 + * will endlessly loop on improvised global reclaim. Prefer
53514 + * looping in the allocator rather than here, at least that
53515 + * code knows what it's doing.
53516 + */
53517 + gfp_mask |= __GFP_NOFAIL;
53518 +
53519 + page = find_or_create_page(inode->i_mapping, index, gfp_mask);
53520 if (!page)
53521 return ret;
53522
53523 @@ -3416,7 +3426,7 @@ void __init buffer_init(void)
53524 bh_cachep = kmem_cache_create("buffer_head",
53525 sizeof(struct buffer_head), 0,
53526 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53527 - SLAB_MEM_SPREAD),
53528 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53529 NULL);
53530
53531 /*
53532 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53533 index 622f469..e8d2d55 100644
53534 --- a/fs/cachefiles/bind.c
53535 +++ b/fs/cachefiles/bind.c
53536 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53537 args);
53538
53539 /* start by checking things over */
53540 - ASSERT(cache->fstop_percent >= 0 &&
53541 - cache->fstop_percent < cache->fcull_percent &&
53542 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53543 cache->fcull_percent < cache->frun_percent &&
53544 cache->frun_percent < 100);
53545
53546 - ASSERT(cache->bstop_percent >= 0 &&
53547 - cache->bstop_percent < cache->bcull_percent &&
53548 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53549 cache->bcull_percent < cache->brun_percent &&
53550 cache->brun_percent < 100);
53551
53552 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53553 index 0a1467b..6a53245 100644
53554 --- a/fs/cachefiles/daemon.c
53555 +++ b/fs/cachefiles/daemon.c
53556 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53557 if (n > buflen)
53558 return -EMSGSIZE;
53559
53560 - if (copy_to_user(_buffer, buffer, n) != 0)
53561 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53562 return -EFAULT;
53563
53564 return n;
53565 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53566 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53567 return -EIO;
53568
53569 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53570 + if (datalen > PAGE_SIZE - 1)
53571 return -EOPNOTSUPP;
53572
53573 /* drag the command string into the kernel so we can parse it */
53574 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53575 if (args[0] != '%' || args[1] != '\0')
53576 return -EINVAL;
53577
53578 - if (fstop < 0 || fstop >= cache->fcull_percent)
53579 + if (fstop >= cache->fcull_percent)
53580 return cachefiles_daemon_range_error(cache, args);
53581
53582 cache->fstop_percent = fstop;
53583 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
53584 if (args[0] != '%' || args[1] != '\0')
53585 return -EINVAL;
53586
53587 - if (bstop < 0 || bstop >= cache->bcull_percent)
53588 + if (bstop >= cache->bcull_percent)
53589 return cachefiles_daemon_range_error(cache, args);
53590
53591 cache->bstop_percent = bstop;
53592 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
53593 index 4938251..7e01445 100644
53594 --- a/fs/cachefiles/internal.h
53595 +++ b/fs/cachefiles/internal.h
53596 @@ -59,7 +59,7 @@ struct cachefiles_cache {
53597 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
53598 struct rb_root active_nodes; /* active nodes (can't be culled) */
53599 rwlock_t active_lock; /* lock for active_nodes */
53600 - atomic_t gravecounter; /* graveyard uniquifier */
53601 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
53602 unsigned frun_percent; /* when to stop culling (% files) */
53603 unsigned fcull_percent; /* when to start culling (% files) */
53604 unsigned fstop_percent; /* when to stop allocating (% files) */
53605 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
53606 * proc.c
53607 */
53608 #ifdef CONFIG_CACHEFILES_HISTOGRAM
53609 -extern atomic_t cachefiles_lookup_histogram[HZ];
53610 -extern atomic_t cachefiles_mkdir_histogram[HZ];
53611 -extern atomic_t cachefiles_create_histogram[HZ];
53612 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53613 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53614 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
53615
53616 extern int __init cachefiles_proc_init(void);
53617 extern void cachefiles_proc_cleanup(void);
53618 static inline
53619 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
53620 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
53621 {
53622 unsigned long jif = jiffies - start_jif;
53623 if (jif >= HZ)
53624 jif = HZ - 1;
53625 - atomic_inc(&histogram[jif]);
53626 + atomic_inc_unchecked(&histogram[jif]);
53627 }
53628
53629 #else
53630 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
53631 index 25badd1..d70d918 100644
53632 --- a/fs/cachefiles/namei.c
53633 +++ b/fs/cachefiles/namei.c
53634 @@ -317,7 +317,7 @@ try_again:
53635 /* first step is to make up a grave dentry in the graveyard */
53636 sprintf(nbuffer, "%08x%08x",
53637 (uint32_t) get_seconds(),
53638 - (uint32_t) atomic_inc_return(&cache->gravecounter));
53639 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
53640
53641 /* do the multiway lock magic */
53642 trap = lock_rename(cache->graveyard, dir);
53643 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
53644 index eccd339..4c1d995 100644
53645 --- a/fs/cachefiles/proc.c
53646 +++ b/fs/cachefiles/proc.c
53647 @@ -14,9 +14,9 @@
53648 #include <linux/seq_file.h>
53649 #include "internal.h"
53650
53651 -atomic_t cachefiles_lookup_histogram[HZ];
53652 -atomic_t cachefiles_mkdir_histogram[HZ];
53653 -atomic_t cachefiles_create_histogram[HZ];
53654 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53655 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53656 +atomic_unchecked_t cachefiles_create_histogram[HZ];
53657
53658 /*
53659 * display the latency histogram
53660 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
53661 return 0;
53662 default:
53663 index = (unsigned long) v - 3;
53664 - x = atomic_read(&cachefiles_lookup_histogram[index]);
53665 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
53666 - z = atomic_read(&cachefiles_create_histogram[index]);
53667 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
53668 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
53669 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
53670 if (x == 0 && y == 0 && z == 0)
53671 return 0;
53672
53673 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
53674 index ebaff36..7e3ea26 100644
53675 --- a/fs/cachefiles/rdwr.c
53676 +++ b/fs/cachefiles/rdwr.c
53677 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
53678 old_fs = get_fs();
53679 set_fs(KERNEL_DS);
53680 ret = file->f_op->write(
53681 - file, (const void __user *) data, len, &pos);
53682 + file, (const void __force_user *) data, len, &pos);
53683 set_fs(old_fs);
53684 kunmap(page);
53685 file_end_write(file);
53686 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
53687 index a40ceda..f43d17c 100644
53688 --- a/fs/ceph/dir.c
53689 +++ b/fs/ceph/dir.c
53690 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
53691 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
53692 struct ceph_mds_client *mdsc = fsc->mdsc;
53693 unsigned frag = fpos_frag(ctx->pos);
53694 - int off = fpos_off(ctx->pos);
53695 + unsigned int off = fpos_off(ctx->pos);
53696 int err;
53697 u32 ftype;
53698 struct ceph_mds_reply_info_parsed *rinfo;
53699 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
53700 index 6627b26..634ec4b 100644
53701 --- a/fs/ceph/super.c
53702 +++ b/fs/ceph/super.c
53703 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
53704 /*
53705 * construct our own bdi so we can control readahead, etc.
53706 */
53707 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
53708 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
53709
53710 static int ceph_register_bdi(struct super_block *sb,
53711 struct ceph_fs_client *fsc)
53712 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
53713 default_backing_dev_info.ra_pages;
53714
53715 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
53716 - atomic_long_inc_return(&bdi_seq));
53717 + atomic_long_inc_return_unchecked(&bdi_seq));
53718 if (!err)
53719 sb->s_bdi = &fsc->backing_dev_info;
53720 return err;
53721 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
53722 index f3ac415..3d2420c 100644
53723 --- a/fs/cifs/cifs_debug.c
53724 +++ b/fs/cifs/cifs_debug.c
53725 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53726
53727 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
53728 #ifdef CONFIG_CIFS_STATS2
53729 - atomic_set(&totBufAllocCount, 0);
53730 - atomic_set(&totSmBufAllocCount, 0);
53731 + atomic_set_unchecked(&totBufAllocCount, 0);
53732 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53733 #endif /* CONFIG_CIFS_STATS2 */
53734 spin_lock(&cifs_tcp_ses_lock);
53735 list_for_each(tmp1, &cifs_tcp_ses_list) {
53736 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53737 tcon = list_entry(tmp3,
53738 struct cifs_tcon,
53739 tcon_list);
53740 - atomic_set(&tcon->num_smbs_sent, 0);
53741 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
53742 if (server->ops->clear_stats)
53743 server->ops->clear_stats(tcon);
53744 }
53745 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53746 smBufAllocCount.counter, cifs_min_small);
53747 #ifdef CONFIG_CIFS_STATS2
53748 seq_printf(m, "Total Large %d Small %d Allocations\n",
53749 - atomic_read(&totBufAllocCount),
53750 - atomic_read(&totSmBufAllocCount));
53751 + atomic_read_unchecked(&totBufAllocCount),
53752 + atomic_read_unchecked(&totSmBufAllocCount));
53753 #endif /* CONFIG_CIFS_STATS2 */
53754
53755 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
53756 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53757 if (tcon->need_reconnect)
53758 seq_puts(m, "\tDISCONNECTED ");
53759 seq_printf(m, "\nSMBs: %d",
53760 - atomic_read(&tcon->num_smbs_sent));
53761 + atomic_read_unchecked(&tcon->num_smbs_sent));
53762 if (server->ops->print_stats)
53763 server->ops->print_stats(m, tcon);
53764 }
53765 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
53766 index 40cfef5..1eee040 100644
53767 --- a/fs/cifs/cifsfs.c
53768 +++ b/fs/cifs/cifsfs.c
53769 @@ -1039,7 +1039,7 @@ cifs_init_request_bufs(void)
53770 */
53771 cifs_req_cachep = kmem_cache_create("cifs_request",
53772 CIFSMaxBufSize + max_hdr_size, 0,
53773 - SLAB_HWCACHE_ALIGN, NULL);
53774 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
53775 if (cifs_req_cachep == NULL)
53776 return -ENOMEM;
53777
53778 @@ -1066,7 +1066,7 @@ cifs_init_request_bufs(void)
53779 efficient to alloc 1 per page off the slab compared to 17K (5page)
53780 alloc of large cifs buffers even when page debugging is on */
53781 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
53782 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
53783 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
53784 NULL);
53785 if (cifs_sm_req_cachep == NULL) {
53786 mempool_destroy(cifs_req_poolp);
53787 @@ -1151,8 +1151,8 @@ init_cifs(void)
53788 atomic_set(&bufAllocCount, 0);
53789 atomic_set(&smBufAllocCount, 0);
53790 #ifdef CONFIG_CIFS_STATS2
53791 - atomic_set(&totBufAllocCount, 0);
53792 - atomic_set(&totSmBufAllocCount, 0);
53793 + atomic_set_unchecked(&totBufAllocCount, 0);
53794 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53795 #endif /* CONFIG_CIFS_STATS2 */
53796
53797 atomic_set(&midCount, 0);
53798 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
53799 index 52ca861..47f309c 100644
53800 --- a/fs/cifs/cifsglob.h
53801 +++ b/fs/cifs/cifsglob.h
53802 @@ -756,35 +756,35 @@ struct cifs_tcon {
53803 __u16 Flags; /* optional support bits */
53804 enum statusEnum tidStatus;
53805 #ifdef CONFIG_CIFS_STATS
53806 - atomic_t num_smbs_sent;
53807 + atomic_unchecked_t num_smbs_sent;
53808 union {
53809 struct {
53810 - atomic_t num_writes;
53811 - atomic_t num_reads;
53812 - atomic_t num_flushes;
53813 - atomic_t num_oplock_brks;
53814 - atomic_t num_opens;
53815 - atomic_t num_closes;
53816 - atomic_t num_deletes;
53817 - atomic_t num_mkdirs;
53818 - atomic_t num_posixopens;
53819 - atomic_t num_posixmkdirs;
53820 - atomic_t num_rmdirs;
53821 - atomic_t num_renames;
53822 - atomic_t num_t2renames;
53823 - atomic_t num_ffirst;
53824 - atomic_t num_fnext;
53825 - atomic_t num_fclose;
53826 - atomic_t num_hardlinks;
53827 - atomic_t num_symlinks;
53828 - atomic_t num_locks;
53829 - atomic_t num_acl_get;
53830 - atomic_t num_acl_set;
53831 + atomic_unchecked_t num_writes;
53832 + atomic_unchecked_t num_reads;
53833 + atomic_unchecked_t num_flushes;
53834 + atomic_unchecked_t num_oplock_brks;
53835 + atomic_unchecked_t num_opens;
53836 + atomic_unchecked_t num_closes;
53837 + atomic_unchecked_t num_deletes;
53838 + atomic_unchecked_t num_mkdirs;
53839 + atomic_unchecked_t num_posixopens;
53840 + atomic_unchecked_t num_posixmkdirs;
53841 + atomic_unchecked_t num_rmdirs;
53842 + atomic_unchecked_t num_renames;
53843 + atomic_unchecked_t num_t2renames;
53844 + atomic_unchecked_t num_ffirst;
53845 + atomic_unchecked_t num_fnext;
53846 + atomic_unchecked_t num_fclose;
53847 + atomic_unchecked_t num_hardlinks;
53848 + atomic_unchecked_t num_symlinks;
53849 + atomic_unchecked_t num_locks;
53850 + atomic_unchecked_t num_acl_get;
53851 + atomic_unchecked_t num_acl_set;
53852 } cifs_stats;
53853 #ifdef CONFIG_CIFS_SMB2
53854 struct {
53855 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53856 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53857 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53858 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53859 } smb2_stats;
53860 #endif /* CONFIG_CIFS_SMB2 */
53861 } stats;
53862 @@ -1096,7 +1096,7 @@ convert_delimiter(char *path, char delim)
53863 }
53864
53865 #ifdef CONFIG_CIFS_STATS
53866 -#define cifs_stats_inc atomic_inc
53867 +#define cifs_stats_inc atomic_inc_unchecked
53868
53869 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
53870 unsigned int bytes)
53871 @@ -1461,8 +1461,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
53872 /* Various Debug counters */
53873 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
53874 #ifdef CONFIG_CIFS_STATS2
53875 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
53876 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
53877 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
53878 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
53879 #endif
53880 GLOBAL_EXTERN atomic_t smBufAllocCount;
53881 GLOBAL_EXTERN atomic_t midCount;
53882 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
53883 index 562044f..4af6a17 100644
53884 --- a/fs/cifs/link.c
53885 +++ b/fs/cifs/link.c
53886 @@ -638,7 +638,7 @@ symlink_exit:
53887
53888 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
53889 {
53890 - char *p = nd_get_link(nd);
53891 + const char *p = nd_get_link(nd);
53892 if (!IS_ERR(p))
53893 kfree(p);
53894 }
53895 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
53896 index f7d4b22..1254377 100644
53897 --- a/fs/cifs/misc.c
53898 +++ b/fs/cifs/misc.c
53899 @@ -169,7 +169,7 @@ cifs_buf_get(void)
53900 memset(ret_buf, 0, buf_size + 3);
53901 atomic_inc(&bufAllocCount);
53902 #ifdef CONFIG_CIFS_STATS2
53903 - atomic_inc(&totBufAllocCount);
53904 + atomic_inc_unchecked(&totBufAllocCount);
53905 #endif /* CONFIG_CIFS_STATS2 */
53906 }
53907
53908 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
53909 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
53910 atomic_inc(&smBufAllocCount);
53911 #ifdef CONFIG_CIFS_STATS2
53912 - atomic_inc(&totSmBufAllocCount);
53913 + atomic_inc_unchecked(&totSmBufAllocCount);
53914 #endif /* CONFIG_CIFS_STATS2 */
53915
53916 }
53917 diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
53918 index af847e1..651a527 100644
53919 --- a/fs/cifs/netmisc.c
53920 +++ b/fs/cifs/netmisc.c
53921 @@ -780,7 +780,9 @@ static const struct {
53922 ERRDOS, ERRnoaccess, 0xc0000290}, {
53923 ERRDOS, ERRbadfunc, 0xc000029c}, {
53924 ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
53925 - ERRDOS, ERRinvlevel, 0x007c0001}, };
53926 + ERRDOS, ERRinvlevel, 0x007c0001}, {
53927 + 0, 0, 0 }
53928 +};
53929
53930 /*****************************************************************************
53931 Print an error message from the status code
53932 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
53933 index 6094397..51e576f 100644
53934 --- a/fs/cifs/smb1ops.c
53935 +++ b/fs/cifs/smb1ops.c
53936 @@ -590,27 +590,27 @@ static void
53937 cifs_clear_stats(struct cifs_tcon *tcon)
53938 {
53939 #ifdef CONFIG_CIFS_STATS
53940 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
53941 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
53942 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
53943 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53944 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
53945 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
53946 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53947 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
53948 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
53949 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
53950 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
53951 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
53952 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
53953 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
53954 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
53955 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
53956 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
53957 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
53958 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
53959 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
53960 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
53961 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
53962 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
53963 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
53964 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53965 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
53966 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
53967 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53968 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
53969 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
53970 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
53971 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
53972 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
53973 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
53974 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
53975 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
53976 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
53977 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
53978 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
53979 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
53980 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
53981 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
53982 #endif
53983 }
53984
53985 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
53986 {
53987 #ifdef CONFIG_CIFS_STATS
53988 seq_printf(m, " Oplocks breaks: %d",
53989 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
53990 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
53991 seq_printf(m, "\nReads: %d Bytes: %llu",
53992 - atomic_read(&tcon->stats.cifs_stats.num_reads),
53993 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
53994 (long long)(tcon->bytes_read));
53995 seq_printf(m, "\nWrites: %d Bytes: %llu",
53996 - atomic_read(&tcon->stats.cifs_stats.num_writes),
53997 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
53998 (long long)(tcon->bytes_written));
53999 seq_printf(m, "\nFlushes: %d",
54000 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54001 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54002 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54003 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54004 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54005 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54006 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54007 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54008 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54009 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54010 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54011 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54012 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54013 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54014 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54015 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54016 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54017 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54018 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54019 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54020 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54021 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54022 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54023 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54024 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54025 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54026 seq_printf(m, "\nRenames: %d T2 Renames %d",
54027 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54028 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54029 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54030 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54031 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54032 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54033 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54034 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54035 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54036 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54037 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54038 #endif
54039 }
54040
54041 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54042 index f259e6c..ca948ff 100644
54043 --- a/fs/cifs/smb2ops.c
54044 +++ b/fs/cifs/smb2ops.c
54045 @@ -281,8 +281,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54046 #ifdef CONFIG_CIFS_STATS
54047 int i;
54048 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54049 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54050 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54051 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54052 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54053 }
54054 #endif
54055 }
54056 @@ -310,65 +310,65 @@ static void
54057 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54058 {
54059 #ifdef CONFIG_CIFS_STATS
54060 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54061 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54062 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54063 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54064 seq_printf(m, "\nNegotiates: %d sent %d failed",
54065 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54066 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54067 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54068 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54069 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54070 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54071 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54072 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54073 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54074 seq_printf(m, "\nLogoffs: %d sent %d failed",
54075 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54076 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54077 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54078 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54079 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54080 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54081 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54082 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54083 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54084 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54085 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54086 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54087 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54088 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54089 seq_printf(m, "\nCreates: %d sent %d failed",
54090 - atomic_read(&sent[SMB2_CREATE_HE]),
54091 - atomic_read(&failed[SMB2_CREATE_HE]));
54092 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54093 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54094 seq_printf(m, "\nCloses: %d sent %d failed",
54095 - atomic_read(&sent[SMB2_CLOSE_HE]),
54096 - atomic_read(&failed[SMB2_CLOSE_HE]));
54097 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54098 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54099 seq_printf(m, "\nFlushes: %d sent %d failed",
54100 - atomic_read(&sent[SMB2_FLUSH_HE]),
54101 - atomic_read(&failed[SMB2_FLUSH_HE]));
54102 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54103 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54104 seq_printf(m, "\nReads: %d sent %d failed",
54105 - atomic_read(&sent[SMB2_READ_HE]),
54106 - atomic_read(&failed[SMB2_READ_HE]));
54107 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54108 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54109 seq_printf(m, "\nWrites: %d sent %d failed",
54110 - atomic_read(&sent[SMB2_WRITE_HE]),
54111 - atomic_read(&failed[SMB2_WRITE_HE]));
54112 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54113 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54114 seq_printf(m, "\nLocks: %d sent %d failed",
54115 - atomic_read(&sent[SMB2_LOCK_HE]),
54116 - atomic_read(&failed[SMB2_LOCK_HE]));
54117 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54118 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54119 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54120 - atomic_read(&sent[SMB2_IOCTL_HE]),
54121 - atomic_read(&failed[SMB2_IOCTL_HE]));
54122 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54123 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54124 seq_printf(m, "\nCancels: %d sent %d failed",
54125 - atomic_read(&sent[SMB2_CANCEL_HE]),
54126 - atomic_read(&failed[SMB2_CANCEL_HE]));
54127 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54128 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54129 seq_printf(m, "\nEchos: %d sent %d failed",
54130 - atomic_read(&sent[SMB2_ECHO_HE]),
54131 - atomic_read(&failed[SMB2_ECHO_HE]));
54132 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54133 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54134 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54135 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54136 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54137 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54138 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54139 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54140 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54141 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54142 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54143 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54144 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54145 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54146 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54147 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54148 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54149 seq_printf(m, "\nSetInfos: %d sent %d failed",
54150 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54151 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54152 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54153 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54154 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54155 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54156 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54157 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54158 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54159 #endif
54160 }
54161
54162 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54163 index abc9c28..3fdae28 100644
54164 --- a/fs/cifs/smb2pdu.c
54165 +++ b/fs/cifs/smb2pdu.c
54166 @@ -1946,8 +1946,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54167 default:
54168 cifs_dbg(VFS, "info level %u isn't supported\n",
54169 srch_inf->info_level);
54170 - rc = -EINVAL;
54171 - goto qdir_exit;
54172 + return -EINVAL;
54173 }
54174
54175 req->FileIndex = cpu_to_le32(index);
54176 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54177 index 1da168c..8bc7ff6 100644
54178 --- a/fs/coda/cache.c
54179 +++ b/fs/coda/cache.c
54180 @@ -24,7 +24,7 @@
54181 #include "coda_linux.h"
54182 #include "coda_cache.h"
54183
54184 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54185 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54186
54187 /* replace or extend an acl cache hit */
54188 void coda_cache_enter(struct inode *inode, int mask)
54189 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54190 struct coda_inode_info *cii = ITOC(inode);
54191
54192 spin_lock(&cii->c_lock);
54193 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54194 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54195 if (!uid_eq(cii->c_uid, current_fsuid())) {
54196 cii->c_uid = current_fsuid();
54197 cii->c_cached_perm = mask;
54198 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54199 {
54200 struct coda_inode_info *cii = ITOC(inode);
54201 spin_lock(&cii->c_lock);
54202 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54203 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54204 spin_unlock(&cii->c_lock);
54205 }
54206
54207 /* remove all acl caches */
54208 void coda_cache_clear_all(struct super_block *sb)
54209 {
54210 - atomic_inc(&permission_epoch);
54211 + atomic_inc_unchecked(&permission_epoch);
54212 }
54213
54214
54215 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54216 spin_lock(&cii->c_lock);
54217 hit = (mask & cii->c_cached_perm) == mask &&
54218 uid_eq(cii->c_uid, current_fsuid()) &&
54219 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54220 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54221 spin_unlock(&cii->c_lock);
54222
54223 return hit;
54224 diff --git a/fs/compat.c b/fs/compat.c
54225 index 6af20de..fec3fbb 100644
54226 --- a/fs/compat.c
54227 +++ b/fs/compat.c
54228 @@ -54,7 +54,7 @@
54229 #include <asm/ioctls.h>
54230 #include "internal.h"
54231
54232 -int compat_log = 1;
54233 +int compat_log = 0;
54234
54235 int compat_printk(const char *fmt, ...)
54236 {
54237 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54238
54239 set_fs(KERNEL_DS);
54240 /* The __user pointer cast is valid because of the set_fs() */
54241 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54242 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54243 set_fs(oldfs);
54244 /* truncating is ok because it's a user address */
54245 if (!ret)
54246 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54247 goto out;
54248
54249 ret = -EINVAL;
54250 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54251 + if (nr_segs > UIO_MAXIOV)
54252 goto out;
54253 if (nr_segs > fast_segs) {
54254 ret = -ENOMEM;
54255 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54256 struct compat_readdir_callback {
54257 struct dir_context ctx;
54258 struct compat_old_linux_dirent __user *dirent;
54259 + struct file * file;
54260 int result;
54261 };
54262
54263 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54264 buf->result = -EOVERFLOW;
54265 return -EOVERFLOW;
54266 }
54267 +
54268 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54269 + return 0;
54270 +
54271 buf->result++;
54272 dirent = buf->dirent;
54273 if (!access_ok(VERIFY_WRITE, dirent,
54274 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54275 if (!f.file)
54276 return -EBADF;
54277
54278 + buf.file = f.file;
54279 error = iterate_dir(f.file, &buf.ctx);
54280 if (buf.result)
54281 error = buf.result;
54282 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54283 struct dir_context ctx;
54284 struct compat_linux_dirent __user *current_dir;
54285 struct compat_linux_dirent __user *previous;
54286 + struct file * file;
54287 int count;
54288 int error;
54289 };
54290 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54291 buf->error = -EOVERFLOW;
54292 return -EOVERFLOW;
54293 }
54294 +
54295 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54296 + return 0;
54297 +
54298 dirent = buf->previous;
54299 if (dirent) {
54300 if (__put_user(offset, &dirent->d_off))
54301 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54302 if (!f.file)
54303 return -EBADF;
54304
54305 + buf.file = f.file;
54306 error = iterate_dir(f.file, &buf.ctx);
54307 if (error >= 0)
54308 error = buf.error;
54309 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54310 struct dir_context ctx;
54311 struct linux_dirent64 __user *current_dir;
54312 struct linux_dirent64 __user *previous;
54313 + struct file * file;
54314 int count;
54315 int error;
54316 };
54317 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54318 buf->error = -EINVAL; /* only used if we fail.. */
54319 if (reclen > buf->count)
54320 return -EINVAL;
54321 +
54322 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54323 + return 0;
54324 +
54325 dirent = buf->previous;
54326
54327 if (dirent) {
54328 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54329 if (!f.file)
54330 return -EBADF;
54331
54332 + buf.file = f.file;
54333 error = iterate_dir(f.file, &buf.ctx);
54334 if (error >= 0)
54335 error = buf.error;
54336 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54337 index a81147e..20bf2b5 100644
54338 --- a/fs/compat_binfmt_elf.c
54339 +++ b/fs/compat_binfmt_elf.c
54340 @@ -30,11 +30,13 @@
54341 #undef elf_phdr
54342 #undef elf_shdr
54343 #undef elf_note
54344 +#undef elf_dyn
54345 #undef elf_addr_t
54346 #define elfhdr elf32_hdr
54347 #define elf_phdr elf32_phdr
54348 #define elf_shdr elf32_shdr
54349 #define elf_note elf32_note
54350 +#define elf_dyn Elf32_Dyn
54351 #define elf_addr_t Elf32_Addr
54352
54353 /*
54354 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54355 index 5d19acf..9ab093b 100644
54356 --- a/fs/compat_ioctl.c
54357 +++ b/fs/compat_ioctl.c
54358 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54359 return -EFAULT;
54360 if (__get_user(udata, &ss32->iomem_base))
54361 return -EFAULT;
54362 - ss.iomem_base = compat_ptr(udata);
54363 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54364 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54365 __get_user(ss.port_high, &ss32->port_high))
54366 return -EFAULT;
54367 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54368 for (i = 0; i < nmsgs; i++) {
54369 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54370 return -EFAULT;
54371 - if (get_user(datap, &umsgs[i].buf) ||
54372 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54373 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54374 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54375 return -EFAULT;
54376 }
54377 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54378 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54379 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54380 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54381 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54382 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54383 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54384 return -EFAULT;
54385
54386 return ioctl_preallocate(file, p);
54387 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54388 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54389 {
54390 unsigned int a, b;
54391 - a = *(unsigned int *)p;
54392 - b = *(unsigned int *)q;
54393 + a = *(const unsigned int *)p;
54394 + b = *(const unsigned int *)q;
54395 if (a > b)
54396 return 1;
54397 if (a < b)
54398 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54399 index 277bd1b..f312c9e 100644
54400 --- a/fs/configfs/dir.c
54401 +++ b/fs/configfs/dir.c
54402 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54403 }
54404 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54405 struct configfs_dirent *next;
54406 - const char *name;
54407 + const unsigned char * name;
54408 + char d_name[sizeof(next->s_dentry->d_iname)];
54409 int len;
54410 struct inode *inode = NULL;
54411
54412 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54413 continue;
54414
54415 name = configfs_get_name(next);
54416 - len = strlen(name);
54417 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54418 + len = next->s_dentry->d_name.len;
54419 + memcpy(d_name, name, len);
54420 + name = d_name;
54421 + } else
54422 + len = strlen(name);
54423
54424 /*
54425 * We'll have a dentry and an inode for
54426 diff --git a/fs/coredump.c b/fs/coredump.c
54427 index 72f816d..1ba8eff 100644
54428 --- a/fs/coredump.c
54429 +++ b/fs/coredump.c
54430 @@ -433,8 +433,8 @@ static void wait_for_dump_helpers(struct file *file)
54431 struct pipe_inode_info *pipe = file->private_data;
54432
54433 pipe_lock(pipe);
54434 - pipe->readers++;
54435 - pipe->writers--;
54436 + atomic_inc(&pipe->readers);
54437 + atomic_dec(&pipe->writers);
54438 wake_up_interruptible_sync(&pipe->wait);
54439 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54440 pipe_unlock(pipe);
54441 @@ -443,11 +443,11 @@ static void wait_for_dump_helpers(struct file *file)
54442 * We actually want wait_event_freezable() but then we need
54443 * to clear TIF_SIGPENDING and improve dump_interrupted().
54444 */
54445 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54446 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54447
54448 pipe_lock(pipe);
54449 - pipe->readers--;
54450 - pipe->writers++;
54451 + atomic_dec(&pipe->readers);
54452 + atomic_inc(&pipe->writers);
54453 pipe_unlock(pipe);
54454 }
54455
54456 @@ -494,7 +494,8 @@ void do_coredump(siginfo_t *siginfo)
54457 struct files_struct *displaced;
54458 bool need_nonrelative = false;
54459 bool core_dumped = false;
54460 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54461 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54462 + long signr = siginfo->si_signo;
54463 struct coredump_params cprm = {
54464 .siginfo = siginfo,
54465 .regs = signal_pt_regs(),
54466 @@ -507,7 +508,10 @@ void do_coredump(siginfo_t *siginfo)
54467 .mm_flags = mm->flags,
54468 };
54469
54470 - audit_core_dumps(siginfo->si_signo);
54471 + audit_core_dumps(signr);
54472 +
54473 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54474 + gr_handle_brute_attach(cprm.mm_flags);
54475
54476 binfmt = mm->binfmt;
54477 if (!binfmt || !binfmt->core_dump)
54478 @@ -531,7 +535,7 @@ void do_coredump(siginfo_t *siginfo)
54479 need_nonrelative = true;
54480 }
54481
54482 - retval = coredump_wait(siginfo->si_signo, &core_state);
54483 + retval = coredump_wait(signr, &core_state);
54484 if (retval < 0)
54485 goto fail_creds;
54486
54487 @@ -574,7 +578,7 @@ void do_coredump(siginfo_t *siginfo)
54488 }
54489 cprm.limit = RLIM_INFINITY;
54490
54491 - dump_count = atomic_inc_return(&core_dump_count);
54492 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54493 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54494 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54495 task_tgid_vnr(current), current->comm);
54496 @@ -606,6 +610,8 @@ void do_coredump(siginfo_t *siginfo)
54497 } else {
54498 struct inode *inode;
54499
54500 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54501 +
54502 if (cprm.limit < binfmt->min_coredump)
54503 goto fail_unlock;
54504
54505 @@ -664,7 +670,7 @@ close_fail:
54506 filp_close(cprm.file, NULL);
54507 fail_dropcount:
54508 if (ispipe)
54509 - atomic_dec(&core_dump_count);
54510 + atomic_dec_unchecked(&core_dump_count);
54511 fail_unlock:
54512 kfree(cn.corename);
54513 coredump_finish(mm, core_dumped);
54514 @@ -684,7 +690,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54515 {
54516 return !dump_interrupted() &&
54517 access_ok(VERIFY_READ, addr, nr) &&
54518 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54519 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54520 }
54521 EXPORT_SYMBOL(dump_write);
54522
54523 diff --git a/fs/dcache.c b/fs/dcache.c
54524 index b949af8..5978926 100644
54525 --- a/fs/dcache.c
54526 +++ b/fs/dcache.c
54527 @@ -3073,7 +3073,8 @@ void __init vfs_caches_init(unsigned long mempages)
54528 mempages -= reserve;
54529
54530 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54531 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54532 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54533 + SLAB_NO_SANITIZE, NULL);
54534
54535 dcache_init();
54536 inode_init();
54537 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54538 index c7c83ff..bda9461 100644
54539 --- a/fs/debugfs/inode.c
54540 +++ b/fs/debugfs/inode.c
54541 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54542 */
54543 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54544 {
54545 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54546 + return __create_file(name, S_IFDIR | S_IRWXU,
54547 +#else
54548 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54549 +#endif
54550 parent, NULL, NULL);
54551 }
54552 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54553 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54554 index 67e9b63..a9adb68 100644
54555 --- a/fs/ecryptfs/inode.c
54556 +++ b/fs/ecryptfs/inode.c
54557 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54558 old_fs = get_fs();
54559 set_fs(get_ds());
54560 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54561 - (char __user *)lower_buf,
54562 + (char __force_user *)lower_buf,
54563 PATH_MAX);
54564 set_fs(old_fs);
54565 if (rc < 0)
54566 @@ -706,7 +706,7 @@ out:
54567 static void
54568 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54569 {
54570 - char *buf = nd_get_link(nd);
54571 + const char *buf = nd_get_link(nd);
54572 if (!IS_ERR(buf)) {
54573 /* Free the char* */
54574 kfree(buf);
54575 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54576 index e4141f2..d8263e8 100644
54577 --- a/fs/ecryptfs/miscdev.c
54578 +++ b/fs/ecryptfs/miscdev.c
54579 @@ -304,7 +304,7 @@ check_list:
54580 goto out_unlock_msg_ctx;
54581 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54582 if (msg_ctx->msg) {
54583 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
54584 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
54585 goto out_unlock_msg_ctx;
54586 i += packet_length_size;
54587 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
54588 diff --git a/fs/exec.c b/fs/exec.c
54589 index fd774c7..1c6a7bf 100644
54590 --- a/fs/exec.c
54591 +++ b/fs/exec.c
54592 @@ -55,8 +55,20 @@
54593 #include <linux/pipe_fs_i.h>
54594 #include <linux/oom.h>
54595 #include <linux/compat.h>
54596 +#include <linux/random.h>
54597 +#include <linux/seq_file.h>
54598 +#include <linux/coredump.h>
54599 +#include <linux/mman.h>
54600 +
54601 +#ifdef CONFIG_PAX_REFCOUNT
54602 +#include <linux/kallsyms.h>
54603 +#include <linux/kdebug.h>
54604 +#endif
54605 +
54606 +#include <trace/events/fs.h>
54607
54608 #include <asm/uaccess.h>
54609 +#include <asm/sections.h>
54610 #include <asm/mmu_context.h>
54611 #include <asm/tlb.h>
54612
54613 @@ -66,17 +78,32 @@
54614
54615 #include <trace/events/sched.h>
54616
54617 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54618 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
54619 +{
54620 + pr_warn_once("PAX: PAX_HAVE_ACL_FLAGS was enabled without providing the pax_set_initial_flags callback, this is probably not what you wanted.\n");
54621 +}
54622 +#endif
54623 +
54624 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
54625 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
54626 +EXPORT_SYMBOL(pax_set_initial_flags_func);
54627 +#endif
54628 +
54629 int suid_dumpable = 0;
54630
54631 static LIST_HEAD(formats);
54632 static DEFINE_RWLOCK(binfmt_lock);
54633
54634 +extern int gr_process_kernel_exec_ban(void);
54635 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
54636 +
54637 void __register_binfmt(struct linux_binfmt * fmt, int insert)
54638 {
54639 BUG_ON(!fmt);
54640 write_lock(&binfmt_lock);
54641 - insert ? list_add(&fmt->lh, &formats) :
54642 - list_add_tail(&fmt->lh, &formats);
54643 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
54644 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
54645 write_unlock(&binfmt_lock);
54646 }
54647
54648 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
54649 void unregister_binfmt(struct linux_binfmt * fmt)
54650 {
54651 write_lock(&binfmt_lock);
54652 - list_del(&fmt->lh);
54653 + pax_list_del((struct list_head *)&fmt->lh);
54654 write_unlock(&binfmt_lock);
54655 }
54656
54657 @@ -181,18 +208,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54658 int write)
54659 {
54660 struct page *page;
54661 - int ret;
54662
54663 -#ifdef CONFIG_STACK_GROWSUP
54664 - if (write) {
54665 - ret = expand_downwards(bprm->vma, pos);
54666 - if (ret < 0)
54667 - return NULL;
54668 - }
54669 -#endif
54670 - ret = get_user_pages(current, bprm->mm, pos,
54671 - 1, write, 1, &page, NULL);
54672 - if (ret <= 0)
54673 + if (0 > expand_downwards(bprm->vma, pos))
54674 + return NULL;
54675 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
54676 return NULL;
54677
54678 if (write) {
54679 @@ -208,6 +227,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54680 if (size <= ARG_MAX)
54681 return page;
54682
54683 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54684 + // only allow 512KB for argv+env on suid/sgid binaries
54685 + // to prevent easy ASLR exhaustion
54686 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
54687 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
54688 + (size > (512 * 1024))) {
54689 + put_page(page);
54690 + return NULL;
54691 + }
54692 +#endif
54693 +
54694 /*
54695 * Limit to 1/4-th the stack size for the argv+env strings.
54696 * This ensures that:
54697 @@ -267,6 +297,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54698 vma->vm_end = STACK_TOP_MAX;
54699 vma->vm_start = vma->vm_end - PAGE_SIZE;
54700 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
54701 +
54702 +#ifdef CONFIG_PAX_SEGMEXEC
54703 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
54704 +#endif
54705 +
54706 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
54707 INIT_LIST_HEAD(&vma->anon_vma_chain);
54708
54709 @@ -277,6 +312,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54710 mm->stack_vm = mm->total_vm = 1;
54711 up_write(&mm->mmap_sem);
54712 bprm->p = vma->vm_end - sizeof(void *);
54713 +
54714 +#ifdef CONFIG_PAX_RANDUSTACK
54715 + if (randomize_va_space)
54716 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
54717 +#endif
54718 +
54719 return 0;
54720 err:
54721 up_write(&mm->mmap_sem);
54722 @@ -397,7 +438,7 @@ struct user_arg_ptr {
54723 } ptr;
54724 };
54725
54726 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54727 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54728 {
54729 const char __user *native;
54730
54731 @@ -406,14 +447,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54732 compat_uptr_t compat;
54733
54734 if (get_user(compat, argv.ptr.compat + nr))
54735 - return ERR_PTR(-EFAULT);
54736 + return (const char __force_user *)ERR_PTR(-EFAULT);
54737
54738 return compat_ptr(compat);
54739 }
54740 #endif
54741
54742 if (get_user(native, argv.ptr.native + nr))
54743 - return ERR_PTR(-EFAULT);
54744 + return (const char __force_user *)ERR_PTR(-EFAULT);
54745
54746 return native;
54747 }
54748 @@ -432,7 +473,7 @@ static int count(struct user_arg_ptr argv, int max)
54749 if (!p)
54750 break;
54751
54752 - if (IS_ERR(p))
54753 + if (IS_ERR((const char __force_kernel *)p))
54754 return -EFAULT;
54755
54756 if (i >= max)
54757 @@ -467,7 +508,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
54758
54759 ret = -EFAULT;
54760 str = get_user_arg_ptr(argv, argc);
54761 - if (IS_ERR(str))
54762 + if (IS_ERR((const char __force_kernel *)str))
54763 goto out;
54764
54765 len = strnlen_user(str, MAX_ARG_STRLEN);
54766 @@ -549,7 +590,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
54767 int r;
54768 mm_segment_t oldfs = get_fs();
54769 struct user_arg_ptr argv = {
54770 - .ptr.native = (const char __user *const __user *)__argv,
54771 + .ptr.native = (const char __force_user * const __force_user *)__argv,
54772 };
54773
54774 set_fs(KERNEL_DS);
54775 @@ -584,7 +625,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54776 unsigned long new_end = old_end - shift;
54777 struct mmu_gather tlb;
54778
54779 - BUG_ON(new_start > new_end);
54780 + if (new_start >= new_end || new_start < mmap_min_addr)
54781 + return -ENOMEM;
54782
54783 /*
54784 * ensure there are no vmas between where we want to go
54785 @@ -593,6 +635,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54786 if (vma != find_vma(mm, new_start))
54787 return -EFAULT;
54788
54789 +#ifdef CONFIG_PAX_SEGMEXEC
54790 + BUG_ON(pax_find_mirror_vma(vma));
54791 +#endif
54792 +
54793 /*
54794 * cover the whole range: [new_start, old_end)
54795 */
54796 @@ -673,10 +719,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54797 stack_top = arch_align_stack(stack_top);
54798 stack_top = PAGE_ALIGN(stack_top);
54799
54800 - if (unlikely(stack_top < mmap_min_addr) ||
54801 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
54802 - return -ENOMEM;
54803 -
54804 stack_shift = vma->vm_end - stack_top;
54805
54806 bprm->p -= stack_shift;
54807 @@ -688,8 +730,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
54808 bprm->exec -= stack_shift;
54809
54810 down_write(&mm->mmap_sem);
54811 +
54812 + /* Move stack pages down in memory. */
54813 + if (stack_shift) {
54814 + ret = shift_arg_pages(vma, stack_shift);
54815 + if (ret)
54816 + goto out_unlock;
54817 + }
54818 +
54819 vm_flags = VM_STACK_FLAGS;
54820
54821 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54822 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54823 + vm_flags &= ~VM_EXEC;
54824 +
54825 +#ifdef CONFIG_PAX_MPROTECT
54826 + if (mm->pax_flags & MF_PAX_MPROTECT)
54827 + vm_flags &= ~VM_MAYEXEC;
54828 +#endif
54829 +
54830 + }
54831 +#endif
54832 +
54833 /*
54834 * Adjust stack execute permissions; explicitly enable for
54835 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
54836 @@ -708,13 +770,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54837 goto out_unlock;
54838 BUG_ON(prev != vma);
54839
54840 - /* Move stack pages down in memory. */
54841 - if (stack_shift) {
54842 - ret = shift_arg_pages(vma, stack_shift);
54843 - if (ret)
54844 - goto out_unlock;
54845 - }
54846 -
54847 /* mprotect_fixup is overkill to remove the temporary stack flags */
54848 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
54849
54850 @@ -738,6 +793,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
54851 #endif
54852 current->mm->start_stack = bprm->p;
54853 ret = expand_stack(vma, stack_base);
54854 +
54855 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
54856 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
54857 + unsigned long size;
54858 + vm_flags_t vm_flags;
54859 +
54860 + size = STACK_TOP - vma->vm_end;
54861 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
54862 +
54863 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
54864 +
54865 +#ifdef CONFIG_X86
54866 + if (!ret) {
54867 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
54868 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
54869 + }
54870 +#endif
54871 +
54872 + }
54873 +#endif
54874 +
54875 if (ret)
54876 ret = -EFAULT;
54877
54878 @@ -774,6 +850,8 @@ struct file *open_exec(const char *name)
54879
54880 fsnotify_open(file);
54881
54882 + trace_open_exec(name);
54883 +
54884 err = deny_write_access(file);
54885 if (err)
54886 goto exit;
54887 @@ -797,7 +875,7 @@ int kernel_read(struct file *file, loff_t offset,
54888 old_fs = get_fs();
54889 set_fs(get_ds());
54890 /* The cast to a user pointer is valid due to the set_fs() */
54891 - result = vfs_read(file, (void __user *)addr, count, &pos);
54892 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
54893 set_fs(old_fs);
54894 return result;
54895 }
54896 @@ -1253,7 +1331,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
54897 }
54898 rcu_read_unlock();
54899
54900 - if (p->fs->users > n_fs) {
54901 + if (atomic_read(&p->fs->users) > n_fs) {
54902 bprm->unsafe |= LSM_UNSAFE_SHARE;
54903 } else {
54904 res = -EAGAIN;
54905 @@ -1453,6 +1531,31 @@ int search_binary_handler(struct linux_binprm *bprm)
54906
54907 EXPORT_SYMBOL(search_binary_handler);
54908
54909 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54910 +static DEFINE_PER_CPU(u64, exec_counter);
54911 +static int __init init_exec_counters(void)
54912 +{
54913 + unsigned int cpu;
54914 +
54915 + for_each_possible_cpu(cpu) {
54916 + per_cpu(exec_counter, cpu) = (u64)cpu;
54917 + }
54918 +
54919 + return 0;
54920 +}
54921 +early_initcall(init_exec_counters);
54922 +static inline void increment_exec_counter(void)
54923 +{
54924 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
54925 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
54926 +}
54927 +#else
54928 +static inline void increment_exec_counter(void) {}
54929 +#endif
54930 +
54931 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
54932 + struct user_arg_ptr argv);
54933 +
54934 /*
54935 * sys_execve() executes a new program.
54936 */
54937 @@ -1460,12 +1563,19 @@ static int do_execve_common(const char *filename,
54938 struct user_arg_ptr argv,
54939 struct user_arg_ptr envp)
54940 {
54941 +#ifdef CONFIG_GRKERNSEC
54942 + struct file *old_exec_file;
54943 + struct acl_subject_label *old_acl;
54944 + struct rlimit old_rlim[RLIM_NLIMITS];
54945 +#endif
54946 struct linux_binprm *bprm;
54947 struct file *file;
54948 struct files_struct *displaced;
54949 bool clear_in_exec;
54950 int retval;
54951
54952 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
54953 +
54954 /*
54955 * We move the actual failure in case of RLIMIT_NPROC excess from
54956 * set*uid() to execve() because too many poorly written programs
54957 @@ -1506,12 +1616,22 @@ static int do_execve_common(const char *filename,
54958 if (IS_ERR(file))
54959 goto out_unmark;
54960
54961 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
54962 + retval = -EPERM;
54963 + goto out_file;
54964 + }
54965 +
54966 sched_exec();
54967
54968 bprm->file = file;
54969 bprm->filename = filename;
54970 bprm->interp = filename;
54971
54972 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
54973 + retval = -EACCES;
54974 + goto out_file;
54975 + }
54976 +
54977 retval = bprm_mm_init(bprm);
54978 if (retval)
54979 goto out_file;
54980 @@ -1528,24 +1648,70 @@ static int do_execve_common(const char *filename,
54981 if (retval < 0)
54982 goto out;
54983
54984 +#ifdef CONFIG_GRKERNSEC
54985 + old_acl = current->acl;
54986 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
54987 + old_exec_file = current->exec_file;
54988 + get_file(file);
54989 + current->exec_file = file;
54990 +#endif
54991 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54992 + /* limit suid stack to 8MB
54993 + * we saved the old limits above and will restore them if this exec fails
54994 + */
54995 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
54996 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
54997 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
54998 +#endif
54999 +
55000 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
55001 + retval = -EPERM;
55002 + goto out_fail;
55003 + }
55004 +
55005 + if (!gr_tpe_allow(file)) {
55006 + retval = -EACCES;
55007 + goto out_fail;
55008 + }
55009 +
55010 + if (gr_check_crash_exec(file)) {
55011 + retval = -EACCES;
55012 + goto out_fail;
55013 + }
55014 +
55015 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55016 + bprm->unsafe);
55017 + if (retval < 0)
55018 + goto out_fail;
55019 +
55020 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55021 if (retval < 0)
55022 - goto out;
55023 + goto out_fail;
55024
55025 bprm->exec = bprm->p;
55026 retval = copy_strings(bprm->envc, envp, bprm);
55027 if (retval < 0)
55028 - goto out;
55029 + goto out_fail;
55030
55031 retval = copy_strings(bprm->argc, argv, bprm);
55032 if (retval < 0)
55033 - goto out;
55034 + goto out_fail;
55035 +
55036 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55037 +
55038 + gr_handle_exec_args(bprm, argv);
55039
55040 retval = search_binary_handler(bprm);
55041 if (retval < 0)
55042 - goto out;
55043 + goto out_fail;
55044 +#ifdef CONFIG_GRKERNSEC
55045 + if (old_exec_file)
55046 + fput(old_exec_file);
55047 +#endif
55048
55049 /* execve succeeded */
55050 +
55051 + increment_exec_counter();
55052 current->fs->in_exec = 0;
55053 current->in_execve = 0;
55054 acct_update_integrals(current);
55055 @@ -1554,6 +1720,14 @@ static int do_execve_common(const char *filename,
55056 put_files_struct(displaced);
55057 return retval;
55058
55059 +out_fail:
55060 +#ifdef CONFIG_GRKERNSEC
55061 + current->acl = old_acl;
55062 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55063 + fput(current->exec_file);
55064 + current->exec_file = old_exec_file;
55065 +#endif
55066 +
55067 out:
55068 if (bprm->mm) {
55069 acct_arg_size(bprm, 0);
55070 @@ -1702,3 +1876,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55071 return error;
55072 }
55073 #endif
55074 +
55075 +int pax_check_flags(unsigned long *flags)
55076 +{
55077 + int retval = 0;
55078 +
55079 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55080 + if (*flags & MF_PAX_SEGMEXEC)
55081 + {
55082 + *flags &= ~MF_PAX_SEGMEXEC;
55083 + retval = -EINVAL;
55084 + }
55085 +#endif
55086 +
55087 + if ((*flags & MF_PAX_PAGEEXEC)
55088 +
55089 +#ifdef CONFIG_PAX_PAGEEXEC
55090 + && (*flags & MF_PAX_SEGMEXEC)
55091 +#endif
55092 +
55093 + )
55094 + {
55095 + *flags &= ~MF_PAX_PAGEEXEC;
55096 + retval = -EINVAL;
55097 + }
55098 +
55099 + if ((*flags & MF_PAX_MPROTECT)
55100 +
55101 +#ifdef CONFIG_PAX_MPROTECT
55102 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55103 +#endif
55104 +
55105 + )
55106 + {
55107 + *flags &= ~MF_PAX_MPROTECT;
55108 + retval = -EINVAL;
55109 + }
55110 +
55111 + if ((*flags & MF_PAX_EMUTRAMP)
55112 +
55113 +#ifdef CONFIG_PAX_EMUTRAMP
55114 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55115 +#endif
55116 +
55117 + )
55118 + {
55119 + *flags &= ~MF_PAX_EMUTRAMP;
55120 + retval = -EINVAL;
55121 + }
55122 +
55123 + return retval;
55124 +}
55125 +
55126 +EXPORT_SYMBOL(pax_check_flags);
55127 +
55128 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55129 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55130 +{
55131 + char *pathname = d_path(path, buf, buflen);
55132 +
55133 + if (IS_ERR(pathname))
55134 + goto toolong;
55135 +
55136 + pathname = mangle_path(buf, pathname, "\t\n\\");
55137 + if (!pathname)
55138 + goto toolong;
55139 +
55140 + *pathname = 0;
55141 + return buf;
55142 +
55143 +toolong:
55144 + return "<path too long>";
55145 +}
55146 +EXPORT_SYMBOL(pax_get_path);
55147 +
55148 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55149 +{
55150 + struct task_struct *tsk = current;
55151 + struct mm_struct *mm = current->mm;
55152 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55153 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55154 + char *path_exec = NULL;
55155 + char *path_fault = NULL;
55156 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55157 + siginfo_t info = { };
55158 +
55159 + if (buffer_exec && buffer_fault) {
55160 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55161 +
55162 + down_read(&mm->mmap_sem);
55163 + vma = mm->mmap;
55164 + while (vma && (!vma_exec || !vma_fault)) {
55165 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55166 + vma_exec = vma;
55167 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55168 + vma_fault = vma;
55169 + vma = vma->vm_next;
55170 + }
55171 + if (vma_exec)
55172 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55173 + if (vma_fault) {
55174 + start = vma_fault->vm_start;
55175 + end = vma_fault->vm_end;
55176 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55177 + if (vma_fault->vm_file)
55178 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55179 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55180 + path_fault = "<heap>";
55181 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55182 + path_fault = "<stack>";
55183 + else
55184 + path_fault = "<anonymous mapping>";
55185 + }
55186 + up_read(&mm->mmap_sem);
55187 + }
55188 + if (tsk->signal->curr_ip)
55189 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55190 + else
55191 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55192 + printk(KERN_ERR "PAX: terminating task: %s(%s):%d, uid/euid: %u/%u, PC: %p, SP: %p\n", path_exec, tsk->comm, task_pid_nr(tsk),
55193 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55194 + free_page((unsigned long)buffer_exec);
55195 + free_page((unsigned long)buffer_fault);
55196 + pax_report_insns(regs, pc, sp);
55197 + info.si_signo = SIGKILL;
55198 + info.si_errno = 0;
55199 + info.si_code = SI_KERNEL;
55200 + info.si_pid = 0;
55201 + info.si_uid = 0;
55202 + do_coredump(&info);
55203 +}
55204 +#endif
55205 +
55206 +#ifdef CONFIG_PAX_REFCOUNT
55207 +void pax_report_refcount_overflow(struct pt_regs *regs)
55208 +{
55209 + if (current->signal->curr_ip)
55210 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55211 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55212 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55213 + else
55214 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55215 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55216 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55217 + preempt_disable();
55218 + show_regs(regs);
55219 + preempt_enable();
55220 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55221 +}
55222 +#endif
55223 +
55224 +#ifdef CONFIG_PAX_USERCOPY
55225 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55226 +static noinline int check_stack_object(const void *obj, unsigned long len)
55227 +{
55228 + const void * const stack = task_stack_page(current);
55229 + const void * const stackend = stack + THREAD_SIZE;
55230 +
55231 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55232 + const void *frame = NULL;
55233 + const void *oldframe;
55234 +#endif
55235 +
55236 + if (obj + len < obj)
55237 + return -1;
55238 +
55239 + if (obj + len <= stack || stackend <= obj)
55240 + return 0;
55241 +
55242 + if (obj < stack || stackend < obj + len)
55243 + return -1;
55244 +
55245 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55246 + oldframe = __builtin_frame_address(1);
55247 + if (oldframe)
55248 + frame = __builtin_frame_address(2);
55249 + /*
55250 + low ----------------------------------------------> high
55251 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55252 + ^----------------^
55253 + allow copies only within here
55254 + */
55255 + while (stack <= frame && frame < stackend) {
55256 + /* if obj + len extends past the last frame, this
55257 + check won't pass and the next frame will be 0,
55258 + causing us to bail out and correctly report
55259 + the copy as invalid
55260 + */
55261 + if (obj + len <= frame)
55262 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55263 + oldframe = frame;
55264 + frame = *(const void * const *)frame;
55265 + }
55266 + return -1;
55267 +#else
55268 + return 1;
55269 +#endif
55270 +}
55271 +
55272 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55273 +{
55274 + if (current->signal->curr_ip)
55275 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55276 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55277 + else
55278 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55279 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55280 + dump_stack();
55281 + gr_handle_kernel_exploit();
55282 + do_group_exit(SIGKILL);
55283 +}
55284 +#endif
55285 +
55286 +#ifdef CONFIG_PAX_USERCOPY
55287 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55288 +{
55289 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55290 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55291 +#ifdef CONFIG_MODULES
55292 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55293 +#else
55294 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55295 +#endif
55296 +
55297 +#else
55298 + unsigned long textlow = (unsigned long)_stext;
55299 + unsigned long texthigh = (unsigned long)_etext;
55300 +#endif
55301 +
55302 + if (high <= textlow || low > texthigh)
55303 + return false;
55304 + else
55305 + return true;
55306 +}
55307 +#endif
55308 +
55309 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55310 +{
55311 +
55312 +#ifdef CONFIG_PAX_USERCOPY
55313 + const char *type;
55314 +
55315 + if (!n)
55316 + return;
55317 +
55318 + type = check_heap_object(ptr, n);
55319 + if (!type) {
55320 + int ret = check_stack_object(ptr, n);
55321 + if (ret == 1 || ret == 2)
55322 + return;
55323 + if (ret == 0) {
55324 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55325 + type = "<kernel text>";
55326 + else
55327 + return;
55328 + } else
55329 + type = "<process stack>";
55330 + }
55331 +
55332 + pax_report_usercopy(ptr, n, to_user, type);
55333 +#endif
55334 +
55335 +}
55336 +EXPORT_SYMBOL(__check_object_size);
55337 +
55338 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55339 +void pax_track_stack(void)
55340 +{
55341 + unsigned long sp = (unsigned long)&sp;
55342 + if (sp < current_thread_info()->lowest_stack &&
55343 + sp > (unsigned long)task_stack_page(current))
55344 + current_thread_info()->lowest_stack = sp;
55345 +}
55346 +EXPORT_SYMBOL(pax_track_stack);
55347 +#endif
55348 +
55349 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55350 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55351 +{
55352 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55353 + dump_stack();
55354 + do_group_exit(SIGKILL);
55355 +}
55356 +EXPORT_SYMBOL(report_size_overflow);
55357 +#endif
55358 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55359 index 9f9992b..8b59411 100644
55360 --- a/fs/ext2/balloc.c
55361 +++ b/fs/ext2/balloc.c
55362 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55363
55364 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55365 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55366 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55367 + if (free_blocks < root_blocks + 1 &&
55368 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55369 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55370 - !in_group_p (sbi->s_resgid))) {
55371 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55372 return 0;
55373 }
55374 return 1;
55375 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55376 index 22548f5..41521d8 100644
55377 --- a/fs/ext3/balloc.c
55378 +++ b/fs/ext3/balloc.c
55379 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55380
55381 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55382 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55383 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55384 + if (free_blocks < root_blocks + 1 &&
55385 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55386 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55387 - !in_group_p (sbi->s_resgid))) {
55388 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55389 return 0;
55390 }
55391 return 1;
55392 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55393 index ddd715e..c772f88 100644
55394 --- a/fs/ext4/balloc.c
55395 +++ b/fs/ext4/balloc.c
55396 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55397 /* Hm, nope. Are (enough) root reserved clusters available? */
55398 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55399 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55400 - capable(CAP_SYS_RESOURCE) ||
55401 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55402 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55403 + capable_nolog(CAP_SYS_RESOURCE)) {
55404
55405 if (free_clusters >= (nclusters + dirty_clusters +
55406 resv_clusters))
55407 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55408 index 0ab26fb..b6ecb39 100644
55409 --- a/fs/ext4/ext4.h
55410 +++ b/fs/ext4/ext4.h
55411 @@ -1247,19 +1247,19 @@ struct ext4_sb_info {
55412 unsigned long s_mb_last_start;
55413
55414 /* stats for buddy allocator */
55415 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55416 - atomic_t s_bal_success; /* we found long enough chunks */
55417 - atomic_t s_bal_allocated; /* in blocks */
55418 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55419 - atomic_t s_bal_goals; /* goal hits */
55420 - atomic_t s_bal_breaks; /* too long searches */
55421 - atomic_t s_bal_2orders; /* 2^order hits */
55422 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55423 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55424 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55425 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55426 + atomic_unchecked_t s_bal_goals; /* goal hits */
55427 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55428 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55429 spinlock_t s_bal_lock;
55430 unsigned long s_mb_buddies_generated;
55431 unsigned long long s_mb_generation_time;
55432 - atomic_t s_mb_lost_chunks;
55433 - atomic_t s_mb_preallocated;
55434 - atomic_t s_mb_discarded;
55435 + atomic_unchecked_t s_mb_lost_chunks;
55436 + atomic_unchecked_t s_mb_preallocated;
55437 + atomic_unchecked_t s_mb_discarded;
55438 atomic_t s_lock_busy;
55439
55440 /* locality groups */
55441 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55442 index 4bbbf13b..dcceaeb 100644
55443 --- a/fs/ext4/mballoc.c
55444 +++ b/fs/ext4/mballoc.c
55445 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55446 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55447
55448 if (EXT4_SB(sb)->s_mb_stats)
55449 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55450 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55451
55452 break;
55453 }
55454 @@ -2171,7 +2171,7 @@ repeat:
55455 ac->ac_status = AC_STATUS_CONTINUE;
55456 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55457 cr = 3;
55458 - atomic_inc(&sbi->s_mb_lost_chunks);
55459 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55460 goto repeat;
55461 }
55462 }
55463 @@ -2679,25 +2679,25 @@ int ext4_mb_release(struct super_block *sb)
55464 if (sbi->s_mb_stats) {
55465 ext4_msg(sb, KERN_INFO,
55466 "mballoc: %u blocks %u reqs (%u success)",
55467 - atomic_read(&sbi->s_bal_allocated),
55468 - atomic_read(&sbi->s_bal_reqs),
55469 - atomic_read(&sbi->s_bal_success));
55470 + atomic_read_unchecked(&sbi->s_bal_allocated),
55471 + atomic_read_unchecked(&sbi->s_bal_reqs),
55472 + atomic_read_unchecked(&sbi->s_bal_success));
55473 ext4_msg(sb, KERN_INFO,
55474 "mballoc: %u extents scanned, %u goal hits, "
55475 "%u 2^N hits, %u breaks, %u lost",
55476 - atomic_read(&sbi->s_bal_ex_scanned),
55477 - atomic_read(&sbi->s_bal_goals),
55478 - atomic_read(&sbi->s_bal_2orders),
55479 - atomic_read(&sbi->s_bal_breaks),
55480 - atomic_read(&sbi->s_mb_lost_chunks));
55481 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55482 + atomic_read_unchecked(&sbi->s_bal_goals),
55483 + atomic_read_unchecked(&sbi->s_bal_2orders),
55484 + atomic_read_unchecked(&sbi->s_bal_breaks),
55485 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55486 ext4_msg(sb, KERN_INFO,
55487 "mballoc: %lu generated and it took %Lu",
55488 sbi->s_mb_buddies_generated,
55489 sbi->s_mb_generation_time);
55490 ext4_msg(sb, KERN_INFO,
55491 "mballoc: %u preallocated, %u discarded",
55492 - atomic_read(&sbi->s_mb_preallocated),
55493 - atomic_read(&sbi->s_mb_discarded));
55494 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55495 + atomic_read_unchecked(&sbi->s_mb_discarded));
55496 }
55497
55498 free_percpu(sbi->s_locality_groups);
55499 @@ -3151,16 +3151,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55500 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55501
55502 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55503 - atomic_inc(&sbi->s_bal_reqs);
55504 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55505 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55506 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55507 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55508 - atomic_inc(&sbi->s_bal_success);
55509 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55510 + atomic_inc_unchecked(&sbi->s_bal_success);
55511 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55512 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55513 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55514 - atomic_inc(&sbi->s_bal_goals);
55515 + atomic_inc_unchecked(&sbi->s_bal_goals);
55516 if (ac->ac_found > sbi->s_mb_max_to_scan)
55517 - atomic_inc(&sbi->s_bal_breaks);
55518 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55519 }
55520
55521 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55522 @@ -3560,7 +3560,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55523 trace_ext4_mb_new_inode_pa(ac, pa);
55524
55525 ext4_mb_use_inode_pa(ac, pa);
55526 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
55527 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
55528
55529 ei = EXT4_I(ac->ac_inode);
55530 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55531 @@ -3620,7 +3620,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
55532 trace_ext4_mb_new_group_pa(ac, pa);
55533
55534 ext4_mb_use_group_pa(ac, pa);
55535 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55536 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55537
55538 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55539 lg = ac->ac_lg;
55540 @@ -3709,7 +3709,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
55541 * from the bitmap and continue.
55542 */
55543 }
55544 - atomic_add(free, &sbi->s_mb_discarded);
55545 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
55546
55547 return err;
55548 }
55549 @@ -3727,7 +3727,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
55550 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
55551 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
55552 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
55553 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55554 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55555 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
55556
55557 return 0;
55558 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
55559 index 214461e..3614c89 100644
55560 --- a/fs/ext4/mmp.c
55561 +++ b/fs/ext4/mmp.c
55562 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
55563 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
55564 const char *function, unsigned int line, const char *msg)
55565 {
55566 - __ext4_warning(sb, function, line, msg);
55567 + __ext4_warning(sb, function, line, "%s", msg);
55568 __ext4_warning(sb, function, line,
55569 "MMP failure info: last update time: %llu, last update "
55570 "node: %s, last update device: %s\n",
55571 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
55572 index b59373b..f41c2b5 100644
55573 --- a/fs/ext4/super.c
55574 +++ b/fs/ext4/super.c
55575 @@ -1254,7 +1254,7 @@ static ext4_fsblk_t get_sb_block(void **data)
55576 }
55577
55578 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
55579 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55580 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55581 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
55582
55583 #ifdef CONFIG_QUOTA
55584 @@ -2394,7 +2394,7 @@ struct ext4_attr {
55585 int offset;
55586 int deprecated_val;
55587 } u;
55588 -};
55589 +} __do_const;
55590
55591 static int parse_strtoull(const char *buf,
55592 unsigned long long max, unsigned long long *value)
55593 diff --git a/fs/fcntl.c b/fs/fcntl.c
55594 index 65343c3..9969dcf 100644
55595 --- a/fs/fcntl.c
55596 +++ b/fs/fcntl.c
55597 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
55598 if (err)
55599 return err;
55600
55601 + if (gr_handle_chroot_fowner(pid, type))
55602 + return -ENOENT;
55603 + if (gr_check_protected_task_fowner(pid, type))
55604 + return -EACCES;
55605 +
55606 f_modown(filp, pid, type, force);
55607 return 0;
55608 }
55609 diff --git a/fs/fhandle.c b/fs/fhandle.c
55610 index 999ff5c..41f4109 100644
55611 --- a/fs/fhandle.c
55612 +++ b/fs/fhandle.c
55613 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
55614 } else
55615 retval = 0;
55616 /* copy the mount id */
55617 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
55618 - sizeof(*mnt_id)) ||
55619 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
55620 copy_to_user(ufh, handle,
55621 sizeof(struct file_handle) + handle_bytes))
55622 retval = -EFAULT;
55623 diff --git a/fs/file.c b/fs/file.c
55624 index 4a78f98..9447397 100644
55625 --- a/fs/file.c
55626 +++ b/fs/file.c
55627 @@ -16,6 +16,7 @@
55628 #include <linux/slab.h>
55629 #include <linux/vmalloc.h>
55630 #include <linux/file.h>
55631 +#include <linux/security.h>
55632 #include <linux/fdtable.h>
55633 #include <linux/bitops.h>
55634 #include <linux/interrupt.h>
55635 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
55636 if (!file)
55637 return __close_fd(files, fd);
55638
55639 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
55640 if (fd >= rlimit(RLIMIT_NOFILE))
55641 return -EBADF;
55642
55643 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
55644 if (unlikely(oldfd == newfd))
55645 return -EINVAL;
55646
55647 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
55648 if (newfd >= rlimit(RLIMIT_NOFILE))
55649 return -EBADF;
55650
55651 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
55652 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
55653 {
55654 int err;
55655 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
55656 if (from >= rlimit(RLIMIT_NOFILE))
55657 return -EINVAL;
55658 err = alloc_fd(from, flags);
55659 diff --git a/fs/filesystems.c b/fs/filesystems.c
55660 index 92567d9..fcd8cbf 100644
55661 --- a/fs/filesystems.c
55662 +++ b/fs/filesystems.c
55663 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
55664 int len = dot ? dot - name : strlen(name);
55665
55666 fs = __get_fs_type(name, len);
55667 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
55668 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
55669 +#else
55670 if (!fs && (request_module("fs-%.*s", len, name) == 0))
55671 +#endif
55672 fs = __get_fs_type(name, len);
55673
55674 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
55675 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
55676 index d8ac61d..79a36f0 100644
55677 --- a/fs/fs_struct.c
55678 +++ b/fs/fs_struct.c
55679 @@ -4,6 +4,7 @@
55680 #include <linux/path.h>
55681 #include <linux/slab.h>
55682 #include <linux/fs_struct.h>
55683 +#include <linux/grsecurity.h>
55684 #include "internal.h"
55685
55686 /*
55687 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
55688 write_seqcount_begin(&fs->seq);
55689 old_root = fs->root;
55690 fs->root = *path;
55691 + gr_set_chroot_entries(current, path);
55692 write_seqcount_end(&fs->seq);
55693 spin_unlock(&fs->lock);
55694 if (old_root.dentry)
55695 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
55696 int hits = 0;
55697 spin_lock(&fs->lock);
55698 write_seqcount_begin(&fs->seq);
55699 + /* this root replacement is only done by pivot_root,
55700 + leave grsec's chroot tagging alone for this task
55701 + so that a pivoted root isn't treated as a chroot
55702 + */
55703 hits += replace_path(&fs->root, old_root, new_root);
55704 hits += replace_path(&fs->pwd, old_root, new_root);
55705 write_seqcount_end(&fs->seq);
55706 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
55707 task_lock(tsk);
55708 spin_lock(&fs->lock);
55709 tsk->fs = NULL;
55710 - kill = !--fs->users;
55711 + gr_clear_chroot_entries(tsk);
55712 + kill = !atomic_dec_return(&fs->users);
55713 spin_unlock(&fs->lock);
55714 task_unlock(tsk);
55715 if (kill)
55716 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55717 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
55718 /* We don't need to lock fs - think why ;-) */
55719 if (fs) {
55720 - fs->users = 1;
55721 + atomic_set(&fs->users, 1);
55722 fs->in_exec = 0;
55723 spin_lock_init(&fs->lock);
55724 seqcount_init(&fs->seq);
55725 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55726 spin_lock(&old->lock);
55727 fs->root = old->root;
55728 path_get(&fs->root);
55729 + /* instead of calling gr_set_chroot_entries here,
55730 + we call it from every caller of this function
55731 + */
55732 fs->pwd = old->pwd;
55733 path_get(&fs->pwd);
55734 spin_unlock(&old->lock);
55735 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
55736
55737 task_lock(current);
55738 spin_lock(&fs->lock);
55739 - kill = !--fs->users;
55740 + kill = !atomic_dec_return(&fs->users);
55741 current->fs = new_fs;
55742 + gr_set_chroot_entries(current, &new_fs->root);
55743 spin_unlock(&fs->lock);
55744 task_unlock(current);
55745
55746 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
55747
55748 int current_umask(void)
55749 {
55750 - return current->fs->umask;
55751 + return current->fs->umask | gr_acl_umask();
55752 }
55753 EXPORT_SYMBOL(current_umask);
55754
55755 /* to be mentioned only in INIT_TASK */
55756 struct fs_struct init_fs = {
55757 - .users = 1,
55758 + .users = ATOMIC_INIT(1),
55759 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
55760 .seq = SEQCNT_ZERO,
55761 .umask = 0022,
55762 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
55763 index 0e91a3c..6c6d2e0 100644
55764 --- a/fs/fscache/cookie.c
55765 +++ b/fs/fscache/cookie.c
55766 @@ -19,7 +19,7 @@
55767
55768 struct kmem_cache *fscache_cookie_jar;
55769
55770 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
55771 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
55772
55773 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
55774 static int fscache_alloc_object(struct fscache_cache *cache,
55775 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
55776 parent ? (char *) parent->def->name : "<no-parent>",
55777 def->name, netfs_data);
55778
55779 - fscache_stat(&fscache_n_acquires);
55780 + fscache_stat_unchecked(&fscache_n_acquires);
55781
55782 /* if there's no parent cookie, then we don't create one here either */
55783 if (!parent) {
55784 - fscache_stat(&fscache_n_acquires_null);
55785 + fscache_stat_unchecked(&fscache_n_acquires_null);
55786 _leave(" [no parent]");
55787 return NULL;
55788 }
55789 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
55790 /* allocate and initialise a cookie */
55791 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
55792 if (!cookie) {
55793 - fscache_stat(&fscache_n_acquires_oom);
55794 + fscache_stat_unchecked(&fscache_n_acquires_oom);
55795 _leave(" [ENOMEM]");
55796 return NULL;
55797 }
55798 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55799
55800 switch (cookie->def->type) {
55801 case FSCACHE_COOKIE_TYPE_INDEX:
55802 - fscache_stat(&fscache_n_cookie_index);
55803 + fscache_stat_unchecked(&fscache_n_cookie_index);
55804 break;
55805 case FSCACHE_COOKIE_TYPE_DATAFILE:
55806 - fscache_stat(&fscache_n_cookie_data);
55807 + fscache_stat_unchecked(&fscache_n_cookie_data);
55808 break;
55809 default:
55810 - fscache_stat(&fscache_n_cookie_special);
55811 + fscache_stat_unchecked(&fscache_n_cookie_special);
55812 break;
55813 }
55814
55815 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55816 if (fscache_acquire_non_index_cookie(cookie) < 0) {
55817 atomic_dec(&parent->n_children);
55818 __fscache_cookie_put(cookie);
55819 - fscache_stat(&fscache_n_acquires_nobufs);
55820 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
55821 _leave(" = NULL");
55822 return NULL;
55823 }
55824 }
55825
55826 - fscache_stat(&fscache_n_acquires_ok);
55827 + fscache_stat_unchecked(&fscache_n_acquires_ok);
55828 _leave(" = %p", cookie);
55829 return cookie;
55830 }
55831 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
55832 cache = fscache_select_cache_for_object(cookie->parent);
55833 if (!cache) {
55834 up_read(&fscache_addremove_sem);
55835 - fscache_stat(&fscache_n_acquires_no_cache);
55836 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
55837 _leave(" = -ENOMEDIUM [no cache]");
55838 return -ENOMEDIUM;
55839 }
55840 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
55841 object = cache->ops->alloc_object(cache, cookie);
55842 fscache_stat_d(&fscache_n_cop_alloc_object);
55843 if (IS_ERR(object)) {
55844 - fscache_stat(&fscache_n_object_no_alloc);
55845 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
55846 ret = PTR_ERR(object);
55847 goto error;
55848 }
55849
55850 - fscache_stat(&fscache_n_object_alloc);
55851 + fscache_stat_unchecked(&fscache_n_object_alloc);
55852
55853 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
55854 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
55855
55856 _debug("ALLOC OBJ%x: %s {%lx}",
55857 object->debug_id, cookie->def->name, object->events);
55858 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
55859
55860 _enter("{%s}", cookie->def->name);
55861
55862 - fscache_stat(&fscache_n_invalidates);
55863 + fscache_stat_unchecked(&fscache_n_invalidates);
55864
55865 /* Only permit invalidation of data files. Invalidating an index will
55866 * require the caller to release all its attachments to the tree rooted
55867 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
55868 {
55869 struct fscache_object *object;
55870
55871 - fscache_stat(&fscache_n_updates);
55872 + fscache_stat_unchecked(&fscache_n_updates);
55873
55874 if (!cookie) {
55875 - fscache_stat(&fscache_n_updates_null);
55876 + fscache_stat_unchecked(&fscache_n_updates_null);
55877 _leave(" [no cookie]");
55878 return;
55879 }
55880 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
55881 {
55882 struct fscache_object *object;
55883
55884 - fscache_stat(&fscache_n_relinquishes);
55885 + fscache_stat_unchecked(&fscache_n_relinquishes);
55886 if (retire)
55887 - fscache_stat(&fscache_n_relinquishes_retire);
55888 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
55889
55890 if (!cookie) {
55891 - fscache_stat(&fscache_n_relinquishes_null);
55892 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
55893 _leave(" [no cookie]");
55894 return;
55895 }
55896 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
55897 index 12d505b..86473a3 100644
55898 --- a/fs/fscache/internal.h
55899 +++ b/fs/fscache/internal.h
55900 @@ -147,101 +147,101 @@ extern void fscache_proc_cleanup(void);
55901 * stats.c
55902 */
55903 #ifdef CONFIG_FSCACHE_STATS
55904 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55905 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55906 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55907 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55908
55909 -extern atomic_t fscache_n_op_pend;
55910 -extern atomic_t fscache_n_op_run;
55911 -extern atomic_t fscache_n_op_enqueue;
55912 -extern atomic_t fscache_n_op_deferred_release;
55913 -extern atomic_t fscache_n_op_release;
55914 -extern atomic_t fscache_n_op_gc;
55915 -extern atomic_t fscache_n_op_cancelled;
55916 -extern atomic_t fscache_n_op_rejected;
55917 +extern atomic_unchecked_t fscache_n_op_pend;
55918 +extern atomic_unchecked_t fscache_n_op_run;
55919 +extern atomic_unchecked_t fscache_n_op_enqueue;
55920 +extern atomic_unchecked_t fscache_n_op_deferred_release;
55921 +extern atomic_unchecked_t fscache_n_op_release;
55922 +extern atomic_unchecked_t fscache_n_op_gc;
55923 +extern atomic_unchecked_t fscache_n_op_cancelled;
55924 +extern atomic_unchecked_t fscache_n_op_rejected;
55925
55926 -extern atomic_t fscache_n_attr_changed;
55927 -extern atomic_t fscache_n_attr_changed_ok;
55928 -extern atomic_t fscache_n_attr_changed_nobufs;
55929 -extern atomic_t fscache_n_attr_changed_nomem;
55930 -extern atomic_t fscache_n_attr_changed_calls;
55931 +extern atomic_unchecked_t fscache_n_attr_changed;
55932 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
55933 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
55934 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
55935 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
55936
55937 -extern atomic_t fscache_n_allocs;
55938 -extern atomic_t fscache_n_allocs_ok;
55939 -extern atomic_t fscache_n_allocs_wait;
55940 -extern atomic_t fscache_n_allocs_nobufs;
55941 -extern atomic_t fscache_n_allocs_intr;
55942 -extern atomic_t fscache_n_allocs_object_dead;
55943 -extern atomic_t fscache_n_alloc_ops;
55944 -extern atomic_t fscache_n_alloc_op_waits;
55945 +extern atomic_unchecked_t fscache_n_allocs;
55946 +extern atomic_unchecked_t fscache_n_allocs_ok;
55947 +extern atomic_unchecked_t fscache_n_allocs_wait;
55948 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
55949 +extern atomic_unchecked_t fscache_n_allocs_intr;
55950 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
55951 +extern atomic_unchecked_t fscache_n_alloc_ops;
55952 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
55953
55954 -extern atomic_t fscache_n_retrievals;
55955 -extern atomic_t fscache_n_retrievals_ok;
55956 -extern atomic_t fscache_n_retrievals_wait;
55957 -extern atomic_t fscache_n_retrievals_nodata;
55958 -extern atomic_t fscache_n_retrievals_nobufs;
55959 -extern atomic_t fscache_n_retrievals_intr;
55960 -extern atomic_t fscache_n_retrievals_nomem;
55961 -extern atomic_t fscache_n_retrievals_object_dead;
55962 -extern atomic_t fscache_n_retrieval_ops;
55963 -extern atomic_t fscache_n_retrieval_op_waits;
55964 +extern atomic_unchecked_t fscache_n_retrievals;
55965 +extern atomic_unchecked_t fscache_n_retrievals_ok;
55966 +extern atomic_unchecked_t fscache_n_retrievals_wait;
55967 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
55968 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
55969 +extern atomic_unchecked_t fscache_n_retrievals_intr;
55970 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
55971 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
55972 +extern atomic_unchecked_t fscache_n_retrieval_ops;
55973 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
55974
55975 -extern atomic_t fscache_n_stores;
55976 -extern atomic_t fscache_n_stores_ok;
55977 -extern atomic_t fscache_n_stores_again;
55978 -extern atomic_t fscache_n_stores_nobufs;
55979 -extern atomic_t fscache_n_stores_oom;
55980 -extern atomic_t fscache_n_store_ops;
55981 -extern atomic_t fscache_n_store_calls;
55982 -extern atomic_t fscache_n_store_pages;
55983 -extern atomic_t fscache_n_store_radix_deletes;
55984 -extern atomic_t fscache_n_store_pages_over_limit;
55985 +extern atomic_unchecked_t fscache_n_stores;
55986 +extern atomic_unchecked_t fscache_n_stores_ok;
55987 +extern atomic_unchecked_t fscache_n_stores_again;
55988 +extern atomic_unchecked_t fscache_n_stores_nobufs;
55989 +extern atomic_unchecked_t fscache_n_stores_oom;
55990 +extern atomic_unchecked_t fscache_n_store_ops;
55991 +extern atomic_unchecked_t fscache_n_store_calls;
55992 +extern atomic_unchecked_t fscache_n_store_pages;
55993 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
55994 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
55995
55996 -extern atomic_t fscache_n_store_vmscan_not_storing;
55997 -extern atomic_t fscache_n_store_vmscan_gone;
55998 -extern atomic_t fscache_n_store_vmscan_busy;
55999 -extern atomic_t fscache_n_store_vmscan_cancelled;
56000 -extern atomic_t fscache_n_store_vmscan_wait;
56001 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56002 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56003 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56004 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56005 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56006
56007 -extern atomic_t fscache_n_marks;
56008 -extern atomic_t fscache_n_uncaches;
56009 +extern atomic_unchecked_t fscache_n_marks;
56010 +extern atomic_unchecked_t fscache_n_uncaches;
56011
56012 -extern atomic_t fscache_n_acquires;
56013 -extern atomic_t fscache_n_acquires_null;
56014 -extern atomic_t fscache_n_acquires_no_cache;
56015 -extern atomic_t fscache_n_acquires_ok;
56016 -extern atomic_t fscache_n_acquires_nobufs;
56017 -extern atomic_t fscache_n_acquires_oom;
56018 +extern atomic_unchecked_t fscache_n_acquires;
56019 +extern atomic_unchecked_t fscache_n_acquires_null;
56020 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56021 +extern atomic_unchecked_t fscache_n_acquires_ok;
56022 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56023 +extern atomic_unchecked_t fscache_n_acquires_oom;
56024
56025 -extern atomic_t fscache_n_invalidates;
56026 -extern atomic_t fscache_n_invalidates_run;
56027 +extern atomic_unchecked_t fscache_n_invalidates;
56028 +extern atomic_unchecked_t fscache_n_invalidates_run;
56029
56030 -extern atomic_t fscache_n_updates;
56031 -extern atomic_t fscache_n_updates_null;
56032 -extern atomic_t fscache_n_updates_run;
56033 +extern atomic_unchecked_t fscache_n_updates;
56034 +extern atomic_unchecked_t fscache_n_updates_null;
56035 +extern atomic_unchecked_t fscache_n_updates_run;
56036
56037 -extern atomic_t fscache_n_relinquishes;
56038 -extern atomic_t fscache_n_relinquishes_null;
56039 -extern atomic_t fscache_n_relinquishes_waitcrt;
56040 -extern atomic_t fscache_n_relinquishes_retire;
56041 +extern atomic_unchecked_t fscache_n_relinquishes;
56042 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56043 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56044 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56045
56046 -extern atomic_t fscache_n_cookie_index;
56047 -extern atomic_t fscache_n_cookie_data;
56048 -extern atomic_t fscache_n_cookie_special;
56049 +extern atomic_unchecked_t fscache_n_cookie_index;
56050 +extern atomic_unchecked_t fscache_n_cookie_data;
56051 +extern atomic_unchecked_t fscache_n_cookie_special;
56052
56053 -extern atomic_t fscache_n_object_alloc;
56054 -extern atomic_t fscache_n_object_no_alloc;
56055 -extern atomic_t fscache_n_object_lookups;
56056 -extern atomic_t fscache_n_object_lookups_negative;
56057 -extern atomic_t fscache_n_object_lookups_positive;
56058 -extern atomic_t fscache_n_object_lookups_timed_out;
56059 -extern atomic_t fscache_n_object_created;
56060 -extern atomic_t fscache_n_object_avail;
56061 -extern atomic_t fscache_n_object_dead;
56062 +extern atomic_unchecked_t fscache_n_object_alloc;
56063 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56064 +extern atomic_unchecked_t fscache_n_object_lookups;
56065 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56066 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56067 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56068 +extern atomic_unchecked_t fscache_n_object_created;
56069 +extern atomic_unchecked_t fscache_n_object_avail;
56070 +extern atomic_unchecked_t fscache_n_object_dead;
56071
56072 -extern atomic_t fscache_n_checkaux_none;
56073 -extern atomic_t fscache_n_checkaux_okay;
56074 -extern atomic_t fscache_n_checkaux_update;
56075 -extern atomic_t fscache_n_checkaux_obsolete;
56076 +extern atomic_unchecked_t fscache_n_checkaux_none;
56077 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56078 +extern atomic_unchecked_t fscache_n_checkaux_update;
56079 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56080
56081 extern atomic_t fscache_n_cop_alloc_object;
56082 extern atomic_t fscache_n_cop_lookup_object;
56083 @@ -266,6 +266,11 @@ static inline void fscache_stat(atomic_t *stat)
56084 atomic_inc(stat);
56085 }
56086
56087 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56088 +{
56089 + atomic_inc_unchecked(stat);
56090 +}
56091 +
56092 static inline void fscache_stat_d(atomic_t *stat)
56093 {
56094 atomic_dec(stat);
56095 @@ -278,6 +283,7 @@ extern const struct file_operations fscache_stats_fops;
56096
56097 #define __fscache_stat(stat) (NULL)
56098 #define fscache_stat(stat) do {} while (0)
56099 +#define fscache_stat_unchecked(stat) do {} while (0)
56100 #define fscache_stat_d(stat) do {} while (0)
56101 #endif
56102
56103 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56104 index 86d75a6..5f3d7a0 100644
56105 --- a/fs/fscache/object.c
56106 +++ b/fs/fscache/object.c
56107 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56108 _debug("LOOKUP \"%s\" in \"%s\"",
56109 cookie->def->name, object->cache->tag->name);
56110
56111 - fscache_stat(&fscache_n_object_lookups);
56112 + fscache_stat_unchecked(&fscache_n_object_lookups);
56113 fscache_stat(&fscache_n_cop_lookup_object);
56114 ret = object->cache->ops->lookup_object(object);
56115 fscache_stat_d(&fscache_n_cop_lookup_object);
56116 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56117 if (ret == -ETIMEDOUT) {
56118 /* probably stuck behind another object, so move this one to
56119 * the back of the queue */
56120 - fscache_stat(&fscache_n_object_lookups_timed_out);
56121 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56122 _leave(" [timeout]");
56123 return NO_TRANSIT;
56124 }
56125 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56126 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56127
56128 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56129 - fscache_stat(&fscache_n_object_lookups_negative);
56130 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56131
56132 /* Allow write requests to begin stacking up and read requests to begin
56133 * returning ENODATA.
56134 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56135 /* if we were still looking up, then we must have a positive lookup
56136 * result, in which case there may be data available */
56137 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56138 - fscache_stat(&fscache_n_object_lookups_positive);
56139 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56140
56141 /* We do (presumably) have data */
56142 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56143 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56144 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56145 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56146 } else {
56147 - fscache_stat(&fscache_n_object_created);
56148 + fscache_stat_unchecked(&fscache_n_object_created);
56149 }
56150
56151 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56152 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56153 fscache_stat_d(&fscache_n_cop_lookup_complete);
56154
56155 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56156 - fscache_stat(&fscache_n_object_avail);
56157 + fscache_stat_unchecked(&fscache_n_object_avail);
56158
56159 _leave("");
56160 return transit_to(JUMPSTART_DEPS);
56161 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56162
56163 /* this just shifts the object release to the work processor */
56164 fscache_put_object(object);
56165 - fscache_stat(&fscache_n_object_dead);
56166 + fscache_stat_unchecked(&fscache_n_object_dead);
56167
56168 _leave("");
56169 return transit_to(OBJECT_DEAD);
56170 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56171 enum fscache_checkaux result;
56172
56173 if (!object->cookie->def->check_aux) {
56174 - fscache_stat(&fscache_n_checkaux_none);
56175 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56176 return FSCACHE_CHECKAUX_OKAY;
56177 }
56178
56179 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56180 switch (result) {
56181 /* entry okay as is */
56182 case FSCACHE_CHECKAUX_OKAY:
56183 - fscache_stat(&fscache_n_checkaux_okay);
56184 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56185 break;
56186
56187 /* entry requires update */
56188 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56189 - fscache_stat(&fscache_n_checkaux_update);
56190 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56191 break;
56192
56193 /* entry requires deletion */
56194 case FSCACHE_CHECKAUX_OBSOLETE:
56195 - fscache_stat(&fscache_n_checkaux_obsolete);
56196 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56197 break;
56198
56199 default:
56200 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56201 {
56202 const struct fscache_state *s;
56203
56204 - fscache_stat(&fscache_n_invalidates_run);
56205 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56206 fscache_stat(&fscache_n_cop_invalidate_object);
56207 s = _fscache_invalidate_object(object, event);
56208 fscache_stat_d(&fscache_n_cop_invalidate_object);
56209 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56210 {
56211 _enter("{OBJ%x},%d", object->debug_id, event);
56212
56213 - fscache_stat(&fscache_n_updates_run);
56214 + fscache_stat_unchecked(&fscache_n_updates_run);
56215 fscache_stat(&fscache_n_cop_update_object);
56216 object->cache->ops->update_object(object);
56217 fscache_stat_d(&fscache_n_cop_update_object);
56218 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56219 index 318071a..379938b 100644
56220 --- a/fs/fscache/operation.c
56221 +++ b/fs/fscache/operation.c
56222 @@ -17,7 +17,7 @@
56223 #include <linux/slab.h>
56224 #include "internal.h"
56225
56226 -atomic_t fscache_op_debug_id;
56227 +atomic_unchecked_t fscache_op_debug_id;
56228 EXPORT_SYMBOL(fscache_op_debug_id);
56229
56230 /**
56231 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56232 ASSERTCMP(atomic_read(&op->usage), >, 0);
56233 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56234
56235 - fscache_stat(&fscache_n_op_enqueue);
56236 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56237 switch (op->flags & FSCACHE_OP_TYPE) {
56238 case FSCACHE_OP_ASYNC:
56239 _debug("queue async");
56240 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56241 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56242 if (op->processor)
56243 fscache_enqueue_operation(op);
56244 - fscache_stat(&fscache_n_op_run);
56245 + fscache_stat_unchecked(&fscache_n_op_run);
56246 }
56247
56248 /*
56249 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56250 if (object->n_in_progress > 0) {
56251 atomic_inc(&op->usage);
56252 list_add_tail(&op->pend_link, &object->pending_ops);
56253 - fscache_stat(&fscache_n_op_pend);
56254 + fscache_stat_unchecked(&fscache_n_op_pend);
56255 } else if (!list_empty(&object->pending_ops)) {
56256 atomic_inc(&op->usage);
56257 list_add_tail(&op->pend_link, &object->pending_ops);
56258 - fscache_stat(&fscache_n_op_pend);
56259 + fscache_stat_unchecked(&fscache_n_op_pend);
56260 fscache_start_operations(object);
56261 } else {
56262 ASSERTCMP(object->n_in_progress, ==, 0);
56263 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56264 object->n_exclusive++; /* reads and writes must wait */
56265 atomic_inc(&op->usage);
56266 list_add_tail(&op->pend_link, &object->pending_ops);
56267 - fscache_stat(&fscache_n_op_pend);
56268 + fscache_stat_unchecked(&fscache_n_op_pend);
56269 ret = 0;
56270 } else {
56271 /* If we're in any other state, there must have been an I/O
56272 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56273 if (object->n_exclusive > 0) {
56274 atomic_inc(&op->usage);
56275 list_add_tail(&op->pend_link, &object->pending_ops);
56276 - fscache_stat(&fscache_n_op_pend);
56277 + fscache_stat_unchecked(&fscache_n_op_pend);
56278 } else if (!list_empty(&object->pending_ops)) {
56279 atomic_inc(&op->usage);
56280 list_add_tail(&op->pend_link, &object->pending_ops);
56281 - fscache_stat(&fscache_n_op_pend);
56282 + fscache_stat_unchecked(&fscache_n_op_pend);
56283 fscache_start_operations(object);
56284 } else {
56285 ASSERTCMP(object->n_exclusive, ==, 0);
56286 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56287 object->n_ops++;
56288 atomic_inc(&op->usage);
56289 list_add_tail(&op->pend_link, &object->pending_ops);
56290 - fscache_stat(&fscache_n_op_pend);
56291 + fscache_stat_unchecked(&fscache_n_op_pend);
56292 ret = 0;
56293 } else if (fscache_object_is_dying(object)) {
56294 - fscache_stat(&fscache_n_op_rejected);
56295 + fscache_stat_unchecked(&fscache_n_op_rejected);
56296 op->state = FSCACHE_OP_ST_CANCELLED;
56297 ret = -ENOBUFS;
56298 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56299 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56300 ret = -EBUSY;
56301 if (op->state == FSCACHE_OP_ST_PENDING) {
56302 ASSERT(!list_empty(&op->pend_link));
56303 - fscache_stat(&fscache_n_op_cancelled);
56304 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56305 list_del_init(&op->pend_link);
56306 if (do_cancel)
56307 do_cancel(op);
56308 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56309 while (!list_empty(&object->pending_ops)) {
56310 op = list_entry(object->pending_ops.next,
56311 struct fscache_operation, pend_link);
56312 - fscache_stat(&fscache_n_op_cancelled);
56313 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56314 list_del_init(&op->pend_link);
56315
56316 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56317 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56318 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56319 op->state = FSCACHE_OP_ST_DEAD;
56320
56321 - fscache_stat(&fscache_n_op_release);
56322 + fscache_stat_unchecked(&fscache_n_op_release);
56323
56324 if (op->release) {
56325 op->release(op);
56326 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56327 * lock, and defer it otherwise */
56328 if (!spin_trylock(&object->lock)) {
56329 _debug("defer put");
56330 - fscache_stat(&fscache_n_op_deferred_release);
56331 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56332
56333 cache = object->cache;
56334 spin_lock(&cache->op_gc_list_lock);
56335 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56336
56337 _debug("GC DEFERRED REL OBJ%x OP%x",
56338 object->debug_id, op->debug_id);
56339 - fscache_stat(&fscache_n_op_gc);
56340 + fscache_stat_unchecked(&fscache_n_op_gc);
56341
56342 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56343 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56344 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56345 index d479ab3..727a7f2 100644
56346 --- a/fs/fscache/page.c
56347 +++ b/fs/fscache/page.c
56348 @@ -61,7 +61,7 @@ try_again:
56349 val = radix_tree_lookup(&cookie->stores, page->index);
56350 if (!val) {
56351 rcu_read_unlock();
56352 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56353 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56354 __fscache_uncache_page(cookie, page);
56355 return true;
56356 }
56357 @@ -91,11 +91,11 @@ try_again:
56358 spin_unlock(&cookie->stores_lock);
56359
56360 if (xpage) {
56361 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56362 - fscache_stat(&fscache_n_store_radix_deletes);
56363 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56364 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56365 ASSERTCMP(xpage, ==, page);
56366 } else {
56367 - fscache_stat(&fscache_n_store_vmscan_gone);
56368 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56369 }
56370
56371 wake_up_bit(&cookie->flags, 0);
56372 @@ -110,11 +110,11 @@ page_busy:
56373 * sleeping on memory allocation, so we may need to impose a timeout
56374 * too. */
56375 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56376 - fscache_stat(&fscache_n_store_vmscan_busy);
56377 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56378 return false;
56379 }
56380
56381 - fscache_stat(&fscache_n_store_vmscan_wait);
56382 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56383 __fscache_wait_on_page_write(cookie, page);
56384 gfp &= ~__GFP_WAIT;
56385 goto try_again;
56386 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56387 FSCACHE_COOKIE_STORING_TAG);
56388 if (!radix_tree_tag_get(&cookie->stores, page->index,
56389 FSCACHE_COOKIE_PENDING_TAG)) {
56390 - fscache_stat(&fscache_n_store_radix_deletes);
56391 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56392 xpage = radix_tree_delete(&cookie->stores, page->index);
56393 }
56394 spin_unlock(&cookie->stores_lock);
56395 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56396
56397 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56398
56399 - fscache_stat(&fscache_n_attr_changed_calls);
56400 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56401
56402 if (fscache_object_is_active(object) &&
56403 fscache_use_cookie(object)) {
56404 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56405
56406 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56407
56408 - fscache_stat(&fscache_n_attr_changed);
56409 + fscache_stat_unchecked(&fscache_n_attr_changed);
56410
56411 op = kzalloc(sizeof(*op), GFP_KERNEL);
56412 if (!op) {
56413 - fscache_stat(&fscache_n_attr_changed_nomem);
56414 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56415 _leave(" = -ENOMEM");
56416 return -ENOMEM;
56417 }
56418 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56419 if (fscache_submit_exclusive_op(object, op) < 0)
56420 goto nobufs;
56421 spin_unlock(&cookie->lock);
56422 - fscache_stat(&fscache_n_attr_changed_ok);
56423 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56424 fscache_put_operation(op);
56425 _leave(" = 0");
56426 return 0;
56427 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56428 nobufs:
56429 spin_unlock(&cookie->lock);
56430 kfree(op);
56431 - fscache_stat(&fscache_n_attr_changed_nobufs);
56432 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56433 _leave(" = %d", -ENOBUFS);
56434 return -ENOBUFS;
56435 }
56436 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56437 /* allocate a retrieval operation and attempt to submit it */
56438 op = kzalloc(sizeof(*op), GFP_NOIO);
56439 if (!op) {
56440 - fscache_stat(&fscache_n_retrievals_nomem);
56441 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56442 return NULL;
56443 }
56444
56445 @@ -289,13 +289,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56446 return 0;
56447 }
56448
56449 - fscache_stat(&fscache_n_retrievals_wait);
56450 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56451
56452 jif = jiffies;
56453 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56454 fscache_wait_bit_interruptible,
56455 TASK_INTERRUPTIBLE) != 0) {
56456 - fscache_stat(&fscache_n_retrievals_intr);
56457 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56458 _leave(" = -ERESTARTSYS");
56459 return -ERESTARTSYS;
56460 }
56461 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56462 */
56463 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56464 struct fscache_retrieval *op,
56465 - atomic_t *stat_op_waits,
56466 - atomic_t *stat_object_dead)
56467 + atomic_unchecked_t *stat_op_waits,
56468 + atomic_unchecked_t *stat_object_dead)
56469 {
56470 int ret;
56471
56472 @@ -333,7 +333,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56473 goto check_if_dead;
56474
56475 _debug(">>> WT");
56476 - fscache_stat(stat_op_waits);
56477 + fscache_stat_unchecked(stat_op_waits);
56478 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
56479 fscache_wait_bit_interruptible,
56480 TASK_INTERRUPTIBLE) != 0) {
56481 @@ -350,14 +350,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56482
56483 check_if_dead:
56484 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
56485 - fscache_stat(stat_object_dead);
56486 + fscache_stat_unchecked(stat_object_dead);
56487 _leave(" = -ENOBUFS [cancelled]");
56488 return -ENOBUFS;
56489 }
56490 if (unlikely(fscache_object_is_dead(object))) {
56491 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
56492 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
56493 - fscache_stat(stat_object_dead);
56494 + fscache_stat_unchecked(stat_object_dead);
56495 return -ENOBUFS;
56496 }
56497 return 0;
56498 @@ -384,7 +384,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56499
56500 _enter("%p,%p,,,", cookie, page);
56501
56502 - fscache_stat(&fscache_n_retrievals);
56503 + fscache_stat_unchecked(&fscache_n_retrievals);
56504
56505 if (hlist_empty(&cookie->backing_objects))
56506 goto nobufs;
56507 @@ -424,7 +424,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56508 goto nobufs_unlock_dec;
56509 spin_unlock(&cookie->lock);
56510
56511 - fscache_stat(&fscache_n_retrieval_ops);
56512 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56513
56514 /* pin the netfs read context in case we need to do the actual netfs
56515 * read because we've encountered a cache read failure */
56516 @@ -454,15 +454,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56517
56518 error:
56519 if (ret == -ENOMEM)
56520 - fscache_stat(&fscache_n_retrievals_nomem);
56521 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56522 else if (ret == -ERESTARTSYS)
56523 - fscache_stat(&fscache_n_retrievals_intr);
56524 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56525 else if (ret == -ENODATA)
56526 - fscache_stat(&fscache_n_retrievals_nodata);
56527 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56528 else if (ret < 0)
56529 - fscache_stat(&fscache_n_retrievals_nobufs);
56530 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56531 else
56532 - fscache_stat(&fscache_n_retrievals_ok);
56533 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56534
56535 fscache_put_retrieval(op);
56536 _leave(" = %d", ret);
56537 @@ -475,7 +475,7 @@ nobufs_unlock:
56538 atomic_dec(&cookie->n_active);
56539 kfree(op);
56540 nobufs:
56541 - fscache_stat(&fscache_n_retrievals_nobufs);
56542 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56543 _leave(" = -ENOBUFS");
56544 return -ENOBUFS;
56545 }
56546 @@ -513,7 +513,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56547
56548 _enter("%p,,%d,,,", cookie, *nr_pages);
56549
56550 - fscache_stat(&fscache_n_retrievals);
56551 + fscache_stat_unchecked(&fscache_n_retrievals);
56552
56553 if (hlist_empty(&cookie->backing_objects))
56554 goto nobufs;
56555 @@ -549,7 +549,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56556 goto nobufs_unlock_dec;
56557 spin_unlock(&cookie->lock);
56558
56559 - fscache_stat(&fscache_n_retrieval_ops);
56560 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56561
56562 /* pin the netfs read context in case we need to do the actual netfs
56563 * read because we've encountered a cache read failure */
56564 @@ -579,15 +579,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56565
56566 error:
56567 if (ret == -ENOMEM)
56568 - fscache_stat(&fscache_n_retrievals_nomem);
56569 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56570 else if (ret == -ERESTARTSYS)
56571 - fscache_stat(&fscache_n_retrievals_intr);
56572 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56573 else if (ret == -ENODATA)
56574 - fscache_stat(&fscache_n_retrievals_nodata);
56575 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56576 else if (ret < 0)
56577 - fscache_stat(&fscache_n_retrievals_nobufs);
56578 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56579 else
56580 - fscache_stat(&fscache_n_retrievals_ok);
56581 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56582
56583 fscache_put_retrieval(op);
56584 _leave(" = %d", ret);
56585 @@ -600,7 +600,7 @@ nobufs_unlock:
56586 atomic_dec(&cookie->n_active);
56587 kfree(op);
56588 nobufs:
56589 - fscache_stat(&fscache_n_retrievals_nobufs);
56590 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56591 _leave(" = -ENOBUFS");
56592 return -ENOBUFS;
56593 }
56594 @@ -624,7 +624,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56595
56596 _enter("%p,%p,,,", cookie, page);
56597
56598 - fscache_stat(&fscache_n_allocs);
56599 + fscache_stat_unchecked(&fscache_n_allocs);
56600
56601 if (hlist_empty(&cookie->backing_objects))
56602 goto nobufs;
56603 @@ -656,7 +656,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56604 goto nobufs_unlock;
56605 spin_unlock(&cookie->lock);
56606
56607 - fscache_stat(&fscache_n_alloc_ops);
56608 + fscache_stat_unchecked(&fscache_n_alloc_ops);
56609
56610 ret = fscache_wait_for_retrieval_activation(
56611 object, op,
56612 @@ -672,11 +672,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56613
56614 error:
56615 if (ret == -ERESTARTSYS)
56616 - fscache_stat(&fscache_n_allocs_intr);
56617 + fscache_stat_unchecked(&fscache_n_allocs_intr);
56618 else if (ret < 0)
56619 - fscache_stat(&fscache_n_allocs_nobufs);
56620 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56621 else
56622 - fscache_stat(&fscache_n_allocs_ok);
56623 + fscache_stat_unchecked(&fscache_n_allocs_ok);
56624
56625 fscache_put_retrieval(op);
56626 _leave(" = %d", ret);
56627 @@ -687,7 +687,7 @@ nobufs_unlock:
56628 atomic_dec(&cookie->n_active);
56629 kfree(op);
56630 nobufs:
56631 - fscache_stat(&fscache_n_allocs_nobufs);
56632 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56633 _leave(" = -ENOBUFS");
56634 return -ENOBUFS;
56635 }
56636 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56637
56638 spin_lock(&cookie->stores_lock);
56639
56640 - fscache_stat(&fscache_n_store_calls);
56641 + fscache_stat_unchecked(&fscache_n_store_calls);
56642
56643 /* find a page to store */
56644 page = NULL;
56645 @@ -758,7 +758,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56646 page = results[0];
56647 _debug("gang %d [%lx]", n, page->index);
56648 if (page->index > op->store_limit) {
56649 - fscache_stat(&fscache_n_store_pages_over_limit);
56650 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
56651 goto superseded;
56652 }
56653
56654 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56655 spin_unlock(&cookie->stores_lock);
56656 spin_unlock(&object->lock);
56657
56658 - fscache_stat(&fscache_n_store_pages);
56659 + fscache_stat_unchecked(&fscache_n_store_pages);
56660 fscache_stat(&fscache_n_cop_write_page);
56661 ret = object->cache->ops->write_page(op, page);
56662 fscache_stat_d(&fscache_n_cop_write_page);
56663 @@ -873,7 +873,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56664 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56665 ASSERT(PageFsCache(page));
56666
56667 - fscache_stat(&fscache_n_stores);
56668 + fscache_stat_unchecked(&fscache_n_stores);
56669
56670 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
56671 _leave(" = -ENOBUFS [invalidating]");
56672 @@ -931,7 +931,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56673 spin_unlock(&cookie->stores_lock);
56674 spin_unlock(&object->lock);
56675
56676 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
56677 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56678 op->store_limit = object->store_limit;
56679
56680 atomic_inc(&cookie->n_active);
56681 @@ -940,8 +940,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56682
56683 spin_unlock(&cookie->lock);
56684 radix_tree_preload_end();
56685 - fscache_stat(&fscache_n_store_ops);
56686 - fscache_stat(&fscache_n_stores_ok);
56687 + fscache_stat_unchecked(&fscache_n_store_ops);
56688 + fscache_stat_unchecked(&fscache_n_stores_ok);
56689
56690 /* the work queue now carries its own ref on the object */
56691 fscache_put_operation(&op->op);
56692 @@ -949,14 +949,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56693 return 0;
56694
56695 already_queued:
56696 - fscache_stat(&fscache_n_stores_again);
56697 + fscache_stat_unchecked(&fscache_n_stores_again);
56698 already_pending:
56699 spin_unlock(&cookie->stores_lock);
56700 spin_unlock(&object->lock);
56701 spin_unlock(&cookie->lock);
56702 radix_tree_preload_end();
56703 kfree(op);
56704 - fscache_stat(&fscache_n_stores_ok);
56705 + fscache_stat_unchecked(&fscache_n_stores_ok);
56706 _leave(" = 0");
56707 return 0;
56708
56709 @@ -976,14 +976,14 @@ nobufs:
56710 spin_unlock(&cookie->lock);
56711 radix_tree_preload_end();
56712 kfree(op);
56713 - fscache_stat(&fscache_n_stores_nobufs);
56714 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
56715 _leave(" = -ENOBUFS");
56716 return -ENOBUFS;
56717
56718 nomem_free:
56719 kfree(op);
56720 nomem:
56721 - fscache_stat(&fscache_n_stores_oom);
56722 + fscache_stat_unchecked(&fscache_n_stores_oom);
56723 _leave(" = -ENOMEM");
56724 return -ENOMEM;
56725 }
56726 @@ -1001,7 +1001,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
56727 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56728 ASSERTCMP(page, !=, NULL);
56729
56730 - fscache_stat(&fscache_n_uncaches);
56731 + fscache_stat_unchecked(&fscache_n_uncaches);
56732
56733 /* cache withdrawal may beat us to it */
56734 if (!PageFsCache(page))
56735 @@ -1052,7 +1052,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
56736 struct fscache_cookie *cookie = op->op.object->cookie;
56737
56738 #ifdef CONFIG_FSCACHE_STATS
56739 - atomic_inc(&fscache_n_marks);
56740 + atomic_inc_unchecked(&fscache_n_marks);
56741 #endif
56742
56743 _debug("- mark %p{%lx}", page, page->index);
56744 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
56745 index 40d13c7..ddf52b9 100644
56746 --- a/fs/fscache/stats.c
56747 +++ b/fs/fscache/stats.c
56748 @@ -18,99 +18,99 @@
56749 /*
56750 * operation counters
56751 */
56752 -atomic_t fscache_n_op_pend;
56753 -atomic_t fscache_n_op_run;
56754 -atomic_t fscache_n_op_enqueue;
56755 -atomic_t fscache_n_op_requeue;
56756 -atomic_t fscache_n_op_deferred_release;
56757 -atomic_t fscache_n_op_release;
56758 -atomic_t fscache_n_op_gc;
56759 -atomic_t fscache_n_op_cancelled;
56760 -atomic_t fscache_n_op_rejected;
56761 +atomic_unchecked_t fscache_n_op_pend;
56762 +atomic_unchecked_t fscache_n_op_run;
56763 +atomic_unchecked_t fscache_n_op_enqueue;
56764 +atomic_unchecked_t fscache_n_op_requeue;
56765 +atomic_unchecked_t fscache_n_op_deferred_release;
56766 +atomic_unchecked_t fscache_n_op_release;
56767 +atomic_unchecked_t fscache_n_op_gc;
56768 +atomic_unchecked_t fscache_n_op_cancelled;
56769 +atomic_unchecked_t fscache_n_op_rejected;
56770
56771 -atomic_t fscache_n_attr_changed;
56772 -atomic_t fscache_n_attr_changed_ok;
56773 -atomic_t fscache_n_attr_changed_nobufs;
56774 -atomic_t fscache_n_attr_changed_nomem;
56775 -atomic_t fscache_n_attr_changed_calls;
56776 +atomic_unchecked_t fscache_n_attr_changed;
56777 +atomic_unchecked_t fscache_n_attr_changed_ok;
56778 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
56779 +atomic_unchecked_t fscache_n_attr_changed_nomem;
56780 +atomic_unchecked_t fscache_n_attr_changed_calls;
56781
56782 -atomic_t fscache_n_allocs;
56783 -atomic_t fscache_n_allocs_ok;
56784 -atomic_t fscache_n_allocs_wait;
56785 -atomic_t fscache_n_allocs_nobufs;
56786 -atomic_t fscache_n_allocs_intr;
56787 -atomic_t fscache_n_allocs_object_dead;
56788 -atomic_t fscache_n_alloc_ops;
56789 -atomic_t fscache_n_alloc_op_waits;
56790 +atomic_unchecked_t fscache_n_allocs;
56791 +atomic_unchecked_t fscache_n_allocs_ok;
56792 +atomic_unchecked_t fscache_n_allocs_wait;
56793 +atomic_unchecked_t fscache_n_allocs_nobufs;
56794 +atomic_unchecked_t fscache_n_allocs_intr;
56795 +atomic_unchecked_t fscache_n_allocs_object_dead;
56796 +atomic_unchecked_t fscache_n_alloc_ops;
56797 +atomic_unchecked_t fscache_n_alloc_op_waits;
56798
56799 -atomic_t fscache_n_retrievals;
56800 -atomic_t fscache_n_retrievals_ok;
56801 -atomic_t fscache_n_retrievals_wait;
56802 -atomic_t fscache_n_retrievals_nodata;
56803 -atomic_t fscache_n_retrievals_nobufs;
56804 -atomic_t fscache_n_retrievals_intr;
56805 -atomic_t fscache_n_retrievals_nomem;
56806 -atomic_t fscache_n_retrievals_object_dead;
56807 -atomic_t fscache_n_retrieval_ops;
56808 -atomic_t fscache_n_retrieval_op_waits;
56809 +atomic_unchecked_t fscache_n_retrievals;
56810 +atomic_unchecked_t fscache_n_retrievals_ok;
56811 +atomic_unchecked_t fscache_n_retrievals_wait;
56812 +atomic_unchecked_t fscache_n_retrievals_nodata;
56813 +atomic_unchecked_t fscache_n_retrievals_nobufs;
56814 +atomic_unchecked_t fscache_n_retrievals_intr;
56815 +atomic_unchecked_t fscache_n_retrievals_nomem;
56816 +atomic_unchecked_t fscache_n_retrievals_object_dead;
56817 +atomic_unchecked_t fscache_n_retrieval_ops;
56818 +atomic_unchecked_t fscache_n_retrieval_op_waits;
56819
56820 -atomic_t fscache_n_stores;
56821 -atomic_t fscache_n_stores_ok;
56822 -atomic_t fscache_n_stores_again;
56823 -atomic_t fscache_n_stores_nobufs;
56824 -atomic_t fscache_n_stores_oom;
56825 -atomic_t fscache_n_store_ops;
56826 -atomic_t fscache_n_store_calls;
56827 -atomic_t fscache_n_store_pages;
56828 -atomic_t fscache_n_store_radix_deletes;
56829 -atomic_t fscache_n_store_pages_over_limit;
56830 +atomic_unchecked_t fscache_n_stores;
56831 +atomic_unchecked_t fscache_n_stores_ok;
56832 +atomic_unchecked_t fscache_n_stores_again;
56833 +atomic_unchecked_t fscache_n_stores_nobufs;
56834 +atomic_unchecked_t fscache_n_stores_oom;
56835 +atomic_unchecked_t fscache_n_store_ops;
56836 +atomic_unchecked_t fscache_n_store_calls;
56837 +atomic_unchecked_t fscache_n_store_pages;
56838 +atomic_unchecked_t fscache_n_store_radix_deletes;
56839 +atomic_unchecked_t fscache_n_store_pages_over_limit;
56840
56841 -atomic_t fscache_n_store_vmscan_not_storing;
56842 -atomic_t fscache_n_store_vmscan_gone;
56843 -atomic_t fscache_n_store_vmscan_busy;
56844 -atomic_t fscache_n_store_vmscan_cancelled;
56845 -atomic_t fscache_n_store_vmscan_wait;
56846 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56847 +atomic_unchecked_t fscache_n_store_vmscan_gone;
56848 +atomic_unchecked_t fscache_n_store_vmscan_busy;
56849 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56850 +atomic_unchecked_t fscache_n_store_vmscan_wait;
56851
56852 -atomic_t fscache_n_marks;
56853 -atomic_t fscache_n_uncaches;
56854 +atomic_unchecked_t fscache_n_marks;
56855 +atomic_unchecked_t fscache_n_uncaches;
56856
56857 -atomic_t fscache_n_acquires;
56858 -atomic_t fscache_n_acquires_null;
56859 -atomic_t fscache_n_acquires_no_cache;
56860 -atomic_t fscache_n_acquires_ok;
56861 -atomic_t fscache_n_acquires_nobufs;
56862 -atomic_t fscache_n_acquires_oom;
56863 +atomic_unchecked_t fscache_n_acquires;
56864 +atomic_unchecked_t fscache_n_acquires_null;
56865 +atomic_unchecked_t fscache_n_acquires_no_cache;
56866 +atomic_unchecked_t fscache_n_acquires_ok;
56867 +atomic_unchecked_t fscache_n_acquires_nobufs;
56868 +atomic_unchecked_t fscache_n_acquires_oom;
56869
56870 -atomic_t fscache_n_invalidates;
56871 -atomic_t fscache_n_invalidates_run;
56872 +atomic_unchecked_t fscache_n_invalidates;
56873 +atomic_unchecked_t fscache_n_invalidates_run;
56874
56875 -atomic_t fscache_n_updates;
56876 -atomic_t fscache_n_updates_null;
56877 -atomic_t fscache_n_updates_run;
56878 +atomic_unchecked_t fscache_n_updates;
56879 +atomic_unchecked_t fscache_n_updates_null;
56880 +atomic_unchecked_t fscache_n_updates_run;
56881
56882 -atomic_t fscache_n_relinquishes;
56883 -atomic_t fscache_n_relinquishes_null;
56884 -atomic_t fscache_n_relinquishes_waitcrt;
56885 -atomic_t fscache_n_relinquishes_retire;
56886 +atomic_unchecked_t fscache_n_relinquishes;
56887 +atomic_unchecked_t fscache_n_relinquishes_null;
56888 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56889 +atomic_unchecked_t fscache_n_relinquishes_retire;
56890
56891 -atomic_t fscache_n_cookie_index;
56892 -atomic_t fscache_n_cookie_data;
56893 -atomic_t fscache_n_cookie_special;
56894 +atomic_unchecked_t fscache_n_cookie_index;
56895 +atomic_unchecked_t fscache_n_cookie_data;
56896 +atomic_unchecked_t fscache_n_cookie_special;
56897
56898 -atomic_t fscache_n_object_alloc;
56899 -atomic_t fscache_n_object_no_alloc;
56900 -atomic_t fscache_n_object_lookups;
56901 -atomic_t fscache_n_object_lookups_negative;
56902 -atomic_t fscache_n_object_lookups_positive;
56903 -atomic_t fscache_n_object_lookups_timed_out;
56904 -atomic_t fscache_n_object_created;
56905 -atomic_t fscache_n_object_avail;
56906 -atomic_t fscache_n_object_dead;
56907 +atomic_unchecked_t fscache_n_object_alloc;
56908 +atomic_unchecked_t fscache_n_object_no_alloc;
56909 +atomic_unchecked_t fscache_n_object_lookups;
56910 +atomic_unchecked_t fscache_n_object_lookups_negative;
56911 +atomic_unchecked_t fscache_n_object_lookups_positive;
56912 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
56913 +atomic_unchecked_t fscache_n_object_created;
56914 +atomic_unchecked_t fscache_n_object_avail;
56915 +atomic_unchecked_t fscache_n_object_dead;
56916
56917 -atomic_t fscache_n_checkaux_none;
56918 -atomic_t fscache_n_checkaux_okay;
56919 -atomic_t fscache_n_checkaux_update;
56920 -atomic_t fscache_n_checkaux_obsolete;
56921 +atomic_unchecked_t fscache_n_checkaux_none;
56922 +atomic_unchecked_t fscache_n_checkaux_okay;
56923 +atomic_unchecked_t fscache_n_checkaux_update;
56924 +atomic_unchecked_t fscache_n_checkaux_obsolete;
56925
56926 atomic_t fscache_n_cop_alloc_object;
56927 atomic_t fscache_n_cop_lookup_object;
56928 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
56929 seq_puts(m, "FS-Cache statistics\n");
56930
56931 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
56932 - atomic_read(&fscache_n_cookie_index),
56933 - atomic_read(&fscache_n_cookie_data),
56934 - atomic_read(&fscache_n_cookie_special));
56935 + atomic_read_unchecked(&fscache_n_cookie_index),
56936 + atomic_read_unchecked(&fscache_n_cookie_data),
56937 + atomic_read_unchecked(&fscache_n_cookie_special));
56938
56939 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
56940 - atomic_read(&fscache_n_object_alloc),
56941 - atomic_read(&fscache_n_object_no_alloc),
56942 - atomic_read(&fscache_n_object_avail),
56943 - atomic_read(&fscache_n_object_dead));
56944 + atomic_read_unchecked(&fscache_n_object_alloc),
56945 + atomic_read_unchecked(&fscache_n_object_no_alloc),
56946 + atomic_read_unchecked(&fscache_n_object_avail),
56947 + atomic_read_unchecked(&fscache_n_object_dead));
56948 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
56949 - atomic_read(&fscache_n_checkaux_none),
56950 - atomic_read(&fscache_n_checkaux_okay),
56951 - atomic_read(&fscache_n_checkaux_update),
56952 - atomic_read(&fscache_n_checkaux_obsolete));
56953 + atomic_read_unchecked(&fscache_n_checkaux_none),
56954 + atomic_read_unchecked(&fscache_n_checkaux_okay),
56955 + atomic_read_unchecked(&fscache_n_checkaux_update),
56956 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
56957
56958 seq_printf(m, "Pages : mrk=%u unc=%u\n",
56959 - atomic_read(&fscache_n_marks),
56960 - atomic_read(&fscache_n_uncaches));
56961 + atomic_read_unchecked(&fscache_n_marks),
56962 + atomic_read_unchecked(&fscache_n_uncaches));
56963
56964 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
56965 " oom=%u\n",
56966 - atomic_read(&fscache_n_acquires),
56967 - atomic_read(&fscache_n_acquires_null),
56968 - atomic_read(&fscache_n_acquires_no_cache),
56969 - atomic_read(&fscache_n_acquires_ok),
56970 - atomic_read(&fscache_n_acquires_nobufs),
56971 - atomic_read(&fscache_n_acquires_oom));
56972 + atomic_read_unchecked(&fscache_n_acquires),
56973 + atomic_read_unchecked(&fscache_n_acquires_null),
56974 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
56975 + atomic_read_unchecked(&fscache_n_acquires_ok),
56976 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
56977 + atomic_read_unchecked(&fscache_n_acquires_oom));
56978
56979 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
56980 - atomic_read(&fscache_n_object_lookups),
56981 - atomic_read(&fscache_n_object_lookups_negative),
56982 - atomic_read(&fscache_n_object_lookups_positive),
56983 - atomic_read(&fscache_n_object_created),
56984 - atomic_read(&fscache_n_object_lookups_timed_out));
56985 + atomic_read_unchecked(&fscache_n_object_lookups),
56986 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
56987 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
56988 + atomic_read_unchecked(&fscache_n_object_created),
56989 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
56990
56991 seq_printf(m, "Invals : n=%u run=%u\n",
56992 - atomic_read(&fscache_n_invalidates),
56993 - atomic_read(&fscache_n_invalidates_run));
56994 + atomic_read_unchecked(&fscache_n_invalidates),
56995 + atomic_read_unchecked(&fscache_n_invalidates_run));
56996
56997 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
56998 - atomic_read(&fscache_n_updates),
56999 - atomic_read(&fscache_n_updates_null),
57000 - atomic_read(&fscache_n_updates_run));
57001 + atomic_read_unchecked(&fscache_n_updates),
57002 + atomic_read_unchecked(&fscache_n_updates_null),
57003 + atomic_read_unchecked(&fscache_n_updates_run));
57004
57005 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57006 - atomic_read(&fscache_n_relinquishes),
57007 - atomic_read(&fscache_n_relinquishes_null),
57008 - atomic_read(&fscache_n_relinquishes_waitcrt),
57009 - atomic_read(&fscache_n_relinquishes_retire));
57010 + atomic_read_unchecked(&fscache_n_relinquishes),
57011 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57012 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57013 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57014
57015 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57016 - atomic_read(&fscache_n_attr_changed),
57017 - atomic_read(&fscache_n_attr_changed_ok),
57018 - atomic_read(&fscache_n_attr_changed_nobufs),
57019 - atomic_read(&fscache_n_attr_changed_nomem),
57020 - atomic_read(&fscache_n_attr_changed_calls));
57021 + atomic_read_unchecked(&fscache_n_attr_changed),
57022 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57023 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57024 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57025 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57026
57027 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57028 - atomic_read(&fscache_n_allocs),
57029 - atomic_read(&fscache_n_allocs_ok),
57030 - atomic_read(&fscache_n_allocs_wait),
57031 - atomic_read(&fscache_n_allocs_nobufs),
57032 - atomic_read(&fscache_n_allocs_intr));
57033 + atomic_read_unchecked(&fscache_n_allocs),
57034 + atomic_read_unchecked(&fscache_n_allocs_ok),
57035 + atomic_read_unchecked(&fscache_n_allocs_wait),
57036 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57037 + atomic_read_unchecked(&fscache_n_allocs_intr));
57038 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57039 - atomic_read(&fscache_n_alloc_ops),
57040 - atomic_read(&fscache_n_alloc_op_waits),
57041 - atomic_read(&fscache_n_allocs_object_dead));
57042 + atomic_read_unchecked(&fscache_n_alloc_ops),
57043 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57044 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57045
57046 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57047 " int=%u oom=%u\n",
57048 - atomic_read(&fscache_n_retrievals),
57049 - atomic_read(&fscache_n_retrievals_ok),
57050 - atomic_read(&fscache_n_retrievals_wait),
57051 - atomic_read(&fscache_n_retrievals_nodata),
57052 - atomic_read(&fscache_n_retrievals_nobufs),
57053 - atomic_read(&fscache_n_retrievals_intr),
57054 - atomic_read(&fscache_n_retrievals_nomem));
57055 + atomic_read_unchecked(&fscache_n_retrievals),
57056 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57057 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57058 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57059 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57060 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57061 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57062 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57063 - atomic_read(&fscache_n_retrieval_ops),
57064 - atomic_read(&fscache_n_retrieval_op_waits),
57065 - atomic_read(&fscache_n_retrievals_object_dead));
57066 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57067 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57068 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57069
57070 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57071 - atomic_read(&fscache_n_stores),
57072 - atomic_read(&fscache_n_stores_ok),
57073 - atomic_read(&fscache_n_stores_again),
57074 - atomic_read(&fscache_n_stores_nobufs),
57075 - atomic_read(&fscache_n_stores_oom));
57076 + atomic_read_unchecked(&fscache_n_stores),
57077 + atomic_read_unchecked(&fscache_n_stores_ok),
57078 + atomic_read_unchecked(&fscache_n_stores_again),
57079 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57080 + atomic_read_unchecked(&fscache_n_stores_oom));
57081 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57082 - atomic_read(&fscache_n_store_ops),
57083 - atomic_read(&fscache_n_store_calls),
57084 - atomic_read(&fscache_n_store_pages),
57085 - atomic_read(&fscache_n_store_radix_deletes),
57086 - atomic_read(&fscache_n_store_pages_over_limit));
57087 + atomic_read_unchecked(&fscache_n_store_ops),
57088 + atomic_read_unchecked(&fscache_n_store_calls),
57089 + atomic_read_unchecked(&fscache_n_store_pages),
57090 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57091 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57092
57093 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57094 - atomic_read(&fscache_n_store_vmscan_not_storing),
57095 - atomic_read(&fscache_n_store_vmscan_gone),
57096 - atomic_read(&fscache_n_store_vmscan_busy),
57097 - atomic_read(&fscache_n_store_vmscan_cancelled),
57098 - atomic_read(&fscache_n_store_vmscan_wait));
57099 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57100 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57101 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57102 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57103 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57104
57105 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57106 - atomic_read(&fscache_n_op_pend),
57107 - atomic_read(&fscache_n_op_run),
57108 - atomic_read(&fscache_n_op_enqueue),
57109 - atomic_read(&fscache_n_op_cancelled),
57110 - atomic_read(&fscache_n_op_rejected));
57111 + atomic_read_unchecked(&fscache_n_op_pend),
57112 + atomic_read_unchecked(&fscache_n_op_run),
57113 + atomic_read_unchecked(&fscache_n_op_enqueue),
57114 + atomic_read_unchecked(&fscache_n_op_cancelled),
57115 + atomic_read_unchecked(&fscache_n_op_rejected));
57116 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57117 - atomic_read(&fscache_n_op_deferred_release),
57118 - atomic_read(&fscache_n_op_release),
57119 - atomic_read(&fscache_n_op_gc));
57120 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57121 + atomic_read_unchecked(&fscache_n_op_release),
57122 + atomic_read_unchecked(&fscache_n_op_gc));
57123
57124 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57125 atomic_read(&fscache_n_cop_alloc_object),
57126 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57127 index aef34b1..59bfd7b 100644
57128 --- a/fs/fuse/cuse.c
57129 +++ b/fs/fuse/cuse.c
57130 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
57131 INIT_LIST_HEAD(&cuse_conntbl[i]);
57132
57133 /* inherit and extend fuse_dev_operations */
57134 - cuse_channel_fops = fuse_dev_operations;
57135 - cuse_channel_fops.owner = THIS_MODULE;
57136 - cuse_channel_fops.open = cuse_channel_open;
57137 - cuse_channel_fops.release = cuse_channel_release;
57138 + pax_open_kernel();
57139 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57140 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57141 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57142 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57143 + pax_close_kernel();
57144
57145 cuse_class = class_create(THIS_MODULE, "cuse");
57146 if (IS_ERR(cuse_class))
57147 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57148 index 1d55f94..088da65 100644
57149 --- a/fs/fuse/dev.c
57150 +++ b/fs/fuse/dev.c
57151 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57152 ret = 0;
57153 pipe_lock(pipe);
57154
57155 - if (!pipe->readers) {
57156 + if (!atomic_read(&pipe->readers)) {
57157 send_sig(SIGPIPE, current, 0);
57158 if (!ret)
57159 ret = -EPIPE;
57160 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57161 page_nr++;
57162 ret += buf->len;
57163
57164 - if (pipe->files)
57165 + if (atomic_read(&pipe->files))
57166 do_wakeup = 1;
57167 }
57168
57169 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57170 index 8fec28f..cd40dba 100644
57171 --- a/fs/fuse/dir.c
57172 +++ b/fs/fuse/dir.c
57173 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
57174 return link;
57175 }
57176
57177 -static void free_link(char *link)
57178 +static void free_link(const char *link)
57179 {
57180 if (!IS_ERR(link))
57181 free_page((unsigned long) link);
57182 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57183 index 64915ee..6bed500 100644
57184 --- a/fs/gfs2/inode.c
57185 +++ b/fs/gfs2/inode.c
57186 @@ -1506,7 +1506,7 @@ out:
57187
57188 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57189 {
57190 - char *s = nd_get_link(nd);
57191 + const char *s = nd_get_link(nd);
57192 if (!IS_ERR(s))
57193 kfree(s);
57194 }
57195 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57196 index d19b30a..ef89c36 100644
57197 --- a/fs/hugetlbfs/inode.c
57198 +++ b/fs/hugetlbfs/inode.c
57199 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57200 struct mm_struct *mm = current->mm;
57201 struct vm_area_struct *vma;
57202 struct hstate *h = hstate_file(file);
57203 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57204 struct vm_unmapped_area_info info;
57205
57206 if (len & ~huge_page_mask(h))
57207 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57208 return addr;
57209 }
57210
57211 +#ifdef CONFIG_PAX_RANDMMAP
57212 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57213 +#endif
57214 +
57215 if (addr) {
57216 addr = ALIGN(addr, huge_page_size(h));
57217 vma = find_vma(mm, addr);
57218 - if (TASK_SIZE - len >= addr &&
57219 - (!vma || addr + len <= vma->vm_start))
57220 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57221 return addr;
57222 }
57223
57224 info.flags = 0;
57225 info.length = len;
57226 info.low_limit = TASK_UNMAPPED_BASE;
57227 +
57228 +#ifdef CONFIG_PAX_RANDMMAP
57229 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57230 + info.low_limit += mm->delta_mmap;
57231 +#endif
57232 +
57233 info.high_limit = TASK_SIZE;
57234 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57235 info.align_offset = 0;
57236 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57237 };
57238 MODULE_ALIAS_FS("hugetlbfs");
57239
57240 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57241 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57242
57243 static int can_do_hugetlb_shm(void)
57244 {
57245 diff --git a/fs/inode.c b/fs/inode.c
57246 index d6dfb09..602e77e 100644
57247 --- a/fs/inode.c
57248 +++ b/fs/inode.c
57249 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
57250
57251 #ifdef CONFIG_SMP
57252 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57253 - static atomic_t shared_last_ino;
57254 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57255 + static atomic_unchecked_t shared_last_ino;
57256 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57257
57258 res = next - LAST_INO_BATCH;
57259 }
57260 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57261 index 4a6cf28..d3a29d3 100644
57262 --- a/fs/jffs2/erase.c
57263 +++ b/fs/jffs2/erase.c
57264 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57265 struct jffs2_unknown_node marker = {
57266 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57267 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57268 - .totlen = cpu_to_je32(c->cleanmarker_size)
57269 + .totlen = cpu_to_je32(c->cleanmarker_size),
57270 + .hdr_crc = cpu_to_je32(0)
57271 };
57272
57273 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57274 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57275 index a6597d6..41b30ec 100644
57276 --- a/fs/jffs2/wbuf.c
57277 +++ b/fs/jffs2/wbuf.c
57278 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57279 {
57280 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57281 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57282 - .totlen = constant_cpu_to_je32(8)
57283 + .totlen = constant_cpu_to_je32(8),
57284 + .hdr_crc = constant_cpu_to_je32(0)
57285 };
57286
57287 /*
57288 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57289 index 6669aa2..36b033d 100644
57290 --- a/fs/jfs/super.c
57291 +++ b/fs/jfs/super.c
57292 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57293
57294 jfs_inode_cachep =
57295 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57296 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57297 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57298 init_once);
57299 if (jfs_inode_cachep == NULL)
57300 return -ENOMEM;
57301 diff --git a/fs/libfs.c b/fs/libfs.c
57302 index 3a3a9b5..3a9b074 100644
57303 --- a/fs/libfs.c
57304 +++ b/fs/libfs.c
57305 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57306
57307 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57308 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57309 + char d_name[sizeof(next->d_iname)];
57310 + const unsigned char *name;
57311 +
57312 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57313 if (!simple_positive(next)) {
57314 spin_unlock(&next->d_lock);
57315 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57316
57317 spin_unlock(&next->d_lock);
57318 spin_unlock(&dentry->d_lock);
57319 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57320 + name = next->d_name.name;
57321 + if (name == next->d_iname) {
57322 + memcpy(d_name, name, next->d_name.len);
57323 + name = d_name;
57324 + }
57325 + if (!dir_emit(ctx, name, next->d_name.len,
57326 next->d_inode->i_ino, dt_type(next->d_inode)))
57327 return 0;
57328 spin_lock(&dentry->d_lock);
57329 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57330 index acd3947..1f896e2 100644
57331 --- a/fs/lockd/clntproc.c
57332 +++ b/fs/lockd/clntproc.c
57333 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57334 /*
57335 * Cookie counter for NLM requests
57336 */
57337 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57338 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57339
57340 void nlmclnt_next_cookie(struct nlm_cookie *c)
57341 {
57342 - u32 cookie = atomic_inc_return(&nlm_cookie);
57343 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57344
57345 memcpy(c->data, &cookie, 4);
57346 c->len=4;
57347 diff --git a/fs/locks.c b/fs/locks.c
57348 index b27a300..4156d0b 100644
57349 --- a/fs/locks.c
57350 +++ b/fs/locks.c
57351 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57352 return;
57353
57354 if (filp->f_op && filp->f_op->flock) {
57355 - struct file_lock fl = {
57356 + struct file_lock flock = {
57357 .fl_pid = current->tgid,
57358 .fl_file = filp,
57359 .fl_flags = FL_FLOCK,
57360 .fl_type = F_UNLCK,
57361 .fl_end = OFFSET_MAX,
57362 };
57363 - filp->f_op->flock(filp, F_SETLKW, &fl);
57364 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57365 - fl.fl_ops->fl_release_private(&fl);
57366 + filp->f_op->flock(filp, F_SETLKW, &flock);
57367 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57368 + flock.fl_ops->fl_release_private(&flock);
57369 }
57370
57371 spin_lock(&inode->i_lock);
57372 diff --git a/fs/namei.c b/fs/namei.c
57373 index 7720fbd..7934bb2 100644
57374 --- a/fs/namei.c
57375 +++ b/fs/namei.c
57376 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57377 if (ret != -EACCES)
57378 return ret;
57379
57380 +#ifdef CONFIG_GRKERNSEC
57381 + /* we'll block if we have to log due to a denied capability use */
57382 + if (mask & MAY_NOT_BLOCK)
57383 + return -ECHILD;
57384 +#endif
57385 +
57386 if (S_ISDIR(inode->i_mode)) {
57387 /* DACs are overridable for directories */
57388 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57389 - return 0;
57390 if (!(mask & MAY_WRITE))
57391 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57392 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57393 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57394 return 0;
57395 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57396 + return 0;
57397 return -EACCES;
57398 }
57399 /*
57400 + * Searching includes executable on directories, else just read.
57401 + */
57402 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57403 + if (mask == MAY_READ)
57404 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57405 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57406 + return 0;
57407 +
57408 + /*
57409 * Read/write DACs are always overridable.
57410 * Executable DACs are overridable when there is
57411 * at least one exec bit set.
57412 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57413 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57414 return 0;
57415
57416 - /*
57417 - * Searching includes executable on directories, else just read.
57418 - */
57419 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57420 - if (mask == MAY_READ)
57421 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57422 - return 0;
57423 -
57424 return -EACCES;
57425 }
57426
57427 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57428 {
57429 struct dentry *dentry = link->dentry;
57430 int error;
57431 - char *s;
57432 + const char *s;
57433
57434 BUG_ON(nd->flags & LOOKUP_RCU);
57435
57436 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57437 if (error)
57438 goto out_put_nd_path;
57439
57440 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57441 + dentry->d_inode, dentry, nd->path.mnt)) {
57442 + error = -EACCES;
57443 + goto out_put_nd_path;
57444 + }
57445 +
57446 nd->last_type = LAST_BIND;
57447 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57448 error = PTR_ERR(*p);
57449 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57450 if (res)
57451 break;
57452 res = walk_component(nd, path, LOOKUP_FOLLOW);
57453 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57454 + res = -EACCES;
57455 put_link(nd, &link, cookie);
57456 } while (res > 0);
57457
57458 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
57459 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57460 {
57461 unsigned long a, b, adata, bdata, mask, hash, len;
57462 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57463 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57464
57465 hash = a = 0;
57466 len = -sizeof(unsigned long);
57467 @@ -1967,6 +1983,8 @@ static int path_lookupat(int dfd, const char *name,
57468 if (err)
57469 break;
57470 err = lookup_last(nd, &path);
57471 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
57472 + err = -EACCES;
57473 put_link(nd, &link, cookie);
57474 }
57475 }
57476 @@ -1974,6 +1992,13 @@ static int path_lookupat(int dfd, const char *name,
57477 if (!err)
57478 err = complete_walk(nd);
57479
57480 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
57481 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57482 + path_put(&nd->path);
57483 + err = -ENOENT;
57484 + }
57485 + }
57486 +
57487 if (!err && nd->flags & LOOKUP_DIRECTORY) {
57488 if (!can_lookup(nd->inode)) {
57489 path_put(&nd->path);
57490 @@ -2001,8 +2026,15 @@ static int filename_lookup(int dfd, struct filename *name,
57491 retval = path_lookupat(dfd, name->name,
57492 flags | LOOKUP_REVAL, nd);
57493
57494 - if (likely(!retval))
57495 + if (likely(!retval)) {
57496 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
57497 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
57498 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
57499 + path_put(&nd->path);
57500 + return -ENOENT;
57501 + }
57502 + }
57503 + }
57504 return retval;
57505 }
57506
57507 @@ -2380,6 +2412,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
57508 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
57509 return -EPERM;
57510
57511 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
57512 + return -EPERM;
57513 + if (gr_handle_rawio(inode))
57514 + return -EPERM;
57515 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
57516 + return -EACCES;
57517 +
57518 return 0;
57519 }
57520
57521 @@ -2601,7 +2640,7 @@ looked_up:
57522 * cleared otherwise prior to returning.
57523 */
57524 static int lookup_open(struct nameidata *nd, struct path *path,
57525 - struct file *file,
57526 + struct path *link, struct file *file,
57527 const struct open_flags *op,
57528 bool got_write, int *opened)
57529 {
57530 @@ -2636,6 +2675,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57531 /* Negative dentry, just create the file */
57532 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
57533 umode_t mode = op->mode;
57534 +
57535 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
57536 + error = -EACCES;
57537 + goto out_dput;
57538 + }
57539 +
57540 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
57541 + error = -EACCES;
57542 + goto out_dput;
57543 + }
57544 +
57545 if (!IS_POSIXACL(dir->d_inode))
57546 mode &= ~current_umask();
57547 /*
57548 @@ -2657,6 +2707,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57549 nd->flags & LOOKUP_EXCL);
57550 if (error)
57551 goto out_dput;
57552 + else
57553 + gr_handle_create(dentry, nd->path.mnt);
57554 }
57555 out_no_open:
57556 path->dentry = dentry;
57557 @@ -2671,7 +2723,7 @@ out_dput:
57558 /*
57559 * Handle the last step of open()
57560 */
57561 -static int do_last(struct nameidata *nd, struct path *path,
57562 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
57563 struct file *file, const struct open_flags *op,
57564 int *opened, struct filename *name)
57565 {
57566 @@ -2721,6 +2773,15 @@ static int do_last(struct nameidata *nd, struct path *path,
57567 if (error)
57568 return error;
57569
57570 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
57571 + error = -ENOENT;
57572 + goto out;
57573 + }
57574 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57575 + error = -EACCES;
57576 + goto out;
57577 + }
57578 +
57579 audit_inode(name, dir, LOOKUP_PARENT);
57580 error = -EISDIR;
57581 /* trailing slashes? */
57582 @@ -2740,7 +2801,7 @@ retry_lookup:
57583 */
57584 }
57585 mutex_lock(&dir->d_inode->i_mutex);
57586 - error = lookup_open(nd, path, file, op, got_write, opened);
57587 + error = lookup_open(nd, path, link, file, op, got_write, opened);
57588 mutex_unlock(&dir->d_inode->i_mutex);
57589
57590 if (error <= 0) {
57591 @@ -2764,11 +2825,28 @@ retry_lookup:
57592 goto finish_open_created;
57593 }
57594
57595 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
57596 + error = -ENOENT;
57597 + goto exit_dput;
57598 + }
57599 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
57600 + error = -EACCES;
57601 + goto exit_dput;
57602 + }
57603 +
57604 /*
57605 * create/update audit record if it already exists.
57606 */
57607 - if (path->dentry->d_inode)
57608 + if (path->dentry->d_inode) {
57609 + /* only check if O_CREAT is specified, all other checks need to go
57610 + into may_open */
57611 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
57612 + error = -EACCES;
57613 + goto exit_dput;
57614 + }
57615 +
57616 audit_inode(name, path->dentry, 0);
57617 + }
57618
57619 /*
57620 * If atomic_open() acquired write access it is dropped now due to
57621 @@ -2809,6 +2887,11 @@ finish_lookup:
57622 }
57623 }
57624 BUG_ON(inode != path->dentry->d_inode);
57625 + /* if we're resolving a symlink to another symlink */
57626 + if (link && gr_handle_symlink_owner(link, inode)) {
57627 + error = -EACCES;
57628 + goto out;
57629 + }
57630 return 1;
57631 }
57632
57633 @@ -2818,7 +2901,6 @@ finish_lookup:
57634 save_parent.dentry = nd->path.dentry;
57635 save_parent.mnt = mntget(path->mnt);
57636 nd->path.dentry = path->dentry;
57637 -
57638 }
57639 nd->inode = inode;
57640 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
57641 @@ -2828,7 +2910,18 @@ finish_open:
57642 path_put(&save_parent);
57643 return error;
57644 }
57645 +
57646 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57647 + error = -ENOENT;
57648 + goto out;
57649 + }
57650 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57651 + error = -EACCES;
57652 + goto out;
57653 + }
57654 +
57655 audit_inode(name, nd->path.dentry, 0);
57656 +
57657 error = -EISDIR;
57658 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
57659 goto out;
57660 @@ -2991,7 +3084,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57661 if (unlikely(error))
57662 goto out;
57663
57664 - error = do_last(nd, &path, file, op, &opened, pathname);
57665 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
57666 while (unlikely(error > 0)) { /* trailing symlink */
57667 struct path link = path;
57668 void *cookie;
57669 @@ -3009,7 +3102,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57670 error = follow_link(&link, nd, &cookie);
57671 if (unlikely(error))
57672 break;
57673 - error = do_last(nd, &path, file, op, &opened, pathname);
57674 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
57675 put_link(nd, &link, cookie);
57676 }
57677 out:
57678 @@ -3109,8 +3202,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
57679 goto unlock;
57680
57681 error = -EEXIST;
57682 - if (dentry->d_inode)
57683 + if (dentry->d_inode) {
57684 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
57685 + error = -ENOENT;
57686 + }
57687 goto fail;
57688 + }
57689 /*
57690 * Special case - lookup gave negative, but... we had foo/bar/
57691 * From the vfs_mknod() POV we just have a negative dentry -
57692 @@ -3162,6 +3259,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
57693 }
57694 EXPORT_SYMBOL(user_path_create);
57695
57696 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
57697 +{
57698 + struct filename *tmp = getname(pathname);
57699 + struct dentry *res;
57700 + if (IS_ERR(tmp))
57701 + return ERR_CAST(tmp);
57702 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
57703 + if (IS_ERR(res))
57704 + putname(tmp);
57705 + else
57706 + *to = tmp;
57707 + return res;
57708 +}
57709 +
57710 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
57711 {
57712 int error = may_create(dir, dentry);
57713 @@ -3224,6 +3335,17 @@ retry:
57714
57715 if (!IS_POSIXACL(path.dentry->d_inode))
57716 mode &= ~current_umask();
57717 +
57718 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
57719 + error = -EPERM;
57720 + goto out;
57721 + }
57722 +
57723 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
57724 + error = -EACCES;
57725 + goto out;
57726 + }
57727 +
57728 error = security_path_mknod(&path, dentry, mode, dev);
57729 if (error)
57730 goto out;
57731 @@ -3240,6 +3362,8 @@ retry:
57732 break;
57733 }
57734 out:
57735 + if (!error)
57736 + gr_handle_create(dentry, path.mnt);
57737 done_path_create(&path, dentry);
57738 if (retry_estale(error, lookup_flags)) {
57739 lookup_flags |= LOOKUP_REVAL;
57740 @@ -3292,9 +3416,16 @@ retry:
57741
57742 if (!IS_POSIXACL(path.dentry->d_inode))
57743 mode &= ~current_umask();
57744 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
57745 + error = -EACCES;
57746 + goto out;
57747 + }
57748 error = security_path_mkdir(&path, dentry, mode);
57749 if (!error)
57750 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
57751 + if (!error)
57752 + gr_handle_create(dentry, path.mnt);
57753 +out:
57754 done_path_create(&path, dentry);
57755 if (retry_estale(error, lookup_flags)) {
57756 lookup_flags |= LOOKUP_REVAL;
57757 @@ -3375,6 +3506,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
57758 struct filename *name;
57759 struct dentry *dentry;
57760 struct nameidata nd;
57761 + ino_t saved_ino = 0;
57762 + dev_t saved_dev = 0;
57763 unsigned int lookup_flags = 0;
57764 retry:
57765 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57766 @@ -3407,10 +3540,21 @@ retry:
57767 error = -ENOENT;
57768 goto exit3;
57769 }
57770 +
57771 + saved_ino = dentry->d_inode->i_ino;
57772 + saved_dev = gr_get_dev_from_dentry(dentry);
57773 +
57774 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
57775 + error = -EACCES;
57776 + goto exit3;
57777 + }
57778 +
57779 error = security_path_rmdir(&nd.path, dentry);
57780 if (error)
57781 goto exit3;
57782 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
57783 + if (!error && (saved_dev || saved_ino))
57784 + gr_handle_delete(saved_ino, saved_dev);
57785 exit3:
57786 dput(dentry);
57787 exit2:
57788 @@ -3476,6 +3620,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
57789 struct dentry *dentry;
57790 struct nameidata nd;
57791 struct inode *inode = NULL;
57792 + ino_t saved_ino = 0;
57793 + dev_t saved_dev = 0;
57794 unsigned int lookup_flags = 0;
57795 retry:
57796 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57797 @@ -3502,10 +3648,22 @@ retry:
57798 if (!inode)
57799 goto slashes;
57800 ihold(inode);
57801 +
57802 + if (inode->i_nlink <= 1) {
57803 + saved_ino = inode->i_ino;
57804 + saved_dev = gr_get_dev_from_dentry(dentry);
57805 + }
57806 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
57807 + error = -EACCES;
57808 + goto exit2;
57809 + }
57810 +
57811 error = security_path_unlink(&nd.path, dentry);
57812 if (error)
57813 goto exit2;
57814 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
57815 + if (!error && (saved_ino || saved_dev))
57816 + gr_handle_delete(saved_ino, saved_dev);
57817 exit2:
57818 dput(dentry);
57819 }
57820 @@ -3583,9 +3741,17 @@ retry:
57821 if (IS_ERR(dentry))
57822 goto out_putname;
57823
57824 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
57825 + error = -EACCES;
57826 + goto out;
57827 + }
57828 +
57829 error = security_path_symlink(&path, dentry, from->name);
57830 if (!error)
57831 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
57832 + if (!error)
57833 + gr_handle_create(dentry, path.mnt);
57834 +out:
57835 done_path_create(&path, dentry);
57836 if (retry_estale(error, lookup_flags)) {
57837 lookup_flags |= LOOKUP_REVAL;
57838 @@ -3665,6 +3831,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
57839 {
57840 struct dentry *new_dentry;
57841 struct path old_path, new_path;
57842 + struct filename *to = NULL;
57843 int how = 0;
57844 int error;
57845
57846 @@ -3688,7 +3855,7 @@ retry:
57847 if (error)
57848 return error;
57849
57850 - new_dentry = user_path_create(newdfd, newname, &new_path,
57851 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
57852 (how & LOOKUP_REVAL));
57853 error = PTR_ERR(new_dentry);
57854 if (IS_ERR(new_dentry))
57855 @@ -3700,11 +3867,28 @@ retry:
57856 error = may_linkat(&old_path);
57857 if (unlikely(error))
57858 goto out_dput;
57859 +
57860 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
57861 + old_path.dentry->d_inode,
57862 + old_path.dentry->d_inode->i_mode, to)) {
57863 + error = -EACCES;
57864 + goto out_dput;
57865 + }
57866 +
57867 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
57868 + old_path.dentry, old_path.mnt, to)) {
57869 + error = -EACCES;
57870 + goto out_dput;
57871 + }
57872 +
57873 error = security_path_link(old_path.dentry, &new_path, new_dentry);
57874 if (error)
57875 goto out_dput;
57876 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
57877 + if (!error)
57878 + gr_handle_create(new_dentry, new_path.mnt);
57879 out_dput:
57880 + putname(to);
57881 done_path_create(&new_path, new_dentry);
57882 if (retry_estale(error, how)) {
57883 how |= LOOKUP_REVAL;
57884 @@ -3950,12 +4134,21 @@ retry:
57885 if (new_dentry == trap)
57886 goto exit5;
57887
57888 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
57889 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
57890 + to);
57891 + if (error)
57892 + goto exit5;
57893 +
57894 error = security_path_rename(&oldnd.path, old_dentry,
57895 &newnd.path, new_dentry);
57896 if (error)
57897 goto exit5;
57898 error = vfs_rename(old_dir->d_inode, old_dentry,
57899 new_dir->d_inode, new_dentry);
57900 + if (!error)
57901 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
57902 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
57903 exit5:
57904 dput(new_dentry);
57905 exit4:
57906 @@ -3987,6 +4180,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
57907
57908 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
57909 {
57910 + char tmpbuf[64];
57911 + const char *newlink;
57912 int len;
57913
57914 len = PTR_ERR(link);
57915 @@ -3996,7 +4191,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
57916 len = strlen(link);
57917 if (len > (unsigned) buflen)
57918 len = buflen;
57919 - if (copy_to_user(buffer, link, len))
57920 +
57921 + if (len < sizeof(tmpbuf)) {
57922 + memcpy(tmpbuf, link, len);
57923 + newlink = tmpbuf;
57924 + } else
57925 + newlink = link;
57926 +
57927 + if (copy_to_user(buffer, newlink, len))
57928 len = -EFAULT;
57929 out:
57930 return len;
57931 diff --git a/fs/namespace.c b/fs/namespace.c
57932 index a45ba4f..b4c7d07 100644
57933 --- a/fs/namespace.c
57934 +++ b/fs/namespace.c
57935 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
57936 if (!(sb->s_flags & MS_RDONLY))
57937 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
57938 up_write(&sb->s_umount);
57939 +
57940 + gr_log_remount(mnt->mnt_devname, retval);
57941 +
57942 return retval;
57943 }
57944
57945 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
57946 }
57947 br_write_unlock(&vfsmount_lock);
57948 namespace_unlock();
57949 +
57950 + gr_log_unmount(mnt->mnt_devname, retval);
57951 +
57952 return retval;
57953 }
57954
57955 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
57956 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
57957 */
57958
57959 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
57960 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
57961 {
57962 struct path path;
57963 struct mount *mnt;
57964 @@ -1342,7 +1348,7 @@ out:
57965 /*
57966 * The 2.0 compatible umount. No flags.
57967 */
57968 -SYSCALL_DEFINE1(oldumount, char __user *, name)
57969 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
57970 {
57971 return sys_umount(name, 0);
57972 }
57973 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
57974 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
57975 MS_STRICTATIME);
57976
57977 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
57978 + retval = -EPERM;
57979 + goto dput_out;
57980 + }
57981 +
57982 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
57983 + retval = -EPERM;
57984 + goto dput_out;
57985 + }
57986 +
57987 if (flags & MS_REMOUNT)
57988 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
57989 data_page);
57990 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
57991 dev_name, data_page);
57992 dput_out:
57993 path_put(&path);
57994 +
57995 + gr_log_mount(dev_name, dir_name, retval);
57996 +
57997 return retval;
57998 }
57999
58000 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
58001 * number incrementing at 10Ghz will take 12,427 years to wrap which
58002 * is effectively never, so we can ignore the possibility.
58003 */
58004 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
58005 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
58006
58007 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58008 {
58009 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58010 kfree(new_ns);
58011 return ERR_PTR(ret);
58012 }
58013 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58014 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58015 atomic_set(&new_ns->count, 1);
58016 new_ns->root = NULL;
58017 INIT_LIST_HEAD(&new_ns->list);
58018 @@ -2373,7 +2392,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58019 * Allocate a new namespace structure and populate it with contents
58020 * copied from the namespace of the passed in task structure.
58021 */
58022 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58023 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58024 struct user_namespace *user_ns, struct fs_struct *fs)
58025 {
58026 struct mnt_namespace *new_ns;
58027 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58028 }
58029 EXPORT_SYMBOL(mount_subtree);
58030
58031 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58032 - char __user *, type, unsigned long, flags, void __user *, data)
58033 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58034 + const char __user *, type, unsigned long, flags, void __user *, data)
58035 {
58036 int ret;
58037 char *kernel_type;
58038 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58039 if (error)
58040 goto out2;
58041
58042 + if (gr_handle_chroot_pivot()) {
58043 + error = -EPERM;
58044 + goto out2;
58045 + }
58046 +
58047 get_fs_root(current->fs, &root);
58048 old_mp = lock_mount(&old);
58049 error = PTR_ERR(old_mp);
58050 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58051 !nsown_capable(CAP_SYS_ADMIN))
58052 return -EPERM;
58053
58054 - if (fs->users != 1)
58055 + if (atomic_read(&fs->users) != 1)
58056 return -EINVAL;
58057
58058 get_mnt_ns(mnt_ns);
58059 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58060 index f4ccfe6..a5cf064 100644
58061 --- a/fs/nfs/callback_xdr.c
58062 +++ b/fs/nfs/callback_xdr.c
58063 @@ -51,7 +51,7 @@ struct callback_op {
58064 callback_decode_arg_t decode_args;
58065 callback_encode_res_t encode_res;
58066 long res_maxsize;
58067 -};
58068 +} __do_const;
58069
58070 static struct callback_op callback_ops[];
58071
58072 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58073 index 941246f..17d8724 100644
58074 --- a/fs/nfs/inode.c
58075 +++ b/fs/nfs/inode.c
58076 @@ -1138,16 +1138,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58077 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58078 }
58079
58080 -static atomic_long_t nfs_attr_generation_counter;
58081 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58082
58083 static unsigned long nfs_read_attr_generation_counter(void)
58084 {
58085 - return atomic_long_read(&nfs_attr_generation_counter);
58086 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58087 }
58088
58089 unsigned long nfs_inc_attr_generation_counter(void)
58090 {
58091 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58092 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58093 }
58094
58095 void nfs_fattr_init(struct nfs_fattr *fattr)
58096 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
58097 index e22862f..92d66eb 100644
58098 --- a/fs/nfs/nfs4state.c
58099 +++ b/fs/nfs/nfs4state.c
58100 @@ -154,6 +154,19 @@ struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp)
58101 return cred;
58102 }
58103
58104 +static void nfs4_root_machine_cred(struct nfs_client *clp)
58105 +{
58106 + struct rpc_cred *cred, *new;
58107 +
58108 + new = rpc_lookup_machine_cred(NULL);
58109 + spin_lock(&clp->cl_lock);
58110 + cred = clp->cl_machine_cred;
58111 + clp->cl_machine_cred = new;
58112 + spin_unlock(&clp->cl_lock);
58113 + if (cred != NULL)
58114 + put_rpccred(cred);
58115 +}
58116 +
58117 static struct rpc_cred *
58118 nfs4_get_renew_cred_server_locked(struct nfs_server *server)
58119 {
58120 @@ -1896,10 +1909,19 @@ again:
58121 __func__, status);
58122 goto again;
58123 case -EACCES:
58124 - if (i++)
58125 + if (i++ == 0) {
58126 + nfs4_root_machine_cred(clp);
58127 + goto again;
58128 + }
58129 + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX)
58130 break;
58131 case -NFS4ERR_CLID_INUSE:
58132 case -NFS4ERR_WRONGSEC:
58133 + /* No point in retrying if we already used RPC_AUTH_UNIX */
58134 + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX) {
58135 + status = -EPERM;
58136 + break;
58137 + }
58138 clnt = rpc_clone_client_set_auth(clnt, RPC_AUTH_UNIX);
58139 if (IS_ERR(clnt)) {
58140 status = PTR_ERR(clnt);
58141 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58142 index 419572f..5414a23 100644
58143 --- a/fs/nfsd/nfs4proc.c
58144 +++ b/fs/nfsd/nfs4proc.c
58145 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58146 nfsd4op_rsize op_rsize_bop;
58147 stateid_getter op_get_currentstateid;
58148 stateid_setter op_set_currentstateid;
58149 -};
58150 +} __do_const;
58151
58152 static struct nfsd4_operation nfsd4_ops[];
58153
58154 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58155 index c2a4701..fd80e29 100644
58156 --- a/fs/nfsd/nfs4xdr.c
58157 +++ b/fs/nfsd/nfs4xdr.c
58158 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58159
58160 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58161
58162 -static nfsd4_dec nfsd4_dec_ops[] = {
58163 +static const nfsd4_dec nfsd4_dec_ops[] = {
58164 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58165 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58166 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58167 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58168 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58169 };
58170
58171 -static nfsd4_dec nfsd41_dec_ops[] = {
58172 +static const nfsd4_dec nfsd41_dec_ops[] = {
58173 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58174 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58175 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58176 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58177 };
58178
58179 struct nfsd4_minorversion_ops {
58180 - nfsd4_dec *decoders;
58181 + const nfsd4_dec *decoders;
58182 int nops;
58183 };
58184
58185 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58186 index e76244e..9fe8f2f1 100644
58187 --- a/fs/nfsd/nfscache.c
58188 +++ b/fs/nfsd/nfscache.c
58189 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58190 {
58191 struct svc_cacherep *rp = rqstp->rq_cacherep;
58192 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58193 - int len;
58194 + long len;
58195 size_t bufsize = 0;
58196
58197 if (!rp)
58198 return;
58199
58200 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58201 - len >>= 2;
58202 + if (statp) {
58203 + len = (char*)statp - (char*)resv->iov_base;
58204 + len = resv->iov_len - len;
58205 + len >>= 2;
58206 + }
58207
58208 /* Don't cache excessive amounts of data and XDR failures */
58209 if (!statp || len > (256 >> 2)) {
58210 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58211 index c827acb..b253b77 100644
58212 --- a/fs/nfsd/vfs.c
58213 +++ b/fs/nfsd/vfs.c
58214 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58215 } else {
58216 oldfs = get_fs();
58217 set_fs(KERNEL_DS);
58218 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58219 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58220 set_fs(oldfs);
58221 }
58222
58223 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58224
58225 /* Write the data. */
58226 oldfs = get_fs(); set_fs(KERNEL_DS);
58227 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58228 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58229 set_fs(oldfs);
58230 if (host_err < 0)
58231 goto out_nfserr;
58232 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58233 */
58234
58235 oldfs = get_fs(); set_fs(KERNEL_DS);
58236 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58237 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58238 set_fs(oldfs);
58239
58240 if (host_err < 0)
58241 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58242 index fea6bd5..8ee9d81 100644
58243 --- a/fs/nls/nls_base.c
58244 +++ b/fs/nls/nls_base.c
58245 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58246
58247 int register_nls(struct nls_table * nls)
58248 {
58249 - struct nls_table ** tmp = &tables;
58250 + struct nls_table *tmp = tables;
58251
58252 if (nls->next)
58253 return -EBUSY;
58254
58255 spin_lock(&nls_lock);
58256 - while (*tmp) {
58257 - if (nls == *tmp) {
58258 + while (tmp) {
58259 + if (nls == tmp) {
58260 spin_unlock(&nls_lock);
58261 return -EBUSY;
58262 }
58263 - tmp = &(*tmp)->next;
58264 + tmp = tmp->next;
58265 }
58266 - nls->next = tables;
58267 + pax_open_kernel();
58268 + *(struct nls_table **)&nls->next = tables;
58269 + pax_close_kernel();
58270 tables = nls;
58271 spin_unlock(&nls_lock);
58272 return 0;
58273 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58274
58275 int unregister_nls(struct nls_table * nls)
58276 {
58277 - struct nls_table ** tmp = &tables;
58278 + struct nls_table * const * tmp = &tables;
58279
58280 spin_lock(&nls_lock);
58281 while (*tmp) {
58282 if (nls == *tmp) {
58283 - *tmp = nls->next;
58284 + pax_open_kernel();
58285 + *(struct nls_table **)tmp = nls->next;
58286 + pax_close_kernel();
58287 spin_unlock(&nls_lock);
58288 return 0;
58289 }
58290 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58291 index 7424929..35f6be5 100644
58292 --- a/fs/nls/nls_euc-jp.c
58293 +++ b/fs/nls/nls_euc-jp.c
58294 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58295 p_nls = load_nls("cp932");
58296
58297 if (p_nls) {
58298 - table.charset2upper = p_nls->charset2upper;
58299 - table.charset2lower = p_nls->charset2lower;
58300 + pax_open_kernel();
58301 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58302 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58303 + pax_close_kernel();
58304 return register_nls(&table);
58305 }
58306
58307 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58308 index e7bc1d7..06bd4bb 100644
58309 --- a/fs/nls/nls_koi8-ru.c
58310 +++ b/fs/nls/nls_koi8-ru.c
58311 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58312 p_nls = load_nls("koi8-u");
58313
58314 if (p_nls) {
58315 - table.charset2upper = p_nls->charset2upper;
58316 - table.charset2lower = p_nls->charset2lower;
58317 + pax_open_kernel();
58318 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58319 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58320 + pax_close_kernel();
58321 return register_nls(&table);
58322 }
58323
58324 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58325 index e44cb64..4807084 100644
58326 --- a/fs/notify/fanotify/fanotify_user.c
58327 +++ b/fs/notify/fanotify/fanotify_user.c
58328 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58329
58330 fd = fanotify_event_metadata.fd;
58331 ret = -EFAULT;
58332 - if (copy_to_user(buf, &fanotify_event_metadata,
58333 - fanotify_event_metadata.event_len))
58334 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58335 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58336 goto out_close_fd;
58337
58338 ret = prepare_for_access_response(group, event, fd);
58339 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58340 index 7b51b05..5ea5ef6 100644
58341 --- a/fs/notify/notification.c
58342 +++ b/fs/notify/notification.c
58343 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58344 * get set to 0 so it will never get 'freed'
58345 */
58346 static struct fsnotify_event *q_overflow_event;
58347 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58348 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58349
58350 /**
58351 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58352 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58353 */
58354 u32 fsnotify_get_cookie(void)
58355 {
58356 - return atomic_inc_return(&fsnotify_sync_cookie);
58357 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58358 }
58359 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58360
58361 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58362 index 9e38daf..5727cae 100644
58363 --- a/fs/ntfs/dir.c
58364 +++ b/fs/ntfs/dir.c
58365 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58366 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58367 ~(s64)(ndir->itype.index.block_size - 1)));
58368 /* Bounds checks. */
58369 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58370 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58371 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58372 "inode 0x%lx or driver bug.", vdir->i_ino);
58373 goto err_out;
58374 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58375 index c5670b8..d590213 100644
58376 --- a/fs/ntfs/file.c
58377 +++ b/fs/ntfs/file.c
58378 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58379 char *addr;
58380 size_t total = 0;
58381 unsigned len;
58382 - int left;
58383 + unsigned left;
58384
58385 do {
58386 len = PAGE_CACHE_SIZE - ofs;
58387 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58388 index 82650d5..db37dcf 100644
58389 --- a/fs/ntfs/super.c
58390 +++ b/fs/ntfs/super.c
58391 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58392 if (!silent)
58393 ntfs_error(sb, "Primary boot sector is invalid.");
58394 } else if (!silent)
58395 - ntfs_error(sb, read_err_str, "primary");
58396 + ntfs_error(sb, read_err_str, "%s", "primary");
58397 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58398 if (bh_primary)
58399 brelse(bh_primary);
58400 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58401 goto hotfix_primary_boot_sector;
58402 brelse(bh_backup);
58403 } else if (!silent)
58404 - ntfs_error(sb, read_err_str, "backup");
58405 + ntfs_error(sb, read_err_str, "%s", "backup");
58406 /* Try to read NT3.51- backup boot sector. */
58407 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58408 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58409 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58410 "sector.");
58411 brelse(bh_backup);
58412 } else if (!silent)
58413 - ntfs_error(sb, read_err_str, "backup");
58414 + ntfs_error(sb, read_err_str, "%s", "backup");
58415 /* We failed. Cleanup and return. */
58416 if (bh_primary)
58417 brelse(bh_primary);
58418 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58419 index aebeacd..0dcdd26 100644
58420 --- a/fs/ocfs2/localalloc.c
58421 +++ b/fs/ocfs2/localalloc.c
58422 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58423 goto bail;
58424 }
58425
58426 - atomic_inc(&osb->alloc_stats.moves);
58427 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58428
58429 bail:
58430 if (handle)
58431 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58432 index 3a90347..c40bef8 100644
58433 --- a/fs/ocfs2/ocfs2.h
58434 +++ b/fs/ocfs2/ocfs2.h
58435 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58436
58437 struct ocfs2_alloc_stats
58438 {
58439 - atomic_t moves;
58440 - atomic_t local_data;
58441 - atomic_t bitmap_data;
58442 - atomic_t bg_allocs;
58443 - atomic_t bg_extends;
58444 + atomic_unchecked_t moves;
58445 + atomic_unchecked_t local_data;
58446 + atomic_unchecked_t bitmap_data;
58447 + atomic_unchecked_t bg_allocs;
58448 + atomic_unchecked_t bg_extends;
58449 };
58450
58451 enum ocfs2_local_alloc_state
58452 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58453 index 5397c07..54afc55 100644
58454 --- a/fs/ocfs2/suballoc.c
58455 +++ b/fs/ocfs2/suballoc.c
58456 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58457 mlog_errno(status);
58458 goto bail;
58459 }
58460 - atomic_inc(&osb->alloc_stats.bg_extends);
58461 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58462
58463 /* You should never ask for this much metadata */
58464 BUG_ON(bits_wanted >
58465 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58466 mlog_errno(status);
58467 goto bail;
58468 }
58469 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58470 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58471
58472 *suballoc_loc = res.sr_bg_blkno;
58473 *suballoc_bit_start = res.sr_bit_offset;
58474 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58475 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58476 res->sr_bits);
58477
58478 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58479 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58480
58481 BUG_ON(res->sr_bits != 1);
58482
58483 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58484 mlog_errno(status);
58485 goto bail;
58486 }
58487 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58488 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58489
58490 BUG_ON(res.sr_bits != 1);
58491
58492 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58493 cluster_start,
58494 num_clusters);
58495 if (!status)
58496 - atomic_inc(&osb->alloc_stats.local_data);
58497 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
58498 } else {
58499 if (min_clusters > (osb->bitmap_cpg - 1)) {
58500 /* The only paths asking for contiguousness
58501 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58502 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
58503 res.sr_bg_blkno,
58504 res.sr_bit_offset);
58505 - atomic_inc(&osb->alloc_stats.bitmap_data);
58506 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
58507 *num_clusters = res.sr_bits;
58508 }
58509 }
58510 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
58511 index 121da2d..a0232bc 100644
58512 --- a/fs/ocfs2/super.c
58513 +++ b/fs/ocfs2/super.c
58514 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
58515 "%10s => GlobalAllocs: %d LocalAllocs: %d "
58516 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
58517 "Stats",
58518 - atomic_read(&osb->alloc_stats.bitmap_data),
58519 - atomic_read(&osb->alloc_stats.local_data),
58520 - atomic_read(&osb->alloc_stats.bg_allocs),
58521 - atomic_read(&osb->alloc_stats.moves),
58522 - atomic_read(&osb->alloc_stats.bg_extends));
58523 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
58524 + atomic_read_unchecked(&osb->alloc_stats.local_data),
58525 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
58526 + atomic_read_unchecked(&osb->alloc_stats.moves),
58527 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
58528
58529 out += snprintf(buf + out, len - out,
58530 "%10s => State: %u Descriptor: %llu Size: %u bits "
58531 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
58532 spin_lock_init(&osb->osb_xattr_lock);
58533 ocfs2_init_steal_slots(osb);
58534
58535 - atomic_set(&osb->alloc_stats.moves, 0);
58536 - atomic_set(&osb->alloc_stats.local_data, 0);
58537 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
58538 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
58539 - atomic_set(&osb->alloc_stats.bg_extends, 0);
58540 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
58541 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
58542 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
58543 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
58544 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
58545
58546 /* Copy the blockcheck stats from the superblock probe */
58547 osb->osb_ecc_stats = *stats;
58548 diff --git a/fs/open.c b/fs/open.c
58549 index 7931f76..7b03f3b 100644
58550 --- a/fs/open.c
58551 +++ b/fs/open.c
58552 @@ -32,6 +32,8 @@
58553 #include <linux/dnotify.h>
58554 #include <linux/compat.h>
58555
58556 +#define CREATE_TRACE_POINTS
58557 +#include <trace/events/fs.h>
58558 #include "internal.h"
58559
58560 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
58561 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
58562 error = locks_verify_truncate(inode, NULL, length);
58563 if (!error)
58564 error = security_path_truncate(path);
58565 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
58566 + error = -EACCES;
58567 if (!error)
58568 error = do_truncate(path->dentry, length, 0, NULL);
58569
58570 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
58571 error = locks_verify_truncate(inode, f.file, length);
58572 if (!error)
58573 error = security_path_truncate(&f.file->f_path);
58574 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
58575 + error = -EACCES;
58576 if (!error)
58577 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
58578 sb_end_write(inode->i_sb);
58579 @@ -360,6 +366,9 @@ retry:
58580 if (__mnt_is_readonly(path.mnt))
58581 res = -EROFS;
58582
58583 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
58584 + res = -EACCES;
58585 +
58586 out_path_release:
58587 path_put(&path);
58588 if (retry_estale(res, lookup_flags)) {
58589 @@ -391,6 +400,8 @@ retry:
58590 if (error)
58591 goto dput_and_out;
58592
58593 + gr_log_chdir(path.dentry, path.mnt);
58594 +
58595 set_fs_pwd(current->fs, &path);
58596
58597 dput_and_out:
58598 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
58599 goto out_putf;
58600
58601 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
58602 +
58603 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
58604 + error = -EPERM;
58605 +
58606 + if (!error)
58607 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
58608 +
58609 if (!error)
58610 set_fs_pwd(current->fs, &f.file->f_path);
58611 out_putf:
58612 @@ -449,7 +467,13 @@ retry:
58613 if (error)
58614 goto dput_and_out;
58615
58616 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
58617 + goto dput_and_out;
58618 +
58619 set_fs_root(current->fs, &path);
58620 +
58621 + gr_handle_chroot_chdir(&path);
58622 +
58623 error = 0;
58624 dput_and_out:
58625 path_put(&path);
58626 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
58627 if (error)
58628 return error;
58629 mutex_lock(&inode->i_mutex);
58630 +
58631 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
58632 + error = -EACCES;
58633 + goto out_unlock;
58634 + }
58635 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
58636 + error = -EACCES;
58637 + goto out_unlock;
58638 + }
58639 +
58640 error = security_path_chmod(path, mode);
58641 if (error)
58642 goto out_unlock;
58643 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
58644 uid = make_kuid(current_user_ns(), user);
58645 gid = make_kgid(current_user_ns(), group);
58646
58647 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
58648 + return -EACCES;
58649 +
58650 newattrs.ia_valid = ATTR_CTIME;
58651 if (user != (uid_t) -1) {
58652 if (!uid_valid(uid))
58653 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
58654 } else {
58655 fsnotify_open(f);
58656 fd_install(fd, f);
58657 + trace_do_sys_open(tmp->name, flags, mode);
58658 }
58659 }
58660 putname(tmp);
58661 diff --git a/fs/pipe.c b/fs/pipe.c
58662 index d2c45e1..009fe1c 100644
58663 --- a/fs/pipe.c
58664 +++ b/fs/pipe.c
58665 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
58666
58667 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
58668 {
58669 - if (pipe->files)
58670 + if (atomic_read(&pipe->files))
58671 mutex_lock_nested(&pipe->mutex, subclass);
58672 }
58673
58674 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
58675
58676 void pipe_unlock(struct pipe_inode_info *pipe)
58677 {
58678 - if (pipe->files)
58679 + if (atomic_read(&pipe->files))
58680 mutex_unlock(&pipe->mutex);
58681 }
58682 EXPORT_SYMBOL(pipe_unlock);
58683 @@ -449,9 +449,9 @@ redo:
58684 }
58685 if (bufs) /* More to do? */
58686 continue;
58687 - if (!pipe->writers)
58688 + if (!atomic_read(&pipe->writers))
58689 break;
58690 - if (!pipe->waiting_writers) {
58691 + if (!atomic_read(&pipe->waiting_writers)) {
58692 /* syscall merging: Usually we must not sleep
58693 * if O_NONBLOCK is set, or if we got some data.
58694 * But if a writer sleeps in kernel space, then
58695 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
58696 ret = 0;
58697 __pipe_lock(pipe);
58698
58699 - if (!pipe->readers) {
58700 + if (!atomic_read(&pipe->readers)) {
58701 send_sig(SIGPIPE, current, 0);
58702 ret = -EPIPE;
58703 goto out;
58704 @@ -562,7 +562,7 @@ redo1:
58705 for (;;) {
58706 int bufs;
58707
58708 - if (!pipe->readers) {
58709 + if (!atomic_read(&pipe->readers)) {
58710 send_sig(SIGPIPE, current, 0);
58711 if (!ret)
58712 ret = -EPIPE;
58713 @@ -653,9 +653,9 @@ redo2:
58714 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58715 do_wakeup = 0;
58716 }
58717 - pipe->waiting_writers++;
58718 + atomic_inc(&pipe->waiting_writers);
58719 pipe_wait(pipe);
58720 - pipe->waiting_writers--;
58721 + atomic_dec(&pipe->waiting_writers);
58722 }
58723 out:
58724 __pipe_unlock(pipe);
58725 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58726 mask = 0;
58727 if (filp->f_mode & FMODE_READ) {
58728 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
58729 - if (!pipe->writers && filp->f_version != pipe->w_counter)
58730 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
58731 mask |= POLLHUP;
58732 }
58733
58734 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58735 * Most Unices do not set POLLERR for FIFOs but on Linux they
58736 * behave exactly like pipes for poll().
58737 */
58738 - if (!pipe->readers)
58739 + if (!atomic_read(&pipe->readers))
58740 mask |= POLLERR;
58741 }
58742
58743 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
58744
58745 __pipe_lock(pipe);
58746 if (file->f_mode & FMODE_READ)
58747 - pipe->readers--;
58748 + atomic_dec(&pipe->readers);
58749 if (file->f_mode & FMODE_WRITE)
58750 - pipe->writers--;
58751 + atomic_dec(&pipe->writers);
58752
58753 - if (pipe->readers || pipe->writers) {
58754 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
58755 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
58756 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58757 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
58758 }
58759 spin_lock(&inode->i_lock);
58760 - if (!--pipe->files) {
58761 + if (atomic_dec_and_test(&pipe->files)) {
58762 inode->i_pipe = NULL;
58763 kill = 1;
58764 }
58765 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
58766 kfree(pipe);
58767 }
58768
58769 -static struct vfsmount *pipe_mnt __read_mostly;
58770 +struct vfsmount *pipe_mnt __read_mostly;
58771
58772 /*
58773 * pipefs_dname() is called from d_path().
58774 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
58775 goto fail_iput;
58776
58777 inode->i_pipe = pipe;
58778 - pipe->files = 2;
58779 - pipe->readers = pipe->writers = 1;
58780 + atomic_set(&pipe->files, 2);
58781 + atomic_set(&pipe->readers, 1);
58782 + atomic_set(&pipe->writers, 1);
58783 inode->i_fop = &pipefifo_fops;
58784
58785 /*
58786 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
58787 spin_lock(&inode->i_lock);
58788 if (inode->i_pipe) {
58789 pipe = inode->i_pipe;
58790 - pipe->files++;
58791 + atomic_inc(&pipe->files);
58792 spin_unlock(&inode->i_lock);
58793 } else {
58794 spin_unlock(&inode->i_lock);
58795 pipe = alloc_pipe_info();
58796 if (!pipe)
58797 return -ENOMEM;
58798 - pipe->files = 1;
58799 + atomic_set(&pipe->files, 1);
58800 spin_lock(&inode->i_lock);
58801 if (unlikely(inode->i_pipe)) {
58802 - inode->i_pipe->files++;
58803 + atomic_inc(&inode->i_pipe->files);
58804 spin_unlock(&inode->i_lock);
58805 free_pipe_info(pipe);
58806 pipe = inode->i_pipe;
58807 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
58808 * opened, even when there is no process writing the FIFO.
58809 */
58810 pipe->r_counter++;
58811 - if (pipe->readers++ == 0)
58812 + if (atomic_inc_return(&pipe->readers) == 1)
58813 wake_up_partner(pipe);
58814
58815 - if (!is_pipe && !pipe->writers) {
58816 + if (!is_pipe && !atomic_read(&pipe->writers)) {
58817 if ((filp->f_flags & O_NONBLOCK)) {
58818 /* suppress POLLHUP until we have
58819 * seen a writer */
58820 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
58821 * errno=ENXIO when there is no process reading the FIFO.
58822 */
58823 ret = -ENXIO;
58824 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
58825 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
58826 goto err;
58827
58828 pipe->w_counter++;
58829 - if (!pipe->writers++)
58830 + if (atomic_inc_return(&pipe->writers) == 1)
58831 wake_up_partner(pipe);
58832
58833 - if (!is_pipe && !pipe->readers) {
58834 + if (!is_pipe && !atomic_read(&pipe->readers)) {
58835 if (wait_for_partner(pipe, &pipe->r_counter))
58836 goto err_wr;
58837 }
58838 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
58839 * the process can at least talk to itself.
58840 */
58841
58842 - pipe->readers++;
58843 - pipe->writers++;
58844 + atomic_inc(&pipe->readers);
58845 + atomic_inc(&pipe->writers);
58846 pipe->r_counter++;
58847 pipe->w_counter++;
58848 - if (pipe->readers == 1 || pipe->writers == 1)
58849 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
58850 wake_up_partner(pipe);
58851 break;
58852
58853 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
58854 return 0;
58855
58856 err_rd:
58857 - if (!--pipe->readers)
58858 + if (atomic_dec_and_test(&pipe->readers))
58859 wake_up_interruptible(&pipe->wait);
58860 ret = -ERESTARTSYS;
58861 goto err;
58862
58863 err_wr:
58864 - if (!--pipe->writers)
58865 + if (atomic_dec_and_test(&pipe->writers))
58866 wake_up_interruptible(&pipe->wait);
58867 ret = -ERESTARTSYS;
58868 goto err;
58869
58870 err:
58871 spin_lock(&inode->i_lock);
58872 - if (!--pipe->files) {
58873 + if (atomic_dec_and_test(&pipe->files)) {
58874 inode->i_pipe = NULL;
58875 kill = 1;
58876 }
58877 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
58878 index 15af622..0e9f4467 100644
58879 --- a/fs/proc/Kconfig
58880 +++ b/fs/proc/Kconfig
58881 @@ -30,12 +30,12 @@ config PROC_FS
58882
58883 config PROC_KCORE
58884 bool "/proc/kcore support" if !ARM
58885 - depends on PROC_FS && MMU
58886 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
58887
58888 config PROC_VMCORE
58889 bool "/proc/vmcore support"
58890 - depends on PROC_FS && CRASH_DUMP
58891 - default y
58892 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
58893 + default n
58894 help
58895 Exports the dump image of crashed kernel in ELF format.
58896
58897 @@ -59,8 +59,8 @@ config PROC_SYSCTL
58898 limited in memory.
58899
58900 config PROC_PAGE_MONITOR
58901 - default y
58902 - depends on PROC_FS && MMU
58903 + default n
58904 + depends on PROC_FS && MMU && !GRKERNSEC
58905 bool "Enable /proc page monitoring" if EXPERT
58906 help
58907 Various /proc files exist to monitor process memory utilization:
58908 diff --git a/fs/proc/array.c b/fs/proc/array.c
58909 index cbd0f1b..adec3f0 100644
58910 --- a/fs/proc/array.c
58911 +++ b/fs/proc/array.c
58912 @@ -60,6 +60,7 @@
58913 #include <linux/tty.h>
58914 #include <linux/string.h>
58915 #include <linux/mman.h>
58916 +#include <linux/grsecurity.h>
58917 #include <linux/proc_fs.h>
58918 #include <linux/ioport.h>
58919 #include <linux/uaccess.h>
58920 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
58921 seq_putc(m, '\n');
58922 }
58923
58924 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58925 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
58926 +{
58927 + if (p->mm)
58928 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
58929 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
58930 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
58931 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
58932 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
58933 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
58934 + else
58935 + seq_printf(m, "PaX:\t-----\n");
58936 +}
58937 +#endif
58938 +
58939 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58940 struct pid *pid, struct task_struct *task)
58941 {
58942 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58943 task_cpus_allowed(m, task);
58944 cpuset_task_status_allowed(m, task);
58945 task_context_switch_counts(m, task);
58946 +
58947 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58948 + task_pax(m, task);
58949 +#endif
58950 +
58951 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
58952 + task_grsec_rbac(m, task);
58953 +#endif
58954 +
58955 return 0;
58956 }
58957
58958 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58959 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58960 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58961 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58962 +#endif
58963 +
58964 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58965 struct pid *pid, struct task_struct *task, int whole)
58966 {
58967 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58968 char tcomm[sizeof(task->comm)];
58969 unsigned long flags;
58970
58971 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58972 + if (current->exec_id != m->exec_id) {
58973 + gr_log_badprocpid("stat");
58974 + return 0;
58975 + }
58976 +#endif
58977 +
58978 state = *get_task_state(task);
58979 vsize = eip = esp = 0;
58980 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
58981 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58982 gtime = task_gtime(task);
58983 }
58984
58985 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58986 + if (PAX_RAND_FLAGS(mm)) {
58987 + eip = 0;
58988 + esp = 0;
58989 + wchan = 0;
58990 + }
58991 +#endif
58992 +#ifdef CONFIG_GRKERNSEC_HIDESYM
58993 + wchan = 0;
58994 + eip =0;
58995 + esp =0;
58996 +#endif
58997 +
58998 /* scale priority and nice values from timeslices to -20..20 */
58999 /* to make it look like a "normal" Unix priority/nice value */
59000 priority = task_prio(task);
59001 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59002 seq_put_decimal_ull(m, ' ', vsize);
59003 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
59004 seq_put_decimal_ull(m, ' ', rsslim);
59005 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59006 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
59007 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
59008 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
59009 +#else
59010 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
59011 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
59012 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
59013 +#endif
59014 seq_put_decimal_ull(m, ' ', esp);
59015 seq_put_decimal_ull(m, ' ', eip);
59016 /* The signal information here is obsolete.
59017 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59018 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
59019 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
59020
59021 - if (mm && permitted) {
59022 + if (mm && permitted
59023 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59024 + && !PAX_RAND_FLAGS(mm)
59025 +#endif
59026 + ) {
59027 seq_put_decimal_ull(m, ' ', mm->start_data);
59028 seq_put_decimal_ull(m, ' ', mm->end_data);
59029 seq_put_decimal_ull(m, ' ', mm->start_brk);
59030 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59031 struct pid *pid, struct task_struct *task)
59032 {
59033 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
59034 - struct mm_struct *mm = get_task_mm(task);
59035 + struct mm_struct *mm;
59036
59037 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59038 + if (current->exec_id != m->exec_id) {
59039 + gr_log_badprocpid("statm");
59040 + return 0;
59041 + }
59042 +#endif
59043 + mm = get_task_mm(task);
59044 if (mm) {
59045 size = task_statm(mm, &shared, &text, &data, &resident);
59046 mmput(mm);
59047 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59048 return 0;
59049 }
59050
59051 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59052 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59053 +{
59054 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59055 +}
59056 +#endif
59057 +
59058 #ifdef CONFIG_CHECKPOINT_RESTORE
59059 static struct pid *
59060 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59061 diff --git a/fs/proc/base.c b/fs/proc/base.c
59062 index 1485e38..8ad4236 100644
59063 --- a/fs/proc/base.c
59064 +++ b/fs/proc/base.c
59065 @@ -113,6 +113,14 @@ struct pid_entry {
59066 union proc_op op;
59067 };
59068
59069 +struct getdents_callback {
59070 + struct linux_dirent __user * current_dir;
59071 + struct linux_dirent __user * previous;
59072 + struct file * file;
59073 + int count;
59074 + int error;
59075 +};
59076 +
59077 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59078 .name = (NAME), \
59079 .len = sizeof(NAME) - 1, \
59080 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59081 if (!mm->arg_end)
59082 goto out_mm; /* Shh! No looking before we're done */
59083
59084 + if (gr_acl_handle_procpidmem(task))
59085 + goto out_mm;
59086 +
59087 len = mm->arg_end - mm->arg_start;
59088
59089 if (len > PAGE_SIZE)
59090 @@ -237,12 +248,28 @@ out:
59091 return res;
59092 }
59093
59094 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59095 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59096 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59097 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59098 +#endif
59099 +
59100 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59101 {
59102 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59103 int res = PTR_ERR(mm);
59104 if (mm && !IS_ERR(mm)) {
59105 unsigned int nwords = 0;
59106 +
59107 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59108 + /* allow if we're currently ptracing this task */
59109 + if (PAX_RAND_FLAGS(mm) &&
59110 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59111 + mmput(mm);
59112 + return 0;
59113 + }
59114 +#endif
59115 +
59116 do {
59117 nwords += 2;
59118 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59119 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59120 }
59121
59122
59123 -#ifdef CONFIG_KALLSYMS
59124 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59125 /*
59126 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59127 * Returns the resolved symbol. If that fails, simply return the address.
59128 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59129 mutex_unlock(&task->signal->cred_guard_mutex);
59130 }
59131
59132 -#ifdef CONFIG_STACKTRACE
59133 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59134
59135 #define MAX_STACK_TRACE_DEPTH 64
59136
59137 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59138 return count;
59139 }
59140
59141 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59142 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59143 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59144 {
59145 long nr;
59146 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59147 /************************************************************************/
59148
59149 /* permission checks */
59150 -static int proc_fd_access_allowed(struct inode *inode)
59151 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59152 {
59153 struct task_struct *task;
59154 int allowed = 0;
59155 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59156 */
59157 task = get_proc_task(inode);
59158 if (task) {
59159 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59160 + if (log)
59161 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59162 + else
59163 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59164 put_task_struct(task);
59165 }
59166 return allowed;
59167 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59168 struct task_struct *task,
59169 int hide_pid_min)
59170 {
59171 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59172 + return false;
59173 +
59174 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59175 + rcu_read_lock();
59176 + {
59177 + const struct cred *tmpcred = current_cred();
59178 + const struct cred *cred = __task_cred(task);
59179 +
59180 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59181 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59182 + || in_group_p(grsec_proc_gid)
59183 +#endif
59184 + ) {
59185 + rcu_read_unlock();
59186 + return true;
59187 + }
59188 + }
59189 + rcu_read_unlock();
59190 +
59191 + if (!pid->hide_pid)
59192 + return false;
59193 +#endif
59194 +
59195 if (pid->hide_pid < hide_pid_min)
59196 return true;
59197 if (in_group_p(pid->pid_gid))
59198 return true;
59199 +
59200 return ptrace_may_access(task, PTRACE_MODE_READ);
59201 }
59202
59203 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59204 put_task_struct(task);
59205
59206 if (!has_perms) {
59207 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59208 + {
59209 +#else
59210 if (pid->hide_pid == 2) {
59211 +#endif
59212 /*
59213 * Let's make getdents(), stat(), and open()
59214 * consistent with each other. If a process
59215 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59216 if (!task)
59217 return -ESRCH;
59218
59219 + if (gr_acl_handle_procpidmem(task)) {
59220 + put_task_struct(task);
59221 + return -EPERM;
59222 + }
59223 +
59224 mm = mm_access(task, mode);
59225 put_task_struct(task);
59226
59227 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59228
59229 file->private_data = mm;
59230
59231 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59232 + file->f_version = current->exec_id;
59233 +#endif
59234 +
59235 return 0;
59236 }
59237
59238 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59239 ssize_t copied;
59240 char *page;
59241
59242 +#ifdef CONFIG_GRKERNSEC
59243 + if (write)
59244 + return -EPERM;
59245 +#endif
59246 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59247 + if (file->f_version != current->exec_id) {
59248 + gr_log_badprocpid("mem");
59249 + return 0;
59250 + }
59251 +#endif
59252 +
59253 if (!mm)
59254 return 0;
59255
59256 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59257 goto free;
59258
59259 while (count > 0) {
59260 - int this_len = min_t(int, count, PAGE_SIZE);
59261 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59262
59263 if (write && copy_from_user(page, buf, this_len)) {
59264 copied = -EFAULT;
59265 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59266 if (!mm)
59267 return 0;
59268
59269 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59270 + if (file->f_version != current->exec_id) {
59271 + gr_log_badprocpid("environ");
59272 + return 0;
59273 + }
59274 +#endif
59275 +
59276 page = (char *)__get_free_page(GFP_TEMPORARY);
59277 if (!page)
59278 return -ENOMEM;
59279 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59280 goto free;
59281 while (count > 0) {
59282 size_t this_len, max_len;
59283 - int retval;
59284 + ssize_t retval;
59285
59286 if (src >= (mm->env_end - mm->env_start))
59287 break;
59288 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59289 int error = -EACCES;
59290
59291 /* Are we allowed to snoop on the tasks file descriptors? */
59292 - if (!proc_fd_access_allowed(inode))
59293 + if (!proc_fd_access_allowed(inode, 0))
59294 goto out;
59295
59296 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59297 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59298 struct path path;
59299
59300 /* Are we allowed to snoop on the tasks file descriptors? */
59301 - if (!proc_fd_access_allowed(inode))
59302 - goto out;
59303 + /* logging this is needed for learning on chromium to work properly,
59304 + but we don't want to flood the logs from 'ps' which does a readlink
59305 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59306 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59307 + */
59308 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59309 + if (!proc_fd_access_allowed(inode,0))
59310 + goto out;
59311 + } else {
59312 + if (!proc_fd_access_allowed(inode,1))
59313 + goto out;
59314 + }
59315
59316 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59317 if (error)
59318 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59319 rcu_read_lock();
59320 cred = __task_cred(task);
59321 inode->i_uid = cred->euid;
59322 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59323 + inode->i_gid = grsec_proc_gid;
59324 +#else
59325 inode->i_gid = cred->egid;
59326 +#endif
59327 rcu_read_unlock();
59328 }
59329 security_task_to_inode(task, inode);
59330 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59331 return -ENOENT;
59332 }
59333 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59334 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59335 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59336 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59337 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59338 +#endif
59339 task_dumpable(task)) {
59340 cred = __task_cred(task);
59341 stat->uid = cred->euid;
59342 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59343 + stat->gid = grsec_proc_gid;
59344 +#else
59345 stat->gid = cred->egid;
59346 +#endif
59347 }
59348 }
59349 rcu_read_unlock();
59350 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59351
59352 if (task) {
59353 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59354 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59355 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59356 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59357 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59358 +#endif
59359 task_dumpable(task)) {
59360 rcu_read_lock();
59361 cred = __task_cred(task);
59362 inode->i_uid = cred->euid;
59363 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59364 + inode->i_gid = grsec_proc_gid;
59365 +#else
59366 inode->i_gid = cred->egid;
59367 +#endif
59368 rcu_read_unlock();
59369 } else {
59370 inode->i_uid = GLOBAL_ROOT_UID;
59371 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59372 if (!task)
59373 goto out_no_task;
59374
59375 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59376 + goto out;
59377 +
59378 /*
59379 * Yes, it does not scale. And it should not. Don't add
59380 * new entries into /proc/<tgid>/ without very good reasons.
59381 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59382 if (!task)
59383 return -ENOENT;
59384
59385 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59386 + goto out;
59387 +
59388 if (!dir_emit_dots(file, ctx))
59389 goto out;
59390
59391 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59392 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59393 #endif
59394 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59395 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59396 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59397 INF("syscall", S_IRUGO, proc_pid_syscall),
59398 #endif
59399 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59400 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59401 #ifdef CONFIG_SECURITY
59402 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59403 #endif
59404 -#ifdef CONFIG_KALLSYMS
59405 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59406 INF("wchan", S_IRUGO, proc_pid_wchan),
59407 #endif
59408 -#ifdef CONFIG_STACKTRACE
59409 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59410 ONE("stack", S_IRUGO, proc_pid_stack),
59411 #endif
59412 #ifdef CONFIG_SCHEDSTATS
59413 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59414 #ifdef CONFIG_HARDWALL
59415 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59416 #endif
59417 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59418 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59419 +#endif
59420 #ifdef CONFIG_USER_NS
59421 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59422 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59423 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59424 if (!inode)
59425 goto out;
59426
59427 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59428 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59429 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59430 + inode->i_gid = grsec_proc_gid;
59431 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59432 +#else
59433 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59434 +#endif
59435 inode->i_op = &proc_tgid_base_inode_operations;
59436 inode->i_fop = &proc_tgid_base_operations;
59437 inode->i_flags|=S_IMMUTABLE;
59438 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59439 if (!task)
59440 goto out;
59441
59442 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59443 + goto out_put_task;
59444 +
59445 result = proc_pid_instantiate(dir, dentry, task, NULL);
59446 +out_put_task:
59447 put_task_struct(task);
59448 out:
59449 return ERR_PTR(result);
59450 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59451 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59452 #endif
59453 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59454 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59455 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59456 INF("syscall", S_IRUGO, proc_pid_syscall),
59457 #endif
59458 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59459 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59460 #ifdef CONFIG_SECURITY
59461 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59462 #endif
59463 -#ifdef CONFIG_KALLSYMS
59464 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59465 INF("wchan", S_IRUGO, proc_pid_wchan),
59466 #endif
59467 -#ifdef CONFIG_STACKTRACE
59468 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59469 ONE("stack", S_IRUGO, proc_pid_stack),
59470 #endif
59471 #ifdef CONFIG_SCHEDSTATS
59472 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59473 index 82676e3..5f8518a 100644
59474 --- a/fs/proc/cmdline.c
59475 +++ b/fs/proc/cmdline.c
59476 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59477
59478 static int __init proc_cmdline_init(void)
59479 {
59480 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59481 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59482 +#else
59483 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59484 +#endif
59485 return 0;
59486 }
59487 module_init(proc_cmdline_init);
59488 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59489 index b143471..bb105e5 100644
59490 --- a/fs/proc/devices.c
59491 +++ b/fs/proc/devices.c
59492 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59493
59494 static int __init proc_devices_init(void)
59495 {
59496 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59497 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
59498 +#else
59499 proc_create("devices", 0, NULL, &proc_devinfo_operations);
59500 +#endif
59501 return 0;
59502 }
59503 module_init(proc_devices_init);
59504 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
59505 index 0ff80f9..a1d7500 100644
59506 --- a/fs/proc/fd.c
59507 +++ b/fs/proc/fd.c
59508 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
59509 if (!task)
59510 return -ENOENT;
59511
59512 - files = get_files_struct(task);
59513 + if (!gr_acl_handle_procpidmem(task))
59514 + files = get_files_struct(task);
59515 put_task_struct(task);
59516
59517 if (files) {
59518 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
59519 */
59520 int proc_fd_permission(struct inode *inode, int mask)
59521 {
59522 + struct task_struct *task;
59523 int rv = generic_permission(inode, mask);
59524 - if (rv == 0)
59525 - return 0;
59526 +
59527 if (task_pid(current) == proc_pid(inode))
59528 rv = 0;
59529 +
59530 + task = get_proc_task(inode);
59531 + if (task == NULL)
59532 + return rv;
59533 +
59534 + if (gr_acl_handle_procpidmem(task))
59535 + rv = -EACCES;
59536 +
59537 + put_task_struct(task);
59538 +
59539 return rv;
59540 }
59541
59542 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
59543 index 073aea6..0630370 100644
59544 --- a/fs/proc/inode.c
59545 +++ b/fs/proc/inode.c
59546 @@ -23,11 +23,17 @@
59547 #include <linux/slab.h>
59548 #include <linux/mount.h>
59549 #include <linux/magic.h>
59550 +#include <linux/grsecurity.h>
59551
59552 #include <asm/uaccess.h>
59553
59554 #include "internal.h"
59555
59556 +#ifdef CONFIG_PROC_SYSCTL
59557 +extern const struct inode_operations proc_sys_inode_operations;
59558 +extern const struct inode_operations proc_sys_dir_operations;
59559 +#endif
59560 +
59561 static void proc_evict_inode(struct inode *inode)
59562 {
59563 struct proc_dir_entry *de;
59564 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
59565 ns = PROC_I(inode)->ns.ns;
59566 if (ns_ops && ns)
59567 ns_ops->put(ns);
59568 +
59569 +#ifdef CONFIG_PROC_SYSCTL
59570 + if (inode->i_op == &proc_sys_inode_operations ||
59571 + inode->i_op == &proc_sys_dir_operations)
59572 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
59573 +#endif
59574 +
59575 }
59576
59577 static struct kmem_cache * proc_inode_cachep;
59578 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
59579 if (de->mode) {
59580 inode->i_mode = de->mode;
59581 inode->i_uid = de->uid;
59582 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59583 + inode->i_gid = grsec_proc_gid;
59584 +#else
59585 inode->i_gid = de->gid;
59586 +#endif
59587 }
59588 if (de->size)
59589 inode->i_size = de->size;
59590 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
59591 index 651d09a..60c73ae 100644
59592 --- a/fs/proc/internal.h
59593 +++ b/fs/proc/internal.h
59594 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
59595 struct pid *, struct task_struct *);
59596 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
59597 struct pid *, struct task_struct *);
59598 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59599 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
59600 +#endif
59601
59602 /*
59603 * base.c
59604 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
59605 index 06ea155..9a798c7 100644
59606 --- a/fs/proc/kcore.c
59607 +++ b/fs/proc/kcore.c
59608 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59609 * the addresses in the elf_phdr on our list.
59610 */
59611 start = kc_offset_to_vaddr(*fpos - elf_buflen);
59612 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
59613 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
59614 + if (tsz > buflen)
59615 tsz = buflen;
59616 -
59617 +
59618 while (buflen) {
59619 struct kcore_list *m;
59620
59621 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59622 kfree(elf_buf);
59623 } else {
59624 if (kern_addr_valid(start)) {
59625 - unsigned long n;
59626 + char *elf_buf;
59627 + mm_segment_t oldfs;
59628
59629 - n = copy_to_user(buffer, (char *)start, tsz);
59630 - /*
59631 - * We cannot distinguish between fault on source
59632 - * and fault on destination. When this happens
59633 - * we clear too and hope it will trigger the
59634 - * EFAULT again.
59635 - */
59636 - if (n) {
59637 - if (clear_user(buffer + tsz - n,
59638 - n))
59639 + elf_buf = kmalloc(tsz, GFP_KERNEL);
59640 + if (!elf_buf)
59641 + return -ENOMEM;
59642 + oldfs = get_fs();
59643 + set_fs(KERNEL_DS);
59644 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
59645 + set_fs(oldfs);
59646 + if (copy_to_user(buffer, elf_buf, tsz)) {
59647 + kfree(elf_buf);
59648 return -EFAULT;
59649 + }
59650 }
59651 + set_fs(oldfs);
59652 + kfree(elf_buf);
59653 } else {
59654 if (clear_user(buffer, tsz))
59655 return -EFAULT;
59656 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59657
59658 static int open_kcore(struct inode *inode, struct file *filp)
59659 {
59660 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
59661 + return -EPERM;
59662 +#endif
59663 if (!capable(CAP_SYS_RAWIO))
59664 return -EPERM;
59665 if (kcore_need_update)
59666 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
59667 index 5aa847a..f77c8d4 100644
59668 --- a/fs/proc/meminfo.c
59669 +++ b/fs/proc/meminfo.c
59670 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
59671 vmi.used >> 10,
59672 vmi.largest_chunk >> 10
59673 #ifdef CONFIG_MEMORY_FAILURE
59674 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59675 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59676 #endif
59677 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
59678 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
59679 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
59680 index ccfd99b..1b7e255 100644
59681 --- a/fs/proc/nommu.c
59682 +++ b/fs/proc/nommu.c
59683 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
59684 if (len < 1)
59685 len = 1;
59686 seq_printf(m, "%*c", len, ' ');
59687 - seq_path(m, &file->f_path, "");
59688 + seq_path(m, &file->f_path, "\n\\");
59689 }
59690
59691 seq_putc(m, '\n');
59692 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
59693 index 4677bb7..408e936 100644
59694 --- a/fs/proc/proc_net.c
59695 +++ b/fs/proc/proc_net.c
59696 @@ -23,6 +23,7 @@
59697 #include <linux/nsproxy.h>
59698 #include <net/net_namespace.h>
59699 #include <linux/seq_file.h>
59700 +#include <linux/grsecurity.h>
59701
59702 #include "internal.h"
59703
59704 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
59705 struct task_struct *task;
59706 struct nsproxy *ns;
59707 struct net *net = NULL;
59708 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59709 + const struct cred *cred = current_cred();
59710 +#endif
59711 +
59712 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59713 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
59714 + return net;
59715 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59716 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
59717 + return net;
59718 +#endif
59719
59720 rcu_read_lock();
59721 task = pid_task(proc_pid(dir), PIDTYPE_PID);
59722 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
59723 index 7129046..130793a 100644
59724 --- a/fs/proc/proc_sysctl.c
59725 +++ b/fs/proc/proc_sysctl.c
59726 @@ -11,13 +11,18 @@
59727 #include <linux/namei.h>
59728 #include <linux/mm.h>
59729 #include <linux/module.h>
59730 +#include <linux/nsproxy.h>
59731 #include "internal.h"
59732
59733 +extern int gr_handle_chroot_sysctl(const int op);
59734 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
59735 + const int op);
59736 +
59737 static const struct dentry_operations proc_sys_dentry_operations;
59738 static const struct file_operations proc_sys_file_operations;
59739 -static const struct inode_operations proc_sys_inode_operations;
59740 +const struct inode_operations proc_sys_inode_operations;
59741 static const struct file_operations proc_sys_dir_file_operations;
59742 -static const struct inode_operations proc_sys_dir_operations;
59743 +const struct inode_operations proc_sys_dir_operations;
59744
59745 void proc_sys_poll_notify(struct ctl_table_poll *poll)
59746 {
59747 @@ -467,6 +472,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
59748
59749 err = NULL;
59750 d_set_d_op(dentry, &proc_sys_dentry_operations);
59751 +
59752 + gr_handle_proc_create(dentry, inode);
59753 +
59754 d_add(dentry, inode);
59755
59756 out:
59757 @@ -482,6 +490,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59758 struct inode *inode = file_inode(filp);
59759 struct ctl_table_header *head = grab_header(inode);
59760 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
59761 + int op = write ? MAY_WRITE : MAY_READ;
59762 ssize_t error;
59763 size_t res;
59764
59765 @@ -493,7 +502,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59766 * and won't be until we finish.
59767 */
59768 error = -EPERM;
59769 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
59770 + if (sysctl_perm(head, table, op))
59771 goto out;
59772
59773 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
59774 @@ -501,6 +510,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59775 if (!table->proc_handler)
59776 goto out;
59777
59778 +#ifdef CONFIG_GRKERNSEC
59779 + error = -EPERM;
59780 + if (gr_handle_chroot_sysctl(op))
59781 + goto out;
59782 + dget(filp->f_path.dentry);
59783 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
59784 + dput(filp->f_path.dentry);
59785 + goto out;
59786 + }
59787 + dput(filp->f_path.dentry);
59788 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
59789 + goto out;
59790 + if (write) {
59791 + if (current->nsproxy->net_ns != table->extra2) {
59792 + if (!capable(CAP_SYS_ADMIN))
59793 + goto out;
59794 + } else if (!nsown_capable(CAP_NET_ADMIN))
59795 + goto out;
59796 + }
59797 +#endif
59798 +
59799 /* careful: calling conventions are nasty here */
59800 res = count;
59801 error = table->proc_handler(table, write, buf, &res, ppos);
59802 @@ -598,6 +628,9 @@ static bool proc_sys_fill_cache(struct file *file,
59803 return false;
59804 } else {
59805 d_set_d_op(child, &proc_sys_dentry_operations);
59806 +
59807 + gr_handle_proc_create(child, inode);
59808 +
59809 d_add(child, inode);
59810 }
59811 } else {
59812 @@ -641,6 +674,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
59813 if ((*pos)++ < ctx->pos)
59814 return true;
59815
59816 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
59817 + return 0;
59818 +
59819 if (unlikely(S_ISLNK(table->mode)))
59820 res = proc_sys_link_fill_cache(file, ctx, head, table);
59821 else
59822 @@ -734,6 +770,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
59823 if (IS_ERR(head))
59824 return PTR_ERR(head);
59825
59826 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
59827 + return -ENOENT;
59828 +
59829 generic_fillattr(inode, stat);
59830 if (table)
59831 stat->mode = (stat->mode & S_IFMT) | table->mode;
59832 @@ -756,13 +795,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
59833 .llseek = generic_file_llseek,
59834 };
59835
59836 -static const struct inode_operations proc_sys_inode_operations = {
59837 +const struct inode_operations proc_sys_inode_operations = {
59838 .permission = proc_sys_permission,
59839 .setattr = proc_sys_setattr,
59840 .getattr = proc_sys_getattr,
59841 };
59842
59843 -static const struct inode_operations proc_sys_dir_operations = {
59844 +const struct inode_operations proc_sys_dir_operations = {
59845 .lookup = proc_sys_lookup,
59846 .permission = proc_sys_permission,
59847 .setattr = proc_sys_setattr,
59848 @@ -839,7 +878,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
59849 static struct ctl_dir *new_dir(struct ctl_table_set *set,
59850 const char *name, int namelen)
59851 {
59852 - struct ctl_table *table;
59853 + ctl_table_no_const *table;
59854 struct ctl_dir *new;
59855 struct ctl_node *node;
59856 char *new_name;
59857 @@ -851,7 +890,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
59858 return NULL;
59859
59860 node = (struct ctl_node *)(new + 1);
59861 - table = (struct ctl_table *)(node + 1);
59862 + table = (ctl_table_no_const *)(node + 1);
59863 new_name = (char *)(table + 2);
59864 memcpy(new_name, name, namelen);
59865 new_name[namelen] = '\0';
59866 @@ -1020,7 +1059,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
59867 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
59868 struct ctl_table_root *link_root)
59869 {
59870 - struct ctl_table *link_table, *entry, *link;
59871 + ctl_table_no_const *link_table, *link;
59872 + struct ctl_table *entry;
59873 struct ctl_table_header *links;
59874 struct ctl_node *node;
59875 char *link_name;
59876 @@ -1043,7 +1083,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
59877 return NULL;
59878
59879 node = (struct ctl_node *)(links + 1);
59880 - link_table = (struct ctl_table *)(node + nr_entries);
59881 + link_table = (ctl_table_no_const *)(node + nr_entries);
59882 link_name = (char *)&link_table[nr_entries + 1];
59883
59884 for (link = link_table, entry = table; entry->procname; link++, entry++) {
59885 @@ -1291,8 +1331,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59886 struct ctl_table_header ***subheader, struct ctl_table_set *set,
59887 struct ctl_table *table)
59888 {
59889 - struct ctl_table *ctl_table_arg = NULL;
59890 - struct ctl_table *entry, *files;
59891 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
59892 + struct ctl_table *entry;
59893 int nr_files = 0;
59894 int nr_dirs = 0;
59895 int err = -ENOMEM;
59896 @@ -1304,10 +1344,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59897 nr_files++;
59898 }
59899
59900 - files = table;
59901 /* If there are mixed files and directories we need a new table */
59902 if (nr_dirs && nr_files) {
59903 - struct ctl_table *new;
59904 + ctl_table_no_const *new;
59905 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
59906 GFP_KERNEL);
59907 if (!files)
59908 @@ -1325,7 +1364,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59909 /* Register everything except a directory full of subdirectories */
59910 if (nr_files || !nr_dirs) {
59911 struct ctl_table_header *header;
59912 - header = __register_sysctl_table(set, path, files);
59913 + header = __register_sysctl_table(set, path, files ? files : table);
59914 if (!header) {
59915 kfree(ctl_table_arg);
59916 goto out;
59917 diff --git a/fs/proc/root.c b/fs/proc/root.c
59918 index 0e0e83c..005ba6a 100644
59919 --- a/fs/proc/root.c
59920 +++ b/fs/proc/root.c
59921 @@ -183,7 +183,15 @@ void __init proc_root_init(void)
59922 #ifdef CONFIG_PROC_DEVICETREE
59923 proc_device_tree_init();
59924 #endif
59925 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59926 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59927 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
59928 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59929 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
59930 +#endif
59931 +#else
59932 proc_mkdir("bus", NULL);
59933 +#endif
59934 proc_sys_init();
59935 }
59936
59937 diff --git a/fs/proc/self.c b/fs/proc/self.c
59938 index 6b6a993..807cccc 100644
59939 --- a/fs/proc/self.c
59940 +++ b/fs/proc/self.c
59941 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
59942 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
59943 void *cookie)
59944 {
59945 - char *s = nd_get_link(nd);
59946 + const char *s = nd_get_link(nd);
59947 if (!IS_ERR(s))
59948 kfree(s);
59949 }
59950 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
59951 index 7a9e255..03763e3 100644
59952 --- a/fs/proc/task_mmu.c
59953 +++ b/fs/proc/task_mmu.c
59954 @@ -12,12 +12,19 @@
59955 #include <linux/swap.h>
59956 #include <linux/swapops.h>
59957 #include <linux/mmu_notifier.h>
59958 +#include <linux/grsecurity.h>
59959
59960 #include <asm/elf.h>
59961 #include <asm/uaccess.h>
59962 #include <asm/tlbflush.h>
59963 #include "internal.h"
59964
59965 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59966 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59967 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59968 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59969 +#endif
59970 +
59971 void task_mem(struct seq_file *m, struct mm_struct *mm)
59972 {
59973 unsigned long data, text, lib, swap;
59974 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59975 "VmExe:\t%8lu kB\n"
59976 "VmLib:\t%8lu kB\n"
59977 "VmPTE:\t%8lu kB\n"
59978 - "VmSwap:\t%8lu kB\n",
59979 - hiwater_vm << (PAGE_SHIFT-10),
59980 + "VmSwap:\t%8lu kB\n"
59981 +
59982 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59983 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
59984 +#endif
59985 +
59986 + ,hiwater_vm << (PAGE_SHIFT-10),
59987 total_vm << (PAGE_SHIFT-10),
59988 mm->locked_vm << (PAGE_SHIFT-10),
59989 mm->pinned_vm << (PAGE_SHIFT-10),
59990 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59991 data << (PAGE_SHIFT-10),
59992 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
59993 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
59994 - swap << (PAGE_SHIFT-10));
59995 + swap << (PAGE_SHIFT-10)
59996 +
59997 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59998 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59999 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
60000 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
60001 +#else
60002 + , mm->context.user_cs_base
60003 + , mm->context.user_cs_limit
60004 +#endif
60005 +#endif
60006 +
60007 + );
60008 }
60009
60010 unsigned long task_vsize(struct mm_struct *mm)
60011 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60012 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
60013 }
60014
60015 - /* We don't show the stack guard page in /proc/maps */
60016 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60017 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
60018 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
60019 +#else
60020 start = vma->vm_start;
60021 - if (stack_guard_page_start(vma, start))
60022 - start += PAGE_SIZE;
60023 end = vma->vm_end;
60024 - if (stack_guard_page_end(vma, end))
60025 - end -= PAGE_SIZE;
60026 +#endif
60027
60028 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
60029 start,
60030 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60031 flags & VM_WRITE ? 'w' : '-',
60032 flags & VM_EXEC ? 'x' : '-',
60033 flags & VM_MAYSHARE ? 's' : 'p',
60034 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60035 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
60036 +#else
60037 pgoff,
60038 +#endif
60039 MAJOR(dev), MINOR(dev), ino, &len);
60040
60041 /*
60042 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60043 */
60044 if (file) {
60045 pad_len_spaces(m, len);
60046 - seq_path(m, &file->f_path, "\n");
60047 + seq_path(m, &file->f_path, "\n\\");
60048 goto done;
60049 }
60050
60051 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60052 * Thread stack in /proc/PID/task/TID/maps or
60053 * the main process stack.
60054 */
60055 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60056 - vma->vm_end >= mm->start_stack)) {
60057 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60058 + (vma->vm_start <= mm->start_stack &&
60059 + vma->vm_end >= mm->start_stack)) {
60060 name = "[stack]";
60061 } else {
60062 /* Thread stack in /proc/PID/maps */
60063 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60064 struct proc_maps_private *priv = m->private;
60065 struct task_struct *task = priv->task;
60066
60067 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60068 + if (current->exec_id != m->exec_id) {
60069 + gr_log_badprocpid("maps");
60070 + return 0;
60071 + }
60072 +#endif
60073 +
60074 show_map_vma(m, vma, is_pid);
60075
60076 if (m->count < m->size) /* vma is copied successfully */
60077 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60078 .private = &mss,
60079 };
60080
60081 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60082 + if (current->exec_id != m->exec_id) {
60083 + gr_log_badprocpid("smaps");
60084 + return 0;
60085 + }
60086 +#endif
60087 memset(&mss, 0, sizeof mss);
60088 - mss.vma = vma;
60089 - /* mmap_sem is held in m_start */
60090 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60091 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60092 -
60093 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60094 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60095 +#endif
60096 + mss.vma = vma;
60097 + /* mmap_sem is held in m_start */
60098 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60099 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60100 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60101 + }
60102 +#endif
60103 show_map_vma(m, vma, is_pid);
60104
60105 seq_printf(m,
60106 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60107 "KernelPageSize: %8lu kB\n"
60108 "MMUPageSize: %8lu kB\n"
60109 "Locked: %8lu kB\n",
60110 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60111 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60112 +#else
60113 (vma->vm_end - vma->vm_start) >> 10,
60114 +#endif
60115 mss.resident >> 10,
60116 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60117 mss.shared_clean >> 10,
60118 @@ -1362,6 +1413,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60119 int n;
60120 char buffer[50];
60121
60122 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60123 + if (current->exec_id != m->exec_id) {
60124 + gr_log_badprocpid("numa_maps");
60125 + return 0;
60126 + }
60127 +#endif
60128 +
60129 if (!mm)
60130 return 0;
60131
60132 @@ -1379,11 +1437,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60133 mpol_to_str(buffer, sizeof(buffer), pol);
60134 mpol_cond_put(pol);
60135
60136 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60137 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60138 +#else
60139 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60140 +#endif
60141
60142 if (file) {
60143 seq_printf(m, " file=");
60144 - seq_path(m, &file->f_path, "\n\t= ");
60145 + seq_path(m, &file->f_path, "\n\t\\= ");
60146 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60147 seq_printf(m, " heap");
60148 } else {
60149 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60150 index 56123a6..5a2f6ec 100644
60151 --- a/fs/proc/task_nommu.c
60152 +++ b/fs/proc/task_nommu.c
60153 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60154 else
60155 bytes += kobjsize(mm);
60156
60157 - if (current->fs && current->fs->users > 1)
60158 + if (current->fs && atomic_read(&current->fs->users) > 1)
60159 sbytes += kobjsize(current->fs);
60160 else
60161 bytes += kobjsize(current->fs);
60162 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60163
60164 if (file) {
60165 pad_len_spaces(m, len);
60166 - seq_path(m, &file->f_path, "");
60167 + seq_path(m, &file->f_path, "\n\\");
60168 } else if (mm) {
60169 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60170
60171 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60172 index a1a16eb..6be46ed 100644
60173 --- a/fs/proc/vmcore.c
60174 +++ b/fs/proc/vmcore.c
60175 @@ -104,9 +104,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60176 nr_bytes = count;
60177
60178 /* If pfn is not ram, return zeros for sparse dump files */
60179 - if (pfn_is_ram(pfn) == 0)
60180 - memset(buf, 0, nr_bytes);
60181 - else {
60182 + if (pfn_is_ram(pfn) == 0) {
60183 + if (userbuf) {
60184 + if (clear_user((char __force_user *)buf, nr_bytes))
60185 + return -EFAULT;
60186 + } else
60187 + memset(buf, 0, nr_bytes);
60188 + } else {
60189 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60190 offset, userbuf);
60191 if (tmp < 0)
60192 @@ -178,7 +182,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
60193 if (*fpos < m->offset + m->size) {
60194 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60195 start = m->paddr + *fpos - m->offset;
60196 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
60197 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
60198 if (tmp < 0)
60199 return tmp;
60200 buflen -= tsz;
60201 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60202 index b00fcc9..e0c6381 100644
60203 --- a/fs/qnx6/qnx6.h
60204 +++ b/fs/qnx6/qnx6.h
60205 @@ -74,7 +74,7 @@ enum {
60206 BYTESEX_BE,
60207 };
60208
60209 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60210 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60211 {
60212 if (sbi->s_bytesex == BYTESEX_LE)
60213 return le64_to_cpu((__force __le64)n);
60214 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60215 return (__force __fs64)cpu_to_be64(n);
60216 }
60217
60218 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60219 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60220 {
60221 if (sbi->s_bytesex == BYTESEX_LE)
60222 return le32_to_cpu((__force __le32)n);
60223 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60224 index 16e8abb..2dcf914 100644
60225 --- a/fs/quota/netlink.c
60226 +++ b/fs/quota/netlink.c
60227 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60228 void quota_send_warning(struct kqid qid, dev_t dev,
60229 const char warntype)
60230 {
60231 - static atomic_t seq;
60232 + static atomic_unchecked_t seq;
60233 struct sk_buff *skb;
60234 void *msg_head;
60235 int ret;
60236 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60237 "VFS: Not enough memory to send quota warning.\n");
60238 return;
60239 }
60240 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60241 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60242 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60243 if (!msg_head) {
60244 printk(KERN_ERR
60245 diff --git a/fs/read_write.c b/fs/read_write.c
60246 index 122a384..0b7ecf2 100644
60247 --- a/fs/read_write.c
60248 +++ b/fs/read_write.c
60249 @@ -440,7 +440,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60250
60251 old_fs = get_fs();
60252 set_fs(get_ds());
60253 - p = (__force const char __user *)buf;
60254 + p = (const char __force_user *)buf;
60255 if (count > MAX_RW_COUNT)
60256 count = MAX_RW_COUNT;
60257 if (file->f_op->write)
60258 diff --git a/fs/readdir.c b/fs/readdir.c
60259 index 93d71e5..6a14be8 100644
60260 --- a/fs/readdir.c
60261 +++ b/fs/readdir.c
60262 @@ -17,6 +17,7 @@
60263 #include <linux/security.h>
60264 #include <linux/syscalls.h>
60265 #include <linux/unistd.h>
60266 +#include <linux/namei.h>
60267
60268 #include <asm/uaccess.h>
60269
60270 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60271 struct readdir_callback {
60272 struct dir_context ctx;
60273 struct old_linux_dirent __user * dirent;
60274 + struct file * file;
60275 int result;
60276 };
60277
60278 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60279 buf->result = -EOVERFLOW;
60280 return -EOVERFLOW;
60281 }
60282 +
60283 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60284 + return 0;
60285 +
60286 buf->result++;
60287 dirent = buf->dirent;
60288 if (!access_ok(VERIFY_WRITE, dirent,
60289 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60290 if (!f.file)
60291 return -EBADF;
60292
60293 + buf.file = f.file;
60294 error = iterate_dir(f.file, &buf.ctx);
60295 if (buf.result)
60296 error = buf.result;
60297 @@ -142,6 +149,7 @@ struct getdents_callback {
60298 struct dir_context ctx;
60299 struct linux_dirent __user * current_dir;
60300 struct linux_dirent __user * previous;
60301 + struct file * file;
60302 int count;
60303 int error;
60304 };
60305 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60306 buf->error = -EOVERFLOW;
60307 return -EOVERFLOW;
60308 }
60309 +
60310 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60311 + return 0;
60312 +
60313 dirent = buf->previous;
60314 if (dirent) {
60315 if (__put_user(offset, &dirent->d_off))
60316 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60317 if (!f.file)
60318 return -EBADF;
60319
60320 + buf.file = f.file;
60321 error = iterate_dir(f.file, &buf.ctx);
60322 if (error >= 0)
60323 error = buf.error;
60324 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60325 struct dir_context ctx;
60326 struct linux_dirent64 __user * current_dir;
60327 struct linux_dirent64 __user * previous;
60328 + struct file *file;
60329 int count;
60330 int error;
60331 };
60332 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60333 buf->error = -EINVAL; /* only used if we fail.. */
60334 if (reclen > buf->count)
60335 return -EINVAL;
60336 +
60337 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60338 + return 0;
60339 +
60340 dirent = buf->previous;
60341 if (dirent) {
60342 if (__put_user(offset, &dirent->d_off))
60343 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60344 if (!f.file)
60345 return -EBADF;
60346
60347 + buf.file = f.file;
60348 error = iterate_dir(f.file, &buf.ctx);
60349 if (error >= 0)
60350 error = buf.error;
60351 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60352 index 2b7882b..1c5ef48 100644
60353 --- a/fs/reiserfs/do_balan.c
60354 +++ b/fs/reiserfs/do_balan.c
60355 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60356 return;
60357 }
60358
60359 - atomic_inc(&(fs_generation(tb->tb_sb)));
60360 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60361 do_balance_starts(tb);
60362
60363 /* balance leaf returns 0 except if combining L R and S into
60364 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60365 index a958444..42b2323 100644
60366 --- a/fs/reiserfs/procfs.c
60367 +++ b/fs/reiserfs/procfs.c
60368 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60369 "SMALL_TAILS " : "NO_TAILS ",
60370 replay_only(sb) ? "REPLAY_ONLY " : "",
60371 convert_reiserfs(sb) ? "CONV " : "",
60372 - atomic_read(&r->s_generation_counter),
60373 + atomic_read_unchecked(&r->s_generation_counter),
60374 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60375 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60376 SF(s_good_search_by_key_reada), SF(s_bmaps),
60377 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60378 index 3df5ce6..8c0f4b0 100644
60379 --- a/fs/reiserfs/reiserfs.h
60380 +++ b/fs/reiserfs/reiserfs.h
60381 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60382 /* Comment? -Hans */
60383 wait_queue_head_t s_wait;
60384 /* To be obsoleted soon by per buffer seals.. -Hans */
60385 - atomic_t s_generation_counter; // increased by one every time the
60386 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60387 // tree gets re-balanced
60388 unsigned long s_properties; /* File system properties. Currently holds
60389 on-disk FS format */
60390 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60391 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60392
60393 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60394 -#define get_generation(s) atomic_read (&fs_generation(s))
60395 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60396 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60397 #define __fs_changed(gen,s) (gen != get_generation (s))
60398 #define fs_changed(gen,s) \
60399 diff --git a/fs/select.c b/fs/select.c
60400 index dfd5cb1..1754d57 100644
60401 --- a/fs/select.c
60402 +++ b/fs/select.c
60403 @@ -20,6 +20,7 @@
60404 #include <linux/export.h>
60405 #include <linux/slab.h>
60406 #include <linux/poll.h>
60407 +#include <linux/security.h>
60408 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60409 #include <linux/file.h>
60410 #include <linux/fdtable.h>
60411 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60412 struct poll_list *walk = head;
60413 unsigned long todo = nfds;
60414
60415 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60416 if (nfds > rlimit(RLIMIT_NOFILE))
60417 return -EINVAL;
60418
60419 diff --git a/fs/seq_file.c b/fs/seq_file.c
60420 index a290157..5fa85e4 100644
60421 --- a/fs/seq_file.c
60422 +++ b/fs/seq_file.c
60423 @@ -10,6 +10,7 @@
60424 #include <linux/seq_file.h>
60425 #include <linux/slab.h>
60426 #include <linux/cred.h>
60427 +#include <linux/sched.h>
60428
60429 #include <asm/uaccess.h>
60430 #include <asm/page.h>
60431 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60432 #ifdef CONFIG_USER_NS
60433 p->user_ns = file->f_cred->user_ns;
60434 #endif
60435 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60436 + p->exec_id = current->exec_id;
60437 +#endif
60438
60439 /*
60440 * Wrappers around seq_open(e.g. swaps_open) need to be
60441 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60442 return 0;
60443 }
60444 if (!m->buf) {
60445 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60446 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60447 if (!m->buf)
60448 return -ENOMEM;
60449 }
60450 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60451 Eoverflow:
60452 m->op->stop(m, p);
60453 kfree(m->buf);
60454 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60455 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60456 return !m->buf ? -ENOMEM : -EAGAIN;
60457 }
60458
60459 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60460
60461 /* grab buffer if we didn't have one */
60462 if (!m->buf) {
60463 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60464 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60465 if (!m->buf)
60466 goto Enomem;
60467 }
60468 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60469 goto Fill;
60470 m->op->stop(m, p);
60471 kfree(m->buf);
60472 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60473 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60474 if (!m->buf)
60475 goto Enomem;
60476 m->count = 0;
60477 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
60478 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60479 void *data)
60480 {
60481 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60482 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60483 int res = -ENOMEM;
60484
60485 if (op) {
60486 diff --git a/fs/splice.c b/fs/splice.c
60487 index 3b7ee65..87fc2e4 100644
60488 --- a/fs/splice.c
60489 +++ b/fs/splice.c
60490 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60491 pipe_lock(pipe);
60492
60493 for (;;) {
60494 - if (!pipe->readers) {
60495 + if (!atomic_read(&pipe->readers)) {
60496 send_sig(SIGPIPE, current, 0);
60497 if (!ret)
60498 ret = -EPIPE;
60499 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60500 page_nr++;
60501 ret += buf->len;
60502
60503 - if (pipe->files)
60504 + if (atomic_read(&pipe->files))
60505 do_wakeup = 1;
60506
60507 if (!--spd->nr_pages)
60508 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60509 do_wakeup = 0;
60510 }
60511
60512 - pipe->waiting_writers++;
60513 + atomic_inc(&pipe->waiting_writers);
60514 pipe_wait(pipe);
60515 - pipe->waiting_writers--;
60516 + atomic_dec(&pipe->waiting_writers);
60517 }
60518
60519 pipe_unlock(pipe);
60520 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
60521 old_fs = get_fs();
60522 set_fs(get_ds());
60523 /* The cast to a user pointer is valid due to the set_fs() */
60524 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
60525 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
60526 set_fs(old_fs);
60527
60528 return res;
60529 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
60530 old_fs = get_fs();
60531 set_fs(get_ds());
60532 /* The cast to a user pointer is valid due to the set_fs() */
60533 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
60534 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
60535 set_fs(old_fs);
60536
60537 return res;
60538 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
60539 goto err;
60540
60541 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
60542 - vec[i].iov_base = (void __user *) page_address(page);
60543 + vec[i].iov_base = (void __force_user *) page_address(page);
60544 vec[i].iov_len = this_len;
60545 spd.pages[i] = page;
60546 spd.nr_pages++;
60547 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
60548 ops->release(pipe, buf);
60549 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
60550 pipe->nrbufs--;
60551 - if (pipe->files)
60552 + if (atomic_read(&pipe->files))
60553 sd->need_wakeup = true;
60554 }
60555
60556 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
60557 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
60558 {
60559 while (!pipe->nrbufs) {
60560 - if (!pipe->writers)
60561 + if (!atomic_read(&pipe->writers))
60562 return 0;
60563
60564 - if (!pipe->waiting_writers && sd->num_spliced)
60565 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
60566 return 0;
60567
60568 if (sd->flags & SPLICE_F_NONBLOCK)
60569 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
60570 * out of the pipe right after the splice_to_pipe(). So set
60571 * PIPE_READERS appropriately.
60572 */
60573 - pipe->readers = 1;
60574 + atomic_set(&pipe->readers, 1);
60575
60576 current->splice_pipe = pipe;
60577 }
60578 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
60579
60580 partial[buffers].offset = off;
60581 partial[buffers].len = plen;
60582 + partial[buffers].private = 0;
60583
60584 off = 0;
60585 len -= plen;
60586 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60587 ret = -ERESTARTSYS;
60588 break;
60589 }
60590 - if (!pipe->writers)
60591 + if (!atomic_read(&pipe->writers))
60592 break;
60593 - if (!pipe->waiting_writers) {
60594 + if (!atomic_read(&pipe->waiting_writers)) {
60595 if (flags & SPLICE_F_NONBLOCK) {
60596 ret = -EAGAIN;
60597 break;
60598 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60599 pipe_lock(pipe);
60600
60601 while (pipe->nrbufs >= pipe->buffers) {
60602 - if (!pipe->readers) {
60603 + if (!atomic_read(&pipe->readers)) {
60604 send_sig(SIGPIPE, current, 0);
60605 ret = -EPIPE;
60606 break;
60607 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60608 ret = -ERESTARTSYS;
60609 break;
60610 }
60611 - pipe->waiting_writers++;
60612 + atomic_inc(&pipe->waiting_writers);
60613 pipe_wait(pipe);
60614 - pipe->waiting_writers--;
60615 + atomic_dec(&pipe->waiting_writers);
60616 }
60617
60618 pipe_unlock(pipe);
60619 @@ -1862,14 +1863,14 @@ retry:
60620 pipe_double_lock(ipipe, opipe);
60621
60622 do {
60623 - if (!opipe->readers) {
60624 + if (!atomic_read(&opipe->readers)) {
60625 send_sig(SIGPIPE, current, 0);
60626 if (!ret)
60627 ret = -EPIPE;
60628 break;
60629 }
60630
60631 - if (!ipipe->nrbufs && !ipipe->writers)
60632 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
60633 break;
60634
60635 /*
60636 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60637 pipe_double_lock(ipipe, opipe);
60638
60639 do {
60640 - if (!opipe->readers) {
60641 + if (!atomic_read(&opipe->readers)) {
60642 send_sig(SIGPIPE, current, 0);
60643 if (!ret)
60644 ret = -EPIPE;
60645 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60646 * return EAGAIN if we have the potential of some data in the
60647 * future, otherwise just return 0
60648 */
60649 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
60650 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
60651 ret = -EAGAIN;
60652
60653 pipe_unlock(ipipe);
60654 diff --git a/fs/stat.c b/fs/stat.c
60655 index 04ce1ac..a13dd1e 100644
60656 --- a/fs/stat.c
60657 +++ b/fs/stat.c
60658 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
60659 stat->gid = inode->i_gid;
60660 stat->rdev = inode->i_rdev;
60661 stat->size = i_size_read(inode);
60662 - stat->atime = inode->i_atime;
60663 - stat->mtime = inode->i_mtime;
60664 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60665 + stat->atime = inode->i_ctime;
60666 + stat->mtime = inode->i_ctime;
60667 + } else {
60668 + stat->atime = inode->i_atime;
60669 + stat->mtime = inode->i_mtime;
60670 + }
60671 stat->ctime = inode->i_ctime;
60672 stat->blksize = (1 << inode->i_blkbits);
60673 stat->blocks = inode->i_blocks;
60674 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
60675 if (retval)
60676 return retval;
60677
60678 - if (inode->i_op->getattr)
60679 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
60680 + if (inode->i_op->getattr) {
60681 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
60682 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60683 + stat->atime = stat->ctime;
60684 + stat->mtime = stat->ctime;
60685 + }
60686 + return retval;
60687 + }
60688
60689 generic_fillattr(inode, stat);
60690 return 0;
60691 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
60692 index 15c68f9..36a8b3e 100644
60693 --- a/fs/sysfs/bin.c
60694 +++ b/fs/sysfs/bin.c
60695 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
60696 return ret;
60697 }
60698
60699 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
60700 - void *buf, int len, int write)
60701 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
60702 + void *buf, size_t len, int write)
60703 {
60704 struct file *file = vma->vm_file;
60705 struct bin_buffer *bb = file->private_data;
60706 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
60707 - int ret;
60708 + ssize_t ret;
60709
60710 if (!bb->vm_ops)
60711 return -EINVAL;
60712 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
60713 index e068e74..92edeb8 100644
60714 --- a/fs/sysfs/dir.c
60715 +++ b/fs/sysfs/dir.c
60716 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
60717 *
60718 * Returns 31 bit hash of ns + name (so it fits in an off_t )
60719 */
60720 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
60721 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
60722 {
60723 unsigned long hash = init_name_hash();
60724 unsigned int len = strlen(name);
60725 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
60726 struct sysfs_dirent *sd;
60727 int rc;
60728
60729 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
60730 + const char *parent_name = parent_sd->s_name;
60731 +
60732 + mode = S_IFDIR | S_IRWXU;
60733 +
60734 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
60735 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
60736 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
60737 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
60738 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
60739 +#endif
60740 +
60741 /* allocate */
60742 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
60743 if (!sd)
60744 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
60745 index d2bb7ed..fe8c331 100644
60746 --- a/fs/sysfs/file.c
60747 +++ b/fs/sysfs/file.c
60748 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
60749
60750 struct sysfs_open_dirent {
60751 atomic_t refcnt;
60752 - atomic_t event;
60753 + atomic_unchecked_t event;
60754 wait_queue_head_t poll;
60755 struct list_head buffers; /* goes through sysfs_buffer.list */
60756 };
60757 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
60758 if (!sysfs_get_active(attr_sd))
60759 return -ENODEV;
60760
60761 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
60762 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
60763 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
60764
60765 sysfs_put_active(attr_sd);
60766 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
60767 return -ENOMEM;
60768
60769 atomic_set(&new_od->refcnt, 0);
60770 - atomic_set(&new_od->event, 1);
60771 + atomic_set_unchecked(&new_od->event, 1);
60772 init_waitqueue_head(&new_od->poll);
60773 INIT_LIST_HEAD(&new_od->buffers);
60774 goto retry;
60775 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
60776
60777 sysfs_put_active(attr_sd);
60778
60779 - if (buffer->event != atomic_read(&od->event))
60780 + if (buffer->event != atomic_read_unchecked(&od->event))
60781 goto trigger;
60782
60783 return DEFAULT_POLLMASK;
60784 @@ -452,7 +452,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
60785 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
60786 od = sd->s_attr.open;
60787 if (od) {
60788 - atomic_inc(&od->event);
60789 + atomic_inc_unchecked(&od->event);
60790 wake_up_interruptible(&od->poll);
60791 }
60792 }
60793 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
60794 index 8c940df..25b733e 100644
60795 --- a/fs/sysfs/symlink.c
60796 +++ b/fs/sysfs/symlink.c
60797 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
60798
60799 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
60800 {
60801 - char *page = nd_get_link(nd);
60802 + const char *page = nd_get_link(nd);
60803 if (!IS_ERR(page))
60804 free_page((unsigned long)page);
60805 }
60806 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
60807 index 69d4889..a810bd4 100644
60808 --- a/fs/sysv/sysv.h
60809 +++ b/fs/sysv/sysv.h
60810 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
60811 #endif
60812 }
60813
60814 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60815 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60816 {
60817 if (sbi->s_bytesex == BYTESEX_PDP)
60818 return PDP_swab((__force __u32)n);
60819 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
60820 index e18b988..f1d4ad0f 100644
60821 --- a/fs/ubifs/io.c
60822 +++ b/fs/ubifs/io.c
60823 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
60824 return err;
60825 }
60826
60827 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60828 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60829 {
60830 int err;
60831
60832 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
60833 index c175b4d..8f36a16 100644
60834 --- a/fs/udf/misc.c
60835 +++ b/fs/udf/misc.c
60836 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
60837
60838 u8 udf_tag_checksum(const struct tag *t)
60839 {
60840 - u8 *data = (u8 *)t;
60841 + const u8 *data = (const u8 *)t;
60842 u8 checksum = 0;
60843 int i;
60844 for (i = 0; i < sizeof(struct tag); ++i)
60845 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
60846 index 8d974c4..b82f6ec 100644
60847 --- a/fs/ufs/swab.h
60848 +++ b/fs/ufs/swab.h
60849 @@ -22,7 +22,7 @@ enum {
60850 BYTESEX_BE
60851 };
60852
60853 -static inline u64
60854 +static inline u64 __intentional_overflow(-1)
60855 fs64_to_cpu(struct super_block *sbp, __fs64 n)
60856 {
60857 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60858 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
60859 return (__force __fs64)cpu_to_be64(n);
60860 }
60861
60862 -static inline u32
60863 +static inline u32 __intentional_overflow(-1)
60864 fs32_to_cpu(struct super_block *sbp, __fs32 n)
60865 {
60866 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60867 diff --git a/fs/utimes.c b/fs/utimes.c
60868 index f4fb7ec..3fe03c0 100644
60869 --- a/fs/utimes.c
60870 +++ b/fs/utimes.c
60871 @@ -1,6 +1,7 @@
60872 #include <linux/compiler.h>
60873 #include <linux/file.h>
60874 #include <linux/fs.h>
60875 +#include <linux/security.h>
60876 #include <linux/linkage.h>
60877 #include <linux/mount.h>
60878 #include <linux/namei.h>
60879 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
60880 goto mnt_drop_write_and_out;
60881 }
60882 }
60883 +
60884 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
60885 + error = -EACCES;
60886 + goto mnt_drop_write_and_out;
60887 + }
60888 +
60889 mutex_lock(&inode->i_mutex);
60890 error = notify_change(path->dentry, &newattrs);
60891 mutex_unlock(&inode->i_mutex);
60892 diff --git a/fs/xattr.c b/fs/xattr.c
60893 index 3377dff..4d074d9 100644
60894 --- a/fs/xattr.c
60895 +++ b/fs/xattr.c
60896 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
60897 return rc;
60898 }
60899
60900 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
60901 +ssize_t
60902 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
60903 +{
60904 + struct inode *inode = dentry->d_inode;
60905 + ssize_t error;
60906 +
60907 + error = inode_permission(inode, MAY_EXEC);
60908 + if (error)
60909 + return error;
60910 +
60911 + if (inode->i_op->getxattr)
60912 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
60913 + else
60914 + error = -EOPNOTSUPP;
60915 +
60916 + return error;
60917 +}
60918 +EXPORT_SYMBOL(pax_getxattr);
60919 +#endif
60920 +
60921 ssize_t
60922 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
60923 {
60924 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
60925 * Extended attribute SET operations
60926 */
60927 static long
60928 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
60929 +setxattr(struct path *path, const char __user *name, const void __user *value,
60930 size_t size, int flags)
60931 {
60932 int error;
60933 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
60934 posix_acl_fix_xattr_from_user(kvalue, size);
60935 }
60936
60937 - error = vfs_setxattr(d, kname, kvalue, size, flags);
60938 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
60939 + error = -EACCES;
60940 + goto out;
60941 + }
60942 +
60943 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
60944 out:
60945 if (vvalue)
60946 vfree(vvalue);
60947 @@ -377,7 +403,7 @@ retry:
60948 return error;
60949 error = mnt_want_write(path.mnt);
60950 if (!error) {
60951 - error = setxattr(path.dentry, name, value, size, flags);
60952 + error = setxattr(&path, name, value, size, flags);
60953 mnt_drop_write(path.mnt);
60954 }
60955 path_put(&path);
60956 @@ -401,7 +427,7 @@ retry:
60957 return error;
60958 error = mnt_want_write(path.mnt);
60959 if (!error) {
60960 - error = setxattr(path.dentry, name, value, size, flags);
60961 + error = setxattr(&path, name, value, size, flags);
60962 mnt_drop_write(path.mnt);
60963 }
60964 path_put(&path);
60965 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
60966 const void __user *,value, size_t, size, int, flags)
60967 {
60968 struct fd f = fdget(fd);
60969 - struct dentry *dentry;
60970 int error = -EBADF;
60971
60972 if (!f.file)
60973 return error;
60974 - dentry = f.file->f_path.dentry;
60975 - audit_inode(NULL, dentry, 0);
60976 + audit_inode(NULL, f.file->f_path.dentry, 0);
60977 error = mnt_want_write_file(f.file);
60978 if (!error) {
60979 - error = setxattr(dentry, name, value, size, flags);
60980 + error = setxattr(&f.file->f_path, name, value, size, flags);
60981 mnt_drop_write_file(f.file);
60982 }
60983 fdput(f);
60984 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
60985 index 9fbea87..6b19972 100644
60986 --- a/fs/xattr_acl.c
60987 +++ b/fs/xattr_acl.c
60988 @@ -76,8 +76,8 @@ struct posix_acl *
60989 posix_acl_from_xattr(struct user_namespace *user_ns,
60990 const void *value, size_t size)
60991 {
60992 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
60993 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
60994 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
60995 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
60996 int count;
60997 struct posix_acl *acl;
60998 struct posix_acl_entry *acl_e;
60999 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
61000 index 05c698c..6b918af 100644
61001 --- a/fs/xfs/xfs_bmap.c
61002 +++ b/fs/xfs/xfs_bmap.c
61003 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
61004
61005 #else
61006 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
61007 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
61008 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
61009 #endif /* DEBUG */
61010
61011 /*
61012 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
61013 index 97676a3..399a75d 100644
61014 --- a/fs/xfs/xfs_dir2_sf.c
61015 +++ b/fs/xfs/xfs_dir2_sf.c
61016 @@ -848,7 +848,12 @@ xfs_dir2_sf_getdents(
61017
61018 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
61019 ctx->pos = off & 0x7fffffff;
61020 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61021 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
61022 + char name[sfep->namelen];
61023 + memcpy(name, sfep->name, sfep->namelen);
61024 + if (!dir_emit(ctx, name, sfep->namelen, ino, DT_UNKNOWN))
61025 + return 0;
61026 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61027 ino, DT_UNKNOWN))
61028 return 0;
61029 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
61030 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
61031 index 6e2bca5..6ce80d3 100644
61032 --- a/fs/xfs/xfs_ioctl.c
61033 +++ b/fs/xfs/xfs_ioctl.c
61034 @@ -127,7 +127,7 @@ xfs_find_handle(
61035 }
61036
61037 error = -EFAULT;
61038 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
61039 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
61040 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
61041 goto out_put;
61042
61043 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
61044 index 96dda62..d6c6a52 100644
61045 --- a/fs/xfs/xfs_iops.c
61046 +++ b/fs/xfs/xfs_iops.c
61047 @@ -395,7 +395,7 @@ xfs_vn_put_link(
61048 struct nameidata *nd,
61049 void *p)
61050 {
61051 - char *s = nd_get_link(nd);
61052 + const char *s = nd_get_link(nd);
61053
61054 if (!IS_ERR(s))
61055 kfree(s);
61056 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61057 new file mode 100644
61058 index 0000000..a326c8d
61059 --- /dev/null
61060 +++ b/grsecurity/Kconfig
61061 @@ -0,0 +1,1112 @@
61062 +#
61063 +# grecurity configuration
61064 +#
61065 +menu "Memory Protections"
61066 +depends on GRKERNSEC
61067 +
61068 +config GRKERNSEC_KMEM
61069 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61070 + default y if GRKERNSEC_CONFIG_AUTO
61071 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61072 + help
61073 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61074 + be written to or read from to modify or leak the contents of the running
61075 + kernel. /dev/port will also not be allowed to be opened and support
61076 + for /dev/cpu/*/msr will be removed. If you have module
61077 + support disabled, enabling this will close up five ways that are
61078 + currently used to insert malicious code into the running kernel.
61079 +
61080 + Even with all these features enabled, we still highly recommend that
61081 + you use the RBAC system, as it is still possible for an attacker to
61082 + modify the running kernel through privileged I/O granted by ioperm/iopl.
61083 +
61084 + If you are not using XFree86, you may be able to stop this additional
61085 + case by enabling the 'Disable privileged I/O' option. Though nothing
61086 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
61087 + but only to video memory, which is the only writing we allow in this
61088 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
61089 + not be allowed to mprotect it with PROT_WRITE later.
61090 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61091 + from working.
61092 +
61093 + It is highly recommended that you say Y here if you meet all the
61094 + conditions above.
61095 +
61096 +config GRKERNSEC_VM86
61097 + bool "Restrict VM86 mode"
61098 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61099 + depends on X86_32
61100 +
61101 + help
61102 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61103 + make use of a special execution mode on 32bit x86 processors called
61104 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61105 + video cards and will still work with this option enabled. The purpose
61106 + of the option is to prevent exploitation of emulation errors in
61107 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61108 + Nearly all users should be able to enable this option.
61109 +
61110 +config GRKERNSEC_IO
61111 + bool "Disable privileged I/O"
61112 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61113 + depends on X86
61114 + select RTC_CLASS
61115 + select RTC_INTF_DEV
61116 + select RTC_DRV_CMOS
61117 +
61118 + help
61119 + If you say Y here, all ioperm and iopl calls will return an error.
61120 + Ioperm and iopl can be used to modify the running kernel.
61121 + Unfortunately, some programs need this access to operate properly,
61122 + the most notable of which are XFree86 and hwclock. hwclock can be
61123 + remedied by having RTC support in the kernel, so real-time
61124 + clock support is enabled if this option is enabled, to ensure
61125 + that hwclock operates correctly. XFree86 still will not
61126 + operate correctly with this option enabled, so DO NOT CHOOSE Y
61127 + IF YOU USE XFree86. If you use XFree86 and you still want to
61128 + protect your kernel against modification, use the RBAC system.
61129 +
61130 +config GRKERNSEC_JIT_HARDEN
61131 + bool "Harden BPF JIT against spray attacks"
61132 + default y if GRKERNSEC_CONFIG_AUTO
61133 + depends on BPF_JIT
61134 + help
61135 + If you say Y here, the native code generated by the kernel's Berkeley
61136 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61137 + attacks that attempt to fit attacker-beneficial instructions in
61138 + 32bit immediate fields of JIT-generated native instructions. The
61139 + attacker will generally aim to cause an unintended instruction sequence
61140 + of JIT-generated native code to execute by jumping into the middle of
61141 + a generated instruction. This feature effectively randomizes the 32bit
61142 + immediate constants present in the generated code to thwart such attacks.
61143 +
61144 + If you're using KERNEXEC, it's recommended that you enable this option
61145 + to supplement the hardening of the kernel.
61146 +
61147 +config GRKERNSEC_PERF_HARDEN
61148 + bool "Disable unprivileged PERF_EVENTS usage by default"
61149 + default y if GRKERNSEC_CONFIG_AUTO
61150 + depends on PERF_EVENTS
61151 + help
61152 + If you say Y here, the range of acceptable values for the
61153 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61154 + default to a new value: 3. When the sysctl is set to this value, no
61155 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61156 +
61157 + Though PERF_EVENTS can be used legitimately for performance monitoring
61158 + and low-level application profiling, it is forced on regardless of
61159 + configuration, has been at fault for several vulnerabilities, and
61160 + creates new opportunities for side channels and other information leaks.
61161 +
61162 + This feature puts PERF_EVENTS into a secure default state and permits
61163 + the administrator to change out of it temporarily if unprivileged
61164 + application profiling is needed.
61165 +
61166 +config GRKERNSEC_RAND_THREADSTACK
61167 + bool "Insert random gaps between thread stacks"
61168 + default y if GRKERNSEC_CONFIG_AUTO
61169 + depends on PAX_RANDMMAP && !PPC
61170 + help
61171 + If you say Y here, a random-sized gap will be enforced between allocated
61172 + thread stacks. Glibc's NPTL and other threading libraries that
61173 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61174 + The implementation currently provides 8 bits of entropy for the gap.
61175 +
61176 + Many distributions do not compile threaded remote services with the
61177 + -fstack-check argument to GCC, causing the variable-sized stack-based
61178 + allocator, alloca(), to not probe the stack on allocation. This
61179 + permits an unbounded alloca() to skip over any guard page and potentially
61180 + modify another thread's stack reliably. An enforced random gap
61181 + reduces the reliability of such an attack and increases the chance
61182 + that such a read/write to another thread's stack instead lands in
61183 + an unmapped area, causing a crash and triggering grsecurity's
61184 + anti-bruteforcing logic.
61185 +
61186 +config GRKERNSEC_PROC_MEMMAP
61187 + bool "Harden ASLR against information leaks and entropy reduction"
61188 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61189 + depends on PAX_NOEXEC || PAX_ASLR
61190 + help
61191 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61192 + give no information about the addresses of its mappings if
61193 + PaX features that rely on random addresses are enabled on the task.
61194 + In addition to sanitizing this information and disabling other
61195 + dangerous sources of information, this option causes reads of sensitive
61196 + /proc/<pid> entries where the file descriptor was opened in a different
61197 + task than the one performing the read. Such attempts are logged.
61198 + This option also limits argv/env strings for suid/sgid binaries
61199 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61200 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61201 + binaries to prevent alternative mmap layouts from being abused.
61202 +
61203 + If you use PaX it is essential that you say Y here as it closes up
61204 + several holes that make full ASLR useless locally.
61205 +
61206 +config GRKERNSEC_BRUTE
61207 + bool "Deter exploit bruteforcing"
61208 + default y if GRKERNSEC_CONFIG_AUTO
61209 + help
61210 + If you say Y here, attempts to bruteforce exploits against forking
61211 + daemons such as apache or sshd, as well as against suid/sgid binaries
61212 + will be deterred. When a child of a forking daemon is killed by PaX
61213 + or crashes due to an illegal instruction or other suspicious signal,
61214 + the parent process will be delayed 30 seconds upon every subsequent
61215 + fork until the administrator is able to assess the situation and
61216 + restart the daemon.
61217 + In the suid/sgid case, the attempt is logged, the user has all their
61218 + existing instances of the suid/sgid binary terminated and will
61219 + be unable to execute any suid/sgid binaries for 15 minutes.
61220 +
61221 + It is recommended that you also enable signal logging in the auditing
61222 + section so that logs are generated when a process triggers a suspicious
61223 + signal.
61224 + If the sysctl option is enabled, a sysctl option with name
61225 + "deter_bruteforce" is created.
61226 +
61227 +
61228 +config GRKERNSEC_MODHARDEN
61229 + bool "Harden module auto-loading"
61230 + default y if GRKERNSEC_CONFIG_AUTO
61231 + depends on MODULES
61232 + help
61233 + If you say Y here, module auto-loading in response to use of some
61234 + feature implemented by an unloaded module will be restricted to
61235 + root users. Enabling this option helps defend against attacks
61236 + by unprivileged users who abuse the auto-loading behavior to
61237 + cause a vulnerable module to load that is then exploited.
61238 +
61239 + If this option prevents a legitimate use of auto-loading for a
61240 + non-root user, the administrator can execute modprobe manually
61241 + with the exact name of the module mentioned in the alert log.
61242 + Alternatively, the administrator can add the module to the list
61243 + of modules loaded at boot by modifying init scripts.
61244 +
61245 + Modification of init scripts will most likely be needed on
61246 + Ubuntu servers with encrypted home directory support enabled,
61247 + as the first non-root user logging in will cause the ecb(aes),
61248 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61249 +
61250 +config GRKERNSEC_HIDESYM
61251 + bool "Hide kernel symbols"
61252 + default y if GRKERNSEC_CONFIG_AUTO
61253 + select PAX_USERCOPY_SLABS
61254 + help
61255 + If you say Y here, getting information on loaded modules, and
61256 + displaying all kernel symbols through a syscall will be restricted
61257 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61258 + /proc/kallsyms will be restricted to the root user. The RBAC
61259 + system can hide that entry even from root.
61260 +
61261 + This option also prevents leaking of kernel addresses through
61262 + several /proc entries.
61263 +
61264 + Note that this option is only effective provided the following
61265 + conditions are met:
61266 + 1) The kernel using grsecurity is not precompiled by some distribution
61267 + 2) You have also enabled GRKERNSEC_DMESG
61268 + 3) You are using the RBAC system and hiding other files such as your
61269 + kernel image and System.map. Alternatively, enabling this option
61270 + causes the permissions on /boot, /lib/modules, and the kernel
61271 + source directory to change at compile time to prevent
61272 + reading by non-root users.
61273 + If the above conditions are met, this option will aid in providing a
61274 + useful protection against local kernel exploitation of overflows
61275 + and arbitrary read/write vulnerabilities.
61276 +
61277 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61278 + in addition to this feature.
61279 +
61280 +config GRKERNSEC_KERN_LOCKOUT
61281 + bool "Active kernel exploit response"
61282 + default y if GRKERNSEC_CONFIG_AUTO
61283 + depends on X86 || ARM || PPC || SPARC
61284 + help
61285 + If you say Y here, when a PaX alert is triggered due to suspicious
61286 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61287 + or an OOPS occurs due to bad memory accesses, instead of just
61288 + terminating the offending process (and potentially allowing
61289 + a subsequent exploit from the same user), we will take one of two
61290 + actions:
61291 + If the user was root, we will panic the system
61292 + If the user was non-root, we will log the attempt, terminate
61293 + all processes owned by the user, then prevent them from creating
61294 + any new processes until the system is restarted
61295 + This deters repeated kernel exploitation/bruteforcing attempts
61296 + and is useful for later forensics.
61297 +
61298 +config GRKERNSEC_OLD_ARM_USERLAND
61299 + bool "Old ARM userland compatibility"
61300 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
61301 + help
61302 + If you say Y here, stubs of executable code to perform such operations
61303 + as "compare-exchange" will be placed at fixed locations in the ARM vector
61304 + table. This is unfortunately needed for old ARM userland meant to run
61305 + across a wide range of processors. Without this option enabled,
61306 + the get_tls and data memory barrier stubs will be emulated by the kernel,
61307 + which is enough for Linaro userlands or other userlands designed for v6
61308 + and newer ARM CPUs. It's recommended that you try without this option enabled
61309 + first, and only enable it if your userland does not boot (it will likely fail
61310 + at init time).
61311 +
61312 +endmenu
61313 +menu "Role Based Access Control Options"
61314 +depends on GRKERNSEC
61315 +
61316 +config GRKERNSEC_RBAC_DEBUG
61317 + bool
61318 +
61319 +config GRKERNSEC_NO_RBAC
61320 + bool "Disable RBAC system"
61321 + help
61322 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61323 + preventing the RBAC system from being enabled. You should only say Y
61324 + here if you have no intention of using the RBAC system, so as to prevent
61325 + an attacker with root access from misusing the RBAC system to hide files
61326 + and processes when loadable module support and /dev/[k]mem have been
61327 + locked down.
61328 +
61329 +config GRKERNSEC_ACL_HIDEKERN
61330 + bool "Hide kernel processes"
61331 + help
61332 + If you say Y here, all kernel threads will be hidden to all
61333 + processes but those whose subject has the "view hidden processes"
61334 + flag.
61335 +
61336 +config GRKERNSEC_ACL_MAXTRIES
61337 + int "Maximum tries before password lockout"
61338 + default 3
61339 + help
61340 + This option enforces the maximum number of times a user can attempt
61341 + to authorize themselves with the grsecurity RBAC system before being
61342 + denied the ability to attempt authorization again for a specified time.
61343 + The lower the number, the harder it will be to brute-force a password.
61344 +
61345 +config GRKERNSEC_ACL_TIMEOUT
61346 + int "Time to wait after max password tries, in seconds"
61347 + default 30
61348 + help
61349 + This option specifies the time the user must wait after attempting to
61350 + authorize to the RBAC system with the maximum number of invalid
61351 + passwords. The higher the number, the harder it will be to brute-force
61352 + a password.
61353 +
61354 +endmenu
61355 +menu "Filesystem Protections"
61356 +depends on GRKERNSEC
61357 +
61358 +config GRKERNSEC_PROC
61359 + bool "Proc restrictions"
61360 + default y if GRKERNSEC_CONFIG_AUTO
61361 + help
61362 + If you say Y here, the permissions of the /proc filesystem
61363 + will be altered to enhance system security and privacy. You MUST
61364 + choose either a user only restriction or a user and group restriction.
61365 + Depending upon the option you choose, you can either restrict users to
61366 + see only the processes they themselves run, or choose a group that can
61367 + view all processes and files normally restricted to root if you choose
61368 + the "restrict to user only" option. NOTE: If you're running identd or
61369 + ntpd as a non-root user, you will have to run it as the group you
61370 + specify here.
61371 +
61372 +config GRKERNSEC_PROC_USER
61373 + bool "Restrict /proc to user only"
61374 + depends on GRKERNSEC_PROC
61375 + help
61376 + If you say Y here, non-root users will only be able to view their own
61377 + processes, and restricts them from viewing network-related information,
61378 + and viewing kernel symbol and module information.
61379 +
61380 +config GRKERNSEC_PROC_USERGROUP
61381 + bool "Allow special group"
61382 + default y if GRKERNSEC_CONFIG_AUTO
61383 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61384 + help
61385 + If you say Y here, you will be able to select a group that will be
61386 + able to view all processes and network-related information. If you've
61387 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61388 + remain hidden. This option is useful if you want to run identd as
61389 + a non-root user. The group you select may also be chosen at boot time
61390 + via "grsec_proc_gid=" on the kernel commandline.
61391 +
61392 +config GRKERNSEC_PROC_GID
61393 + int "GID for special group"
61394 + depends on GRKERNSEC_PROC_USERGROUP
61395 + default 1001
61396 +
61397 +config GRKERNSEC_PROC_ADD
61398 + bool "Additional restrictions"
61399 + default y if GRKERNSEC_CONFIG_AUTO
61400 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61401 + help
61402 + If you say Y here, additional restrictions will be placed on
61403 + /proc that keep normal users from viewing device information and
61404 + slabinfo information that could be useful for exploits.
61405 +
61406 +config GRKERNSEC_LINK
61407 + bool "Linking restrictions"
61408 + default y if GRKERNSEC_CONFIG_AUTO
61409 + help
61410 + If you say Y here, /tmp race exploits will be prevented, since users
61411 + will no longer be able to follow symlinks owned by other users in
61412 + world-writable +t directories (e.g. /tmp), unless the owner of the
61413 + symlink is the owner of the directory. users will also not be
61414 + able to hardlink to files they do not own. If the sysctl option is
61415 + enabled, a sysctl option with name "linking_restrictions" is created.
61416 +
61417 +config GRKERNSEC_SYMLINKOWN
61418 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61419 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61420 + help
61421 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61422 + that prevents it from being used as a security feature. As Apache
61423 + verifies the symlink by performing a stat() against the target of
61424 + the symlink before it is followed, an attacker can setup a symlink
61425 + to point to a same-owned file, then replace the symlink with one
61426 + that targets another user's file just after Apache "validates" the
61427 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61428 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61429 + will be in place for the group you specify. If the sysctl option
61430 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61431 + created.
61432 +
61433 +config GRKERNSEC_SYMLINKOWN_GID
61434 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61435 + depends on GRKERNSEC_SYMLINKOWN
61436 + default 1006
61437 + help
61438 + Setting this GID determines what group kernel-enforced
61439 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61440 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61441 +
61442 +config GRKERNSEC_FIFO
61443 + bool "FIFO restrictions"
61444 + default y if GRKERNSEC_CONFIG_AUTO
61445 + help
61446 + If you say Y here, users will not be able to write to FIFOs they don't
61447 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61448 + the FIFO is the same owner of the directory it's held in. If the sysctl
61449 + option is enabled, a sysctl option with name "fifo_restrictions" is
61450 + created.
61451 +
61452 +config GRKERNSEC_SYSFS_RESTRICT
61453 + bool "Sysfs/debugfs restriction"
61454 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61455 + depends on SYSFS
61456 + help
61457 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61458 + any filesystem normally mounted under it (e.g. debugfs) will be
61459 + mostly accessible only by root. These filesystems generally provide access
61460 + to hardware and debug information that isn't appropriate for unprivileged
61461 + users of the system. Sysfs and debugfs have also become a large source
61462 + of new vulnerabilities, ranging from infoleaks to local compromise.
61463 + There has been very little oversight with an eye toward security involved
61464 + in adding new exporters of information to these filesystems, so their
61465 + use is discouraged.
61466 + For reasons of compatibility, a few directories have been whitelisted
61467 + for access by non-root users:
61468 + /sys/fs/selinux
61469 + /sys/fs/fuse
61470 + /sys/devices/system/cpu
61471 +
61472 +config GRKERNSEC_ROFS
61473 + bool "Runtime read-only mount protection"
61474 + depends on SYSCTL
61475 + help
61476 + If you say Y here, a sysctl option with name "romount_protect" will
61477 + be created. By setting this option to 1 at runtime, filesystems
61478 + will be protected in the following ways:
61479 + * No new writable mounts will be allowed
61480 + * Existing read-only mounts won't be able to be remounted read/write
61481 + * Write operations will be denied on all block devices
61482 + This option acts independently of grsec_lock: once it is set to 1,
61483 + it cannot be turned off. Therefore, please be mindful of the resulting
61484 + behavior if this option is enabled in an init script on a read-only
61485 + filesystem. This feature is mainly intended for secure embedded systems.
61486 +
61487 +config GRKERNSEC_DEVICE_SIDECHANNEL
61488 + bool "Eliminate stat/notify-based device sidechannels"
61489 + default y if GRKERNSEC_CONFIG_AUTO
61490 + help
61491 + If you say Y here, timing analyses on block or character
61492 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
61493 + will be thwarted for unprivileged users. If a process without
61494 + CAP_MKNOD stats such a device, the last access and last modify times
61495 + will match the device's create time. No access or modify events
61496 + will be triggered through inotify/dnotify/fanotify for such devices.
61497 + This feature will prevent attacks that may at a minimum
61498 + allow an attacker to determine the administrator's password length.
61499 +
61500 +config GRKERNSEC_CHROOT
61501 + bool "Chroot jail restrictions"
61502 + default y if GRKERNSEC_CONFIG_AUTO
61503 + help
61504 + If you say Y here, you will be able to choose several options that will
61505 + make breaking out of a chrooted jail much more difficult. If you
61506 + encounter no software incompatibilities with the following options, it
61507 + is recommended that you enable each one.
61508 +
61509 +config GRKERNSEC_CHROOT_MOUNT
61510 + bool "Deny mounts"
61511 + default y if GRKERNSEC_CONFIG_AUTO
61512 + depends on GRKERNSEC_CHROOT
61513 + help
61514 + If you say Y here, processes inside a chroot will not be able to
61515 + mount or remount filesystems. If the sysctl option is enabled, a
61516 + sysctl option with name "chroot_deny_mount" is created.
61517 +
61518 +config GRKERNSEC_CHROOT_DOUBLE
61519 + bool "Deny double-chroots"
61520 + default y if GRKERNSEC_CONFIG_AUTO
61521 + depends on GRKERNSEC_CHROOT
61522 + help
61523 + If you say Y here, processes inside a chroot will not be able to chroot
61524 + again outside the chroot. This is a widely used method of breaking
61525 + out of a chroot jail and should not be allowed. If the sysctl
61526 + option is enabled, a sysctl option with name
61527 + "chroot_deny_chroot" is created.
61528 +
61529 +config GRKERNSEC_CHROOT_PIVOT
61530 + bool "Deny pivot_root in chroot"
61531 + default y if GRKERNSEC_CONFIG_AUTO
61532 + depends on GRKERNSEC_CHROOT
61533 + help
61534 + If you say Y here, processes inside a chroot will not be able to use
61535 + a function called pivot_root() that was introduced in Linux 2.3.41. It
61536 + works similar to chroot in that it changes the root filesystem. This
61537 + function could be misused in a chrooted process to attempt to break out
61538 + of the chroot, and therefore should not be allowed. If the sysctl
61539 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
61540 + created.
61541 +
61542 +config GRKERNSEC_CHROOT_CHDIR
61543 + bool "Enforce chdir(\"/\") on all chroots"
61544 + default y if GRKERNSEC_CONFIG_AUTO
61545 + depends on GRKERNSEC_CHROOT
61546 + help
61547 + If you say Y here, the current working directory of all newly-chrooted
61548 + applications will be set to the the root directory of the chroot.
61549 + The man page on chroot(2) states:
61550 + Note that this call does not change the current working
61551 + directory, so that `.' can be outside the tree rooted at
61552 + `/'. In particular, the super-user can escape from a
61553 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
61554 +
61555 + It is recommended that you say Y here, since it's not known to break
61556 + any software. If the sysctl option is enabled, a sysctl option with
61557 + name "chroot_enforce_chdir" is created.
61558 +
61559 +config GRKERNSEC_CHROOT_CHMOD
61560 + bool "Deny (f)chmod +s"
61561 + default y if GRKERNSEC_CONFIG_AUTO
61562 + depends on GRKERNSEC_CHROOT
61563 + help
61564 + If you say Y here, processes inside a chroot will not be able to chmod
61565 + or fchmod files to make them have suid or sgid bits. This protects
61566 + against another published method of breaking a chroot. If the sysctl
61567 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
61568 + created.
61569 +
61570 +config GRKERNSEC_CHROOT_FCHDIR
61571 + bool "Deny fchdir out of chroot"
61572 + default y if GRKERNSEC_CONFIG_AUTO
61573 + depends on GRKERNSEC_CHROOT
61574 + help
61575 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
61576 + to a file descriptor of the chrooting process that points to a directory
61577 + outside the filesystem will be stopped. If the sysctl option
61578 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
61579 +
61580 +config GRKERNSEC_CHROOT_MKNOD
61581 + bool "Deny mknod"
61582 + default y if GRKERNSEC_CONFIG_AUTO
61583 + depends on GRKERNSEC_CHROOT
61584 + help
61585 + If you say Y here, processes inside a chroot will not be allowed to
61586 + mknod. The problem with using mknod inside a chroot is that it
61587 + would allow an attacker to create a device entry that is the same
61588 + as one on the physical root of your system, which could range from
61589 + anything from the console device to a device for your harddrive (which
61590 + they could then use to wipe the drive or steal data). It is recommended
61591 + that you say Y here, unless you run into software incompatibilities.
61592 + If the sysctl option is enabled, a sysctl option with name
61593 + "chroot_deny_mknod" is created.
61594 +
61595 +config GRKERNSEC_CHROOT_SHMAT
61596 + bool "Deny shmat() out of chroot"
61597 + default y if GRKERNSEC_CONFIG_AUTO
61598 + depends on GRKERNSEC_CHROOT
61599 + help
61600 + If you say Y here, processes inside a chroot will not be able to attach
61601 + to shared memory segments that were created outside of the chroot jail.
61602 + It is recommended that you say Y here. If the sysctl option is enabled,
61603 + a sysctl option with name "chroot_deny_shmat" is created.
61604 +
61605 +config GRKERNSEC_CHROOT_UNIX
61606 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
61607 + default y if GRKERNSEC_CONFIG_AUTO
61608 + depends on GRKERNSEC_CHROOT
61609 + help
61610 + If you say Y here, processes inside a chroot will not be able to
61611 + connect to abstract (meaning not belonging to a filesystem) Unix
61612 + domain sockets that were bound outside of a chroot. It is recommended
61613 + that you say Y here. If the sysctl option is enabled, a sysctl option
61614 + with name "chroot_deny_unix" is created.
61615 +
61616 +config GRKERNSEC_CHROOT_FINDTASK
61617 + bool "Protect outside processes"
61618 + default y if GRKERNSEC_CONFIG_AUTO
61619 + depends on GRKERNSEC_CHROOT
61620 + help
61621 + If you say Y here, processes inside a chroot will not be able to
61622 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
61623 + getsid, or view any process outside of the chroot. If the sysctl
61624 + option is enabled, a sysctl option with name "chroot_findtask" is
61625 + created.
61626 +
61627 +config GRKERNSEC_CHROOT_NICE
61628 + bool "Restrict priority changes"
61629 + default y if GRKERNSEC_CONFIG_AUTO
61630 + depends on GRKERNSEC_CHROOT
61631 + help
61632 + If you say Y here, processes inside a chroot will not be able to raise
61633 + the priority of processes in the chroot, or alter the priority of
61634 + processes outside the chroot. This provides more security than simply
61635 + removing CAP_SYS_NICE from the process' capability set. If the
61636 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
61637 + is created.
61638 +
61639 +config GRKERNSEC_CHROOT_SYSCTL
61640 + bool "Deny sysctl writes"
61641 + default y if GRKERNSEC_CONFIG_AUTO
61642 + depends on GRKERNSEC_CHROOT
61643 + help
61644 + If you say Y here, an attacker in a chroot will not be able to
61645 + write to sysctl entries, either by sysctl(2) or through a /proc
61646 + interface. It is strongly recommended that you say Y here. If the
61647 + sysctl option is enabled, a sysctl option with name
61648 + "chroot_deny_sysctl" is created.
61649 +
61650 +config GRKERNSEC_CHROOT_CAPS
61651 + bool "Capability restrictions"
61652 + default y if GRKERNSEC_CONFIG_AUTO
61653 + depends on GRKERNSEC_CHROOT
61654 + help
61655 + If you say Y here, the capabilities on all processes within a
61656 + chroot jail will be lowered to stop module insertion, raw i/o,
61657 + system and net admin tasks, rebooting the system, modifying immutable
61658 + files, modifying IPC owned by another, and changing the system time.
61659 + This is left an option because it can break some apps. Disable this
61660 + if your chrooted apps are having problems performing those kinds of
61661 + tasks. If the sysctl option is enabled, a sysctl option with
61662 + name "chroot_caps" is created.
61663 +
61664 +config GRKERNSEC_CHROOT_INITRD
61665 + bool "Exempt initrd tasks from restrictions"
61666 + default y if GRKERNSEC_CONFIG_AUTO
61667 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
61668 + help
61669 + If you say Y here, tasks started prior to init will be exempted from
61670 + grsecurity's chroot restrictions. This option is mainly meant to
61671 + resolve Plymouth's performing privileged operations unnecessarily
61672 + in a chroot.
61673 +
61674 +endmenu
61675 +menu "Kernel Auditing"
61676 +depends on GRKERNSEC
61677 +
61678 +config GRKERNSEC_AUDIT_GROUP
61679 + bool "Single group for auditing"
61680 + help
61681 + If you say Y here, the exec and chdir logging features will only operate
61682 + on a group you specify. This option is recommended if you only want to
61683 + watch certain users instead of having a large amount of logs from the
61684 + entire system. If the sysctl option is enabled, a sysctl option with
61685 + name "audit_group" is created.
61686 +
61687 +config GRKERNSEC_AUDIT_GID
61688 + int "GID for auditing"
61689 + depends on GRKERNSEC_AUDIT_GROUP
61690 + default 1007
61691 +
61692 +config GRKERNSEC_EXECLOG
61693 + bool "Exec logging"
61694 + help
61695 + If you say Y here, all execve() calls will be logged (since the
61696 + other exec*() calls are frontends to execve(), all execution
61697 + will be logged). Useful for shell-servers that like to keep track
61698 + of their users. If the sysctl option is enabled, a sysctl option with
61699 + name "exec_logging" is created.
61700 + WARNING: This option when enabled will produce a LOT of logs, especially
61701 + on an active system.
61702 +
61703 +config GRKERNSEC_RESLOG
61704 + bool "Resource logging"
61705 + default y if GRKERNSEC_CONFIG_AUTO
61706 + help
61707 + If you say Y here, all attempts to overstep resource limits will
61708 + be logged with the resource name, the requested size, and the current
61709 + limit. It is highly recommended that you say Y here. If the sysctl
61710 + option is enabled, a sysctl option with name "resource_logging" is
61711 + created. If the RBAC system is enabled, the sysctl value is ignored.
61712 +
61713 +config GRKERNSEC_CHROOT_EXECLOG
61714 + bool "Log execs within chroot"
61715 + help
61716 + If you say Y here, all executions inside a chroot jail will be logged
61717 + to syslog. This can cause a large amount of logs if certain
61718 + applications (eg. djb's daemontools) are installed on the system, and
61719 + is therefore left as an option. If the sysctl option is enabled, a
61720 + sysctl option with name "chroot_execlog" is created.
61721 +
61722 +config GRKERNSEC_AUDIT_PTRACE
61723 + bool "Ptrace logging"
61724 + help
61725 + If you say Y here, all attempts to attach to a process via ptrace
61726 + will be logged. If the sysctl option is enabled, a sysctl option
61727 + with name "audit_ptrace" is created.
61728 +
61729 +config GRKERNSEC_AUDIT_CHDIR
61730 + bool "Chdir logging"
61731 + help
61732 + If you say Y here, all chdir() calls will be logged. If the sysctl
61733 + option is enabled, a sysctl option with name "audit_chdir" is created.
61734 +
61735 +config GRKERNSEC_AUDIT_MOUNT
61736 + bool "(Un)Mount logging"
61737 + help
61738 + If you say Y here, all mounts and unmounts will be logged. If the
61739 + sysctl option is enabled, a sysctl option with name "audit_mount" is
61740 + created.
61741 +
61742 +config GRKERNSEC_SIGNAL
61743 + bool "Signal logging"
61744 + default y if GRKERNSEC_CONFIG_AUTO
61745 + help
61746 + If you say Y here, certain important signals will be logged, such as
61747 + SIGSEGV, which will as a result inform you of when a error in a program
61748 + occurred, which in some cases could mean a possible exploit attempt.
61749 + If the sysctl option is enabled, a sysctl option with name
61750 + "signal_logging" is created.
61751 +
61752 +config GRKERNSEC_FORKFAIL
61753 + bool "Fork failure logging"
61754 + help
61755 + If you say Y here, all failed fork() attempts will be logged.
61756 + This could suggest a fork bomb, or someone attempting to overstep
61757 + their process limit. If the sysctl option is enabled, a sysctl option
61758 + with name "forkfail_logging" is created.
61759 +
61760 +config GRKERNSEC_TIME
61761 + bool "Time change logging"
61762 + default y if GRKERNSEC_CONFIG_AUTO
61763 + help
61764 + If you say Y here, any changes of the system clock will be logged.
61765 + If the sysctl option is enabled, a sysctl option with name
61766 + "timechange_logging" is created.
61767 +
61768 +config GRKERNSEC_PROC_IPADDR
61769 + bool "/proc/<pid>/ipaddr support"
61770 + default y if GRKERNSEC_CONFIG_AUTO
61771 + help
61772 + If you say Y here, a new entry will be added to each /proc/<pid>
61773 + directory that contains the IP address of the person using the task.
61774 + The IP is carried across local TCP and AF_UNIX stream sockets.
61775 + This information can be useful for IDS/IPSes to perform remote response
61776 + to a local attack. The entry is readable by only the owner of the
61777 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
61778 + the RBAC system), and thus does not create privacy concerns.
61779 +
61780 +config GRKERNSEC_RWXMAP_LOG
61781 + bool 'Denied RWX mmap/mprotect logging'
61782 + default y if GRKERNSEC_CONFIG_AUTO
61783 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
61784 + help
61785 + If you say Y here, calls to mmap() and mprotect() with explicit
61786 + usage of PROT_WRITE and PROT_EXEC together will be logged when
61787 + denied by the PAX_MPROTECT feature. This feature will also
61788 + log other problematic scenarios that can occur when PAX_MPROTECT
61789 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
61790 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
61791 + is created.
61792 +
61793 +endmenu
61794 +
61795 +menu "Executable Protections"
61796 +depends on GRKERNSEC
61797 +
61798 +config GRKERNSEC_DMESG
61799 + bool "Dmesg(8) restriction"
61800 + default y if GRKERNSEC_CONFIG_AUTO
61801 + help
61802 + If you say Y here, non-root users will not be able to use dmesg(8)
61803 + to view the contents of the kernel's circular log buffer.
61804 + The kernel's log buffer often contains kernel addresses and other
61805 + identifying information useful to an attacker in fingerprinting a
61806 + system for a targeted exploit.
61807 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
61808 + created.
61809 +
61810 +config GRKERNSEC_HARDEN_PTRACE
61811 + bool "Deter ptrace-based process snooping"
61812 + default y if GRKERNSEC_CONFIG_AUTO
61813 + help
61814 + If you say Y here, TTY sniffers and other malicious monitoring
61815 + programs implemented through ptrace will be defeated. If you
61816 + have been using the RBAC system, this option has already been
61817 + enabled for several years for all users, with the ability to make
61818 + fine-grained exceptions.
61819 +
61820 + This option only affects the ability of non-root users to ptrace
61821 + processes that are not a descendent of the ptracing process.
61822 + This means that strace ./binary and gdb ./binary will still work,
61823 + but attaching to arbitrary processes will not. If the sysctl
61824 + option is enabled, a sysctl option with name "harden_ptrace" is
61825 + created.
61826 +
61827 +config GRKERNSEC_PTRACE_READEXEC
61828 + bool "Require read access to ptrace sensitive binaries"
61829 + default y if GRKERNSEC_CONFIG_AUTO
61830 + help
61831 + If you say Y here, unprivileged users will not be able to ptrace unreadable
61832 + binaries. This option is useful in environments that
61833 + remove the read bits (e.g. file mode 4711) from suid binaries to
61834 + prevent infoleaking of their contents. This option adds
61835 + consistency to the use of that file mode, as the binary could normally
61836 + be read out when run without privileges while ptracing.
61837 +
61838 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
61839 + is created.
61840 +
61841 +config GRKERNSEC_SETXID
61842 + bool "Enforce consistent multithreaded privileges"
61843 + default y if GRKERNSEC_CONFIG_AUTO
61844 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
61845 + help
61846 + If you say Y here, a change from a root uid to a non-root uid
61847 + in a multithreaded application will cause the resulting uids,
61848 + gids, supplementary groups, and capabilities in that thread
61849 + to be propagated to the other threads of the process. In most
61850 + cases this is unnecessary, as glibc will emulate this behavior
61851 + on behalf of the application. Other libcs do not act in the
61852 + same way, allowing the other threads of the process to continue
61853 + running with root privileges. If the sysctl option is enabled,
61854 + a sysctl option with name "consistent_setxid" is created.
61855 +
61856 +config GRKERNSEC_HARDEN_IPC
61857 + bool "Disallow access to world-accessible IPC objects"
61858 + default y if GRKERNSEC_CONFIG_AUTO
61859 + depends on SYSVIPC
61860 + help
61861 + If you say Y here, access to overly-permissive IPC (shared memory,
61862 + message queues, and semaphores) will be denied for processes whose
61863 + effective user or group would not grant them permission. It's a
61864 + common error to grant too much permission to these objects, with
61865 + impact ranging from denial of service and information leaking to
61866 + privilege escalation. This feature was developed in response to
61867 + research by Tim Brown:
61868 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
61869 + who found hundreds of such insecure usages. Processes with
61870 + CAP_IPC_OWNER are still permitted to access these IPC objects.
61871 + If the sysctl option is enabled, a sysctl option with name
61872 + "harden_ipc" is created.
61873 +
61874 +config GRKERNSEC_TPE
61875 + bool "Trusted Path Execution (TPE)"
61876 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61877 + help
61878 + If you say Y here, you will be able to choose a gid to add to the
61879 + supplementary groups of users you want to mark as "untrusted."
61880 + These users will not be able to execute any files that are not in
61881 + root-owned directories writable only by root. If the sysctl option
61882 + is enabled, a sysctl option with name "tpe" is created.
61883 +
61884 +config GRKERNSEC_TPE_ALL
61885 + bool "Partially restrict all non-root users"
61886 + depends on GRKERNSEC_TPE
61887 + help
61888 + If you say Y here, all non-root users will be covered under
61889 + a weaker TPE restriction. This is separate from, and in addition to,
61890 + the main TPE options that you have selected elsewhere. Thus, if a
61891 + "trusted" GID is chosen, this restriction applies to even that GID.
61892 + Under this restriction, all non-root users will only be allowed to
61893 + execute files in directories they own that are not group or
61894 + world-writable, or in directories owned by root and writable only by
61895 + root. If the sysctl option is enabled, a sysctl option with name
61896 + "tpe_restrict_all" is created.
61897 +
61898 +config GRKERNSEC_TPE_INVERT
61899 + bool "Invert GID option"
61900 + depends on GRKERNSEC_TPE
61901 + help
61902 + If you say Y here, the group you specify in the TPE configuration will
61903 + decide what group TPE restrictions will be *disabled* for. This
61904 + option is useful if you want TPE restrictions to be applied to most
61905 + users on the system. If the sysctl option is enabled, a sysctl option
61906 + with name "tpe_invert" is created. Unlike other sysctl options, this
61907 + entry will default to on for backward-compatibility.
61908 +
61909 +config GRKERNSEC_TPE_GID
61910 + int
61911 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
61912 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
61913 +
61914 +config GRKERNSEC_TPE_UNTRUSTED_GID
61915 + int "GID for TPE-untrusted users"
61916 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
61917 + default 1005
61918 + help
61919 + Setting this GID determines what group TPE restrictions will be
61920 + *enabled* for. If the sysctl option is enabled, a sysctl option
61921 + with name "tpe_gid" is created.
61922 +
61923 +config GRKERNSEC_TPE_TRUSTED_GID
61924 + int "GID for TPE-trusted users"
61925 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
61926 + default 1005
61927 + help
61928 + Setting this GID determines what group TPE restrictions will be
61929 + *disabled* for. If the sysctl option is enabled, a sysctl option
61930 + with name "tpe_gid" is created.
61931 +
61932 +endmenu
61933 +menu "Network Protections"
61934 +depends on GRKERNSEC
61935 +
61936 +config GRKERNSEC_RANDNET
61937 + bool "Larger entropy pools"
61938 + default y if GRKERNSEC_CONFIG_AUTO
61939 + help
61940 + If you say Y here, the entropy pools used for many features of Linux
61941 + and grsecurity will be doubled in size. Since several grsecurity
61942 + features use additional randomness, it is recommended that you say Y
61943 + here. Saying Y here has a similar effect as modifying
61944 + /proc/sys/kernel/random/poolsize.
61945 +
61946 +config GRKERNSEC_BLACKHOLE
61947 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
61948 + default y if GRKERNSEC_CONFIG_AUTO
61949 + depends on NET
61950 + help
61951 + If you say Y here, neither TCP resets nor ICMP
61952 + destination-unreachable packets will be sent in response to packets
61953 + sent to ports for which no associated listening process exists.
61954 + This feature supports both IPV4 and IPV6 and exempts the
61955 + loopback interface from blackholing. Enabling this feature
61956 + makes a host more resilient to DoS attacks and reduces network
61957 + visibility against scanners.
61958 +
61959 + The blackhole feature as-implemented is equivalent to the FreeBSD
61960 + blackhole feature, as it prevents RST responses to all packets, not
61961 + just SYNs. Under most application behavior this causes no
61962 + problems, but applications (like haproxy) may not close certain
61963 + connections in a way that cleanly terminates them on the remote
61964 + end, leaving the remote host in LAST_ACK state. Because of this
61965 + side-effect and to prevent intentional LAST_ACK DoSes, this
61966 + feature also adds automatic mitigation against such attacks.
61967 + The mitigation drastically reduces the amount of time a socket
61968 + can spend in LAST_ACK state. If you're using haproxy and not
61969 + all servers it connects to have this option enabled, consider
61970 + disabling this feature on the haproxy host.
61971 +
61972 + If the sysctl option is enabled, two sysctl options with names
61973 + "ip_blackhole" and "lastack_retries" will be created.
61974 + While "ip_blackhole" takes the standard zero/non-zero on/off
61975 + toggle, "lastack_retries" uses the same kinds of values as
61976 + "tcp_retries1" and "tcp_retries2". The default value of 4
61977 + prevents a socket from lasting more than 45 seconds in LAST_ACK
61978 + state.
61979 +
61980 +config GRKERNSEC_NO_SIMULT_CONNECT
61981 + bool "Disable TCP Simultaneous Connect"
61982 + default y if GRKERNSEC_CONFIG_AUTO
61983 + depends on NET
61984 + help
61985 + If you say Y here, a feature by Willy Tarreau will be enabled that
61986 + removes a weakness in Linux's strict implementation of TCP that
61987 + allows two clients to connect to each other without either entering
61988 + a listening state. The weakness allows an attacker to easily prevent
61989 + a client from connecting to a known server provided the source port
61990 + for the connection is guessed correctly.
61991 +
61992 + As the weakness could be used to prevent an antivirus or IPS from
61993 + fetching updates, or prevent an SSL gateway from fetching a CRL,
61994 + it should be eliminated by enabling this option. Though Linux is
61995 + one of few operating systems supporting simultaneous connect, it
61996 + has no legitimate use in practice and is rarely supported by firewalls.
61997 +
61998 +config GRKERNSEC_SOCKET
61999 + bool "Socket restrictions"
62000 + depends on NET
62001 + help
62002 + If you say Y here, you will be able to choose from several options.
62003 + If you assign a GID on your system and add it to the supplementary
62004 + groups of users you want to restrict socket access to, this patch
62005 + will perform up to three things, based on the option(s) you choose.
62006 +
62007 +config GRKERNSEC_SOCKET_ALL
62008 + bool "Deny any sockets to group"
62009 + depends on GRKERNSEC_SOCKET
62010 + help
62011 + If you say Y here, you will be able to choose a GID of whose users will
62012 + be unable to connect to other hosts from your machine or run server
62013 + applications from your machine. If the sysctl option is enabled, a
62014 + sysctl option with name "socket_all" is created.
62015 +
62016 +config GRKERNSEC_SOCKET_ALL_GID
62017 + int "GID to deny all sockets for"
62018 + depends on GRKERNSEC_SOCKET_ALL
62019 + default 1004
62020 + help
62021 + Here you can choose the GID to disable socket access for. Remember to
62022 + add the users you want socket access disabled for to the GID
62023 + specified here. If the sysctl option is enabled, a sysctl option
62024 + with name "socket_all_gid" is created.
62025 +
62026 +config GRKERNSEC_SOCKET_CLIENT
62027 + bool "Deny client sockets to group"
62028 + depends on GRKERNSEC_SOCKET
62029 + help
62030 + If you say Y here, you will be able to choose a GID of whose users will
62031 + be unable to connect to other hosts from your machine, but will be
62032 + able to run servers. If this option is enabled, all users in the group
62033 + you specify will have to use passive mode when initiating ftp transfers
62034 + from the shell on your machine. If the sysctl option is enabled, a
62035 + sysctl option with name "socket_client" is created.
62036 +
62037 +config GRKERNSEC_SOCKET_CLIENT_GID
62038 + int "GID to deny client sockets for"
62039 + depends on GRKERNSEC_SOCKET_CLIENT
62040 + default 1003
62041 + help
62042 + Here you can choose the GID to disable client socket access for.
62043 + Remember to add the users you want client socket access disabled for to
62044 + the GID specified here. If the sysctl option is enabled, a sysctl
62045 + option with name "socket_client_gid" is created.
62046 +
62047 +config GRKERNSEC_SOCKET_SERVER
62048 + bool "Deny server sockets to group"
62049 + depends on GRKERNSEC_SOCKET
62050 + help
62051 + If you say Y here, you will be able to choose a GID of whose users will
62052 + be unable to run server applications from your machine. If the sysctl
62053 + option is enabled, a sysctl option with name "socket_server" is created.
62054 +
62055 +config GRKERNSEC_SOCKET_SERVER_GID
62056 + int "GID to deny server sockets for"
62057 + depends on GRKERNSEC_SOCKET_SERVER
62058 + default 1002
62059 + help
62060 + Here you can choose the GID to disable server socket access for.
62061 + Remember to add the users you want server socket access disabled for to
62062 + the GID specified here. If the sysctl option is enabled, a sysctl
62063 + option with name "socket_server_gid" is created.
62064 +
62065 +endmenu
62066 +
62067 +menu "Physical Protections"
62068 +depends on GRKERNSEC
62069 +
62070 +config GRKERNSEC_DENYUSB
62071 + bool "Deny new USB connections after toggle"
62072 + default y if GRKERNSEC_CONFIG_AUTO
62073 + depends on SYSCTL && USB_SUPPORT
62074 + help
62075 + If you say Y here, a new sysctl option with name "deny_new_usb"
62076 + will be created. Setting its value to 1 will prevent any new
62077 + USB devices from being recognized by the OS. Any attempted USB
62078 + device insertion will be logged. This option is intended to be
62079 + used against custom USB devices designed to exploit vulnerabilities
62080 + in various USB device drivers.
62081 +
62082 + For greatest effectiveness, this sysctl should be set after any
62083 + relevant init scripts. This option is safe to enable in distros
62084 + as each user can choose whether or not to toggle the sysctl.
62085 +
62086 +config GRKERNSEC_DENYUSB_FORCE
62087 + bool "Reject all USB devices not connected at boot"
62088 + select USB
62089 + depends on GRKERNSEC_DENYUSB
62090 + help
62091 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62092 + that doesn't involve a sysctl entry. This option should only be
62093 + enabled if you're sure you want to deny all new USB connections
62094 + at runtime and don't want to modify init scripts. This should not
62095 + be enabled by distros. It forces the core USB code to be built
62096 + into the kernel image so that all devices connected at boot time
62097 + can be recognized and new USB device connections can be prevented
62098 + prior to init running.
62099 +
62100 +endmenu
62101 +
62102 +menu "Sysctl Support"
62103 +depends on GRKERNSEC && SYSCTL
62104 +
62105 +config GRKERNSEC_SYSCTL
62106 + bool "Sysctl support"
62107 + default y if GRKERNSEC_CONFIG_AUTO
62108 + help
62109 + If you say Y here, you will be able to change the options that
62110 + grsecurity runs with at bootup, without having to recompile your
62111 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62112 + to enable (1) or disable (0) various features. All the sysctl entries
62113 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62114 + All features enabled in the kernel configuration are disabled at boot
62115 + if you do not say Y to the "Turn on features by default" option.
62116 + All options should be set at startup, and the grsec_lock entry should
62117 + be set to a non-zero value after all the options are set.
62118 + *THIS IS EXTREMELY IMPORTANT*
62119 +
62120 +config GRKERNSEC_SYSCTL_DISTRO
62121 + bool "Extra sysctl support for distro makers (READ HELP)"
62122 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62123 + help
62124 + If you say Y here, additional sysctl options will be created
62125 + for features that affect processes running as root. Therefore,
62126 + it is critical when using this option that the grsec_lock entry be
62127 + enabled after boot. Only distros with prebuilt kernel packages
62128 + with this option enabled that can ensure grsec_lock is enabled
62129 + after boot should use this option.
62130 + *Failure to set grsec_lock after boot makes all grsec features
62131 + this option covers useless*
62132 +
62133 + Currently this option creates the following sysctl entries:
62134 + "Disable Privileged I/O": "disable_priv_io"
62135 +
62136 +config GRKERNSEC_SYSCTL_ON
62137 + bool "Turn on features by default"
62138 + default y if GRKERNSEC_CONFIG_AUTO
62139 + depends on GRKERNSEC_SYSCTL
62140 + help
62141 + If you say Y here, instead of having all features enabled in the
62142 + kernel configuration disabled at boot time, the features will be
62143 + enabled at boot time. It is recommended you say Y here unless
62144 + there is some reason you would want all sysctl-tunable features to
62145 + be disabled by default. As mentioned elsewhere, it is important
62146 + to enable the grsec_lock entry once you have finished modifying
62147 + the sysctl entries.
62148 +
62149 +endmenu
62150 +menu "Logging Options"
62151 +depends on GRKERNSEC
62152 +
62153 +config GRKERNSEC_FLOODTIME
62154 + int "Seconds in between log messages (minimum)"
62155 + default 10
62156 + help
62157 + This option allows you to enforce the number of seconds between
62158 + grsecurity log messages. The default should be suitable for most
62159 + people, however, if you choose to change it, choose a value small enough
62160 + to allow informative logs to be produced, but large enough to
62161 + prevent flooding.
62162 +
62163 +config GRKERNSEC_FLOODBURST
62164 + int "Number of messages in a burst (maximum)"
62165 + default 6
62166 + help
62167 + This option allows you to choose the maximum number of messages allowed
62168 + within the flood time interval you chose in a separate option. The
62169 + default should be suitable for most people, however if you find that
62170 + many of your logs are being interpreted as flooding, you may want to
62171 + raise this value.
62172 +
62173 +endmenu
62174 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62175 new file mode 100644
62176 index 0000000..0bc0a5c
62177 --- /dev/null
62178 +++ b/grsecurity/Makefile
62179 @@ -0,0 +1,43 @@
62180 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62181 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62182 +# into an RBAC system
62183 +#
62184 +# All code in this directory and various hooks inserted throughout the kernel
62185 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62186 +# under the GPL v2 or higher
62187 +
62188 +KBUILD_CFLAGS += -Werror
62189 +
62190 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62191 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62192 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62193 + grsec_usb.o grsec_ipc.o
62194 +
62195 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62196 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62197 + gracl_learn.o grsec_log.o
62198 +ifdef CONFIG_COMPAT
62199 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62200 +endif
62201 +
62202 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62203 +
62204 +ifdef CONFIG_NET
62205 +obj-y += grsec_sock.o
62206 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62207 +endif
62208 +
62209 +ifndef CONFIG_GRKERNSEC
62210 +obj-y += grsec_disabled.o
62211 +endif
62212 +
62213 +ifdef CONFIG_GRKERNSEC_HIDESYM
62214 +extra-y := grsec_hidesym.o
62215 +$(obj)/grsec_hidesym.o:
62216 + @-chmod -f 500 /boot
62217 + @-chmod -f 500 /lib/modules
62218 + @-chmod -f 500 /lib64/modules
62219 + @-chmod -f 500 /lib32/modules
62220 + @-chmod -f 700 .
62221 + @echo ' grsec: protected kernel image paths'
62222 +endif
62223 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62224 new file mode 100644
62225 index 0000000..c0793fd
62226 --- /dev/null
62227 +++ b/grsecurity/gracl.c
62228 @@ -0,0 +1,4178 @@
62229 +#include <linux/kernel.h>
62230 +#include <linux/module.h>
62231 +#include <linux/sched.h>
62232 +#include <linux/mm.h>
62233 +#include <linux/file.h>
62234 +#include <linux/fs.h>
62235 +#include <linux/namei.h>
62236 +#include <linux/mount.h>
62237 +#include <linux/tty.h>
62238 +#include <linux/proc_fs.h>
62239 +#include <linux/lglock.h>
62240 +#include <linux/slab.h>
62241 +#include <linux/vmalloc.h>
62242 +#include <linux/types.h>
62243 +#include <linux/sysctl.h>
62244 +#include <linux/netdevice.h>
62245 +#include <linux/ptrace.h>
62246 +#include <linux/gracl.h>
62247 +#include <linux/gralloc.h>
62248 +#include <linux/security.h>
62249 +#include <linux/grinternal.h>
62250 +#include <linux/pid_namespace.h>
62251 +#include <linux/stop_machine.h>
62252 +#include <linux/fdtable.h>
62253 +#include <linux/percpu.h>
62254 +#include <linux/lglock.h>
62255 +#include <linux/hugetlb.h>
62256 +#include <linux/posix-timers.h>
62257 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62258 +#include <linux/magic.h>
62259 +#include <linux/pagemap.h>
62260 +#include "../fs/btrfs/async-thread.h"
62261 +#include "../fs/btrfs/ctree.h"
62262 +#include "../fs/btrfs/btrfs_inode.h"
62263 +#endif
62264 +#include "../fs/mount.h"
62265 +
62266 +#include <asm/uaccess.h>
62267 +#include <asm/errno.h>
62268 +#include <asm/mman.h>
62269 +
62270 +extern struct lglock vfsmount_lock;
62271 +
62272 +static struct acl_role_db acl_role_set;
62273 +static struct name_db name_set;
62274 +static struct inodev_db inodev_set;
62275 +
62276 +/* for keeping track of userspace pointers used for subjects, so we
62277 + can share references in the kernel as well
62278 +*/
62279 +
62280 +static struct path real_root;
62281 +
62282 +static struct acl_subj_map_db subj_map_set;
62283 +
62284 +static struct acl_role_label *default_role;
62285 +
62286 +static struct acl_role_label *role_list;
62287 +
62288 +static u16 acl_sp_role_value;
62289 +
62290 +extern char *gr_shared_page[4];
62291 +static DEFINE_MUTEX(gr_dev_mutex);
62292 +DEFINE_RWLOCK(gr_inode_lock);
62293 +
62294 +struct gr_arg *gr_usermode;
62295 +
62296 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62297 +
62298 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
62299 +extern void gr_clear_learn_entries(void);
62300 +
62301 +unsigned char *gr_system_salt;
62302 +unsigned char *gr_system_sum;
62303 +
62304 +static struct sprole_pw **acl_special_roles = NULL;
62305 +static __u16 num_sprole_pws = 0;
62306 +
62307 +static struct acl_role_label *kernel_role = NULL;
62308 +
62309 +static unsigned int gr_auth_attempts = 0;
62310 +static unsigned long gr_auth_expires = 0UL;
62311 +
62312 +#ifdef CONFIG_NET
62313 +extern struct vfsmount *sock_mnt;
62314 +#endif
62315 +
62316 +extern struct vfsmount *pipe_mnt;
62317 +extern struct vfsmount *shm_mnt;
62318 +
62319 +#ifdef CONFIG_HUGETLBFS
62320 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62321 +#endif
62322 +
62323 +static struct acl_object_label *fakefs_obj_rw;
62324 +static struct acl_object_label *fakefs_obj_rwx;
62325 +
62326 +extern int gr_init_uidset(void);
62327 +extern void gr_free_uidset(void);
62328 +extern void gr_remove_uid(uid_t uid);
62329 +extern int gr_find_uid(uid_t uid);
62330 +
62331 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
62332 +{
62333 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
62334 + return -EFAULT;
62335 +
62336 + return 0;
62337 +}
62338 +
62339 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
62340 +{
62341 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
62342 + return -EFAULT;
62343 +
62344 + return 0;
62345 +}
62346 +
62347 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
62348 +{
62349 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
62350 + return -EFAULT;
62351 +
62352 + return 0;
62353 +}
62354 +
62355 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
62356 +{
62357 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
62358 + return -EFAULT;
62359 +
62360 + return 0;
62361 +}
62362 +
62363 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
62364 +{
62365 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
62366 + return -EFAULT;
62367 +
62368 + return 0;
62369 +}
62370 +
62371 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
62372 +{
62373 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
62374 + return -EFAULT;
62375 +
62376 + return 0;
62377 +}
62378 +
62379 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
62380 +{
62381 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
62382 + return -EFAULT;
62383 +
62384 + return 0;
62385 +}
62386 +
62387 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
62388 +{
62389 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
62390 + return -EFAULT;
62391 +
62392 + return 0;
62393 +}
62394 +
62395 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
62396 +{
62397 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
62398 + return -EFAULT;
62399 +
62400 + return 0;
62401 +}
62402 +
62403 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
62404 +{
62405 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
62406 + return -EFAULT;
62407 +
62408 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
62409 + return -EINVAL;
62410 +
62411 + return 0;
62412 +}
62413 +
62414 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
62415 +{
62416 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
62417 + return -EFAULT;
62418 +
62419 + return 0;
62420 +}
62421 +
62422 +static size_t get_gr_arg_wrapper_size_normal(void)
62423 +{
62424 + return sizeof(struct gr_arg_wrapper);
62425 +}
62426 +
62427 +#ifdef CONFIG_COMPAT
62428 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
62429 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
62430 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
62431 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
62432 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
62433 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
62434 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
62435 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
62436 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
62437 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
62438 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
62439 +extern size_t get_gr_arg_wrapper_size_compat(void);
62440 +
62441 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
62442 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
62443 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
62444 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
62445 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
62446 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
62447 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
62448 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
62449 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
62450 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
62451 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
62452 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
62453 +
62454 +#else
62455 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
62456 +#define copy_gr_arg copy_gr_arg_normal
62457 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
62458 +#define copy_acl_object_label copy_acl_object_label_normal
62459 +#define copy_acl_subject_label copy_acl_subject_label_normal
62460 +#define copy_acl_role_label copy_acl_role_label_normal
62461 +#define copy_acl_ip_label copy_acl_ip_label_normal
62462 +#define copy_pointer_from_array copy_pointer_from_array_normal
62463 +#define copy_sprole_pw copy_sprole_pw_normal
62464 +#define copy_role_transition copy_role_transition_normal
62465 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
62466 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
62467 +#endif
62468 +
62469 +__inline__ int
62470 +gr_acl_is_enabled(void)
62471 +{
62472 + return (gr_status & GR_READY);
62473 +}
62474 +
62475 +static inline dev_t __get_dev(const struct dentry *dentry)
62476 +{
62477 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62478 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62479 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62480 + else
62481 +#endif
62482 + return dentry->d_sb->s_dev;
62483 +}
62484 +
62485 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62486 +{
62487 + return __get_dev(dentry);
62488 +}
62489 +
62490 +static char gr_task_roletype_to_char(struct task_struct *task)
62491 +{
62492 + switch (task->role->roletype &
62493 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62494 + GR_ROLE_SPECIAL)) {
62495 + case GR_ROLE_DEFAULT:
62496 + return 'D';
62497 + case GR_ROLE_USER:
62498 + return 'U';
62499 + case GR_ROLE_GROUP:
62500 + return 'G';
62501 + case GR_ROLE_SPECIAL:
62502 + return 'S';
62503 + }
62504 +
62505 + return 'X';
62506 +}
62507 +
62508 +char gr_roletype_to_char(void)
62509 +{
62510 + return gr_task_roletype_to_char(current);
62511 +}
62512 +
62513 +__inline__ int
62514 +gr_acl_tpe_check(void)
62515 +{
62516 + if (unlikely(!(gr_status & GR_READY)))
62517 + return 0;
62518 + if (current->role->roletype & GR_ROLE_TPE)
62519 + return 1;
62520 + else
62521 + return 0;
62522 +}
62523 +
62524 +int
62525 +gr_handle_rawio(const struct inode *inode)
62526 +{
62527 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62528 + if (inode && S_ISBLK(inode->i_mode) &&
62529 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62530 + !capable(CAP_SYS_RAWIO))
62531 + return 1;
62532 +#endif
62533 + return 0;
62534 +}
62535 +
62536 +static int
62537 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62538 +{
62539 + if (likely(lena != lenb))
62540 + return 0;
62541 +
62542 + return !memcmp(a, b, lena);
62543 +}
62544 +
62545 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62546 +{
62547 + *buflen -= namelen;
62548 + if (*buflen < 0)
62549 + return -ENAMETOOLONG;
62550 + *buffer -= namelen;
62551 + memcpy(*buffer, str, namelen);
62552 + return 0;
62553 +}
62554 +
62555 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62556 +{
62557 + return prepend(buffer, buflen, name->name, name->len);
62558 +}
62559 +
62560 +static int prepend_path(const struct path *path, struct path *root,
62561 + char **buffer, int *buflen)
62562 +{
62563 + struct dentry *dentry = path->dentry;
62564 + struct vfsmount *vfsmnt = path->mnt;
62565 + struct mount *mnt = real_mount(vfsmnt);
62566 + bool slash = false;
62567 + int error = 0;
62568 +
62569 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62570 + struct dentry * parent;
62571 +
62572 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62573 + /* Global root? */
62574 + if (!mnt_has_parent(mnt)) {
62575 + goto out;
62576 + }
62577 + dentry = mnt->mnt_mountpoint;
62578 + mnt = mnt->mnt_parent;
62579 + vfsmnt = &mnt->mnt;
62580 + continue;
62581 + }
62582 + parent = dentry->d_parent;
62583 + prefetch(parent);
62584 + spin_lock(&dentry->d_lock);
62585 + error = prepend_name(buffer, buflen, &dentry->d_name);
62586 + spin_unlock(&dentry->d_lock);
62587 + if (!error)
62588 + error = prepend(buffer, buflen, "/", 1);
62589 + if (error)
62590 + break;
62591 +
62592 + slash = true;
62593 + dentry = parent;
62594 + }
62595 +
62596 +out:
62597 + if (!error && !slash)
62598 + error = prepend(buffer, buflen, "/", 1);
62599 +
62600 + return error;
62601 +}
62602 +
62603 +/* this must be called with vfsmount_lock and rename_lock held */
62604 +
62605 +static char *__our_d_path(const struct path *path, struct path *root,
62606 + char *buf, int buflen)
62607 +{
62608 + char *res = buf + buflen;
62609 + int error;
62610 +
62611 + prepend(&res, &buflen, "\0", 1);
62612 + error = prepend_path(path, root, &res, &buflen);
62613 + if (error)
62614 + return ERR_PTR(error);
62615 +
62616 + return res;
62617 +}
62618 +
62619 +static char *
62620 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62621 +{
62622 + char *retval;
62623 +
62624 + retval = __our_d_path(path, root, buf, buflen);
62625 + if (unlikely(IS_ERR(retval)))
62626 + retval = strcpy(buf, "<path too long>");
62627 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62628 + retval[1] = '\0';
62629 +
62630 + return retval;
62631 +}
62632 +
62633 +static char *
62634 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62635 + char *buf, int buflen)
62636 +{
62637 + struct path path;
62638 + char *res;
62639 +
62640 + path.dentry = (struct dentry *)dentry;
62641 + path.mnt = (struct vfsmount *)vfsmnt;
62642 +
62643 + /* we can use real_root.dentry, real_root.mnt, because this is only called
62644 + by the RBAC system */
62645 + res = gen_full_path(&path, &real_root, buf, buflen);
62646 +
62647 + return res;
62648 +}
62649 +
62650 +static char *
62651 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62652 + char *buf, int buflen)
62653 +{
62654 + char *res;
62655 + struct path path;
62656 + struct path root;
62657 + struct task_struct *reaper = init_pid_ns.child_reaper;
62658 +
62659 + path.dentry = (struct dentry *)dentry;
62660 + path.mnt = (struct vfsmount *)vfsmnt;
62661 +
62662 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
62663 + get_fs_root(reaper->fs, &root);
62664 +
62665 + br_read_lock(&vfsmount_lock);
62666 + write_seqlock(&rename_lock);
62667 + res = gen_full_path(&path, &root, buf, buflen);
62668 + write_sequnlock(&rename_lock);
62669 + br_read_unlock(&vfsmount_lock);
62670 +
62671 + path_put(&root);
62672 + return res;
62673 +}
62674 +
62675 +static char *
62676 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62677 +{
62678 + char *ret;
62679 + br_read_lock(&vfsmount_lock);
62680 + write_seqlock(&rename_lock);
62681 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62682 + PAGE_SIZE);
62683 + write_sequnlock(&rename_lock);
62684 + br_read_unlock(&vfsmount_lock);
62685 + return ret;
62686 +}
62687 +
62688 +static char *
62689 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62690 +{
62691 + char *ret;
62692 + char *buf;
62693 + int buflen;
62694 +
62695 + br_read_lock(&vfsmount_lock);
62696 + write_seqlock(&rename_lock);
62697 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
62698 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
62699 + buflen = (int)(ret - buf);
62700 + if (buflen >= 5)
62701 + prepend(&ret, &buflen, "/proc", 5);
62702 + else
62703 + ret = strcpy(buf, "<path too long>");
62704 + write_sequnlock(&rename_lock);
62705 + br_read_unlock(&vfsmount_lock);
62706 + return ret;
62707 +}
62708 +
62709 +char *
62710 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
62711 +{
62712 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62713 + PAGE_SIZE);
62714 +}
62715 +
62716 +char *
62717 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
62718 +{
62719 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62720 + PAGE_SIZE);
62721 +}
62722 +
62723 +char *
62724 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
62725 +{
62726 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
62727 + PAGE_SIZE);
62728 +}
62729 +
62730 +char *
62731 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
62732 +{
62733 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
62734 + PAGE_SIZE);
62735 +}
62736 +
62737 +char *
62738 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
62739 +{
62740 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
62741 + PAGE_SIZE);
62742 +}
62743 +
62744 +__inline__ __u32
62745 +to_gr_audit(const __u32 reqmode)
62746 +{
62747 + /* masks off auditable permission flags, then shifts them to create
62748 + auditing flags, and adds the special case of append auditing if
62749 + we're requesting write */
62750 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
62751 +}
62752 +
62753 +struct acl_subject_label *
62754 +lookup_subject_map(const struct acl_subject_label *userp)
62755 +{
62756 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
62757 + struct subject_map *match;
62758 +
62759 + match = subj_map_set.s_hash[index];
62760 +
62761 + while (match && match->user != userp)
62762 + match = match->next;
62763 +
62764 + if (match != NULL)
62765 + return match->kernel;
62766 + else
62767 + return NULL;
62768 +}
62769 +
62770 +static void
62771 +insert_subj_map_entry(struct subject_map *subjmap)
62772 +{
62773 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
62774 + struct subject_map **curr;
62775 +
62776 + subjmap->prev = NULL;
62777 +
62778 + curr = &subj_map_set.s_hash[index];
62779 + if (*curr != NULL)
62780 + (*curr)->prev = subjmap;
62781 +
62782 + subjmap->next = *curr;
62783 + *curr = subjmap;
62784 +
62785 + return;
62786 +}
62787 +
62788 +static struct acl_role_label *
62789 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
62790 + const gid_t gid)
62791 +{
62792 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
62793 + struct acl_role_label *match;
62794 + struct role_allowed_ip *ipp;
62795 + unsigned int x;
62796 + u32 curr_ip = task->signal->curr_ip;
62797 +
62798 + task->signal->saved_ip = curr_ip;
62799 +
62800 + match = acl_role_set.r_hash[index];
62801 +
62802 + while (match) {
62803 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
62804 + for (x = 0; x < match->domain_child_num; x++) {
62805 + if (match->domain_children[x] == uid)
62806 + goto found;
62807 + }
62808 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
62809 + break;
62810 + match = match->next;
62811 + }
62812 +found:
62813 + if (match == NULL) {
62814 + try_group:
62815 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
62816 + match = acl_role_set.r_hash[index];
62817 +
62818 + while (match) {
62819 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
62820 + for (x = 0; x < match->domain_child_num; x++) {
62821 + if (match->domain_children[x] == gid)
62822 + goto found2;
62823 + }
62824 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
62825 + break;
62826 + match = match->next;
62827 + }
62828 +found2:
62829 + if (match == NULL)
62830 + match = default_role;
62831 + if (match->allowed_ips == NULL)
62832 + return match;
62833 + else {
62834 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62835 + if (likely
62836 + ((ntohl(curr_ip) & ipp->netmask) ==
62837 + (ntohl(ipp->addr) & ipp->netmask)))
62838 + return match;
62839 + }
62840 + match = default_role;
62841 + }
62842 + } else if (match->allowed_ips == NULL) {
62843 + return match;
62844 + } else {
62845 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62846 + if (likely
62847 + ((ntohl(curr_ip) & ipp->netmask) ==
62848 + (ntohl(ipp->addr) & ipp->netmask)))
62849 + return match;
62850 + }
62851 + goto try_group;
62852 + }
62853 +
62854 + return match;
62855 +}
62856 +
62857 +struct acl_subject_label *
62858 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
62859 + const struct acl_role_label *role)
62860 +{
62861 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62862 + struct acl_subject_label *match;
62863 +
62864 + match = role->subj_hash[index];
62865 +
62866 + while (match && (match->inode != ino || match->device != dev ||
62867 + (match->mode & GR_DELETED))) {
62868 + match = match->next;
62869 + }
62870 +
62871 + if (match && !(match->mode & GR_DELETED))
62872 + return match;
62873 + else
62874 + return NULL;
62875 +}
62876 +
62877 +struct acl_subject_label *
62878 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
62879 + const struct acl_role_label *role)
62880 +{
62881 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62882 + struct acl_subject_label *match;
62883 +
62884 + match = role->subj_hash[index];
62885 +
62886 + while (match && (match->inode != ino || match->device != dev ||
62887 + !(match->mode & GR_DELETED))) {
62888 + match = match->next;
62889 + }
62890 +
62891 + if (match && (match->mode & GR_DELETED))
62892 + return match;
62893 + else
62894 + return NULL;
62895 +}
62896 +
62897 +static struct acl_object_label *
62898 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
62899 + const struct acl_subject_label *subj)
62900 +{
62901 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62902 + struct acl_object_label *match;
62903 +
62904 + match = subj->obj_hash[index];
62905 +
62906 + while (match && (match->inode != ino || match->device != dev ||
62907 + (match->mode & GR_DELETED))) {
62908 + match = match->next;
62909 + }
62910 +
62911 + if (match && !(match->mode & GR_DELETED))
62912 + return match;
62913 + else
62914 + return NULL;
62915 +}
62916 +
62917 +static struct acl_object_label *
62918 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
62919 + const struct acl_subject_label *subj)
62920 +{
62921 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62922 + struct acl_object_label *match;
62923 +
62924 + match = subj->obj_hash[index];
62925 +
62926 + while (match && (match->inode != ino || match->device != dev ||
62927 + !(match->mode & GR_DELETED))) {
62928 + match = match->next;
62929 + }
62930 +
62931 + if (match && (match->mode & GR_DELETED))
62932 + return match;
62933 +
62934 + match = subj->obj_hash[index];
62935 +
62936 + while (match && (match->inode != ino || match->device != dev ||
62937 + (match->mode & GR_DELETED))) {
62938 + match = match->next;
62939 + }
62940 +
62941 + if (match && !(match->mode & GR_DELETED))
62942 + return match;
62943 + else
62944 + return NULL;
62945 +}
62946 +
62947 +static struct name_entry *
62948 +lookup_name_entry(const char *name)
62949 +{
62950 + unsigned int len = strlen(name);
62951 + unsigned int key = full_name_hash(name, len);
62952 + unsigned int index = key % name_set.n_size;
62953 + struct name_entry *match;
62954 +
62955 + match = name_set.n_hash[index];
62956 +
62957 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
62958 + match = match->next;
62959 +
62960 + return match;
62961 +}
62962 +
62963 +static struct name_entry *
62964 +lookup_name_entry_create(const char *name)
62965 +{
62966 + unsigned int len = strlen(name);
62967 + unsigned int key = full_name_hash(name, len);
62968 + unsigned int index = key % name_set.n_size;
62969 + struct name_entry *match;
62970 +
62971 + match = name_set.n_hash[index];
62972 +
62973 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62974 + !match->deleted))
62975 + match = match->next;
62976 +
62977 + if (match && match->deleted)
62978 + return match;
62979 +
62980 + match = name_set.n_hash[index];
62981 +
62982 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62983 + match->deleted))
62984 + match = match->next;
62985 +
62986 + if (match && !match->deleted)
62987 + return match;
62988 + else
62989 + return NULL;
62990 +}
62991 +
62992 +static struct inodev_entry *
62993 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
62994 +{
62995 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
62996 + struct inodev_entry *match;
62997 +
62998 + match = inodev_set.i_hash[index];
62999 +
63000 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
63001 + match = match->next;
63002 +
63003 + return match;
63004 +}
63005 +
63006 +static void
63007 +insert_inodev_entry(struct inodev_entry *entry)
63008 +{
63009 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
63010 + inodev_set.i_size);
63011 + struct inodev_entry **curr;
63012 +
63013 + entry->prev = NULL;
63014 +
63015 + curr = &inodev_set.i_hash[index];
63016 + if (*curr != NULL)
63017 + (*curr)->prev = entry;
63018 +
63019 + entry->next = *curr;
63020 + *curr = entry;
63021 +
63022 + return;
63023 +}
63024 +
63025 +static void
63026 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
63027 +{
63028 + unsigned int index =
63029 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
63030 + struct acl_role_label **curr;
63031 + struct acl_role_label *tmp, *tmp2;
63032 +
63033 + curr = &acl_role_set.r_hash[index];
63034 +
63035 + /* simple case, slot is empty, just set it to our role */
63036 + if (*curr == NULL) {
63037 + *curr = role;
63038 + } else {
63039 + /* example:
63040 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
63041 + 2 -> 3
63042 + */
63043 + /* first check to see if we can already be reached via this slot */
63044 + tmp = *curr;
63045 + while (tmp && tmp != role)
63046 + tmp = tmp->next;
63047 + if (tmp == role) {
63048 + /* we don't need to add ourselves to this slot's chain */
63049 + return;
63050 + }
63051 + /* we need to add ourselves to this chain, two cases */
63052 + if (role->next == NULL) {
63053 + /* simple case, append the current chain to our role */
63054 + role->next = *curr;
63055 + *curr = role;
63056 + } else {
63057 + /* 1 -> 2 -> 3 -> 4
63058 + 2 -> 3 -> 4
63059 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
63060 + */
63061 + /* trickier case: walk our role's chain until we find
63062 + the role for the start of the current slot's chain */
63063 + tmp = role;
63064 + tmp2 = *curr;
63065 + while (tmp->next && tmp->next != tmp2)
63066 + tmp = tmp->next;
63067 + if (tmp->next == tmp2) {
63068 + /* from example above, we found 3, so just
63069 + replace this slot's chain with ours */
63070 + *curr = role;
63071 + } else {
63072 + /* we didn't find a subset of our role's chain
63073 + in the current slot's chain, so append their
63074 + chain to ours, and set us as the first role in
63075 + the slot's chain
63076 +
63077 + we could fold this case with the case above,
63078 + but making it explicit for clarity
63079 + */
63080 + tmp->next = tmp2;
63081 + *curr = role;
63082 + }
63083 + }
63084 + }
63085 +
63086 + return;
63087 +}
63088 +
63089 +static void
63090 +insert_acl_role_label(struct acl_role_label *role)
63091 +{
63092 + int i;
63093 +
63094 + if (role_list == NULL) {
63095 + role_list = role;
63096 + role->prev = NULL;
63097 + } else {
63098 + role->prev = role_list;
63099 + role_list = role;
63100 + }
63101 +
63102 + /* used for hash chains */
63103 + role->next = NULL;
63104 +
63105 + if (role->roletype & GR_ROLE_DOMAIN) {
63106 + for (i = 0; i < role->domain_child_num; i++)
63107 + __insert_acl_role_label(role, role->domain_children[i]);
63108 + } else
63109 + __insert_acl_role_label(role, role->uidgid);
63110 +}
63111 +
63112 +static int
63113 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
63114 +{
63115 + struct name_entry **curr, *nentry;
63116 + struct inodev_entry *ientry;
63117 + unsigned int len = strlen(name);
63118 + unsigned int key = full_name_hash(name, len);
63119 + unsigned int index = key % name_set.n_size;
63120 +
63121 + curr = &name_set.n_hash[index];
63122 +
63123 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
63124 + curr = &((*curr)->next);
63125 +
63126 + if (*curr != NULL)
63127 + return 1;
63128 +
63129 + nentry = acl_alloc(sizeof (struct name_entry));
63130 + if (nentry == NULL)
63131 + return 0;
63132 + ientry = acl_alloc(sizeof (struct inodev_entry));
63133 + if (ientry == NULL)
63134 + return 0;
63135 + ientry->nentry = nentry;
63136 +
63137 + nentry->key = key;
63138 + nentry->name = name;
63139 + nentry->inode = inode;
63140 + nentry->device = device;
63141 + nentry->len = len;
63142 + nentry->deleted = deleted;
63143 +
63144 + nentry->prev = NULL;
63145 + curr = &name_set.n_hash[index];
63146 + if (*curr != NULL)
63147 + (*curr)->prev = nentry;
63148 + nentry->next = *curr;
63149 + *curr = nentry;
63150 +
63151 + /* insert us into the table searchable by inode/dev */
63152 + insert_inodev_entry(ientry);
63153 +
63154 + return 1;
63155 +}
63156 +
63157 +static void
63158 +insert_acl_obj_label(struct acl_object_label *obj,
63159 + struct acl_subject_label *subj)
63160 +{
63161 + unsigned int index =
63162 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
63163 + struct acl_object_label **curr;
63164 +
63165 +
63166 + obj->prev = NULL;
63167 +
63168 + curr = &subj->obj_hash[index];
63169 + if (*curr != NULL)
63170 + (*curr)->prev = obj;
63171 +
63172 + obj->next = *curr;
63173 + *curr = obj;
63174 +
63175 + return;
63176 +}
63177 +
63178 +static void
63179 +insert_acl_subj_label(struct acl_subject_label *obj,
63180 + struct acl_role_label *role)
63181 +{
63182 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
63183 + struct acl_subject_label **curr;
63184 +
63185 + obj->prev = NULL;
63186 +
63187 + curr = &role->subj_hash[index];
63188 + if (*curr != NULL)
63189 + (*curr)->prev = obj;
63190 +
63191 + obj->next = *curr;
63192 + *curr = obj;
63193 +
63194 + return;
63195 +}
63196 +
63197 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
63198 +
63199 +static void *
63200 +create_table(__u32 * len, int elementsize)
63201 +{
63202 + unsigned int table_sizes[] = {
63203 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
63204 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
63205 + 4194301, 8388593, 16777213, 33554393, 67108859
63206 + };
63207 + void *newtable = NULL;
63208 + unsigned int pwr = 0;
63209 +
63210 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
63211 + table_sizes[pwr] <= *len)
63212 + pwr++;
63213 +
63214 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
63215 + return newtable;
63216 +
63217 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
63218 + newtable =
63219 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
63220 + else
63221 + newtable = vmalloc(table_sizes[pwr] * elementsize);
63222 +
63223 + *len = table_sizes[pwr];
63224 +
63225 + return newtable;
63226 +}
63227 +
63228 +static int
63229 +init_variables(const struct gr_arg *arg)
63230 +{
63231 + struct task_struct *reaper = init_pid_ns.child_reaper;
63232 + unsigned int stacksize;
63233 +
63234 + subj_map_set.s_size = arg->role_db.num_subjects;
63235 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
63236 + name_set.n_size = arg->role_db.num_objects;
63237 + inodev_set.i_size = arg->role_db.num_objects;
63238 +
63239 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
63240 + !name_set.n_size || !inodev_set.i_size)
63241 + return 1;
63242 +
63243 + if (!gr_init_uidset())
63244 + return 1;
63245 +
63246 + /* set up the stack that holds allocation info */
63247 +
63248 + stacksize = arg->role_db.num_pointers + 5;
63249 +
63250 + if (!acl_alloc_stack_init(stacksize))
63251 + return 1;
63252 +
63253 + /* grab reference for the real root dentry and vfsmount */
63254 + get_fs_root(reaper->fs, &real_root);
63255 +
63256 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63257 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
63258 +#endif
63259 +
63260 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
63261 + if (fakefs_obj_rw == NULL)
63262 + return 1;
63263 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
63264 +
63265 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
63266 + if (fakefs_obj_rwx == NULL)
63267 + return 1;
63268 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
63269 +
63270 + subj_map_set.s_hash =
63271 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
63272 + acl_role_set.r_hash =
63273 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
63274 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
63275 + inodev_set.i_hash =
63276 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
63277 +
63278 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
63279 + !name_set.n_hash || !inodev_set.i_hash)
63280 + return 1;
63281 +
63282 + memset(subj_map_set.s_hash, 0,
63283 + sizeof(struct subject_map *) * subj_map_set.s_size);
63284 + memset(acl_role_set.r_hash, 0,
63285 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
63286 + memset(name_set.n_hash, 0,
63287 + sizeof (struct name_entry *) * name_set.n_size);
63288 + memset(inodev_set.i_hash, 0,
63289 + sizeof (struct inodev_entry *) * inodev_set.i_size);
63290 +
63291 + return 0;
63292 +}
63293 +
63294 +/* free information not needed after startup
63295 + currently contains user->kernel pointer mappings for subjects
63296 +*/
63297 +
63298 +static void
63299 +free_init_variables(void)
63300 +{
63301 + __u32 i;
63302 +
63303 + if (subj_map_set.s_hash) {
63304 + for (i = 0; i < subj_map_set.s_size; i++) {
63305 + if (subj_map_set.s_hash[i]) {
63306 + kfree(subj_map_set.s_hash[i]);
63307 + subj_map_set.s_hash[i] = NULL;
63308 + }
63309 + }
63310 +
63311 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
63312 + PAGE_SIZE)
63313 + kfree(subj_map_set.s_hash);
63314 + else
63315 + vfree(subj_map_set.s_hash);
63316 + }
63317 +
63318 + return;
63319 +}
63320 +
63321 +static void
63322 +free_variables(void)
63323 +{
63324 + struct acl_subject_label *s;
63325 + struct acl_role_label *r;
63326 + struct task_struct *task, *task2;
63327 + unsigned int x;
63328 +
63329 + gr_clear_learn_entries();
63330 +
63331 + read_lock(&tasklist_lock);
63332 + do_each_thread(task2, task) {
63333 + task->acl_sp_role = 0;
63334 + task->acl_role_id = 0;
63335 + task->acl = NULL;
63336 + task->role = NULL;
63337 + } while_each_thread(task2, task);
63338 + read_unlock(&tasklist_lock);
63339 +
63340 + /* release the reference to the real root dentry and vfsmount */
63341 + path_put(&real_root);
63342 + memset(&real_root, 0, sizeof(real_root));
63343 +
63344 + /* free all object hash tables */
63345 +
63346 + FOR_EACH_ROLE_START(r)
63347 + if (r->subj_hash == NULL)
63348 + goto next_role;
63349 + FOR_EACH_SUBJECT_START(r, s, x)
63350 + if (s->obj_hash == NULL)
63351 + break;
63352 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63353 + kfree(s->obj_hash);
63354 + else
63355 + vfree(s->obj_hash);
63356 + FOR_EACH_SUBJECT_END(s, x)
63357 + FOR_EACH_NESTED_SUBJECT_START(r, s)
63358 + if (s->obj_hash == NULL)
63359 + break;
63360 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63361 + kfree(s->obj_hash);
63362 + else
63363 + vfree(s->obj_hash);
63364 + FOR_EACH_NESTED_SUBJECT_END(s)
63365 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
63366 + kfree(r->subj_hash);
63367 + else
63368 + vfree(r->subj_hash);
63369 + r->subj_hash = NULL;
63370 +next_role:
63371 + FOR_EACH_ROLE_END(r)
63372 +
63373 + acl_free_all();
63374 +
63375 + if (acl_role_set.r_hash) {
63376 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
63377 + PAGE_SIZE)
63378 + kfree(acl_role_set.r_hash);
63379 + else
63380 + vfree(acl_role_set.r_hash);
63381 + }
63382 + if (name_set.n_hash) {
63383 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
63384 + PAGE_SIZE)
63385 + kfree(name_set.n_hash);
63386 + else
63387 + vfree(name_set.n_hash);
63388 + }
63389 +
63390 + if (inodev_set.i_hash) {
63391 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
63392 + PAGE_SIZE)
63393 + kfree(inodev_set.i_hash);
63394 + else
63395 + vfree(inodev_set.i_hash);
63396 + }
63397 +
63398 + gr_free_uidset();
63399 +
63400 + memset(&name_set, 0, sizeof (struct name_db));
63401 + memset(&inodev_set, 0, sizeof (struct inodev_db));
63402 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
63403 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
63404 +
63405 + default_role = NULL;
63406 + kernel_role = NULL;
63407 + role_list = NULL;
63408 +
63409 + return;
63410 +}
63411 +
63412 +static struct acl_subject_label *
63413 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
63414 +
63415 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
63416 +{
63417 + unsigned int len = strnlen_user(*name, maxlen);
63418 + char *tmp;
63419 +
63420 + if (!len || len >= maxlen)
63421 + return -EINVAL;
63422 +
63423 + if ((tmp = (char *) acl_alloc(len)) == NULL)
63424 + return -ENOMEM;
63425 +
63426 + if (copy_from_user(tmp, *name, len))
63427 + return -EFAULT;
63428 +
63429 + tmp[len-1] = '\0';
63430 + *name = tmp;
63431 +
63432 + return 0;
63433 +}
63434 +
63435 +static int
63436 +copy_user_glob(struct acl_object_label *obj)
63437 +{
63438 + struct acl_object_label *g_tmp, **guser;
63439 + int error;
63440 +
63441 + if (obj->globbed == NULL)
63442 + return 0;
63443 +
63444 + guser = &obj->globbed;
63445 + while (*guser) {
63446 + g_tmp = (struct acl_object_label *)
63447 + acl_alloc(sizeof (struct acl_object_label));
63448 + if (g_tmp == NULL)
63449 + return -ENOMEM;
63450 +
63451 + if (copy_acl_object_label(g_tmp, *guser))
63452 + return -EFAULT;
63453 +
63454 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
63455 + if (error)
63456 + return error;
63457 +
63458 + *guser = g_tmp;
63459 + guser = &(g_tmp->next);
63460 + }
63461 +
63462 + return 0;
63463 +}
63464 +
63465 +static int
63466 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
63467 + struct acl_role_label *role)
63468 +{
63469 + struct acl_object_label *o_tmp;
63470 + int ret;
63471 +
63472 + while (userp) {
63473 + if ((o_tmp = (struct acl_object_label *)
63474 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
63475 + return -ENOMEM;
63476 +
63477 + if (copy_acl_object_label(o_tmp, userp))
63478 + return -EFAULT;
63479 +
63480 + userp = o_tmp->prev;
63481 +
63482 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
63483 + if (ret)
63484 + return ret;
63485 +
63486 + insert_acl_obj_label(o_tmp, subj);
63487 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
63488 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
63489 + return -ENOMEM;
63490 +
63491 + ret = copy_user_glob(o_tmp);
63492 + if (ret)
63493 + return ret;
63494 +
63495 + if (o_tmp->nested) {
63496 + int already_copied;
63497 +
63498 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
63499 + if (IS_ERR(o_tmp->nested))
63500 + return PTR_ERR(o_tmp->nested);
63501 +
63502 + /* insert into nested subject list if we haven't copied this one yet
63503 + to prevent duplicate entries */
63504 + if (!already_copied) {
63505 + o_tmp->nested->next = role->hash->first;
63506 + role->hash->first = o_tmp->nested;
63507 + }
63508 + }
63509 + }
63510 +
63511 + return 0;
63512 +}
63513 +
63514 +static __u32
63515 +count_user_subjs(struct acl_subject_label *userp)
63516 +{
63517 + struct acl_subject_label s_tmp;
63518 + __u32 num = 0;
63519 +
63520 + while (userp) {
63521 + if (copy_acl_subject_label(&s_tmp, userp))
63522 + break;
63523 +
63524 + userp = s_tmp.prev;
63525 + }
63526 +
63527 + return num;
63528 +}
63529 +
63530 +static int
63531 +copy_user_allowedips(struct acl_role_label *rolep)
63532 +{
63533 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
63534 +
63535 + ruserip = rolep->allowed_ips;
63536 +
63537 + while (ruserip) {
63538 + rlast = rtmp;
63539 +
63540 + if ((rtmp = (struct role_allowed_ip *)
63541 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
63542 + return -ENOMEM;
63543 +
63544 + if (copy_role_allowed_ip(rtmp, ruserip))
63545 + return -EFAULT;
63546 +
63547 + ruserip = rtmp->prev;
63548 +
63549 + if (!rlast) {
63550 + rtmp->prev = NULL;
63551 + rolep->allowed_ips = rtmp;
63552 + } else {
63553 + rlast->next = rtmp;
63554 + rtmp->prev = rlast;
63555 + }
63556 +
63557 + if (!ruserip)
63558 + rtmp->next = NULL;
63559 + }
63560 +
63561 + return 0;
63562 +}
63563 +
63564 +static int
63565 +copy_user_transitions(struct acl_role_label *rolep)
63566 +{
63567 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
63568 + int error;
63569 +
63570 + rusertp = rolep->transitions;
63571 +
63572 + while (rusertp) {
63573 + rlast = rtmp;
63574 +
63575 + if ((rtmp = (struct role_transition *)
63576 + acl_alloc(sizeof (struct role_transition))) == NULL)
63577 + return -ENOMEM;
63578 +
63579 + if (copy_role_transition(rtmp, rusertp))
63580 + return -EFAULT;
63581 +
63582 + rusertp = rtmp->prev;
63583 +
63584 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
63585 + if (error)
63586 + return error;
63587 +
63588 + if (!rlast) {
63589 + rtmp->prev = NULL;
63590 + rolep->transitions = rtmp;
63591 + } else {
63592 + rlast->next = rtmp;
63593 + rtmp->prev = rlast;
63594 + }
63595 +
63596 + if (!rusertp)
63597 + rtmp->next = NULL;
63598 + }
63599 +
63600 + return 0;
63601 +}
63602 +
63603 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
63604 +{
63605 + struct acl_object_label o_tmp;
63606 + __u32 num = 0;
63607 +
63608 + while (userp) {
63609 + if (copy_acl_object_label(&o_tmp, userp))
63610 + break;
63611 +
63612 + userp = o_tmp.prev;
63613 + num++;
63614 + }
63615 +
63616 + return num;
63617 +}
63618 +
63619 +static struct acl_subject_label *
63620 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
63621 +{
63622 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
63623 + __u32 num_objs;
63624 + struct acl_ip_label **i_tmp, *i_utmp2;
63625 + struct gr_hash_struct ghash;
63626 + struct subject_map *subjmap;
63627 + unsigned int i_num;
63628 + int err;
63629 +
63630 + if (already_copied != NULL)
63631 + *already_copied = 0;
63632 +
63633 + s_tmp = lookup_subject_map(userp);
63634 +
63635 + /* we've already copied this subject into the kernel, just return
63636 + the reference to it, and don't copy it over again
63637 + */
63638 + if (s_tmp) {
63639 + if (already_copied != NULL)
63640 + *already_copied = 1;
63641 + return(s_tmp);
63642 + }
63643 +
63644 + if ((s_tmp = (struct acl_subject_label *)
63645 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
63646 + return ERR_PTR(-ENOMEM);
63647 +
63648 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
63649 + if (subjmap == NULL)
63650 + return ERR_PTR(-ENOMEM);
63651 +
63652 + subjmap->user = userp;
63653 + subjmap->kernel = s_tmp;
63654 + insert_subj_map_entry(subjmap);
63655 +
63656 + if (copy_acl_subject_label(s_tmp, userp))
63657 + return ERR_PTR(-EFAULT);
63658 +
63659 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
63660 + if (err)
63661 + return ERR_PTR(err);
63662 +
63663 + if (!strcmp(s_tmp->filename, "/"))
63664 + role->root_label = s_tmp;
63665 +
63666 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
63667 + return ERR_PTR(-EFAULT);
63668 +
63669 + /* copy user and group transition tables */
63670 +
63671 + if (s_tmp->user_trans_num) {
63672 + uid_t *uidlist;
63673 +
63674 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
63675 + if (uidlist == NULL)
63676 + return ERR_PTR(-ENOMEM);
63677 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
63678 + return ERR_PTR(-EFAULT);
63679 +
63680 + s_tmp->user_transitions = uidlist;
63681 + }
63682 +
63683 + if (s_tmp->group_trans_num) {
63684 + gid_t *gidlist;
63685 +
63686 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
63687 + if (gidlist == NULL)
63688 + return ERR_PTR(-ENOMEM);
63689 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
63690 + return ERR_PTR(-EFAULT);
63691 +
63692 + s_tmp->group_transitions = gidlist;
63693 + }
63694 +
63695 + /* set up object hash table */
63696 + num_objs = count_user_objs(ghash.first);
63697 +
63698 + s_tmp->obj_hash_size = num_objs;
63699 + s_tmp->obj_hash =
63700 + (struct acl_object_label **)
63701 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
63702 +
63703 + if (!s_tmp->obj_hash)
63704 + return ERR_PTR(-ENOMEM);
63705 +
63706 + memset(s_tmp->obj_hash, 0,
63707 + s_tmp->obj_hash_size *
63708 + sizeof (struct acl_object_label *));
63709 +
63710 + /* add in objects */
63711 + err = copy_user_objs(ghash.first, s_tmp, role);
63712 +
63713 + if (err)
63714 + return ERR_PTR(err);
63715 +
63716 + /* set pointer for parent subject */
63717 + if (s_tmp->parent_subject) {
63718 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
63719 +
63720 + if (IS_ERR(s_tmp2))
63721 + return s_tmp2;
63722 +
63723 + s_tmp->parent_subject = s_tmp2;
63724 + }
63725 +
63726 + /* add in ip acls */
63727 +
63728 + if (!s_tmp->ip_num) {
63729 + s_tmp->ips = NULL;
63730 + goto insert;
63731 + }
63732 +
63733 + i_tmp =
63734 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
63735 + sizeof (struct acl_ip_label *));
63736 +
63737 + if (!i_tmp)
63738 + return ERR_PTR(-ENOMEM);
63739 +
63740 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
63741 + *(i_tmp + i_num) =
63742 + (struct acl_ip_label *)
63743 + acl_alloc(sizeof (struct acl_ip_label));
63744 + if (!*(i_tmp + i_num))
63745 + return ERR_PTR(-ENOMEM);
63746 +
63747 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
63748 + return ERR_PTR(-EFAULT);
63749 +
63750 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
63751 + return ERR_PTR(-EFAULT);
63752 +
63753 + if ((*(i_tmp + i_num))->iface == NULL)
63754 + continue;
63755 +
63756 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
63757 + if (err)
63758 + return ERR_PTR(err);
63759 + }
63760 +
63761 + s_tmp->ips = i_tmp;
63762 +
63763 +insert:
63764 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
63765 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
63766 + return ERR_PTR(-ENOMEM);
63767 +
63768 + return s_tmp;
63769 +}
63770 +
63771 +static int
63772 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
63773 +{
63774 + struct acl_subject_label s_pre;
63775 + struct acl_subject_label * ret;
63776 + int err;
63777 +
63778 + while (userp) {
63779 + if (copy_acl_subject_label(&s_pre, userp))
63780 + return -EFAULT;
63781 +
63782 + ret = do_copy_user_subj(userp, role, NULL);
63783 +
63784 + err = PTR_ERR(ret);
63785 + if (IS_ERR(ret))
63786 + return err;
63787 +
63788 + insert_acl_subj_label(ret, role);
63789 +
63790 + userp = s_pre.prev;
63791 + }
63792 +
63793 + return 0;
63794 +}
63795 +
63796 +static int
63797 +copy_user_acl(struct gr_arg *arg)
63798 +{
63799 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
63800 + struct acl_subject_label *subj_list;
63801 + struct sprole_pw *sptmp;
63802 + struct gr_hash_struct *ghash;
63803 + uid_t *domainlist;
63804 + unsigned int r_num;
63805 + int err = 0;
63806 + __u16 i;
63807 + __u32 num_subjs;
63808 +
63809 + /* we need a default and kernel role */
63810 + if (arg->role_db.num_roles < 2)
63811 + return -EINVAL;
63812 +
63813 + /* copy special role authentication info from userspace */
63814 +
63815 + num_sprole_pws = arg->num_sprole_pws;
63816 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
63817 +
63818 + if (!acl_special_roles && num_sprole_pws)
63819 + return -ENOMEM;
63820 +
63821 + for (i = 0; i < num_sprole_pws; i++) {
63822 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
63823 + if (!sptmp)
63824 + return -ENOMEM;
63825 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
63826 + return -EFAULT;
63827 +
63828 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
63829 + if (err)
63830 + return err;
63831 +
63832 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63833 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
63834 +#endif
63835 +
63836 + acl_special_roles[i] = sptmp;
63837 + }
63838 +
63839 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
63840 +
63841 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
63842 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
63843 +
63844 + if (!r_tmp)
63845 + return -ENOMEM;
63846 +
63847 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
63848 + return -EFAULT;
63849 +
63850 + if (copy_acl_role_label(r_tmp, r_utmp2))
63851 + return -EFAULT;
63852 +
63853 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
63854 + if (err)
63855 + return err;
63856 +
63857 + if (!strcmp(r_tmp->rolename, "default")
63858 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
63859 + default_role = r_tmp;
63860 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
63861 + kernel_role = r_tmp;
63862 + }
63863 +
63864 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
63865 + return -ENOMEM;
63866 +
63867 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
63868 + return -EFAULT;
63869 +
63870 + r_tmp->hash = ghash;
63871 +
63872 + num_subjs = count_user_subjs(r_tmp->hash->first);
63873 +
63874 + r_tmp->subj_hash_size = num_subjs;
63875 + r_tmp->subj_hash =
63876 + (struct acl_subject_label **)
63877 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
63878 +
63879 + if (!r_tmp->subj_hash)
63880 + return -ENOMEM;
63881 +
63882 + err = copy_user_allowedips(r_tmp);
63883 + if (err)
63884 + return err;
63885 +
63886 + /* copy domain info */
63887 + if (r_tmp->domain_children != NULL) {
63888 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
63889 + if (domainlist == NULL)
63890 + return -ENOMEM;
63891 +
63892 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
63893 + return -EFAULT;
63894 +
63895 + r_tmp->domain_children = domainlist;
63896 + }
63897 +
63898 + err = copy_user_transitions(r_tmp);
63899 + if (err)
63900 + return err;
63901 +
63902 + memset(r_tmp->subj_hash, 0,
63903 + r_tmp->subj_hash_size *
63904 + sizeof (struct acl_subject_label *));
63905 +
63906 + /* acquire the list of subjects, then NULL out
63907 + the list prior to parsing the subjects for this role,
63908 + as during this parsing the list is replaced with a list
63909 + of *nested* subjects for the role
63910 + */
63911 + subj_list = r_tmp->hash->first;
63912 +
63913 + /* set nested subject list to null */
63914 + r_tmp->hash->first = NULL;
63915 +
63916 + err = copy_user_subjs(subj_list, r_tmp);
63917 +
63918 + if (err)
63919 + return err;
63920 +
63921 + insert_acl_role_label(r_tmp);
63922 + }
63923 +
63924 + if (default_role == NULL || kernel_role == NULL)
63925 + return -EINVAL;
63926 +
63927 + return err;
63928 +}
63929 +
63930 +static int
63931 +gracl_init(struct gr_arg *args)
63932 +{
63933 + int error = 0;
63934 +
63935 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
63936 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
63937 +
63938 + if (init_variables(args)) {
63939 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
63940 + error = -ENOMEM;
63941 + free_variables();
63942 + goto out;
63943 + }
63944 +
63945 + error = copy_user_acl(args);
63946 + free_init_variables();
63947 + if (error) {
63948 + free_variables();
63949 + goto out;
63950 + }
63951 +
63952 + if ((error = gr_set_acls(0))) {
63953 + free_variables();
63954 + goto out;
63955 + }
63956 +
63957 + pax_open_kernel();
63958 + gr_status |= GR_READY;
63959 + pax_close_kernel();
63960 +
63961 + out:
63962 + return error;
63963 +}
63964 +
63965 +/* derived from glibc fnmatch() 0: match, 1: no match*/
63966 +
63967 +static int
63968 +glob_match(const char *p, const char *n)
63969 +{
63970 + char c;
63971 +
63972 + while ((c = *p++) != '\0') {
63973 + switch (c) {
63974 + case '?':
63975 + if (*n == '\0')
63976 + return 1;
63977 + else if (*n == '/')
63978 + return 1;
63979 + break;
63980 + case '\\':
63981 + if (*n != c)
63982 + return 1;
63983 + break;
63984 + case '*':
63985 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
63986 + if (*n == '/')
63987 + return 1;
63988 + else if (c == '?') {
63989 + if (*n == '\0')
63990 + return 1;
63991 + else
63992 + ++n;
63993 + }
63994 + }
63995 + if (c == '\0') {
63996 + return 0;
63997 + } else {
63998 + const char *endp;
63999 +
64000 + if ((endp = strchr(n, '/')) == NULL)
64001 + endp = n + strlen(n);
64002 +
64003 + if (c == '[') {
64004 + for (--p; n < endp; ++n)
64005 + if (!glob_match(p, n))
64006 + return 0;
64007 + } else if (c == '/') {
64008 + while (*n != '\0' && *n != '/')
64009 + ++n;
64010 + if (*n == '/' && !glob_match(p, n + 1))
64011 + return 0;
64012 + } else {
64013 + for (--p; n < endp; ++n)
64014 + if (*n == c && !glob_match(p, n))
64015 + return 0;
64016 + }
64017 +
64018 + return 1;
64019 + }
64020 + case '[':
64021 + {
64022 + int not;
64023 + char cold;
64024 +
64025 + if (*n == '\0' || *n == '/')
64026 + return 1;
64027 +
64028 + not = (*p == '!' || *p == '^');
64029 + if (not)
64030 + ++p;
64031 +
64032 + c = *p++;
64033 + for (;;) {
64034 + unsigned char fn = (unsigned char)*n;
64035 +
64036 + if (c == '\0')
64037 + return 1;
64038 + else {
64039 + if (c == fn)
64040 + goto matched;
64041 + cold = c;
64042 + c = *p++;
64043 +
64044 + if (c == '-' && *p != ']') {
64045 + unsigned char cend = *p++;
64046 +
64047 + if (cend == '\0')
64048 + return 1;
64049 +
64050 + if (cold <= fn && fn <= cend)
64051 + goto matched;
64052 +
64053 + c = *p++;
64054 + }
64055 + }
64056 +
64057 + if (c == ']')
64058 + break;
64059 + }
64060 + if (!not)
64061 + return 1;
64062 + break;
64063 + matched:
64064 + while (c != ']') {
64065 + if (c == '\0')
64066 + return 1;
64067 +
64068 + c = *p++;
64069 + }
64070 + if (not)
64071 + return 1;
64072 + }
64073 + break;
64074 + default:
64075 + if (c != *n)
64076 + return 1;
64077 + }
64078 +
64079 + ++n;
64080 + }
64081 +
64082 + if (*n == '\0')
64083 + return 0;
64084 +
64085 + if (*n == '/')
64086 + return 0;
64087 +
64088 + return 1;
64089 +}
64090 +
64091 +static struct acl_object_label *
64092 +chk_glob_label(struct acl_object_label *globbed,
64093 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
64094 +{
64095 + struct acl_object_label *tmp;
64096 +
64097 + if (*path == NULL)
64098 + *path = gr_to_filename_nolock(dentry, mnt);
64099 +
64100 + tmp = globbed;
64101 +
64102 + while (tmp) {
64103 + if (!glob_match(tmp->filename, *path))
64104 + return tmp;
64105 + tmp = tmp->next;
64106 + }
64107 +
64108 + return NULL;
64109 +}
64110 +
64111 +static struct acl_object_label *
64112 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64113 + const ino_t curr_ino, const dev_t curr_dev,
64114 + const struct acl_subject_label *subj, char **path, const int checkglob)
64115 +{
64116 + struct acl_subject_label *tmpsubj;
64117 + struct acl_object_label *retval;
64118 + struct acl_object_label *retval2;
64119 +
64120 + tmpsubj = (struct acl_subject_label *) subj;
64121 + read_lock(&gr_inode_lock);
64122 + do {
64123 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
64124 + if (retval) {
64125 + if (checkglob && retval->globbed) {
64126 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
64127 + if (retval2)
64128 + retval = retval2;
64129 + }
64130 + break;
64131 + }
64132 + } while ((tmpsubj = tmpsubj->parent_subject));
64133 + read_unlock(&gr_inode_lock);
64134 +
64135 + return retval;
64136 +}
64137 +
64138 +static __inline__ struct acl_object_label *
64139 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64140 + struct dentry *curr_dentry,
64141 + const struct acl_subject_label *subj, char **path, const int checkglob)
64142 +{
64143 + int newglob = checkglob;
64144 + ino_t inode;
64145 + dev_t device;
64146 +
64147 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
64148 + as we don't want a / * rule to match instead of the / object
64149 + don't do this for create lookups that call this function though, since they're looking up
64150 + on the parent and thus need globbing checks on all paths
64151 + */
64152 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
64153 + newglob = GR_NO_GLOB;
64154 +
64155 + spin_lock(&curr_dentry->d_lock);
64156 + inode = curr_dentry->d_inode->i_ino;
64157 + device = __get_dev(curr_dentry);
64158 + spin_unlock(&curr_dentry->d_lock);
64159 +
64160 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
64161 +}
64162 +
64163 +#ifdef CONFIG_HUGETLBFS
64164 +static inline bool
64165 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
64166 +{
64167 + int i;
64168 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
64169 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
64170 + return true;
64171 + }
64172 +
64173 + return false;
64174 +}
64175 +#endif
64176 +
64177 +static struct acl_object_label *
64178 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64179 + const struct acl_subject_label *subj, char *path, const int checkglob)
64180 +{
64181 + struct dentry *dentry = (struct dentry *) l_dentry;
64182 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64183 + struct mount *real_mnt = real_mount(mnt);
64184 + struct acl_object_label *retval;
64185 + struct dentry *parent;
64186 +
64187 + br_read_lock(&vfsmount_lock);
64188 + write_seqlock(&rename_lock);
64189 +
64190 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
64191 +#ifdef CONFIG_NET
64192 + mnt == sock_mnt ||
64193 +#endif
64194 +#ifdef CONFIG_HUGETLBFS
64195 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64196 +#endif
64197 + /* ignore Eric Biederman */
64198 + IS_PRIVATE(l_dentry->d_inode))) {
64199 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64200 + goto out;
64201 + }
64202 +
64203 + for (;;) {
64204 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64205 + break;
64206 +
64207 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64208 + if (!mnt_has_parent(real_mnt))
64209 + break;
64210 +
64211 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64212 + if (retval != NULL)
64213 + goto out;
64214 +
64215 + dentry = real_mnt->mnt_mountpoint;
64216 + real_mnt = real_mnt->mnt_parent;
64217 + mnt = &real_mnt->mnt;
64218 + continue;
64219 + }
64220 +
64221 + parent = dentry->d_parent;
64222 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64223 + if (retval != NULL)
64224 + goto out;
64225 +
64226 + dentry = parent;
64227 + }
64228 +
64229 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64230 +
64231 + /* real_root is pinned so we don't have to hold a reference */
64232 + if (retval == NULL)
64233 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
64234 +out:
64235 + write_sequnlock(&rename_lock);
64236 + br_read_unlock(&vfsmount_lock);
64237 +
64238 + BUG_ON(retval == NULL);
64239 +
64240 + return retval;
64241 +}
64242 +
64243 +static __inline__ struct acl_object_label *
64244 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64245 + const struct acl_subject_label *subj)
64246 +{
64247 + char *path = NULL;
64248 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64249 +}
64250 +
64251 +static __inline__ struct acl_object_label *
64252 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64253 + const struct acl_subject_label *subj)
64254 +{
64255 + char *path = NULL;
64256 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64257 +}
64258 +
64259 +static __inline__ struct acl_object_label *
64260 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64261 + const struct acl_subject_label *subj, char *path)
64262 +{
64263 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64264 +}
64265 +
64266 +static struct acl_subject_label *
64267 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64268 + const struct acl_role_label *role)
64269 +{
64270 + struct dentry *dentry = (struct dentry *) l_dentry;
64271 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64272 + struct mount *real_mnt = real_mount(mnt);
64273 + struct acl_subject_label *retval;
64274 + struct dentry *parent;
64275 +
64276 + br_read_lock(&vfsmount_lock);
64277 + write_seqlock(&rename_lock);
64278 +
64279 + for (;;) {
64280 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64281 + break;
64282 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64283 + if (!mnt_has_parent(real_mnt))
64284 + break;
64285 +
64286 + spin_lock(&dentry->d_lock);
64287 + read_lock(&gr_inode_lock);
64288 + retval =
64289 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64290 + __get_dev(dentry), role);
64291 + read_unlock(&gr_inode_lock);
64292 + spin_unlock(&dentry->d_lock);
64293 + if (retval != NULL)
64294 + goto out;
64295 +
64296 + dentry = real_mnt->mnt_mountpoint;
64297 + real_mnt = real_mnt->mnt_parent;
64298 + mnt = &real_mnt->mnt;
64299 + continue;
64300 + }
64301 +
64302 + spin_lock(&dentry->d_lock);
64303 + read_lock(&gr_inode_lock);
64304 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64305 + __get_dev(dentry), role);
64306 + read_unlock(&gr_inode_lock);
64307 + parent = dentry->d_parent;
64308 + spin_unlock(&dentry->d_lock);
64309 +
64310 + if (retval != NULL)
64311 + goto out;
64312 +
64313 + dentry = parent;
64314 + }
64315 +
64316 + spin_lock(&dentry->d_lock);
64317 + read_lock(&gr_inode_lock);
64318 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64319 + __get_dev(dentry), role);
64320 + read_unlock(&gr_inode_lock);
64321 + spin_unlock(&dentry->d_lock);
64322 +
64323 + if (unlikely(retval == NULL)) {
64324 + /* real_root is pinned, we don't need to hold a reference */
64325 + read_lock(&gr_inode_lock);
64326 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
64327 + __get_dev(real_root.dentry), role);
64328 + read_unlock(&gr_inode_lock);
64329 + }
64330 +out:
64331 + write_sequnlock(&rename_lock);
64332 + br_read_unlock(&vfsmount_lock);
64333 +
64334 + BUG_ON(retval == NULL);
64335 +
64336 + return retval;
64337 +}
64338 +
64339 +static void
64340 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
64341 +{
64342 + struct task_struct *task = current;
64343 + const struct cred *cred = current_cred();
64344 +
64345 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64346 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64347 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64348 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64349 +
64350 + return;
64351 +}
64352 +
64353 +static void
64354 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64355 +{
64356 + struct task_struct *task = current;
64357 + const struct cred *cred = current_cred();
64358 +
64359 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64360 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64361 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64362 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64363 +
64364 + return;
64365 +}
64366 +
64367 +static void
64368 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64369 +{
64370 + struct task_struct *task = current;
64371 + const struct cred *cred = current_cred();
64372 +
64373 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64374 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64375 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64376 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64377 +
64378 + return;
64379 +}
64380 +
64381 +__u32
64382 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64383 + const struct vfsmount * mnt)
64384 +{
64385 + __u32 retval = mode;
64386 + struct acl_subject_label *curracl;
64387 + struct acl_object_label *currobj;
64388 +
64389 + if (unlikely(!(gr_status & GR_READY)))
64390 + return (mode & ~GR_AUDITS);
64391 +
64392 + curracl = current->acl;
64393 +
64394 + currobj = chk_obj_label(dentry, mnt, curracl);
64395 + retval = currobj->mode & mode;
64396 +
64397 + /* if we're opening a specified transfer file for writing
64398 + (e.g. /dev/initctl), then transfer our role to init
64399 + */
64400 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64401 + current->role->roletype & GR_ROLE_PERSIST)) {
64402 + struct task_struct *task = init_pid_ns.child_reaper;
64403 +
64404 + if (task->role != current->role) {
64405 + task->acl_sp_role = 0;
64406 + task->acl_role_id = current->acl_role_id;
64407 + task->role = current->role;
64408 + rcu_read_lock();
64409 + read_lock(&grsec_exec_file_lock);
64410 + gr_apply_subject_to_task(task);
64411 + read_unlock(&grsec_exec_file_lock);
64412 + rcu_read_unlock();
64413 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64414 + }
64415 + }
64416 +
64417 + if (unlikely
64418 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64419 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64420 + __u32 new_mode = mode;
64421 +
64422 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64423 +
64424 + retval = new_mode;
64425 +
64426 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64427 + new_mode |= GR_INHERIT;
64428 +
64429 + if (!(mode & GR_NOLEARN))
64430 + gr_log_learn(dentry, mnt, new_mode);
64431 + }
64432 +
64433 + return retval;
64434 +}
64435 +
64436 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64437 + const struct dentry *parent,
64438 + const struct vfsmount *mnt)
64439 +{
64440 + struct name_entry *match;
64441 + struct acl_object_label *matchpo;
64442 + struct acl_subject_label *curracl;
64443 + char *path;
64444 +
64445 + if (unlikely(!(gr_status & GR_READY)))
64446 + return NULL;
64447 +
64448 + preempt_disable();
64449 + path = gr_to_filename_rbac(new_dentry, mnt);
64450 + match = lookup_name_entry_create(path);
64451 +
64452 + curracl = current->acl;
64453 +
64454 + if (match) {
64455 + read_lock(&gr_inode_lock);
64456 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64457 + read_unlock(&gr_inode_lock);
64458 +
64459 + if (matchpo) {
64460 + preempt_enable();
64461 + return matchpo;
64462 + }
64463 + }
64464 +
64465 + // lookup parent
64466 +
64467 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64468 +
64469 + preempt_enable();
64470 + return matchpo;
64471 +}
64472 +
64473 +__u32
64474 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64475 + const struct vfsmount * mnt, const __u32 mode)
64476 +{
64477 + struct acl_object_label *matchpo;
64478 + __u32 retval;
64479 +
64480 + if (unlikely(!(gr_status & GR_READY)))
64481 + return (mode & ~GR_AUDITS);
64482 +
64483 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64484 +
64485 + retval = matchpo->mode & mode;
64486 +
64487 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64488 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64489 + __u32 new_mode = mode;
64490 +
64491 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64492 +
64493 + gr_log_learn(new_dentry, mnt, new_mode);
64494 + return new_mode;
64495 + }
64496 +
64497 + return retval;
64498 +}
64499 +
64500 +__u32
64501 +gr_check_link(const struct dentry * new_dentry,
64502 + const struct dentry * parent_dentry,
64503 + const struct vfsmount * parent_mnt,
64504 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64505 +{
64506 + struct acl_object_label *obj;
64507 + __u32 oldmode, newmode;
64508 + __u32 needmode;
64509 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64510 + GR_DELETE | GR_INHERIT;
64511 +
64512 + if (unlikely(!(gr_status & GR_READY)))
64513 + return (GR_CREATE | GR_LINK);
64514 +
64515 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64516 + oldmode = obj->mode;
64517 +
64518 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64519 + newmode = obj->mode;
64520 +
64521 + needmode = newmode & checkmodes;
64522 +
64523 + // old name for hardlink must have at least the permissions of the new name
64524 + if ((oldmode & needmode) != needmode)
64525 + goto bad;
64526 +
64527 + // if old name had restrictions/auditing, make sure the new name does as well
64528 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64529 +
64530 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64531 + if (is_privileged_binary(old_dentry))
64532 + needmode |= GR_SETID;
64533 +
64534 + if ((newmode & needmode) != needmode)
64535 + goto bad;
64536 +
64537 + // enforce minimum permissions
64538 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64539 + return newmode;
64540 +bad:
64541 + needmode = oldmode;
64542 + if (is_privileged_binary(old_dentry))
64543 + needmode |= GR_SETID;
64544 +
64545 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64546 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64547 + return (GR_CREATE | GR_LINK);
64548 + } else if (newmode & GR_SUPPRESS)
64549 + return GR_SUPPRESS;
64550 + else
64551 + return 0;
64552 +}
64553 +
64554 +int
64555 +gr_check_hidden_task(const struct task_struct *task)
64556 +{
64557 + if (unlikely(!(gr_status & GR_READY)))
64558 + return 0;
64559 +
64560 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64561 + return 1;
64562 +
64563 + return 0;
64564 +}
64565 +
64566 +int
64567 +gr_check_protected_task(const struct task_struct *task)
64568 +{
64569 + if (unlikely(!(gr_status & GR_READY) || !task))
64570 + return 0;
64571 +
64572 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64573 + task->acl != current->acl)
64574 + return 1;
64575 +
64576 + return 0;
64577 +}
64578 +
64579 +int
64580 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64581 +{
64582 + struct task_struct *p;
64583 + int ret = 0;
64584 +
64585 + if (unlikely(!(gr_status & GR_READY) || !pid))
64586 + return ret;
64587 +
64588 + read_lock(&tasklist_lock);
64589 + do_each_pid_task(pid, type, p) {
64590 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64591 + p->acl != current->acl) {
64592 + ret = 1;
64593 + goto out;
64594 + }
64595 + } while_each_pid_task(pid, type, p);
64596 +out:
64597 + read_unlock(&tasklist_lock);
64598 +
64599 + return ret;
64600 +}
64601 +
64602 +void
64603 +gr_copy_label(struct task_struct *tsk)
64604 +{
64605 + tsk->signal->used_accept = 0;
64606 + tsk->acl_sp_role = 0;
64607 + tsk->acl_role_id = current->acl_role_id;
64608 + tsk->acl = current->acl;
64609 + tsk->role = current->role;
64610 + tsk->signal->curr_ip = current->signal->curr_ip;
64611 + tsk->signal->saved_ip = current->signal->saved_ip;
64612 + if (current->exec_file)
64613 + get_file(current->exec_file);
64614 + tsk->exec_file = current->exec_file;
64615 + tsk->is_writable = current->is_writable;
64616 + if (unlikely(current->signal->used_accept)) {
64617 + current->signal->curr_ip = 0;
64618 + current->signal->saved_ip = 0;
64619 + }
64620 +
64621 + return;
64622 +}
64623 +
64624 +static void
64625 +gr_set_proc_res(struct task_struct *task)
64626 +{
64627 + struct acl_subject_label *proc;
64628 + unsigned short i;
64629 +
64630 + proc = task->acl;
64631 +
64632 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64633 + return;
64634 +
64635 + for (i = 0; i < RLIM_NLIMITS; i++) {
64636 + if (!(proc->resmask & (1U << i)))
64637 + continue;
64638 +
64639 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64640 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64641 +
64642 + if (i == RLIMIT_CPU)
64643 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64644 + }
64645 +
64646 + return;
64647 +}
64648 +
64649 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64650 +
64651 +int
64652 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64653 +{
64654 + unsigned int i;
64655 + __u16 num;
64656 + uid_t *uidlist;
64657 + uid_t curuid;
64658 + int realok = 0;
64659 + int effectiveok = 0;
64660 + int fsok = 0;
64661 + uid_t globalreal, globaleffective, globalfs;
64662 +
64663 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64664 + struct user_struct *user;
64665 +
64666 + if (!uid_valid(real))
64667 + goto skipit;
64668 +
64669 + /* find user based on global namespace */
64670 +
64671 + globalreal = GR_GLOBAL_UID(real);
64672 +
64673 + user = find_user(make_kuid(&init_user_ns, globalreal));
64674 + if (user == NULL)
64675 + goto skipit;
64676 +
64677 + if (gr_process_kernel_setuid_ban(user)) {
64678 + /* for find_user */
64679 + free_uid(user);
64680 + return 1;
64681 + }
64682 +
64683 + /* for find_user */
64684 + free_uid(user);
64685 +
64686 +skipit:
64687 +#endif
64688 +
64689 + if (unlikely(!(gr_status & GR_READY)))
64690 + return 0;
64691 +
64692 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64693 + gr_log_learn_uid_change(real, effective, fs);
64694 +
64695 + num = current->acl->user_trans_num;
64696 + uidlist = current->acl->user_transitions;
64697 +
64698 + if (uidlist == NULL)
64699 + return 0;
64700 +
64701 + if (!uid_valid(real)) {
64702 + realok = 1;
64703 + globalreal = (uid_t)-1;
64704 + } else {
64705 + globalreal = GR_GLOBAL_UID(real);
64706 + }
64707 + if (!uid_valid(effective)) {
64708 + effectiveok = 1;
64709 + globaleffective = (uid_t)-1;
64710 + } else {
64711 + globaleffective = GR_GLOBAL_UID(effective);
64712 + }
64713 + if (!uid_valid(fs)) {
64714 + fsok = 1;
64715 + globalfs = (uid_t)-1;
64716 + } else {
64717 + globalfs = GR_GLOBAL_UID(fs);
64718 + }
64719 +
64720 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64721 + for (i = 0; i < num; i++) {
64722 + curuid = uidlist[i];
64723 + if (globalreal == curuid)
64724 + realok = 1;
64725 + if (globaleffective == curuid)
64726 + effectiveok = 1;
64727 + if (globalfs == curuid)
64728 + fsok = 1;
64729 + }
64730 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64731 + for (i = 0; i < num; i++) {
64732 + curuid = uidlist[i];
64733 + if (globalreal == curuid)
64734 + break;
64735 + if (globaleffective == curuid)
64736 + break;
64737 + if (globalfs == curuid)
64738 + break;
64739 + }
64740 + /* not in deny list */
64741 + if (i == num) {
64742 + realok = 1;
64743 + effectiveok = 1;
64744 + fsok = 1;
64745 + }
64746 + }
64747 +
64748 + if (realok && effectiveok && fsok)
64749 + return 0;
64750 + else {
64751 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64752 + return 1;
64753 + }
64754 +}
64755 +
64756 +int
64757 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64758 +{
64759 + unsigned int i;
64760 + __u16 num;
64761 + gid_t *gidlist;
64762 + gid_t curgid;
64763 + int realok = 0;
64764 + int effectiveok = 0;
64765 + int fsok = 0;
64766 + gid_t globalreal, globaleffective, globalfs;
64767 +
64768 + if (unlikely(!(gr_status & GR_READY)))
64769 + return 0;
64770 +
64771 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64772 + gr_log_learn_gid_change(real, effective, fs);
64773 +
64774 + num = current->acl->group_trans_num;
64775 + gidlist = current->acl->group_transitions;
64776 +
64777 + if (gidlist == NULL)
64778 + return 0;
64779 +
64780 + if (!gid_valid(real)) {
64781 + realok = 1;
64782 + globalreal = (gid_t)-1;
64783 + } else {
64784 + globalreal = GR_GLOBAL_GID(real);
64785 + }
64786 + if (!gid_valid(effective)) {
64787 + effectiveok = 1;
64788 + globaleffective = (gid_t)-1;
64789 + } else {
64790 + globaleffective = GR_GLOBAL_GID(effective);
64791 + }
64792 + if (!gid_valid(fs)) {
64793 + fsok = 1;
64794 + globalfs = (gid_t)-1;
64795 + } else {
64796 + globalfs = GR_GLOBAL_GID(fs);
64797 + }
64798 +
64799 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64800 + for (i = 0; i < num; i++) {
64801 + curgid = gidlist[i];
64802 + if (globalreal == curgid)
64803 + realok = 1;
64804 + if (globaleffective == curgid)
64805 + effectiveok = 1;
64806 + if (globalfs == curgid)
64807 + fsok = 1;
64808 + }
64809 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64810 + for (i = 0; i < num; i++) {
64811 + curgid = gidlist[i];
64812 + if (globalreal == curgid)
64813 + break;
64814 + if (globaleffective == curgid)
64815 + break;
64816 + if (globalfs == curgid)
64817 + break;
64818 + }
64819 + /* not in deny list */
64820 + if (i == num) {
64821 + realok = 1;
64822 + effectiveok = 1;
64823 + fsok = 1;
64824 + }
64825 + }
64826 +
64827 + if (realok && effectiveok && fsok)
64828 + return 0;
64829 + else {
64830 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64831 + return 1;
64832 + }
64833 +}
64834 +
64835 +extern int gr_acl_is_capable(const int cap);
64836 +
64837 +void
64838 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64839 +{
64840 + struct acl_role_label *role = task->role;
64841 + struct acl_subject_label *subj = NULL;
64842 + struct acl_object_label *obj;
64843 + struct file *filp;
64844 + uid_t uid;
64845 + gid_t gid;
64846 +
64847 + if (unlikely(!(gr_status & GR_READY)))
64848 + return;
64849 +
64850 + uid = GR_GLOBAL_UID(kuid);
64851 + gid = GR_GLOBAL_GID(kgid);
64852 +
64853 + filp = task->exec_file;
64854 +
64855 + /* kernel process, we'll give them the kernel role */
64856 + if (unlikely(!filp)) {
64857 + task->role = kernel_role;
64858 + task->acl = kernel_role->root_label;
64859 + return;
64860 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
64861 + role = lookup_acl_role_label(task, uid, gid);
64862 +
64863 + /* don't change the role if we're not a privileged process */
64864 + if (role && task->role != role &&
64865 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64866 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64867 + return;
64868 +
64869 + /* perform subject lookup in possibly new role
64870 + we can use this result below in the case where role == task->role
64871 + */
64872 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64873 +
64874 + /* if we changed uid/gid, but result in the same role
64875 + and are using inheritance, don't lose the inherited subject
64876 + if current subject is other than what normal lookup
64877 + would result in, we arrived via inheritance, don't
64878 + lose subject
64879 + */
64880 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64881 + (subj == task->acl)))
64882 + task->acl = subj;
64883 +
64884 + task->role = role;
64885 +
64886 + task->is_writable = 0;
64887 +
64888 + /* ignore additional mmap checks for processes that are writable
64889 + by the default ACL */
64890 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64891 + if (unlikely(obj->mode & GR_WRITE))
64892 + task->is_writable = 1;
64893 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64894 + if (unlikely(obj->mode & GR_WRITE))
64895 + task->is_writable = 1;
64896 +
64897 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64898 + 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);
64899 +#endif
64900 +
64901 + gr_set_proc_res(task);
64902 +
64903 + return;
64904 +}
64905 +
64906 +int
64907 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64908 + const int unsafe_flags)
64909 +{
64910 + struct task_struct *task = current;
64911 + struct acl_subject_label *newacl;
64912 + struct acl_object_label *obj;
64913 + __u32 retmode;
64914 +
64915 + if (unlikely(!(gr_status & GR_READY)))
64916 + return 0;
64917 +
64918 + newacl = chk_subj_label(dentry, mnt, task->role);
64919 +
64920 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64921 + did an exec
64922 + */
64923 + rcu_read_lock();
64924 + read_lock(&tasklist_lock);
64925 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64926 + (task->parent->acl->mode & GR_POVERRIDE))) {
64927 + read_unlock(&tasklist_lock);
64928 + rcu_read_unlock();
64929 + goto skip_check;
64930 + }
64931 + read_unlock(&tasklist_lock);
64932 + rcu_read_unlock();
64933 +
64934 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64935 + !(task->role->roletype & GR_ROLE_GOD) &&
64936 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64937 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64938 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64939 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64940 + else
64941 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64942 + return -EACCES;
64943 + }
64944 +
64945 +skip_check:
64946 +
64947 + obj = chk_obj_label(dentry, mnt, task->acl);
64948 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64949 +
64950 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64951 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
64952 + if (obj->nested)
64953 + task->acl = obj->nested;
64954 + else
64955 + task->acl = newacl;
64956 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64957 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64958 +
64959 + task->is_writable = 0;
64960 +
64961 + /* ignore additional mmap checks for processes that are writable
64962 + by the default ACL */
64963 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
64964 + if (unlikely(obj->mode & GR_WRITE))
64965 + task->is_writable = 1;
64966 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64967 + if (unlikely(obj->mode & GR_WRITE))
64968 + task->is_writable = 1;
64969 +
64970 + gr_set_proc_res(task);
64971 +
64972 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64973 + 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);
64974 +#endif
64975 + return 0;
64976 +}
64977 +
64978 +/* always called with valid inodev ptr */
64979 +static void
64980 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64981 +{
64982 + struct acl_object_label *matchpo;
64983 + struct acl_subject_label *matchps;
64984 + struct acl_subject_label *subj;
64985 + struct acl_role_label *role;
64986 + unsigned int x;
64987 +
64988 + FOR_EACH_ROLE_START(role)
64989 + FOR_EACH_SUBJECT_START(role, subj, x)
64990 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64991 + matchpo->mode |= GR_DELETED;
64992 + FOR_EACH_SUBJECT_END(subj,x)
64993 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64994 + /* nested subjects aren't in the role's subj_hash table */
64995 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64996 + matchpo->mode |= GR_DELETED;
64997 + FOR_EACH_NESTED_SUBJECT_END(subj)
64998 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64999 + matchps->mode |= GR_DELETED;
65000 + FOR_EACH_ROLE_END(role)
65001 +
65002 + inodev->nentry->deleted = 1;
65003 +
65004 + return;
65005 +}
65006 +
65007 +void
65008 +gr_handle_delete(const ino_t ino, const dev_t dev)
65009 +{
65010 + struct inodev_entry *inodev;
65011 +
65012 + if (unlikely(!(gr_status & GR_READY)))
65013 + return;
65014 +
65015 + write_lock(&gr_inode_lock);
65016 + inodev = lookup_inodev_entry(ino, dev);
65017 + if (inodev != NULL)
65018 + do_handle_delete(inodev, ino, dev);
65019 + write_unlock(&gr_inode_lock);
65020 +
65021 + return;
65022 +}
65023 +
65024 +static void
65025 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
65026 + const ino_t newinode, const dev_t newdevice,
65027 + struct acl_subject_label *subj)
65028 +{
65029 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
65030 + struct acl_object_label *match;
65031 +
65032 + match = subj->obj_hash[index];
65033 +
65034 + while (match && (match->inode != oldinode ||
65035 + match->device != olddevice ||
65036 + !(match->mode & GR_DELETED)))
65037 + match = match->next;
65038 +
65039 + if (match && (match->inode == oldinode)
65040 + && (match->device == olddevice)
65041 + && (match->mode & GR_DELETED)) {
65042 + if (match->prev == NULL) {
65043 + subj->obj_hash[index] = match->next;
65044 + if (match->next != NULL)
65045 + match->next->prev = NULL;
65046 + } else {
65047 + match->prev->next = match->next;
65048 + if (match->next != NULL)
65049 + match->next->prev = match->prev;
65050 + }
65051 + match->prev = NULL;
65052 + match->next = NULL;
65053 + match->inode = newinode;
65054 + match->device = newdevice;
65055 + match->mode &= ~GR_DELETED;
65056 +
65057 + insert_acl_obj_label(match, subj);
65058 + }
65059 +
65060 + return;
65061 +}
65062 +
65063 +static void
65064 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
65065 + const ino_t newinode, const dev_t newdevice,
65066 + struct acl_role_label *role)
65067 +{
65068 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
65069 + struct acl_subject_label *match;
65070 +
65071 + match = role->subj_hash[index];
65072 +
65073 + while (match && (match->inode != oldinode ||
65074 + match->device != olddevice ||
65075 + !(match->mode & GR_DELETED)))
65076 + match = match->next;
65077 +
65078 + if (match && (match->inode == oldinode)
65079 + && (match->device == olddevice)
65080 + && (match->mode & GR_DELETED)) {
65081 + if (match->prev == NULL) {
65082 + role->subj_hash[index] = match->next;
65083 + if (match->next != NULL)
65084 + match->next->prev = NULL;
65085 + } else {
65086 + match->prev->next = match->next;
65087 + if (match->next != NULL)
65088 + match->next->prev = match->prev;
65089 + }
65090 + match->prev = NULL;
65091 + match->next = NULL;
65092 + match->inode = newinode;
65093 + match->device = newdevice;
65094 + match->mode &= ~GR_DELETED;
65095 +
65096 + insert_acl_subj_label(match, role);
65097 + }
65098 +
65099 + return;
65100 +}
65101 +
65102 +static void
65103 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
65104 + const ino_t newinode, const dev_t newdevice)
65105 +{
65106 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
65107 + struct inodev_entry *match;
65108 +
65109 + match = inodev_set.i_hash[index];
65110 +
65111 + while (match && (match->nentry->inode != oldinode ||
65112 + match->nentry->device != olddevice || !match->nentry->deleted))
65113 + match = match->next;
65114 +
65115 + if (match && (match->nentry->inode == oldinode)
65116 + && (match->nentry->device == olddevice) &&
65117 + match->nentry->deleted) {
65118 + if (match->prev == NULL) {
65119 + inodev_set.i_hash[index] = match->next;
65120 + if (match->next != NULL)
65121 + match->next->prev = NULL;
65122 + } else {
65123 + match->prev->next = match->next;
65124 + if (match->next != NULL)
65125 + match->next->prev = match->prev;
65126 + }
65127 + match->prev = NULL;
65128 + match->next = NULL;
65129 + match->nentry->inode = newinode;
65130 + match->nentry->device = newdevice;
65131 + match->nentry->deleted = 0;
65132 +
65133 + insert_inodev_entry(match);
65134 + }
65135 +
65136 + return;
65137 +}
65138 +
65139 +static void
65140 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
65141 +{
65142 + struct acl_subject_label *subj;
65143 + struct acl_role_label *role;
65144 + unsigned int x;
65145 +
65146 + FOR_EACH_ROLE_START(role)
65147 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
65148 +
65149 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65150 + if ((subj->inode == ino) && (subj->device == dev)) {
65151 + subj->inode = ino;
65152 + subj->device = dev;
65153 + }
65154 + /* nested subjects aren't in the role's subj_hash table */
65155 + update_acl_obj_label(matchn->inode, matchn->device,
65156 + ino, dev, subj);
65157 + FOR_EACH_NESTED_SUBJECT_END(subj)
65158 + FOR_EACH_SUBJECT_START(role, subj, x)
65159 + update_acl_obj_label(matchn->inode, matchn->device,
65160 + ino, dev, subj);
65161 + FOR_EACH_SUBJECT_END(subj,x)
65162 + FOR_EACH_ROLE_END(role)
65163 +
65164 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
65165 +
65166 + return;
65167 +}
65168 +
65169 +static void
65170 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
65171 + const struct vfsmount *mnt)
65172 +{
65173 + ino_t ino = dentry->d_inode->i_ino;
65174 + dev_t dev = __get_dev(dentry);
65175 +
65176 + __do_handle_create(matchn, ino, dev);
65177 +
65178 + return;
65179 +}
65180 +
65181 +void
65182 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65183 +{
65184 + struct name_entry *matchn;
65185 +
65186 + if (unlikely(!(gr_status & GR_READY)))
65187 + return;
65188 +
65189 + preempt_disable();
65190 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
65191 +
65192 + if (unlikely((unsigned long)matchn)) {
65193 + write_lock(&gr_inode_lock);
65194 + do_handle_create(matchn, dentry, mnt);
65195 + write_unlock(&gr_inode_lock);
65196 + }
65197 + preempt_enable();
65198 +
65199 + return;
65200 +}
65201 +
65202 +void
65203 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65204 +{
65205 + struct name_entry *matchn;
65206 +
65207 + if (unlikely(!(gr_status & GR_READY)))
65208 + return;
65209 +
65210 + preempt_disable();
65211 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
65212 +
65213 + if (unlikely((unsigned long)matchn)) {
65214 + write_lock(&gr_inode_lock);
65215 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
65216 + write_unlock(&gr_inode_lock);
65217 + }
65218 + preempt_enable();
65219 +
65220 + return;
65221 +}
65222 +
65223 +void
65224 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65225 + struct dentry *old_dentry,
65226 + struct dentry *new_dentry,
65227 + struct vfsmount *mnt, const __u8 replace)
65228 +{
65229 + struct name_entry *matchn;
65230 + struct inodev_entry *inodev;
65231 + struct inode *inode = new_dentry->d_inode;
65232 + ino_t old_ino = old_dentry->d_inode->i_ino;
65233 + dev_t old_dev = __get_dev(old_dentry);
65234 +
65235 + /* vfs_rename swaps the name and parent link for old_dentry and
65236 + new_dentry
65237 + at this point, old_dentry has the new name, parent link, and inode
65238 + for the renamed file
65239 + if a file is being replaced by a rename, new_dentry has the inode
65240 + and name for the replaced file
65241 + */
65242 +
65243 + if (unlikely(!(gr_status & GR_READY)))
65244 + return;
65245 +
65246 + preempt_disable();
65247 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65248 +
65249 + /* we wouldn't have to check d_inode if it weren't for
65250 + NFS silly-renaming
65251 + */
65252 +
65253 + write_lock(&gr_inode_lock);
65254 + if (unlikely(replace && inode)) {
65255 + ino_t new_ino = inode->i_ino;
65256 + dev_t new_dev = __get_dev(new_dentry);
65257 +
65258 + inodev = lookup_inodev_entry(new_ino, new_dev);
65259 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65260 + do_handle_delete(inodev, new_ino, new_dev);
65261 + }
65262 +
65263 + inodev = lookup_inodev_entry(old_ino, old_dev);
65264 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65265 + do_handle_delete(inodev, old_ino, old_dev);
65266 +
65267 + if (unlikely((unsigned long)matchn))
65268 + do_handle_create(matchn, old_dentry, mnt);
65269 +
65270 + write_unlock(&gr_inode_lock);
65271 + preempt_enable();
65272 +
65273 + return;
65274 +}
65275 +
65276 +static int
65277 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
65278 + unsigned char **sum)
65279 +{
65280 + struct acl_role_label *r;
65281 + struct role_allowed_ip *ipp;
65282 + struct role_transition *trans;
65283 + unsigned int i;
65284 + int found = 0;
65285 + u32 curr_ip = current->signal->curr_ip;
65286 +
65287 + current->signal->saved_ip = curr_ip;
65288 +
65289 + /* check transition table */
65290 +
65291 + for (trans = current->role->transitions; trans; trans = trans->next) {
65292 + if (!strcmp(rolename, trans->rolename)) {
65293 + found = 1;
65294 + break;
65295 + }
65296 + }
65297 +
65298 + if (!found)
65299 + return 0;
65300 +
65301 + /* handle special roles that do not require authentication
65302 + and check ip */
65303 +
65304 + FOR_EACH_ROLE_START(r)
65305 + if (!strcmp(rolename, r->rolename) &&
65306 + (r->roletype & GR_ROLE_SPECIAL)) {
65307 + found = 0;
65308 + if (r->allowed_ips != NULL) {
65309 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
65310 + if ((ntohl(curr_ip) & ipp->netmask) ==
65311 + (ntohl(ipp->addr) & ipp->netmask))
65312 + found = 1;
65313 + }
65314 + } else
65315 + found = 2;
65316 + if (!found)
65317 + return 0;
65318 +
65319 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
65320 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
65321 + *salt = NULL;
65322 + *sum = NULL;
65323 + return 1;
65324 + }
65325 + }
65326 + FOR_EACH_ROLE_END(r)
65327 +
65328 + for (i = 0; i < num_sprole_pws; i++) {
65329 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
65330 + *salt = acl_special_roles[i]->salt;
65331 + *sum = acl_special_roles[i]->sum;
65332 + return 1;
65333 + }
65334 + }
65335 +
65336 + return 0;
65337 +}
65338 +
65339 +static void
65340 +assign_special_role(char *rolename)
65341 +{
65342 + struct acl_object_label *obj;
65343 + struct acl_role_label *r;
65344 + struct acl_role_label *assigned = NULL;
65345 + struct task_struct *tsk;
65346 + struct file *filp;
65347 +
65348 + FOR_EACH_ROLE_START(r)
65349 + if (!strcmp(rolename, r->rolename) &&
65350 + (r->roletype & GR_ROLE_SPECIAL)) {
65351 + assigned = r;
65352 + break;
65353 + }
65354 + FOR_EACH_ROLE_END(r)
65355 +
65356 + if (!assigned)
65357 + return;
65358 +
65359 + read_lock(&tasklist_lock);
65360 + read_lock(&grsec_exec_file_lock);
65361 +
65362 + tsk = current->real_parent;
65363 + if (tsk == NULL)
65364 + goto out_unlock;
65365 +
65366 + filp = tsk->exec_file;
65367 + if (filp == NULL)
65368 + goto out_unlock;
65369 +
65370 + tsk->is_writable = 0;
65371 +
65372 + tsk->acl_sp_role = 1;
65373 + tsk->acl_role_id = ++acl_sp_role_value;
65374 + tsk->role = assigned;
65375 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
65376 +
65377 + /* ignore additional mmap checks for processes that are writable
65378 + by the default ACL */
65379 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65380 + if (unlikely(obj->mode & GR_WRITE))
65381 + tsk->is_writable = 1;
65382 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
65383 + if (unlikely(obj->mode & GR_WRITE))
65384 + tsk->is_writable = 1;
65385 +
65386 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65387 + 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));
65388 +#endif
65389 +
65390 +out_unlock:
65391 + read_unlock(&grsec_exec_file_lock);
65392 + read_unlock(&tasklist_lock);
65393 + return;
65394 +}
65395 +
65396 +int gr_check_secure_terminal(struct task_struct *task)
65397 +{
65398 + struct task_struct *p, *p2, *p3;
65399 + struct files_struct *files;
65400 + struct fdtable *fdt;
65401 + struct file *our_file = NULL, *file;
65402 + int i;
65403 +
65404 + if (task->signal->tty == NULL)
65405 + return 1;
65406 +
65407 + files = get_files_struct(task);
65408 + if (files != NULL) {
65409 + rcu_read_lock();
65410 + fdt = files_fdtable(files);
65411 + for (i=0; i < fdt->max_fds; i++) {
65412 + file = fcheck_files(files, i);
65413 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
65414 + get_file(file);
65415 + our_file = file;
65416 + }
65417 + }
65418 + rcu_read_unlock();
65419 + put_files_struct(files);
65420 + }
65421 +
65422 + if (our_file == NULL)
65423 + return 1;
65424 +
65425 + read_lock(&tasklist_lock);
65426 + do_each_thread(p2, p) {
65427 + files = get_files_struct(p);
65428 + if (files == NULL ||
65429 + (p->signal && p->signal->tty == task->signal->tty)) {
65430 + if (files != NULL)
65431 + put_files_struct(files);
65432 + continue;
65433 + }
65434 + rcu_read_lock();
65435 + fdt = files_fdtable(files);
65436 + for (i=0; i < fdt->max_fds; i++) {
65437 + file = fcheck_files(files, i);
65438 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
65439 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
65440 + p3 = task;
65441 + while (task_pid_nr(p3) > 0) {
65442 + if (p3 == p)
65443 + break;
65444 + p3 = p3->real_parent;
65445 + }
65446 + if (p3 == p)
65447 + break;
65448 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
65449 + gr_handle_alertkill(p);
65450 + rcu_read_unlock();
65451 + put_files_struct(files);
65452 + read_unlock(&tasklist_lock);
65453 + fput(our_file);
65454 + return 0;
65455 + }
65456 + }
65457 + rcu_read_unlock();
65458 + put_files_struct(files);
65459 + } while_each_thread(p2, p);
65460 + read_unlock(&tasklist_lock);
65461 +
65462 + fput(our_file);
65463 + return 1;
65464 +}
65465 +
65466 +static int gr_rbac_disable(void *unused)
65467 +{
65468 + pax_open_kernel();
65469 + gr_status &= ~GR_READY;
65470 + pax_close_kernel();
65471 +
65472 + return 0;
65473 +}
65474 +
65475 +ssize_t
65476 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
65477 +{
65478 + struct gr_arg_wrapper uwrap;
65479 + unsigned char *sprole_salt = NULL;
65480 + unsigned char *sprole_sum = NULL;
65481 + int error = 0;
65482 + int error2 = 0;
65483 + size_t req_count = 0;
65484 +
65485 + mutex_lock(&gr_dev_mutex);
65486 +
65487 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
65488 + error = -EPERM;
65489 + goto out;
65490 + }
65491 +
65492 +#ifdef CONFIG_COMPAT
65493 + pax_open_kernel();
65494 + if (is_compat_task()) {
65495 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
65496 + copy_gr_arg = &copy_gr_arg_compat;
65497 + copy_acl_object_label = &copy_acl_object_label_compat;
65498 + copy_acl_subject_label = &copy_acl_subject_label_compat;
65499 + copy_acl_role_label = &copy_acl_role_label_compat;
65500 + copy_acl_ip_label = &copy_acl_ip_label_compat;
65501 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
65502 + copy_role_transition = &copy_role_transition_compat;
65503 + copy_sprole_pw = &copy_sprole_pw_compat;
65504 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
65505 + copy_pointer_from_array = &copy_pointer_from_array_compat;
65506 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
65507 + } else {
65508 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
65509 + copy_gr_arg = &copy_gr_arg_normal;
65510 + copy_acl_object_label = &copy_acl_object_label_normal;
65511 + copy_acl_subject_label = &copy_acl_subject_label_normal;
65512 + copy_acl_role_label = &copy_acl_role_label_normal;
65513 + copy_acl_ip_label = &copy_acl_ip_label_normal;
65514 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
65515 + copy_role_transition = &copy_role_transition_normal;
65516 + copy_sprole_pw = &copy_sprole_pw_normal;
65517 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
65518 + copy_pointer_from_array = &copy_pointer_from_array_normal;
65519 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
65520 + }
65521 + pax_close_kernel();
65522 +#endif
65523 +
65524 + req_count = get_gr_arg_wrapper_size();
65525 +
65526 + if (count != req_count) {
65527 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
65528 + error = -EINVAL;
65529 + goto out;
65530 + }
65531 +
65532 +
65533 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
65534 + gr_auth_expires = 0;
65535 + gr_auth_attempts = 0;
65536 + }
65537 +
65538 + error = copy_gr_arg_wrapper(buf, &uwrap);
65539 + if (error)
65540 + goto out;
65541 +
65542 + error = copy_gr_arg(uwrap.arg, gr_usermode);
65543 + if (error)
65544 + goto out;
65545 +
65546 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65547 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65548 + time_after(gr_auth_expires, get_seconds())) {
65549 + error = -EBUSY;
65550 + goto out;
65551 + }
65552 +
65553 + /* if non-root trying to do anything other than use a special role,
65554 + do not attempt authentication, do not count towards authentication
65555 + locking
65556 + */
65557 +
65558 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
65559 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65560 + gr_is_global_nonroot(current_uid())) {
65561 + error = -EPERM;
65562 + goto out;
65563 + }
65564 +
65565 + /* ensure pw and special role name are null terminated */
65566 +
65567 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
65568 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
65569 +
65570 + /* Okay.
65571 + * We have our enough of the argument structure..(we have yet
65572 + * to copy_from_user the tables themselves) . Copy the tables
65573 + * only if we need them, i.e. for loading operations. */
65574 +
65575 + switch (gr_usermode->mode) {
65576 + case GR_STATUS:
65577 + if (gr_status & GR_READY) {
65578 + error = 1;
65579 + if (!gr_check_secure_terminal(current))
65580 + error = 3;
65581 + } else
65582 + error = 2;
65583 + goto out;
65584 + case GR_SHUTDOWN:
65585 + if ((gr_status & GR_READY)
65586 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65587 + stop_machine(gr_rbac_disable, NULL, NULL);
65588 + free_variables();
65589 + memset(gr_usermode, 0, sizeof (struct gr_arg));
65590 + memset(gr_system_salt, 0, GR_SALT_LEN);
65591 + memset(gr_system_sum, 0, GR_SHA_LEN);
65592 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
65593 + } else if (gr_status & GR_READY) {
65594 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
65595 + error = -EPERM;
65596 + } else {
65597 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
65598 + error = -EAGAIN;
65599 + }
65600 + break;
65601 + case GR_ENABLE:
65602 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
65603 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
65604 + else {
65605 + if (gr_status & GR_READY)
65606 + error = -EAGAIN;
65607 + else
65608 + error = error2;
65609 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
65610 + }
65611 + break;
65612 + case GR_RELOAD:
65613 + if (!(gr_status & GR_READY)) {
65614 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
65615 + error = -EAGAIN;
65616 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65617 + stop_machine(gr_rbac_disable, NULL, NULL);
65618 + free_variables();
65619 + error2 = gracl_init(gr_usermode);
65620 + if (!error2)
65621 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
65622 + else {
65623 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65624 + error = error2;
65625 + }
65626 + } else {
65627 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65628 + error = -EPERM;
65629 + }
65630 + break;
65631 + case GR_SEGVMOD:
65632 + if (unlikely(!(gr_status & GR_READY))) {
65633 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
65634 + error = -EAGAIN;
65635 + break;
65636 + }
65637 +
65638 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65639 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
65640 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
65641 + struct acl_subject_label *segvacl;
65642 + segvacl =
65643 + lookup_acl_subj_label(gr_usermode->segv_inode,
65644 + gr_usermode->segv_device,
65645 + current->role);
65646 + if (segvacl) {
65647 + segvacl->crashes = 0;
65648 + segvacl->expires = 0;
65649 + }
65650 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
65651 + gr_remove_uid(gr_usermode->segv_uid);
65652 + }
65653 + } else {
65654 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
65655 + error = -EPERM;
65656 + }
65657 + break;
65658 + case GR_SPROLE:
65659 + case GR_SPROLEPAM:
65660 + if (unlikely(!(gr_status & GR_READY))) {
65661 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
65662 + error = -EAGAIN;
65663 + break;
65664 + }
65665 +
65666 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
65667 + current->role->expires = 0;
65668 + current->role->auth_attempts = 0;
65669 + }
65670 +
65671 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65672 + time_after(current->role->expires, get_seconds())) {
65673 + error = -EBUSY;
65674 + goto out;
65675 + }
65676 +
65677 + if (lookup_special_role_auth
65678 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
65679 + && ((!sprole_salt && !sprole_sum)
65680 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
65681 + char *p = "";
65682 + assign_special_role(gr_usermode->sp_role);
65683 + read_lock(&tasklist_lock);
65684 + if (current->real_parent)
65685 + p = current->real_parent->role->rolename;
65686 + read_unlock(&tasklist_lock);
65687 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
65688 + p, acl_sp_role_value);
65689 + } else {
65690 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
65691 + error = -EPERM;
65692 + if(!(current->role->auth_attempts++))
65693 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65694 +
65695 + goto out;
65696 + }
65697 + break;
65698 + case GR_UNSPROLE:
65699 + if (unlikely(!(gr_status & GR_READY))) {
65700 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
65701 + error = -EAGAIN;
65702 + break;
65703 + }
65704 +
65705 + if (current->role->roletype & GR_ROLE_SPECIAL) {
65706 + char *p = "";
65707 + int i = 0;
65708 +
65709 + read_lock(&tasklist_lock);
65710 + if (current->real_parent) {
65711 + p = current->real_parent->role->rolename;
65712 + i = current->real_parent->acl_role_id;
65713 + }
65714 + read_unlock(&tasklist_lock);
65715 +
65716 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
65717 + gr_set_acls(1);
65718 + } else {
65719 + error = -EPERM;
65720 + goto out;
65721 + }
65722 + break;
65723 + default:
65724 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
65725 + error = -EINVAL;
65726 + break;
65727 + }
65728 +
65729 + if (error != -EPERM)
65730 + goto out;
65731 +
65732 + if(!(gr_auth_attempts++))
65733 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65734 +
65735 + out:
65736 + mutex_unlock(&gr_dev_mutex);
65737 +
65738 + if (!error)
65739 + error = req_count;
65740 +
65741 + return error;
65742 +}
65743 +
65744 +/* must be called with
65745 + rcu_read_lock();
65746 + read_lock(&tasklist_lock);
65747 + read_lock(&grsec_exec_file_lock);
65748 +*/
65749 +int gr_apply_subject_to_task(struct task_struct *task)
65750 +{
65751 + struct acl_object_label *obj;
65752 + char *tmpname;
65753 + struct acl_subject_label *tmpsubj;
65754 + struct file *filp;
65755 + struct name_entry *nmatch;
65756 +
65757 + filp = task->exec_file;
65758 + if (filp == NULL)
65759 + return 0;
65760 +
65761 + /* the following is to apply the correct subject
65762 + on binaries running when the RBAC system
65763 + is enabled, when the binaries have been
65764 + replaced or deleted since their execution
65765 + -----
65766 + when the RBAC system starts, the inode/dev
65767 + from exec_file will be one the RBAC system
65768 + is unaware of. It only knows the inode/dev
65769 + of the present file on disk, or the absence
65770 + of it.
65771 + */
65772 + preempt_disable();
65773 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
65774 +
65775 + nmatch = lookup_name_entry(tmpname);
65776 + preempt_enable();
65777 + tmpsubj = NULL;
65778 + if (nmatch) {
65779 + if (nmatch->deleted)
65780 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
65781 + else
65782 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
65783 + if (tmpsubj != NULL)
65784 + task->acl = tmpsubj;
65785 + }
65786 + if (tmpsubj == NULL)
65787 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
65788 + task->role);
65789 + if (task->acl) {
65790 + task->is_writable = 0;
65791 + /* ignore additional mmap checks for processes that are writable
65792 + by the default ACL */
65793 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65794 + if (unlikely(obj->mode & GR_WRITE))
65795 + task->is_writable = 1;
65796 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65797 + if (unlikely(obj->mode & GR_WRITE))
65798 + task->is_writable = 1;
65799 +
65800 + gr_set_proc_res(task);
65801 +
65802 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65803 + 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);
65804 +#endif
65805 + } else {
65806 + return 1;
65807 + }
65808 +
65809 + return 0;
65810 +}
65811 +
65812 +int
65813 +gr_set_acls(const int type)
65814 +{
65815 + struct task_struct *task, *task2;
65816 + struct acl_role_label *role = current->role;
65817 + __u16 acl_role_id = current->acl_role_id;
65818 + const struct cred *cred;
65819 + int ret;
65820 +
65821 + rcu_read_lock();
65822 + read_lock(&tasklist_lock);
65823 + read_lock(&grsec_exec_file_lock);
65824 + do_each_thread(task2, task) {
65825 + /* check to see if we're called from the exit handler,
65826 + if so, only replace ACLs that have inherited the admin
65827 + ACL */
65828 +
65829 + if (type && (task->role != role ||
65830 + task->acl_role_id != acl_role_id))
65831 + continue;
65832 +
65833 + task->acl_role_id = 0;
65834 + task->acl_sp_role = 0;
65835 +
65836 + if (task->exec_file) {
65837 + cred = __task_cred(task);
65838 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
65839 + ret = gr_apply_subject_to_task(task);
65840 + if (ret) {
65841 + read_unlock(&grsec_exec_file_lock);
65842 + read_unlock(&tasklist_lock);
65843 + rcu_read_unlock();
65844 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
65845 + return ret;
65846 + }
65847 + } else {
65848 + // it's a kernel process
65849 + task->role = kernel_role;
65850 + task->acl = kernel_role->root_label;
65851 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
65852 + task->acl->mode &= ~GR_PROCFIND;
65853 +#endif
65854 + }
65855 + } while_each_thread(task2, task);
65856 + read_unlock(&grsec_exec_file_lock);
65857 + read_unlock(&tasklist_lock);
65858 + rcu_read_unlock();
65859 +
65860 + return 0;
65861 +}
65862 +
65863 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65864 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65865 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65866 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65867 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65868 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65869 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65870 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65871 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65872 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65873 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65874 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65875 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65876 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65877 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65878 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65879 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65880 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65881 +};
65882 +
65883 +void
65884 +gr_learn_resource(const struct task_struct *task,
65885 + const int res, const unsigned long wanted, const int gt)
65886 +{
65887 + struct acl_subject_label *acl;
65888 + const struct cred *cred;
65889 +
65890 + if (unlikely((gr_status & GR_READY) &&
65891 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65892 + goto skip_reslog;
65893 +
65894 + gr_log_resource(task, res, wanted, gt);
65895 +skip_reslog:
65896 +
65897 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65898 + return;
65899 +
65900 + acl = task->acl;
65901 +
65902 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65903 + !(acl->resmask & (1U << (unsigned short) res))))
65904 + return;
65905 +
65906 + if (wanted >= acl->res[res].rlim_cur) {
65907 + unsigned long res_add;
65908 +
65909 + res_add = wanted + res_learn_bumps[res];
65910 +
65911 + acl->res[res].rlim_cur = res_add;
65912 +
65913 + if (wanted > acl->res[res].rlim_max)
65914 + acl->res[res].rlim_max = res_add;
65915 +
65916 + /* only log the subject filename, since resource logging is supported for
65917 + single-subject learning only */
65918 + rcu_read_lock();
65919 + cred = __task_cred(task);
65920 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65921 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65922 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65923 + "", (unsigned long) res, &task->signal->saved_ip);
65924 + rcu_read_unlock();
65925 + }
65926 +
65927 + return;
65928 +}
65929 +EXPORT_SYMBOL(gr_learn_resource);
65930 +#endif
65931 +
65932 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65933 +void
65934 +pax_set_initial_flags(struct linux_binprm *bprm)
65935 +{
65936 + struct task_struct *task = current;
65937 + struct acl_subject_label *proc;
65938 + unsigned long flags;
65939 +
65940 + if (unlikely(!(gr_status & GR_READY)))
65941 + return;
65942 +
65943 + flags = pax_get_flags(task);
65944 +
65945 + proc = task->acl;
65946 +
65947 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65948 + flags &= ~MF_PAX_PAGEEXEC;
65949 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65950 + flags &= ~MF_PAX_SEGMEXEC;
65951 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
65952 + flags &= ~MF_PAX_RANDMMAP;
65953 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
65954 + flags &= ~MF_PAX_EMUTRAMP;
65955 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
65956 + flags &= ~MF_PAX_MPROTECT;
65957 +
65958 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
65959 + flags |= MF_PAX_PAGEEXEC;
65960 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
65961 + flags |= MF_PAX_SEGMEXEC;
65962 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
65963 + flags |= MF_PAX_RANDMMAP;
65964 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
65965 + flags |= MF_PAX_EMUTRAMP;
65966 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
65967 + flags |= MF_PAX_MPROTECT;
65968 +
65969 + pax_set_flags(task, flags);
65970 +
65971 + return;
65972 +}
65973 +#endif
65974 +
65975 +int
65976 +gr_handle_proc_ptrace(struct task_struct *task)
65977 +{
65978 + struct file *filp;
65979 + struct task_struct *tmp = task;
65980 + struct task_struct *curtemp = current;
65981 + __u32 retmode;
65982 +
65983 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65984 + if (unlikely(!(gr_status & GR_READY)))
65985 + return 0;
65986 +#endif
65987 +
65988 + read_lock(&tasklist_lock);
65989 + read_lock(&grsec_exec_file_lock);
65990 + filp = task->exec_file;
65991 +
65992 + while (task_pid_nr(tmp) > 0) {
65993 + if (tmp == curtemp)
65994 + break;
65995 + tmp = tmp->real_parent;
65996 + }
65997 +
65998 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65999 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
66000 + read_unlock(&grsec_exec_file_lock);
66001 + read_unlock(&tasklist_lock);
66002 + return 1;
66003 + }
66004 +
66005 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66006 + if (!(gr_status & GR_READY)) {
66007 + read_unlock(&grsec_exec_file_lock);
66008 + read_unlock(&tasklist_lock);
66009 + return 0;
66010 + }
66011 +#endif
66012 +
66013 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
66014 + read_unlock(&grsec_exec_file_lock);
66015 + read_unlock(&tasklist_lock);
66016 +
66017 + if (retmode & GR_NOPTRACE)
66018 + return 1;
66019 +
66020 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
66021 + && (current->acl != task->acl || (current->acl != current->role->root_label
66022 + && task_pid_nr(current) != task_pid_nr(task))))
66023 + return 1;
66024 +
66025 + return 0;
66026 +}
66027 +
66028 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
66029 +{
66030 + if (unlikely(!(gr_status & GR_READY)))
66031 + return;
66032 +
66033 + if (!(current->role->roletype & GR_ROLE_GOD))
66034 + return;
66035 +
66036 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
66037 + p->role->rolename, gr_task_roletype_to_char(p),
66038 + p->acl->filename);
66039 +}
66040 +
66041 +int
66042 +gr_handle_ptrace(struct task_struct *task, const long request)
66043 +{
66044 + struct task_struct *tmp = task;
66045 + struct task_struct *curtemp = current;
66046 + __u32 retmode;
66047 +
66048 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66049 + if (unlikely(!(gr_status & GR_READY)))
66050 + return 0;
66051 +#endif
66052 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
66053 + read_lock(&tasklist_lock);
66054 + while (task_pid_nr(tmp) > 0) {
66055 + if (tmp == curtemp)
66056 + break;
66057 + tmp = tmp->real_parent;
66058 + }
66059 +
66060 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66061 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
66062 + read_unlock(&tasklist_lock);
66063 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66064 + return 1;
66065 + }
66066 + read_unlock(&tasklist_lock);
66067 + }
66068 +
66069 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66070 + if (!(gr_status & GR_READY))
66071 + return 0;
66072 +#endif
66073 +
66074 + read_lock(&grsec_exec_file_lock);
66075 + if (unlikely(!task->exec_file)) {
66076 + read_unlock(&grsec_exec_file_lock);
66077 + return 0;
66078 + }
66079 +
66080 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
66081 + read_unlock(&grsec_exec_file_lock);
66082 +
66083 + if (retmode & GR_NOPTRACE) {
66084 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66085 + return 1;
66086 + }
66087 +
66088 + if (retmode & GR_PTRACERD) {
66089 + switch (request) {
66090 + case PTRACE_SEIZE:
66091 + case PTRACE_POKETEXT:
66092 + case PTRACE_POKEDATA:
66093 + case PTRACE_POKEUSR:
66094 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
66095 + case PTRACE_SETREGS:
66096 + case PTRACE_SETFPREGS:
66097 +#endif
66098 +#ifdef CONFIG_X86
66099 + case PTRACE_SETFPXREGS:
66100 +#endif
66101 +#ifdef CONFIG_ALTIVEC
66102 + case PTRACE_SETVRREGS:
66103 +#endif
66104 + return 1;
66105 + default:
66106 + return 0;
66107 + }
66108 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
66109 + !(current->role->roletype & GR_ROLE_GOD) &&
66110 + (current->acl != task->acl)) {
66111 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66112 + return 1;
66113 + }
66114 +
66115 + return 0;
66116 +}
66117 +
66118 +static int is_writable_mmap(const struct file *filp)
66119 +{
66120 + struct task_struct *task = current;
66121 + struct acl_object_label *obj, *obj2;
66122 +
66123 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
66124 + !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))) {
66125 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66126 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
66127 + task->role->root_label);
66128 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
66129 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
66130 + return 1;
66131 + }
66132 + }
66133 + return 0;
66134 +}
66135 +
66136 +int
66137 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
66138 +{
66139 + __u32 mode;
66140 +
66141 + if (unlikely(!file || !(prot & PROT_EXEC)))
66142 + return 1;
66143 +
66144 + if (is_writable_mmap(file))
66145 + return 0;
66146 +
66147 + mode =
66148 + gr_search_file(file->f_path.dentry,
66149 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66150 + file->f_path.mnt);
66151 +
66152 + if (!gr_tpe_allow(file))
66153 + return 0;
66154 +
66155 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66156 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66157 + return 0;
66158 + } else if (unlikely(!(mode & GR_EXEC))) {
66159 + return 0;
66160 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66161 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66162 + return 1;
66163 + }
66164 +
66165 + return 1;
66166 +}
66167 +
66168 +int
66169 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
66170 +{
66171 + __u32 mode;
66172 +
66173 + if (unlikely(!file || !(prot & PROT_EXEC)))
66174 + return 1;
66175 +
66176 + if (is_writable_mmap(file))
66177 + return 0;
66178 +
66179 + mode =
66180 + gr_search_file(file->f_path.dentry,
66181 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66182 + file->f_path.mnt);
66183 +
66184 + if (!gr_tpe_allow(file))
66185 + return 0;
66186 +
66187 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66188 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66189 + return 0;
66190 + } else if (unlikely(!(mode & GR_EXEC))) {
66191 + return 0;
66192 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66193 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66194 + return 1;
66195 + }
66196 +
66197 + return 1;
66198 +}
66199 +
66200 +void
66201 +gr_acl_handle_psacct(struct task_struct *task, const long code)
66202 +{
66203 + unsigned long runtime;
66204 + unsigned long cputime;
66205 + unsigned int wday, cday;
66206 + __u8 whr, chr;
66207 + __u8 wmin, cmin;
66208 + __u8 wsec, csec;
66209 + struct timespec timeval;
66210 +
66211 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
66212 + !(task->acl->mode & GR_PROCACCT)))
66213 + return;
66214 +
66215 + do_posix_clock_monotonic_gettime(&timeval);
66216 + runtime = timeval.tv_sec - task->start_time.tv_sec;
66217 + wday = runtime / (3600 * 24);
66218 + runtime -= wday * (3600 * 24);
66219 + whr = runtime / 3600;
66220 + runtime -= whr * 3600;
66221 + wmin = runtime / 60;
66222 + runtime -= wmin * 60;
66223 + wsec = runtime;
66224 +
66225 + cputime = (task->utime + task->stime) / HZ;
66226 + cday = cputime / (3600 * 24);
66227 + cputime -= cday * (3600 * 24);
66228 + chr = cputime / 3600;
66229 + cputime -= chr * 3600;
66230 + cmin = cputime / 60;
66231 + cputime -= cmin * 60;
66232 + csec = cputime;
66233 +
66234 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
66235 +
66236 + return;
66237 +}
66238 +
66239 +void gr_set_kernel_label(struct task_struct *task)
66240 +{
66241 + if (gr_status & GR_READY) {
66242 + task->role = kernel_role;
66243 + task->acl = kernel_role->root_label;
66244 + }
66245 + return;
66246 +}
66247 +
66248 +#ifdef CONFIG_TASKSTATS
66249 +int gr_is_taskstats_denied(int pid)
66250 +{
66251 + struct task_struct *task;
66252 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66253 + const struct cred *cred;
66254 +#endif
66255 + int ret = 0;
66256 +
66257 + /* restrict taskstats viewing to un-chrooted root users
66258 + who have the 'view' subject flag if the RBAC system is enabled
66259 + */
66260 +
66261 + rcu_read_lock();
66262 + read_lock(&tasklist_lock);
66263 + task = find_task_by_vpid(pid);
66264 + if (task) {
66265 +#ifdef CONFIG_GRKERNSEC_CHROOT
66266 + if (proc_is_chrooted(task))
66267 + ret = -EACCES;
66268 +#endif
66269 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66270 + cred = __task_cred(task);
66271 +#ifdef CONFIG_GRKERNSEC_PROC_USER
66272 + if (gr_is_global_nonroot(cred->uid))
66273 + ret = -EACCES;
66274 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66275 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
66276 + ret = -EACCES;
66277 +#endif
66278 +#endif
66279 + if (gr_status & GR_READY) {
66280 + if (!(task->acl->mode & GR_VIEW))
66281 + ret = -EACCES;
66282 + }
66283 + } else
66284 + ret = -ENOENT;
66285 +
66286 + read_unlock(&tasklist_lock);
66287 + rcu_read_unlock();
66288 +
66289 + return ret;
66290 +}
66291 +#endif
66292 +
66293 +/* AUXV entries are filled via a descendant of search_binary_handler
66294 + after we've already applied the subject for the target
66295 +*/
66296 +int gr_acl_enable_at_secure(void)
66297 +{
66298 + if (unlikely(!(gr_status & GR_READY)))
66299 + return 0;
66300 +
66301 + if (current->acl->mode & GR_ATSECURE)
66302 + return 1;
66303 +
66304 + return 0;
66305 +}
66306 +
66307 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66308 +{
66309 + struct task_struct *task = current;
66310 + struct dentry *dentry = file->f_path.dentry;
66311 + struct vfsmount *mnt = file->f_path.mnt;
66312 + struct acl_object_label *obj, *tmp;
66313 + struct acl_subject_label *subj;
66314 + unsigned int bufsize;
66315 + int is_not_root;
66316 + char *path;
66317 + dev_t dev = __get_dev(dentry);
66318 +
66319 + if (unlikely(!(gr_status & GR_READY)))
66320 + return 1;
66321 +
66322 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66323 + return 1;
66324 +
66325 + /* ignore Eric Biederman */
66326 + if (IS_PRIVATE(dentry->d_inode))
66327 + return 1;
66328 +
66329 + subj = task->acl;
66330 + read_lock(&gr_inode_lock);
66331 + do {
66332 + obj = lookup_acl_obj_label(ino, dev, subj);
66333 + if (obj != NULL) {
66334 + read_unlock(&gr_inode_lock);
66335 + return (obj->mode & GR_FIND) ? 1 : 0;
66336 + }
66337 + } while ((subj = subj->parent_subject));
66338 + read_unlock(&gr_inode_lock);
66339 +
66340 + /* this is purely an optimization since we're looking for an object
66341 + for the directory we're doing a readdir on
66342 + if it's possible for any globbed object to match the entry we're
66343 + filling into the directory, then the object we find here will be
66344 + an anchor point with attached globbed objects
66345 + */
66346 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66347 + if (obj->globbed == NULL)
66348 + return (obj->mode & GR_FIND) ? 1 : 0;
66349 +
66350 + is_not_root = ((obj->filename[0] == '/') &&
66351 + (obj->filename[1] == '\0')) ? 0 : 1;
66352 + bufsize = PAGE_SIZE - namelen - is_not_root;
66353 +
66354 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66355 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66356 + return 1;
66357 +
66358 + preempt_disable();
66359 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66360 + bufsize);
66361 +
66362 + bufsize = strlen(path);
66363 +
66364 + /* if base is "/", don't append an additional slash */
66365 + if (is_not_root)
66366 + *(path + bufsize) = '/';
66367 + memcpy(path + bufsize + is_not_root, name, namelen);
66368 + *(path + bufsize + namelen + is_not_root) = '\0';
66369 +
66370 + tmp = obj->globbed;
66371 + while (tmp) {
66372 + if (!glob_match(tmp->filename, path)) {
66373 + preempt_enable();
66374 + return (tmp->mode & GR_FIND) ? 1 : 0;
66375 + }
66376 + tmp = tmp->next;
66377 + }
66378 + preempt_enable();
66379 + return (obj->mode & GR_FIND) ? 1 : 0;
66380 +}
66381 +
66382 +void gr_put_exec_file(struct task_struct *task)
66383 +{
66384 + struct file *filp;
66385 +
66386 + write_lock(&grsec_exec_file_lock);
66387 + filp = task->exec_file;
66388 + task->exec_file = NULL;
66389 + write_unlock(&grsec_exec_file_lock);
66390 +
66391 + if (filp)
66392 + fput(filp);
66393 +
66394 + return;
66395 +}
66396 +
66397 +
66398 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66399 +EXPORT_SYMBOL(gr_acl_is_enabled);
66400 +#endif
66401 +EXPORT_SYMBOL(gr_set_kernel_label);
66402 +#ifdef CONFIG_SECURITY
66403 +EXPORT_SYMBOL(gr_check_user_change);
66404 +EXPORT_SYMBOL(gr_check_group_change);
66405 +#endif
66406 +
66407 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66408 new file mode 100644
66409 index 0000000..34fefda
66410 --- /dev/null
66411 +++ b/grsecurity/gracl_alloc.c
66412 @@ -0,0 +1,105 @@
66413 +#include <linux/kernel.h>
66414 +#include <linux/mm.h>
66415 +#include <linux/slab.h>
66416 +#include <linux/vmalloc.h>
66417 +#include <linux/gracl.h>
66418 +#include <linux/grsecurity.h>
66419 +
66420 +static unsigned long alloc_stack_next = 1;
66421 +static unsigned long alloc_stack_size = 1;
66422 +static void **alloc_stack;
66423 +
66424 +static __inline__ int
66425 +alloc_pop(void)
66426 +{
66427 + if (alloc_stack_next == 1)
66428 + return 0;
66429 +
66430 + kfree(alloc_stack[alloc_stack_next - 2]);
66431 +
66432 + alloc_stack_next--;
66433 +
66434 + return 1;
66435 +}
66436 +
66437 +static __inline__ int
66438 +alloc_push(void *buf)
66439 +{
66440 + if (alloc_stack_next >= alloc_stack_size)
66441 + return 1;
66442 +
66443 + alloc_stack[alloc_stack_next - 1] = buf;
66444 +
66445 + alloc_stack_next++;
66446 +
66447 + return 0;
66448 +}
66449 +
66450 +void *
66451 +acl_alloc(unsigned long len)
66452 +{
66453 + void *ret = NULL;
66454 +
66455 + if (!len || len > PAGE_SIZE)
66456 + goto out;
66457 +
66458 + ret = kmalloc(len, GFP_KERNEL);
66459 +
66460 + if (ret) {
66461 + if (alloc_push(ret)) {
66462 + kfree(ret);
66463 + ret = NULL;
66464 + }
66465 + }
66466 +
66467 +out:
66468 + return ret;
66469 +}
66470 +
66471 +void *
66472 +acl_alloc_num(unsigned long num, unsigned long len)
66473 +{
66474 + if (!len || (num > (PAGE_SIZE / len)))
66475 + return NULL;
66476 +
66477 + return acl_alloc(num * len);
66478 +}
66479 +
66480 +void
66481 +acl_free_all(void)
66482 +{
66483 + if (gr_acl_is_enabled() || !alloc_stack)
66484 + return;
66485 +
66486 + while (alloc_pop()) ;
66487 +
66488 + if (alloc_stack) {
66489 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66490 + kfree(alloc_stack);
66491 + else
66492 + vfree(alloc_stack);
66493 + }
66494 +
66495 + alloc_stack = NULL;
66496 + alloc_stack_size = 1;
66497 + alloc_stack_next = 1;
66498 +
66499 + return;
66500 +}
66501 +
66502 +int
66503 +acl_alloc_stack_init(unsigned long size)
66504 +{
66505 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66506 + alloc_stack =
66507 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66508 + else
66509 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
66510 +
66511 + alloc_stack_size = size;
66512 +
66513 + if (!alloc_stack)
66514 + return 0;
66515 + else
66516 + return 1;
66517 +}
66518 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66519 new file mode 100644
66520 index 0000000..bdd51ea
66521 --- /dev/null
66522 +++ b/grsecurity/gracl_cap.c
66523 @@ -0,0 +1,110 @@
66524 +#include <linux/kernel.h>
66525 +#include <linux/module.h>
66526 +#include <linux/sched.h>
66527 +#include <linux/gracl.h>
66528 +#include <linux/grsecurity.h>
66529 +#include <linux/grinternal.h>
66530 +
66531 +extern const char *captab_log[];
66532 +extern int captab_log_entries;
66533 +
66534 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66535 +{
66536 + struct acl_subject_label *curracl;
66537 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66538 + kernel_cap_t cap_audit = __cap_empty_set;
66539 +
66540 + if (!gr_acl_is_enabled())
66541 + return 1;
66542 +
66543 + curracl = task->acl;
66544 +
66545 + cap_drop = curracl->cap_lower;
66546 + cap_mask = curracl->cap_mask;
66547 + cap_audit = curracl->cap_invert_audit;
66548 +
66549 + while ((curracl = curracl->parent_subject)) {
66550 + /* if the cap isn't specified in the current computed mask but is specified in the
66551 + current level subject, and is lowered in the current level subject, then add
66552 + it to the set of dropped capabilities
66553 + otherwise, add the current level subject's mask to the current computed mask
66554 + */
66555 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66556 + cap_raise(cap_mask, cap);
66557 + if (cap_raised(curracl->cap_lower, cap))
66558 + cap_raise(cap_drop, cap);
66559 + if (cap_raised(curracl->cap_invert_audit, cap))
66560 + cap_raise(cap_audit, cap);
66561 + }
66562 + }
66563 +
66564 + if (!cap_raised(cap_drop, cap)) {
66565 + if (cap_raised(cap_audit, cap))
66566 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66567 + return 1;
66568 + }
66569 +
66570 + curracl = task->acl;
66571 +
66572 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66573 + && cap_raised(cred->cap_effective, cap)) {
66574 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66575 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66576 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66577 + gr_to_filename(task->exec_file->f_path.dentry,
66578 + task->exec_file->f_path.mnt) : curracl->filename,
66579 + curracl->filename, 0UL,
66580 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66581 + return 1;
66582 + }
66583 +
66584 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66585 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66586 +
66587 + return 0;
66588 +}
66589 +
66590 +int
66591 +gr_acl_is_capable(const int cap)
66592 +{
66593 + return gr_task_acl_is_capable(current, current_cred(), cap);
66594 +}
66595 +
66596 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66597 +{
66598 + struct acl_subject_label *curracl;
66599 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66600 +
66601 + if (!gr_acl_is_enabled())
66602 + return 1;
66603 +
66604 + curracl = task->acl;
66605 +
66606 + cap_drop = curracl->cap_lower;
66607 + cap_mask = curracl->cap_mask;
66608 +
66609 + while ((curracl = curracl->parent_subject)) {
66610 + /* if the cap isn't specified in the current computed mask but is specified in the
66611 + current level subject, and is lowered in the current level subject, then add
66612 + it to the set of dropped capabilities
66613 + otherwise, add the current level subject's mask to the current computed mask
66614 + */
66615 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66616 + cap_raise(cap_mask, cap);
66617 + if (cap_raised(curracl->cap_lower, cap))
66618 + cap_raise(cap_drop, cap);
66619 + }
66620 + }
66621 +
66622 + if (!cap_raised(cap_drop, cap))
66623 + return 1;
66624 +
66625 + return 0;
66626 +}
66627 +
66628 +int
66629 +gr_acl_is_capable_nolog(const int cap)
66630 +{
66631 + return gr_task_acl_is_capable_nolog(current, cap);
66632 +}
66633 +
66634 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66635 new file mode 100644
66636 index 0000000..a43dd06
66637 --- /dev/null
66638 +++ b/grsecurity/gracl_compat.c
66639 @@ -0,0 +1,269 @@
66640 +#include <linux/kernel.h>
66641 +#include <linux/gracl.h>
66642 +#include <linux/compat.h>
66643 +#include <linux/gracl_compat.h>
66644 +
66645 +#include <asm/uaccess.h>
66646 +
66647 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66648 +{
66649 + struct gr_arg_wrapper_compat uwrapcompat;
66650 +
66651 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66652 + return -EFAULT;
66653 +
66654 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
66655 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66656 + return -EINVAL;
66657 +
66658 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66659 + uwrap->version = uwrapcompat.version;
66660 + uwrap->size = sizeof(struct gr_arg);
66661 +
66662 + return 0;
66663 +}
66664 +
66665 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66666 +{
66667 + struct gr_arg_compat argcompat;
66668 +
66669 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66670 + return -EFAULT;
66671 +
66672 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66673 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66674 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66675 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66676 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66677 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66678 +
66679 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66680 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66681 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66682 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66683 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66684 + arg->segv_device = argcompat.segv_device;
66685 + arg->segv_inode = argcompat.segv_inode;
66686 + arg->segv_uid = argcompat.segv_uid;
66687 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66688 + arg->mode = argcompat.mode;
66689 +
66690 + return 0;
66691 +}
66692 +
66693 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66694 +{
66695 + struct acl_object_label_compat objcompat;
66696 +
66697 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66698 + return -EFAULT;
66699 +
66700 + obj->filename = compat_ptr(objcompat.filename);
66701 + obj->inode = objcompat.inode;
66702 + obj->device = objcompat.device;
66703 + obj->mode = objcompat.mode;
66704 +
66705 + obj->nested = compat_ptr(objcompat.nested);
66706 + obj->globbed = compat_ptr(objcompat.globbed);
66707 +
66708 + obj->prev = compat_ptr(objcompat.prev);
66709 + obj->next = compat_ptr(objcompat.next);
66710 +
66711 + return 0;
66712 +}
66713 +
66714 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66715 +{
66716 + unsigned int i;
66717 + struct acl_subject_label_compat subjcompat;
66718 +
66719 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66720 + return -EFAULT;
66721 +
66722 + subj->filename = compat_ptr(subjcompat.filename);
66723 + subj->inode = subjcompat.inode;
66724 + subj->device = subjcompat.device;
66725 + subj->mode = subjcompat.mode;
66726 + subj->cap_mask = subjcompat.cap_mask;
66727 + subj->cap_lower = subjcompat.cap_lower;
66728 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66729 +
66730 + for (i = 0; i < GR_NLIMITS; i++) {
66731 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66732 + subj->res[i].rlim_cur = RLIM_INFINITY;
66733 + else
66734 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66735 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66736 + subj->res[i].rlim_max = RLIM_INFINITY;
66737 + else
66738 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66739 + }
66740 + subj->resmask = subjcompat.resmask;
66741 +
66742 + subj->user_trans_type = subjcompat.user_trans_type;
66743 + subj->group_trans_type = subjcompat.group_trans_type;
66744 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66745 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66746 + subj->user_trans_num = subjcompat.user_trans_num;
66747 + subj->group_trans_num = subjcompat.group_trans_num;
66748 +
66749 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66750 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66751 + subj->ip_type = subjcompat.ip_type;
66752 + subj->ips = compat_ptr(subjcompat.ips);
66753 + subj->ip_num = subjcompat.ip_num;
66754 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66755 +
66756 + subj->crashes = subjcompat.crashes;
66757 + subj->expires = subjcompat.expires;
66758 +
66759 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66760 + subj->hash = compat_ptr(subjcompat.hash);
66761 + subj->prev = compat_ptr(subjcompat.prev);
66762 + subj->next = compat_ptr(subjcompat.next);
66763 +
66764 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66765 + subj->obj_hash_size = subjcompat.obj_hash_size;
66766 + subj->pax_flags = subjcompat.pax_flags;
66767 +
66768 + return 0;
66769 +}
66770 +
66771 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66772 +{
66773 + struct acl_role_label_compat rolecompat;
66774 +
66775 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66776 + return -EFAULT;
66777 +
66778 + role->rolename = compat_ptr(rolecompat.rolename);
66779 + role->uidgid = rolecompat.uidgid;
66780 + role->roletype = rolecompat.roletype;
66781 +
66782 + role->auth_attempts = rolecompat.auth_attempts;
66783 + role->expires = rolecompat.expires;
66784 +
66785 + role->root_label = compat_ptr(rolecompat.root_label);
66786 + role->hash = compat_ptr(rolecompat.hash);
66787 +
66788 + role->prev = compat_ptr(rolecompat.prev);
66789 + role->next = compat_ptr(rolecompat.next);
66790 +
66791 + role->transitions = compat_ptr(rolecompat.transitions);
66792 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66793 + role->domain_children = compat_ptr(rolecompat.domain_children);
66794 + role->domain_child_num = rolecompat.domain_child_num;
66795 +
66796 + role->umask = rolecompat.umask;
66797 +
66798 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66799 + role->subj_hash_size = rolecompat.subj_hash_size;
66800 +
66801 + return 0;
66802 +}
66803 +
66804 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66805 +{
66806 + struct role_allowed_ip_compat roleip_compat;
66807 +
66808 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66809 + return -EFAULT;
66810 +
66811 + roleip->addr = roleip_compat.addr;
66812 + roleip->netmask = roleip_compat.netmask;
66813 +
66814 + roleip->prev = compat_ptr(roleip_compat.prev);
66815 + roleip->next = compat_ptr(roleip_compat.next);
66816 +
66817 + return 0;
66818 +}
66819 +
66820 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66821 +{
66822 + struct role_transition_compat trans_compat;
66823 +
66824 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66825 + return -EFAULT;
66826 +
66827 + trans->rolename = compat_ptr(trans_compat.rolename);
66828 +
66829 + trans->prev = compat_ptr(trans_compat.prev);
66830 + trans->next = compat_ptr(trans_compat.next);
66831 +
66832 + return 0;
66833 +
66834 +}
66835 +
66836 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66837 +{
66838 + struct gr_hash_struct_compat hash_compat;
66839 +
66840 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66841 + return -EFAULT;
66842 +
66843 + hash->table = compat_ptr(hash_compat.table);
66844 + hash->nametable = compat_ptr(hash_compat.nametable);
66845 + hash->first = compat_ptr(hash_compat.first);
66846 +
66847 + hash->table_size = hash_compat.table_size;
66848 + hash->used_size = hash_compat.used_size;
66849 +
66850 + hash->type = hash_compat.type;
66851 +
66852 + return 0;
66853 +}
66854 +
66855 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66856 +{
66857 + compat_uptr_t ptrcompat;
66858 +
66859 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66860 + return -EFAULT;
66861 +
66862 + *(void **)ptr = compat_ptr(ptrcompat);
66863 +
66864 + return 0;
66865 +}
66866 +
66867 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66868 +{
66869 + struct acl_ip_label_compat ip_compat;
66870 +
66871 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66872 + return -EFAULT;
66873 +
66874 + ip->iface = compat_ptr(ip_compat.iface);
66875 + ip->addr = ip_compat.addr;
66876 + ip->netmask = ip_compat.netmask;
66877 + ip->low = ip_compat.low;
66878 + ip->high = ip_compat.high;
66879 + ip->mode = ip_compat.mode;
66880 + ip->type = ip_compat.type;
66881 +
66882 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66883 +
66884 + ip->prev = compat_ptr(ip_compat.prev);
66885 + ip->next = compat_ptr(ip_compat.next);
66886 +
66887 + return 0;
66888 +}
66889 +
66890 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66891 +{
66892 + struct sprole_pw_compat pw_compat;
66893 +
66894 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66895 + return -EFAULT;
66896 +
66897 + pw->rolename = compat_ptr(pw_compat.rolename);
66898 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66899 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66900 +
66901 + return 0;
66902 +}
66903 +
66904 +size_t get_gr_arg_wrapper_size_compat(void)
66905 +{
66906 + return sizeof(struct gr_arg_wrapper_compat);
66907 +}
66908 +
66909 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66910 new file mode 100644
66911 index 0000000..a340c17
66912 --- /dev/null
66913 +++ b/grsecurity/gracl_fs.c
66914 @@ -0,0 +1,431 @@
66915 +#include <linux/kernel.h>
66916 +#include <linux/sched.h>
66917 +#include <linux/types.h>
66918 +#include <linux/fs.h>
66919 +#include <linux/file.h>
66920 +#include <linux/stat.h>
66921 +#include <linux/grsecurity.h>
66922 +#include <linux/grinternal.h>
66923 +#include <linux/gracl.h>
66924 +
66925 +umode_t
66926 +gr_acl_umask(void)
66927 +{
66928 + if (unlikely(!gr_acl_is_enabled()))
66929 + return 0;
66930 +
66931 + return current->role->umask;
66932 +}
66933 +
66934 +__u32
66935 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66936 + const struct vfsmount * mnt)
66937 +{
66938 + __u32 mode;
66939 +
66940 + if (unlikely(!dentry->d_inode))
66941 + return GR_FIND;
66942 +
66943 + mode =
66944 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66945 +
66946 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66947 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66948 + return mode;
66949 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66950 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66951 + return 0;
66952 + } else if (unlikely(!(mode & GR_FIND)))
66953 + return 0;
66954 +
66955 + return GR_FIND;
66956 +}
66957 +
66958 +__u32
66959 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
66960 + int acc_mode)
66961 +{
66962 + __u32 reqmode = GR_FIND;
66963 + __u32 mode;
66964 +
66965 + if (unlikely(!dentry->d_inode))
66966 + return reqmode;
66967 +
66968 + if (acc_mode & MAY_APPEND)
66969 + reqmode |= GR_APPEND;
66970 + else if (acc_mode & MAY_WRITE)
66971 + reqmode |= GR_WRITE;
66972 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
66973 + reqmode |= GR_READ;
66974 +
66975 + mode =
66976 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66977 + mnt);
66978 +
66979 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66980 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66981 + reqmode & GR_READ ? " reading" : "",
66982 + reqmode & GR_WRITE ? " writing" : reqmode &
66983 + GR_APPEND ? " appending" : "");
66984 + return reqmode;
66985 + } else
66986 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66987 + {
66988 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66989 + reqmode & GR_READ ? " reading" : "",
66990 + reqmode & GR_WRITE ? " writing" : reqmode &
66991 + GR_APPEND ? " appending" : "");
66992 + return 0;
66993 + } else if (unlikely((mode & reqmode) != reqmode))
66994 + return 0;
66995 +
66996 + return reqmode;
66997 +}
66998 +
66999 +__u32
67000 +gr_acl_handle_creat(const struct dentry * dentry,
67001 + const struct dentry * p_dentry,
67002 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
67003 + const int imode)
67004 +{
67005 + __u32 reqmode = GR_WRITE | GR_CREATE;
67006 + __u32 mode;
67007 +
67008 + if (acc_mode & MAY_APPEND)
67009 + reqmode |= GR_APPEND;
67010 + // if a directory was required or the directory already exists, then
67011 + // don't count this open as a read
67012 + if ((acc_mode & MAY_READ) &&
67013 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
67014 + reqmode |= GR_READ;
67015 + if ((open_flags & O_CREAT) &&
67016 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67017 + reqmode |= GR_SETID;
67018 +
67019 + mode =
67020 + gr_check_create(dentry, p_dentry, p_mnt,
67021 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67022 +
67023 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67024 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67025 + reqmode & GR_READ ? " reading" : "",
67026 + reqmode & GR_WRITE ? " writing" : reqmode &
67027 + GR_APPEND ? " appending" : "");
67028 + return reqmode;
67029 + } else
67030 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67031 + {
67032 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67033 + reqmode & GR_READ ? " reading" : "",
67034 + reqmode & GR_WRITE ? " writing" : reqmode &
67035 + GR_APPEND ? " appending" : "");
67036 + return 0;
67037 + } else if (unlikely((mode & reqmode) != reqmode))
67038 + return 0;
67039 +
67040 + return reqmode;
67041 +}
67042 +
67043 +__u32
67044 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
67045 + const int fmode)
67046 +{
67047 + __u32 mode, reqmode = GR_FIND;
67048 +
67049 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
67050 + reqmode |= GR_EXEC;
67051 + if (fmode & S_IWOTH)
67052 + reqmode |= GR_WRITE;
67053 + if (fmode & S_IROTH)
67054 + reqmode |= GR_READ;
67055 +
67056 + mode =
67057 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67058 + mnt);
67059 +
67060 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67061 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67062 + reqmode & GR_READ ? " reading" : "",
67063 + reqmode & GR_WRITE ? " writing" : "",
67064 + reqmode & GR_EXEC ? " executing" : "");
67065 + return reqmode;
67066 + } else
67067 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67068 + {
67069 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67070 + reqmode & GR_READ ? " reading" : "",
67071 + reqmode & GR_WRITE ? " writing" : "",
67072 + reqmode & GR_EXEC ? " executing" : "");
67073 + return 0;
67074 + } else if (unlikely((mode & reqmode) != reqmode))
67075 + return 0;
67076 +
67077 + return reqmode;
67078 +}
67079 +
67080 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
67081 +{
67082 + __u32 mode;
67083 +
67084 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
67085 +
67086 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67087 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
67088 + return mode;
67089 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67090 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
67091 + return 0;
67092 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67093 + return 0;
67094 +
67095 + return (reqmode);
67096 +}
67097 +
67098 +__u32
67099 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67100 +{
67101 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
67102 +}
67103 +
67104 +__u32
67105 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
67106 +{
67107 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
67108 +}
67109 +
67110 +__u32
67111 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
67112 +{
67113 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
67114 +}
67115 +
67116 +__u32
67117 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
67118 +{
67119 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
67120 +}
67121 +
67122 +__u32
67123 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
67124 + umode_t *modeptr)
67125 +{
67126 + umode_t mode;
67127 +
67128 + *modeptr &= ~gr_acl_umask();
67129 + mode = *modeptr;
67130 +
67131 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
67132 + return 1;
67133 +
67134 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
67135 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
67136 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
67137 + GR_CHMOD_ACL_MSG);
67138 + } else {
67139 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
67140 + }
67141 +}
67142 +
67143 +__u32
67144 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
67145 +{
67146 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
67147 +}
67148 +
67149 +__u32
67150 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
67151 +{
67152 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
67153 +}
67154 +
67155 +__u32
67156 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
67157 +{
67158 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
67159 +}
67160 +
67161 +__u32
67162 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
67163 +{
67164 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
67165 + GR_UNIXCONNECT_ACL_MSG);
67166 +}
67167 +
67168 +/* hardlinks require at minimum create and link permission,
67169 + any additional privilege required is based on the
67170 + privilege of the file being linked to
67171 +*/
67172 +__u32
67173 +gr_acl_handle_link(const struct dentry * new_dentry,
67174 + const struct dentry * parent_dentry,
67175 + const struct vfsmount * parent_mnt,
67176 + const struct dentry * old_dentry,
67177 + const struct vfsmount * old_mnt, const struct filename *to)
67178 +{
67179 + __u32 mode;
67180 + __u32 needmode = GR_CREATE | GR_LINK;
67181 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
67182 +
67183 + mode =
67184 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
67185 + old_mnt);
67186 +
67187 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
67188 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67189 + return mode;
67190 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67191 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67192 + return 0;
67193 + } else if (unlikely((mode & needmode) != needmode))
67194 + return 0;
67195 +
67196 + return 1;
67197 +}
67198 +
67199 +__u32
67200 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67201 + const struct dentry * parent_dentry,
67202 + const struct vfsmount * parent_mnt, const struct filename *from)
67203 +{
67204 + __u32 needmode = GR_WRITE | GR_CREATE;
67205 + __u32 mode;
67206 +
67207 + mode =
67208 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
67209 + GR_CREATE | GR_AUDIT_CREATE |
67210 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
67211 +
67212 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
67213 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67214 + return mode;
67215 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67216 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67217 + return 0;
67218 + } else if (unlikely((mode & needmode) != needmode))
67219 + return 0;
67220 +
67221 + return (GR_WRITE | GR_CREATE);
67222 +}
67223 +
67224 +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)
67225 +{
67226 + __u32 mode;
67227 +
67228 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67229 +
67230 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67231 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
67232 + return mode;
67233 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67234 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
67235 + return 0;
67236 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67237 + return 0;
67238 +
67239 + return (reqmode);
67240 +}
67241 +
67242 +__u32
67243 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67244 + const struct dentry * parent_dentry,
67245 + const struct vfsmount * parent_mnt,
67246 + const int mode)
67247 +{
67248 + __u32 reqmode = GR_WRITE | GR_CREATE;
67249 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67250 + reqmode |= GR_SETID;
67251 +
67252 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67253 + reqmode, GR_MKNOD_ACL_MSG);
67254 +}
67255 +
67256 +__u32
67257 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
67258 + const struct dentry *parent_dentry,
67259 + const struct vfsmount *parent_mnt)
67260 +{
67261 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67262 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
67263 +}
67264 +
67265 +#define RENAME_CHECK_SUCCESS(old, new) \
67266 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
67267 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
67268 +
67269 +int
67270 +gr_acl_handle_rename(struct dentry *new_dentry,
67271 + struct dentry *parent_dentry,
67272 + const struct vfsmount *parent_mnt,
67273 + struct dentry *old_dentry,
67274 + struct inode *old_parent_inode,
67275 + struct vfsmount *old_mnt, const struct filename *newname)
67276 +{
67277 + __u32 comp1, comp2;
67278 + int error = 0;
67279 +
67280 + if (unlikely(!gr_acl_is_enabled()))
67281 + return 0;
67282 +
67283 + if (!new_dentry->d_inode) {
67284 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
67285 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
67286 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
67287 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
67288 + GR_DELETE | GR_AUDIT_DELETE |
67289 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67290 + GR_SUPPRESS, old_mnt);
67291 + } else {
67292 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
67293 + GR_CREATE | GR_DELETE |
67294 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
67295 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67296 + GR_SUPPRESS, parent_mnt);
67297 + comp2 =
67298 + gr_search_file(old_dentry,
67299 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67300 + GR_DELETE | GR_AUDIT_DELETE |
67301 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67302 + }
67303 +
67304 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67305 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67306 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67307 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67308 + && !(comp2 & GR_SUPPRESS)) {
67309 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67310 + error = -EACCES;
67311 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67312 + error = -EACCES;
67313 +
67314 + return error;
67315 +}
67316 +
67317 +void
67318 +gr_acl_handle_exit(void)
67319 +{
67320 + u16 id;
67321 + char *rolename;
67322 +
67323 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67324 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67325 + id = current->acl_role_id;
67326 + rolename = current->role->rolename;
67327 + gr_set_acls(1);
67328 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67329 + }
67330 +
67331 + gr_put_exec_file(current);
67332 + return;
67333 +}
67334 +
67335 +int
67336 +gr_acl_handle_procpidmem(const struct task_struct *task)
67337 +{
67338 + if (unlikely(!gr_acl_is_enabled()))
67339 + return 0;
67340 +
67341 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67342 + return -EACCES;
67343 +
67344 + return 0;
67345 +}
67346 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67347 new file mode 100644
67348 index 0000000..f056b81
67349 --- /dev/null
67350 +++ b/grsecurity/gracl_ip.c
67351 @@ -0,0 +1,386 @@
67352 +#include <linux/kernel.h>
67353 +#include <asm/uaccess.h>
67354 +#include <asm/errno.h>
67355 +#include <net/sock.h>
67356 +#include <linux/file.h>
67357 +#include <linux/fs.h>
67358 +#include <linux/net.h>
67359 +#include <linux/in.h>
67360 +#include <linux/skbuff.h>
67361 +#include <linux/ip.h>
67362 +#include <linux/udp.h>
67363 +#include <linux/types.h>
67364 +#include <linux/sched.h>
67365 +#include <linux/netdevice.h>
67366 +#include <linux/inetdevice.h>
67367 +#include <linux/gracl.h>
67368 +#include <linux/grsecurity.h>
67369 +#include <linux/grinternal.h>
67370 +
67371 +#define GR_BIND 0x01
67372 +#define GR_CONNECT 0x02
67373 +#define GR_INVERT 0x04
67374 +#define GR_BINDOVERRIDE 0x08
67375 +#define GR_CONNECTOVERRIDE 0x10
67376 +#define GR_SOCK_FAMILY 0x20
67377 +
67378 +static const char * gr_protocols[IPPROTO_MAX] = {
67379 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67380 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67381 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67382 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67383 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67384 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67385 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67386 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67387 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67388 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67389 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67390 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67391 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67392 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67393 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67394 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67395 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67396 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67397 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67398 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67399 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67400 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67401 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67402 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67403 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67404 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67405 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67406 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67407 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67408 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67409 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67410 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67411 + };
67412 +
67413 +static const char * gr_socktypes[SOCK_MAX] = {
67414 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67415 + "unknown:7", "unknown:8", "unknown:9", "packet"
67416 + };
67417 +
67418 +static const char * gr_sockfamilies[AF_MAX+1] = {
67419 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67420 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67421 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67422 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67423 + };
67424 +
67425 +const char *
67426 +gr_proto_to_name(unsigned char proto)
67427 +{
67428 + return gr_protocols[proto];
67429 +}
67430 +
67431 +const char *
67432 +gr_socktype_to_name(unsigned char type)
67433 +{
67434 + return gr_socktypes[type];
67435 +}
67436 +
67437 +const char *
67438 +gr_sockfamily_to_name(unsigned char family)
67439 +{
67440 + return gr_sockfamilies[family];
67441 +}
67442 +
67443 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67444 +
67445 +int
67446 +gr_search_socket(const int domain, const int type, const int protocol)
67447 +{
67448 + struct acl_subject_label *curr;
67449 + const struct cred *cred = current_cred();
67450 +
67451 + if (unlikely(!gr_acl_is_enabled()))
67452 + goto exit;
67453 +
67454 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67455 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67456 + goto exit; // let the kernel handle it
67457 +
67458 + curr = current->acl;
67459 +
67460 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67461 + /* the family is allowed, if this is PF_INET allow it only if
67462 + the extra sock type/protocol checks pass */
67463 + if (domain == PF_INET)
67464 + goto inet_check;
67465 + goto exit;
67466 + } else {
67467 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67468 + __u32 fakeip = 0;
67469 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67470 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67471 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67472 + gr_to_filename(current->exec_file->f_path.dentry,
67473 + current->exec_file->f_path.mnt) :
67474 + curr->filename, curr->filename,
67475 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67476 + &current->signal->saved_ip);
67477 + goto exit;
67478 + }
67479 + goto exit_fail;
67480 + }
67481 +
67482 +inet_check:
67483 + /* the rest of this checking is for IPv4 only */
67484 + if (!curr->ips)
67485 + goto exit;
67486 +
67487 + if ((curr->ip_type & (1U << type)) &&
67488 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67489 + goto exit;
67490 +
67491 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67492 + /* we don't place acls on raw sockets , and sometimes
67493 + dgram/ip sockets are opened for ioctl and not
67494 + bind/connect, so we'll fake a bind learn log */
67495 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67496 + __u32 fakeip = 0;
67497 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67498 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67499 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67500 + gr_to_filename(current->exec_file->f_path.dentry,
67501 + current->exec_file->f_path.mnt) :
67502 + curr->filename, curr->filename,
67503 + &fakeip, 0, type,
67504 + protocol, GR_CONNECT, &current->signal->saved_ip);
67505 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67506 + __u32 fakeip = 0;
67507 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67508 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67509 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67510 + gr_to_filename(current->exec_file->f_path.dentry,
67511 + current->exec_file->f_path.mnt) :
67512 + curr->filename, curr->filename,
67513 + &fakeip, 0, type,
67514 + protocol, GR_BIND, &current->signal->saved_ip);
67515 + }
67516 + /* we'll log when they use connect or bind */
67517 + goto exit;
67518 + }
67519 +
67520 +exit_fail:
67521 + if (domain == PF_INET)
67522 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67523 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67524 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67525 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67526 + gr_socktype_to_name(type), protocol);
67527 +
67528 + return 0;
67529 +exit:
67530 + return 1;
67531 +}
67532 +
67533 +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)
67534 +{
67535 + if ((ip->mode & mode) &&
67536 + (ip_port >= ip->low) &&
67537 + (ip_port <= ip->high) &&
67538 + ((ntohl(ip_addr) & our_netmask) ==
67539 + (ntohl(our_addr) & our_netmask))
67540 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67541 + && (ip->type & (1U << type))) {
67542 + if (ip->mode & GR_INVERT)
67543 + return 2; // specifically denied
67544 + else
67545 + return 1; // allowed
67546 + }
67547 +
67548 + return 0; // not specifically allowed, may continue parsing
67549 +}
67550 +
67551 +static int
67552 +gr_search_connectbind(const int full_mode, struct sock *sk,
67553 + struct sockaddr_in *addr, const int type)
67554 +{
67555 + char iface[IFNAMSIZ] = {0};
67556 + struct acl_subject_label *curr;
67557 + struct acl_ip_label *ip;
67558 + struct inet_sock *isk;
67559 + struct net_device *dev;
67560 + struct in_device *idev;
67561 + unsigned long i;
67562 + int ret;
67563 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67564 + __u32 ip_addr = 0;
67565 + __u32 our_addr;
67566 + __u32 our_netmask;
67567 + char *p;
67568 + __u16 ip_port = 0;
67569 + const struct cred *cred = current_cred();
67570 +
67571 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67572 + return 0;
67573 +
67574 + curr = current->acl;
67575 + isk = inet_sk(sk);
67576 +
67577 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67578 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67579 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67580 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67581 + struct sockaddr_in saddr;
67582 + int err;
67583 +
67584 + saddr.sin_family = AF_INET;
67585 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67586 + saddr.sin_port = isk->inet_sport;
67587 +
67588 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67589 + if (err)
67590 + return err;
67591 +
67592 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67593 + if (err)
67594 + return err;
67595 + }
67596 +
67597 + if (!curr->ips)
67598 + return 0;
67599 +
67600 + ip_addr = addr->sin_addr.s_addr;
67601 + ip_port = ntohs(addr->sin_port);
67602 +
67603 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67604 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67605 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67606 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67607 + gr_to_filename(current->exec_file->f_path.dentry,
67608 + current->exec_file->f_path.mnt) :
67609 + curr->filename, curr->filename,
67610 + &ip_addr, ip_port, type,
67611 + sk->sk_protocol, mode, &current->signal->saved_ip);
67612 + return 0;
67613 + }
67614 +
67615 + for (i = 0; i < curr->ip_num; i++) {
67616 + ip = *(curr->ips + i);
67617 + if (ip->iface != NULL) {
67618 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67619 + p = strchr(iface, ':');
67620 + if (p != NULL)
67621 + *p = '\0';
67622 + dev = dev_get_by_name(sock_net(sk), iface);
67623 + if (dev == NULL)
67624 + continue;
67625 + idev = in_dev_get(dev);
67626 + if (idev == NULL) {
67627 + dev_put(dev);
67628 + continue;
67629 + }
67630 + rcu_read_lock();
67631 + for_ifa(idev) {
67632 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67633 + our_addr = ifa->ifa_address;
67634 + our_netmask = 0xffffffff;
67635 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67636 + if (ret == 1) {
67637 + rcu_read_unlock();
67638 + in_dev_put(idev);
67639 + dev_put(dev);
67640 + return 0;
67641 + } else if (ret == 2) {
67642 + rcu_read_unlock();
67643 + in_dev_put(idev);
67644 + dev_put(dev);
67645 + goto denied;
67646 + }
67647 + }
67648 + } endfor_ifa(idev);
67649 + rcu_read_unlock();
67650 + in_dev_put(idev);
67651 + dev_put(dev);
67652 + } else {
67653 + our_addr = ip->addr;
67654 + our_netmask = ip->netmask;
67655 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67656 + if (ret == 1)
67657 + return 0;
67658 + else if (ret == 2)
67659 + goto denied;
67660 + }
67661 + }
67662 +
67663 +denied:
67664 + if (mode == GR_BIND)
67665 + 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));
67666 + else if (mode == GR_CONNECT)
67667 + 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));
67668 +
67669 + return -EACCES;
67670 +}
67671 +
67672 +int
67673 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67674 +{
67675 + /* always allow disconnection of dgram sockets with connect */
67676 + if (addr->sin_family == AF_UNSPEC)
67677 + return 0;
67678 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67679 +}
67680 +
67681 +int
67682 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67683 +{
67684 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67685 +}
67686 +
67687 +int gr_search_listen(struct socket *sock)
67688 +{
67689 + struct sock *sk = sock->sk;
67690 + struct sockaddr_in addr;
67691 +
67692 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67693 + addr.sin_port = inet_sk(sk)->inet_sport;
67694 +
67695 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67696 +}
67697 +
67698 +int gr_search_accept(struct socket *sock)
67699 +{
67700 + struct sock *sk = sock->sk;
67701 + struct sockaddr_in addr;
67702 +
67703 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67704 + addr.sin_port = inet_sk(sk)->inet_sport;
67705 +
67706 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67707 +}
67708 +
67709 +int
67710 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67711 +{
67712 + if (addr)
67713 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67714 + else {
67715 + struct sockaddr_in sin;
67716 + const struct inet_sock *inet = inet_sk(sk);
67717 +
67718 + sin.sin_addr.s_addr = inet->inet_daddr;
67719 + sin.sin_port = inet->inet_dport;
67720 +
67721 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67722 + }
67723 +}
67724 +
67725 +int
67726 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67727 +{
67728 + struct sockaddr_in sin;
67729 +
67730 + if (unlikely(skb->len < sizeof (struct udphdr)))
67731 + return 0; // skip this packet
67732 +
67733 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67734 + sin.sin_port = udp_hdr(skb)->source;
67735 +
67736 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67737 +}
67738 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67739 new file mode 100644
67740 index 0000000..25f54ef
67741 --- /dev/null
67742 +++ b/grsecurity/gracl_learn.c
67743 @@ -0,0 +1,207 @@
67744 +#include <linux/kernel.h>
67745 +#include <linux/mm.h>
67746 +#include <linux/sched.h>
67747 +#include <linux/poll.h>
67748 +#include <linux/string.h>
67749 +#include <linux/file.h>
67750 +#include <linux/types.h>
67751 +#include <linux/vmalloc.h>
67752 +#include <linux/grinternal.h>
67753 +
67754 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67755 + size_t count, loff_t *ppos);
67756 +extern int gr_acl_is_enabled(void);
67757 +
67758 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67759 +static int gr_learn_attached;
67760 +
67761 +/* use a 512k buffer */
67762 +#define LEARN_BUFFER_SIZE (512 * 1024)
67763 +
67764 +static DEFINE_SPINLOCK(gr_learn_lock);
67765 +static DEFINE_MUTEX(gr_learn_user_mutex);
67766 +
67767 +/* we need to maintain two buffers, so that the kernel context of grlearn
67768 + uses a semaphore around the userspace copying, and the other kernel contexts
67769 + use a spinlock when copying into the buffer, since they cannot sleep
67770 +*/
67771 +static char *learn_buffer;
67772 +static char *learn_buffer_user;
67773 +static int learn_buffer_len;
67774 +static int learn_buffer_user_len;
67775 +
67776 +static ssize_t
67777 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67778 +{
67779 + DECLARE_WAITQUEUE(wait, current);
67780 + ssize_t retval = 0;
67781 +
67782 + add_wait_queue(&learn_wait, &wait);
67783 + set_current_state(TASK_INTERRUPTIBLE);
67784 + do {
67785 + mutex_lock(&gr_learn_user_mutex);
67786 + spin_lock(&gr_learn_lock);
67787 + if (learn_buffer_len)
67788 + break;
67789 + spin_unlock(&gr_learn_lock);
67790 + mutex_unlock(&gr_learn_user_mutex);
67791 + if (file->f_flags & O_NONBLOCK) {
67792 + retval = -EAGAIN;
67793 + goto out;
67794 + }
67795 + if (signal_pending(current)) {
67796 + retval = -ERESTARTSYS;
67797 + goto out;
67798 + }
67799 +
67800 + schedule();
67801 + } while (1);
67802 +
67803 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67804 + learn_buffer_user_len = learn_buffer_len;
67805 + retval = learn_buffer_len;
67806 + learn_buffer_len = 0;
67807 +
67808 + spin_unlock(&gr_learn_lock);
67809 +
67810 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67811 + retval = -EFAULT;
67812 +
67813 + mutex_unlock(&gr_learn_user_mutex);
67814 +out:
67815 + set_current_state(TASK_RUNNING);
67816 + remove_wait_queue(&learn_wait, &wait);
67817 + return retval;
67818 +}
67819 +
67820 +static unsigned int
67821 +poll_learn(struct file * file, poll_table * wait)
67822 +{
67823 + poll_wait(file, &learn_wait, wait);
67824 +
67825 + if (learn_buffer_len)
67826 + return (POLLIN | POLLRDNORM);
67827 +
67828 + return 0;
67829 +}
67830 +
67831 +void
67832 +gr_clear_learn_entries(void)
67833 +{
67834 + char *tmp;
67835 +
67836 + mutex_lock(&gr_learn_user_mutex);
67837 + spin_lock(&gr_learn_lock);
67838 + tmp = learn_buffer;
67839 + learn_buffer = NULL;
67840 + spin_unlock(&gr_learn_lock);
67841 + if (tmp)
67842 + vfree(tmp);
67843 + if (learn_buffer_user != NULL) {
67844 + vfree(learn_buffer_user);
67845 + learn_buffer_user = NULL;
67846 + }
67847 + learn_buffer_len = 0;
67848 + mutex_unlock(&gr_learn_user_mutex);
67849 +
67850 + return;
67851 +}
67852 +
67853 +void
67854 +gr_add_learn_entry(const char *fmt, ...)
67855 +{
67856 + va_list args;
67857 + unsigned int len;
67858 +
67859 + if (!gr_learn_attached)
67860 + return;
67861 +
67862 + spin_lock(&gr_learn_lock);
67863 +
67864 + /* leave a gap at the end so we know when it's "full" but don't have to
67865 + compute the exact length of the string we're trying to append
67866 + */
67867 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67868 + spin_unlock(&gr_learn_lock);
67869 + wake_up_interruptible(&learn_wait);
67870 + return;
67871 + }
67872 + if (learn_buffer == NULL) {
67873 + spin_unlock(&gr_learn_lock);
67874 + return;
67875 + }
67876 +
67877 + va_start(args, fmt);
67878 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67879 + va_end(args);
67880 +
67881 + learn_buffer_len += len + 1;
67882 +
67883 + spin_unlock(&gr_learn_lock);
67884 + wake_up_interruptible(&learn_wait);
67885 +
67886 + return;
67887 +}
67888 +
67889 +static int
67890 +open_learn(struct inode *inode, struct file *file)
67891 +{
67892 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67893 + return -EBUSY;
67894 + if (file->f_mode & FMODE_READ) {
67895 + int retval = 0;
67896 + mutex_lock(&gr_learn_user_mutex);
67897 + if (learn_buffer == NULL)
67898 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67899 + if (learn_buffer_user == NULL)
67900 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67901 + if (learn_buffer == NULL) {
67902 + retval = -ENOMEM;
67903 + goto out_error;
67904 + }
67905 + if (learn_buffer_user == NULL) {
67906 + retval = -ENOMEM;
67907 + goto out_error;
67908 + }
67909 + learn_buffer_len = 0;
67910 + learn_buffer_user_len = 0;
67911 + gr_learn_attached = 1;
67912 +out_error:
67913 + mutex_unlock(&gr_learn_user_mutex);
67914 + return retval;
67915 + }
67916 + return 0;
67917 +}
67918 +
67919 +static int
67920 +close_learn(struct inode *inode, struct file *file)
67921 +{
67922 + if (file->f_mode & FMODE_READ) {
67923 + char *tmp = NULL;
67924 + mutex_lock(&gr_learn_user_mutex);
67925 + spin_lock(&gr_learn_lock);
67926 + tmp = learn_buffer;
67927 + learn_buffer = NULL;
67928 + spin_unlock(&gr_learn_lock);
67929 + if (tmp)
67930 + vfree(tmp);
67931 + if (learn_buffer_user != NULL) {
67932 + vfree(learn_buffer_user);
67933 + learn_buffer_user = NULL;
67934 + }
67935 + learn_buffer_len = 0;
67936 + learn_buffer_user_len = 0;
67937 + gr_learn_attached = 0;
67938 + mutex_unlock(&gr_learn_user_mutex);
67939 + }
67940 +
67941 + return 0;
67942 +}
67943 +
67944 +const struct file_operations grsec_fops = {
67945 + .read = read_learn,
67946 + .write = write_grsec_handler,
67947 + .open = open_learn,
67948 + .release = close_learn,
67949 + .poll = poll_learn,
67950 +};
67951 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
67952 new file mode 100644
67953 index 0000000..39645c9
67954 --- /dev/null
67955 +++ b/grsecurity/gracl_res.c
67956 @@ -0,0 +1,68 @@
67957 +#include <linux/kernel.h>
67958 +#include <linux/sched.h>
67959 +#include <linux/gracl.h>
67960 +#include <linux/grinternal.h>
67961 +
67962 +static const char *restab_log[] = {
67963 + [RLIMIT_CPU] = "RLIMIT_CPU",
67964 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
67965 + [RLIMIT_DATA] = "RLIMIT_DATA",
67966 + [RLIMIT_STACK] = "RLIMIT_STACK",
67967 + [RLIMIT_CORE] = "RLIMIT_CORE",
67968 + [RLIMIT_RSS] = "RLIMIT_RSS",
67969 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
67970 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
67971 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
67972 + [RLIMIT_AS] = "RLIMIT_AS",
67973 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
67974 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
67975 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
67976 + [RLIMIT_NICE] = "RLIMIT_NICE",
67977 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
67978 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
67979 + [GR_CRASH_RES] = "RLIMIT_CRASH"
67980 +};
67981 +
67982 +void
67983 +gr_log_resource(const struct task_struct *task,
67984 + const int res, const unsigned long wanted, const int gt)
67985 +{
67986 + const struct cred *cred;
67987 + unsigned long rlim;
67988 +
67989 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
67990 + return;
67991 +
67992 + // not yet supported resource
67993 + if (unlikely(!restab_log[res]))
67994 + return;
67995 +
67996 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
67997 + rlim = task_rlimit_max(task, res);
67998 + else
67999 + rlim = task_rlimit(task, res);
68000 +
68001 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
68002 + return;
68003 +
68004 + rcu_read_lock();
68005 + cred = __task_cred(task);
68006 +
68007 + if (res == RLIMIT_NPROC &&
68008 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
68009 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
68010 + goto out_rcu_unlock;
68011 + else if (res == RLIMIT_MEMLOCK &&
68012 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
68013 + goto out_rcu_unlock;
68014 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
68015 + goto out_rcu_unlock;
68016 + rcu_read_unlock();
68017 +
68018 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
68019 +
68020 + return;
68021 +out_rcu_unlock:
68022 + rcu_read_unlock();
68023 + return;
68024 +}
68025 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
68026 new file mode 100644
68027 index 0000000..3c38bfe
68028 --- /dev/null
68029 +++ b/grsecurity/gracl_segv.c
68030 @@ -0,0 +1,305 @@
68031 +#include <linux/kernel.h>
68032 +#include <linux/mm.h>
68033 +#include <asm/uaccess.h>
68034 +#include <asm/errno.h>
68035 +#include <asm/mman.h>
68036 +#include <net/sock.h>
68037 +#include <linux/file.h>
68038 +#include <linux/fs.h>
68039 +#include <linux/net.h>
68040 +#include <linux/in.h>
68041 +#include <linux/slab.h>
68042 +#include <linux/types.h>
68043 +#include <linux/sched.h>
68044 +#include <linux/timer.h>
68045 +#include <linux/gracl.h>
68046 +#include <linux/grsecurity.h>
68047 +#include <linux/grinternal.h>
68048 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68049 +#include <linux/magic.h>
68050 +#include <linux/pagemap.h>
68051 +#include "../fs/btrfs/async-thread.h"
68052 +#include "../fs/btrfs/ctree.h"
68053 +#include "../fs/btrfs/btrfs_inode.h"
68054 +#endif
68055 +
68056 +static struct crash_uid *uid_set;
68057 +static unsigned short uid_used;
68058 +static DEFINE_SPINLOCK(gr_uid_lock);
68059 +extern rwlock_t gr_inode_lock;
68060 +extern struct acl_subject_label *
68061 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
68062 + struct acl_role_label *role);
68063 +
68064 +static inline dev_t __get_dev(const struct dentry *dentry)
68065 +{
68066 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68067 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
68068 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
68069 + else
68070 +#endif
68071 + return dentry->d_sb->s_dev;
68072 +}
68073 +
68074 +int
68075 +gr_init_uidset(void)
68076 +{
68077 + uid_set =
68078 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
68079 + uid_used = 0;
68080 +
68081 + return uid_set ? 1 : 0;
68082 +}
68083 +
68084 +void
68085 +gr_free_uidset(void)
68086 +{
68087 + if (uid_set)
68088 + kfree(uid_set);
68089 +
68090 + return;
68091 +}
68092 +
68093 +int
68094 +gr_find_uid(const uid_t uid)
68095 +{
68096 + struct crash_uid *tmp = uid_set;
68097 + uid_t buid;
68098 + int low = 0, high = uid_used - 1, mid;
68099 +
68100 + while (high >= low) {
68101 + mid = (low + high) >> 1;
68102 + buid = tmp[mid].uid;
68103 + if (buid == uid)
68104 + return mid;
68105 + if (buid > uid)
68106 + high = mid - 1;
68107 + if (buid < uid)
68108 + low = mid + 1;
68109 + }
68110 +
68111 + return -1;
68112 +}
68113 +
68114 +static __inline__ void
68115 +gr_insertsort(void)
68116 +{
68117 + unsigned short i, j;
68118 + struct crash_uid index;
68119 +
68120 + for (i = 1; i < uid_used; i++) {
68121 + index = uid_set[i];
68122 + j = i;
68123 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
68124 + uid_set[j] = uid_set[j - 1];
68125 + j--;
68126 + }
68127 + uid_set[j] = index;
68128 + }
68129 +
68130 + return;
68131 +}
68132 +
68133 +static __inline__ void
68134 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
68135 +{
68136 + int loc;
68137 + uid_t uid = GR_GLOBAL_UID(kuid);
68138 +
68139 + if (uid_used == GR_UIDTABLE_MAX)
68140 + return;
68141 +
68142 + loc = gr_find_uid(uid);
68143 +
68144 + if (loc >= 0) {
68145 + uid_set[loc].expires = expires;
68146 + return;
68147 + }
68148 +
68149 + uid_set[uid_used].uid = uid;
68150 + uid_set[uid_used].expires = expires;
68151 + uid_used++;
68152 +
68153 + gr_insertsort();
68154 +
68155 + return;
68156 +}
68157 +
68158 +void
68159 +gr_remove_uid(const unsigned short loc)
68160 +{
68161 + unsigned short i;
68162 +
68163 + for (i = loc + 1; i < uid_used; i++)
68164 + uid_set[i - 1] = uid_set[i];
68165 +
68166 + uid_used--;
68167 +
68168 + return;
68169 +}
68170 +
68171 +int
68172 +gr_check_crash_uid(const kuid_t kuid)
68173 +{
68174 + int loc;
68175 + int ret = 0;
68176 + uid_t uid;
68177 +
68178 + if (unlikely(!gr_acl_is_enabled()))
68179 + return 0;
68180 +
68181 + uid = GR_GLOBAL_UID(kuid);
68182 +
68183 + spin_lock(&gr_uid_lock);
68184 + loc = gr_find_uid(uid);
68185 +
68186 + if (loc < 0)
68187 + goto out_unlock;
68188 +
68189 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
68190 + gr_remove_uid(loc);
68191 + else
68192 + ret = 1;
68193 +
68194 +out_unlock:
68195 + spin_unlock(&gr_uid_lock);
68196 + return ret;
68197 +}
68198 +
68199 +static __inline__ int
68200 +proc_is_setxid(const struct cred *cred)
68201 +{
68202 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
68203 + !uid_eq(cred->uid, cred->fsuid))
68204 + return 1;
68205 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
68206 + !gid_eq(cred->gid, cred->fsgid))
68207 + return 1;
68208 +
68209 + return 0;
68210 +}
68211 +
68212 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
68213 +
68214 +void
68215 +gr_handle_crash(struct task_struct *task, const int sig)
68216 +{
68217 + struct acl_subject_label *curr;
68218 + struct task_struct *tsk, *tsk2;
68219 + const struct cred *cred;
68220 + const struct cred *cred2;
68221 +
68222 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
68223 + return;
68224 +
68225 + if (unlikely(!gr_acl_is_enabled()))
68226 + return;
68227 +
68228 + curr = task->acl;
68229 +
68230 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
68231 + return;
68232 +
68233 + if (time_before_eq(curr->expires, get_seconds())) {
68234 + curr->expires = 0;
68235 + curr->crashes = 0;
68236 + }
68237 +
68238 + curr->crashes++;
68239 +
68240 + if (!curr->expires)
68241 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
68242 +
68243 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68244 + time_after(curr->expires, get_seconds())) {
68245 + rcu_read_lock();
68246 + cred = __task_cred(task);
68247 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
68248 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68249 + spin_lock(&gr_uid_lock);
68250 + gr_insert_uid(cred->uid, curr->expires);
68251 + spin_unlock(&gr_uid_lock);
68252 + curr->expires = 0;
68253 + curr->crashes = 0;
68254 + read_lock(&tasklist_lock);
68255 + do_each_thread(tsk2, tsk) {
68256 + cred2 = __task_cred(tsk);
68257 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
68258 + gr_fake_force_sig(SIGKILL, tsk);
68259 + } while_each_thread(tsk2, tsk);
68260 + read_unlock(&tasklist_lock);
68261 + } else {
68262 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68263 + read_lock(&tasklist_lock);
68264 + read_lock(&grsec_exec_file_lock);
68265 + do_each_thread(tsk2, tsk) {
68266 + if (likely(tsk != task)) {
68267 + // if this thread has the same subject as the one that triggered
68268 + // RES_CRASH and it's the same binary, kill it
68269 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
68270 + gr_fake_force_sig(SIGKILL, tsk);
68271 + }
68272 + } while_each_thread(tsk2, tsk);
68273 + read_unlock(&grsec_exec_file_lock);
68274 + read_unlock(&tasklist_lock);
68275 + }
68276 + rcu_read_unlock();
68277 + }
68278 +
68279 + return;
68280 +}
68281 +
68282 +int
68283 +gr_check_crash_exec(const struct file *filp)
68284 +{
68285 + struct acl_subject_label *curr;
68286 +
68287 + if (unlikely(!gr_acl_is_enabled()))
68288 + return 0;
68289 +
68290 + read_lock(&gr_inode_lock);
68291 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
68292 + __get_dev(filp->f_path.dentry),
68293 + current->role);
68294 + read_unlock(&gr_inode_lock);
68295 +
68296 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
68297 + (!curr->crashes && !curr->expires))
68298 + return 0;
68299 +
68300 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68301 + time_after(curr->expires, get_seconds()))
68302 + return 1;
68303 + else if (time_before_eq(curr->expires, get_seconds())) {
68304 + curr->crashes = 0;
68305 + curr->expires = 0;
68306 + }
68307 +
68308 + return 0;
68309 +}
68310 +
68311 +void
68312 +gr_handle_alertkill(struct task_struct *task)
68313 +{
68314 + struct acl_subject_label *curracl;
68315 + __u32 curr_ip;
68316 + struct task_struct *p, *p2;
68317 +
68318 + if (unlikely(!gr_acl_is_enabled()))
68319 + return;
68320 +
68321 + curracl = task->acl;
68322 + curr_ip = task->signal->curr_ip;
68323 +
68324 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
68325 + read_lock(&tasklist_lock);
68326 + do_each_thread(p2, p) {
68327 + if (p->signal->curr_ip == curr_ip)
68328 + gr_fake_force_sig(SIGKILL, p);
68329 + } while_each_thread(p2, p);
68330 + read_unlock(&tasklist_lock);
68331 + } else if (curracl->mode & GR_KILLPROC)
68332 + gr_fake_force_sig(SIGKILL, task);
68333 +
68334 + return;
68335 +}
68336 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
68337 new file mode 100644
68338 index 0000000..98011b0
68339 --- /dev/null
68340 +++ b/grsecurity/gracl_shm.c
68341 @@ -0,0 +1,40 @@
68342 +#include <linux/kernel.h>
68343 +#include <linux/mm.h>
68344 +#include <linux/sched.h>
68345 +#include <linux/file.h>
68346 +#include <linux/ipc.h>
68347 +#include <linux/gracl.h>
68348 +#include <linux/grsecurity.h>
68349 +#include <linux/grinternal.h>
68350 +
68351 +int
68352 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68353 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
68354 +{
68355 + struct task_struct *task;
68356 +
68357 + if (!gr_acl_is_enabled())
68358 + return 1;
68359 +
68360 + rcu_read_lock();
68361 + read_lock(&tasklist_lock);
68362 +
68363 + task = find_task_by_vpid(shm_cprid);
68364 +
68365 + if (unlikely(!task))
68366 + task = find_task_by_vpid(shm_lapid);
68367 +
68368 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
68369 + (task_pid_nr(task) == shm_lapid)) &&
68370 + (task->acl->mode & GR_PROTSHM) &&
68371 + (task->acl != current->acl))) {
68372 + read_unlock(&tasklist_lock);
68373 + rcu_read_unlock();
68374 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
68375 + return 0;
68376 + }
68377 + read_unlock(&tasklist_lock);
68378 + rcu_read_unlock();
68379 +
68380 + return 1;
68381 +}
68382 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
68383 new file mode 100644
68384 index 0000000..bc0be01
68385 --- /dev/null
68386 +++ b/grsecurity/grsec_chdir.c
68387 @@ -0,0 +1,19 @@
68388 +#include <linux/kernel.h>
68389 +#include <linux/sched.h>
68390 +#include <linux/fs.h>
68391 +#include <linux/file.h>
68392 +#include <linux/grsecurity.h>
68393 +#include <linux/grinternal.h>
68394 +
68395 +void
68396 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
68397 +{
68398 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
68399 + if ((grsec_enable_chdir && grsec_enable_group &&
68400 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
68401 + !grsec_enable_group)) {
68402 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
68403 + }
68404 +#endif
68405 + return;
68406 +}
68407 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
68408 new file mode 100644
68409 index 0000000..bd6e105
68410 --- /dev/null
68411 +++ b/grsecurity/grsec_chroot.c
68412 @@ -0,0 +1,370 @@
68413 +#include <linux/kernel.h>
68414 +#include <linux/module.h>
68415 +#include <linux/sched.h>
68416 +#include <linux/file.h>
68417 +#include <linux/fs.h>
68418 +#include <linux/mount.h>
68419 +#include <linux/types.h>
68420 +#include "../fs/mount.h"
68421 +#include <linux/grsecurity.h>
68422 +#include <linux/grinternal.h>
68423 +
68424 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68425 +static int gr_init_ran;
68426 +#endif
68427 +
68428 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
68429 +{
68430 +#ifdef CONFIG_GRKERNSEC
68431 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
68432 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
68433 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68434 + && gr_init_ran
68435 +#endif
68436 + )
68437 + task->gr_is_chrooted = 1;
68438 + else {
68439 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68440 + if (task_pid_nr(task) == 1 && !gr_init_ran)
68441 + gr_init_ran = 1;
68442 +#endif
68443 + task->gr_is_chrooted = 0;
68444 + }
68445 +
68446 + task->gr_chroot_dentry = path->dentry;
68447 +#endif
68448 + return;
68449 +}
68450 +
68451 +void gr_clear_chroot_entries(struct task_struct *task)
68452 +{
68453 +#ifdef CONFIG_GRKERNSEC
68454 + task->gr_is_chrooted = 0;
68455 + task->gr_chroot_dentry = NULL;
68456 +#endif
68457 + return;
68458 +}
68459 +
68460 +int
68461 +gr_handle_chroot_unix(const pid_t pid)
68462 +{
68463 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68464 + struct task_struct *p;
68465 +
68466 + if (unlikely(!grsec_enable_chroot_unix))
68467 + return 1;
68468 +
68469 + if (likely(!proc_is_chrooted(current)))
68470 + return 1;
68471 +
68472 + rcu_read_lock();
68473 + read_lock(&tasklist_lock);
68474 + p = find_task_by_vpid_unrestricted(pid);
68475 + if (unlikely(p && !have_same_root(current, p))) {
68476 + read_unlock(&tasklist_lock);
68477 + rcu_read_unlock();
68478 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
68479 + return 0;
68480 + }
68481 + read_unlock(&tasklist_lock);
68482 + rcu_read_unlock();
68483 +#endif
68484 + return 1;
68485 +}
68486 +
68487 +int
68488 +gr_handle_chroot_nice(void)
68489 +{
68490 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68491 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
68492 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
68493 + return -EPERM;
68494 + }
68495 +#endif
68496 + return 0;
68497 +}
68498 +
68499 +int
68500 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
68501 +{
68502 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68503 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
68504 + && proc_is_chrooted(current)) {
68505 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
68506 + return -EACCES;
68507 + }
68508 +#endif
68509 + return 0;
68510 +}
68511 +
68512 +int
68513 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
68514 +{
68515 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68516 + struct task_struct *p;
68517 + int ret = 0;
68518 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
68519 + return ret;
68520 +
68521 + read_lock(&tasklist_lock);
68522 + do_each_pid_task(pid, type, p) {
68523 + if (!have_same_root(current, p)) {
68524 + ret = 1;
68525 + goto out;
68526 + }
68527 + } while_each_pid_task(pid, type, p);
68528 +out:
68529 + read_unlock(&tasklist_lock);
68530 + return ret;
68531 +#endif
68532 + return 0;
68533 +}
68534 +
68535 +int
68536 +gr_pid_is_chrooted(struct task_struct *p)
68537 +{
68538 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68539 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
68540 + return 0;
68541 +
68542 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
68543 + !have_same_root(current, p)) {
68544 + return 1;
68545 + }
68546 +#endif
68547 + return 0;
68548 +}
68549 +
68550 +EXPORT_SYMBOL(gr_pid_is_chrooted);
68551 +
68552 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
68553 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
68554 +{
68555 + struct path path, currentroot;
68556 + int ret = 0;
68557 +
68558 + path.dentry = (struct dentry *)u_dentry;
68559 + path.mnt = (struct vfsmount *)u_mnt;
68560 + get_fs_root(current->fs, &currentroot);
68561 + if (path_is_under(&path, &currentroot))
68562 + ret = 1;
68563 + path_put(&currentroot);
68564 +
68565 + return ret;
68566 +}
68567 +#endif
68568 +
68569 +int
68570 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
68571 +{
68572 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68573 + if (!grsec_enable_chroot_fchdir)
68574 + return 1;
68575 +
68576 + if (!proc_is_chrooted(current))
68577 + return 1;
68578 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
68579 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
68580 + return 0;
68581 + }
68582 +#endif
68583 + return 1;
68584 +}
68585 +
68586 +int
68587 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68588 + const time_t shm_createtime)
68589 +{
68590 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68591 + struct task_struct *p;
68592 + time_t starttime;
68593 +
68594 + if (unlikely(!grsec_enable_chroot_shmat))
68595 + return 1;
68596 +
68597 + if (likely(!proc_is_chrooted(current)))
68598 + return 1;
68599 +
68600 + rcu_read_lock();
68601 + read_lock(&tasklist_lock);
68602 +
68603 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
68604 + starttime = p->start_time.tv_sec;
68605 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
68606 + if (have_same_root(current, p)) {
68607 + goto allow;
68608 + } else {
68609 + read_unlock(&tasklist_lock);
68610 + rcu_read_unlock();
68611 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68612 + return 0;
68613 + }
68614 + }
68615 + /* creator exited, pid reuse, fall through to next check */
68616 + }
68617 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
68618 + if (unlikely(!have_same_root(current, p))) {
68619 + read_unlock(&tasklist_lock);
68620 + rcu_read_unlock();
68621 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68622 + return 0;
68623 + }
68624 + }
68625 +
68626 +allow:
68627 + read_unlock(&tasklist_lock);
68628 + rcu_read_unlock();
68629 +#endif
68630 + return 1;
68631 +}
68632 +
68633 +void
68634 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
68635 +{
68636 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68637 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
68638 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
68639 +#endif
68640 + return;
68641 +}
68642 +
68643 +int
68644 +gr_handle_chroot_mknod(const struct dentry *dentry,
68645 + const struct vfsmount *mnt, const int mode)
68646 +{
68647 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68648 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
68649 + proc_is_chrooted(current)) {
68650 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
68651 + return -EPERM;
68652 + }
68653 +#endif
68654 + return 0;
68655 +}
68656 +
68657 +int
68658 +gr_handle_chroot_mount(const struct dentry *dentry,
68659 + const struct vfsmount *mnt, const char *dev_name)
68660 +{
68661 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68662 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
68663 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
68664 + return -EPERM;
68665 + }
68666 +#endif
68667 + return 0;
68668 +}
68669 +
68670 +int
68671 +gr_handle_chroot_pivot(void)
68672 +{
68673 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68674 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
68675 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
68676 + return -EPERM;
68677 + }
68678 +#endif
68679 + return 0;
68680 +}
68681 +
68682 +int
68683 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
68684 +{
68685 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68686 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
68687 + !gr_is_outside_chroot(dentry, mnt)) {
68688 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
68689 + return -EPERM;
68690 + }
68691 +#endif
68692 + return 0;
68693 +}
68694 +
68695 +extern const char *captab_log[];
68696 +extern int captab_log_entries;
68697 +
68698 +int
68699 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
68700 +{
68701 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68702 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68703 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68704 + if (cap_raised(chroot_caps, cap)) {
68705 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
68706 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
68707 + }
68708 + return 0;
68709 + }
68710 + }
68711 +#endif
68712 + return 1;
68713 +}
68714 +
68715 +int
68716 +gr_chroot_is_capable(const int cap)
68717 +{
68718 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68719 + return gr_task_chroot_is_capable(current, current_cred(), cap);
68720 +#endif
68721 + return 1;
68722 +}
68723 +
68724 +int
68725 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
68726 +{
68727 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68728 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68729 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68730 + if (cap_raised(chroot_caps, cap)) {
68731 + return 0;
68732 + }
68733 + }
68734 +#endif
68735 + return 1;
68736 +}
68737 +
68738 +int
68739 +gr_chroot_is_capable_nolog(const int cap)
68740 +{
68741 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68742 + return gr_task_chroot_is_capable_nolog(current, cap);
68743 +#endif
68744 + return 1;
68745 +}
68746 +
68747 +int
68748 +gr_handle_chroot_sysctl(const int op)
68749 +{
68750 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
68751 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
68752 + proc_is_chrooted(current))
68753 + return -EACCES;
68754 +#endif
68755 + return 0;
68756 +}
68757 +
68758 +void
68759 +gr_handle_chroot_chdir(const struct path *path)
68760 +{
68761 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
68762 + if (grsec_enable_chroot_chdir)
68763 + set_fs_pwd(current->fs, path);
68764 +#endif
68765 + return;
68766 +}
68767 +
68768 +int
68769 +gr_handle_chroot_chmod(const struct dentry *dentry,
68770 + const struct vfsmount *mnt, const int mode)
68771 +{
68772 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
68773 + /* allow chmod +s on directories, but not files */
68774 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
68775 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
68776 + proc_is_chrooted(current)) {
68777 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
68778 + return -EPERM;
68779 + }
68780 +#endif
68781 + return 0;
68782 +}
68783 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
68784 new file mode 100644
68785 index 0000000..ce65ceb
68786 --- /dev/null
68787 +++ b/grsecurity/grsec_disabled.c
68788 @@ -0,0 +1,434 @@
68789 +#include <linux/kernel.h>
68790 +#include <linux/module.h>
68791 +#include <linux/sched.h>
68792 +#include <linux/file.h>
68793 +#include <linux/fs.h>
68794 +#include <linux/kdev_t.h>
68795 +#include <linux/net.h>
68796 +#include <linux/in.h>
68797 +#include <linux/ip.h>
68798 +#include <linux/skbuff.h>
68799 +#include <linux/sysctl.h>
68800 +
68801 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
68802 +void
68803 +pax_set_initial_flags(struct linux_binprm *bprm)
68804 +{
68805 + return;
68806 +}
68807 +#endif
68808 +
68809 +#ifdef CONFIG_SYSCTL
68810 +__u32
68811 +gr_handle_sysctl(const struct ctl_table * table, const int op)
68812 +{
68813 + return 0;
68814 +}
68815 +#endif
68816 +
68817 +#ifdef CONFIG_TASKSTATS
68818 +int gr_is_taskstats_denied(int pid)
68819 +{
68820 + return 0;
68821 +}
68822 +#endif
68823 +
68824 +int
68825 +gr_acl_is_enabled(void)
68826 +{
68827 + return 0;
68828 +}
68829 +
68830 +void
68831 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
68832 +{
68833 + return;
68834 +}
68835 +
68836 +int
68837 +gr_handle_rawio(const struct inode *inode)
68838 +{
68839 + return 0;
68840 +}
68841 +
68842 +void
68843 +gr_acl_handle_psacct(struct task_struct *task, const long code)
68844 +{
68845 + return;
68846 +}
68847 +
68848 +int
68849 +gr_handle_ptrace(struct task_struct *task, const long request)
68850 +{
68851 + return 0;
68852 +}
68853 +
68854 +int
68855 +gr_handle_proc_ptrace(struct task_struct *task)
68856 +{
68857 + return 0;
68858 +}
68859 +
68860 +int
68861 +gr_set_acls(const int type)
68862 +{
68863 + return 0;
68864 +}
68865 +
68866 +int
68867 +gr_check_hidden_task(const struct task_struct *tsk)
68868 +{
68869 + return 0;
68870 +}
68871 +
68872 +int
68873 +gr_check_protected_task(const struct task_struct *task)
68874 +{
68875 + return 0;
68876 +}
68877 +
68878 +int
68879 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
68880 +{
68881 + return 0;
68882 +}
68883 +
68884 +void
68885 +gr_copy_label(struct task_struct *tsk)
68886 +{
68887 + return;
68888 +}
68889 +
68890 +void
68891 +gr_set_pax_flags(struct task_struct *task)
68892 +{
68893 + return;
68894 +}
68895 +
68896 +int
68897 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
68898 + const int unsafe_share)
68899 +{
68900 + return 0;
68901 +}
68902 +
68903 +void
68904 +gr_handle_delete(const ino_t ino, const dev_t dev)
68905 +{
68906 + return;
68907 +}
68908 +
68909 +void
68910 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
68911 +{
68912 + return;
68913 +}
68914 +
68915 +void
68916 +gr_handle_crash(struct task_struct *task, const int sig)
68917 +{
68918 + return;
68919 +}
68920 +
68921 +int
68922 +gr_check_crash_exec(const struct file *filp)
68923 +{
68924 + return 0;
68925 +}
68926 +
68927 +int
68928 +gr_check_crash_uid(const kuid_t uid)
68929 +{
68930 + return 0;
68931 +}
68932 +
68933 +void
68934 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68935 + struct dentry *old_dentry,
68936 + struct dentry *new_dentry,
68937 + struct vfsmount *mnt, const __u8 replace)
68938 +{
68939 + return;
68940 +}
68941 +
68942 +int
68943 +gr_search_socket(const int family, const int type, const int protocol)
68944 +{
68945 + return 1;
68946 +}
68947 +
68948 +int
68949 +gr_search_connectbind(const int mode, const struct socket *sock,
68950 + const struct sockaddr_in *addr)
68951 +{
68952 + return 0;
68953 +}
68954 +
68955 +void
68956 +gr_handle_alertkill(struct task_struct *task)
68957 +{
68958 + return;
68959 +}
68960 +
68961 +__u32
68962 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
68963 +{
68964 + return 1;
68965 +}
68966 +
68967 +__u32
68968 +gr_acl_handle_hidden_file(const struct dentry * dentry,
68969 + const struct vfsmount * mnt)
68970 +{
68971 + return 1;
68972 +}
68973 +
68974 +__u32
68975 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
68976 + int acc_mode)
68977 +{
68978 + return 1;
68979 +}
68980 +
68981 +__u32
68982 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
68983 +{
68984 + return 1;
68985 +}
68986 +
68987 +__u32
68988 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
68989 +{
68990 + return 1;
68991 +}
68992 +
68993 +int
68994 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
68995 + unsigned int *vm_flags)
68996 +{
68997 + return 1;
68998 +}
68999 +
69000 +__u32
69001 +gr_acl_handle_truncate(const struct dentry * dentry,
69002 + const struct vfsmount * mnt)
69003 +{
69004 + return 1;
69005 +}
69006 +
69007 +__u32
69008 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
69009 +{
69010 + return 1;
69011 +}
69012 +
69013 +__u32
69014 +gr_acl_handle_access(const struct dentry * dentry,
69015 + const struct vfsmount * mnt, const int fmode)
69016 +{
69017 + return 1;
69018 +}
69019 +
69020 +__u32
69021 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
69022 + umode_t *mode)
69023 +{
69024 + return 1;
69025 +}
69026 +
69027 +__u32
69028 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
69029 +{
69030 + return 1;
69031 +}
69032 +
69033 +__u32
69034 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
69035 +{
69036 + return 1;
69037 +}
69038 +
69039 +void
69040 +grsecurity_init(void)
69041 +{
69042 + return;
69043 +}
69044 +
69045 +umode_t gr_acl_umask(void)
69046 +{
69047 + return 0;
69048 +}
69049 +
69050 +__u32
69051 +gr_acl_handle_mknod(const struct dentry * new_dentry,
69052 + const struct dentry * parent_dentry,
69053 + const struct vfsmount * parent_mnt,
69054 + const int mode)
69055 +{
69056 + return 1;
69057 +}
69058 +
69059 +__u32
69060 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
69061 + const struct dentry * parent_dentry,
69062 + const struct vfsmount * parent_mnt)
69063 +{
69064 + return 1;
69065 +}
69066 +
69067 +__u32
69068 +gr_acl_handle_symlink(const struct dentry * new_dentry,
69069 + const struct dentry * parent_dentry,
69070 + const struct vfsmount * parent_mnt, const struct filename *from)
69071 +{
69072 + return 1;
69073 +}
69074 +
69075 +__u32
69076 +gr_acl_handle_link(const struct dentry * new_dentry,
69077 + const struct dentry * parent_dentry,
69078 + const struct vfsmount * parent_mnt,
69079 + const struct dentry * old_dentry,
69080 + const struct vfsmount * old_mnt, const struct filename *to)
69081 +{
69082 + return 1;
69083 +}
69084 +
69085 +int
69086 +gr_acl_handle_rename(const struct dentry *new_dentry,
69087 + const struct dentry *parent_dentry,
69088 + const struct vfsmount *parent_mnt,
69089 + const struct dentry *old_dentry,
69090 + const struct inode *old_parent_inode,
69091 + const struct vfsmount *old_mnt, const struct filename *newname)
69092 +{
69093 + return 0;
69094 +}
69095 +
69096 +int
69097 +gr_acl_handle_filldir(const struct file *file, const char *name,
69098 + const int namelen, const ino_t ino)
69099 +{
69100 + return 1;
69101 +}
69102 +
69103 +int
69104 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69105 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69106 +{
69107 + return 1;
69108 +}
69109 +
69110 +int
69111 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
69112 +{
69113 + return 0;
69114 +}
69115 +
69116 +int
69117 +gr_search_accept(const struct socket *sock)
69118 +{
69119 + return 0;
69120 +}
69121 +
69122 +int
69123 +gr_search_listen(const struct socket *sock)
69124 +{
69125 + return 0;
69126 +}
69127 +
69128 +int
69129 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
69130 +{
69131 + return 0;
69132 +}
69133 +
69134 +__u32
69135 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
69136 +{
69137 + return 1;
69138 +}
69139 +
69140 +__u32
69141 +gr_acl_handle_creat(const struct dentry * dentry,
69142 + const struct dentry * p_dentry,
69143 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69144 + const int imode)
69145 +{
69146 + return 1;
69147 +}
69148 +
69149 +void
69150 +gr_acl_handle_exit(void)
69151 +{
69152 + return;
69153 +}
69154 +
69155 +int
69156 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69157 +{
69158 + return 1;
69159 +}
69160 +
69161 +void
69162 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
69163 +{
69164 + return;
69165 +}
69166 +
69167 +int
69168 +gr_acl_handle_procpidmem(const struct task_struct *task)
69169 +{
69170 + return 0;
69171 +}
69172 +
69173 +int
69174 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
69175 +{
69176 + return 0;
69177 +}
69178 +
69179 +int
69180 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
69181 +{
69182 + return 0;
69183 +}
69184 +
69185 +void
69186 +gr_set_kernel_label(struct task_struct *task)
69187 +{
69188 + return;
69189 +}
69190 +
69191 +int
69192 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
69193 +{
69194 + return 0;
69195 +}
69196 +
69197 +int
69198 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
69199 +{
69200 + return 0;
69201 +}
69202 +
69203 +int gr_acl_enable_at_secure(void)
69204 +{
69205 + return 0;
69206 +}
69207 +
69208 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
69209 +{
69210 + return dentry->d_sb->s_dev;
69211 +}
69212 +
69213 +void gr_put_exec_file(struct task_struct *task)
69214 +{
69215 + return;
69216 +}
69217 +
69218 +EXPORT_SYMBOL(gr_set_kernel_label);
69219 +#ifdef CONFIG_SECURITY
69220 +EXPORT_SYMBOL(gr_check_user_change);
69221 +EXPORT_SYMBOL(gr_check_group_change);
69222 +#endif
69223 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
69224 new file mode 100644
69225 index 0000000..387032b
69226 --- /dev/null
69227 +++ b/grsecurity/grsec_exec.c
69228 @@ -0,0 +1,187 @@
69229 +#include <linux/kernel.h>
69230 +#include <linux/sched.h>
69231 +#include <linux/file.h>
69232 +#include <linux/binfmts.h>
69233 +#include <linux/fs.h>
69234 +#include <linux/types.h>
69235 +#include <linux/grdefs.h>
69236 +#include <linux/grsecurity.h>
69237 +#include <linux/grinternal.h>
69238 +#include <linux/capability.h>
69239 +#include <linux/module.h>
69240 +#include <linux/compat.h>
69241 +
69242 +#include <asm/uaccess.h>
69243 +
69244 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69245 +static char gr_exec_arg_buf[132];
69246 +static DEFINE_MUTEX(gr_exec_arg_mutex);
69247 +#endif
69248 +
69249 +struct user_arg_ptr {
69250 +#ifdef CONFIG_COMPAT
69251 + bool is_compat;
69252 +#endif
69253 + union {
69254 + const char __user *const __user *native;
69255 +#ifdef CONFIG_COMPAT
69256 + const compat_uptr_t __user *compat;
69257 +#endif
69258 + } ptr;
69259 +};
69260 +
69261 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
69262 +
69263 +void
69264 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
69265 +{
69266 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69267 + char *grarg = gr_exec_arg_buf;
69268 + unsigned int i, x, execlen = 0;
69269 + char c;
69270 +
69271 + if (!((grsec_enable_execlog && grsec_enable_group &&
69272 + in_group_p(grsec_audit_gid))
69273 + || (grsec_enable_execlog && !grsec_enable_group)))
69274 + return;
69275 +
69276 + mutex_lock(&gr_exec_arg_mutex);
69277 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
69278 +
69279 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
69280 + const char __user *p;
69281 + unsigned int len;
69282 +
69283 + p = get_user_arg_ptr(argv, i);
69284 + if (IS_ERR(p))
69285 + goto log;
69286 +
69287 + len = strnlen_user(p, 128 - execlen);
69288 + if (len > 128 - execlen)
69289 + len = 128 - execlen;
69290 + else if (len > 0)
69291 + len--;
69292 + if (copy_from_user(grarg + execlen, p, len))
69293 + goto log;
69294 +
69295 + /* rewrite unprintable characters */
69296 + for (x = 0; x < len; x++) {
69297 + c = *(grarg + execlen + x);
69298 + if (c < 32 || c > 126)
69299 + *(grarg + execlen + x) = ' ';
69300 + }
69301 +
69302 + execlen += len;
69303 + *(grarg + execlen) = ' ';
69304 + *(grarg + execlen + 1) = '\0';
69305 + execlen++;
69306 + }
69307 +
69308 + log:
69309 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
69310 + bprm->file->f_path.mnt, grarg);
69311 + mutex_unlock(&gr_exec_arg_mutex);
69312 +#endif
69313 + return;
69314 +}
69315 +
69316 +#ifdef CONFIG_GRKERNSEC
69317 +extern int gr_acl_is_capable(const int cap);
69318 +extern int gr_acl_is_capable_nolog(const int cap);
69319 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69320 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
69321 +extern int gr_chroot_is_capable(const int cap);
69322 +extern int gr_chroot_is_capable_nolog(const int cap);
69323 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69324 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
69325 +#endif
69326 +
69327 +const char *captab_log[] = {
69328 + "CAP_CHOWN",
69329 + "CAP_DAC_OVERRIDE",
69330 + "CAP_DAC_READ_SEARCH",
69331 + "CAP_FOWNER",
69332 + "CAP_FSETID",
69333 + "CAP_KILL",
69334 + "CAP_SETGID",
69335 + "CAP_SETUID",
69336 + "CAP_SETPCAP",
69337 + "CAP_LINUX_IMMUTABLE",
69338 + "CAP_NET_BIND_SERVICE",
69339 + "CAP_NET_BROADCAST",
69340 + "CAP_NET_ADMIN",
69341 + "CAP_NET_RAW",
69342 + "CAP_IPC_LOCK",
69343 + "CAP_IPC_OWNER",
69344 + "CAP_SYS_MODULE",
69345 + "CAP_SYS_RAWIO",
69346 + "CAP_SYS_CHROOT",
69347 + "CAP_SYS_PTRACE",
69348 + "CAP_SYS_PACCT",
69349 + "CAP_SYS_ADMIN",
69350 + "CAP_SYS_BOOT",
69351 + "CAP_SYS_NICE",
69352 + "CAP_SYS_RESOURCE",
69353 + "CAP_SYS_TIME",
69354 + "CAP_SYS_TTY_CONFIG",
69355 + "CAP_MKNOD",
69356 + "CAP_LEASE",
69357 + "CAP_AUDIT_WRITE",
69358 + "CAP_AUDIT_CONTROL",
69359 + "CAP_SETFCAP",
69360 + "CAP_MAC_OVERRIDE",
69361 + "CAP_MAC_ADMIN",
69362 + "CAP_SYSLOG",
69363 + "CAP_WAKE_ALARM"
69364 +};
69365 +
69366 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
69367 +
69368 +int gr_is_capable(const int cap)
69369 +{
69370 +#ifdef CONFIG_GRKERNSEC
69371 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
69372 + return 1;
69373 + return 0;
69374 +#else
69375 + return 1;
69376 +#endif
69377 +}
69378 +
69379 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69380 +{
69381 +#ifdef CONFIG_GRKERNSEC
69382 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
69383 + return 1;
69384 + return 0;
69385 +#else
69386 + return 1;
69387 +#endif
69388 +}
69389 +
69390 +int gr_is_capable_nolog(const int cap)
69391 +{
69392 +#ifdef CONFIG_GRKERNSEC
69393 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
69394 + return 1;
69395 + return 0;
69396 +#else
69397 + return 1;
69398 +#endif
69399 +}
69400 +
69401 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
69402 +{
69403 +#ifdef CONFIG_GRKERNSEC
69404 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
69405 + return 1;
69406 + return 0;
69407 +#else
69408 + return 1;
69409 +#endif
69410 +}
69411 +
69412 +EXPORT_SYMBOL(gr_is_capable);
69413 +EXPORT_SYMBOL(gr_is_capable_nolog);
69414 +EXPORT_SYMBOL(gr_task_is_capable);
69415 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
69416 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
69417 new file mode 100644
69418 index 0000000..06cc6ea
69419 --- /dev/null
69420 +++ b/grsecurity/grsec_fifo.c
69421 @@ -0,0 +1,24 @@
69422 +#include <linux/kernel.h>
69423 +#include <linux/sched.h>
69424 +#include <linux/fs.h>
69425 +#include <linux/file.h>
69426 +#include <linux/grinternal.h>
69427 +
69428 +int
69429 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
69430 + const struct dentry *dir, const int flag, const int acc_mode)
69431 +{
69432 +#ifdef CONFIG_GRKERNSEC_FIFO
69433 + const struct cred *cred = current_cred();
69434 +
69435 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
69436 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
69437 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
69438 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
69439 + if (!inode_permission(dentry->d_inode, acc_mode))
69440 + 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));
69441 + return -EACCES;
69442 + }
69443 +#endif
69444 + return 0;
69445 +}
69446 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
69447 new file mode 100644
69448 index 0000000..8ca18bf
69449 --- /dev/null
69450 +++ b/grsecurity/grsec_fork.c
69451 @@ -0,0 +1,23 @@
69452 +#include <linux/kernel.h>
69453 +#include <linux/sched.h>
69454 +#include <linux/grsecurity.h>
69455 +#include <linux/grinternal.h>
69456 +#include <linux/errno.h>
69457 +
69458 +void
69459 +gr_log_forkfail(const int retval)
69460 +{
69461 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69462 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
69463 + switch (retval) {
69464 + case -EAGAIN:
69465 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
69466 + break;
69467 + case -ENOMEM:
69468 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
69469 + break;
69470 + }
69471 + }
69472 +#endif
69473 + return;
69474 +}
69475 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
69476 new file mode 100644
69477 index 0000000..087cf30
69478 --- /dev/null
69479 +++ b/grsecurity/grsec_init.c
69480 @@ -0,0 +1,287 @@
69481 +#include <linux/kernel.h>
69482 +#include <linux/sched.h>
69483 +#include <linux/mm.h>
69484 +#include <linux/gracl.h>
69485 +#include <linux/slab.h>
69486 +#include <linux/vmalloc.h>
69487 +#include <linux/percpu.h>
69488 +#include <linux/module.h>
69489 +
69490 +int grsec_enable_ptrace_readexec;
69491 +int grsec_enable_setxid;
69492 +int grsec_enable_symlinkown;
69493 +kgid_t grsec_symlinkown_gid;
69494 +int grsec_enable_brute;
69495 +int grsec_enable_link;
69496 +int grsec_enable_dmesg;
69497 +int grsec_enable_harden_ptrace;
69498 +int grsec_enable_harden_ipc;
69499 +int grsec_enable_fifo;
69500 +int grsec_enable_execlog;
69501 +int grsec_enable_signal;
69502 +int grsec_enable_forkfail;
69503 +int grsec_enable_audit_ptrace;
69504 +int grsec_enable_time;
69505 +int grsec_enable_group;
69506 +kgid_t grsec_audit_gid;
69507 +int grsec_enable_chdir;
69508 +int grsec_enable_mount;
69509 +int grsec_enable_rofs;
69510 +int grsec_deny_new_usb;
69511 +int grsec_enable_chroot_findtask;
69512 +int grsec_enable_chroot_mount;
69513 +int grsec_enable_chroot_shmat;
69514 +int grsec_enable_chroot_fchdir;
69515 +int grsec_enable_chroot_double;
69516 +int grsec_enable_chroot_pivot;
69517 +int grsec_enable_chroot_chdir;
69518 +int grsec_enable_chroot_chmod;
69519 +int grsec_enable_chroot_mknod;
69520 +int grsec_enable_chroot_nice;
69521 +int grsec_enable_chroot_execlog;
69522 +int grsec_enable_chroot_caps;
69523 +int grsec_enable_chroot_sysctl;
69524 +int grsec_enable_chroot_unix;
69525 +int grsec_enable_tpe;
69526 +kgid_t grsec_tpe_gid;
69527 +int grsec_enable_blackhole;
69528 +#ifdef CONFIG_IPV6_MODULE
69529 +EXPORT_SYMBOL(grsec_enable_blackhole);
69530 +#endif
69531 +int grsec_lastack_retries;
69532 +int grsec_enable_tpe_all;
69533 +int grsec_enable_tpe_invert;
69534 +int grsec_enable_socket_all;
69535 +kgid_t grsec_socket_all_gid;
69536 +int grsec_enable_socket_client;
69537 +kgid_t grsec_socket_client_gid;
69538 +int grsec_enable_socket_server;
69539 +kgid_t grsec_socket_server_gid;
69540 +int grsec_resource_logging;
69541 +int grsec_disable_privio;
69542 +int grsec_enable_log_rwxmaps;
69543 +int grsec_lock;
69544 +
69545 +DEFINE_SPINLOCK(grsec_alert_lock);
69546 +unsigned long grsec_alert_wtime = 0;
69547 +unsigned long grsec_alert_fyet = 0;
69548 +
69549 +DEFINE_SPINLOCK(grsec_audit_lock);
69550 +
69551 +DEFINE_RWLOCK(grsec_exec_file_lock);
69552 +
69553 +char *gr_shared_page[4];
69554 +
69555 +char *gr_alert_log_fmt;
69556 +char *gr_audit_log_fmt;
69557 +char *gr_alert_log_buf;
69558 +char *gr_audit_log_buf;
69559 +
69560 +extern struct gr_arg *gr_usermode;
69561 +extern unsigned char *gr_system_salt;
69562 +extern unsigned char *gr_system_sum;
69563 +
69564 +void __init
69565 +grsecurity_init(void)
69566 +{
69567 + int j;
69568 + /* create the per-cpu shared pages */
69569 +
69570 +#ifdef CONFIG_X86
69571 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
69572 +#endif
69573 +
69574 + for (j = 0; j < 4; j++) {
69575 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
69576 + if (gr_shared_page[j] == NULL) {
69577 + panic("Unable to allocate grsecurity shared page");
69578 + return;
69579 + }
69580 + }
69581 +
69582 + /* allocate log buffers */
69583 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
69584 + if (!gr_alert_log_fmt) {
69585 + panic("Unable to allocate grsecurity alert log format buffer");
69586 + return;
69587 + }
69588 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
69589 + if (!gr_audit_log_fmt) {
69590 + panic("Unable to allocate grsecurity audit log format buffer");
69591 + return;
69592 + }
69593 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69594 + if (!gr_alert_log_buf) {
69595 + panic("Unable to allocate grsecurity alert log buffer");
69596 + return;
69597 + }
69598 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69599 + if (!gr_audit_log_buf) {
69600 + panic("Unable to allocate grsecurity audit log buffer");
69601 + return;
69602 + }
69603 +
69604 + /* allocate memory for authentication structure */
69605 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
69606 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
69607 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
69608 +
69609 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
69610 + panic("Unable to allocate grsecurity authentication structure");
69611 + return;
69612 + }
69613 +
69614 +
69615 +#ifdef CONFIG_GRKERNSEC_IO
69616 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
69617 + grsec_disable_privio = 1;
69618 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69619 + grsec_disable_privio = 1;
69620 +#else
69621 + grsec_disable_privio = 0;
69622 +#endif
69623 +#endif
69624 +
69625 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69626 + /* for backward compatibility, tpe_invert always defaults to on if
69627 + enabled in the kernel
69628 + */
69629 + grsec_enable_tpe_invert = 1;
69630 +#endif
69631 +
69632 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69633 +#ifndef CONFIG_GRKERNSEC_SYSCTL
69634 + grsec_lock = 1;
69635 +#endif
69636 +
69637 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69638 + grsec_enable_log_rwxmaps = 1;
69639 +#endif
69640 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69641 + grsec_enable_group = 1;
69642 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
69643 +#endif
69644 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69645 + grsec_enable_ptrace_readexec = 1;
69646 +#endif
69647 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69648 + grsec_enable_chdir = 1;
69649 +#endif
69650 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69651 + grsec_enable_harden_ptrace = 1;
69652 +#endif
69653 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
69654 + grsec_enable_harden_ipc = 1;
69655 +#endif
69656 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69657 + grsec_enable_mount = 1;
69658 +#endif
69659 +#ifdef CONFIG_GRKERNSEC_LINK
69660 + grsec_enable_link = 1;
69661 +#endif
69662 +#ifdef CONFIG_GRKERNSEC_BRUTE
69663 + grsec_enable_brute = 1;
69664 +#endif
69665 +#ifdef CONFIG_GRKERNSEC_DMESG
69666 + grsec_enable_dmesg = 1;
69667 +#endif
69668 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69669 + grsec_enable_blackhole = 1;
69670 + grsec_lastack_retries = 4;
69671 +#endif
69672 +#ifdef CONFIG_GRKERNSEC_FIFO
69673 + grsec_enable_fifo = 1;
69674 +#endif
69675 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69676 + grsec_enable_execlog = 1;
69677 +#endif
69678 +#ifdef CONFIG_GRKERNSEC_SETXID
69679 + grsec_enable_setxid = 1;
69680 +#endif
69681 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69682 + grsec_enable_signal = 1;
69683 +#endif
69684 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69685 + grsec_enable_forkfail = 1;
69686 +#endif
69687 +#ifdef CONFIG_GRKERNSEC_TIME
69688 + grsec_enable_time = 1;
69689 +#endif
69690 +#ifdef CONFIG_GRKERNSEC_RESLOG
69691 + grsec_resource_logging = 1;
69692 +#endif
69693 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69694 + grsec_enable_chroot_findtask = 1;
69695 +#endif
69696 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69697 + grsec_enable_chroot_unix = 1;
69698 +#endif
69699 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69700 + grsec_enable_chroot_mount = 1;
69701 +#endif
69702 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69703 + grsec_enable_chroot_fchdir = 1;
69704 +#endif
69705 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69706 + grsec_enable_chroot_shmat = 1;
69707 +#endif
69708 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69709 + grsec_enable_audit_ptrace = 1;
69710 +#endif
69711 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69712 + grsec_enable_chroot_double = 1;
69713 +#endif
69714 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69715 + grsec_enable_chroot_pivot = 1;
69716 +#endif
69717 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69718 + grsec_enable_chroot_chdir = 1;
69719 +#endif
69720 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69721 + grsec_enable_chroot_chmod = 1;
69722 +#endif
69723 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69724 + grsec_enable_chroot_mknod = 1;
69725 +#endif
69726 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69727 + grsec_enable_chroot_nice = 1;
69728 +#endif
69729 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69730 + grsec_enable_chroot_execlog = 1;
69731 +#endif
69732 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69733 + grsec_enable_chroot_caps = 1;
69734 +#endif
69735 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69736 + grsec_enable_chroot_sysctl = 1;
69737 +#endif
69738 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69739 + grsec_enable_symlinkown = 1;
69740 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
69741 +#endif
69742 +#ifdef CONFIG_GRKERNSEC_TPE
69743 + grsec_enable_tpe = 1;
69744 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
69745 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69746 + grsec_enable_tpe_all = 1;
69747 +#endif
69748 +#endif
69749 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69750 + grsec_enable_socket_all = 1;
69751 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
69752 +#endif
69753 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69754 + grsec_enable_socket_client = 1;
69755 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
69756 +#endif
69757 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69758 + grsec_enable_socket_server = 1;
69759 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
69760 +#endif
69761 +#endif
69762 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
69763 + grsec_deny_new_usb = 1;
69764 +#endif
69765 +
69766 + return;
69767 +}
69768 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
69769 new file mode 100644
69770 index 0000000..f365de0
69771 --- /dev/null
69772 +++ b/grsecurity/grsec_ipc.c
69773 @@ -0,0 +1,22 @@
69774 +#include <linux/kernel.h>
69775 +#include <linux/mm.h>
69776 +#include <linux/sched.h>
69777 +#include <linux/file.h>
69778 +#include <linux/ipc.h>
69779 +#include <linux/ipc_namespace.h>
69780 +#include <linux/grsecurity.h>
69781 +#include <linux/grinternal.h>
69782 +
69783 +int
69784 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
69785 +{
69786 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
69787 + int write = (requested_mode & 00002);
69788 +
69789 + if (grsec_enable_harden_ipc && !(requested_mode & ~granted_mode & 0007) && !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
69790 + gr_log_str2_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", write ? "writ" : "read", GR_GLOBAL_UID(ipcp->cuid));
69791 + return 0;
69792 + }
69793 +#endif
69794 + return 1;
69795 +}
69796 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
69797 new file mode 100644
69798 index 0000000..5e05e20
69799 --- /dev/null
69800 +++ b/grsecurity/grsec_link.c
69801 @@ -0,0 +1,58 @@
69802 +#include <linux/kernel.h>
69803 +#include <linux/sched.h>
69804 +#include <linux/fs.h>
69805 +#include <linux/file.h>
69806 +#include <linux/grinternal.h>
69807 +
69808 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
69809 +{
69810 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69811 + const struct inode *link_inode = link->dentry->d_inode;
69812 +
69813 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
69814 + /* ignore root-owned links, e.g. /proc/self */
69815 + gr_is_global_nonroot(link_inode->i_uid) && target &&
69816 + !uid_eq(link_inode->i_uid, target->i_uid)) {
69817 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
69818 + return 1;
69819 + }
69820 +#endif
69821 + return 0;
69822 +}
69823 +
69824 +int
69825 +gr_handle_follow_link(const struct inode *parent,
69826 + const struct inode *inode,
69827 + const struct dentry *dentry, const struct vfsmount *mnt)
69828 +{
69829 +#ifdef CONFIG_GRKERNSEC_LINK
69830 + const struct cred *cred = current_cred();
69831 +
69832 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
69833 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
69834 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
69835 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
69836 + return -EACCES;
69837 + }
69838 +#endif
69839 + return 0;
69840 +}
69841 +
69842 +int
69843 +gr_handle_hardlink(const struct dentry *dentry,
69844 + const struct vfsmount *mnt,
69845 + struct inode *inode, const int mode, const struct filename *to)
69846 +{
69847 +#ifdef CONFIG_GRKERNSEC_LINK
69848 + const struct cred *cred = current_cred();
69849 +
69850 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
69851 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
69852 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
69853 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
69854 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
69855 + return -EPERM;
69856 + }
69857 +#endif
69858 + return 0;
69859 +}
69860 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
69861 new file mode 100644
69862 index 0000000..dbe0a6b
69863 --- /dev/null
69864 +++ b/grsecurity/grsec_log.c
69865 @@ -0,0 +1,341 @@
69866 +#include <linux/kernel.h>
69867 +#include <linux/sched.h>
69868 +#include <linux/file.h>
69869 +#include <linux/tty.h>
69870 +#include <linux/fs.h>
69871 +#include <linux/mm.h>
69872 +#include <linux/grinternal.h>
69873 +
69874 +#ifdef CONFIG_TREE_PREEMPT_RCU
69875 +#define DISABLE_PREEMPT() preempt_disable()
69876 +#define ENABLE_PREEMPT() preempt_enable()
69877 +#else
69878 +#define DISABLE_PREEMPT()
69879 +#define ENABLE_PREEMPT()
69880 +#endif
69881 +
69882 +#define BEGIN_LOCKS(x) \
69883 + DISABLE_PREEMPT(); \
69884 + rcu_read_lock(); \
69885 + read_lock(&tasklist_lock); \
69886 + read_lock(&grsec_exec_file_lock); \
69887 + if (x != GR_DO_AUDIT) \
69888 + spin_lock(&grsec_alert_lock); \
69889 + else \
69890 + spin_lock(&grsec_audit_lock)
69891 +
69892 +#define END_LOCKS(x) \
69893 + if (x != GR_DO_AUDIT) \
69894 + spin_unlock(&grsec_alert_lock); \
69895 + else \
69896 + spin_unlock(&grsec_audit_lock); \
69897 + read_unlock(&grsec_exec_file_lock); \
69898 + read_unlock(&tasklist_lock); \
69899 + rcu_read_unlock(); \
69900 + ENABLE_PREEMPT(); \
69901 + if (x == GR_DONT_AUDIT) \
69902 + gr_handle_alertkill(current)
69903 +
69904 +enum {
69905 + FLOODING,
69906 + NO_FLOODING
69907 +};
69908 +
69909 +extern char *gr_alert_log_fmt;
69910 +extern char *gr_audit_log_fmt;
69911 +extern char *gr_alert_log_buf;
69912 +extern char *gr_audit_log_buf;
69913 +
69914 +static int gr_log_start(int audit)
69915 +{
69916 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
69917 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
69918 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69919 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
69920 + unsigned long curr_secs = get_seconds();
69921 +
69922 + if (audit == GR_DO_AUDIT)
69923 + goto set_fmt;
69924 +
69925 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
69926 + grsec_alert_wtime = curr_secs;
69927 + grsec_alert_fyet = 0;
69928 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
69929 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
69930 + grsec_alert_fyet++;
69931 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
69932 + grsec_alert_wtime = curr_secs;
69933 + grsec_alert_fyet++;
69934 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
69935 + return FLOODING;
69936 + }
69937 + else return FLOODING;
69938 +
69939 +set_fmt:
69940 +#endif
69941 + memset(buf, 0, PAGE_SIZE);
69942 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
69943 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
69944 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69945 + } else if (current->signal->curr_ip) {
69946 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
69947 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
69948 + } else if (gr_acl_is_enabled()) {
69949 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
69950 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69951 + } else {
69952 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
69953 + strcpy(buf, fmt);
69954 + }
69955 +
69956 + return NO_FLOODING;
69957 +}
69958 +
69959 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69960 + __attribute__ ((format (printf, 2, 0)));
69961 +
69962 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69963 +{
69964 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69965 + unsigned int len = strlen(buf);
69966 +
69967 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69968 +
69969 + return;
69970 +}
69971 +
69972 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69973 + __attribute__ ((format (printf, 2, 3)));
69974 +
69975 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69976 +{
69977 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69978 + unsigned int len = strlen(buf);
69979 + va_list ap;
69980 +
69981 + va_start(ap, msg);
69982 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69983 + va_end(ap);
69984 +
69985 + return;
69986 +}
69987 +
69988 +static void gr_log_end(int audit, int append_default)
69989 +{
69990 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69991 + if (append_default) {
69992 + struct task_struct *task = current;
69993 + struct task_struct *parent = task->real_parent;
69994 + const struct cred *cred = __task_cred(task);
69995 + const struct cred *pcred = __task_cred(parent);
69996 + unsigned int len = strlen(buf);
69997 +
69998 + 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));
69999 + }
70000 +
70001 + printk("%s\n", buf);
70002 +
70003 + return;
70004 +}
70005 +
70006 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
70007 +{
70008 + int logtype;
70009 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
70010 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
70011 + void *voidptr = NULL;
70012 + int num1 = 0, num2 = 0;
70013 + unsigned long ulong1 = 0, ulong2 = 0;
70014 + struct dentry *dentry = NULL;
70015 + struct vfsmount *mnt = NULL;
70016 + struct file *file = NULL;
70017 + struct task_struct *task = NULL;
70018 + struct vm_area_struct *vma = NULL;
70019 + const struct cred *cred, *pcred;
70020 + va_list ap;
70021 +
70022 + BEGIN_LOCKS(audit);
70023 + logtype = gr_log_start(audit);
70024 + if (logtype == FLOODING) {
70025 + END_LOCKS(audit);
70026 + return;
70027 + }
70028 + va_start(ap, argtypes);
70029 + switch (argtypes) {
70030 + case GR_TTYSNIFF:
70031 + task = va_arg(ap, struct task_struct *);
70032 + 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));
70033 + break;
70034 + case GR_SYSCTL_HIDDEN:
70035 + str1 = va_arg(ap, char *);
70036 + gr_log_middle_varargs(audit, msg, result, str1);
70037 + break;
70038 + case GR_RBAC:
70039 + dentry = va_arg(ap, struct dentry *);
70040 + mnt = va_arg(ap, struct vfsmount *);
70041 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
70042 + break;
70043 + case GR_RBAC_STR:
70044 + dentry = va_arg(ap, struct dentry *);
70045 + mnt = va_arg(ap, struct vfsmount *);
70046 + str1 = va_arg(ap, char *);
70047 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
70048 + break;
70049 + case GR_STR_RBAC:
70050 + str1 = va_arg(ap, char *);
70051 + dentry = va_arg(ap, struct dentry *);
70052 + mnt = va_arg(ap, struct vfsmount *);
70053 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
70054 + break;
70055 + case GR_RBAC_MODE2:
70056 + dentry = va_arg(ap, struct dentry *);
70057 + mnt = va_arg(ap, struct vfsmount *);
70058 + str1 = va_arg(ap, char *);
70059 + str2 = va_arg(ap, char *);
70060 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
70061 + break;
70062 + case GR_RBAC_MODE3:
70063 + dentry = va_arg(ap, struct dentry *);
70064 + mnt = va_arg(ap, struct vfsmount *);
70065 + str1 = va_arg(ap, char *);
70066 + str2 = va_arg(ap, char *);
70067 + str3 = va_arg(ap, char *);
70068 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
70069 + break;
70070 + case GR_FILENAME:
70071 + dentry = va_arg(ap, struct dentry *);
70072 + mnt = va_arg(ap, struct vfsmount *);
70073 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
70074 + break;
70075 + case GR_STR_FILENAME:
70076 + str1 = va_arg(ap, char *);
70077 + dentry = va_arg(ap, struct dentry *);
70078 + mnt = va_arg(ap, struct vfsmount *);
70079 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
70080 + break;
70081 + case GR_FILENAME_STR:
70082 + dentry = va_arg(ap, struct dentry *);
70083 + mnt = va_arg(ap, struct vfsmount *);
70084 + str1 = va_arg(ap, char *);
70085 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
70086 + break;
70087 + case GR_FILENAME_TWO_INT:
70088 + dentry = va_arg(ap, struct dentry *);
70089 + mnt = va_arg(ap, struct vfsmount *);
70090 + num1 = va_arg(ap, int);
70091 + num2 = va_arg(ap, int);
70092 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
70093 + break;
70094 + case GR_FILENAME_TWO_INT_STR:
70095 + dentry = va_arg(ap, struct dentry *);
70096 + mnt = va_arg(ap, struct vfsmount *);
70097 + num1 = va_arg(ap, int);
70098 + num2 = va_arg(ap, int);
70099 + str1 = va_arg(ap, char *);
70100 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
70101 + break;
70102 + case GR_TEXTREL:
70103 + file = va_arg(ap, struct file *);
70104 + ulong1 = va_arg(ap, unsigned long);
70105 + ulong2 = va_arg(ap, unsigned long);
70106 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
70107 + break;
70108 + case GR_PTRACE:
70109 + task = va_arg(ap, struct task_struct *);
70110 + 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));
70111 + break;
70112 + case GR_RESOURCE:
70113 + task = va_arg(ap, struct task_struct *);
70114 + cred = __task_cred(task);
70115 + pcred = __task_cred(task->real_parent);
70116 + ulong1 = va_arg(ap, unsigned long);
70117 + str1 = va_arg(ap, char *);
70118 + ulong2 = va_arg(ap, unsigned long);
70119 + 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));
70120 + break;
70121 + case GR_CAP:
70122 + task = va_arg(ap, struct task_struct *);
70123 + cred = __task_cred(task);
70124 + pcred = __task_cred(task->real_parent);
70125 + str1 = va_arg(ap, char *);
70126 + 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));
70127 + break;
70128 + case GR_SIG:
70129 + str1 = va_arg(ap, char *);
70130 + voidptr = va_arg(ap, void *);
70131 + gr_log_middle_varargs(audit, msg, str1, voidptr);
70132 + break;
70133 + case GR_SIG2:
70134 + task = va_arg(ap, struct task_struct *);
70135 + cred = __task_cred(task);
70136 + pcred = __task_cred(task->real_parent);
70137 + num1 = va_arg(ap, int);
70138 + 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));
70139 + break;
70140 + case GR_CRASH1:
70141 + task = va_arg(ap, struct task_struct *);
70142 + cred = __task_cred(task);
70143 + pcred = __task_cred(task->real_parent);
70144 + ulong1 = va_arg(ap, unsigned long);
70145 + 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);
70146 + break;
70147 + case GR_CRASH2:
70148 + task = va_arg(ap, struct task_struct *);
70149 + cred = __task_cred(task);
70150 + pcred = __task_cred(task->real_parent);
70151 + ulong1 = va_arg(ap, unsigned long);
70152 + 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);
70153 + break;
70154 + case GR_RWXMAP:
70155 + file = va_arg(ap, struct file *);
70156 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
70157 + break;
70158 + case GR_RWXMAPVMA:
70159 + vma = va_arg(ap, struct vm_area_struct *);
70160 + if (vma->vm_file)
70161 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
70162 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
70163 + str1 = "<stack>";
70164 + else if (vma->vm_start <= current->mm->brk &&
70165 + vma->vm_end >= current->mm->start_brk)
70166 + str1 = "<heap>";
70167 + else
70168 + str1 = "<anonymous mapping>";
70169 + gr_log_middle_varargs(audit, msg, str1);
70170 + break;
70171 + case GR_PSACCT:
70172 + {
70173 + unsigned int wday, cday;
70174 + __u8 whr, chr;
70175 + __u8 wmin, cmin;
70176 + __u8 wsec, csec;
70177 + char cur_tty[64] = { 0 };
70178 + char parent_tty[64] = { 0 };
70179 +
70180 + task = va_arg(ap, struct task_struct *);
70181 + wday = va_arg(ap, unsigned int);
70182 + cday = va_arg(ap, unsigned int);
70183 + whr = va_arg(ap, int);
70184 + chr = va_arg(ap, int);
70185 + wmin = va_arg(ap, int);
70186 + cmin = va_arg(ap, int);
70187 + wsec = va_arg(ap, int);
70188 + csec = va_arg(ap, int);
70189 + ulong1 = va_arg(ap, unsigned long);
70190 + cred = __task_cred(task);
70191 + pcred = __task_cred(task->real_parent);
70192 +
70193 + 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));
70194 + }
70195 + break;
70196 + default:
70197 + gr_log_middle(audit, msg, ap);
70198 + }
70199 + va_end(ap);
70200 + // these don't need DEFAULTSECARGS printed on the end
70201 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
70202 + gr_log_end(audit, 0);
70203 + else
70204 + gr_log_end(audit, 1);
70205 + END_LOCKS(audit);
70206 +}
70207 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
70208 new file mode 100644
70209 index 0000000..f536303
70210 --- /dev/null
70211 +++ b/grsecurity/grsec_mem.c
70212 @@ -0,0 +1,40 @@
70213 +#include <linux/kernel.h>
70214 +#include <linux/sched.h>
70215 +#include <linux/mm.h>
70216 +#include <linux/mman.h>
70217 +#include <linux/grinternal.h>
70218 +
70219 +void
70220 +gr_handle_ioperm(void)
70221 +{
70222 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
70223 + return;
70224 +}
70225 +
70226 +void
70227 +gr_handle_iopl(void)
70228 +{
70229 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
70230 + return;
70231 +}
70232 +
70233 +void
70234 +gr_handle_mem_readwrite(u64 from, u64 to)
70235 +{
70236 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
70237 + return;
70238 +}
70239 +
70240 +void
70241 +gr_handle_vm86(void)
70242 +{
70243 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
70244 + return;
70245 +}
70246 +
70247 +void
70248 +gr_log_badprocpid(const char *entry)
70249 +{
70250 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
70251 + return;
70252 +}
70253 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
70254 new file mode 100644
70255 index 0000000..2131422
70256 --- /dev/null
70257 +++ b/grsecurity/grsec_mount.c
70258 @@ -0,0 +1,62 @@
70259 +#include <linux/kernel.h>
70260 +#include <linux/sched.h>
70261 +#include <linux/mount.h>
70262 +#include <linux/grsecurity.h>
70263 +#include <linux/grinternal.h>
70264 +
70265 +void
70266 +gr_log_remount(const char *devname, const int retval)
70267 +{
70268 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70269 + if (grsec_enable_mount && (retval >= 0))
70270 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
70271 +#endif
70272 + return;
70273 +}
70274 +
70275 +void
70276 +gr_log_unmount(const char *devname, const int retval)
70277 +{
70278 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70279 + if (grsec_enable_mount && (retval >= 0))
70280 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
70281 +#endif
70282 + return;
70283 +}
70284 +
70285 +void
70286 +gr_log_mount(const char *from, const char *to, const int retval)
70287 +{
70288 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70289 + if (grsec_enable_mount && (retval >= 0))
70290 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
70291 +#endif
70292 + return;
70293 +}
70294 +
70295 +int
70296 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
70297 +{
70298 +#ifdef CONFIG_GRKERNSEC_ROFS
70299 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
70300 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
70301 + return -EPERM;
70302 + } else
70303 + return 0;
70304 +#endif
70305 + return 0;
70306 +}
70307 +
70308 +int
70309 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
70310 +{
70311 +#ifdef CONFIG_GRKERNSEC_ROFS
70312 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
70313 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
70314 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
70315 + return -EPERM;
70316 + } else
70317 + return 0;
70318 +#endif
70319 + return 0;
70320 +}
70321 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
70322 new file mode 100644
70323 index 0000000..6ee9d50
70324 --- /dev/null
70325 +++ b/grsecurity/grsec_pax.c
70326 @@ -0,0 +1,45 @@
70327 +#include <linux/kernel.h>
70328 +#include <linux/sched.h>
70329 +#include <linux/mm.h>
70330 +#include <linux/file.h>
70331 +#include <linux/grinternal.h>
70332 +#include <linux/grsecurity.h>
70333 +
70334 +void
70335 +gr_log_textrel(struct vm_area_struct * vma)
70336 +{
70337 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70338 + if (grsec_enable_log_rwxmaps)
70339 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
70340 +#endif
70341 + return;
70342 +}
70343 +
70344 +void gr_log_ptgnustack(struct file *file)
70345 +{
70346 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70347 + if (grsec_enable_log_rwxmaps)
70348 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
70349 +#endif
70350 + return;
70351 +}
70352 +
70353 +void
70354 +gr_log_rwxmmap(struct file *file)
70355 +{
70356 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70357 + if (grsec_enable_log_rwxmaps)
70358 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
70359 +#endif
70360 + return;
70361 +}
70362 +
70363 +void
70364 +gr_log_rwxmprotect(struct vm_area_struct *vma)
70365 +{
70366 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70367 + if (grsec_enable_log_rwxmaps)
70368 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
70369 +#endif
70370 + return;
70371 +}
70372 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
70373 new file mode 100644
70374 index 0000000..f7f29aa
70375 --- /dev/null
70376 +++ b/grsecurity/grsec_ptrace.c
70377 @@ -0,0 +1,30 @@
70378 +#include <linux/kernel.h>
70379 +#include <linux/sched.h>
70380 +#include <linux/grinternal.h>
70381 +#include <linux/security.h>
70382 +
70383 +void
70384 +gr_audit_ptrace(struct task_struct *task)
70385 +{
70386 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70387 + if (grsec_enable_audit_ptrace)
70388 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
70389 +#endif
70390 + return;
70391 +}
70392 +
70393 +int
70394 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
70395 +{
70396 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70397 + const struct dentry *dentry = file->f_path.dentry;
70398 + const struct vfsmount *mnt = file->f_path.mnt;
70399 +
70400 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
70401 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
70402 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
70403 + return -EACCES;
70404 + }
70405 +#endif
70406 + return 0;
70407 +}
70408 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
70409 new file mode 100644
70410 index 0000000..4e29cc7
70411 --- /dev/null
70412 +++ b/grsecurity/grsec_sig.c
70413 @@ -0,0 +1,246 @@
70414 +#include <linux/kernel.h>
70415 +#include <linux/sched.h>
70416 +#include <linux/fs.h>
70417 +#include <linux/delay.h>
70418 +#include <linux/grsecurity.h>
70419 +#include <linux/grinternal.h>
70420 +#include <linux/hardirq.h>
70421 +
70422 +char *signames[] = {
70423 + [SIGSEGV] = "Segmentation fault",
70424 + [SIGILL] = "Illegal instruction",
70425 + [SIGABRT] = "Abort",
70426 + [SIGBUS] = "Invalid alignment/Bus error"
70427 +};
70428 +
70429 +void
70430 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
70431 +{
70432 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70433 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
70434 + (sig == SIGABRT) || (sig == SIGBUS))) {
70435 + if (task_pid_nr(t) == task_pid_nr(current)) {
70436 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
70437 + } else {
70438 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
70439 + }
70440 + }
70441 +#endif
70442 + return;
70443 +}
70444 +
70445 +int
70446 +gr_handle_signal(const struct task_struct *p, const int sig)
70447 +{
70448 +#ifdef CONFIG_GRKERNSEC
70449 + /* ignore the 0 signal for protected task checks */
70450 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
70451 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
70452 + return -EPERM;
70453 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
70454 + return -EPERM;
70455 + }
70456 +#endif
70457 + return 0;
70458 +}
70459 +
70460 +#ifdef CONFIG_GRKERNSEC
70461 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
70462 +
70463 +int gr_fake_force_sig(int sig, struct task_struct *t)
70464 +{
70465 + unsigned long int flags;
70466 + int ret, blocked, ignored;
70467 + struct k_sigaction *action;
70468 +
70469 + spin_lock_irqsave(&t->sighand->siglock, flags);
70470 + action = &t->sighand->action[sig-1];
70471 + ignored = action->sa.sa_handler == SIG_IGN;
70472 + blocked = sigismember(&t->blocked, sig);
70473 + if (blocked || ignored) {
70474 + action->sa.sa_handler = SIG_DFL;
70475 + if (blocked) {
70476 + sigdelset(&t->blocked, sig);
70477 + recalc_sigpending_and_wake(t);
70478 + }
70479 + }
70480 + if (action->sa.sa_handler == SIG_DFL)
70481 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
70482 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
70483 +
70484 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
70485 +
70486 + return ret;
70487 +}
70488 +#endif
70489 +
70490 +#ifdef CONFIG_GRKERNSEC_BRUTE
70491 +#define GR_USER_BAN_TIME (15 * 60)
70492 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
70493 +
70494 +static int __get_dumpable(unsigned long mm_flags)
70495 +{
70496 + int ret;
70497 +
70498 + ret = mm_flags & MMF_DUMPABLE_MASK;
70499 + return (ret >= 2) ? 2 : ret;
70500 +}
70501 +#endif
70502 +
70503 +void gr_handle_brute_attach(unsigned long mm_flags)
70504 +{
70505 +#ifdef CONFIG_GRKERNSEC_BRUTE
70506 + struct task_struct *p = current;
70507 + kuid_t uid = GLOBAL_ROOT_UID;
70508 + int daemon = 0;
70509 +
70510 + if (!grsec_enable_brute)
70511 + return;
70512 +
70513 + rcu_read_lock();
70514 + read_lock(&tasklist_lock);
70515 + read_lock(&grsec_exec_file_lock);
70516 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
70517 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
70518 + p->real_parent->brute = 1;
70519 + daemon = 1;
70520 + } else {
70521 + const struct cred *cred = __task_cred(p), *cred2;
70522 + struct task_struct *tsk, *tsk2;
70523 +
70524 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
70525 + struct user_struct *user;
70526 +
70527 + uid = cred->uid;
70528 +
70529 + /* this is put upon execution past expiration */
70530 + user = find_user(uid);
70531 + if (user == NULL)
70532 + goto unlock;
70533 + user->suid_banned = 1;
70534 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
70535 + if (user->suid_ban_expires == ~0UL)
70536 + user->suid_ban_expires--;
70537 +
70538 + /* only kill other threads of the same binary, from the same user */
70539 + do_each_thread(tsk2, tsk) {
70540 + cred2 = __task_cred(tsk);
70541 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
70542 + gr_fake_force_sig(SIGKILL, tsk);
70543 + } while_each_thread(tsk2, tsk);
70544 + }
70545 + }
70546 +unlock:
70547 + read_unlock(&grsec_exec_file_lock);
70548 + read_unlock(&tasklist_lock);
70549 + rcu_read_unlock();
70550 +
70551 + if (gr_is_global_nonroot(uid))
70552 + 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);
70553 + else if (daemon)
70554 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
70555 +
70556 +#endif
70557 + return;
70558 +}
70559 +
70560 +void gr_handle_brute_check(void)
70561 +{
70562 +#ifdef CONFIG_GRKERNSEC_BRUTE
70563 + struct task_struct *p = current;
70564 +
70565 + if (unlikely(p->brute)) {
70566 + if (!grsec_enable_brute)
70567 + p->brute = 0;
70568 + else if (time_before(get_seconds(), p->brute_expires))
70569 + msleep(30 * 1000);
70570 + }
70571 +#endif
70572 + return;
70573 +}
70574 +
70575 +void gr_handle_kernel_exploit(void)
70576 +{
70577 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70578 + const struct cred *cred;
70579 + struct task_struct *tsk, *tsk2;
70580 + struct user_struct *user;
70581 + kuid_t uid;
70582 +
70583 + if (in_irq() || in_serving_softirq() || in_nmi())
70584 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
70585 +
70586 + uid = current_uid();
70587 +
70588 + if (gr_is_global_root(uid))
70589 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
70590 + else {
70591 + /* kill all the processes of this user, hold a reference
70592 + to their creds struct, and prevent them from creating
70593 + another process until system reset
70594 + */
70595 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
70596 + GR_GLOBAL_UID(uid));
70597 + /* we intentionally leak this ref */
70598 + user = get_uid(current->cred->user);
70599 + if (user)
70600 + user->kernel_banned = 1;
70601 +
70602 + /* kill all processes of this user */
70603 + read_lock(&tasklist_lock);
70604 + do_each_thread(tsk2, tsk) {
70605 + cred = __task_cred(tsk);
70606 + if (uid_eq(cred->uid, uid))
70607 + gr_fake_force_sig(SIGKILL, tsk);
70608 + } while_each_thread(tsk2, tsk);
70609 + read_unlock(&tasklist_lock);
70610 + }
70611 +#endif
70612 +}
70613 +
70614 +#ifdef CONFIG_GRKERNSEC_BRUTE
70615 +static bool suid_ban_expired(struct user_struct *user)
70616 +{
70617 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
70618 + user->suid_banned = 0;
70619 + user->suid_ban_expires = 0;
70620 + free_uid(user);
70621 + return true;
70622 + }
70623 +
70624 + return false;
70625 +}
70626 +#endif
70627 +
70628 +int gr_process_kernel_exec_ban(void)
70629 +{
70630 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70631 + if (unlikely(current->cred->user->kernel_banned))
70632 + return -EPERM;
70633 +#endif
70634 + return 0;
70635 +}
70636 +
70637 +int gr_process_kernel_setuid_ban(struct user_struct *user)
70638 +{
70639 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70640 + if (unlikely(user->kernel_banned))
70641 + gr_fake_force_sig(SIGKILL, current);
70642 +#endif
70643 + return 0;
70644 +}
70645 +
70646 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
70647 +{
70648 +#ifdef CONFIG_GRKERNSEC_BRUTE
70649 + struct user_struct *user = current->cred->user;
70650 + if (unlikely(user->suid_banned)) {
70651 + if (suid_ban_expired(user))
70652 + return 0;
70653 + /* disallow execution of suid binaries only */
70654 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
70655 + return -EPERM;
70656 + }
70657 +#endif
70658 + return 0;
70659 +}
70660 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
70661 new file mode 100644
70662 index 0000000..4030d57
70663 --- /dev/null
70664 +++ b/grsecurity/grsec_sock.c
70665 @@ -0,0 +1,244 @@
70666 +#include <linux/kernel.h>
70667 +#include <linux/module.h>
70668 +#include <linux/sched.h>
70669 +#include <linux/file.h>
70670 +#include <linux/net.h>
70671 +#include <linux/in.h>
70672 +#include <linux/ip.h>
70673 +#include <net/sock.h>
70674 +#include <net/inet_sock.h>
70675 +#include <linux/grsecurity.h>
70676 +#include <linux/grinternal.h>
70677 +#include <linux/gracl.h>
70678 +
70679 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
70680 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
70681 +
70682 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
70683 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
70684 +
70685 +#ifdef CONFIG_UNIX_MODULE
70686 +EXPORT_SYMBOL(gr_acl_handle_unix);
70687 +EXPORT_SYMBOL(gr_acl_handle_mknod);
70688 +EXPORT_SYMBOL(gr_handle_chroot_unix);
70689 +EXPORT_SYMBOL(gr_handle_create);
70690 +#endif
70691 +
70692 +#ifdef CONFIG_GRKERNSEC
70693 +#define gr_conn_table_size 32749
70694 +struct conn_table_entry {
70695 + struct conn_table_entry *next;
70696 + struct signal_struct *sig;
70697 +};
70698 +
70699 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
70700 +DEFINE_SPINLOCK(gr_conn_table_lock);
70701 +
70702 +extern const char * gr_socktype_to_name(unsigned char type);
70703 +extern const char * gr_proto_to_name(unsigned char proto);
70704 +extern const char * gr_sockfamily_to_name(unsigned char family);
70705 +
70706 +static __inline__ int
70707 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
70708 +{
70709 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
70710 +}
70711 +
70712 +static __inline__ int
70713 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
70714 + __u16 sport, __u16 dport)
70715 +{
70716 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
70717 + sig->gr_sport == sport && sig->gr_dport == dport))
70718 + return 1;
70719 + else
70720 + return 0;
70721 +}
70722 +
70723 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
70724 +{
70725 + struct conn_table_entry **match;
70726 + unsigned int index;
70727 +
70728 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70729 + sig->gr_sport, sig->gr_dport,
70730 + gr_conn_table_size);
70731 +
70732 + newent->sig = sig;
70733 +
70734 + match = &gr_conn_table[index];
70735 + newent->next = *match;
70736 + *match = newent;
70737 +
70738 + return;
70739 +}
70740 +
70741 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
70742 +{
70743 + struct conn_table_entry *match, *last = NULL;
70744 + unsigned int index;
70745 +
70746 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70747 + sig->gr_sport, sig->gr_dport,
70748 + gr_conn_table_size);
70749 +
70750 + match = gr_conn_table[index];
70751 + while (match && !conn_match(match->sig,
70752 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
70753 + sig->gr_dport)) {
70754 + last = match;
70755 + match = match->next;
70756 + }
70757 +
70758 + if (match) {
70759 + if (last)
70760 + last->next = match->next;
70761 + else
70762 + gr_conn_table[index] = NULL;
70763 + kfree(match);
70764 + }
70765 +
70766 + return;
70767 +}
70768 +
70769 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
70770 + __u16 sport, __u16 dport)
70771 +{
70772 + struct conn_table_entry *match;
70773 + unsigned int index;
70774 +
70775 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
70776 +
70777 + match = gr_conn_table[index];
70778 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
70779 + match = match->next;
70780 +
70781 + if (match)
70782 + return match->sig;
70783 + else
70784 + return NULL;
70785 +}
70786 +
70787 +#endif
70788 +
70789 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
70790 +{
70791 +#ifdef CONFIG_GRKERNSEC
70792 + struct signal_struct *sig = task->signal;
70793 + struct conn_table_entry *newent;
70794 +
70795 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
70796 + if (newent == NULL)
70797 + return;
70798 + /* no bh lock needed since we are called with bh disabled */
70799 + spin_lock(&gr_conn_table_lock);
70800 + gr_del_task_from_ip_table_nolock(sig);
70801 + sig->gr_saddr = inet->inet_rcv_saddr;
70802 + sig->gr_daddr = inet->inet_daddr;
70803 + sig->gr_sport = inet->inet_sport;
70804 + sig->gr_dport = inet->inet_dport;
70805 + gr_add_to_task_ip_table_nolock(sig, newent);
70806 + spin_unlock(&gr_conn_table_lock);
70807 +#endif
70808 + return;
70809 +}
70810 +
70811 +void gr_del_task_from_ip_table(struct task_struct *task)
70812 +{
70813 +#ifdef CONFIG_GRKERNSEC
70814 + spin_lock_bh(&gr_conn_table_lock);
70815 + gr_del_task_from_ip_table_nolock(task->signal);
70816 + spin_unlock_bh(&gr_conn_table_lock);
70817 +#endif
70818 + return;
70819 +}
70820 +
70821 +void
70822 +gr_attach_curr_ip(const struct sock *sk)
70823 +{
70824 +#ifdef CONFIG_GRKERNSEC
70825 + struct signal_struct *p, *set;
70826 + const struct inet_sock *inet = inet_sk(sk);
70827 +
70828 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
70829 + return;
70830 +
70831 + set = current->signal;
70832 +
70833 + spin_lock_bh(&gr_conn_table_lock);
70834 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
70835 + inet->inet_dport, inet->inet_sport);
70836 + if (unlikely(p != NULL)) {
70837 + set->curr_ip = p->curr_ip;
70838 + set->used_accept = 1;
70839 + gr_del_task_from_ip_table_nolock(p);
70840 + spin_unlock_bh(&gr_conn_table_lock);
70841 + return;
70842 + }
70843 + spin_unlock_bh(&gr_conn_table_lock);
70844 +
70845 + set->curr_ip = inet->inet_daddr;
70846 + set->used_accept = 1;
70847 +#endif
70848 + return;
70849 +}
70850 +
70851 +int
70852 +gr_handle_sock_all(const int family, const int type, const int protocol)
70853 +{
70854 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70855 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
70856 + (family != AF_UNIX)) {
70857 + if (family == AF_INET)
70858 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
70859 + else
70860 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
70861 + return -EACCES;
70862 + }
70863 +#endif
70864 + return 0;
70865 +}
70866 +
70867 +int
70868 +gr_handle_sock_server(const struct sockaddr *sck)
70869 +{
70870 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70871 + if (grsec_enable_socket_server &&
70872 + in_group_p(grsec_socket_server_gid) &&
70873 + sck && (sck->sa_family != AF_UNIX) &&
70874 + (sck->sa_family != AF_LOCAL)) {
70875 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70876 + return -EACCES;
70877 + }
70878 +#endif
70879 + return 0;
70880 +}
70881 +
70882 +int
70883 +gr_handle_sock_server_other(const struct sock *sck)
70884 +{
70885 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70886 + if (grsec_enable_socket_server &&
70887 + in_group_p(grsec_socket_server_gid) &&
70888 + sck && (sck->sk_family != AF_UNIX) &&
70889 + (sck->sk_family != AF_LOCAL)) {
70890 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70891 + return -EACCES;
70892 + }
70893 +#endif
70894 + return 0;
70895 +}
70896 +
70897 +int
70898 +gr_handle_sock_client(const struct sockaddr *sck)
70899 +{
70900 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70901 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
70902 + sck && (sck->sa_family != AF_UNIX) &&
70903 + (sck->sa_family != AF_LOCAL)) {
70904 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
70905 + return -EACCES;
70906 + }
70907 +#endif
70908 + return 0;
70909 +}
70910 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
70911 new file mode 100644
70912 index 0000000..8159888
70913 --- /dev/null
70914 +++ b/grsecurity/grsec_sysctl.c
70915 @@ -0,0 +1,479 @@
70916 +#include <linux/kernel.h>
70917 +#include <linux/sched.h>
70918 +#include <linux/sysctl.h>
70919 +#include <linux/grsecurity.h>
70920 +#include <linux/grinternal.h>
70921 +
70922 +int
70923 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
70924 +{
70925 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70926 + if (dirname == NULL || name == NULL)
70927 + return 0;
70928 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
70929 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
70930 + return -EACCES;
70931 + }
70932 +#endif
70933 + return 0;
70934 +}
70935 +
70936 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
70937 +static int __maybe_unused __read_only one = 1;
70938 +#endif
70939 +
70940 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
70941 + defined(CONFIG_GRKERNSEC_DENYUSB)
70942 +struct ctl_table grsecurity_table[] = {
70943 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70944 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
70945 +#ifdef CONFIG_GRKERNSEC_IO
70946 + {
70947 + .procname = "disable_priv_io",
70948 + .data = &grsec_disable_privio,
70949 + .maxlen = sizeof(int),
70950 + .mode = 0600,
70951 + .proc_handler = &proc_dointvec,
70952 + },
70953 +#endif
70954 +#endif
70955 +#ifdef CONFIG_GRKERNSEC_LINK
70956 + {
70957 + .procname = "linking_restrictions",
70958 + .data = &grsec_enable_link,
70959 + .maxlen = sizeof(int),
70960 + .mode = 0600,
70961 + .proc_handler = &proc_dointvec,
70962 + },
70963 +#endif
70964 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70965 + {
70966 + .procname = "enforce_symlinksifowner",
70967 + .data = &grsec_enable_symlinkown,
70968 + .maxlen = sizeof(int),
70969 + .mode = 0600,
70970 + .proc_handler = &proc_dointvec,
70971 + },
70972 + {
70973 + .procname = "symlinkown_gid",
70974 + .data = &grsec_symlinkown_gid,
70975 + .maxlen = sizeof(int),
70976 + .mode = 0600,
70977 + .proc_handler = &proc_dointvec,
70978 + },
70979 +#endif
70980 +#ifdef CONFIG_GRKERNSEC_BRUTE
70981 + {
70982 + .procname = "deter_bruteforce",
70983 + .data = &grsec_enable_brute,
70984 + .maxlen = sizeof(int),
70985 + .mode = 0600,
70986 + .proc_handler = &proc_dointvec,
70987 + },
70988 +#endif
70989 +#ifdef CONFIG_GRKERNSEC_FIFO
70990 + {
70991 + .procname = "fifo_restrictions",
70992 + .data = &grsec_enable_fifo,
70993 + .maxlen = sizeof(int),
70994 + .mode = 0600,
70995 + .proc_handler = &proc_dointvec,
70996 + },
70997 +#endif
70998 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70999 + {
71000 + .procname = "ptrace_readexec",
71001 + .data = &grsec_enable_ptrace_readexec,
71002 + .maxlen = sizeof(int),
71003 + .mode = 0600,
71004 + .proc_handler = &proc_dointvec,
71005 + },
71006 +#endif
71007 +#ifdef CONFIG_GRKERNSEC_SETXID
71008 + {
71009 + .procname = "consistent_setxid",
71010 + .data = &grsec_enable_setxid,
71011 + .maxlen = sizeof(int),
71012 + .mode = 0600,
71013 + .proc_handler = &proc_dointvec,
71014 + },
71015 +#endif
71016 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71017 + {
71018 + .procname = "ip_blackhole",
71019 + .data = &grsec_enable_blackhole,
71020 + .maxlen = sizeof(int),
71021 + .mode = 0600,
71022 + .proc_handler = &proc_dointvec,
71023 + },
71024 + {
71025 + .procname = "lastack_retries",
71026 + .data = &grsec_lastack_retries,
71027 + .maxlen = sizeof(int),
71028 + .mode = 0600,
71029 + .proc_handler = &proc_dointvec,
71030 + },
71031 +#endif
71032 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71033 + {
71034 + .procname = "exec_logging",
71035 + .data = &grsec_enable_execlog,
71036 + .maxlen = sizeof(int),
71037 + .mode = 0600,
71038 + .proc_handler = &proc_dointvec,
71039 + },
71040 +#endif
71041 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71042 + {
71043 + .procname = "rwxmap_logging",
71044 + .data = &grsec_enable_log_rwxmaps,
71045 + .maxlen = sizeof(int),
71046 + .mode = 0600,
71047 + .proc_handler = &proc_dointvec,
71048 + },
71049 +#endif
71050 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71051 + {
71052 + .procname = "signal_logging",
71053 + .data = &grsec_enable_signal,
71054 + .maxlen = sizeof(int),
71055 + .mode = 0600,
71056 + .proc_handler = &proc_dointvec,
71057 + },
71058 +#endif
71059 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71060 + {
71061 + .procname = "forkfail_logging",
71062 + .data = &grsec_enable_forkfail,
71063 + .maxlen = sizeof(int),
71064 + .mode = 0600,
71065 + .proc_handler = &proc_dointvec,
71066 + },
71067 +#endif
71068 +#ifdef CONFIG_GRKERNSEC_TIME
71069 + {
71070 + .procname = "timechange_logging",
71071 + .data = &grsec_enable_time,
71072 + .maxlen = sizeof(int),
71073 + .mode = 0600,
71074 + .proc_handler = &proc_dointvec,
71075 + },
71076 +#endif
71077 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71078 + {
71079 + .procname = "chroot_deny_shmat",
71080 + .data = &grsec_enable_chroot_shmat,
71081 + .maxlen = sizeof(int),
71082 + .mode = 0600,
71083 + .proc_handler = &proc_dointvec,
71084 + },
71085 +#endif
71086 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71087 + {
71088 + .procname = "chroot_deny_unix",
71089 + .data = &grsec_enable_chroot_unix,
71090 + .maxlen = sizeof(int),
71091 + .mode = 0600,
71092 + .proc_handler = &proc_dointvec,
71093 + },
71094 +#endif
71095 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71096 + {
71097 + .procname = "chroot_deny_mount",
71098 + .data = &grsec_enable_chroot_mount,
71099 + .maxlen = sizeof(int),
71100 + .mode = 0600,
71101 + .proc_handler = &proc_dointvec,
71102 + },
71103 +#endif
71104 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71105 + {
71106 + .procname = "chroot_deny_fchdir",
71107 + .data = &grsec_enable_chroot_fchdir,
71108 + .maxlen = sizeof(int),
71109 + .mode = 0600,
71110 + .proc_handler = &proc_dointvec,
71111 + },
71112 +#endif
71113 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71114 + {
71115 + .procname = "chroot_deny_chroot",
71116 + .data = &grsec_enable_chroot_double,
71117 + .maxlen = sizeof(int),
71118 + .mode = 0600,
71119 + .proc_handler = &proc_dointvec,
71120 + },
71121 +#endif
71122 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71123 + {
71124 + .procname = "chroot_deny_pivot",
71125 + .data = &grsec_enable_chroot_pivot,
71126 + .maxlen = sizeof(int),
71127 + .mode = 0600,
71128 + .proc_handler = &proc_dointvec,
71129 + },
71130 +#endif
71131 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71132 + {
71133 + .procname = "chroot_enforce_chdir",
71134 + .data = &grsec_enable_chroot_chdir,
71135 + .maxlen = sizeof(int),
71136 + .mode = 0600,
71137 + .proc_handler = &proc_dointvec,
71138 + },
71139 +#endif
71140 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71141 + {
71142 + .procname = "chroot_deny_chmod",
71143 + .data = &grsec_enable_chroot_chmod,
71144 + .maxlen = sizeof(int),
71145 + .mode = 0600,
71146 + .proc_handler = &proc_dointvec,
71147 + },
71148 +#endif
71149 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71150 + {
71151 + .procname = "chroot_deny_mknod",
71152 + .data = &grsec_enable_chroot_mknod,
71153 + .maxlen = sizeof(int),
71154 + .mode = 0600,
71155 + .proc_handler = &proc_dointvec,
71156 + },
71157 +#endif
71158 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71159 + {
71160 + .procname = "chroot_restrict_nice",
71161 + .data = &grsec_enable_chroot_nice,
71162 + .maxlen = sizeof(int),
71163 + .mode = 0600,
71164 + .proc_handler = &proc_dointvec,
71165 + },
71166 +#endif
71167 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71168 + {
71169 + .procname = "chroot_execlog",
71170 + .data = &grsec_enable_chroot_execlog,
71171 + .maxlen = sizeof(int),
71172 + .mode = 0600,
71173 + .proc_handler = &proc_dointvec,
71174 + },
71175 +#endif
71176 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71177 + {
71178 + .procname = "chroot_caps",
71179 + .data = &grsec_enable_chroot_caps,
71180 + .maxlen = sizeof(int),
71181 + .mode = 0600,
71182 + .proc_handler = &proc_dointvec,
71183 + },
71184 +#endif
71185 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71186 + {
71187 + .procname = "chroot_deny_sysctl",
71188 + .data = &grsec_enable_chroot_sysctl,
71189 + .maxlen = sizeof(int),
71190 + .mode = 0600,
71191 + .proc_handler = &proc_dointvec,
71192 + },
71193 +#endif
71194 +#ifdef CONFIG_GRKERNSEC_TPE
71195 + {
71196 + .procname = "tpe",
71197 + .data = &grsec_enable_tpe,
71198 + .maxlen = sizeof(int),
71199 + .mode = 0600,
71200 + .proc_handler = &proc_dointvec,
71201 + },
71202 + {
71203 + .procname = "tpe_gid",
71204 + .data = &grsec_tpe_gid,
71205 + .maxlen = sizeof(int),
71206 + .mode = 0600,
71207 + .proc_handler = &proc_dointvec,
71208 + },
71209 +#endif
71210 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71211 + {
71212 + .procname = "tpe_invert",
71213 + .data = &grsec_enable_tpe_invert,
71214 + .maxlen = sizeof(int),
71215 + .mode = 0600,
71216 + .proc_handler = &proc_dointvec,
71217 + },
71218 +#endif
71219 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71220 + {
71221 + .procname = "tpe_restrict_all",
71222 + .data = &grsec_enable_tpe_all,
71223 + .maxlen = sizeof(int),
71224 + .mode = 0600,
71225 + .proc_handler = &proc_dointvec,
71226 + },
71227 +#endif
71228 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71229 + {
71230 + .procname = "socket_all",
71231 + .data = &grsec_enable_socket_all,
71232 + .maxlen = sizeof(int),
71233 + .mode = 0600,
71234 + .proc_handler = &proc_dointvec,
71235 + },
71236 + {
71237 + .procname = "socket_all_gid",
71238 + .data = &grsec_socket_all_gid,
71239 + .maxlen = sizeof(int),
71240 + .mode = 0600,
71241 + .proc_handler = &proc_dointvec,
71242 + },
71243 +#endif
71244 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71245 + {
71246 + .procname = "socket_client",
71247 + .data = &grsec_enable_socket_client,
71248 + .maxlen = sizeof(int),
71249 + .mode = 0600,
71250 + .proc_handler = &proc_dointvec,
71251 + },
71252 + {
71253 + .procname = "socket_client_gid",
71254 + .data = &grsec_socket_client_gid,
71255 + .maxlen = sizeof(int),
71256 + .mode = 0600,
71257 + .proc_handler = &proc_dointvec,
71258 + },
71259 +#endif
71260 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71261 + {
71262 + .procname = "socket_server",
71263 + .data = &grsec_enable_socket_server,
71264 + .maxlen = sizeof(int),
71265 + .mode = 0600,
71266 + .proc_handler = &proc_dointvec,
71267 + },
71268 + {
71269 + .procname = "socket_server_gid",
71270 + .data = &grsec_socket_server_gid,
71271 + .maxlen = sizeof(int),
71272 + .mode = 0600,
71273 + .proc_handler = &proc_dointvec,
71274 + },
71275 +#endif
71276 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71277 + {
71278 + .procname = "audit_group",
71279 + .data = &grsec_enable_group,
71280 + .maxlen = sizeof(int),
71281 + .mode = 0600,
71282 + .proc_handler = &proc_dointvec,
71283 + },
71284 + {
71285 + .procname = "audit_gid",
71286 + .data = &grsec_audit_gid,
71287 + .maxlen = sizeof(int),
71288 + .mode = 0600,
71289 + .proc_handler = &proc_dointvec,
71290 + },
71291 +#endif
71292 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71293 + {
71294 + .procname = "audit_chdir",
71295 + .data = &grsec_enable_chdir,
71296 + .maxlen = sizeof(int),
71297 + .mode = 0600,
71298 + .proc_handler = &proc_dointvec,
71299 + },
71300 +#endif
71301 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71302 + {
71303 + .procname = "audit_mount",
71304 + .data = &grsec_enable_mount,
71305 + .maxlen = sizeof(int),
71306 + .mode = 0600,
71307 + .proc_handler = &proc_dointvec,
71308 + },
71309 +#endif
71310 +#ifdef CONFIG_GRKERNSEC_DMESG
71311 + {
71312 + .procname = "dmesg",
71313 + .data = &grsec_enable_dmesg,
71314 + .maxlen = sizeof(int),
71315 + .mode = 0600,
71316 + .proc_handler = &proc_dointvec,
71317 + },
71318 +#endif
71319 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71320 + {
71321 + .procname = "chroot_findtask",
71322 + .data = &grsec_enable_chroot_findtask,
71323 + .maxlen = sizeof(int),
71324 + .mode = 0600,
71325 + .proc_handler = &proc_dointvec,
71326 + },
71327 +#endif
71328 +#ifdef CONFIG_GRKERNSEC_RESLOG
71329 + {
71330 + .procname = "resource_logging",
71331 + .data = &grsec_resource_logging,
71332 + .maxlen = sizeof(int),
71333 + .mode = 0600,
71334 + .proc_handler = &proc_dointvec,
71335 + },
71336 +#endif
71337 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71338 + {
71339 + .procname = "audit_ptrace",
71340 + .data = &grsec_enable_audit_ptrace,
71341 + .maxlen = sizeof(int),
71342 + .mode = 0600,
71343 + .proc_handler = &proc_dointvec,
71344 + },
71345 +#endif
71346 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71347 + {
71348 + .procname = "harden_ptrace",
71349 + .data = &grsec_enable_harden_ptrace,
71350 + .maxlen = sizeof(int),
71351 + .mode = 0600,
71352 + .proc_handler = &proc_dointvec,
71353 + },
71354 +#endif
71355 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71356 + {
71357 + .procname = "harden_ipc",
71358 + .data = &grsec_enable_harden_ipc,
71359 + .maxlen = sizeof(int),
71360 + .mode = 0600,
71361 + .proc_handler = &proc_dointvec,
71362 + },
71363 +#endif
71364 + {
71365 + .procname = "grsec_lock",
71366 + .data = &grsec_lock,
71367 + .maxlen = sizeof(int),
71368 + .mode = 0600,
71369 + .proc_handler = &proc_dointvec,
71370 + },
71371 +#endif
71372 +#ifdef CONFIG_GRKERNSEC_ROFS
71373 + {
71374 + .procname = "romount_protect",
71375 + .data = &grsec_enable_rofs,
71376 + .maxlen = sizeof(int),
71377 + .mode = 0600,
71378 + .proc_handler = &proc_dointvec_minmax,
71379 + .extra1 = &one,
71380 + .extra2 = &one,
71381 + },
71382 +#endif
71383 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
71384 + {
71385 + .procname = "deny_new_usb",
71386 + .data = &grsec_deny_new_usb,
71387 + .maxlen = sizeof(int),
71388 + .mode = 0600,
71389 + .proc_handler = &proc_dointvec,
71390 + },
71391 +#endif
71392 + { }
71393 +};
71394 +#endif
71395 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
71396 new file mode 100644
71397 index 0000000..0dc13c3
71398 --- /dev/null
71399 +++ b/grsecurity/grsec_time.c
71400 @@ -0,0 +1,16 @@
71401 +#include <linux/kernel.h>
71402 +#include <linux/sched.h>
71403 +#include <linux/grinternal.h>
71404 +#include <linux/module.h>
71405 +
71406 +void
71407 +gr_log_timechange(void)
71408 +{
71409 +#ifdef CONFIG_GRKERNSEC_TIME
71410 + if (grsec_enable_time)
71411 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
71412 +#endif
71413 + return;
71414 +}
71415 +
71416 +EXPORT_SYMBOL(gr_log_timechange);
71417 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
71418 new file mode 100644
71419 index 0000000..ee57dcf
71420 --- /dev/null
71421 +++ b/grsecurity/grsec_tpe.c
71422 @@ -0,0 +1,73 @@
71423 +#include <linux/kernel.h>
71424 +#include <linux/sched.h>
71425 +#include <linux/file.h>
71426 +#include <linux/fs.h>
71427 +#include <linux/grinternal.h>
71428 +
71429 +extern int gr_acl_tpe_check(void);
71430 +
71431 +int
71432 +gr_tpe_allow(const struct file *file)
71433 +{
71434 +#ifdef CONFIG_GRKERNSEC
71435 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
71436 + const struct cred *cred = current_cred();
71437 + char *msg = NULL;
71438 + char *msg2 = NULL;
71439 +
71440 + // never restrict root
71441 + if (gr_is_global_root(cred->uid))
71442 + return 1;
71443 +
71444 + if (grsec_enable_tpe) {
71445 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71446 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
71447 + msg = "not being in trusted group";
71448 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
71449 + msg = "being in untrusted group";
71450 +#else
71451 + if (in_group_p(grsec_tpe_gid))
71452 + msg = "being in untrusted group";
71453 +#endif
71454 + }
71455 + if (!msg && gr_acl_tpe_check())
71456 + msg = "being in untrusted role";
71457 +
71458 + // not in any affected group/role
71459 + if (!msg)
71460 + goto next_check;
71461 +
71462 + if (gr_is_global_nonroot(inode->i_uid))
71463 + msg2 = "file in non-root-owned directory";
71464 + else if (inode->i_mode & S_IWOTH)
71465 + msg2 = "file in world-writable directory";
71466 + else if (inode->i_mode & S_IWGRP)
71467 + msg2 = "file in group-writable directory";
71468 +
71469 + if (msg && msg2) {
71470 + char fullmsg[70] = {0};
71471 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
71472 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
71473 + return 0;
71474 + }
71475 + msg = NULL;
71476 +next_check:
71477 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71478 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
71479 + return 1;
71480 +
71481 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
71482 + msg = "directory not owned by user";
71483 + else if (inode->i_mode & S_IWOTH)
71484 + msg = "file in world-writable directory";
71485 + else if (inode->i_mode & S_IWGRP)
71486 + msg = "file in group-writable directory";
71487 +
71488 + if (msg) {
71489 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
71490 + return 0;
71491 + }
71492 +#endif
71493 +#endif
71494 + return 1;
71495 +}
71496 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
71497 new file mode 100644
71498 index 0000000..ae02d8e
71499 --- /dev/null
71500 +++ b/grsecurity/grsec_usb.c
71501 @@ -0,0 +1,15 @@
71502 +#include <linux/kernel.h>
71503 +#include <linux/grinternal.h>
71504 +#include <linux/module.h>
71505 +
71506 +int gr_handle_new_usb(void)
71507 +{
71508 +#ifdef CONFIG_GRKERNSEC_DENYUSB
71509 + if (grsec_deny_new_usb) {
71510 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
71511 + return 1;
71512 + }
71513 +#endif
71514 + return 0;
71515 +}
71516 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
71517 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
71518 new file mode 100644
71519 index 0000000..9f7b1ac
71520 --- /dev/null
71521 +++ b/grsecurity/grsum.c
71522 @@ -0,0 +1,61 @@
71523 +#include <linux/err.h>
71524 +#include <linux/kernel.h>
71525 +#include <linux/sched.h>
71526 +#include <linux/mm.h>
71527 +#include <linux/scatterlist.h>
71528 +#include <linux/crypto.h>
71529 +#include <linux/gracl.h>
71530 +
71531 +
71532 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
71533 +#error "crypto and sha256 must be built into the kernel"
71534 +#endif
71535 +
71536 +int
71537 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
71538 +{
71539 + char *p;
71540 + struct crypto_hash *tfm;
71541 + struct hash_desc desc;
71542 + struct scatterlist sg;
71543 + unsigned char temp_sum[GR_SHA_LEN];
71544 + volatile int retval = 0;
71545 + volatile int dummy = 0;
71546 + unsigned int i;
71547 +
71548 + sg_init_table(&sg, 1);
71549 +
71550 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
71551 + if (IS_ERR(tfm)) {
71552 + /* should never happen, since sha256 should be built in */
71553 + return 1;
71554 + }
71555 +
71556 + desc.tfm = tfm;
71557 + desc.flags = 0;
71558 +
71559 + crypto_hash_init(&desc);
71560 +
71561 + p = salt;
71562 + sg_set_buf(&sg, p, GR_SALT_LEN);
71563 + crypto_hash_update(&desc, &sg, sg.length);
71564 +
71565 + p = entry->pw;
71566 + sg_set_buf(&sg, p, strlen(p));
71567 +
71568 + crypto_hash_update(&desc, &sg, sg.length);
71569 +
71570 + crypto_hash_final(&desc, temp_sum);
71571 +
71572 + memset(entry->pw, 0, GR_PW_LEN);
71573 +
71574 + for (i = 0; i < GR_SHA_LEN; i++)
71575 + if (sum[i] != temp_sum[i])
71576 + retval = 1;
71577 + else
71578 + dummy = 1; // waste a cycle
71579 +
71580 + crypto_free_hash(tfm);
71581 +
71582 + return retval;
71583 +}
71584 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
71585 index 77ff547..181834f 100644
71586 --- a/include/asm-generic/4level-fixup.h
71587 +++ b/include/asm-generic/4level-fixup.h
71588 @@ -13,8 +13,10 @@
71589 #define pmd_alloc(mm, pud, address) \
71590 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
71591 NULL: pmd_offset(pud, address))
71592 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
71593
71594 #define pud_alloc(mm, pgd, address) (pgd)
71595 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
71596 #define pud_offset(pgd, start) (pgd)
71597 #define pud_none(pud) 0
71598 #define pud_bad(pud) 0
71599 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
71600 index b7babf0..04ad282 100644
71601 --- a/include/asm-generic/atomic-long.h
71602 +++ b/include/asm-generic/atomic-long.h
71603 @@ -22,6 +22,12 @@
71604
71605 typedef atomic64_t atomic_long_t;
71606
71607 +#ifdef CONFIG_PAX_REFCOUNT
71608 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
71609 +#else
71610 +typedef atomic64_t atomic_long_unchecked_t;
71611 +#endif
71612 +
71613 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
71614
71615 static inline long atomic_long_read(atomic_long_t *l)
71616 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71617 return (long)atomic64_read(v);
71618 }
71619
71620 +#ifdef CONFIG_PAX_REFCOUNT
71621 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71622 +{
71623 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71624 +
71625 + return (long)atomic64_read_unchecked(v);
71626 +}
71627 +#endif
71628 +
71629 static inline void atomic_long_set(atomic_long_t *l, long i)
71630 {
71631 atomic64_t *v = (atomic64_t *)l;
71632 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71633 atomic64_set(v, i);
71634 }
71635
71636 +#ifdef CONFIG_PAX_REFCOUNT
71637 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71638 +{
71639 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71640 +
71641 + atomic64_set_unchecked(v, i);
71642 +}
71643 +#endif
71644 +
71645 static inline void atomic_long_inc(atomic_long_t *l)
71646 {
71647 atomic64_t *v = (atomic64_t *)l;
71648 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71649 atomic64_inc(v);
71650 }
71651
71652 +#ifdef CONFIG_PAX_REFCOUNT
71653 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71654 +{
71655 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71656 +
71657 + atomic64_inc_unchecked(v);
71658 +}
71659 +#endif
71660 +
71661 static inline void atomic_long_dec(atomic_long_t *l)
71662 {
71663 atomic64_t *v = (atomic64_t *)l;
71664 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71665 atomic64_dec(v);
71666 }
71667
71668 +#ifdef CONFIG_PAX_REFCOUNT
71669 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71670 +{
71671 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71672 +
71673 + atomic64_dec_unchecked(v);
71674 +}
71675 +#endif
71676 +
71677 static inline void atomic_long_add(long i, atomic_long_t *l)
71678 {
71679 atomic64_t *v = (atomic64_t *)l;
71680 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71681 atomic64_add(i, v);
71682 }
71683
71684 +#ifdef CONFIG_PAX_REFCOUNT
71685 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71686 +{
71687 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71688 +
71689 + atomic64_add_unchecked(i, v);
71690 +}
71691 +#endif
71692 +
71693 static inline void atomic_long_sub(long i, atomic_long_t *l)
71694 {
71695 atomic64_t *v = (atomic64_t *)l;
71696 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71697 atomic64_sub(i, v);
71698 }
71699
71700 +#ifdef CONFIG_PAX_REFCOUNT
71701 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71702 +{
71703 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71704 +
71705 + atomic64_sub_unchecked(i, v);
71706 +}
71707 +#endif
71708 +
71709 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71710 {
71711 atomic64_t *v = (atomic64_t *)l;
71712 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71713 return (long)atomic64_add_return(i, v);
71714 }
71715
71716 +#ifdef CONFIG_PAX_REFCOUNT
71717 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71718 +{
71719 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71720 +
71721 + return (long)atomic64_add_return_unchecked(i, v);
71722 +}
71723 +#endif
71724 +
71725 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71726 {
71727 atomic64_t *v = (atomic64_t *)l;
71728 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71729 return (long)atomic64_inc_return(v);
71730 }
71731
71732 +#ifdef CONFIG_PAX_REFCOUNT
71733 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71734 +{
71735 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71736 +
71737 + return (long)atomic64_inc_return_unchecked(v);
71738 +}
71739 +#endif
71740 +
71741 static inline long atomic_long_dec_return(atomic_long_t *l)
71742 {
71743 atomic64_t *v = (atomic64_t *)l;
71744 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71745
71746 typedef atomic_t atomic_long_t;
71747
71748 +#ifdef CONFIG_PAX_REFCOUNT
71749 +typedef atomic_unchecked_t atomic_long_unchecked_t;
71750 +#else
71751 +typedef atomic_t atomic_long_unchecked_t;
71752 +#endif
71753 +
71754 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
71755 static inline long atomic_long_read(atomic_long_t *l)
71756 {
71757 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71758 return (long)atomic_read(v);
71759 }
71760
71761 +#ifdef CONFIG_PAX_REFCOUNT
71762 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71763 +{
71764 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71765 +
71766 + return (long)atomic_read_unchecked(v);
71767 +}
71768 +#endif
71769 +
71770 static inline void atomic_long_set(atomic_long_t *l, long i)
71771 {
71772 atomic_t *v = (atomic_t *)l;
71773 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71774 atomic_set(v, i);
71775 }
71776
71777 +#ifdef CONFIG_PAX_REFCOUNT
71778 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71779 +{
71780 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71781 +
71782 + atomic_set_unchecked(v, i);
71783 +}
71784 +#endif
71785 +
71786 static inline void atomic_long_inc(atomic_long_t *l)
71787 {
71788 atomic_t *v = (atomic_t *)l;
71789 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71790 atomic_inc(v);
71791 }
71792
71793 +#ifdef CONFIG_PAX_REFCOUNT
71794 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71795 +{
71796 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71797 +
71798 + atomic_inc_unchecked(v);
71799 +}
71800 +#endif
71801 +
71802 static inline void atomic_long_dec(atomic_long_t *l)
71803 {
71804 atomic_t *v = (atomic_t *)l;
71805 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71806 atomic_dec(v);
71807 }
71808
71809 +#ifdef CONFIG_PAX_REFCOUNT
71810 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71811 +{
71812 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71813 +
71814 + atomic_dec_unchecked(v);
71815 +}
71816 +#endif
71817 +
71818 static inline void atomic_long_add(long i, atomic_long_t *l)
71819 {
71820 atomic_t *v = (atomic_t *)l;
71821 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71822 atomic_add(i, v);
71823 }
71824
71825 +#ifdef CONFIG_PAX_REFCOUNT
71826 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71827 +{
71828 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71829 +
71830 + atomic_add_unchecked(i, v);
71831 +}
71832 +#endif
71833 +
71834 static inline void atomic_long_sub(long i, atomic_long_t *l)
71835 {
71836 atomic_t *v = (atomic_t *)l;
71837 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71838 atomic_sub(i, v);
71839 }
71840
71841 +#ifdef CONFIG_PAX_REFCOUNT
71842 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71843 +{
71844 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71845 +
71846 + atomic_sub_unchecked(i, v);
71847 +}
71848 +#endif
71849 +
71850 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71851 {
71852 atomic_t *v = (atomic_t *)l;
71853 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71854 return (long)atomic_add_return(i, v);
71855 }
71856
71857 +#ifdef CONFIG_PAX_REFCOUNT
71858 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71859 +{
71860 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71861 +
71862 + return (long)atomic_add_return_unchecked(i, v);
71863 +}
71864 +
71865 +#endif
71866 +
71867 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71868 {
71869 atomic_t *v = (atomic_t *)l;
71870 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71871 return (long)atomic_inc_return(v);
71872 }
71873
71874 +#ifdef CONFIG_PAX_REFCOUNT
71875 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71876 +{
71877 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71878 +
71879 + return (long)atomic_inc_return_unchecked(v);
71880 +}
71881 +#endif
71882 +
71883 static inline long atomic_long_dec_return(atomic_long_t *l)
71884 {
71885 atomic_t *v = (atomic_t *)l;
71886 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71887
71888 #endif /* BITS_PER_LONG == 64 */
71889
71890 +#ifdef CONFIG_PAX_REFCOUNT
71891 +static inline void pax_refcount_needs_these_functions(void)
71892 +{
71893 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
71894 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
71895 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
71896 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
71897 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
71898 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
71899 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
71900 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
71901 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
71902 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
71903 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
71904 +#ifdef CONFIG_X86
71905 + atomic_clear_mask_unchecked(0, NULL);
71906 + atomic_set_mask_unchecked(0, NULL);
71907 +#endif
71908 +
71909 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
71910 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
71911 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
71912 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
71913 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
71914 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
71915 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
71916 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
71917 +}
71918 +#else
71919 +#define atomic_read_unchecked(v) atomic_read(v)
71920 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
71921 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
71922 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
71923 +#define atomic_inc_unchecked(v) atomic_inc(v)
71924 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
71925 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
71926 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
71927 +#define atomic_dec_unchecked(v) atomic_dec(v)
71928 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
71929 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
71930 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
71931 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
71932 +
71933 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
71934 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
71935 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
71936 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
71937 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
71938 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
71939 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
71940 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
71941 +#endif
71942 +
71943 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
71944 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
71945 index 33bd2de..f31bff97 100644
71946 --- a/include/asm-generic/atomic.h
71947 +++ b/include/asm-generic/atomic.h
71948 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
71949 * Atomically clears the bits set in @mask from @v
71950 */
71951 #ifndef atomic_clear_mask
71952 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
71953 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
71954 {
71955 unsigned long flags;
71956
71957 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
71958 index b18ce4f..2ee2843 100644
71959 --- a/include/asm-generic/atomic64.h
71960 +++ b/include/asm-generic/atomic64.h
71961 @@ -16,6 +16,8 @@ typedef struct {
71962 long long counter;
71963 } atomic64_t;
71964
71965 +typedef atomic64_t atomic64_unchecked_t;
71966 +
71967 #define ATOMIC64_INIT(i) { (i) }
71968
71969 extern long long atomic64_read(const atomic64_t *v);
71970 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
71971 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
71972 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
71973
71974 +#define atomic64_read_unchecked(v) atomic64_read(v)
71975 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
71976 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
71977 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
71978 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
71979 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
71980 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
71981 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
71982 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
71983 +
71984 #endif /* _ASM_GENERIC_ATOMIC64_H */
71985 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
71986 index 1bfcfe5..e04c5c9 100644
71987 --- a/include/asm-generic/cache.h
71988 +++ b/include/asm-generic/cache.h
71989 @@ -6,7 +6,7 @@
71990 * cache lines need to provide their own cache.h.
71991 */
71992
71993 -#define L1_CACHE_SHIFT 5
71994 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
71995 +#define L1_CACHE_SHIFT 5UL
71996 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
71997
71998 #endif /* __ASM_GENERIC_CACHE_H */
71999 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
72000 index 0d68a1e..b74a761 100644
72001 --- a/include/asm-generic/emergency-restart.h
72002 +++ b/include/asm-generic/emergency-restart.h
72003 @@ -1,7 +1,7 @@
72004 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
72005 #define _ASM_GENERIC_EMERGENCY_RESTART_H
72006
72007 -static inline void machine_emergency_restart(void)
72008 +static inline __noreturn void machine_emergency_restart(void)
72009 {
72010 machine_restart(NULL);
72011 }
72012 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
72013 index 90f99c7..00ce236 100644
72014 --- a/include/asm-generic/kmap_types.h
72015 +++ b/include/asm-generic/kmap_types.h
72016 @@ -2,9 +2,9 @@
72017 #define _ASM_GENERIC_KMAP_TYPES_H
72018
72019 #ifdef __WITH_KM_FENCE
72020 -# define KM_TYPE_NR 41
72021 +# define KM_TYPE_NR 42
72022 #else
72023 -# define KM_TYPE_NR 20
72024 +# define KM_TYPE_NR 21
72025 #endif
72026
72027 #endif
72028 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
72029 index 9ceb03b..62b0b8f 100644
72030 --- a/include/asm-generic/local.h
72031 +++ b/include/asm-generic/local.h
72032 @@ -23,24 +23,37 @@ typedef struct
72033 atomic_long_t a;
72034 } local_t;
72035
72036 +typedef struct {
72037 + atomic_long_unchecked_t a;
72038 +} local_unchecked_t;
72039 +
72040 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
72041
72042 #define local_read(l) atomic_long_read(&(l)->a)
72043 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
72044 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
72045 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
72046 #define local_inc(l) atomic_long_inc(&(l)->a)
72047 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
72048 #define local_dec(l) atomic_long_dec(&(l)->a)
72049 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
72050 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
72051 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
72052 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
72053 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
72054
72055 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
72056 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
72057 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
72058 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
72059 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
72060 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
72061 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
72062 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
72063 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
72064
72065 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72066 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72067 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
72068 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
72069 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
72070 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
72071 index 725612b..9cc513a 100644
72072 --- a/include/asm-generic/pgtable-nopmd.h
72073 +++ b/include/asm-generic/pgtable-nopmd.h
72074 @@ -1,14 +1,19 @@
72075 #ifndef _PGTABLE_NOPMD_H
72076 #define _PGTABLE_NOPMD_H
72077
72078 -#ifndef __ASSEMBLY__
72079 -
72080 #include <asm-generic/pgtable-nopud.h>
72081
72082 -struct mm_struct;
72083 -
72084 #define __PAGETABLE_PMD_FOLDED
72085
72086 +#define PMD_SHIFT PUD_SHIFT
72087 +#define PTRS_PER_PMD 1
72088 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
72089 +#define PMD_MASK (~(PMD_SIZE-1))
72090 +
72091 +#ifndef __ASSEMBLY__
72092 +
72093 +struct mm_struct;
72094 +
72095 /*
72096 * Having the pmd type consist of a pud gets the size right, and allows
72097 * us to conceptually access the pud entry that this pmd is folded into
72098 @@ -16,11 +21,6 @@ struct mm_struct;
72099 */
72100 typedef struct { pud_t pud; } pmd_t;
72101
72102 -#define PMD_SHIFT PUD_SHIFT
72103 -#define PTRS_PER_PMD 1
72104 -#define PMD_SIZE (1UL << PMD_SHIFT)
72105 -#define PMD_MASK (~(PMD_SIZE-1))
72106 -
72107 /*
72108 * The "pud_xxx()" functions here are trivial for a folded two-level
72109 * setup: the pmd is never bad, and a pmd always exists (as it's folded
72110 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
72111 index 810431d..0ec4804f 100644
72112 --- a/include/asm-generic/pgtable-nopud.h
72113 +++ b/include/asm-generic/pgtable-nopud.h
72114 @@ -1,10 +1,15 @@
72115 #ifndef _PGTABLE_NOPUD_H
72116 #define _PGTABLE_NOPUD_H
72117
72118 -#ifndef __ASSEMBLY__
72119 -
72120 #define __PAGETABLE_PUD_FOLDED
72121
72122 +#define PUD_SHIFT PGDIR_SHIFT
72123 +#define PTRS_PER_PUD 1
72124 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
72125 +#define PUD_MASK (~(PUD_SIZE-1))
72126 +
72127 +#ifndef __ASSEMBLY__
72128 +
72129 /*
72130 * Having the pud type consist of a pgd gets the size right, and allows
72131 * us to conceptually access the pgd entry that this pud is folded into
72132 @@ -12,11 +17,6 @@
72133 */
72134 typedef struct { pgd_t pgd; } pud_t;
72135
72136 -#define PUD_SHIFT PGDIR_SHIFT
72137 -#define PTRS_PER_PUD 1
72138 -#define PUD_SIZE (1UL << PUD_SHIFT)
72139 -#define PUD_MASK (~(PUD_SIZE-1))
72140 -
72141 /*
72142 * The "pgd_xxx()" functions here are trivial for a folded two-level
72143 * setup: the pud is never bad, and a pud always exists (as it's folded
72144 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
72145 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
72146
72147 #define pgd_populate(mm, pgd, pud) do { } while (0)
72148 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
72149 /*
72150 * (puds are folded into pgds so this doesn't get actually called,
72151 * but the define is needed for a generic inline function.)
72152 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
72153 index 0807ddf..cd67747 100644
72154 --- a/include/asm-generic/pgtable.h
72155 +++ b/include/asm-generic/pgtable.h
72156 @@ -741,6 +741,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
72157 }
72158 #endif /* CONFIG_NUMA_BALANCING */
72159
72160 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
72161 +#ifdef CONFIG_PAX_KERNEXEC
72162 +#error KERNEXEC requires pax_open_kernel
72163 +#else
72164 +static inline unsigned long pax_open_kernel(void) { return 0; }
72165 +#endif
72166 +#endif
72167 +
72168 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
72169 +#ifdef CONFIG_PAX_KERNEXEC
72170 +#error KERNEXEC requires pax_close_kernel
72171 +#else
72172 +static inline unsigned long pax_close_kernel(void) { return 0; }
72173 +#endif
72174 +#endif
72175 +
72176 #endif /* CONFIG_MMU */
72177
72178 #endif /* !__ASSEMBLY__ */
72179 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
72180 index dc1269c..48a4f51 100644
72181 --- a/include/asm-generic/uaccess.h
72182 +++ b/include/asm-generic/uaccess.h
72183 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
72184 return __clear_user(to, n);
72185 }
72186
72187 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
72188 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72189 +#error UDEREF requires pax_open_userland
72190 +#else
72191 +static inline unsigned long pax_open_userland(void) { return 0; }
72192 +#endif
72193 +#endif
72194 +
72195 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
72196 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72197 +#error UDEREF requires pax_close_userland
72198 +#else
72199 +static inline unsigned long pax_close_userland(void) { return 0; }
72200 +#endif
72201 +#endif
72202 +
72203 #endif /* __ASM_GENERIC_UACCESS_H */
72204 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
72205 index 69732d2..cbe16d9 100644
72206 --- a/include/asm-generic/vmlinux.lds.h
72207 +++ b/include/asm-generic/vmlinux.lds.h
72208 @@ -227,6 +227,7 @@
72209 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
72210 VMLINUX_SYMBOL(__start_rodata) = .; \
72211 *(.rodata) *(.rodata.*) \
72212 + *(.data..read_only) \
72213 *(__vermagic) /* Kernel version magic */ \
72214 . = ALIGN(8); \
72215 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
72216 @@ -710,17 +711,18 @@
72217 * section in the linker script will go there too. @phdr should have
72218 * a leading colon.
72219 *
72220 - * Note that this macros defines __per_cpu_load as an absolute symbol.
72221 + * Note that this macros defines per_cpu_load as an absolute symbol.
72222 * If there is no need to put the percpu section at a predetermined
72223 * address, use PERCPU_SECTION.
72224 */
72225 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
72226 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
72227 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
72228 + per_cpu_load = .; \
72229 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
72230 - LOAD_OFFSET) { \
72231 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
72232 PERCPU_INPUT(cacheline) \
72233 } phdr \
72234 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
72235 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
72236
72237 /**
72238 * PERCPU_SECTION - define output section for percpu area, simple version
72239 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
72240 index 418d270..bfd2794 100644
72241 --- a/include/crypto/algapi.h
72242 +++ b/include/crypto/algapi.h
72243 @@ -34,7 +34,7 @@ struct crypto_type {
72244 unsigned int maskclear;
72245 unsigned int maskset;
72246 unsigned int tfmsize;
72247 -};
72248 +} __do_const;
72249
72250 struct crypto_instance {
72251 struct crypto_alg alg;
72252 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
72253 index 12083dc..39740ec 100644
72254 --- a/include/drm/drmP.h
72255 +++ b/include/drm/drmP.h
72256 @@ -69,6 +69,7 @@
72257 #include <linux/workqueue.h>
72258 #include <linux/poll.h>
72259 #include <asm/pgalloc.h>
72260 +#include <asm/local.h>
72261 #include <drm/drm.h>
72262 #include <drm/drm_sarea.h>
72263
72264 @@ -293,10 +294,12 @@ do { \
72265 * \param cmd command.
72266 * \param arg argument.
72267 */
72268 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
72269 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
72270 + struct drm_file *file_priv);
72271 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
72272 struct drm_file *file_priv);
72273
72274 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72275 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
72276 unsigned long arg);
72277
72278 #define DRM_IOCTL_NR(n) _IOC_NR(n)
72279 @@ -311,10 +314,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72280 struct drm_ioctl_desc {
72281 unsigned int cmd;
72282 int flags;
72283 - drm_ioctl_t *func;
72284 + drm_ioctl_t func;
72285 unsigned int cmd_drv;
72286 const char *name;
72287 -};
72288 +} __do_const;
72289
72290 /**
72291 * Creates a driver or general drm_ioctl_desc array entry for the given
72292 @@ -1015,7 +1018,7 @@ struct drm_info_list {
72293 int (*show)(struct seq_file*, void*); /** show callback */
72294 u32 driver_features; /**< Required driver features for this entry */
72295 void *data;
72296 -};
72297 +} __do_const;
72298
72299 /**
72300 * debugfs node structure. This structure represents a debugfs file.
72301 @@ -1088,7 +1091,7 @@ struct drm_device {
72302
72303 /** \name Usage Counters */
72304 /*@{ */
72305 - int open_count; /**< Outstanding files open */
72306 + local_t open_count; /**< Outstanding files open */
72307 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
72308 atomic_t vma_count; /**< Outstanding vma areas open */
72309 int buf_use; /**< Buffers in use -- cannot alloc */
72310 @@ -1099,7 +1102,7 @@ struct drm_device {
72311 /*@{ */
72312 unsigned long counters;
72313 enum drm_stat_type types[15];
72314 - atomic_t counts[15];
72315 + atomic_unchecked_t counts[15];
72316 /*@} */
72317
72318 struct list_head filelist;
72319 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
72320 index f43d556..94d9343 100644
72321 --- a/include/drm/drm_crtc_helper.h
72322 +++ b/include/drm/drm_crtc_helper.h
72323 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
72324 struct drm_connector *connector);
72325 /* disable encoder when not in use - more explicit than dpms off */
72326 void (*disable)(struct drm_encoder *encoder);
72327 -};
72328 +} __no_const;
72329
72330 /**
72331 * drm_connector_helper_funcs - helper operations for connectors
72332 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
72333 index 72dcbe8..8db58d7 100644
72334 --- a/include/drm/ttm/ttm_memory.h
72335 +++ b/include/drm/ttm/ttm_memory.h
72336 @@ -48,7 +48,7 @@
72337
72338 struct ttm_mem_shrink {
72339 int (*do_shrink) (struct ttm_mem_shrink *);
72340 -};
72341 +} __no_const;
72342
72343 /**
72344 * struct ttm_mem_global - Global memory accounting structure.
72345 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
72346 index 4b840e8..155d235 100644
72347 --- a/include/keys/asymmetric-subtype.h
72348 +++ b/include/keys/asymmetric-subtype.h
72349 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
72350 /* Verify the signature on a key of this subtype (optional) */
72351 int (*verify_signature)(const struct key *key,
72352 const struct public_key_signature *sig);
72353 -};
72354 +} __do_const;
72355
72356 /**
72357 * asymmetric_key_subtype - Get the subtype from an asymmetric key
72358 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
72359 index c1da539..1dcec55 100644
72360 --- a/include/linux/atmdev.h
72361 +++ b/include/linux/atmdev.h
72362 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
72363 #endif
72364
72365 struct k_atm_aal_stats {
72366 -#define __HANDLE_ITEM(i) atomic_t i
72367 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72368 __AAL_STAT_ITEMS
72369 #undef __HANDLE_ITEM
72370 };
72371 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
72372 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
72373 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
72374 struct module *owner;
72375 -};
72376 +} __do_const ;
72377
72378 struct atmphy_ops {
72379 int (*start)(struct atm_dev *dev);
72380 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
72381 index 70cf138..0418ee2 100644
72382 --- a/include/linux/binfmts.h
72383 +++ b/include/linux/binfmts.h
72384 @@ -73,8 +73,10 @@ struct linux_binfmt {
72385 int (*load_binary)(struct linux_binprm *);
72386 int (*load_shlib)(struct file *);
72387 int (*core_dump)(struct coredump_params *cprm);
72388 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
72389 + void (*handle_mmap)(struct file *);
72390 unsigned long min_coredump; /* minimal dump size */
72391 -};
72392 +} __do_const;
72393
72394 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
72395
72396 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
72397 index 2fdb4a4..54aad7e 100644
72398 --- a/include/linux/blkdev.h
72399 +++ b/include/linux/blkdev.h
72400 @@ -1526,7 +1526,7 @@ struct block_device_operations {
72401 /* this callback is with swap_lock and sometimes page table lock held */
72402 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
72403 struct module *owner;
72404 -};
72405 +} __do_const;
72406
72407 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
72408 unsigned long);
72409 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
72410 index 7c2e030..b72475d 100644
72411 --- a/include/linux/blktrace_api.h
72412 +++ b/include/linux/blktrace_api.h
72413 @@ -23,7 +23,7 @@ struct blk_trace {
72414 struct dentry *dir;
72415 struct dentry *dropped_file;
72416 struct dentry *msg_file;
72417 - atomic_t dropped;
72418 + atomic_unchecked_t dropped;
72419 };
72420
72421 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
72422 diff --git a/include/linux/cache.h b/include/linux/cache.h
72423 index 4c57065..40346da 100644
72424 --- a/include/linux/cache.h
72425 +++ b/include/linux/cache.h
72426 @@ -16,6 +16,14 @@
72427 #define __read_mostly
72428 #endif
72429
72430 +#ifndef __read_only
72431 +#ifdef CONFIG_PAX_KERNEXEC
72432 +#error KERNEXEC requires __read_only
72433 +#else
72434 +#define __read_only __read_mostly
72435 +#endif
72436 +#endif
72437 +
72438 #ifndef ____cacheline_aligned
72439 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
72440 #endif
72441 diff --git a/include/linux/capability.h b/include/linux/capability.h
72442 index d9a4f7f4..19f77d6 100644
72443 --- a/include/linux/capability.h
72444 +++ b/include/linux/capability.h
72445 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
72446 extern bool nsown_capable(int cap);
72447 extern bool inode_capable(const struct inode *inode, int cap);
72448 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
72449 +extern bool capable_nolog(int cap);
72450 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
72451 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
72452
72453 /* audit system wants to get cap info from files as well */
72454 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
72455
72456 +extern int is_privileged_binary(const struct dentry *dentry);
72457 +
72458 #endif /* !_LINUX_CAPABILITY_H */
72459 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
72460 index 8609d57..86e4d79 100644
72461 --- a/include/linux/cdrom.h
72462 +++ b/include/linux/cdrom.h
72463 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
72464
72465 /* driver specifications */
72466 const int capability; /* capability flags */
72467 - int n_minors; /* number of active minor devices */
72468 /* handle uniform packets for scsi type devices (scsi,atapi) */
72469 int (*generic_packet) (struct cdrom_device_info *,
72470 struct packet_command *);
72471 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
72472 index 4ce9056..86caac6 100644
72473 --- a/include/linux/cleancache.h
72474 +++ b/include/linux/cleancache.h
72475 @@ -31,7 +31,7 @@ struct cleancache_ops {
72476 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
72477 void (*invalidate_inode)(int, struct cleancache_filekey);
72478 void (*invalidate_fs)(int);
72479 -};
72480 +} __no_const;
72481
72482 extern struct cleancache_ops *
72483 cleancache_register_ops(struct cleancache_ops *ops);
72484 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
72485 index 1ec14a7..d0654a2 100644
72486 --- a/include/linux/clk-provider.h
72487 +++ b/include/linux/clk-provider.h
72488 @@ -132,6 +132,7 @@ struct clk_ops {
72489 unsigned long);
72490 void (*init)(struct clk_hw *hw);
72491 };
72492 +typedef struct clk_ops __no_const clk_ops_no_const;
72493
72494 /**
72495 * struct clk_init_data - holds init data that's common to all clocks and is
72496 diff --git a/include/linux/compat.h b/include/linux/compat.h
72497 index ec1aee4..1077986 100644
72498 --- a/include/linux/compat.h
72499 +++ b/include/linux/compat.h
72500 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
72501 compat_size_t __user *len_ptr);
72502
72503 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
72504 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
72505 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
72506 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
72507 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
72508 compat_ssize_t msgsz, int msgflg);
72509 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
72510 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
72511 compat_ulong_t addr, compat_ulong_t data);
72512 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
72513 - compat_long_t addr, compat_long_t data);
72514 + compat_ulong_t addr, compat_ulong_t data);
72515
72516 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
72517 /*
72518 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
72519 index ded4299..da50e3b 100644
72520 --- a/include/linux/compiler-gcc4.h
72521 +++ b/include/linux/compiler-gcc4.h
72522 @@ -39,9 +39,29 @@
72523 # define __compiletime_warning(message) __attribute__((warning(message)))
72524 # define __compiletime_error(message) __attribute__((error(message)))
72525 #endif /* __CHECKER__ */
72526 +
72527 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
72528 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
72529 +#define __bos0(ptr) __bos((ptr), 0)
72530 +#define __bos1(ptr) __bos((ptr), 1)
72531 #endif /* GCC_VERSION >= 40300 */
72532
72533 #if GCC_VERSION >= 40500
72534 +
72535 +#ifdef CONSTIFY_PLUGIN
72536 +#define __no_const __attribute__((no_const))
72537 +#define __do_const __attribute__((do_const))
72538 +#endif
72539 +
72540 +#ifdef SIZE_OVERFLOW_PLUGIN
72541 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
72542 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
72543 +#endif
72544 +
72545 +#ifdef LATENT_ENTROPY_PLUGIN
72546 +#define __latent_entropy __attribute__((latent_entropy))
72547 +#endif
72548 +
72549 /*
72550 * Mark a position in code as unreachable. This can be used to
72551 * suppress control flow warnings after asm blocks that transfer
72552 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
72553 index 92669cd..1771a15 100644
72554 --- a/include/linux/compiler.h
72555 +++ b/include/linux/compiler.h
72556 @@ -5,11 +5,14 @@
72557
72558 #ifdef __CHECKER__
72559 # define __user __attribute__((noderef, address_space(1)))
72560 +# define __force_user __force __user
72561 # define __kernel __attribute__((address_space(0)))
72562 +# define __force_kernel __force __kernel
72563 # define __safe __attribute__((safe))
72564 # define __force __attribute__((force))
72565 # define __nocast __attribute__((nocast))
72566 # define __iomem __attribute__((noderef, address_space(2)))
72567 +# define __force_iomem __force __iomem
72568 # define __must_hold(x) __attribute__((context(x,1,1)))
72569 # define __acquires(x) __attribute__((context(x,0,1)))
72570 # define __releases(x) __attribute__((context(x,1,0)))
72571 @@ -17,20 +20,37 @@
72572 # define __release(x) __context__(x,-1)
72573 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
72574 # define __percpu __attribute__((noderef, address_space(3)))
72575 +# define __force_percpu __force __percpu
72576 #ifdef CONFIG_SPARSE_RCU_POINTER
72577 # define __rcu __attribute__((noderef, address_space(4)))
72578 +# define __force_rcu __force __rcu
72579 #else
72580 # define __rcu
72581 +# define __force_rcu
72582 #endif
72583 extern void __chk_user_ptr(const volatile void __user *);
72584 extern void __chk_io_ptr(const volatile void __iomem *);
72585 #else
72586 -# define __user
72587 -# define __kernel
72588 +# ifdef CHECKER_PLUGIN
72589 +//# define __user
72590 +//# define __force_user
72591 +//# define __kernel
72592 +//# define __force_kernel
72593 +# else
72594 +# ifdef STRUCTLEAK_PLUGIN
72595 +# define __user __attribute__((user))
72596 +# else
72597 +# define __user
72598 +# endif
72599 +# define __force_user
72600 +# define __kernel
72601 +# define __force_kernel
72602 +# endif
72603 # define __safe
72604 # define __force
72605 # define __nocast
72606 # define __iomem
72607 +# define __force_iomem
72608 # define __chk_user_ptr(x) (void)0
72609 # define __chk_io_ptr(x) (void)0
72610 # define __builtin_warning(x, y...) (1)
72611 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
72612 # define __release(x) (void)0
72613 # define __cond_lock(x,c) (c)
72614 # define __percpu
72615 +# define __force_percpu
72616 # define __rcu
72617 +# define __force_rcu
72618 #endif
72619
72620 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
72621 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72622 # define __attribute_const__ /* unimplemented */
72623 #endif
72624
72625 +#ifndef __no_const
72626 +# define __no_const
72627 +#endif
72628 +
72629 +#ifndef __do_const
72630 +# define __do_const
72631 +#endif
72632 +
72633 +#ifndef __size_overflow
72634 +# define __size_overflow(...)
72635 +#endif
72636 +
72637 +#ifndef __intentional_overflow
72638 +# define __intentional_overflow(...)
72639 +#endif
72640 +
72641 +#ifndef __latent_entropy
72642 +# define __latent_entropy
72643 +#endif
72644 +
72645 /*
72646 * Tell gcc if a function is cold. The compiler will assume any path
72647 * directly leading to the call is unlikely.
72648 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72649 #define __cold
72650 #endif
72651
72652 +#ifndef __alloc_size
72653 +#define __alloc_size(...)
72654 +#endif
72655 +
72656 +#ifndef __bos
72657 +#define __bos(ptr, arg)
72658 +#endif
72659 +
72660 +#ifndef __bos0
72661 +#define __bos0(ptr)
72662 +#endif
72663 +
72664 +#ifndef __bos1
72665 +#define __bos1(ptr)
72666 +#endif
72667 +
72668 /* Simple shorthand for a section definition */
72669 #ifndef __section
72670 # define __section(S) __attribute__ ((__section__(#S)))
72671 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72672 * use is to mediate communication between process-level code and irq/NMI
72673 * handlers, all running on the same CPU.
72674 */
72675 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
72676 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
72677 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
72678
72679 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
72680 #ifdef CONFIG_KPROBES
72681 diff --git a/include/linux/completion.h b/include/linux/completion.h
72682 index 3cd574d..adce5fa 100644
72683 --- a/include/linux/completion.h
72684 +++ b/include/linux/completion.h
72685 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
72686 extern void wait_for_completion(struct completion *);
72687 extern void wait_for_completion_io(struct completion *);
72688 extern int wait_for_completion_interruptible(struct completion *x);
72689 -extern int wait_for_completion_killable(struct completion *x);
72690 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
72691 extern unsigned long wait_for_completion_timeout(struct completion *x,
72692 unsigned long timeout);
72693 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
72694 unsigned long timeout);
72695 extern long wait_for_completion_interruptible_timeout(
72696 - struct completion *x, unsigned long timeout);
72697 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72698 extern long wait_for_completion_killable_timeout(
72699 - struct completion *x, unsigned long timeout);
72700 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72701 extern bool try_wait_for_completion(struct completion *x);
72702 extern bool completion_done(struct completion *x);
72703
72704 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
72705 index 34025df..d94bbbc 100644
72706 --- a/include/linux/configfs.h
72707 +++ b/include/linux/configfs.h
72708 @@ -125,7 +125,7 @@ struct configfs_attribute {
72709 const char *ca_name;
72710 struct module *ca_owner;
72711 umode_t ca_mode;
72712 -};
72713 +} __do_const;
72714
72715 /*
72716 * Users often need to create attribute structures for their configurable
72717 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
72718 index 90d5a15..950cb80 100644
72719 --- a/include/linux/cpufreq.h
72720 +++ b/include/linux/cpufreq.h
72721 @@ -266,7 +266,7 @@ struct cpufreq_driver {
72722 int (*suspend) (struct cpufreq_policy *policy);
72723 int (*resume) (struct cpufreq_policy *policy);
72724 struct freq_attr **attr;
72725 -};
72726 +} __do_const;
72727
72728 /* flags */
72729
72730 @@ -325,6 +325,7 @@ struct global_attr {
72731 ssize_t (*store)(struct kobject *a, struct attribute *b,
72732 const char *c, size_t count);
72733 };
72734 +typedef struct global_attr __no_const global_attr_no_const;
72735
72736 #define define_one_global_ro(_name) \
72737 static struct global_attr _name = \
72738 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
72739 index 0bc4b74..973b368 100644
72740 --- a/include/linux/cpuidle.h
72741 +++ b/include/linux/cpuidle.h
72742 @@ -52,7 +52,8 @@ struct cpuidle_state {
72743 int index);
72744
72745 int (*enter_dead) (struct cpuidle_device *dev, int index);
72746 -};
72747 +} __do_const;
72748 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
72749
72750 /* Idle State Flags */
72751 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
72752 @@ -191,7 +192,7 @@ struct cpuidle_governor {
72753 void (*reflect) (struct cpuidle_device *dev, int index);
72754
72755 struct module *owner;
72756 -};
72757 +} __do_const;
72758
72759 #ifdef CONFIG_CPU_IDLE
72760
72761 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
72762 index d08e4d2..95fad61 100644
72763 --- a/include/linux/cpumask.h
72764 +++ b/include/linux/cpumask.h
72765 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72766 }
72767
72768 /* Valid inputs for n are -1 and 0. */
72769 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72770 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72771 {
72772 return n+1;
72773 }
72774
72775 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72776 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72777 {
72778 return n+1;
72779 }
72780
72781 -static inline unsigned int cpumask_next_and(int n,
72782 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
72783 const struct cpumask *srcp,
72784 const struct cpumask *andp)
72785 {
72786 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72787 *
72788 * Returns >= nr_cpu_ids if no further cpus set.
72789 */
72790 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72791 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72792 {
72793 /* -1 is a legal arg here. */
72794 if (n != -1)
72795 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72796 *
72797 * Returns >= nr_cpu_ids if no further cpus unset.
72798 */
72799 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72800 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72801 {
72802 /* -1 is a legal arg here. */
72803 if (n != -1)
72804 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72805 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
72806 }
72807
72808 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
72809 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
72810 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
72811
72812 /**
72813 diff --git a/include/linux/cred.h b/include/linux/cred.h
72814 index 04421e8..6bce4ef 100644
72815 --- a/include/linux/cred.h
72816 +++ b/include/linux/cred.h
72817 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
72818 static inline void validate_process_creds(void)
72819 {
72820 }
72821 +static inline void validate_task_creds(struct task_struct *task)
72822 +{
72823 +}
72824 #endif
72825
72826 /**
72827 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
72828 index b92eadf..b4ecdc1 100644
72829 --- a/include/linux/crypto.h
72830 +++ b/include/linux/crypto.h
72831 @@ -373,7 +373,7 @@ struct cipher_tfm {
72832 const u8 *key, unsigned int keylen);
72833 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72834 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72835 -};
72836 +} __no_const;
72837
72838 struct hash_tfm {
72839 int (*init)(struct hash_desc *desc);
72840 @@ -394,13 +394,13 @@ struct compress_tfm {
72841 int (*cot_decompress)(struct crypto_tfm *tfm,
72842 const u8 *src, unsigned int slen,
72843 u8 *dst, unsigned int *dlen);
72844 -};
72845 +} __no_const;
72846
72847 struct rng_tfm {
72848 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
72849 unsigned int dlen);
72850 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
72851 -};
72852 +} __no_const;
72853
72854 #define crt_ablkcipher crt_u.ablkcipher
72855 #define crt_aead crt_u.aead
72856 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
72857 index 653589e..4ef254a 100644
72858 --- a/include/linux/ctype.h
72859 +++ b/include/linux/ctype.h
72860 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
72861 * Fast implementation of tolower() for internal usage. Do not use in your
72862 * code.
72863 */
72864 -static inline char _tolower(const char c)
72865 +static inline unsigned char _tolower(const unsigned char c)
72866 {
72867 return c | 0x20;
72868 }
72869 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
72870 index 7925bf0..d5143d2 100644
72871 --- a/include/linux/decompress/mm.h
72872 +++ b/include/linux/decompress/mm.h
72873 @@ -77,7 +77,7 @@ static void free(void *where)
72874 * warnings when not needed (indeed large_malloc / large_free are not
72875 * needed by inflate */
72876
72877 -#define malloc(a) kmalloc(a, GFP_KERNEL)
72878 +#define malloc(a) kmalloc((a), GFP_KERNEL)
72879 #define free(a) kfree(a)
72880
72881 #define large_malloc(a) vmalloc(a)
72882 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
72883 index 5f1ab92..39c35ae 100644
72884 --- a/include/linux/devfreq.h
72885 +++ b/include/linux/devfreq.h
72886 @@ -114,7 +114,7 @@ struct devfreq_governor {
72887 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
72888 int (*event_handler)(struct devfreq *devfreq,
72889 unsigned int event, void *data);
72890 -};
72891 +} __do_const;
72892
72893 /**
72894 * struct devfreq - Device devfreq structure
72895 diff --git a/include/linux/device.h b/include/linux/device.h
72896 index 22b546a..a573dc9 100644
72897 --- a/include/linux/device.h
72898 +++ b/include/linux/device.h
72899 @@ -305,7 +305,7 @@ struct subsys_interface {
72900 struct list_head node;
72901 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
72902 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
72903 -};
72904 +} __do_const;
72905
72906 int subsys_interface_register(struct subsys_interface *sif);
72907 void subsys_interface_unregister(struct subsys_interface *sif);
72908 @@ -493,7 +493,7 @@ struct device_type {
72909 void (*release)(struct device *dev);
72910
72911 const struct dev_pm_ops *pm;
72912 -};
72913 +} __do_const;
72914
72915 /* interface for exporting device attributes */
72916 struct device_attribute {
72917 @@ -503,11 +503,12 @@ struct device_attribute {
72918 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
72919 const char *buf, size_t count);
72920 };
72921 +typedef struct device_attribute __no_const device_attribute_no_const;
72922
72923 struct dev_ext_attribute {
72924 struct device_attribute attr;
72925 void *var;
72926 -};
72927 +} __do_const;
72928
72929 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
72930 char *buf);
72931 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
72932 index 94af418..b1ca7a2 100644
72933 --- a/include/linux/dma-mapping.h
72934 +++ b/include/linux/dma-mapping.h
72935 @@ -54,7 +54,7 @@ struct dma_map_ops {
72936 u64 (*get_required_mask)(struct device *dev);
72937 #endif
72938 int is_phys;
72939 -};
72940 +} __do_const;
72941
72942 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
72943
72944 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
72945 index cb286b1..923d066 100644
72946 --- a/include/linux/dmaengine.h
72947 +++ b/include/linux/dmaengine.h
72948 @@ -1030,9 +1030,9 @@ struct dma_pinned_list {
72949 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
72950 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
72951
72952 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72953 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72954 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
72955 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72956 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72957 struct dma_pinned_list *pinned_list, struct page *page,
72958 unsigned int offset, size_t len);
72959
72960 diff --git a/include/linux/efi.h b/include/linux/efi.h
72961 index 5f8f176..62a0556 100644
72962 --- a/include/linux/efi.h
72963 +++ b/include/linux/efi.h
72964 @@ -745,6 +745,7 @@ struct efivar_operations {
72965 efi_set_variable_t *set_variable;
72966 efi_query_variable_store_t *query_variable_store;
72967 };
72968 +typedef struct efivar_operations __no_const efivar_operations_no_const;
72969
72970 struct efivars {
72971 /*
72972 diff --git a/include/linux/elf.h b/include/linux/elf.h
72973 index 40a3c0e..4c45a38 100644
72974 --- a/include/linux/elf.h
72975 +++ b/include/linux/elf.h
72976 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
72977 #define elf_note elf32_note
72978 #define elf_addr_t Elf32_Off
72979 #define Elf_Half Elf32_Half
72980 +#define elf_dyn Elf32_Dyn
72981
72982 #else
72983
72984 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
72985 #define elf_note elf64_note
72986 #define elf_addr_t Elf64_Off
72987 #define Elf_Half Elf64_Half
72988 +#define elf_dyn Elf64_Dyn
72989
72990 #endif
72991
72992 diff --git a/include/linux/err.h b/include/linux/err.h
72993 index 221fcfb..f29e5e2 100644
72994 --- a/include/linux/err.h
72995 +++ b/include/linux/err.h
72996 @@ -19,12 +19,12 @@
72997
72998 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
72999
73000 -static inline void * __must_check ERR_PTR(long error)
73001 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
73002 {
73003 return (void *) error;
73004 }
73005
73006 -static inline long __must_check PTR_ERR(__force const void *ptr)
73007 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
73008 {
73009 return (long) ptr;
73010 }
73011 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
73012 index fcb51c8..bdafcf6 100644
73013 --- a/include/linux/extcon.h
73014 +++ b/include/linux/extcon.h
73015 @@ -134,7 +134,7 @@ struct extcon_dev {
73016 /* /sys/class/extcon/.../mutually_exclusive/... */
73017 struct attribute_group attr_g_muex;
73018 struct attribute **attrs_muex;
73019 - struct device_attribute *d_attrs_muex;
73020 + device_attribute_no_const *d_attrs_muex;
73021 };
73022
73023 /**
73024 diff --git a/include/linux/fb.h b/include/linux/fb.h
73025 index ffac70a..ca3e711 100644
73026 --- a/include/linux/fb.h
73027 +++ b/include/linux/fb.h
73028 @@ -304,7 +304,7 @@ struct fb_ops {
73029 /* called at KDB enter and leave time to prepare the console */
73030 int (*fb_debug_enter)(struct fb_info *info);
73031 int (*fb_debug_leave)(struct fb_info *info);
73032 -};
73033 +} __do_const;
73034
73035 #ifdef CONFIG_FB_TILEBLITTING
73036 #define FB_TILE_CURSOR_NONE 0
73037 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
73038 index 085197b..0fa6f0b 100644
73039 --- a/include/linux/fdtable.h
73040 +++ b/include/linux/fdtable.h
73041 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
73042 void put_files_struct(struct files_struct *fs);
73043 void reset_files_struct(struct files_struct *);
73044 int unshare_files(struct files_struct **);
73045 -struct files_struct *dup_fd(struct files_struct *, int *);
73046 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
73047 void do_close_on_exec(struct files_struct *);
73048 int iterate_fd(struct files_struct *, unsigned,
73049 int (*)(const void *, struct file *, unsigned),
73050 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
73051 index 8293262..2b3b8bd 100644
73052 --- a/include/linux/frontswap.h
73053 +++ b/include/linux/frontswap.h
73054 @@ -11,7 +11,7 @@ struct frontswap_ops {
73055 int (*load)(unsigned, pgoff_t, struct page *);
73056 void (*invalidate_page)(unsigned, pgoff_t);
73057 void (*invalidate_area)(unsigned);
73058 -};
73059 +} __no_const;
73060
73061 extern bool frontswap_enabled;
73062 extern struct frontswap_ops *
73063 diff --git a/include/linux/fs.h b/include/linux/fs.h
73064 index 9818747..788bfbd 100644
73065 --- a/include/linux/fs.h
73066 +++ b/include/linux/fs.h
73067 @@ -1554,7 +1554,8 @@ struct file_operations {
73068 long (*fallocate)(struct file *file, int mode, loff_t offset,
73069 loff_t len);
73070 int (*show_fdinfo)(struct seq_file *m, struct file *f);
73071 -};
73072 +} __do_const;
73073 +typedef struct file_operations __no_const file_operations_no_const;
73074
73075 struct inode_operations {
73076 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
73077 @@ -2740,4 +2741,14 @@ static inline bool dir_relax(struct inode *inode)
73078 return !IS_DEADDIR(inode);
73079 }
73080
73081 +static inline bool is_sidechannel_device(const struct inode *inode)
73082 +{
73083 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
73084 + umode_t mode = inode->i_mode;
73085 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
73086 +#else
73087 + return false;
73088 +#endif
73089 +}
73090 +
73091 #endif /* _LINUX_FS_H */
73092 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
73093 index 2b93a9a..855d94a 100644
73094 --- a/include/linux/fs_struct.h
73095 +++ b/include/linux/fs_struct.h
73096 @@ -6,7 +6,7 @@
73097 #include <linux/seqlock.h>
73098
73099 struct fs_struct {
73100 - int users;
73101 + atomic_t users;
73102 spinlock_t lock;
73103 seqcount_t seq;
73104 int umask;
73105 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
73106 index a9ff9a3..1ba1788 100644
73107 --- a/include/linux/fscache-cache.h
73108 +++ b/include/linux/fscache-cache.h
73109 @@ -113,7 +113,7 @@ struct fscache_operation {
73110 fscache_operation_release_t release;
73111 };
73112
73113 -extern atomic_t fscache_op_debug_id;
73114 +extern atomic_unchecked_t fscache_op_debug_id;
73115 extern void fscache_op_work_func(struct work_struct *work);
73116
73117 extern void fscache_enqueue_operation(struct fscache_operation *);
73118 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
73119 INIT_WORK(&op->work, fscache_op_work_func);
73120 atomic_set(&op->usage, 1);
73121 op->state = FSCACHE_OP_ST_INITIALISED;
73122 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
73123 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
73124 op->processor = processor;
73125 op->release = release;
73126 INIT_LIST_HEAD(&op->pend_link);
73127 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
73128 index 7a08623..4c07b0f 100644
73129 --- a/include/linux/fscache.h
73130 +++ b/include/linux/fscache.h
73131 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
73132 * - this is mandatory for any object that may have data
73133 */
73134 void (*now_uncached)(void *cookie_netfs_data);
73135 -};
73136 +} __do_const;
73137
73138 /*
73139 * fscache cached network filesystem type
73140 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
73141 index 1c804b0..1432c2b 100644
73142 --- a/include/linux/fsnotify.h
73143 +++ b/include/linux/fsnotify.h
73144 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
73145 struct inode *inode = file_inode(file);
73146 __u32 mask = FS_ACCESS;
73147
73148 + if (is_sidechannel_device(inode))
73149 + return;
73150 +
73151 if (S_ISDIR(inode->i_mode))
73152 mask |= FS_ISDIR;
73153
73154 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
73155 struct inode *inode = file_inode(file);
73156 __u32 mask = FS_MODIFY;
73157
73158 + if (is_sidechannel_device(inode))
73159 + return;
73160 +
73161 if (S_ISDIR(inode->i_mode))
73162 mask |= FS_ISDIR;
73163
73164 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
73165 */
73166 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
73167 {
73168 - return kstrdup(name, GFP_KERNEL);
73169 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
73170 }
73171
73172 /*
73173 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
73174 index 9f3c275..8bdff5d 100644
73175 --- a/include/linux/genhd.h
73176 +++ b/include/linux/genhd.h
73177 @@ -194,7 +194,7 @@ struct gendisk {
73178 struct kobject *slave_dir;
73179
73180 struct timer_rand_state *random;
73181 - atomic_t sync_io; /* RAID */
73182 + atomic_unchecked_t sync_io; /* RAID */
73183 struct disk_events *ev;
73184 #ifdef CONFIG_BLK_DEV_INTEGRITY
73185 struct blk_integrity *integrity;
73186 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
73187 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
73188
73189 /* drivers/char/random.c */
73190 -extern void add_disk_randomness(struct gendisk *disk);
73191 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
73192 extern void rand_initialize_disk(struct gendisk *disk);
73193
73194 static inline sector_t get_start_sect(struct block_device *bdev)
73195 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
73196 index 023bc34..b02b46a 100644
73197 --- a/include/linux/genl_magic_func.h
73198 +++ b/include/linux/genl_magic_func.h
73199 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
73200 },
73201
73202 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
73203 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
73204 +static struct genl_ops ZZZ_genl_ops[] = {
73205 #include GENL_MAGIC_INCLUDE_FILE
73206 };
73207
73208 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
73209 index 9b4dd49..61fd41d 100644
73210 --- a/include/linux/gfp.h
73211 +++ b/include/linux/gfp.h
73212 @@ -35,6 +35,13 @@ struct vm_area_struct;
73213 #define ___GFP_NO_KSWAPD 0x400000u
73214 #define ___GFP_OTHER_NODE 0x800000u
73215 #define ___GFP_WRITE 0x1000000u
73216 +
73217 +#ifdef CONFIG_PAX_USERCOPY_SLABS
73218 +#define ___GFP_USERCOPY 0x2000000u
73219 +#else
73220 +#define ___GFP_USERCOPY 0
73221 +#endif
73222 +
73223 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
73224
73225 /*
73226 @@ -92,6 +99,7 @@ struct vm_area_struct;
73227 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
73228 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
73229 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
73230 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
73231
73232 /*
73233 * This may seem redundant, but it's a way of annotating false positives vs.
73234 @@ -99,7 +107,7 @@ struct vm_area_struct;
73235 */
73236 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
73237
73238 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
73239 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
73240 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
73241
73242 /* This equals 0, but use constants in case they ever change */
73243 @@ -153,6 +161,8 @@ struct vm_area_struct;
73244 /* 4GB DMA on some platforms */
73245 #define GFP_DMA32 __GFP_DMA32
73246
73247 +#define GFP_USERCOPY __GFP_USERCOPY
73248 +
73249 /* Convert GFP flags to their corresponding migrate type */
73250 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
73251 {
73252 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
73253 new file mode 100644
73254 index 0000000..ebe6d72
73255 --- /dev/null
73256 +++ b/include/linux/gracl.h
73257 @@ -0,0 +1,319 @@
73258 +#ifndef GR_ACL_H
73259 +#define GR_ACL_H
73260 +
73261 +#include <linux/grdefs.h>
73262 +#include <linux/resource.h>
73263 +#include <linux/capability.h>
73264 +#include <linux/dcache.h>
73265 +#include <asm/resource.h>
73266 +
73267 +/* Major status information */
73268 +
73269 +#define GR_VERSION "grsecurity 2.9.1"
73270 +#define GRSECURITY_VERSION 0x2901
73271 +
73272 +enum {
73273 + GR_SHUTDOWN = 0,
73274 + GR_ENABLE = 1,
73275 + GR_SPROLE = 2,
73276 + GR_RELOAD = 3,
73277 + GR_SEGVMOD = 4,
73278 + GR_STATUS = 5,
73279 + GR_UNSPROLE = 6,
73280 + GR_PASSSET = 7,
73281 + GR_SPROLEPAM = 8,
73282 +};
73283 +
73284 +/* Password setup definitions
73285 + * kernel/grhash.c */
73286 +enum {
73287 + GR_PW_LEN = 128,
73288 + GR_SALT_LEN = 16,
73289 + GR_SHA_LEN = 32,
73290 +};
73291 +
73292 +enum {
73293 + GR_SPROLE_LEN = 64,
73294 +};
73295 +
73296 +enum {
73297 + GR_NO_GLOB = 0,
73298 + GR_REG_GLOB,
73299 + GR_CREATE_GLOB
73300 +};
73301 +
73302 +#define GR_NLIMITS 32
73303 +
73304 +/* Begin Data Structures */
73305 +
73306 +struct sprole_pw {
73307 + unsigned char *rolename;
73308 + unsigned char salt[GR_SALT_LEN];
73309 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
73310 +};
73311 +
73312 +struct name_entry {
73313 + __u32 key;
73314 + ino_t inode;
73315 + dev_t device;
73316 + char *name;
73317 + __u16 len;
73318 + __u8 deleted;
73319 + struct name_entry *prev;
73320 + struct name_entry *next;
73321 +};
73322 +
73323 +struct inodev_entry {
73324 + struct name_entry *nentry;
73325 + struct inodev_entry *prev;
73326 + struct inodev_entry *next;
73327 +};
73328 +
73329 +struct acl_role_db {
73330 + struct acl_role_label **r_hash;
73331 + __u32 r_size;
73332 +};
73333 +
73334 +struct inodev_db {
73335 + struct inodev_entry **i_hash;
73336 + __u32 i_size;
73337 +};
73338 +
73339 +struct name_db {
73340 + struct name_entry **n_hash;
73341 + __u32 n_size;
73342 +};
73343 +
73344 +struct crash_uid {
73345 + uid_t uid;
73346 + unsigned long expires;
73347 +};
73348 +
73349 +struct gr_hash_struct {
73350 + void **table;
73351 + void **nametable;
73352 + void *first;
73353 + __u32 table_size;
73354 + __u32 used_size;
73355 + int type;
73356 +};
73357 +
73358 +/* Userspace Grsecurity ACL data structures */
73359 +
73360 +struct acl_subject_label {
73361 + char *filename;
73362 + ino_t inode;
73363 + dev_t device;
73364 + __u32 mode;
73365 + kernel_cap_t cap_mask;
73366 + kernel_cap_t cap_lower;
73367 + kernel_cap_t cap_invert_audit;
73368 +
73369 + struct rlimit res[GR_NLIMITS];
73370 + __u32 resmask;
73371 +
73372 + __u8 user_trans_type;
73373 + __u8 group_trans_type;
73374 + uid_t *user_transitions;
73375 + gid_t *group_transitions;
73376 + __u16 user_trans_num;
73377 + __u16 group_trans_num;
73378 +
73379 + __u32 sock_families[2];
73380 + __u32 ip_proto[8];
73381 + __u32 ip_type;
73382 + struct acl_ip_label **ips;
73383 + __u32 ip_num;
73384 + __u32 inaddr_any_override;
73385 +
73386 + __u32 crashes;
73387 + unsigned long expires;
73388 +
73389 + struct acl_subject_label *parent_subject;
73390 + struct gr_hash_struct *hash;
73391 + struct acl_subject_label *prev;
73392 + struct acl_subject_label *next;
73393 +
73394 + struct acl_object_label **obj_hash;
73395 + __u32 obj_hash_size;
73396 + __u16 pax_flags;
73397 +};
73398 +
73399 +struct role_allowed_ip {
73400 + __u32 addr;
73401 + __u32 netmask;
73402 +
73403 + struct role_allowed_ip *prev;
73404 + struct role_allowed_ip *next;
73405 +};
73406 +
73407 +struct role_transition {
73408 + char *rolename;
73409 +
73410 + struct role_transition *prev;
73411 + struct role_transition *next;
73412 +};
73413 +
73414 +struct acl_role_label {
73415 + char *rolename;
73416 + uid_t uidgid;
73417 + __u16 roletype;
73418 +
73419 + __u16 auth_attempts;
73420 + unsigned long expires;
73421 +
73422 + struct acl_subject_label *root_label;
73423 + struct gr_hash_struct *hash;
73424 +
73425 + struct acl_role_label *prev;
73426 + struct acl_role_label *next;
73427 +
73428 + struct role_transition *transitions;
73429 + struct role_allowed_ip *allowed_ips;
73430 + uid_t *domain_children;
73431 + __u16 domain_child_num;
73432 +
73433 + umode_t umask;
73434 +
73435 + struct acl_subject_label **subj_hash;
73436 + __u32 subj_hash_size;
73437 +};
73438 +
73439 +struct user_acl_role_db {
73440 + struct acl_role_label **r_table;
73441 + __u32 num_pointers; /* Number of allocations to track */
73442 + __u32 num_roles; /* Number of roles */
73443 + __u32 num_domain_children; /* Number of domain children */
73444 + __u32 num_subjects; /* Number of subjects */
73445 + __u32 num_objects; /* Number of objects */
73446 +};
73447 +
73448 +struct acl_object_label {
73449 + char *filename;
73450 + ino_t inode;
73451 + dev_t device;
73452 + __u32 mode;
73453 +
73454 + struct acl_subject_label *nested;
73455 + struct acl_object_label *globbed;
73456 +
73457 + /* next two structures not used */
73458 +
73459 + struct acl_object_label *prev;
73460 + struct acl_object_label *next;
73461 +};
73462 +
73463 +struct acl_ip_label {
73464 + char *iface;
73465 + __u32 addr;
73466 + __u32 netmask;
73467 + __u16 low, high;
73468 + __u8 mode;
73469 + __u32 type;
73470 + __u32 proto[8];
73471 +
73472 + /* next two structures not used */
73473 +
73474 + struct acl_ip_label *prev;
73475 + struct acl_ip_label *next;
73476 +};
73477 +
73478 +struct gr_arg {
73479 + struct user_acl_role_db role_db;
73480 + unsigned char pw[GR_PW_LEN];
73481 + unsigned char salt[GR_SALT_LEN];
73482 + unsigned char sum[GR_SHA_LEN];
73483 + unsigned char sp_role[GR_SPROLE_LEN];
73484 + struct sprole_pw *sprole_pws;
73485 + dev_t segv_device;
73486 + ino_t segv_inode;
73487 + uid_t segv_uid;
73488 + __u16 num_sprole_pws;
73489 + __u16 mode;
73490 +};
73491 +
73492 +struct gr_arg_wrapper {
73493 + struct gr_arg *arg;
73494 + __u32 version;
73495 + __u32 size;
73496 +};
73497 +
73498 +struct subject_map {
73499 + struct acl_subject_label *user;
73500 + struct acl_subject_label *kernel;
73501 + struct subject_map *prev;
73502 + struct subject_map *next;
73503 +};
73504 +
73505 +struct acl_subj_map_db {
73506 + struct subject_map **s_hash;
73507 + __u32 s_size;
73508 +};
73509 +
73510 +/* End Data Structures Section */
73511 +
73512 +/* Hash functions generated by empirical testing by Brad Spengler
73513 + Makes good use of the low bits of the inode. Generally 0-1 times
73514 + in loop for successful match. 0-3 for unsuccessful match.
73515 + Shift/add algorithm with modulus of table size and an XOR*/
73516 +
73517 +static __inline__ unsigned int
73518 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
73519 +{
73520 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
73521 +}
73522 +
73523 + static __inline__ unsigned int
73524 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
73525 +{
73526 + return ((const unsigned long)userp % sz);
73527 +}
73528 +
73529 +static __inline__ unsigned int
73530 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
73531 +{
73532 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
73533 +}
73534 +
73535 +static __inline__ unsigned int
73536 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
73537 +{
73538 + return full_name_hash((const unsigned char *)name, len) % sz;
73539 +}
73540 +
73541 +#define FOR_EACH_ROLE_START(role) \
73542 + role = role_list; \
73543 + while (role) {
73544 +
73545 +#define FOR_EACH_ROLE_END(role) \
73546 + role = role->prev; \
73547 + }
73548 +
73549 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
73550 + subj = NULL; \
73551 + iter = 0; \
73552 + while (iter < role->subj_hash_size) { \
73553 + if (subj == NULL) \
73554 + subj = role->subj_hash[iter]; \
73555 + if (subj == NULL) { \
73556 + iter++; \
73557 + continue; \
73558 + }
73559 +
73560 +#define FOR_EACH_SUBJECT_END(subj,iter) \
73561 + subj = subj->next; \
73562 + if (subj == NULL) \
73563 + iter++; \
73564 + }
73565 +
73566 +
73567 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
73568 + subj = role->hash->first; \
73569 + while (subj != NULL) {
73570 +
73571 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
73572 + subj = subj->next; \
73573 + }
73574 +
73575 +#endif
73576 +
73577 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
73578 new file mode 100644
73579 index 0000000..33ebd1f
73580 --- /dev/null
73581 +++ b/include/linux/gracl_compat.h
73582 @@ -0,0 +1,156 @@
73583 +#ifndef GR_ACL_COMPAT_H
73584 +#define GR_ACL_COMPAT_H
73585 +
73586 +#include <linux/resource.h>
73587 +#include <asm/resource.h>
73588 +
73589 +struct sprole_pw_compat {
73590 + compat_uptr_t rolename;
73591 + unsigned char salt[GR_SALT_LEN];
73592 + unsigned char sum[GR_SHA_LEN];
73593 +};
73594 +
73595 +struct gr_hash_struct_compat {
73596 + compat_uptr_t table;
73597 + compat_uptr_t nametable;
73598 + compat_uptr_t first;
73599 + __u32 table_size;
73600 + __u32 used_size;
73601 + int type;
73602 +};
73603 +
73604 +struct acl_subject_label_compat {
73605 + compat_uptr_t filename;
73606 + compat_ino_t inode;
73607 + __u32 device;
73608 + __u32 mode;
73609 + kernel_cap_t cap_mask;
73610 + kernel_cap_t cap_lower;
73611 + kernel_cap_t cap_invert_audit;
73612 +
73613 + struct compat_rlimit res[GR_NLIMITS];
73614 + __u32 resmask;
73615 +
73616 + __u8 user_trans_type;
73617 + __u8 group_trans_type;
73618 + compat_uptr_t user_transitions;
73619 + compat_uptr_t group_transitions;
73620 + __u16 user_trans_num;
73621 + __u16 group_trans_num;
73622 +
73623 + __u32 sock_families[2];
73624 + __u32 ip_proto[8];
73625 + __u32 ip_type;
73626 + compat_uptr_t ips;
73627 + __u32 ip_num;
73628 + __u32 inaddr_any_override;
73629 +
73630 + __u32 crashes;
73631 + compat_ulong_t expires;
73632 +
73633 + compat_uptr_t parent_subject;
73634 + compat_uptr_t hash;
73635 + compat_uptr_t prev;
73636 + compat_uptr_t next;
73637 +
73638 + compat_uptr_t obj_hash;
73639 + __u32 obj_hash_size;
73640 + __u16 pax_flags;
73641 +};
73642 +
73643 +struct role_allowed_ip_compat {
73644 + __u32 addr;
73645 + __u32 netmask;
73646 +
73647 + compat_uptr_t prev;
73648 + compat_uptr_t next;
73649 +};
73650 +
73651 +struct role_transition_compat {
73652 + compat_uptr_t rolename;
73653 +
73654 + compat_uptr_t prev;
73655 + compat_uptr_t next;
73656 +};
73657 +
73658 +struct acl_role_label_compat {
73659 + compat_uptr_t rolename;
73660 + uid_t uidgid;
73661 + __u16 roletype;
73662 +
73663 + __u16 auth_attempts;
73664 + compat_ulong_t expires;
73665 +
73666 + compat_uptr_t root_label;
73667 + compat_uptr_t hash;
73668 +
73669 + compat_uptr_t prev;
73670 + compat_uptr_t next;
73671 +
73672 + compat_uptr_t transitions;
73673 + compat_uptr_t allowed_ips;
73674 + compat_uptr_t domain_children;
73675 + __u16 domain_child_num;
73676 +
73677 + umode_t umask;
73678 +
73679 + compat_uptr_t subj_hash;
73680 + __u32 subj_hash_size;
73681 +};
73682 +
73683 +struct user_acl_role_db_compat {
73684 + compat_uptr_t r_table;
73685 + __u32 num_pointers;
73686 + __u32 num_roles;
73687 + __u32 num_domain_children;
73688 + __u32 num_subjects;
73689 + __u32 num_objects;
73690 +};
73691 +
73692 +struct acl_object_label_compat {
73693 + compat_uptr_t filename;
73694 + compat_ino_t inode;
73695 + __u32 device;
73696 + __u32 mode;
73697 +
73698 + compat_uptr_t nested;
73699 + compat_uptr_t globbed;
73700 +
73701 + compat_uptr_t prev;
73702 + compat_uptr_t next;
73703 +};
73704 +
73705 +struct acl_ip_label_compat {
73706 + compat_uptr_t iface;
73707 + __u32 addr;
73708 + __u32 netmask;
73709 + __u16 low, high;
73710 + __u8 mode;
73711 + __u32 type;
73712 + __u32 proto[8];
73713 +
73714 + compat_uptr_t prev;
73715 + compat_uptr_t next;
73716 +};
73717 +
73718 +struct gr_arg_compat {
73719 + struct user_acl_role_db_compat role_db;
73720 + unsigned char pw[GR_PW_LEN];
73721 + unsigned char salt[GR_SALT_LEN];
73722 + unsigned char sum[GR_SHA_LEN];
73723 + unsigned char sp_role[GR_SPROLE_LEN];
73724 + compat_uptr_t sprole_pws;
73725 + __u32 segv_device;
73726 + compat_ino_t segv_inode;
73727 + uid_t segv_uid;
73728 + __u16 num_sprole_pws;
73729 + __u16 mode;
73730 +};
73731 +
73732 +struct gr_arg_wrapper_compat {
73733 + compat_uptr_t arg;
73734 + __u32 version;
73735 + __u32 size;
73736 +};
73737 +
73738 +#endif
73739 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
73740 new file mode 100644
73741 index 0000000..323ecf2
73742 --- /dev/null
73743 +++ b/include/linux/gralloc.h
73744 @@ -0,0 +1,9 @@
73745 +#ifndef __GRALLOC_H
73746 +#define __GRALLOC_H
73747 +
73748 +void acl_free_all(void);
73749 +int acl_alloc_stack_init(unsigned long size);
73750 +void *acl_alloc(unsigned long len);
73751 +void *acl_alloc_num(unsigned long num, unsigned long len);
73752 +
73753 +#endif
73754 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
73755 new file mode 100644
73756 index 0000000..be66033
73757 --- /dev/null
73758 +++ b/include/linux/grdefs.h
73759 @@ -0,0 +1,140 @@
73760 +#ifndef GRDEFS_H
73761 +#define GRDEFS_H
73762 +
73763 +/* Begin grsecurity status declarations */
73764 +
73765 +enum {
73766 + GR_READY = 0x01,
73767 + GR_STATUS_INIT = 0x00 // disabled state
73768 +};
73769 +
73770 +/* Begin ACL declarations */
73771 +
73772 +/* Role flags */
73773 +
73774 +enum {
73775 + GR_ROLE_USER = 0x0001,
73776 + GR_ROLE_GROUP = 0x0002,
73777 + GR_ROLE_DEFAULT = 0x0004,
73778 + GR_ROLE_SPECIAL = 0x0008,
73779 + GR_ROLE_AUTH = 0x0010,
73780 + GR_ROLE_NOPW = 0x0020,
73781 + GR_ROLE_GOD = 0x0040,
73782 + GR_ROLE_LEARN = 0x0080,
73783 + GR_ROLE_TPE = 0x0100,
73784 + GR_ROLE_DOMAIN = 0x0200,
73785 + GR_ROLE_PAM = 0x0400,
73786 + GR_ROLE_PERSIST = 0x0800
73787 +};
73788 +
73789 +/* ACL Subject and Object mode flags */
73790 +enum {
73791 + GR_DELETED = 0x80000000
73792 +};
73793 +
73794 +/* ACL Object-only mode flags */
73795 +enum {
73796 + GR_READ = 0x00000001,
73797 + GR_APPEND = 0x00000002,
73798 + GR_WRITE = 0x00000004,
73799 + GR_EXEC = 0x00000008,
73800 + GR_FIND = 0x00000010,
73801 + GR_INHERIT = 0x00000020,
73802 + GR_SETID = 0x00000040,
73803 + GR_CREATE = 0x00000080,
73804 + GR_DELETE = 0x00000100,
73805 + GR_LINK = 0x00000200,
73806 + GR_AUDIT_READ = 0x00000400,
73807 + GR_AUDIT_APPEND = 0x00000800,
73808 + GR_AUDIT_WRITE = 0x00001000,
73809 + GR_AUDIT_EXEC = 0x00002000,
73810 + GR_AUDIT_FIND = 0x00004000,
73811 + GR_AUDIT_INHERIT= 0x00008000,
73812 + GR_AUDIT_SETID = 0x00010000,
73813 + GR_AUDIT_CREATE = 0x00020000,
73814 + GR_AUDIT_DELETE = 0x00040000,
73815 + GR_AUDIT_LINK = 0x00080000,
73816 + GR_PTRACERD = 0x00100000,
73817 + GR_NOPTRACE = 0x00200000,
73818 + GR_SUPPRESS = 0x00400000,
73819 + GR_NOLEARN = 0x00800000,
73820 + GR_INIT_TRANSFER= 0x01000000
73821 +};
73822 +
73823 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
73824 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
73825 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
73826 +
73827 +/* ACL subject-only mode flags */
73828 +enum {
73829 + GR_KILL = 0x00000001,
73830 + GR_VIEW = 0x00000002,
73831 + GR_PROTECTED = 0x00000004,
73832 + GR_LEARN = 0x00000008,
73833 + GR_OVERRIDE = 0x00000010,
73834 + /* just a placeholder, this mode is only used in userspace */
73835 + GR_DUMMY = 0x00000020,
73836 + GR_PROTSHM = 0x00000040,
73837 + GR_KILLPROC = 0x00000080,
73838 + GR_KILLIPPROC = 0x00000100,
73839 + /* just a placeholder, this mode is only used in userspace */
73840 + GR_NOTROJAN = 0x00000200,
73841 + GR_PROTPROCFD = 0x00000400,
73842 + GR_PROCACCT = 0x00000800,
73843 + GR_RELAXPTRACE = 0x00001000,
73844 + //GR_NESTED = 0x00002000,
73845 + GR_INHERITLEARN = 0x00004000,
73846 + GR_PROCFIND = 0x00008000,
73847 + GR_POVERRIDE = 0x00010000,
73848 + GR_KERNELAUTH = 0x00020000,
73849 + GR_ATSECURE = 0x00040000,
73850 + GR_SHMEXEC = 0x00080000
73851 +};
73852 +
73853 +enum {
73854 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
73855 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
73856 + GR_PAX_ENABLE_MPROTECT = 0x0004,
73857 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
73858 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
73859 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
73860 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
73861 + GR_PAX_DISABLE_MPROTECT = 0x0400,
73862 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
73863 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
73864 +};
73865 +
73866 +enum {
73867 + GR_ID_USER = 0x01,
73868 + GR_ID_GROUP = 0x02,
73869 +};
73870 +
73871 +enum {
73872 + GR_ID_ALLOW = 0x01,
73873 + GR_ID_DENY = 0x02,
73874 +};
73875 +
73876 +#define GR_CRASH_RES 31
73877 +#define GR_UIDTABLE_MAX 500
73878 +
73879 +/* begin resource learning section */
73880 +enum {
73881 + GR_RLIM_CPU_BUMP = 60,
73882 + GR_RLIM_FSIZE_BUMP = 50000,
73883 + GR_RLIM_DATA_BUMP = 10000,
73884 + GR_RLIM_STACK_BUMP = 1000,
73885 + GR_RLIM_CORE_BUMP = 10000,
73886 + GR_RLIM_RSS_BUMP = 500000,
73887 + GR_RLIM_NPROC_BUMP = 1,
73888 + GR_RLIM_NOFILE_BUMP = 5,
73889 + GR_RLIM_MEMLOCK_BUMP = 50000,
73890 + GR_RLIM_AS_BUMP = 500000,
73891 + GR_RLIM_LOCKS_BUMP = 2,
73892 + GR_RLIM_SIGPENDING_BUMP = 5,
73893 + GR_RLIM_MSGQUEUE_BUMP = 10000,
73894 + GR_RLIM_NICE_BUMP = 1,
73895 + GR_RLIM_RTPRIO_BUMP = 1,
73896 + GR_RLIM_RTTIME_BUMP = 1000000
73897 +};
73898 +
73899 +#endif
73900 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
73901 new file mode 100644
73902 index 0000000..a5625be
73903 --- /dev/null
73904 +++ b/include/linux/grinternal.h
73905 @@ -0,0 +1,230 @@
73906 +#ifndef __GRINTERNAL_H
73907 +#define __GRINTERNAL_H
73908 +
73909 +#ifdef CONFIG_GRKERNSEC
73910 +
73911 +#include <linux/fs.h>
73912 +#include <linux/mnt_namespace.h>
73913 +#include <linux/nsproxy.h>
73914 +#include <linux/gracl.h>
73915 +#include <linux/grdefs.h>
73916 +#include <linux/grmsg.h>
73917 +
73918 +void gr_add_learn_entry(const char *fmt, ...)
73919 + __attribute__ ((format (printf, 1, 2)));
73920 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
73921 + const struct vfsmount *mnt);
73922 +__u32 gr_check_create(const struct dentry *new_dentry,
73923 + const struct dentry *parent,
73924 + const struct vfsmount *mnt, const __u32 mode);
73925 +int gr_check_protected_task(const struct task_struct *task);
73926 +__u32 to_gr_audit(const __u32 reqmode);
73927 +int gr_set_acls(const int type);
73928 +int gr_apply_subject_to_task(struct task_struct *task);
73929 +int gr_acl_is_enabled(void);
73930 +char gr_roletype_to_char(void);
73931 +
73932 +void gr_handle_alertkill(struct task_struct *task);
73933 +char *gr_to_filename(const struct dentry *dentry,
73934 + const struct vfsmount *mnt);
73935 +char *gr_to_filename1(const struct dentry *dentry,
73936 + const struct vfsmount *mnt);
73937 +char *gr_to_filename2(const struct dentry *dentry,
73938 + const struct vfsmount *mnt);
73939 +char *gr_to_filename3(const struct dentry *dentry,
73940 + const struct vfsmount *mnt);
73941 +
73942 +extern int grsec_enable_ptrace_readexec;
73943 +extern int grsec_enable_harden_ptrace;
73944 +extern int grsec_enable_link;
73945 +extern int grsec_enable_fifo;
73946 +extern int grsec_enable_execve;
73947 +extern int grsec_enable_shm;
73948 +extern int grsec_enable_execlog;
73949 +extern int grsec_enable_signal;
73950 +extern int grsec_enable_audit_ptrace;
73951 +extern int grsec_enable_forkfail;
73952 +extern int grsec_enable_time;
73953 +extern int grsec_enable_rofs;
73954 +extern int grsec_deny_new_usb;
73955 +extern int grsec_enable_chroot_shmat;
73956 +extern int grsec_enable_chroot_mount;
73957 +extern int grsec_enable_chroot_double;
73958 +extern int grsec_enable_chroot_pivot;
73959 +extern int grsec_enable_chroot_chdir;
73960 +extern int grsec_enable_chroot_chmod;
73961 +extern int grsec_enable_chroot_mknod;
73962 +extern int grsec_enable_chroot_fchdir;
73963 +extern int grsec_enable_chroot_nice;
73964 +extern int grsec_enable_chroot_execlog;
73965 +extern int grsec_enable_chroot_caps;
73966 +extern int grsec_enable_chroot_sysctl;
73967 +extern int grsec_enable_chroot_unix;
73968 +extern int grsec_enable_symlinkown;
73969 +extern kgid_t grsec_symlinkown_gid;
73970 +extern int grsec_enable_tpe;
73971 +extern kgid_t grsec_tpe_gid;
73972 +extern int grsec_enable_tpe_all;
73973 +extern int grsec_enable_tpe_invert;
73974 +extern int grsec_enable_socket_all;
73975 +extern kgid_t grsec_socket_all_gid;
73976 +extern int grsec_enable_socket_client;
73977 +extern kgid_t grsec_socket_client_gid;
73978 +extern int grsec_enable_socket_server;
73979 +extern kgid_t grsec_socket_server_gid;
73980 +extern kgid_t grsec_audit_gid;
73981 +extern int grsec_enable_group;
73982 +extern int grsec_enable_log_rwxmaps;
73983 +extern int grsec_enable_mount;
73984 +extern int grsec_enable_chdir;
73985 +extern int grsec_resource_logging;
73986 +extern int grsec_enable_blackhole;
73987 +extern int grsec_lastack_retries;
73988 +extern int grsec_enable_brute;
73989 +extern int grsec_enable_harden_ipc;
73990 +extern int grsec_lock;
73991 +
73992 +extern spinlock_t grsec_alert_lock;
73993 +extern unsigned long grsec_alert_wtime;
73994 +extern unsigned long grsec_alert_fyet;
73995 +
73996 +extern spinlock_t grsec_audit_lock;
73997 +
73998 +extern rwlock_t grsec_exec_file_lock;
73999 +
74000 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
74001 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
74002 + (tsk)->exec_file->f_path.mnt) : "/")
74003 +
74004 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
74005 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
74006 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74007 +
74008 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
74009 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
74010 + (tsk)->exec_file->f_path.mnt) : "/")
74011 +
74012 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
74013 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
74014 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74015 +
74016 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
74017 +
74018 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
74019 +
74020 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
74021 +{
74022 + if (file1 && file2) {
74023 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
74024 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
74025 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
74026 + return true;
74027 + }
74028 +
74029 + return false;
74030 +}
74031 +
74032 +#define GR_CHROOT_CAPS {{ \
74033 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
74034 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
74035 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
74036 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
74037 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
74038 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
74039 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
74040 +
74041 +#define security_learn(normal_msg,args...) \
74042 +({ \
74043 + read_lock(&grsec_exec_file_lock); \
74044 + gr_add_learn_entry(normal_msg "\n", ## args); \
74045 + read_unlock(&grsec_exec_file_lock); \
74046 +})
74047 +
74048 +enum {
74049 + GR_DO_AUDIT,
74050 + GR_DONT_AUDIT,
74051 + /* used for non-audit messages that we shouldn't kill the task on */
74052 + GR_DONT_AUDIT_GOOD
74053 +};
74054 +
74055 +enum {
74056 + GR_TTYSNIFF,
74057 + GR_RBAC,
74058 + GR_RBAC_STR,
74059 + GR_STR_RBAC,
74060 + GR_RBAC_MODE2,
74061 + GR_RBAC_MODE3,
74062 + GR_FILENAME,
74063 + GR_SYSCTL_HIDDEN,
74064 + GR_NOARGS,
74065 + GR_ONE_INT,
74066 + GR_ONE_INT_TWO_STR,
74067 + GR_ONE_STR,
74068 + GR_STR_INT,
74069 + GR_TWO_STR_INT,
74070 + GR_TWO_INT,
74071 + GR_TWO_U64,
74072 + GR_THREE_INT,
74073 + GR_FIVE_INT_TWO_STR,
74074 + GR_TWO_STR,
74075 + GR_THREE_STR,
74076 + GR_FOUR_STR,
74077 + GR_STR_FILENAME,
74078 + GR_FILENAME_STR,
74079 + GR_FILENAME_TWO_INT,
74080 + GR_FILENAME_TWO_INT_STR,
74081 + GR_TEXTREL,
74082 + GR_PTRACE,
74083 + GR_RESOURCE,
74084 + GR_CAP,
74085 + GR_SIG,
74086 + GR_SIG2,
74087 + GR_CRASH1,
74088 + GR_CRASH2,
74089 + GR_PSACCT,
74090 + GR_RWXMAP,
74091 + GR_RWXMAPVMA
74092 +};
74093 +
74094 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
74095 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
74096 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
74097 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
74098 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
74099 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
74100 +#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)
74101 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
74102 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
74103 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
74104 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
74105 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
74106 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
74107 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
74108 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
74109 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
74110 +#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)
74111 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
74112 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
74113 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
74114 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
74115 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
74116 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
74117 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
74118 +#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)
74119 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
74120 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
74121 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
74122 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
74123 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
74124 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
74125 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
74126 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
74127 +#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)
74128 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
74129 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
74130 +
74131 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
74132 +
74133 +#endif
74134 +
74135 +#endif
74136 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
74137 new file mode 100644
74138 index 0000000..378a81a
74139 --- /dev/null
74140 +++ b/include/linux/grmsg.h
74141 @@ -0,0 +1,114 @@
74142 +#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"
74143 +#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"
74144 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
74145 +#define GR_STOPMOD_MSG "denied modification of module state by "
74146 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
74147 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
74148 +#define GR_IOPERM_MSG "denied use of ioperm() by "
74149 +#define GR_IOPL_MSG "denied use of iopl() by "
74150 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
74151 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
74152 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
74153 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
74154 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
74155 +#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"
74156 +#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"
74157 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
74158 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
74159 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
74160 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
74161 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
74162 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
74163 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
74164 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
74165 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
74166 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
74167 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
74168 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
74169 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
74170 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
74171 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
74172 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
74173 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
74174 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
74175 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
74176 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
74177 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
74178 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
74179 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
74180 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
74181 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
74182 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
74183 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
74184 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
74185 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
74186 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
74187 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
74188 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
74189 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
74190 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
74191 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
74192 +#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"
74193 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
74194 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
74195 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
74196 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
74197 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
74198 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
74199 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
74200 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
74201 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
74202 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
74203 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
74204 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
74205 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
74206 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
74207 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
74208 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
74209 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
74210 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
74211 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
74212 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
74213 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
74214 +#define GR_NICE_CHROOT_MSG "denied priority change by "
74215 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
74216 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
74217 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
74218 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
74219 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
74220 +#define GR_TIME_MSG "time set by "
74221 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
74222 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
74223 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
74224 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
74225 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
74226 +#define GR_BIND_MSG "denied bind() by "
74227 +#define GR_CONNECT_MSG "denied connect() by "
74228 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
74229 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
74230 +#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"
74231 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
74232 +#define GR_CAP_ACL_MSG "use of %s denied for "
74233 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
74234 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
74235 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
74236 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
74237 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
74238 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
74239 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
74240 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
74241 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
74242 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
74243 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
74244 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
74245 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
74246 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
74247 +#define GR_VM86_MSG "denied use of vm86 by "
74248 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
74249 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
74250 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
74251 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
74252 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
74253 +#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 "
74254 +#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 "
74255 +#define GR_IPC_DENIED_MSG "denied %s of globally-%sable IPC with creator uid %u by "
74256 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
74257 new file mode 100644
74258 index 0000000..d6f5a21
74259 --- /dev/null
74260 +++ b/include/linux/grsecurity.h
74261 @@ -0,0 +1,244 @@
74262 +#ifndef GR_SECURITY_H
74263 +#define GR_SECURITY_H
74264 +#include <linux/fs.h>
74265 +#include <linux/fs_struct.h>
74266 +#include <linux/binfmts.h>
74267 +#include <linux/gracl.h>
74268 +
74269 +/* notify of brain-dead configs */
74270 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74271 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
74272 +#endif
74273 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
74274 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
74275 +#endif
74276 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
74277 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
74278 +#endif
74279 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
74280 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
74281 +#endif
74282 +
74283 +int gr_handle_new_usb(void);
74284 +
74285 +void gr_handle_brute_attach(unsigned long mm_flags);
74286 +void gr_handle_brute_check(void);
74287 +void gr_handle_kernel_exploit(void);
74288 +
74289 +char gr_roletype_to_char(void);
74290 +
74291 +int gr_acl_enable_at_secure(void);
74292 +
74293 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
74294 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
74295 +
74296 +void gr_del_task_from_ip_table(struct task_struct *p);
74297 +
74298 +int gr_pid_is_chrooted(struct task_struct *p);
74299 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
74300 +int gr_handle_chroot_nice(void);
74301 +int gr_handle_chroot_sysctl(const int op);
74302 +int gr_handle_chroot_setpriority(struct task_struct *p,
74303 + const int niceval);
74304 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
74305 +int gr_handle_chroot_chroot(const struct dentry *dentry,
74306 + const struct vfsmount *mnt);
74307 +void gr_handle_chroot_chdir(const struct path *path);
74308 +int gr_handle_chroot_chmod(const struct dentry *dentry,
74309 + const struct vfsmount *mnt, const int mode);
74310 +int gr_handle_chroot_mknod(const struct dentry *dentry,
74311 + const struct vfsmount *mnt, const int mode);
74312 +int gr_handle_chroot_mount(const struct dentry *dentry,
74313 + const struct vfsmount *mnt,
74314 + const char *dev_name);
74315 +int gr_handle_chroot_pivot(void);
74316 +int gr_handle_chroot_unix(const pid_t pid);
74317 +
74318 +int gr_handle_rawio(const struct inode *inode);
74319 +
74320 +void gr_handle_ioperm(void);
74321 +void gr_handle_iopl(void);
74322 +
74323 +umode_t gr_acl_umask(void);
74324 +
74325 +int gr_tpe_allow(const struct file *file);
74326 +
74327 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
74328 +void gr_clear_chroot_entries(struct task_struct *task);
74329 +
74330 +void gr_log_forkfail(const int retval);
74331 +void gr_log_timechange(void);
74332 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
74333 +void gr_log_chdir(const struct dentry *dentry,
74334 + const struct vfsmount *mnt);
74335 +void gr_log_chroot_exec(const struct dentry *dentry,
74336 + const struct vfsmount *mnt);
74337 +void gr_log_remount(const char *devname, const int retval);
74338 +void gr_log_unmount(const char *devname, const int retval);
74339 +void gr_log_mount(const char *from, const char *to, const int retval);
74340 +void gr_log_textrel(struct vm_area_struct *vma);
74341 +void gr_log_ptgnustack(struct file *file);
74342 +void gr_log_rwxmmap(struct file *file);
74343 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
74344 +
74345 +int gr_handle_follow_link(const struct inode *parent,
74346 + const struct inode *inode,
74347 + const struct dentry *dentry,
74348 + const struct vfsmount *mnt);
74349 +int gr_handle_fifo(const struct dentry *dentry,
74350 + const struct vfsmount *mnt,
74351 + const struct dentry *dir, const int flag,
74352 + const int acc_mode);
74353 +int gr_handle_hardlink(const struct dentry *dentry,
74354 + const struct vfsmount *mnt,
74355 + struct inode *inode,
74356 + const int mode, const struct filename *to);
74357 +
74358 +int gr_is_capable(const int cap);
74359 +int gr_is_capable_nolog(const int cap);
74360 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
74361 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
74362 +
74363 +void gr_copy_label(struct task_struct *tsk);
74364 +void gr_handle_crash(struct task_struct *task, const int sig);
74365 +int gr_handle_signal(const struct task_struct *p, const int sig);
74366 +int gr_check_crash_uid(const kuid_t uid);
74367 +int gr_check_protected_task(const struct task_struct *task);
74368 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
74369 +int gr_acl_handle_mmap(const struct file *file,
74370 + const unsigned long prot);
74371 +int gr_acl_handle_mprotect(const struct file *file,
74372 + const unsigned long prot);
74373 +int gr_check_hidden_task(const struct task_struct *tsk);
74374 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
74375 + const struct vfsmount *mnt);
74376 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
74377 + const struct vfsmount *mnt);
74378 +__u32 gr_acl_handle_access(const struct dentry *dentry,
74379 + const struct vfsmount *mnt, const int fmode);
74380 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
74381 + const struct vfsmount *mnt, umode_t *mode);
74382 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
74383 + const struct vfsmount *mnt);
74384 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
74385 + const struct vfsmount *mnt);
74386 +int gr_handle_ptrace(struct task_struct *task, const long request);
74387 +int gr_handle_proc_ptrace(struct task_struct *task);
74388 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
74389 + const struct vfsmount *mnt);
74390 +int gr_check_crash_exec(const struct file *filp);
74391 +int gr_acl_is_enabled(void);
74392 +void gr_set_kernel_label(struct task_struct *task);
74393 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
74394 + const kgid_t gid);
74395 +int gr_set_proc_label(const struct dentry *dentry,
74396 + const struct vfsmount *mnt,
74397 + const int unsafe_flags);
74398 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
74399 + const struct vfsmount *mnt);
74400 +__u32 gr_acl_handle_open(const struct dentry *dentry,
74401 + const struct vfsmount *mnt, int acc_mode);
74402 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
74403 + const struct dentry *p_dentry,
74404 + const struct vfsmount *p_mnt,
74405 + int open_flags, int acc_mode, const int imode);
74406 +void gr_handle_create(const struct dentry *dentry,
74407 + const struct vfsmount *mnt);
74408 +void gr_handle_proc_create(const struct dentry *dentry,
74409 + const struct inode *inode);
74410 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
74411 + const struct dentry *parent_dentry,
74412 + const struct vfsmount *parent_mnt,
74413 + const int mode);
74414 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
74415 + const struct dentry *parent_dentry,
74416 + const struct vfsmount *parent_mnt);
74417 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
74418 + const struct vfsmount *mnt);
74419 +void gr_handle_delete(const ino_t ino, const dev_t dev);
74420 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
74421 + const struct vfsmount *mnt);
74422 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
74423 + const struct dentry *parent_dentry,
74424 + const struct vfsmount *parent_mnt,
74425 + const struct filename *from);
74426 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
74427 + const struct dentry *parent_dentry,
74428 + const struct vfsmount *parent_mnt,
74429 + const struct dentry *old_dentry,
74430 + const struct vfsmount *old_mnt, const struct filename *to);
74431 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
74432 +int gr_acl_handle_rename(struct dentry *new_dentry,
74433 + struct dentry *parent_dentry,
74434 + const struct vfsmount *parent_mnt,
74435 + struct dentry *old_dentry,
74436 + struct inode *old_parent_inode,
74437 + struct vfsmount *old_mnt, const struct filename *newname);
74438 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
74439 + struct dentry *old_dentry,
74440 + struct dentry *new_dentry,
74441 + struct vfsmount *mnt, const __u8 replace);
74442 +__u32 gr_check_link(const struct dentry *new_dentry,
74443 + const struct dentry *parent_dentry,
74444 + const struct vfsmount *parent_mnt,
74445 + const struct dentry *old_dentry,
74446 + const struct vfsmount *old_mnt);
74447 +int gr_acl_handle_filldir(const struct file *file, const char *name,
74448 + const unsigned int namelen, const ino_t ino);
74449 +
74450 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
74451 + const struct vfsmount *mnt);
74452 +void gr_acl_handle_exit(void);
74453 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
74454 +int gr_acl_handle_procpidmem(const struct task_struct *task);
74455 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
74456 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
74457 +void gr_audit_ptrace(struct task_struct *task);
74458 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
74459 +void gr_put_exec_file(struct task_struct *task);
74460 +
74461 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
74462 +
74463 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
74464 +extern void gr_learn_resource(const struct task_struct *task, const int res,
74465 + const unsigned long wanted, const int gt);
74466 +#else
74467 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
74468 + const unsigned long wanted, const int gt)
74469 +{
74470 +}
74471 +#endif
74472 +
74473 +#ifdef CONFIG_GRKERNSEC_RESLOG
74474 +extern void gr_log_resource(const struct task_struct *task, const int res,
74475 + const unsigned long wanted, const int gt);
74476 +#else
74477 +static inline void gr_log_resource(const struct task_struct *task, const int res,
74478 + const unsigned long wanted, const int gt)
74479 +{
74480 +}
74481 +#endif
74482 +
74483 +#ifdef CONFIG_GRKERNSEC
74484 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
74485 +void gr_handle_vm86(void);
74486 +void gr_handle_mem_readwrite(u64 from, u64 to);
74487 +
74488 +void gr_log_badprocpid(const char *entry);
74489 +
74490 +extern int grsec_enable_dmesg;
74491 +extern int grsec_disable_privio;
74492 +
74493 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74494 +extern kgid_t grsec_proc_gid;
74495 +#endif
74496 +
74497 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
74498 +extern int grsec_enable_chroot_findtask;
74499 +#endif
74500 +#ifdef CONFIG_GRKERNSEC_SETXID
74501 +extern int grsec_enable_setxid;
74502 +#endif
74503 +#endif
74504 +
74505 +#endif
74506 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
74507 new file mode 100644
74508 index 0000000..e7ffaaf
74509 --- /dev/null
74510 +++ b/include/linux/grsock.h
74511 @@ -0,0 +1,19 @@
74512 +#ifndef __GRSOCK_H
74513 +#define __GRSOCK_H
74514 +
74515 +extern void gr_attach_curr_ip(const struct sock *sk);
74516 +extern int gr_handle_sock_all(const int family, const int type,
74517 + const int protocol);
74518 +extern int gr_handle_sock_server(const struct sockaddr *sck);
74519 +extern int gr_handle_sock_server_other(const struct sock *sck);
74520 +extern int gr_handle_sock_client(const struct sockaddr *sck);
74521 +extern int gr_search_connect(struct socket * sock,
74522 + struct sockaddr_in * addr);
74523 +extern int gr_search_bind(struct socket * sock,
74524 + struct sockaddr_in * addr);
74525 +extern int gr_search_listen(struct socket * sock);
74526 +extern int gr_search_accept(struct socket * sock);
74527 +extern int gr_search_socket(const int domain, const int type,
74528 + const int protocol);
74529 +
74530 +#endif
74531 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
74532 index 7fb31da..08b5114 100644
74533 --- a/include/linux/highmem.h
74534 +++ b/include/linux/highmem.h
74535 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
74536 kunmap_atomic(kaddr);
74537 }
74538
74539 +static inline void sanitize_highpage(struct page *page)
74540 +{
74541 + void *kaddr;
74542 + unsigned long flags;
74543 +
74544 + local_irq_save(flags);
74545 + kaddr = kmap_atomic(page);
74546 + clear_page(kaddr);
74547 + kunmap_atomic(kaddr);
74548 + local_irq_restore(flags);
74549 +}
74550 +
74551 static inline void zero_user_segments(struct page *page,
74552 unsigned start1, unsigned end1,
74553 unsigned start2, unsigned end2)
74554 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
74555 index 1c7b89a..7f52502 100644
74556 --- a/include/linux/hwmon-sysfs.h
74557 +++ b/include/linux/hwmon-sysfs.h
74558 @@ -25,7 +25,8 @@
74559 struct sensor_device_attribute{
74560 struct device_attribute dev_attr;
74561 int index;
74562 -};
74563 +} __do_const;
74564 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
74565 #define to_sensor_dev_attr(_dev_attr) \
74566 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
74567
74568 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
74569 struct device_attribute dev_attr;
74570 u8 index;
74571 u8 nr;
74572 -};
74573 +} __do_const;
74574 #define to_sensor_dev_attr_2(_dev_attr) \
74575 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
74576
74577 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
74578 index e988fa9..ff9f17e 100644
74579 --- a/include/linux/i2c.h
74580 +++ b/include/linux/i2c.h
74581 @@ -366,6 +366,7 @@ struct i2c_algorithm {
74582 /* To determine what the adapter supports */
74583 u32 (*functionality) (struct i2c_adapter *);
74584 };
74585 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
74586
74587 /**
74588 * struct i2c_bus_recovery_info - I2C bus recovery information
74589 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
74590 index d23c3c2..eb63c81 100644
74591 --- a/include/linux/i2o.h
74592 +++ b/include/linux/i2o.h
74593 @@ -565,7 +565,7 @@ struct i2o_controller {
74594 struct i2o_device *exec; /* Executive */
74595 #if BITS_PER_LONG == 64
74596 spinlock_t context_list_lock; /* lock for context_list */
74597 - atomic_t context_list_counter; /* needed for unique contexts */
74598 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
74599 struct list_head context_list; /* list of context id's
74600 and pointers */
74601 #endif
74602 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
74603 index aff7ad8..3942bbd 100644
74604 --- a/include/linux/if_pppox.h
74605 +++ b/include/linux/if_pppox.h
74606 @@ -76,7 +76,7 @@ struct pppox_proto {
74607 int (*ioctl)(struct socket *sock, unsigned int cmd,
74608 unsigned long arg);
74609 struct module *owner;
74610 -};
74611 +} __do_const;
74612
74613 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
74614 extern void unregister_pppox_proto(int proto_num);
74615 diff --git a/include/linux/init.h b/include/linux/init.h
74616 index e73f2b7..cc996e0 100644
74617 --- a/include/linux/init.h
74618 +++ b/include/linux/init.h
74619 @@ -39,9 +39,17 @@
74620 * Also note, that this data cannot be "const".
74621 */
74622
74623 +#define add_init_latent_entropy __latent_entropy
74624 +
74625 +#ifdef CONFIG_MEMORY_HOTPLUG
74626 +#define add_meminit_latent_entropy
74627 +#else
74628 +#define add_meminit_latent_entropy __latent_entropy
74629 +#endif
74630 +
74631 /* These are for everybody (although not all archs will actually
74632 discard it in modules) */
74633 -#define __init __section(.init.text) __cold notrace
74634 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
74635 #define __initdata __section(.init.data)
74636 #define __initconst __constsection(.init.rodata)
74637 #define __exitdata __section(.exit.data)
74638 @@ -102,7 +110,7 @@
74639 #define __cpuexitconst
74640
74641 /* Used for MEMORY_HOTPLUG */
74642 -#define __meminit __section(.meminit.text) __cold notrace
74643 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
74644 #define __meminitdata __section(.meminit.data)
74645 #define __meminitconst __constsection(.meminit.rodata)
74646 #define __memexit __section(.memexit.text) __exitused __cold notrace
74647 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
74648 index 5cd0f09..c9f67cc 100644
74649 --- a/include/linux/init_task.h
74650 +++ b/include/linux/init_task.h
74651 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
74652
74653 #define INIT_TASK_COMM "swapper"
74654
74655 +#ifdef CONFIG_X86
74656 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
74657 +#else
74658 +#define INIT_TASK_THREAD_INFO
74659 +#endif
74660 +
74661 /*
74662 * INIT_TASK is used to set up the first task table, touch at
74663 * your own risk!. Base=0, limit=0x1fffff (=2MB)
74664 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
74665 RCU_POINTER_INITIALIZER(cred, &init_cred), \
74666 .comm = INIT_TASK_COMM, \
74667 .thread = INIT_THREAD, \
74668 + INIT_TASK_THREAD_INFO \
74669 .fs = &init_fs, \
74670 .files = &init_files, \
74671 .signal = &init_signals, \
74672 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
74673 index 5fa5afe..ac55b25 100644
74674 --- a/include/linux/interrupt.h
74675 +++ b/include/linux/interrupt.h
74676 @@ -430,7 +430,7 @@ enum
74677 /* map softirq index to softirq name. update 'softirq_to_name' in
74678 * kernel/softirq.c when adding a new softirq.
74679 */
74680 -extern char *softirq_to_name[NR_SOFTIRQS];
74681 +extern const char * const softirq_to_name[NR_SOFTIRQS];
74682
74683 /* softirq mask and active fields moved to irq_cpustat_t in
74684 * asm/hardirq.h to get better cache usage. KAO
74685 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
74686
74687 struct softirq_action
74688 {
74689 - void (*action)(struct softirq_action *);
74690 -};
74691 + void (*action)(void);
74692 +} __no_const;
74693
74694 asmlinkage void do_softirq(void);
74695 asmlinkage void __do_softirq(void);
74696 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
74697 +extern void open_softirq(int nr, void (*action)(void));
74698 extern void softirq_init(void);
74699 extern void __raise_softirq_irqoff(unsigned int nr);
74700
74701 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
74702 index 3aeb730..2177f39 100644
74703 --- a/include/linux/iommu.h
74704 +++ b/include/linux/iommu.h
74705 @@ -113,7 +113,7 @@ struct iommu_ops {
74706 u32 (*domain_get_windows)(struct iommu_domain *domain);
74707
74708 unsigned long pgsize_bitmap;
74709 -};
74710 +} __do_const;
74711
74712 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
74713 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
74714 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
74715 index 89b7c24..382af74 100644
74716 --- a/include/linux/ioport.h
74717 +++ b/include/linux/ioport.h
74718 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
74719 int adjust_resource(struct resource *res, resource_size_t start,
74720 resource_size_t size);
74721 resource_size_t resource_alignment(struct resource *res);
74722 -static inline resource_size_t resource_size(const struct resource *res)
74723 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
74724 {
74725 return res->end - res->start + 1;
74726 }
74727 diff --git a/include/linux/irq.h b/include/linux/irq.h
74728 index f04d3ba..bcf2cfb 100644
74729 --- a/include/linux/irq.h
74730 +++ b/include/linux/irq.h
74731 @@ -333,7 +333,8 @@ struct irq_chip {
74732 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
74733
74734 unsigned long flags;
74735 -};
74736 +} __do_const;
74737 +typedef struct irq_chip __no_const irq_chip_no_const;
74738
74739 /*
74740 * irq_chip specific flags
74741 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
74742 index 3e203eb..3fe68d0 100644
74743 --- a/include/linux/irqchip/arm-gic.h
74744 +++ b/include/linux/irqchip/arm-gic.h
74745 @@ -59,9 +59,11 @@
74746
74747 #ifndef __ASSEMBLY__
74748
74749 +#include <linux/irq.h>
74750 +
74751 struct device_node;
74752
74753 -extern struct irq_chip gic_arch_extn;
74754 +extern irq_chip_no_const gic_arch_extn;
74755
74756 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
74757 u32 offset, struct device_node *);
74758 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
74759 index 6883e19..e854fcb 100644
74760 --- a/include/linux/kallsyms.h
74761 +++ b/include/linux/kallsyms.h
74762 @@ -15,7 +15,8 @@
74763
74764 struct module;
74765
74766 -#ifdef CONFIG_KALLSYMS
74767 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
74768 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
74769 /* Lookup the address for a symbol. Returns 0 if not found. */
74770 unsigned long kallsyms_lookup_name(const char *name);
74771
74772 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
74773 /* Stupid that this does nothing, but I didn't create this mess. */
74774 #define __print_symbol(fmt, addr)
74775 #endif /*CONFIG_KALLSYMS*/
74776 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
74777 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
74778 +extern unsigned long kallsyms_lookup_name(const char *name);
74779 +extern void __print_symbol(const char *fmt, unsigned long address);
74780 +extern int sprint_backtrace(char *buffer, unsigned long address);
74781 +extern int sprint_symbol(char *buffer, unsigned long address);
74782 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
74783 +const char *kallsyms_lookup(unsigned long addr,
74784 + unsigned long *symbolsize,
74785 + unsigned long *offset,
74786 + char **modname, char *namebuf);
74787 +extern int kallsyms_lookup_size_offset(unsigned long addr,
74788 + unsigned long *symbolsize,
74789 + unsigned long *offset);
74790 +#endif
74791
74792 /* This macro allows us to keep printk typechecking */
74793 static __printf(1, 2)
74794 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
74795 index 518a53a..5e28358 100644
74796 --- a/include/linux/key-type.h
74797 +++ b/include/linux/key-type.h
74798 @@ -125,7 +125,7 @@ struct key_type {
74799 /* internal fields */
74800 struct list_head link; /* link in types list */
74801 struct lock_class_key lock_class; /* key->sem lock class */
74802 -};
74803 +} __do_const;
74804
74805 extern struct key_type key_type_keyring;
74806
74807 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
74808 index c6e091b..a940adf 100644
74809 --- a/include/linux/kgdb.h
74810 +++ b/include/linux/kgdb.h
74811 @@ -52,7 +52,7 @@ extern int kgdb_connected;
74812 extern int kgdb_io_module_registered;
74813
74814 extern atomic_t kgdb_setting_breakpoint;
74815 -extern atomic_t kgdb_cpu_doing_single_step;
74816 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
74817
74818 extern struct task_struct *kgdb_usethread;
74819 extern struct task_struct *kgdb_contthread;
74820 @@ -254,7 +254,7 @@ struct kgdb_arch {
74821 void (*correct_hw_break)(void);
74822
74823 void (*enable_nmi)(bool on);
74824 -};
74825 +} __do_const;
74826
74827 /**
74828 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
74829 @@ -279,7 +279,7 @@ struct kgdb_io {
74830 void (*pre_exception) (void);
74831 void (*post_exception) (void);
74832 int is_console;
74833 -};
74834 +} __do_const;
74835
74836 extern struct kgdb_arch arch_kgdb_ops;
74837
74838 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
74839 index 0555cc6..b16a7a4 100644
74840 --- a/include/linux/kmod.h
74841 +++ b/include/linux/kmod.h
74842 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
74843 * usually useless though. */
74844 extern __printf(2, 3)
74845 int __request_module(bool wait, const char *name, ...);
74846 +extern __printf(3, 4)
74847 +int ___request_module(bool wait, char *param_name, const char *name, ...);
74848 #define request_module(mod...) __request_module(true, mod)
74849 #define request_module_nowait(mod...) __request_module(false, mod)
74850 #define try_then_request_module(x, mod...) \
74851 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
74852 index 939b112..ed6ed51 100644
74853 --- a/include/linux/kobject.h
74854 +++ b/include/linux/kobject.h
74855 @@ -111,7 +111,7 @@ struct kobj_type {
74856 struct attribute **default_attrs;
74857 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
74858 const void *(*namespace)(struct kobject *kobj);
74859 -};
74860 +} __do_const;
74861
74862 struct kobj_uevent_env {
74863 char *envp[UEVENT_NUM_ENVP];
74864 @@ -134,6 +134,7 @@ struct kobj_attribute {
74865 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
74866 const char *buf, size_t count);
74867 };
74868 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
74869
74870 extern const struct sysfs_ops kobj_sysfs_ops;
74871
74872 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
74873 index f66b065..c2c29b4 100644
74874 --- a/include/linux/kobject_ns.h
74875 +++ b/include/linux/kobject_ns.h
74876 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
74877 const void *(*netlink_ns)(struct sock *sk);
74878 const void *(*initial_ns)(void);
74879 void (*drop_ns)(void *);
74880 -};
74881 +} __do_const;
74882
74883 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
74884 int kobj_ns_type_registered(enum kobj_ns_type type);
74885 diff --git a/include/linux/kref.h b/include/linux/kref.h
74886 index 484604d..0f6c5b6 100644
74887 --- a/include/linux/kref.h
74888 +++ b/include/linux/kref.h
74889 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
74890 static inline int kref_sub(struct kref *kref, unsigned int count,
74891 void (*release)(struct kref *kref))
74892 {
74893 - WARN_ON(release == NULL);
74894 + BUG_ON(release == NULL);
74895
74896 if (atomic_sub_and_test((int) count, &kref->refcount)) {
74897 release(kref);
74898 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
74899 index a63d83e..77fd685 100644
74900 --- a/include/linux/kvm_host.h
74901 +++ b/include/linux/kvm_host.h
74902 @@ -446,7 +446,7 @@ static inline void kvm_irqfd_exit(void)
74903 {
74904 }
74905 #endif
74906 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74907 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74908 struct module *module);
74909 void kvm_exit(void);
74910
74911 @@ -618,7 +618,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
74912 struct kvm_guest_debug *dbg);
74913 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
74914
74915 -int kvm_arch_init(void *opaque);
74916 +int kvm_arch_init(const void *opaque);
74917 void kvm_arch_exit(void);
74918
74919 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
74920 diff --git a/include/linux/libata.h b/include/linux/libata.h
74921 index 4ea55bb..dcd2601 100644
74922 --- a/include/linux/libata.h
74923 +++ b/include/linux/libata.h
74924 @@ -924,7 +924,7 @@ struct ata_port_operations {
74925 * fields must be pointers.
74926 */
74927 const struct ata_port_operations *inherits;
74928 -};
74929 +} __do_const;
74930
74931 struct ata_port_info {
74932 unsigned long flags;
74933 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
74934 index d3e8ad2..a949f68 100644
74935 --- a/include/linux/linkage.h
74936 +++ b/include/linux/linkage.h
74937 @@ -31,6 +31,7 @@
74938 #endif
74939
74940 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
74941 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
74942 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
74943
74944 /*
74945 diff --git a/include/linux/list.h b/include/linux/list.h
74946 index f4d8a2f..38e6e46 100644
74947 --- a/include/linux/list.h
74948 +++ b/include/linux/list.h
74949 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
74950 extern void list_del(struct list_head *entry);
74951 #endif
74952
74953 +extern void __pax_list_add(struct list_head *new,
74954 + struct list_head *prev,
74955 + struct list_head *next);
74956 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
74957 +{
74958 + __pax_list_add(new, head, head->next);
74959 +}
74960 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
74961 +{
74962 + __pax_list_add(new, head->prev, head);
74963 +}
74964 +extern void pax_list_del(struct list_head *entry);
74965 +
74966 /**
74967 * list_replace - replace old entry by new one
74968 * @old : the element to be replaced
74969 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
74970 INIT_LIST_HEAD(entry);
74971 }
74972
74973 +extern void pax_list_del_init(struct list_head *entry);
74974 +
74975 /**
74976 * list_move - delete from one list and add as another's head
74977 * @list: the entry to move
74978 diff --git a/include/linux/math64.h b/include/linux/math64.h
74979 index 2913b86..8dcbb1e 100644
74980 --- a/include/linux/math64.h
74981 +++ b/include/linux/math64.h
74982 @@ -15,7 +15,7 @@
74983 * This is commonly provided by 32bit archs to provide an optimized 64bit
74984 * divide.
74985 */
74986 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74987 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74988 {
74989 *remainder = dividend % divisor;
74990 return dividend / divisor;
74991 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
74992 /**
74993 * div64_u64 - unsigned 64bit divide with 64bit divisor
74994 */
74995 -static inline u64 div64_u64(u64 dividend, u64 divisor)
74996 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
74997 {
74998 return dividend / divisor;
74999 }
75000 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
75001 #define div64_ul(x, y) div_u64((x), (y))
75002
75003 #ifndef div_u64_rem
75004 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75005 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75006 {
75007 *remainder = do_div(dividend, divisor);
75008 return dividend;
75009 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
75010 * divide.
75011 */
75012 #ifndef div_u64
75013 -static inline u64 div_u64(u64 dividend, u32 divisor)
75014 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
75015 {
75016 u32 remainder;
75017 return div_u64_rem(dividend, divisor, &remainder);
75018 diff --git a/include/linux/mm.h b/include/linux/mm.h
75019 index f022460..6ecf4f9 100644
75020 --- a/include/linux/mm.h
75021 +++ b/include/linux/mm.h
75022 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
75023 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
75024 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
75025 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
75026 +
75027 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
75028 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
75029 +#endif
75030 +
75031 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
75032
75033 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
75034 @@ -208,8 +213,8 @@ struct vm_operations_struct {
75035 /* called by access_process_vm when get_user_pages() fails, typically
75036 * for use by special VMAs that can switch between memory and hardware
75037 */
75038 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
75039 - void *buf, int len, int write);
75040 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
75041 + void *buf, size_t len, int write);
75042 #ifdef CONFIG_NUMA
75043 /*
75044 * set_policy() op must add a reference to any non-NULL @new mempolicy
75045 @@ -239,6 +244,7 @@ struct vm_operations_struct {
75046 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
75047 unsigned long size, pgoff_t pgoff);
75048 };
75049 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
75050
75051 struct mmu_gather;
75052 struct inode;
75053 @@ -983,8 +989,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
75054 unsigned long *pfn);
75055 int follow_phys(struct vm_area_struct *vma, unsigned long address,
75056 unsigned int flags, unsigned long *prot, resource_size_t *phys);
75057 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75058 - void *buf, int len, int write);
75059 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75060 + void *buf, size_t len, int write);
75061
75062 static inline void unmap_shared_mapping_range(struct address_space *mapping,
75063 loff_t const holebegin, loff_t const holelen)
75064 @@ -1023,9 +1029,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
75065 }
75066 #endif
75067
75068 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
75069 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
75070 - void *buf, int len, int write);
75071 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
75072 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
75073 + void *buf, size_t len, int write);
75074
75075 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
75076 unsigned long start, unsigned long nr_pages,
75077 @@ -1057,34 +1063,6 @@ int set_page_dirty(struct page *page);
75078 int set_page_dirty_lock(struct page *page);
75079 int clear_page_dirty_for_io(struct page *page);
75080
75081 -/* Is the vma a continuation of the stack vma above it? */
75082 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
75083 -{
75084 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
75085 -}
75086 -
75087 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
75088 - unsigned long addr)
75089 -{
75090 - return (vma->vm_flags & VM_GROWSDOWN) &&
75091 - (vma->vm_start == addr) &&
75092 - !vma_growsdown(vma->vm_prev, addr);
75093 -}
75094 -
75095 -/* Is the vma a continuation of the stack vma below it? */
75096 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
75097 -{
75098 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
75099 -}
75100 -
75101 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
75102 - unsigned long addr)
75103 -{
75104 - return (vma->vm_flags & VM_GROWSUP) &&
75105 - (vma->vm_end == addr) &&
75106 - !vma_growsup(vma->vm_next, addr);
75107 -}
75108 -
75109 extern pid_t
75110 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
75111
75112 @@ -1184,6 +1162,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
75113 }
75114 #endif
75115
75116 +#ifdef CONFIG_MMU
75117 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
75118 +#else
75119 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
75120 +{
75121 + return __pgprot(0);
75122 +}
75123 +#endif
75124 +
75125 int vma_wants_writenotify(struct vm_area_struct *vma);
75126
75127 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
75128 @@ -1202,8 +1189,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
75129 {
75130 return 0;
75131 }
75132 +
75133 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
75134 + unsigned long address)
75135 +{
75136 + return 0;
75137 +}
75138 #else
75139 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75140 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75141 #endif
75142
75143 #ifdef __PAGETABLE_PMD_FOLDED
75144 @@ -1212,8 +1206,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
75145 {
75146 return 0;
75147 }
75148 +
75149 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
75150 + unsigned long address)
75151 +{
75152 + return 0;
75153 +}
75154 #else
75155 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
75156 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
75157 #endif
75158
75159 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
75160 @@ -1231,11 +1232,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
75161 NULL: pud_offset(pgd, address);
75162 }
75163
75164 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
75165 +{
75166 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
75167 + NULL: pud_offset(pgd, address);
75168 +}
75169 +
75170 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
75171 {
75172 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
75173 NULL: pmd_offset(pud, address);
75174 }
75175 +
75176 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
75177 +{
75178 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
75179 + NULL: pmd_offset(pud, address);
75180 +}
75181 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
75182
75183 #if USE_SPLIT_PTLOCKS
75184 @@ -1531,6 +1544,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
75185 unsigned long len, unsigned long prot, unsigned long flags,
75186 unsigned long pgoff, unsigned long *populate);
75187 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
75188 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
75189
75190 #ifdef CONFIG_MMU
75191 extern int __mm_populate(unsigned long addr, unsigned long len,
75192 @@ -1559,10 +1573,11 @@ struct vm_unmapped_area_info {
75193 unsigned long high_limit;
75194 unsigned long align_mask;
75195 unsigned long align_offset;
75196 + unsigned long threadstack_offset;
75197 };
75198
75199 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
75200 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75201 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
75202 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
75203
75204 /*
75205 * Search for an unmapped address range.
75206 @@ -1574,7 +1589,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75207 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
75208 */
75209 static inline unsigned long
75210 -vm_unmapped_area(struct vm_unmapped_area_info *info)
75211 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
75212 {
75213 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
75214 return unmapped_area(info);
75215 @@ -1637,6 +1652,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
75216 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
75217 struct vm_area_struct **pprev);
75218
75219 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
75220 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
75221 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
75222 +
75223 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
75224 NULL if none. Assume start_addr < end_addr. */
75225 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
75226 @@ -1665,15 +1684,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
75227 return vma;
75228 }
75229
75230 -#ifdef CONFIG_MMU
75231 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
75232 -#else
75233 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
75234 -{
75235 - return __pgprot(0);
75236 -}
75237 -#endif
75238 -
75239 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
75240 unsigned long change_prot_numa(struct vm_area_struct *vma,
75241 unsigned long start, unsigned long end);
75242 @@ -1725,6 +1735,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
75243 static inline void vm_stat_account(struct mm_struct *mm,
75244 unsigned long flags, struct file *file, long pages)
75245 {
75246 +
75247 +#ifdef CONFIG_PAX_RANDMMAP
75248 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
75249 +#endif
75250 +
75251 mm->total_vm += pages;
75252 }
75253 #endif /* CONFIG_PROC_FS */
75254 @@ -1805,7 +1820,7 @@ extern int unpoison_memory(unsigned long pfn);
75255 extern int sysctl_memory_failure_early_kill;
75256 extern int sysctl_memory_failure_recovery;
75257 extern void shake_page(struct page *p, int access);
75258 -extern atomic_long_t num_poisoned_pages;
75259 +extern atomic_long_unchecked_t num_poisoned_pages;
75260 extern int soft_offline_page(struct page *page, int flags);
75261
75262 extern void dump_page(struct page *page);
75263 @@ -1842,5 +1857,11 @@ void __init setup_nr_node_ids(void);
75264 static inline void setup_nr_node_ids(void) {}
75265 #endif
75266
75267 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
75268 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
75269 +#else
75270 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
75271 +#endif
75272 +
75273 #endif /* __KERNEL__ */
75274 #endif /* _LINUX_MM_H */
75275 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
75276 index faf4b7c..1e70c6e 100644
75277 --- a/include/linux/mm_types.h
75278 +++ b/include/linux/mm_types.h
75279 @@ -289,6 +289,8 @@ struct vm_area_struct {
75280 #ifdef CONFIG_NUMA
75281 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
75282 #endif
75283 +
75284 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
75285 };
75286
75287 struct core_thread {
75288 @@ -435,6 +437,24 @@ struct mm_struct {
75289 int first_nid;
75290 #endif
75291 struct uprobes_state uprobes_state;
75292 +
75293 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75294 + unsigned long pax_flags;
75295 +#endif
75296 +
75297 +#ifdef CONFIG_PAX_DLRESOLVE
75298 + unsigned long call_dl_resolve;
75299 +#endif
75300 +
75301 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
75302 + unsigned long call_syscall;
75303 +#endif
75304 +
75305 +#ifdef CONFIG_PAX_ASLR
75306 + unsigned long delta_mmap; /* randomized offset */
75307 + unsigned long delta_stack; /* randomized offset */
75308 +#endif
75309 +
75310 };
75311
75312 /* first nid will either be a valid NID or one of these values */
75313 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
75314 index c5d5278..f0b68c8 100644
75315 --- a/include/linux/mmiotrace.h
75316 +++ b/include/linux/mmiotrace.h
75317 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
75318 /* Called from ioremap.c */
75319 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
75320 void __iomem *addr);
75321 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
75322 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
75323
75324 /* For anyone to insert markers. Remember trailing newline. */
75325 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
75326 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
75327 {
75328 }
75329
75330 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
75331 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
75332 {
75333 }
75334
75335 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
75336 index af4a3b7..9ad8889 100644
75337 --- a/include/linux/mmzone.h
75338 +++ b/include/linux/mmzone.h
75339 @@ -396,7 +396,7 @@ struct zone {
75340 unsigned long flags; /* zone flags, see below */
75341
75342 /* Zone statistics */
75343 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75344 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75345
75346 /*
75347 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
75348 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
75349 index 45e9214..a7227d6 100644
75350 --- a/include/linux/mod_devicetable.h
75351 +++ b/include/linux/mod_devicetable.h
75352 @@ -13,7 +13,7 @@
75353 typedef unsigned long kernel_ulong_t;
75354 #endif
75355
75356 -#define PCI_ANY_ID (~0)
75357 +#define PCI_ANY_ID ((__u16)~0)
75358
75359 struct pci_device_id {
75360 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
75361 @@ -139,7 +139,7 @@ struct usb_device_id {
75362 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
75363 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
75364
75365 -#define HID_ANY_ID (~0)
75366 +#define HID_ANY_ID (~0U)
75367 #define HID_BUS_ANY 0xffff
75368 #define HID_GROUP_ANY 0x0000
75369
75370 @@ -467,7 +467,7 @@ struct dmi_system_id {
75371 const char *ident;
75372 struct dmi_strmatch matches[4];
75373 void *driver_data;
75374 -};
75375 +} __do_const;
75376 /*
75377 * struct dmi_device_id appears during expansion of
75378 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
75379 diff --git a/include/linux/module.h b/include/linux/module.h
75380 index 46f1ea0..a34ca37 100644
75381 --- a/include/linux/module.h
75382 +++ b/include/linux/module.h
75383 @@ -17,9 +17,11 @@
75384 #include <linux/moduleparam.h>
75385 #include <linux/tracepoint.h>
75386 #include <linux/export.h>
75387 +#include <linux/fs.h>
75388
75389 #include <linux/percpu.h>
75390 #include <asm/module.h>
75391 +#include <asm/pgtable.h>
75392
75393 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
75394 #define MODULE_SIG_STRING "~Module signature appended~\n"
75395 @@ -54,12 +56,13 @@ struct module_attribute {
75396 int (*test)(struct module *);
75397 void (*free)(struct module *);
75398 };
75399 +typedef struct module_attribute __no_const module_attribute_no_const;
75400
75401 struct module_version_attribute {
75402 struct module_attribute mattr;
75403 const char *module_name;
75404 const char *version;
75405 -} __attribute__ ((__aligned__(sizeof(void *))));
75406 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
75407
75408 extern ssize_t __modver_version_show(struct module_attribute *,
75409 struct module_kobject *, char *);
75410 @@ -232,7 +235,7 @@ struct module
75411
75412 /* Sysfs stuff. */
75413 struct module_kobject mkobj;
75414 - struct module_attribute *modinfo_attrs;
75415 + module_attribute_no_const *modinfo_attrs;
75416 const char *version;
75417 const char *srcversion;
75418 struct kobject *holders_dir;
75419 @@ -281,19 +284,16 @@ struct module
75420 int (*init)(void);
75421
75422 /* If this is non-NULL, vfree after init() returns */
75423 - void *module_init;
75424 + void *module_init_rx, *module_init_rw;
75425
75426 /* Here is the actual code + data, vfree'd on unload. */
75427 - void *module_core;
75428 + void *module_core_rx, *module_core_rw;
75429
75430 /* Here are the sizes of the init and core sections */
75431 - unsigned int init_size, core_size;
75432 + unsigned int init_size_rw, core_size_rw;
75433
75434 /* The size of the executable code in each section. */
75435 - unsigned int init_text_size, core_text_size;
75436 -
75437 - /* Size of RO sections of the module (text+rodata) */
75438 - unsigned int init_ro_size, core_ro_size;
75439 + unsigned int init_size_rx, core_size_rx;
75440
75441 /* Arch-specific module values */
75442 struct mod_arch_specific arch;
75443 @@ -349,6 +349,10 @@ struct module
75444 #ifdef CONFIG_EVENT_TRACING
75445 struct ftrace_event_call **trace_events;
75446 unsigned int num_trace_events;
75447 + struct file_operations trace_id;
75448 + struct file_operations trace_enable;
75449 + struct file_operations trace_format;
75450 + struct file_operations trace_filter;
75451 #endif
75452 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
75453 unsigned int num_ftrace_callsites;
75454 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
75455 bool is_module_percpu_address(unsigned long addr);
75456 bool is_module_text_address(unsigned long addr);
75457
75458 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
75459 +{
75460 +
75461 +#ifdef CONFIG_PAX_KERNEXEC
75462 + if (ktla_ktva(addr) >= (unsigned long)start &&
75463 + ktla_ktva(addr) < (unsigned long)start + size)
75464 + return 1;
75465 +#endif
75466 +
75467 + return ((void *)addr >= start && (void *)addr < start + size);
75468 +}
75469 +
75470 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
75471 +{
75472 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
75473 +}
75474 +
75475 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
75476 +{
75477 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
75478 +}
75479 +
75480 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
75481 +{
75482 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
75483 +}
75484 +
75485 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
75486 +{
75487 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
75488 +}
75489 +
75490 static inline int within_module_core(unsigned long addr, const struct module *mod)
75491 {
75492 - return (unsigned long)mod->module_core <= addr &&
75493 - addr < (unsigned long)mod->module_core + mod->core_size;
75494 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
75495 }
75496
75497 static inline int within_module_init(unsigned long addr, const struct module *mod)
75498 {
75499 - return (unsigned long)mod->module_init <= addr &&
75500 - addr < (unsigned long)mod->module_init + mod->init_size;
75501 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
75502 }
75503
75504 /* Search for module by name: must hold module_mutex. */
75505 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
75506 index 560ca53..ef621ef 100644
75507 --- a/include/linux/moduleloader.h
75508 +++ b/include/linux/moduleloader.h
75509 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
75510 sections. Returns NULL on failure. */
75511 void *module_alloc(unsigned long size);
75512
75513 +#ifdef CONFIG_PAX_KERNEXEC
75514 +void *module_alloc_exec(unsigned long size);
75515 +#else
75516 +#define module_alloc_exec(x) module_alloc(x)
75517 +#endif
75518 +
75519 /* Free memory returned from module_alloc. */
75520 void module_free(struct module *mod, void *module_region);
75521
75522 +#ifdef CONFIG_PAX_KERNEXEC
75523 +void module_free_exec(struct module *mod, void *module_region);
75524 +#else
75525 +#define module_free_exec(x, y) module_free((x), (y))
75526 +#endif
75527 +
75528 /*
75529 * Apply the given relocation to the (simplified) ELF. Return -error
75530 * or 0.
75531 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
75532 unsigned int relsec,
75533 struct module *me)
75534 {
75535 +#ifdef CONFIG_MODULES
75536 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75537 +#endif
75538 return -ENOEXEC;
75539 }
75540 #endif
75541 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
75542 unsigned int relsec,
75543 struct module *me)
75544 {
75545 +#ifdef CONFIG_MODULES
75546 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75547 +#endif
75548 return -ENOEXEC;
75549 }
75550 #endif
75551 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
75552 index 27d9da3..5d94aa3 100644
75553 --- a/include/linux/moduleparam.h
75554 +++ b/include/linux/moduleparam.h
75555 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
75556 * @len is usually just sizeof(string).
75557 */
75558 #define module_param_string(name, string, len, perm) \
75559 - static const struct kparam_string __param_string_##name \
75560 + static const struct kparam_string __param_string_##name __used \
75561 = { len, string }; \
75562 __module_param_call(MODULE_PARAM_PREFIX, name, \
75563 &param_ops_string, \
75564 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
75565 */
75566 #define module_param_array_named(name, array, type, nump, perm) \
75567 param_check_##type(name, &(array)[0]); \
75568 - static const struct kparam_array __param_arr_##name \
75569 + static const struct kparam_array __param_arr_##name __used \
75570 = { .max = ARRAY_SIZE(array), .num = nump, \
75571 .ops = &param_ops_##type, \
75572 .elemsize = sizeof(array[0]), .elem = array }; \
75573 diff --git a/include/linux/namei.h b/include/linux/namei.h
75574 index 5a5ff57..5ae5070 100644
75575 --- a/include/linux/namei.h
75576 +++ b/include/linux/namei.h
75577 @@ -19,7 +19,7 @@ struct nameidata {
75578 unsigned seq;
75579 int last_type;
75580 unsigned depth;
75581 - char *saved_names[MAX_NESTED_LINKS + 1];
75582 + const char *saved_names[MAX_NESTED_LINKS + 1];
75583 };
75584
75585 /*
75586 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
75587
75588 extern void nd_jump_link(struct nameidata *nd, struct path *path);
75589
75590 -static inline void nd_set_link(struct nameidata *nd, char *path)
75591 +static inline void nd_set_link(struct nameidata *nd, const char *path)
75592 {
75593 nd->saved_names[nd->depth] = path;
75594 }
75595
75596 -static inline char *nd_get_link(struct nameidata *nd)
75597 +static inline const char *nd_get_link(const struct nameidata *nd)
75598 {
75599 return nd->saved_names[nd->depth];
75600 }
75601 diff --git a/include/linux/net.h b/include/linux/net.h
75602 index 4f27575..fc8a65f 100644
75603 --- a/include/linux/net.h
75604 +++ b/include/linux/net.h
75605 @@ -183,7 +183,7 @@ struct net_proto_family {
75606 int (*create)(struct net *net, struct socket *sock,
75607 int protocol, int kern);
75608 struct module *owner;
75609 -};
75610 +} __do_const;
75611
75612 struct iovec;
75613 struct kvec;
75614 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
75615 index 9a41568..203d903 100644
75616 --- a/include/linux/netdevice.h
75617 +++ b/include/linux/netdevice.h
75618 @@ -1061,6 +1061,7 @@ struct net_device_ops {
75619 int (*ndo_change_carrier)(struct net_device *dev,
75620 bool new_carrier);
75621 };
75622 +typedef struct net_device_ops __no_const net_device_ops_no_const;
75623
75624 /*
75625 * The DEVICE structure.
75626 @@ -1131,7 +1132,7 @@ struct net_device {
75627 int iflink;
75628
75629 struct net_device_stats stats;
75630 - atomic_long_t rx_dropped; /* dropped packets by core network
75631 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
75632 * Do not use this in drivers.
75633 */
75634
75635 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
75636 index de70f7b..2675e91 100644
75637 --- a/include/linux/netfilter.h
75638 +++ b/include/linux/netfilter.h
75639 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
75640 #endif
75641 /* Use the module struct to lock set/get code in place */
75642 struct module *owner;
75643 -};
75644 +} __do_const;
75645
75646 /* Function to register/unregister hook points. */
75647 int nf_register_hook(struct nf_hook_ops *reg);
75648 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
75649 index d80e275..c3510b8 100644
75650 --- a/include/linux/netfilter/ipset/ip_set.h
75651 +++ b/include/linux/netfilter/ipset/ip_set.h
75652 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
75653 /* Return true if "b" set is the same as "a"
75654 * according to the create set parameters */
75655 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
75656 -};
75657 +} __do_const;
75658
75659 /* The core set type structure */
75660 struct ip_set_type {
75661 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
75662 index cadb740..d7c37c0 100644
75663 --- a/include/linux/netfilter/nfnetlink.h
75664 +++ b/include/linux/netfilter/nfnetlink.h
75665 @@ -16,7 +16,7 @@ struct nfnl_callback {
75666 const struct nlattr * const cda[]);
75667 const struct nla_policy *policy; /* netlink attribute policy */
75668 const u_int16_t attr_count; /* number of nlattr's */
75669 -};
75670 +} __do_const;
75671
75672 struct nfnetlink_subsystem {
75673 const char *name;
75674 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
75675 new file mode 100644
75676 index 0000000..33f4af8
75677 --- /dev/null
75678 +++ b/include/linux/netfilter/xt_gradm.h
75679 @@ -0,0 +1,9 @@
75680 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
75681 +#define _LINUX_NETFILTER_XT_GRADM_H 1
75682 +
75683 +struct xt_gradm_mtinfo {
75684 + __u16 flags;
75685 + __u16 invflags;
75686 +};
75687 +
75688 +#endif
75689 diff --git a/include/linux/nls.h b/include/linux/nls.h
75690 index 5dc635f..35f5e11 100644
75691 --- a/include/linux/nls.h
75692 +++ b/include/linux/nls.h
75693 @@ -31,7 +31,7 @@ struct nls_table {
75694 const unsigned char *charset2upper;
75695 struct module *owner;
75696 struct nls_table *next;
75697 -};
75698 +} __do_const;
75699
75700 /* this value hold the maximum octet of charset */
75701 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
75702 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
75703 index d14a4c3..a078786 100644
75704 --- a/include/linux/notifier.h
75705 +++ b/include/linux/notifier.h
75706 @@ -54,7 +54,8 @@ struct notifier_block {
75707 notifier_fn_t notifier_call;
75708 struct notifier_block __rcu *next;
75709 int priority;
75710 -};
75711 +} __do_const;
75712 +typedef struct notifier_block __no_const notifier_block_no_const;
75713
75714 struct atomic_notifier_head {
75715 spinlock_t lock;
75716 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
75717 index a4c5624..79d6d88 100644
75718 --- a/include/linux/oprofile.h
75719 +++ b/include/linux/oprofile.h
75720 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
75721 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
75722 char const * name, ulong * val);
75723
75724 -/** Create a file for read-only access to an atomic_t. */
75725 +/** Create a file for read-only access to an atomic_unchecked_t. */
75726 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
75727 - char const * name, atomic_t * val);
75728 + char const * name, atomic_unchecked_t * val);
75729
75730 /** create a directory */
75731 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
75732 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
75733 index 8db71dc..a76bf2c 100644
75734 --- a/include/linux/pci_hotplug.h
75735 +++ b/include/linux/pci_hotplug.h
75736 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
75737 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
75738 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
75739 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
75740 -};
75741 +} __do_const;
75742 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
75743
75744 /**
75745 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
75746 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
75747 index c43f6ea..2d4416f 100644
75748 --- a/include/linux/perf_event.h
75749 +++ b/include/linux/perf_event.h
75750 @@ -328,8 +328,8 @@ struct perf_event {
75751
75752 enum perf_event_active_state state;
75753 unsigned int attach_state;
75754 - local64_t count;
75755 - atomic64_t child_count;
75756 + local64_t count; /* PaX: fix it one day */
75757 + atomic64_unchecked_t child_count;
75758
75759 /*
75760 * These are the total time in nanoseconds that the event
75761 @@ -380,8 +380,8 @@ struct perf_event {
75762 * These accumulate total time (in nanoseconds) that children
75763 * events have been enabled and running, respectively.
75764 */
75765 - atomic64_t child_total_time_enabled;
75766 - atomic64_t child_total_time_running;
75767 + atomic64_unchecked_t child_total_time_enabled;
75768 + atomic64_unchecked_t child_total_time_running;
75769
75770 /*
75771 * Protect attach/detach and child_list:
75772 @@ -703,7 +703,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
75773 entry->ip[entry->nr++] = ip;
75774 }
75775
75776 -extern int sysctl_perf_event_paranoid;
75777 +extern int sysctl_perf_event_legitimately_concerned;
75778 extern int sysctl_perf_event_mlock;
75779 extern int sysctl_perf_event_sample_rate;
75780 extern int sysctl_perf_cpu_time_max_percent;
75781 @@ -718,19 +718,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
75782 loff_t *ppos);
75783
75784
75785 +static inline bool perf_paranoid_any(void)
75786 +{
75787 + return sysctl_perf_event_legitimately_concerned > 2;
75788 +}
75789 +
75790 static inline bool perf_paranoid_tracepoint_raw(void)
75791 {
75792 - return sysctl_perf_event_paranoid > -1;
75793 + return sysctl_perf_event_legitimately_concerned > -1;
75794 }
75795
75796 static inline bool perf_paranoid_cpu(void)
75797 {
75798 - return sysctl_perf_event_paranoid > 0;
75799 + return sysctl_perf_event_legitimately_concerned > 0;
75800 }
75801
75802 static inline bool perf_paranoid_kernel(void)
75803 {
75804 - return sysctl_perf_event_paranoid > 1;
75805 + return sysctl_perf_event_legitimately_concerned > 1;
75806 }
75807
75808 extern void perf_event_init(void);
75809 @@ -846,7 +851,7 @@ struct perf_pmu_events_attr {
75810 struct device_attribute attr;
75811 u64 id;
75812 const char *event_str;
75813 -};
75814 +} __do_const;
75815
75816 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
75817 static struct perf_pmu_events_attr _var = { \
75818 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
75819 index b8809fe..ae4ccd0 100644
75820 --- a/include/linux/pipe_fs_i.h
75821 +++ b/include/linux/pipe_fs_i.h
75822 @@ -47,10 +47,10 @@ struct pipe_inode_info {
75823 struct mutex mutex;
75824 wait_queue_head_t wait;
75825 unsigned int nrbufs, curbuf, buffers;
75826 - unsigned int readers;
75827 - unsigned int writers;
75828 - unsigned int files;
75829 - unsigned int waiting_writers;
75830 + atomic_t readers;
75831 + atomic_t writers;
75832 + atomic_t files;
75833 + atomic_t waiting_writers;
75834 unsigned int r_counter;
75835 unsigned int w_counter;
75836 struct page *tmp_page;
75837 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
75838 index 5f28cae..3d23723 100644
75839 --- a/include/linux/platform_data/usb-ehci-s5p.h
75840 +++ b/include/linux/platform_data/usb-ehci-s5p.h
75841 @@ -14,7 +14,7 @@
75842 struct s5p_ehci_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 s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
75849
75850 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
75851 index c256c59..8ea94c7 100644
75852 --- a/include/linux/platform_data/usb-ohci-exynos.h
75853 +++ b/include/linux/platform_data/usb-ohci-exynos.h
75854 @@ -14,7 +14,7 @@
75855 struct exynos4_ohci_platdata {
75856 int (*phy_init)(struct platform_device *pdev, int type);
75857 int (*phy_exit)(struct platform_device *pdev, int type);
75858 -};
75859 +} __no_const;
75860
75861 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
75862
75863 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
75864 index 7c1d252..c5c773e 100644
75865 --- a/include/linux/pm_domain.h
75866 +++ b/include/linux/pm_domain.h
75867 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
75868
75869 struct gpd_cpu_data {
75870 unsigned int saved_exit_latency;
75871 - struct cpuidle_state *idle_state;
75872 + cpuidle_state_no_const *idle_state;
75873 };
75874
75875 struct generic_pm_domain {
75876 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
75877 index 6fa7cea..7bf6415 100644
75878 --- a/include/linux/pm_runtime.h
75879 +++ b/include/linux/pm_runtime.h
75880 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
75881
75882 static inline void pm_runtime_mark_last_busy(struct device *dev)
75883 {
75884 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
75885 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
75886 }
75887
75888 #else /* !CONFIG_PM_RUNTIME */
75889 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
75890 index 195aafc..49a7bc2 100644
75891 --- a/include/linux/pnp.h
75892 +++ b/include/linux/pnp.h
75893 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
75894 struct pnp_fixup {
75895 char id[7];
75896 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
75897 -};
75898 +} __do_const;
75899
75900 /* config parameters */
75901 #define PNP_CONFIG_NORMAL 0x0001
75902 diff --git a/include/linux/poison.h b/include/linux/poison.h
75903 index 2110a81..13a11bb 100644
75904 --- a/include/linux/poison.h
75905 +++ b/include/linux/poison.h
75906 @@ -19,8 +19,8 @@
75907 * under normal circumstances, used to verify that nobody uses
75908 * non-initialized list entries.
75909 */
75910 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
75911 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
75912 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
75913 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
75914
75915 /********** include/linux/timer.h **********/
75916 /*
75917 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
75918 index d8b187c3..9a9257a 100644
75919 --- a/include/linux/power/smartreflex.h
75920 +++ b/include/linux/power/smartreflex.h
75921 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
75922 int (*notify)(struct omap_sr *sr, u32 status);
75923 u8 notify_flags;
75924 u8 class_type;
75925 -};
75926 +} __do_const;
75927
75928 /**
75929 * struct omap_sr_nvalue_table - Smartreflex n-target value info
75930 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
75931 index 4ea1d37..80f4b33 100644
75932 --- a/include/linux/ppp-comp.h
75933 +++ b/include/linux/ppp-comp.h
75934 @@ -84,7 +84,7 @@ struct compressor {
75935 struct module *owner;
75936 /* Extra skb space needed by the compressor algorithm */
75937 unsigned int comp_extra;
75938 -};
75939 +} __do_const;
75940
75941 /*
75942 * The return value from decompress routine is the length of the
75943 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
75944 index f5d4723..a6ea2fa 100644
75945 --- a/include/linux/preempt.h
75946 +++ b/include/linux/preempt.h
75947 @@ -18,8 +18,13 @@
75948 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75949 #endif
75950
75951 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
75952 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75953 +
75954 #define inc_preempt_count() add_preempt_count(1)
75955 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
75956 #define dec_preempt_count() sub_preempt_count(1)
75957 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
75958
75959 #define preempt_count() (current_thread_info()->preempt_count)
75960
75961 @@ -64,6 +69,12 @@ do { \
75962 barrier(); \
75963 } while (0)
75964
75965 +#define raw_preempt_disable() \
75966 +do { \
75967 + raw_inc_preempt_count(); \
75968 + barrier(); \
75969 +} while (0)
75970 +
75971 #define sched_preempt_enable_no_resched() \
75972 do { \
75973 barrier(); \
75974 @@ -72,6 +83,12 @@ do { \
75975
75976 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
75977
75978 +#define raw_preempt_enable_no_resched() \
75979 +do { \
75980 + barrier(); \
75981 + raw_dec_preempt_count(); \
75982 +} while (0)
75983 +
75984 #define preempt_enable() \
75985 do { \
75986 preempt_enable_no_resched(); \
75987 @@ -116,8 +133,10 @@ do { \
75988 * region.
75989 */
75990 #define preempt_disable() barrier()
75991 +#define raw_preempt_disable() barrier()
75992 #define sched_preempt_enable_no_resched() barrier()
75993 #define preempt_enable_no_resched() barrier()
75994 +#define raw_preempt_enable_no_resched() barrier()
75995 #define preempt_enable() barrier()
75996
75997 #define preempt_disable_notrace() barrier()
75998 diff --git a/include/linux/printk.h b/include/linux/printk.h
75999 index 22c7052..ad3fa0a 100644
76000 --- a/include/linux/printk.h
76001 +++ b/include/linux/printk.h
76002 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
76003 void early_printk(const char *s, ...) { }
76004 #endif
76005
76006 +extern int kptr_restrict;
76007 +
76008 #ifdef CONFIG_PRINTK
76009 asmlinkage __printf(5, 0)
76010 int vprintk_emit(int facility, int level,
76011 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
76012
76013 extern int printk_delay_msec;
76014 extern int dmesg_restrict;
76015 -extern int kptr_restrict;
76016
76017 extern void wake_up_klogd(void);
76018
76019 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
76020 index 608e60a..c26f864 100644
76021 --- a/include/linux/proc_fs.h
76022 +++ b/include/linux/proc_fs.h
76023 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
76024 return proc_create_data(name, mode, parent, proc_fops, NULL);
76025 }
76026
76027 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
76028 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
76029 +{
76030 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76031 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
76032 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76033 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
76034 +#else
76035 + return proc_create_data(name, mode, parent, proc_fops, NULL);
76036 +#endif
76037 +}
76038 +
76039 +
76040 extern void proc_set_size(struct proc_dir_entry *, loff_t);
76041 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
76042 extern void *PDE_DATA(const struct inode *);
76043 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
76044 index 34a1e10..03a6d03 100644
76045 --- a/include/linux/proc_ns.h
76046 +++ b/include/linux/proc_ns.h
76047 @@ -14,7 +14,7 @@ struct proc_ns_operations {
76048 void (*put)(void *ns);
76049 int (*install)(struct nsproxy *nsproxy, void *ns);
76050 unsigned int (*inum)(void *ns);
76051 -};
76052 +} __do_const;
76053
76054 struct proc_ns {
76055 void *ns;
76056 diff --git a/include/linux/random.h b/include/linux/random.h
76057 index 6312dd9..2561947 100644
76058 --- a/include/linux/random.h
76059 +++ b/include/linux/random.h
76060 @@ -10,9 +10,19 @@
76061
76062
76063 extern void add_device_randomness(const void *, unsigned int);
76064 +
76065 +static inline void add_latent_entropy(void)
76066 +{
76067 +
76068 +#ifdef LATENT_ENTROPY_PLUGIN
76069 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
76070 +#endif
76071 +
76072 +}
76073 +
76074 extern void add_input_randomness(unsigned int type, unsigned int code,
76075 - unsigned int value);
76076 -extern void add_interrupt_randomness(int irq, int irq_flags);
76077 + unsigned int value) __latent_entropy;
76078 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
76079
76080 extern void get_random_bytes(void *buf, int nbytes);
76081 extern void get_random_bytes_arch(void *buf, int nbytes);
76082 @@ -33,6 +43,11 @@ void prandom_seed(u32 seed);
76083 u32 prandom_u32_state(struct rnd_state *);
76084 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
76085
76086 +static inline unsigned long pax_get_random_long(void)
76087 +{
76088 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
76089 +}
76090 +
76091 /*
76092 * Handle minimum values for seeds
76093 */
76094 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
76095 index 4106721..132d42c 100644
76096 --- a/include/linux/rculist.h
76097 +++ b/include/linux/rculist.h
76098 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
76099 struct list_head *prev, struct list_head *next);
76100 #endif
76101
76102 +extern void __pax_list_add_rcu(struct list_head *new,
76103 + struct list_head *prev, struct list_head *next);
76104 +
76105 /**
76106 * list_add_rcu - add a new entry to rcu-protected list
76107 * @new: new entry to be added
76108 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
76109 __list_add_rcu(new, head, head->next);
76110 }
76111
76112 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
76113 +{
76114 + __pax_list_add_rcu(new, head, head->next);
76115 +}
76116 +
76117 /**
76118 * list_add_tail_rcu - add a new entry to rcu-protected list
76119 * @new: new entry to be added
76120 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
76121 __list_add_rcu(new, head->prev, head);
76122 }
76123
76124 +static inline void pax_list_add_tail_rcu(struct list_head *new,
76125 + struct list_head *head)
76126 +{
76127 + __pax_list_add_rcu(new, head->prev, head);
76128 +}
76129 +
76130 /**
76131 * list_del_rcu - deletes entry from list without re-initialization
76132 * @entry: the element to delete from the list.
76133 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
76134 entry->prev = LIST_POISON2;
76135 }
76136
76137 +extern void pax_list_del_rcu(struct list_head *entry);
76138 +
76139 /**
76140 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
76141 * @n: the element to delete from the hash list.
76142 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
76143 index 8e00f9f..9449b55 100644
76144 --- a/include/linux/reboot.h
76145 +++ b/include/linux/reboot.h
76146 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
76147 * Architecture-specific implementations of sys_reboot commands.
76148 */
76149
76150 -extern void machine_restart(char *cmd);
76151 -extern void machine_halt(void);
76152 -extern void machine_power_off(void);
76153 +extern void machine_restart(char *cmd) __noreturn;
76154 +extern void machine_halt(void) __noreturn;
76155 +extern void machine_power_off(void) __noreturn;
76156
76157 extern void machine_shutdown(void);
76158 struct pt_regs;
76159 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
76160 */
76161
76162 extern void kernel_restart_prepare(char *cmd);
76163 -extern void kernel_restart(char *cmd);
76164 -extern void kernel_halt(void);
76165 -extern void kernel_power_off(void);
76166 +extern void kernel_restart(char *cmd) __noreturn;
76167 +extern void kernel_halt(void) __noreturn;
76168 +extern void kernel_power_off(void) __noreturn;
76169
76170 extern int C_A_D; /* for sysctl */
76171 void ctrl_alt_del(void);
76172 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
76173 * Emergency restart, callable from an interrupt handler.
76174 */
76175
76176 -extern void emergency_restart(void);
76177 +extern void emergency_restart(void) __noreturn;
76178 #include <asm/emergency-restart.h>
76179
76180 #endif /* _LINUX_REBOOT_H */
76181 diff --git a/include/linux/regset.h b/include/linux/regset.h
76182 index 8e0c9fe..ac4d221 100644
76183 --- a/include/linux/regset.h
76184 +++ b/include/linux/regset.h
76185 @@ -161,7 +161,8 @@ struct user_regset {
76186 unsigned int align;
76187 unsigned int bias;
76188 unsigned int core_note_type;
76189 -};
76190 +} __do_const;
76191 +typedef struct user_regset __no_const user_regset_no_const;
76192
76193 /**
76194 * struct user_regset_view - available regsets
76195 diff --git a/include/linux/relay.h b/include/linux/relay.h
76196 index d7c8359..818daf5 100644
76197 --- a/include/linux/relay.h
76198 +++ b/include/linux/relay.h
76199 @@ -157,7 +157,7 @@ struct rchan_callbacks
76200 * The callback should return 0 if successful, negative if not.
76201 */
76202 int (*remove_buf_file)(struct dentry *dentry);
76203 -};
76204 +} __no_const;
76205
76206 /*
76207 * CONFIG_RELAY kernel API, kernel/relay.c
76208 diff --git a/include/linux/rio.h b/include/linux/rio.h
76209 index b71d573..2f940bd 100644
76210 --- a/include/linux/rio.h
76211 +++ b/include/linux/rio.h
76212 @@ -355,7 +355,7 @@ struct rio_ops {
76213 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
76214 u64 rstart, u32 size, u32 flags);
76215 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
76216 -};
76217 +} __no_const;
76218
76219 #define RIO_RESOURCE_MEM 0x00000100
76220 #define RIO_RESOURCE_DOORBELL 0x00000200
76221 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
76222 index 6dacb93..6174423 100644
76223 --- a/include/linux/rmap.h
76224 +++ b/include/linux/rmap.h
76225 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
76226 void anon_vma_init(void); /* create anon_vma_cachep */
76227 int anon_vma_prepare(struct vm_area_struct *);
76228 void unlink_anon_vmas(struct vm_area_struct *);
76229 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
76230 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
76231 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
76232 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
76233
76234 static inline void anon_vma_merge(struct vm_area_struct *vma,
76235 struct vm_area_struct *next)
76236 diff --git a/include/linux/sched.h b/include/linux/sched.h
76237 index 078066d..4090b3b 100644
76238 --- a/include/linux/sched.h
76239 +++ b/include/linux/sched.h
76240 @@ -62,6 +62,7 @@ struct bio_list;
76241 struct fs_struct;
76242 struct perf_event_context;
76243 struct blk_plug;
76244 +struct linux_binprm;
76245
76246 /*
76247 * List of flags we want to share for kernel threads,
76248 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
76249 extern int in_sched_functions(unsigned long addr);
76250
76251 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
76252 -extern signed long schedule_timeout(signed long timeout);
76253 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
76254 extern signed long schedule_timeout_interruptible(signed long timeout);
76255 extern signed long schedule_timeout_killable(signed long timeout);
76256 extern signed long schedule_timeout_uninterruptible(signed long timeout);
76257 @@ -314,6 +315,19 @@ struct nsproxy;
76258 struct user_namespace;
76259
76260 #ifdef CONFIG_MMU
76261 +
76262 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
76263 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
76264 +#else
76265 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
76266 +{
76267 + return 0;
76268 +}
76269 +#endif
76270 +
76271 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
76272 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
76273 +
76274 extern void arch_pick_mmap_layout(struct mm_struct *mm);
76275 extern unsigned long
76276 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
76277 @@ -589,6 +603,17 @@ struct signal_struct {
76278 #ifdef CONFIG_TASKSTATS
76279 struct taskstats *stats;
76280 #endif
76281 +
76282 +#ifdef CONFIG_GRKERNSEC
76283 + u32 curr_ip;
76284 + u32 saved_ip;
76285 + u32 gr_saddr;
76286 + u32 gr_daddr;
76287 + u16 gr_sport;
76288 + u16 gr_dport;
76289 + u8 used_accept:1;
76290 +#endif
76291 +
76292 #ifdef CONFIG_AUDIT
76293 unsigned audit_tty;
76294 unsigned audit_tty_log_passwd;
76295 @@ -669,6 +694,14 @@ struct user_struct {
76296 struct key *session_keyring; /* UID's default session keyring */
76297 #endif
76298
76299 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
76300 + unsigned char kernel_banned;
76301 +#endif
76302 +#ifdef CONFIG_GRKERNSEC_BRUTE
76303 + unsigned char suid_banned;
76304 + unsigned long suid_ban_expires;
76305 +#endif
76306 +
76307 /* Hash table maintenance information */
76308 struct hlist_node uidhash_node;
76309 kuid_t uid;
76310 @@ -1151,8 +1184,8 @@ struct task_struct {
76311 struct list_head thread_group;
76312
76313 struct completion *vfork_done; /* for vfork() */
76314 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
76315 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76316 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
76317 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76318
76319 cputime_t utime, stime, utimescaled, stimescaled;
76320 cputime_t gtime;
76321 @@ -1177,11 +1210,6 @@ struct task_struct {
76322 struct task_cputime cputime_expires;
76323 struct list_head cpu_timers[3];
76324
76325 -/* process credentials */
76326 - const struct cred __rcu *real_cred; /* objective and real subjective task
76327 - * credentials (COW) */
76328 - const struct cred __rcu *cred; /* effective (overridable) subjective task
76329 - * credentials (COW) */
76330 char comm[TASK_COMM_LEN]; /* executable name excluding path
76331 - access with [gs]et_task_comm (which lock
76332 it with task_lock())
76333 @@ -1198,6 +1226,10 @@ struct task_struct {
76334 #endif
76335 /* CPU-specific state of this task */
76336 struct thread_struct thread;
76337 +/* thread_info moved to task_struct */
76338 +#ifdef CONFIG_X86
76339 + struct thread_info tinfo;
76340 +#endif
76341 /* filesystem information */
76342 struct fs_struct *fs;
76343 /* open file information */
76344 @@ -1271,6 +1303,10 @@ struct task_struct {
76345 gfp_t lockdep_reclaim_gfp;
76346 #endif
76347
76348 +/* process credentials */
76349 + const struct cred __rcu *real_cred; /* objective and real subjective task
76350 + * credentials (COW) */
76351 +
76352 /* journalling filesystem info */
76353 void *journal_info;
76354
76355 @@ -1309,6 +1345,10 @@ struct task_struct {
76356 /* cg_list protected by css_set_lock and tsk->alloc_lock */
76357 struct list_head cg_list;
76358 #endif
76359 +
76360 + const struct cred __rcu *cred; /* effective (overridable) subjective task
76361 + * credentials (COW) */
76362 +
76363 #ifdef CONFIG_FUTEX
76364 struct robust_list_head __user *robust_list;
76365 #ifdef CONFIG_COMPAT
76366 @@ -1406,8 +1446,76 @@ struct task_struct {
76367 unsigned int sequential_io;
76368 unsigned int sequential_io_avg;
76369 #endif
76370 +
76371 +#ifdef CONFIG_GRKERNSEC
76372 + /* grsecurity */
76373 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76374 + u64 exec_id;
76375 +#endif
76376 +#ifdef CONFIG_GRKERNSEC_SETXID
76377 + const struct cred *delayed_cred;
76378 +#endif
76379 + struct dentry *gr_chroot_dentry;
76380 + struct acl_subject_label *acl;
76381 + struct acl_role_label *role;
76382 + struct file *exec_file;
76383 + unsigned long brute_expires;
76384 + u16 acl_role_id;
76385 + /* is this the task that authenticated to the special role */
76386 + u8 acl_sp_role;
76387 + u8 is_writable;
76388 + u8 brute;
76389 + u8 gr_is_chrooted;
76390 +#endif
76391 +
76392 };
76393
76394 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
76395 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
76396 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
76397 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
76398 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
76399 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
76400 +
76401 +#ifdef CONFIG_PAX_SOFTMODE
76402 +extern int pax_softmode;
76403 +#endif
76404 +
76405 +extern int pax_check_flags(unsigned long *);
76406 +
76407 +/* if tsk != current then task_lock must be held on it */
76408 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76409 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
76410 +{
76411 + if (likely(tsk->mm))
76412 + return tsk->mm->pax_flags;
76413 + else
76414 + return 0UL;
76415 +}
76416 +
76417 +/* if tsk != current then task_lock must be held on it */
76418 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
76419 +{
76420 + if (likely(tsk->mm)) {
76421 + tsk->mm->pax_flags = flags;
76422 + return 0;
76423 + }
76424 + return -EINVAL;
76425 +}
76426 +#endif
76427 +
76428 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76429 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
76430 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
76431 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76432 +#endif
76433 +
76434 +struct path;
76435 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
76436 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
76437 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
76438 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
76439 +
76440 /* Future-safe accessor for struct task_struct's cpus_allowed. */
76441 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
76442
76443 @@ -1466,7 +1574,7 @@ struct pid_namespace;
76444 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
76445 struct pid_namespace *ns);
76446
76447 -static inline pid_t task_pid_nr(struct task_struct *tsk)
76448 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
76449 {
76450 return tsk->pid;
76451 }
76452 @@ -1916,7 +2024,9 @@ void yield(void);
76453 extern struct exec_domain default_exec_domain;
76454
76455 union thread_union {
76456 +#ifndef CONFIG_X86
76457 struct thread_info thread_info;
76458 +#endif
76459 unsigned long stack[THREAD_SIZE/sizeof(long)];
76460 };
76461
76462 @@ -1949,6 +2059,7 @@ extern struct pid_namespace init_pid_ns;
76463 */
76464
76465 extern struct task_struct *find_task_by_vpid(pid_t nr);
76466 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
76467 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
76468 struct pid_namespace *ns);
76469
76470 @@ -2113,7 +2224,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
76471 extern void exit_itimers(struct signal_struct *);
76472 extern void flush_itimer_signals(void);
76473
76474 -extern void do_group_exit(int);
76475 +extern __noreturn void do_group_exit(int);
76476
76477 extern int allow_signal(int);
76478 extern int disallow_signal(int);
76479 @@ -2304,9 +2415,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
76480
76481 #endif
76482
76483 -static inline int object_is_on_stack(void *obj)
76484 +static inline int object_starts_on_stack(void *obj)
76485 {
76486 - void *stack = task_stack_page(current);
76487 + const void *stack = task_stack_page(current);
76488
76489 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
76490 }
76491 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
76492 index bf8086b..962b035 100644
76493 --- a/include/linux/sched/sysctl.h
76494 +++ b/include/linux/sched/sysctl.h
76495 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
76496 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
76497
76498 extern int sysctl_max_map_count;
76499 +extern unsigned long sysctl_heap_stack_gap;
76500
76501 extern unsigned int sysctl_sched_latency;
76502 extern unsigned int sysctl_sched_min_granularity;
76503 diff --git a/include/linux/security.h b/include/linux/security.h
76504 index 7ce53ae..8ee24a5 100644
76505 --- a/include/linux/security.h
76506 +++ b/include/linux/security.h
76507 @@ -27,6 +27,7 @@
76508 #include <linux/slab.h>
76509 #include <linux/err.h>
76510 #include <linux/string.h>
76511 +#include <linux/grsecurity.h>
76512
76513 struct linux_binprm;
76514 struct cred;
76515 @@ -116,8 +117,6 @@ struct seq_file;
76516
76517 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
76518
76519 -void reset_security_ops(void);
76520 -
76521 #ifdef CONFIG_MMU
76522 extern unsigned long mmap_min_addr;
76523 extern unsigned long dac_mmap_min_addr;
76524 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
76525 index 4e32edc..f8f2d18 100644
76526 --- a/include/linux/seq_file.h
76527 +++ b/include/linux/seq_file.h
76528 @@ -26,6 +26,9 @@ struct seq_file {
76529 struct mutex lock;
76530 const struct seq_operations *op;
76531 int poll_event;
76532 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76533 + u64 exec_id;
76534 +#endif
76535 #ifdef CONFIG_USER_NS
76536 struct user_namespace *user_ns;
76537 #endif
76538 @@ -38,6 +41,7 @@ struct seq_operations {
76539 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
76540 int (*show) (struct seq_file *m, void *v);
76541 };
76542 +typedef struct seq_operations __no_const seq_operations_no_const;
76543
76544 #define SEQ_SKIP 1
76545
76546 diff --git a/include/linux/shm.h b/include/linux/shm.h
76547 index 429c199..4d42e38 100644
76548 --- a/include/linux/shm.h
76549 +++ b/include/linux/shm.h
76550 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
76551
76552 /* The task created the shm object. NULL if the task is dead. */
76553 struct task_struct *shm_creator;
76554 +#ifdef CONFIG_GRKERNSEC
76555 + time_t shm_createtime;
76556 + pid_t shm_lapid;
76557 +#endif
76558 };
76559
76560 /* shm_mode upper byte flags */
76561 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
76562 index 6bd165b..4823435 100644
76563 --- a/include/linux/skbuff.h
76564 +++ b/include/linux/skbuff.h
76565 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
76566 extern struct sk_buff *__alloc_skb(unsigned int size,
76567 gfp_t priority, int flags, int node);
76568 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
76569 -static inline struct sk_buff *alloc_skb(unsigned int size,
76570 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
76571 gfp_t priority)
76572 {
76573 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
76574 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
76575 */
76576 static inline int skb_queue_empty(const struct sk_buff_head *list)
76577 {
76578 - return list->next == (struct sk_buff *)list;
76579 + return list->next == (const struct sk_buff *)list;
76580 }
76581
76582 /**
76583 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
76584 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76585 const struct sk_buff *skb)
76586 {
76587 - return skb->next == (struct sk_buff *)list;
76588 + return skb->next == (const struct sk_buff *)list;
76589 }
76590
76591 /**
76592 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76593 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
76594 const struct sk_buff *skb)
76595 {
76596 - return skb->prev == (struct sk_buff *)list;
76597 + return skb->prev == (const struct sk_buff *)list;
76598 }
76599
76600 /**
76601 @@ -1755,7 +1755,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
76602 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
76603 */
76604 #ifndef NET_SKB_PAD
76605 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
76606 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
76607 #endif
76608
76609 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
76610 @@ -2350,7 +2350,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
76611 int noblock, int *err);
76612 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
76613 struct poll_table_struct *wait);
76614 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
76615 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
76616 int offset, struct iovec *to,
76617 int size);
76618 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
76619 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
76620 nf_bridge_put(skb->nf_bridge);
76621 skb->nf_bridge = NULL;
76622 #endif
76623 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
76624 + skb->nf_trace = 0;
76625 +#endif
76626 }
76627
76628 static inline void nf_reset_trace(struct sk_buff *skb)
76629 diff --git a/include/linux/slab.h b/include/linux/slab.h
76630 index 6c5cc0e..9ca0fd6 100644
76631 --- a/include/linux/slab.h
76632 +++ b/include/linux/slab.h
76633 @@ -12,15 +12,29 @@
76634 #include <linux/gfp.h>
76635 #include <linux/types.h>
76636 #include <linux/workqueue.h>
76637 -
76638 +#include <linux/err.h>
76639
76640 /*
76641 * Flags to pass to kmem_cache_create().
76642 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
76643 */
76644 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
76645 +
76646 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76647 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
76648 +#else
76649 +#define SLAB_USERCOPY 0x00000000UL
76650 +#endif
76651 +
76652 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
76653 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
76654 +
76655 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76656 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
76657 +#else
76658 +#define SLAB_NO_SANITIZE 0x00000000UL
76659 +#endif
76660 +
76661 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
76662 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
76663 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
76664 @@ -89,10 +103,13 @@
76665 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
76666 * Both make kfree a no-op.
76667 */
76668 -#define ZERO_SIZE_PTR ((void *)16)
76669 +#define ZERO_SIZE_PTR \
76670 +({ \
76671 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
76672 + (void *)(-MAX_ERRNO-1L); \
76673 +})
76674
76675 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
76676 - (unsigned long)ZERO_SIZE_PTR)
76677 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
76678
76679
76680 struct mem_cgroup;
76681 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
76682 void kfree(const void *);
76683 void kzfree(const void *);
76684 size_t ksize(const void *);
76685 +const char *check_heap_object(const void *ptr, unsigned long n);
76686 +bool is_usercopy_object(const void *ptr);
76687
76688 /*
76689 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
76690 @@ -164,7 +183,7 @@ struct kmem_cache {
76691 unsigned int align; /* Alignment as calculated */
76692 unsigned long flags; /* Active flags on the slab */
76693 const char *name; /* Slab name for sysfs */
76694 - int refcount; /* Use counter */
76695 + atomic_t refcount; /* Use counter */
76696 void (*ctor)(void *); /* Called on object slot creation */
76697 struct list_head list; /* List of all slab caches on the system */
76698 };
76699 @@ -238,6 +257,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
76700 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76701 #endif
76702
76703 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76704 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
76705 +#endif
76706 +
76707 /*
76708 * Figure out which kmalloc slab an allocation of a certain size
76709 * belongs to.
76710 @@ -246,7 +269,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76711 * 2 = 120 .. 192 bytes
76712 * n = 2^(n-1) .. 2^n -1
76713 */
76714 -static __always_inline int kmalloc_index(size_t size)
76715 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
76716 {
76717 if (!size)
76718 return 0;
76719 @@ -492,7 +515,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
76720 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76721 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76722 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76723 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76724 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
76725 #define kmalloc_track_caller(size, flags) \
76726 __kmalloc_track_caller(size, flags, _RET_IP_)
76727 #else
76728 @@ -512,7 +535,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76729 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76730 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76731 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76732 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
76733 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
76734 #define kmalloc_node_track_caller(size, flags, node) \
76735 __kmalloc_node_track_caller(size, flags, node, \
76736 _RET_IP_)
76737 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
76738 index cd40158..4e2f7af 100644
76739 --- a/include/linux/slab_def.h
76740 +++ b/include/linux/slab_def.h
76741 @@ -50,7 +50,7 @@ struct kmem_cache {
76742 /* 4) cache creation/removal */
76743 const char *name;
76744 struct list_head list;
76745 - int refcount;
76746 + atomic_t refcount;
76747 int object_size;
76748 int align;
76749
76750 @@ -66,10 +66,14 @@ struct kmem_cache {
76751 unsigned long node_allocs;
76752 unsigned long node_frees;
76753 unsigned long node_overflow;
76754 - atomic_t allochit;
76755 - atomic_t allocmiss;
76756 - atomic_t freehit;
76757 - atomic_t freemiss;
76758 + atomic_unchecked_t allochit;
76759 + atomic_unchecked_t allocmiss;
76760 + atomic_unchecked_t freehit;
76761 + atomic_unchecked_t freemiss;
76762 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76763 + atomic_unchecked_t sanitized;
76764 + atomic_unchecked_t not_sanitized;
76765 +#endif
76766
76767 /*
76768 * If debugging is enabled, then the allocator can add additional
76769 @@ -103,7 +107,7 @@ struct kmem_cache {
76770 };
76771
76772 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76773 -void *__kmalloc(size_t size, gfp_t flags);
76774 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
76775
76776 #ifdef CONFIG_TRACING
76777 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
76778 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76779 cachep = kmalloc_dma_caches[i];
76780 else
76781 #endif
76782 +
76783 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76784 + if (flags & GFP_USERCOPY)
76785 + cachep = kmalloc_usercopy_caches[i];
76786 + else
76787 +#endif
76788 +
76789 cachep = kmalloc_caches[i];
76790
76791 ret = kmem_cache_alloc_trace(cachep, flags, size);
76792 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76793 }
76794
76795 #ifdef CONFIG_NUMA
76796 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
76797 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76798 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76799
76800 #ifdef CONFIG_TRACING
76801 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76802 cachep = kmalloc_dma_caches[i];
76803 else
76804 #endif
76805 +
76806 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76807 + if (flags & GFP_USERCOPY)
76808 + cachep = kmalloc_usercopy_caches[i];
76809 + else
76810 +#endif
76811 +
76812 cachep = kmalloc_caches[i];
76813
76814 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
76815 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
76816 index 095a5a4..4b82027 100644
76817 --- a/include/linux/slob_def.h
76818 +++ b/include/linux/slob_def.h
76819 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
76820 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
76821 }
76822
76823 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76824 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76825
76826 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76827 {
76828 @@ -23,7 +23,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76829 return __kmalloc_node(size, flags, NUMA_NO_NODE);
76830 }
76831
76832 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
76833 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
76834 {
76835 return kmalloc(size, flags);
76836 }
76837 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
76838 index 027276f..092bfe8 100644
76839 --- a/include/linux/slub_def.h
76840 +++ b/include/linux/slub_def.h
76841 @@ -80,7 +80,7 @@ struct kmem_cache {
76842 struct kmem_cache_order_objects max;
76843 struct kmem_cache_order_objects min;
76844 gfp_t allocflags; /* gfp flags to use on each alloc */
76845 - int refcount; /* Refcount for slab cache destroy */
76846 + atomic_t refcount; /* Refcount for slab cache destroy */
76847 void (*ctor)(void *);
76848 int inuse; /* Offset to metadata */
76849 int align; /* Alignment */
76850 @@ -105,7 +105,7 @@ struct kmem_cache {
76851 };
76852
76853 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76854 -void *__kmalloc(size_t size, gfp_t flags);
76855 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
76856
76857 static __always_inline void *
76858 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
76859 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
76860 }
76861 #endif
76862
76863 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
76864 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
76865 {
76866 unsigned int order = get_order(size);
76867 return kmalloc_order_trace(size, flags, order);
76868 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76869 }
76870
76871 #ifdef CONFIG_NUMA
76872 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76873 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76874 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76875
76876 #ifdef CONFIG_TRACING
76877 diff --git a/include/linux/smp.h b/include/linux/smp.h
76878 index c181399..09d7b92 100644
76879 --- a/include/linux/smp.h
76880 +++ b/include/linux/smp.h
76881 @@ -217,7 +217,9 @@ static inline void kick_all_cpus_sync(void) { }
76882 #endif
76883
76884 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
76885 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
76886 #define put_cpu() preempt_enable()
76887 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
76888
76889 /*
76890 * Callback to arch code if there's nosmp or maxcpus=0 on the
76891 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
76892 index 54f91d3..be2c379 100644
76893 --- a/include/linux/sock_diag.h
76894 +++ b/include/linux/sock_diag.h
76895 @@ -11,7 +11,7 @@ struct sock;
76896 struct sock_diag_handler {
76897 __u8 family;
76898 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
76899 -};
76900 +} __do_const;
76901
76902 int sock_diag_register(const struct sock_diag_handler *h);
76903 void sock_diag_unregister(const struct sock_diag_handler *h);
76904 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
76905 index 680f9a3..f13aeb0 100644
76906 --- a/include/linux/sonet.h
76907 +++ b/include/linux/sonet.h
76908 @@ -7,7 +7,7 @@
76909 #include <uapi/linux/sonet.h>
76910
76911 struct k_sonet_stats {
76912 -#define __HANDLE_ITEM(i) atomic_t i
76913 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
76914 __SONET_ITEMS
76915 #undef __HANDLE_ITEM
76916 };
76917 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
76918 index 07d8e53..dc934c9 100644
76919 --- a/include/linux/sunrpc/addr.h
76920 +++ b/include/linux/sunrpc/addr.h
76921 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
76922 {
76923 switch (sap->sa_family) {
76924 case AF_INET:
76925 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
76926 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
76927 case AF_INET6:
76928 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
76929 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
76930 }
76931 return 0;
76932 }
76933 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
76934 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
76935 const struct sockaddr *src)
76936 {
76937 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
76938 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
76939 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
76940
76941 dsin->sin_family = ssin->sin_family;
76942 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
76943 if (sa->sa_family != AF_INET6)
76944 return 0;
76945
76946 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
76947 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
76948 }
76949
76950 #endif /* _LINUX_SUNRPC_ADDR_H */
76951 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
76952 index bfe11be..12bc8c4 100644
76953 --- a/include/linux/sunrpc/clnt.h
76954 +++ b/include/linux/sunrpc/clnt.h
76955 @@ -96,7 +96,7 @@ struct rpc_procinfo {
76956 unsigned int p_timer; /* Which RTT timer to use */
76957 u32 p_statidx; /* Which procedure to account */
76958 const char * p_name; /* name of procedure */
76959 -};
76960 +} __do_const;
76961
76962 #ifdef __KERNEL__
76963
76964 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
76965 index 1f0216b..6a4fa50 100644
76966 --- a/include/linux/sunrpc/svc.h
76967 +++ b/include/linux/sunrpc/svc.h
76968 @@ -411,7 +411,7 @@ struct svc_procedure {
76969 unsigned int pc_count; /* call count */
76970 unsigned int pc_cachetype; /* cache info (NFS) */
76971 unsigned int pc_xdrressize; /* maximum size of XDR reply */
76972 -};
76973 +} __do_const;
76974
76975 /*
76976 * Function prototypes.
76977 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
76978 index 0b8e3e6..33e0a01 100644
76979 --- a/include/linux/sunrpc/svc_rdma.h
76980 +++ b/include/linux/sunrpc/svc_rdma.h
76981 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
76982 extern unsigned int svcrdma_max_requests;
76983 extern unsigned int svcrdma_max_req_size;
76984
76985 -extern atomic_t rdma_stat_recv;
76986 -extern atomic_t rdma_stat_read;
76987 -extern atomic_t rdma_stat_write;
76988 -extern atomic_t rdma_stat_sq_starve;
76989 -extern atomic_t rdma_stat_rq_starve;
76990 -extern atomic_t rdma_stat_rq_poll;
76991 -extern atomic_t rdma_stat_rq_prod;
76992 -extern atomic_t rdma_stat_sq_poll;
76993 -extern atomic_t rdma_stat_sq_prod;
76994 +extern atomic_unchecked_t rdma_stat_recv;
76995 +extern atomic_unchecked_t rdma_stat_read;
76996 +extern atomic_unchecked_t rdma_stat_write;
76997 +extern atomic_unchecked_t rdma_stat_sq_starve;
76998 +extern atomic_unchecked_t rdma_stat_rq_starve;
76999 +extern atomic_unchecked_t rdma_stat_rq_poll;
77000 +extern atomic_unchecked_t rdma_stat_rq_prod;
77001 +extern atomic_unchecked_t rdma_stat_sq_poll;
77002 +extern atomic_unchecked_t rdma_stat_sq_prod;
77003
77004 #define RPCRDMA_VERSION 1
77005
77006 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
77007 index 8d71d65..f79586e 100644
77008 --- a/include/linux/sunrpc/svcauth.h
77009 +++ b/include/linux/sunrpc/svcauth.h
77010 @@ -120,7 +120,7 @@ struct auth_ops {
77011 int (*release)(struct svc_rqst *rq);
77012 void (*domain_release)(struct auth_domain *);
77013 int (*set_client)(struct svc_rqst *rq);
77014 -};
77015 +} __do_const;
77016
77017 #define SVC_GARBAGE 1
77018 #define SVC_SYSERR 2
77019 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
77020 index a5ffd32..0935dea 100644
77021 --- a/include/linux/swiotlb.h
77022 +++ b/include/linux/swiotlb.h
77023 @@ -60,7 +60,8 @@ extern void
77024
77025 extern void
77026 swiotlb_free_coherent(struct device *hwdev, size_t size,
77027 - void *vaddr, dma_addr_t dma_handle);
77028 + void *vaddr, dma_addr_t dma_handle,
77029 + struct dma_attrs *attrs);
77030
77031 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
77032 unsigned long offset, size_t size,
77033 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
77034 index 84662ec..5271947 100644
77035 --- a/include/linux/syscalls.h
77036 +++ b/include/linux/syscalls.h
77037 @@ -97,8 +97,14 @@ struct sigaltstack;
77038 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
77039
77040 #define __SC_DECL(t, a) t a
77041 +#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))
77042 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
77043 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
77044 +#define __SC_LONG(t, a) __typeof( \
77045 + __builtin_choose_expr( \
77046 + sizeof(t) > sizeof(int), \
77047 + (t) 0, \
77048 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
77049 + )) a
77050 #define __SC_CAST(t, a) (t) a
77051 #define __SC_ARGS(t, a) a
77052 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
77053 @@ -362,11 +368,11 @@ asmlinkage long sys_sync(void);
77054 asmlinkage long sys_fsync(unsigned int fd);
77055 asmlinkage long sys_fdatasync(unsigned int fd);
77056 asmlinkage long sys_bdflush(int func, long data);
77057 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
77058 - char __user *type, unsigned long flags,
77059 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
77060 + const char __user *type, unsigned long flags,
77061 void __user *data);
77062 -asmlinkage long sys_umount(char __user *name, int flags);
77063 -asmlinkage long sys_oldumount(char __user *name);
77064 +asmlinkage long sys_umount(const char __user *name, int flags);
77065 +asmlinkage long sys_oldumount(const char __user *name);
77066 asmlinkage long sys_truncate(const char __user *path, long length);
77067 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
77068 asmlinkage long sys_stat(const char __user *filename,
77069 @@ -578,7 +584,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
77070 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
77071 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
77072 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
77073 - struct sockaddr __user *, int);
77074 + struct sockaddr __user *, int) __intentional_overflow(0);
77075 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
77076 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
77077 unsigned int vlen, unsigned flags);
77078 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
77079 index 27b3b0b..e093dd9 100644
77080 --- a/include/linux/syscore_ops.h
77081 +++ b/include/linux/syscore_ops.h
77082 @@ -16,7 +16,7 @@ struct syscore_ops {
77083 int (*suspend)(void);
77084 void (*resume)(void);
77085 void (*shutdown)(void);
77086 -};
77087 +} __do_const;
77088
77089 extern void register_syscore_ops(struct syscore_ops *ops);
77090 extern void unregister_syscore_ops(struct syscore_ops *ops);
77091 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
77092 index 14a8ff2..af52bad 100644
77093 --- a/include/linux/sysctl.h
77094 +++ b/include/linux/sysctl.h
77095 @@ -34,13 +34,13 @@ struct ctl_table_root;
77096 struct ctl_table_header;
77097 struct ctl_dir;
77098
77099 -typedef struct ctl_table ctl_table;
77100 -
77101 typedef int proc_handler (struct ctl_table *ctl, int write,
77102 void __user *buffer, size_t *lenp, loff_t *ppos);
77103
77104 extern int proc_dostring(struct ctl_table *, int,
77105 void __user *, size_t *, loff_t *);
77106 +extern int proc_dostring_modpriv(struct ctl_table *, int,
77107 + void __user *, size_t *, loff_t *);
77108 extern int proc_dointvec(struct ctl_table *, int,
77109 void __user *, size_t *, loff_t *);
77110 extern int proc_dointvec_minmax(struct ctl_table *, int,
77111 @@ -115,7 +115,9 @@ struct ctl_table
77112 struct ctl_table_poll *poll;
77113 void *extra1;
77114 void *extra2;
77115 -};
77116 +} __do_const;
77117 +typedef struct ctl_table __no_const ctl_table_no_const;
77118 +typedef struct ctl_table ctl_table;
77119
77120 struct ctl_node {
77121 struct rb_node node;
77122 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
77123 index 9e8a9b5..753de68 100644
77124 --- a/include/linux/sysfs.h
77125 +++ b/include/linux/sysfs.h
77126 @@ -33,7 +33,8 @@ struct attribute {
77127 struct lock_class_key *key;
77128 struct lock_class_key skey;
77129 #endif
77130 -};
77131 +} __do_const;
77132 +typedef struct attribute __no_const attribute_no_const;
77133
77134 /**
77135 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
77136 @@ -62,7 +63,8 @@ struct attribute_group {
77137 struct attribute *, int);
77138 struct attribute **attrs;
77139 struct bin_attribute **bin_attrs;
77140 -};
77141 +} __do_const;
77142 +typedef struct attribute_group __no_const attribute_group_no_const;
77143
77144 /**
77145 * Use these macros to make defining attributes easier. See include/linux/device.h
77146 @@ -123,7 +125,8 @@ struct bin_attribute {
77147 char *, loff_t, size_t);
77148 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
77149 struct vm_area_struct *vma);
77150 -};
77151 +} __do_const;
77152 +typedef struct bin_attribute __no_const bin_attribute_no_const;
77153
77154 /**
77155 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
77156 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
77157 index 7faf933..9b85a0c 100644
77158 --- a/include/linux/sysrq.h
77159 +++ b/include/linux/sysrq.h
77160 @@ -16,6 +16,7 @@
77161
77162 #include <linux/errno.h>
77163 #include <linux/types.h>
77164 +#include <linux/compiler.h>
77165
77166 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
77167 #define SYSRQ_DEFAULT_ENABLE 1
77168 @@ -36,7 +37,7 @@ struct sysrq_key_op {
77169 char *help_msg;
77170 char *action_msg;
77171 int enable_mask;
77172 -};
77173 +} __do_const;
77174
77175 #ifdef CONFIG_MAGIC_SYSRQ
77176
77177 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
77178 index e7e0473..7989295 100644
77179 --- a/include/linux/thread_info.h
77180 +++ b/include/linux/thread_info.h
77181 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
77182 #error "no set_restore_sigmask() provided and default one won't work"
77183 #endif
77184
77185 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
77186 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
77187 +{
77188 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
77189 + if (!__builtin_constant_p(n))
77190 +#endif
77191 + __check_object_size(ptr, n, to_user);
77192 +}
77193 +
77194 #endif /* __KERNEL__ */
77195
77196 #endif /* _LINUX_THREAD_INFO_H */
77197 diff --git a/include/linux/tty.h b/include/linux/tty.h
77198 index 01ac30e..bf18a71 100644
77199 --- a/include/linux/tty.h
77200 +++ b/include/linux/tty.h
77201 @@ -194,7 +194,7 @@ struct tty_port {
77202 const struct tty_port_operations *ops; /* Port operations */
77203 spinlock_t lock; /* Lock protecting tty field */
77204 int blocked_open; /* Waiting to open */
77205 - int count; /* Usage count */
77206 + atomic_t count; /* Usage count */
77207 wait_queue_head_t open_wait; /* Open waiters */
77208 wait_queue_head_t close_wait; /* Close waiters */
77209 wait_queue_head_t delta_msr_wait; /* Modem status change */
77210 @@ -547,7 +547,7 @@ extern int tty_port_open(struct tty_port *port,
77211 struct tty_struct *tty, struct file *filp);
77212 static inline int tty_port_users(struct tty_port *port)
77213 {
77214 - return port->count + port->blocked_open;
77215 + return atomic_read(&port->count) + port->blocked_open;
77216 }
77217
77218 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
77219 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
77220 index 756a609..b302dd6 100644
77221 --- a/include/linux/tty_driver.h
77222 +++ b/include/linux/tty_driver.h
77223 @@ -285,7 +285,7 @@ struct tty_operations {
77224 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
77225 #endif
77226 const struct file_operations *proc_fops;
77227 -};
77228 +} __do_const;
77229
77230 struct tty_driver {
77231 int magic; /* magic number for this structure */
77232 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
77233 index a1b0489..f02e17c 100644
77234 --- a/include/linux/tty_ldisc.h
77235 +++ b/include/linux/tty_ldisc.h
77236 @@ -198,7 +198,7 @@ struct tty_ldisc_ops {
77237
77238 struct module *owner;
77239
77240 - int refcount;
77241 + atomic_t refcount;
77242 };
77243
77244 struct tty_ldisc {
77245 diff --git a/include/linux/types.h b/include/linux/types.h
77246 index 4d118ba..c3ee9bf 100644
77247 --- a/include/linux/types.h
77248 +++ b/include/linux/types.h
77249 @@ -176,10 +176,26 @@ typedef struct {
77250 int counter;
77251 } atomic_t;
77252
77253 +#ifdef CONFIG_PAX_REFCOUNT
77254 +typedef struct {
77255 + int counter;
77256 +} atomic_unchecked_t;
77257 +#else
77258 +typedef atomic_t atomic_unchecked_t;
77259 +#endif
77260 +
77261 #ifdef CONFIG_64BIT
77262 typedef struct {
77263 long counter;
77264 } atomic64_t;
77265 +
77266 +#ifdef CONFIG_PAX_REFCOUNT
77267 +typedef struct {
77268 + long counter;
77269 +} atomic64_unchecked_t;
77270 +#else
77271 +typedef atomic64_t atomic64_unchecked_t;
77272 +#endif
77273 #endif
77274
77275 struct list_head {
77276 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
77277 index 5ca0951..ab496a5 100644
77278 --- a/include/linux/uaccess.h
77279 +++ b/include/linux/uaccess.h
77280 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
77281 long ret; \
77282 mm_segment_t old_fs = get_fs(); \
77283 \
77284 - set_fs(KERNEL_DS); \
77285 pagefault_disable(); \
77286 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
77287 - pagefault_enable(); \
77288 + set_fs(KERNEL_DS); \
77289 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
77290 set_fs(old_fs); \
77291 + pagefault_enable(); \
77292 ret; \
77293 })
77294
77295 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
77296 index 8e522cbc..aa8572d 100644
77297 --- a/include/linux/uidgid.h
77298 +++ b/include/linux/uidgid.h
77299 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
77300
77301 #endif /* CONFIG_USER_NS */
77302
77303 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
77304 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
77305 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
77306 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
77307 +
77308 #endif /* _LINUX_UIDGID_H */
77309 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
77310 index 99c1b4d..562e6f3 100644
77311 --- a/include/linux/unaligned/access_ok.h
77312 +++ b/include/linux/unaligned/access_ok.h
77313 @@ -4,34 +4,34 @@
77314 #include <linux/kernel.h>
77315 #include <asm/byteorder.h>
77316
77317 -static inline u16 get_unaligned_le16(const void *p)
77318 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
77319 {
77320 - return le16_to_cpup((__le16 *)p);
77321 + return le16_to_cpup((const __le16 *)p);
77322 }
77323
77324 -static inline u32 get_unaligned_le32(const void *p)
77325 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
77326 {
77327 - return le32_to_cpup((__le32 *)p);
77328 + return le32_to_cpup((const __le32 *)p);
77329 }
77330
77331 -static inline u64 get_unaligned_le64(const void *p)
77332 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
77333 {
77334 - return le64_to_cpup((__le64 *)p);
77335 + return le64_to_cpup((const __le64 *)p);
77336 }
77337
77338 -static inline u16 get_unaligned_be16(const void *p)
77339 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
77340 {
77341 - return be16_to_cpup((__be16 *)p);
77342 + return be16_to_cpup((const __be16 *)p);
77343 }
77344
77345 -static inline u32 get_unaligned_be32(const void *p)
77346 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
77347 {
77348 - return be32_to_cpup((__be32 *)p);
77349 + return be32_to_cpup((const __be32 *)p);
77350 }
77351
77352 -static inline u64 get_unaligned_be64(const void *p)
77353 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
77354 {
77355 - return be64_to_cpup((__be64 *)p);
77356 + return be64_to_cpup((const __be64 *)p);
77357 }
77358
77359 static inline void put_unaligned_le16(u16 val, void *p)
77360 diff --git a/include/linux/usb.h b/include/linux/usb.h
77361 index 0eec268..4496526 100644
77362 --- a/include/linux/usb.h
77363 +++ b/include/linux/usb.h
77364 @@ -560,7 +560,7 @@ struct usb_device {
77365 int maxchild;
77366
77367 u32 quirks;
77368 - atomic_t urbnum;
77369 + atomic_unchecked_t urbnum;
77370
77371 unsigned long active_duration;
77372
77373 @@ -1617,7 +1617,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
77374
77375 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
77376 __u8 request, __u8 requesttype, __u16 value, __u16 index,
77377 - void *data, __u16 size, int timeout);
77378 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
77379 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
77380 void *data, int len, int *actual_length, int timeout);
77381 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
77382 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
77383 index e452ba6..78f8e80 100644
77384 --- a/include/linux/usb/renesas_usbhs.h
77385 +++ b/include/linux/usb/renesas_usbhs.h
77386 @@ -39,7 +39,7 @@ enum {
77387 */
77388 struct renesas_usbhs_driver_callback {
77389 int (*notify_hotplug)(struct platform_device *pdev);
77390 -};
77391 +} __no_const;
77392
77393 /*
77394 * callback functions for platform
77395 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
77396 index 6f8fbcf..8259001 100644
77397 --- a/include/linux/vermagic.h
77398 +++ b/include/linux/vermagic.h
77399 @@ -25,9 +25,35 @@
77400 #define MODULE_ARCH_VERMAGIC ""
77401 #endif
77402
77403 +#ifdef CONFIG_PAX_REFCOUNT
77404 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
77405 +#else
77406 +#define MODULE_PAX_REFCOUNT ""
77407 +#endif
77408 +
77409 +#ifdef CONSTIFY_PLUGIN
77410 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
77411 +#else
77412 +#define MODULE_CONSTIFY_PLUGIN ""
77413 +#endif
77414 +
77415 +#ifdef STACKLEAK_PLUGIN
77416 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
77417 +#else
77418 +#define MODULE_STACKLEAK_PLUGIN ""
77419 +#endif
77420 +
77421 +#ifdef CONFIG_GRKERNSEC
77422 +#define MODULE_GRSEC "GRSEC "
77423 +#else
77424 +#define MODULE_GRSEC ""
77425 +#endif
77426 +
77427 #define VERMAGIC_STRING \
77428 UTS_RELEASE " " \
77429 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
77430 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
77431 - MODULE_ARCH_VERMAGIC
77432 + MODULE_ARCH_VERMAGIC \
77433 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
77434 + MODULE_GRSEC
77435
77436 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
77437 index 4b8a891..c20e936 100644
77438 --- a/include/linux/vmalloc.h
77439 +++ b/include/linux/vmalloc.h
77440 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
77441 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
77442 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
77443 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
77444 +
77445 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
77446 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
77447 +#endif
77448 +
77449 /* bits [20..32] reserved for arch specific ioremap internals */
77450
77451 /*
77452 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
77453 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
77454 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
77455 unsigned long start, unsigned long end, gfp_t gfp_mask,
77456 - pgprot_t prot, int node, const void *caller);
77457 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
77458 extern void vfree(const void *addr);
77459
77460 extern void *vmap(struct page **pages, unsigned int count,
77461 @@ -141,8 +146,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
77462 extern void free_vm_area(struct vm_struct *area);
77463
77464 /* for /dev/kmem */
77465 -extern long vread(char *buf, char *addr, unsigned long count);
77466 -extern long vwrite(char *buf, char *addr, unsigned long count);
77467 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
77468 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
77469
77470 /*
77471 * Internals. Dont't use..
77472 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
77473 index c586679..f06b389 100644
77474 --- a/include/linux/vmstat.h
77475 +++ b/include/linux/vmstat.h
77476 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
77477 /*
77478 * Zone based page accounting with per cpu differentials.
77479 */
77480 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77481 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77482
77483 static inline void zone_page_state_add(long x, struct zone *zone,
77484 enum zone_stat_item item)
77485 {
77486 - atomic_long_add(x, &zone->vm_stat[item]);
77487 - atomic_long_add(x, &vm_stat[item]);
77488 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
77489 + atomic_long_add_unchecked(x, &vm_stat[item]);
77490 }
77491
77492 static inline unsigned long global_page_state(enum zone_stat_item item)
77493 {
77494 - long x = atomic_long_read(&vm_stat[item]);
77495 + long x = atomic_long_read_unchecked(&vm_stat[item]);
77496 #ifdef CONFIG_SMP
77497 if (x < 0)
77498 x = 0;
77499 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
77500 static inline unsigned long zone_page_state(struct zone *zone,
77501 enum zone_stat_item item)
77502 {
77503 - long x = atomic_long_read(&zone->vm_stat[item]);
77504 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77505 #ifdef CONFIG_SMP
77506 if (x < 0)
77507 x = 0;
77508 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
77509 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
77510 enum zone_stat_item item)
77511 {
77512 - long x = atomic_long_read(&zone->vm_stat[item]);
77513 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77514
77515 #ifdef CONFIG_SMP
77516 int cpu;
77517 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
77518
77519 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
77520 {
77521 - atomic_long_inc(&zone->vm_stat[item]);
77522 - atomic_long_inc(&vm_stat[item]);
77523 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
77524 + atomic_long_inc_unchecked(&vm_stat[item]);
77525 }
77526
77527 static inline void __inc_zone_page_state(struct page *page,
77528 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
77529
77530 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
77531 {
77532 - atomic_long_dec(&zone->vm_stat[item]);
77533 - atomic_long_dec(&vm_stat[item]);
77534 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
77535 + atomic_long_dec_unchecked(&vm_stat[item]);
77536 }
77537
77538 static inline void __dec_zone_page_state(struct page *page,
77539 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
77540 index fdbafc6..49dfe4f 100644
77541 --- a/include/linux/xattr.h
77542 +++ b/include/linux/xattr.h
77543 @@ -28,7 +28,7 @@ struct xattr_handler {
77544 size_t size, int handler_flags);
77545 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
77546 size_t size, int flags, int handler_flags);
77547 -};
77548 +} __do_const;
77549
77550 struct xattr {
77551 char *name;
77552 @@ -37,6 +37,9 @@ struct xattr {
77553 };
77554
77555 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
77556 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
77557 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
77558 +#endif
77559 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
77560 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
77561 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
77562 diff --git a/include/linux/yam.h b/include/linux/yam.h
77563 index 7fe2822..512cdc2 100644
77564 --- a/include/linux/yam.h
77565 +++ b/include/linux/yam.h
77566 @@ -77,6 +77,6 @@ struct yamdrv_ioctl_cfg {
77567
77568 struct yamdrv_ioctl_mcs {
77569 int cmd;
77570 - int bitrate;
77571 + unsigned int bitrate;
77572 unsigned char bits[YAM_FPGA_SIZE];
77573 };
77574 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
77575 index 9c5a6b4..09c9438 100644
77576 --- a/include/linux/zlib.h
77577 +++ b/include/linux/zlib.h
77578 @@ -31,6 +31,7 @@
77579 #define _ZLIB_H
77580
77581 #include <linux/zconf.h>
77582 +#include <linux/compiler.h>
77583
77584 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
77585 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
77586 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
77587
77588 /* basic functions */
77589
77590 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
77591 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
77592 /*
77593 Returns the number of bytes that needs to be allocated for a per-
77594 stream workspace with the specified parameters. A pointer to this
77595 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
77596 index c768c9f..bdcaa5a 100644
77597 --- a/include/media/v4l2-dev.h
77598 +++ b/include/media/v4l2-dev.h
77599 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
77600 int (*mmap) (struct file *, struct vm_area_struct *);
77601 int (*open) (struct file *);
77602 int (*release) (struct file *);
77603 -};
77604 +} __do_const;
77605
77606 /*
77607 * Newer version of video_device, handled by videodev2.c
77608 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
77609 index c9b1593..a572459 100644
77610 --- a/include/media/v4l2-device.h
77611 +++ b/include/media/v4l2-device.h
77612 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
77613 this function returns 0. If the name ends with a digit (e.g. cx18),
77614 then the name will be set to cx18-0 since cx180 looks really odd. */
77615 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
77616 - atomic_t *instance);
77617 + atomic_unchecked_t *instance);
77618
77619 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
77620 Since the parent disappears this ensures that v4l2_dev doesn't have an
77621 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
77622 index d9fa68f..45c88d1 100644
77623 --- a/include/net/9p/transport.h
77624 +++ b/include/net/9p/transport.h
77625 @@ -63,7 +63,7 @@ struct p9_trans_module {
77626 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
77627 int (*zc_request)(struct p9_client *, struct p9_req_t *,
77628 char *, char *, int , int, int, int);
77629 -};
77630 +} __do_const;
77631
77632 void v9fs_register_trans(struct p9_trans_module *m);
77633 void v9fs_unregister_trans(struct p9_trans_module *m);
77634 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
77635 index 1a966af..2767cf6 100644
77636 --- a/include/net/bluetooth/l2cap.h
77637 +++ b/include/net/bluetooth/l2cap.h
77638 @@ -551,7 +551,7 @@ struct l2cap_ops {
77639 void (*defer) (struct l2cap_chan *chan);
77640 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
77641 unsigned long len, int nb);
77642 -};
77643 +} __do_const;
77644
77645 struct l2cap_conn {
77646 struct hci_conn *hcon;
77647 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
77648 index f2ae33d..c457cf0 100644
77649 --- a/include/net/caif/cfctrl.h
77650 +++ b/include/net/caif/cfctrl.h
77651 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
77652 void (*radioset_rsp)(void);
77653 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
77654 struct cflayer *client_layer);
77655 -};
77656 +} __no_const;
77657
77658 /* Link Setup Parameters for CAIF-Links. */
77659 struct cfctrl_link_param {
77660 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
77661 struct cfctrl {
77662 struct cfsrvl serv;
77663 struct cfctrl_rsp res;
77664 - atomic_t req_seq_no;
77665 - atomic_t rsp_seq_no;
77666 + atomic_unchecked_t req_seq_no;
77667 + atomic_unchecked_t rsp_seq_no;
77668 struct list_head list;
77669 /* Protects from simultaneous access to first_req list */
77670 spinlock_t info_list_lock;
77671 diff --git a/include/net/flow.h b/include/net/flow.h
77672 index 628e11b..4c475df 100644
77673 --- a/include/net/flow.h
77674 +++ b/include/net/flow.h
77675 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
77676
77677 extern void flow_cache_flush(void);
77678 extern void flow_cache_flush_deferred(void);
77679 -extern atomic_t flow_cache_genid;
77680 +extern atomic_unchecked_t flow_cache_genid;
77681
77682 #endif
77683 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
77684 index 8e0b6c8..73cf605 100644
77685 --- a/include/net/genetlink.h
77686 +++ b/include/net/genetlink.h
77687 @@ -120,7 +120,7 @@ struct genl_ops {
77688 struct netlink_callback *cb);
77689 int (*done)(struct netlink_callback *cb);
77690 struct list_head ops_list;
77691 -};
77692 +} __do_const;
77693
77694 extern int __genl_register_family(struct genl_family *family);
77695
77696 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
77697 index 734d9b5..48a9a4b 100644
77698 --- a/include/net/gro_cells.h
77699 +++ b/include/net/gro_cells.h
77700 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
77701 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
77702
77703 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
77704 - atomic_long_inc(&dev->rx_dropped);
77705 + atomic_long_inc_unchecked(&dev->rx_dropped);
77706 kfree_skb(skb);
77707 return;
77708 }
77709 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
77710 index de2c785..0588a6b 100644
77711 --- a/include/net/inet_connection_sock.h
77712 +++ b/include/net/inet_connection_sock.h
77713 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
77714 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
77715 int (*bind_conflict)(const struct sock *sk,
77716 const struct inet_bind_bucket *tb, bool relax);
77717 -};
77718 +} __do_const;
77719
77720 /** inet_connection_sock - INET connection oriented sock
77721 *
77722 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
77723 index 53f464d..0bd0b49 100644
77724 --- a/include/net/inetpeer.h
77725 +++ b/include/net/inetpeer.h
77726 @@ -47,8 +47,8 @@ struct inet_peer {
77727 */
77728 union {
77729 struct {
77730 - atomic_t rid; /* Frag reception counter */
77731 - atomic_t ip_id_count; /* IP ID for the next packet */
77732 + atomic_unchecked_t rid; /* Frag reception counter */
77733 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
77734 };
77735 struct rcu_head rcu;
77736 struct inet_peer *gc_next;
77737 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
77738 /* can be called with or without local BH being disabled */
77739 static inline int inet_getid(struct inet_peer *p, int more)
77740 {
77741 - int old, new;
77742 + int id;
77743 more++;
77744 inet_peer_refcheck(p);
77745 - do {
77746 - old = atomic_read(&p->ip_id_count);
77747 - new = old + more;
77748 - if (!new)
77749 - new = 1;
77750 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
77751 - return new;
77752 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
77753 + if (!id)
77754 + id = atomic_inc_return_unchecked(&p->ip_id_count);
77755 + return id;
77756 }
77757
77758 #endif /* _NET_INETPEER_H */
77759 diff --git a/include/net/ip.h b/include/net/ip.h
77760 index edfa591..a643b82 100644
77761 --- a/include/net/ip.h
77762 +++ b/include/net/ip.h
77763 @@ -202,7 +202,7 @@ extern struct local_ports {
77764 } sysctl_local_ports;
77765 extern void inet_get_local_port_range(int *low, int *high);
77766
77767 -extern unsigned long *sysctl_local_reserved_ports;
77768 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
77769 static inline int inet_is_reserved_local_port(int port)
77770 {
77771 return test_bit(port, sysctl_local_reserved_ports);
77772 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
77773 index cbf2be3..3683f6d 100644
77774 --- a/include/net/ip_fib.h
77775 +++ b/include/net/ip_fib.h
77776 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
77777
77778 #define FIB_RES_SADDR(net, res) \
77779 ((FIB_RES_NH(res).nh_saddr_genid == \
77780 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
77781 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
77782 FIB_RES_NH(res).nh_saddr : \
77783 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
77784 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
77785 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
77786 index f0d70f0..185f15b 100644
77787 --- a/include/net/ip_vs.h
77788 +++ b/include/net/ip_vs.h
77789 @@ -588,7 +588,7 @@ struct ip_vs_conn {
77790 struct ip_vs_conn *control; /* Master control connection */
77791 atomic_t n_control; /* Number of controlled ones */
77792 struct ip_vs_dest *dest; /* real server */
77793 - atomic_t in_pkts; /* incoming packet counter */
77794 + atomic_unchecked_t in_pkts; /* incoming packet counter */
77795
77796 /* packet transmitter for different forwarding methods. If it
77797 mangles the packet, it must return NF_DROP or better NF_STOLEN,
77798 @@ -737,7 +737,7 @@ struct ip_vs_dest {
77799 __be16 port; /* port number of the server */
77800 union nf_inet_addr addr; /* IP address of the server */
77801 volatile unsigned int flags; /* dest status flags */
77802 - atomic_t conn_flags; /* flags to copy to conn */
77803 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
77804 atomic_t weight; /* server weight */
77805
77806 atomic_t refcnt; /* reference counter */
77807 @@ -993,11 +993,11 @@ struct netns_ipvs {
77808 /* ip_vs_lblc */
77809 int sysctl_lblc_expiration;
77810 struct ctl_table_header *lblc_ctl_header;
77811 - struct ctl_table *lblc_ctl_table;
77812 + ctl_table_no_const *lblc_ctl_table;
77813 /* ip_vs_lblcr */
77814 int sysctl_lblcr_expiration;
77815 struct ctl_table_header *lblcr_ctl_header;
77816 - struct ctl_table *lblcr_ctl_table;
77817 + ctl_table_no_const *lblcr_ctl_table;
77818 /* ip_vs_est */
77819 struct list_head est_list; /* estimator list */
77820 spinlock_t est_lock;
77821 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
77822 index 80ffde3..968b0f4 100644
77823 --- a/include/net/irda/ircomm_tty.h
77824 +++ b/include/net/irda/ircomm_tty.h
77825 @@ -35,6 +35,7 @@
77826 #include <linux/termios.h>
77827 #include <linux/timer.h>
77828 #include <linux/tty.h> /* struct tty_struct */
77829 +#include <asm/local.h>
77830
77831 #include <net/irda/irias_object.h>
77832 #include <net/irda/ircomm_core.h>
77833 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
77834 index 714cc9a..ea05f3e 100644
77835 --- a/include/net/iucv/af_iucv.h
77836 +++ b/include/net/iucv/af_iucv.h
77837 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
77838 struct iucv_sock_list {
77839 struct hlist_head head;
77840 rwlock_t lock;
77841 - atomic_t autobind_name;
77842 + atomic_unchecked_t autobind_name;
77843 };
77844
77845 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
77846 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
77847 index df83f69..9b640b8 100644
77848 --- a/include/net/llc_c_ac.h
77849 +++ b/include/net/llc_c_ac.h
77850 @@ -87,7 +87,7 @@
77851 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
77852 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
77853
77854 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77855 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77856
77857 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
77858 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
77859 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
77860 index 6ca3113..f8026dd 100644
77861 --- a/include/net/llc_c_ev.h
77862 +++ b/include/net/llc_c_ev.h
77863 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
77864 return (struct llc_conn_state_ev *)skb->cb;
77865 }
77866
77867 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77868 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77869 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77870 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77871
77872 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
77873 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
77874 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
77875 index 0e79cfb..f46db31 100644
77876 --- a/include/net/llc_c_st.h
77877 +++ b/include/net/llc_c_st.h
77878 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
77879 u8 next_state;
77880 llc_conn_ev_qfyr_t *ev_qualifiers;
77881 llc_conn_action_t *ev_actions;
77882 -};
77883 +} __do_const;
77884
77885 struct llc_conn_state {
77886 u8 current_state;
77887 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
77888 index 37a3bbd..55a4241 100644
77889 --- a/include/net/llc_s_ac.h
77890 +++ b/include/net/llc_s_ac.h
77891 @@ -23,7 +23,7 @@
77892 #define SAP_ACT_TEST_IND 9
77893
77894 /* All action functions must look like this */
77895 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77896 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77897
77898 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
77899 struct sk_buff *skb);
77900 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
77901 index 567c681..cd73ac0 100644
77902 --- a/include/net/llc_s_st.h
77903 +++ b/include/net/llc_s_st.h
77904 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
77905 llc_sap_ev_t ev;
77906 u8 next_state;
77907 llc_sap_action_t *ev_actions;
77908 -};
77909 +} __do_const;
77910
77911 struct llc_sap_state {
77912 u8 curr_state;
77913 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
77914 index 551ba6a..11c99c1 100644
77915 --- a/include/net/mac80211.h
77916 +++ b/include/net/mac80211.h
77917 @@ -4221,7 +4221,7 @@ struct rate_control_ops {
77918 void (*add_sta_debugfs)(void *priv, void *priv_sta,
77919 struct dentry *dir);
77920 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
77921 -};
77922 +} __do_const;
77923
77924 static inline int rate_supported(struct ieee80211_sta *sta,
77925 enum ieee80211_band band,
77926 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
77927 index 7e748ad..5c6229b 100644
77928 --- a/include/net/neighbour.h
77929 +++ b/include/net/neighbour.h
77930 @@ -123,7 +123,7 @@ struct neigh_ops {
77931 void (*error_report)(struct neighbour *, struct sk_buff *);
77932 int (*output)(struct neighbour *, struct sk_buff *);
77933 int (*connected_output)(struct neighbour *, struct sk_buff *);
77934 -};
77935 +} __do_const;
77936
77937 struct pneigh_entry {
77938 struct pneigh_entry *next;
77939 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
77940 index 84e37b1..8eba19a 100644
77941 --- a/include/net/net_namespace.h
77942 +++ b/include/net/net_namespace.h
77943 @@ -119,8 +119,8 @@ struct net {
77944 struct netns_ipvs *ipvs;
77945 #endif
77946 struct sock *diag_nlsk;
77947 - atomic_t rt_genid;
77948 - atomic_t fnhe_genid;
77949 + atomic_unchecked_t rt_genid;
77950 + atomic_unchecked_t fnhe_genid;
77951 };
77952
77953 /*
77954 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
77955 #define __net_init __init
77956 #define __net_exit __exit_refok
77957 #define __net_initdata __initdata
77958 +#ifdef CONSTIFY_PLUGIN
77959 #define __net_initconst __initconst
77960 +#else
77961 +#define __net_initconst __initdata
77962 +#endif
77963 #endif
77964
77965 struct pernet_operations {
77966 @@ -287,7 +291,7 @@ struct pernet_operations {
77967 void (*exit_batch)(struct list_head *net_exit_list);
77968 int *id;
77969 size_t size;
77970 -};
77971 +} __do_const;
77972
77973 /*
77974 * Use these carefully. If you implement a network device and it
77975 @@ -335,22 +339,22 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
77976
77977 static inline int rt_genid(struct net *net)
77978 {
77979 - return atomic_read(&net->rt_genid);
77980 + return atomic_read_unchecked(&net->rt_genid);
77981 }
77982
77983 static inline void rt_genid_bump(struct net *net)
77984 {
77985 - atomic_inc(&net->rt_genid);
77986 + atomic_inc_unchecked(&net->rt_genid);
77987 }
77988
77989 static inline int fnhe_genid(struct net *net)
77990 {
77991 - return atomic_read(&net->fnhe_genid);
77992 + return atomic_read_unchecked(&net->fnhe_genid);
77993 }
77994
77995 static inline void fnhe_genid_bump(struct net *net)
77996 {
77997 - atomic_inc(&net->fnhe_genid);
77998 + atomic_inc_unchecked(&net->fnhe_genid);
77999 }
78000
78001 #endif /* __NET_NET_NAMESPACE_H */
78002 diff --git a/include/net/netdma.h b/include/net/netdma.h
78003 index 8ba8ce2..99b7fff 100644
78004 --- a/include/net/netdma.h
78005 +++ b/include/net/netdma.h
78006 @@ -24,7 +24,7 @@
78007 #include <linux/dmaengine.h>
78008 #include <linux/skbuff.h>
78009
78010 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78011 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78012 struct sk_buff *skb, int offset, struct iovec *to,
78013 size_t len, struct dma_pinned_list *pinned_list);
78014
78015 diff --git a/include/net/netlink.h b/include/net/netlink.h
78016 index 9690b0f..87aded7 100644
78017 --- a/include/net/netlink.h
78018 +++ b/include/net/netlink.h
78019 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
78020 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
78021 {
78022 if (mark)
78023 - skb_trim(skb, (unsigned char *) mark - skb->data);
78024 + skb_trim(skb, (const unsigned char *) mark - skb->data);
78025 }
78026
78027 /**
78028 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
78029 index c9c0c53..53f24c3 100644
78030 --- a/include/net/netns/conntrack.h
78031 +++ b/include/net/netns/conntrack.h
78032 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
78033 struct nf_proto_net {
78034 #ifdef CONFIG_SYSCTL
78035 struct ctl_table_header *ctl_table_header;
78036 - struct ctl_table *ctl_table;
78037 + ctl_table_no_const *ctl_table;
78038 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
78039 struct ctl_table_header *ctl_compat_header;
78040 - struct ctl_table *ctl_compat_table;
78041 + ctl_table_no_const *ctl_compat_table;
78042 #endif
78043 #endif
78044 unsigned int users;
78045 @@ -58,7 +58,7 @@ struct nf_ip_net {
78046 struct nf_icmp_net icmpv6;
78047 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
78048 struct ctl_table_header *ctl_table_header;
78049 - struct ctl_table *ctl_table;
78050 + ctl_table_no_const *ctl_table;
78051 #endif
78052 };
78053
78054 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
78055 index 2ba9de8..47bd6c7 100644
78056 --- a/include/net/netns/ipv4.h
78057 +++ b/include/net/netns/ipv4.h
78058 @@ -67,7 +67,7 @@ struct netns_ipv4 {
78059 kgid_t sysctl_ping_group_range[2];
78060 long sysctl_tcp_mem[3];
78061
78062 - atomic_t dev_addr_genid;
78063 + atomic_unchecked_t dev_addr_genid;
78064
78065 #ifdef CONFIG_IP_MROUTE
78066 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
78067 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
78068 index 005e2c2..023d340 100644
78069 --- a/include/net/netns/ipv6.h
78070 +++ b/include/net/netns/ipv6.h
78071 @@ -71,7 +71,7 @@ struct netns_ipv6 {
78072 struct fib_rules_ops *mr6_rules_ops;
78073 #endif
78074 #endif
78075 - atomic_t dev_addr_genid;
78076 + atomic_unchecked_t dev_addr_genid;
78077 };
78078
78079 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
78080 diff --git a/include/net/ping.h b/include/net/ping.h
78081 index 5db0224..0d65365 100644
78082 --- a/include/net/ping.h
78083 +++ b/include/net/ping.h
78084 @@ -55,7 +55,7 @@ struct ping_iter_state {
78085 extern struct proto ping_prot;
78086 extern struct ping_table ping_table;
78087 #if IS_ENABLED(CONFIG_IPV6)
78088 -extern struct pingv6_ops pingv6_ops;
78089 +extern struct pingv6_ops *pingv6_ops;
78090 #endif
78091
78092 struct pingfakehdr {
78093 diff --git a/include/net/protocol.h b/include/net/protocol.h
78094 index 047c047..b9dad15 100644
78095 --- a/include/net/protocol.h
78096 +++ b/include/net/protocol.h
78097 @@ -44,7 +44,7 @@ struct net_protocol {
78098 void (*err_handler)(struct sk_buff *skb, u32 info);
78099 unsigned int no_policy:1,
78100 netns_ok:1;
78101 -};
78102 +} __do_const;
78103
78104 #if IS_ENABLED(CONFIG_IPV6)
78105 struct inet6_protocol {
78106 @@ -57,7 +57,7 @@ struct inet6_protocol {
78107 u8 type, u8 code, int offset,
78108 __be32 info);
78109 unsigned int flags; /* INET6_PROTO_xxx */
78110 -};
78111 +} __do_const;
78112
78113 #define INET6_PROTO_NOPOLICY 0x1
78114 #define INET6_PROTO_FINAL 0x2
78115 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
78116 index 7026648..584cc8c 100644
78117 --- a/include/net/rtnetlink.h
78118 +++ b/include/net/rtnetlink.h
78119 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
78120 const struct net_device *dev);
78121 unsigned int (*get_num_tx_queues)(void);
78122 unsigned int (*get_num_rx_queues)(void);
78123 -};
78124 +} __do_const;
78125
78126 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
78127 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
78128 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
78129 index 2a82d13..62a31c2 100644
78130 --- a/include/net/sctp/sm.h
78131 +++ b/include/net/sctp/sm.h
78132 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
78133 typedef struct {
78134 sctp_state_fn_t *fn;
78135 const char *name;
78136 -} sctp_sm_table_entry_t;
78137 +} __do_const sctp_sm_table_entry_t;
78138
78139 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
78140 * currently in use.
78141 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
78142 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
78143
78144 /* Extern declarations for major data structures. */
78145 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78146 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78147
78148
78149 /* Get the size of a DATA chunk payload. */
78150 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
78151 index e745c92..3641448 100644
78152 --- a/include/net/sctp/structs.h
78153 +++ b/include/net/sctp/structs.h
78154 @@ -516,7 +516,7 @@ struct sctp_pf {
78155 struct sctp_association *asoc);
78156 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
78157 struct sctp_af *af;
78158 -};
78159 +} __do_const;
78160
78161
78162 /* Structure to track chunk fragments that have been acked, but peer
78163 diff --git a/include/net/sock.h b/include/net/sock.h
78164 index 04e148f..3b1c7e0 100644
78165 --- a/include/net/sock.h
78166 +++ b/include/net/sock.h
78167 @@ -332,7 +332,7 @@ struct sock {
78168 unsigned int sk_napi_id;
78169 unsigned int sk_ll_usec;
78170 #endif
78171 - atomic_t sk_drops;
78172 + atomic_unchecked_t sk_drops;
78173 int sk_rcvbuf;
78174
78175 struct sk_filter __rcu *sk_filter;
78176 @@ -1805,7 +1805,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
78177 }
78178
78179 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
78180 - char __user *from, char *to,
78181 + char __user *from, unsigned char *to,
78182 int copy, int offset)
78183 {
78184 if (skb->ip_summed == CHECKSUM_NONE) {
78185 @@ -2067,7 +2067,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
78186 }
78187 }
78188
78189 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78190 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78191
78192 /**
78193 * sk_page_frag - return an appropriate page_frag
78194 diff --git a/include/net/tcp.h b/include/net/tcp.h
78195 index 46cb8a4..32b7b4a 100644
78196 --- a/include/net/tcp.h
78197 +++ b/include/net/tcp.h
78198 @@ -522,7 +522,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
78199 extern void tcp_xmit_retransmit_queue(struct sock *);
78200 extern void tcp_simple_retransmit(struct sock *);
78201 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
78202 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78203 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78204
78205 extern void tcp_send_probe0(struct sock *);
78206 extern void tcp_send_partial(struct sock *);
78207 @@ -695,8 +695,8 @@ struct tcp_skb_cb {
78208 struct inet6_skb_parm h6;
78209 #endif
78210 } header; /* For incoming frames */
78211 - __u32 seq; /* Starting sequence number */
78212 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
78213 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
78214 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
78215 __u32 when; /* used to compute rtt's */
78216 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
78217
78218 @@ -710,7 +710,7 @@ struct tcp_skb_cb {
78219
78220 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
78221 /* 1 byte hole */
78222 - __u32 ack_seq; /* Sequence number ACK'd */
78223 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
78224 };
78225
78226 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
78227 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
78228 index e823786..53b0608 100644
78229 --- a/include/net/xfrm.h
78230 +++ b/include/net/xfrm.h
78231 @@ -287,7 +287,6 @@ struct xfrm_dst;
78232 struct xfrm_policy_afinfo {
78233 unsigned short family;
78234 struct dst_ops *dst_ops;
78235 - void (*garbage_collect)(struct net *net);
78236 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
78237 const xfrm_address_t *saddr,
78238 const xfrm_address_t *daddr);
78239 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
78240 struct net_device *dev,
78241 const struct flowi *fl);
78242 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
78243 -};
78244 +} __do_const;
78245
78246 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
78247 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
78248 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
78249 int (*transport_finish)(struct sk_buff *skb,
78250 int async);
78251 void (*local_error)(struct sk_buff *skb, u32 mtu);
78252 -};
78253 +} __do_const;
78254
78255 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
78256 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
78257 @@ -427,7 +426,7 @@ struct xfrm_mode {
78258 struct module *owner;
78259 unsigned int encap;
78260 int flags;
78261 -};
78262 +} __do_const;
78263
78264 /* Flags for xfrm_mode. */
78265 enum {
78266 @@ -524,7 +523,7 @@ struct xfrm_policy {
78267 struct timer_list timer;
78268
78269 struct flow_cache_object flo;
78270 - atomic_t genid;
78271 + atomic_unchecked_t genid;
78272 u32 priority;
78273 u32 index;
78274 struct xfrm_mark mark;
78275 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
78276 }
78277
78278 extern void xfrm_garbage_collect(struct net *net);
78279 +extern void xfrm_garbage_collect_deferred(struct net *net);
78280
78281 #else
78282
78283 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
78284 static inline void xfrm_garbage_collect(struct net *net)
78285 {
78286 }
78287 +static inline void xfrm_garbage_collect_deferred(struct net *net)
78288 +{
78289 +}
78290 #endif
78291
78292 static __inline__
78293 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
78294 index 1a046b1..ee0bef0 100644
78295 --- a/include/rdma/iw_cm.h
78296 +++ b/include/rdma/iw_cm.h
78297 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
78298 int backlog);
78299
78300 int (*destroy_listen)(struct iw_cm_id *cm_id);
78301 -};
78302 +} __no_const;
78303
78304 /**
78305 * iw_create_cm_id - Create an IW CM identifier.
78306 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
78307 index e1379b4..67eafbe 100644
78308 --- a/include/scsi/libfc.h
78309 +++ b/include/scsi/libfc.h
78310 @@ -762,6 +762,7 @@ struct libfc_function_template {
78311 */
78312 void (*disc_stop_final) (struct fc_lport *);
78313 };
78314 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
78315
78316 /**
78317 * struct fc_disc - Discovery context
78318 @@ -866,7 +867,7 @@ struct fc_lport {
78319 struct fc_vport *vport;
78320
78321 /* Operational Information */
78322 - struct libfc_function_template tt;
78323 + libfc_function_template_no_const tt;
78324 u8 link_up;
78325 u8 qfull;
78326 enum fc_lport_state state;
78327 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
78328 index a44954c..5da04b2 100644
78329 --- a/include/scsi/scsi_device.h
78330 +++ b/include/scsi/scsi_device.h
78331 @@ -172,9 +172,9 @@ struct scsi_device {
78332 unsigned int max_device_blocked; /* what device_blocked counts down from */
78333 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
78334
78335 - atomic_t iorequest_cnt;
78336 - atomic_t iodone_cnt;
78337 - atomic_t ioerr_cnt;
78338 + atomic_unchecked_t iorequest_cnt;
78339 + atomic_unchecked_t iodone_cnt;
78340 + atomic_unchecked_t ioerr_cnt;
78341
78342 struct device sdev_gendev,
78343 sdev_dev;
78344 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
78345 index b797e8f..8e2c3aa 100644
78346 --- a/include/scsi/scsi_transport_fc.h
78347 +++ b/include/scsi/scsi_transport_fc.h
78348 @@ -751,7 +751,8 @@ struct fc_function_template {
78349 unsigned long show_host_system_hostname:1;
78350
78351 unsigned long disable_target_scan:1;
78352 -};
78353 +} __do_const;
78354 +typedef struct fc_function_template __no_const fc_function_template_no_const;
78355
78356
78357 /**
78358 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
78359 index 9031a26..750d592 100644
78360 --- a/include/sound/compress_driver.h
78361 +++ b/include/sound/compress_driver.h
78362 @@ -128,7 +128,7 @@ struct snd_compr_ops {
78363 struct snd_compr_caps *caps);
78364 int (*get_codec_caps) (struct snd_compr_stream *stream,
78365 struct snd_compr_codec_caps *codec);
78366 -};
78367 +} __no_const;
78368
78369 /**
78370 * struct snd_compr: Compressed device
78371 diff --git a/include/sound/soc.h b/include/sound/soc.h
78372 index 6eabee7..58afb50 100644
78373 --- a/include/sound/soc.h
78374 +++ b/include/sound/soc.h
78375 @@ -783,7 +783,7 @@ struct snd_soc_codec_driver {
78376 /* probe ordering - for components with runtime dependencies */
78377 int probe_order;
78378 int remove_order;
78379 -};
78380 +} __do_const;
78381
78382 /* SoC platform interface */
78383 struct snd_soc_platform_driver {
78384 @@ -829,7 +829,7 @@ struct snd_soc_platform_driver {
78385 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
78386 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
78387 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
78388 -};
78389 +} __do_const;
78390
78391 struct snd_soc_platform {
78392 const char *name;
78393 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
78394 index e34fc90..ecefa2c 100644
78395 --- a/include/target/target_core_base.h
78396 +++ b/include/target/target_core_base.h
78397 @@ -643,7 +643,7 @@ struct se_device {
78398 spinlock_t stats_lock;
78399 /* Active commands on this virtual SE device */
78400 atomic_t simple_cmds;
78401 - atomic_t dev_ordered_id;
78402 + atomic_unchecked_t dev_ordered_id;
78403 atomic_t dev_ordered_sync;
78404 atomic_t dev_qf_count;
78405 int export_count;
78406 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
78407 new file mode 100644
78408 index 0000000..fb634b7
78409 --- /dev/null
78410 +++ b/include/trace/events/fs.h
78411 @@ -0,0 +1,53 @@
78412 +#undef TRACE_SYSTEM
78413 +#define TRACE_SYSTEM fs
78414 +
78415 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
78416 +#define _TRACE_FS_H
78417 +
78418 +#include <linux/fs.h>
78419 +#include <linux/tracepoint.h>
78420 +
78421 +TRACE_EVENT(do_sys_open,
78422 +
78423 + TP_PROTO(const char *filename, int flags, int mode),
78424 +
78425 + TP_ARGS(filename, flags, mode),
78426 +
78427 + TP_STRUCT__entry(
78428 + __string( filename, filename )
78429 + __field( int, flags )
78430 + __field( int, mode )
78431 + ),
78432 +
78433 + TP_fast_assign(
78434 + __assign_str(filename, filename);
78435 + __entry->flags = flags;
78436 + __entry->mode = mode;
78437 + ),
78438 +
78439 + TP_printk("\"%s\" %x %o",
78440 + __get_str(filename), __entry->flags, __entry->mode)
78441 +);
78442 +
78443 +TRACE_EVENT(open_exec,
78444 +
78445 + TP_PROTO(const char *filename),
78446 +
78447 + TP_ARGS(filename),
78448 +
78449 + TP_STRUCT__entry(
78450 + __string( filename, filename )
78451 + ),
78452 +
78453 + TP_fast_assign(
78454 + __assign_str(filename, filename);
78455 + ),
78456 +
78457 + TP_printk("\"%s\"",
78458 + __get_str(filename))
78459 +);
78460 +
78461 +#endif /* _TRACE_FS_H */
78462 +
78463 +/* This part must be outside protection */
78464 +#include <trace/define_trace.h>
78465 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
78466 index 1c09820..7f5ec79 100644
78467 --- a/include/trace/events/irq.h
78468 +++ b/include/trace/events/irq.h
78469 @@ -36,7 +36,7 @@ struct softirq_action;
78470 */
78471 TRACE_EVENT(irq_handler_entry,
78472
78473 - TP_PROTO(int irq, struct irqaction *action),
78474 + TP_PROTO(int irq, const struct irqaction *action),
78475
78476 TP_ARGS(irq, action),
78477
78478 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
78479 */
78480 TRACE_EVENT(irq_handler_exit,
78481
78482 - TP_PROTO(int irq, struct irqaction *action, int ret),
78483 + TP_PROTO(int irq, const struct irqaction *action, int ret),
78484
78485 TP_ARGS(irq, action, ret),
78486
78487 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
78488 index 7caf44c..23c6f27 100644
78489 --- a/include/uapi/linux/a.out.h
78490 +++ b/include/uapi/linux/a.out.h
78491 @@ -39,6 +39,14 @@ enum machine_type {
78492 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
78493 };
78494
78495 +/* Constants for the N_FLAGS field */
78496 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78497 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
78498 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
78499 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
78500 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78501 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78502 +
78503 #if !defined (N_MAGIC)
78504 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
78505 #endif
78506 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
78507 index d876736..ccce5c0 100644
78508 --- a/include/uapi/linux/byteorder/little_endian.h
78509 +++ b/include/uapi/linux/byteorder/little_endian.h
78510 @@ -42,51 +42,51 @@
78511
78512 static inline __le64 __cpu_to_le64p(const __u64 *p)
78513 {
78514 - return (__force __le64)*p;
78515 + return (__force const __le64)*p;
78516 }
78517 -static inline __u64 __le64_to_cpup(const __le64 *p)
78518 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
78519 {
78520 - return (__force __u64)*p;
78521 + return (__force const __u64)*p;
78522 }
78523 static inline __le32 __cpu_to_le32p(const __u32 *p)
78524 {
78525 - return (__force __le32)*p;
78526 + return (__force const __le32)*p;
78527 }
78528 static inline __u32 __le32_to_cpup(const __le32 *p)
78529 {
78530 - return (__force __u32)*p;
78531 + return (__force const __u32)*p;
78532 }
78533 static inline __le16 __cpu_to_le16p(const __u16 *p)
78534 {
78535 - return (__force __le16)*p;
78536 + return (__force const __le16)*p;
78537 }
78538 static inline __u16 __le16_to_cpup(const __le16 *p)
78539 {
78540 - return (__force __u16)*p;
78541 + return (__force const __u16)*p;
78542 }
78543 static inline __be64 __cpu_to_be64p(const __u64 *p)
78544 {
78545 - return (__force __be64)__swab64p(p);
78546 + return (__force const __be64)__swab64p(p);
78547 }
78548 static inline __u64 __be64_to_cpup(const __be64 *p)
78549 {
78550 - return __swab64p((__u64 *)p);
78551 + return __swab64p((const __u64 *)p);
78552 }
78553 static inline __be32 __cpu_to_be32p(const __u32 *p)
78554 {
78555 - return (__force __be32)__swab32p(p);
78556 + return (__force const __be32)__swab32p(p);
78557 }
78558 -static inline __u32 __be32_to_cpup(const __be32 *p)
78559 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
78560 {
78561 - return __swab32p((__u32 *)p);
78562 + return __swab32p((const __u32 *)p);
78563 }
78564 static inline __be16 __cpu_to_be16p(const __u16 *p)
78565 {
78566 - return (__force __be16)__swab16p(p);
78567 + return (__force const __be16)__swab16p(p);
78568 }
78569 static inline __u16 __be16_to_cpup(const __be16 *p)
78570 {
78571 - return __swab16p((__u16 *)p);
78572 + return __swab16p((const __u16 *)p);
78573 }
78574 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
78575 #define __le64_to_cpus(x) do { (void)(x); } while (0)
78576 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
78577 index ef6103b..d4e65dd 100644
78578 --- a/include/uapi/linux/elf.h
78579 +++ b/include/uapi/linux/elf.h
78580 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
78581 #define PT_GNU_EH_FRAME 0x6474e550
78582
78583 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
78584 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
78585 +
78586 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
78587 +
78588 +/* Constants for the e_flags field */
78589 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78590 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
78591 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
78592 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
78593 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78594 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78595
78596 /*
78597 * Extended Numbering
78598 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
78599 #define DT_DEBUG 21
78600 #define DT_TEXTREL 22
78601 #define DT_JMPREL 23
78602 +#define DT_FLAGS 30
78603 + #define DF_TEXTREL 0x00000004
78604 #define DT_ENCODING 32
78605 #define OLD_DT_LOOS 0x60000000
78606 #define DT_LOOS 0x6000000d
78607 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
78608 #define PF_W 0x2
78609 #define PF_X 0x1
78610
78611 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
78612 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
78613 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
78614 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
78615 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
78616 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
78617 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
78618 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
78619 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
78620 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
78621 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
78622 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
78623 +
78624 typedef struct elf32_phdr{
78625 Elf32_Word p_type;
78626 Elf32_Off p_offset;
78627 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
78628 #define EI_OSABI 7
78629 #define EI_PAD 8
78630
78631 +#define EI_PAX 14
78632 +
78633 #define ELFMAG0 0x7f /* EI_MAG */
78634 #define ELFMAG1 'E'
78635 #define ELFMAG2 'L'
78636 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
78637 index aa169c4..6a2771d 100644
78638 --- a/include/uapi/linux/personality.h
78639 +++ b/include/uapi/linux/personality.h
78640 @@ -30,6 +30,7 @@ enum {
78641 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
78642 ADDR_NO_RANDOMIZE | \
78643 ADDR_COMPAT_LAYOUT | \
78644 + ADDR_LIMIT_3GB | \
78645 MMAP_PAGE_ZERO)
78646
78647 /*
78648 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
78649 index 7530e74..e714828 100644
78650 --- a/include/uapi/linux/screen_info.h
78651 +++ b/include/uapi/linux/screen_info.h
78652 @@ -43,7 +43,8 @@ struct screen_info {
78653 __u16 pages; /* 0x32 */
78654 __u16 vesa_attributes; /* 0x34 */
78655 __u32 capabilities; /* 0x36 */
78656 - __u8 _reserved[6]; /* 0x3a */
78657 + __u16 vesapm_size; /* 0x3a */
78658 + __u8 _reserved[4]; /* 0x3c */
78659 } __attribute__((packed));
78660
78661 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
78662 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
78663 index 0e011eb..82681b1 100644
78664 --- a/include/uapi/linux/swab.h
78665 +++ b/include/uapi/linux/swab.h
78666 @@ -43,7 +43,7 @@
78667 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
78668 */
78669
78670 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
78671 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
78672 {
78673 #ifdef __HAVE_BUILTIN_BSWAP16__
78674 return __builtin_bswap16(val);
78675 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
78676 #endif
78677 }
78678
78679 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
78680 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
78681 {
78682 #ifdef __HAVE_BUILTIN_BSWAP32__
78683 return __builtin_bswap32(val);
78684 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
78685 #endif
78686 }
78687
78688 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
78689 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
78690 {
78691 #ifdef __HAVE_BUILTIN_BSWAP64__
78692 return __builtin_bswap64(val);
78693 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
78694 index 6d67213..8dab561 100644
78695 --- a/include/uapi/linux/sysctl.h
78696 +++ b/include/uapi/linux/sysctl.h
78697 @@ -155,7 +155,11 @@ enum
78698 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
78699 };
78700
78701 -
78702 +#ifdef CONFIG_PAX_SOFTMODE
78703 +enum {
78704 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
78705 +};
78706 +#endif
78707
78708 /* CTL_VM names: */
78709 enum
78710 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
78711 index e4629b9..6958086 100644
78712 --- a/include/uapi/linux/xattr.h
78713 +++ b/include/uapi/linux/xattr.h
78714 @@ -63,5 +63,9 @@
78715 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
78716 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
78717
78718 +/* User namespace */
78719 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
78720 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
78721 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
78722
78723 #endif /* _UAPI_LINUX_XATTR_H */
78724 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
78725 index f9466fa..f4e2b81 100644
78726 --- a/include/video/udlfb.h
78727 +++ b/include/video/udlfb.h
78728 @@ -53,10 +53,10 @@ struct dlfb_data {
78729 u32 pseudo_palette[256];
78730 int blank_mode; /*one of FB_BLANK_ */
78731 /* blit-only rendering path metrics, exposed through sysfs */
78732 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78733 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
78734 - atomic_t bytes_sent; /* to usb, after compression including overhead */
78735 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
78736 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78737 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
78738 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
78739 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
78740 };
78741
78742 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
78743 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
78744 index 30f5362..8ed8ac9 100644
78745 --- a/include/video/uvesafb.h
78746 +++ b/include/video/uvesafb.h
78747 @@ -122,6 +122,7 @@ struct uvesafb_par {
78748 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
78749 u8 pmi_setpal; /* PMI for palette changes */
78750 u16 *pmi_base; /* protected mode interface location */
78751 + u8 *pmi_code; /* protected mode code location */
78752 void *pmi_start;
78753 void *pmi_pal;
78754 u8 *vbe_state_orig; /*
78755 diff --git a/init/Kconfig b/init/Kconfig
78756 index fed81b5..0d3b964 100644
78757 --- a/init/Kconfig
78758 +++ b/init/Kconfig
78759 @@ -1069,6 +1069,7 @@ endif # CGROUPS
78760
78761 config CHECKPOINT_RESTORE
78762 bool "Checkpoint/restore support" if EXPERT
78763 + depends on !GRKERNSEC
78764 default n
78765 help
78766 Enables additional kernel features in a sake of checkpoint/restore.
78767 @@ -1553,7 +1554,7 @@ config SLUB_DEBUG
78768
78769 config COMPAT_BRK
78770 bool "Disable heap randomization"
78771 - default y
78772 + default n
78773 help
78774 Randomizing heap placement makes heap exploits harder, but it
78775 also breaks ancient binaries (including anything libc5 based).
78776 @@ -1827,7 +1828,7 @@ config INIT_ALL_POSSIBLE
78777 config STOP_MACHINE
78778 bool
78779 default y
78780 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
78781 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
78782 help
78783 Need stop_machine() primitive.
78784
78785 diff --git a/init/Makefile b/init/Makefile
78786 index 7bc47ee..6da2dc7 100644
78787 --- a/init/Makefile
78788 +++ b/init/Makefile
78789 @@ -2,6 +2,9 @@
78790 # Makefile for the linux kernel.
78791 #
78792
78793 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
78794 +asflags-y := $(GCC_PLUGINS_AFLAGS)
78795 +
78796 obj-y := main.o version.o mounts.o
78797 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
78798 obj-y += noinitramfs.o
78799 diff --git a/init/do_mounts.c b/init/do_mounts.c
78800 index 816014c..c2054db 100644
78801 --- a/init/do_mounts.c
78802 +++ b/init/do_mounts.c
78803 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
78804 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
78805 {
78806 struct super_block *s;
78807 - int err = sys_mount(name, "/root", fs, flags, data);
78808 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
78809 if (err)
78810 return err;
78811
78812 - sys_chdir("/root");
78813 + sys_chdir((const char __force_user *)"/root");
78814 s = current->fs->pwd.dentry->d_sb;
78815 ROOT_DEV = s->s_dev;
78816 printk(KERN_INFO
78817 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
78818 va_start(args, fmt);
78819 vsprintf(buf, fmt, args);
78820 va_end(args);
78821 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
78822 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
78823 if (fd >= 0) {
78824 sys_ioctl(fd, FDEJECT, 0);
78825 sys_close(fd);
78826 }
78827 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
78828 - fd = sys_open("/dev/console", O_RDWR, 0);
78829 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
78830 if (fd >= 0) {
78831 sys_ioctl(fd, TCGETS, (long)&termios);
78832 termios.c_lflag &= ~ICANON;
78833 sys_ioctl(fd, TCSETSF, (long)&termios);
78834 - sys_read(fd, &c, 1);
78835 + sys_read(fd, (char __user *)&c, 1);
78836 termios.c_lflag |= ICANON;
78837 sys_ioctl(fd, TCSETSF, (long)&termios);
78838 sys_close(fd);
78839 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
78840 mount_root();
78841 out:
78842 devtmpfs_mount("dev");
78843 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78844 - sys_chroot(".");
78845 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78846 + sys_chroot((const char __force_user *)".");
78847 }
78848 diff --git a/init/do_mounts.h b/init/do_mounts.h
78849 index f5b978a..69dbfe8 100644
78850 --- a/init/do_mounts.h
78851 +++ b/init/do_mounts.h
78852 @@ -15,15 +15,15 @@ extern int root_mountflags;
78853
78854 static inline int create_dev(char *name, dev_t dev)
78855 {
78856 - sys_unlink(name);
78857 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
78858 + sys_unlink((char __force_user *)name);
78859 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
78860 }
78861
78862 #if BITS_PER_LONG == 32
78863 static inline u32 bstat(char *name)
78864 {
78865 struct stat64 stat;
78866 - if (sys_stat64(name, &stat) != 0)
78867 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
78868 return 0;
78869 if (!S_ISBLK(stat.st_mode))
78870 return 0;
78871 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
78872 static inline u32 bstat(char *name)
78873 {
78874 struct stat stat;
78875 - if (sys_newstat(name, &stat) != 0)
78876 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
78877 return 0;
78878 if (!S_ISBLK(stat.st_mode))
78879 return 0;
78880 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
78881 index 3e0878e..8a9d7a0 100644
78882 --- a/init/do_mounts_initrd.c
78883 +++ b/init/do_mounts_initrd.c
78884 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
78885 {
78886 sys_unshare(CLONE_FS | CLONE_FILES);
78887 /* stdin/stdout/stderr for /linuxrc */
78888 - sys_open("/dev/console", O_RDWR, 0);
78889 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
78890 sys_dup(0);
78891 sys_dup(0);
78892 /* move initrd over / and chdir/chroot in initrd root */
78893 - sys_chdir("/root");
78894 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78895 - sys_chroot(".");
78896 + sys_chdir((const char __force_user *)"/root");
78897 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78898 + sys_chroot((const char __force_user *)".");
78899 sys_setsid();
78900 return 0;
78901 }
78902 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
78903 create_dev("/dev/root.old", Root_RAM0);
78904 /* mount initrd on rootfs' /root */
78905 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
78906 - sys_mkdir("/old", 0700);
78907 - sys_chdir("/old");
78908 + sys_mkdir((const char __force_user *)"/old", 0700);
78909 + sys_chdir((const char __force_user *)"/old");
78910
78911 /* try loading default modules from initrd */
78912 load_default_modules();
78913 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
78914 current->flags &= ~PF_FREEZER_SKIP;
78915
78916 /* move initrd to rootfs' /old */
78917 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
78918 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
78919 /* switch root and cwd back to / of rootfs */
78920 - sys_chroot("..");
78921 + sys_chroot((const char __force_user *)"..");
78922
78923 if (new_decode_dev(real_root_dev) == Root_RAM0) {
78924 - sys_chdir("/old");
78925 + sys_chdir((const char __force_user *)"/old");
78926 return;
78927 }
78928
78929 - sys_chdir("/");
78930 + sys_chdir((const char __force_user *)"/");
78931 ROOT_DEV = new_decode_dev(real_root_dev);
78932 mount_root();
78933
78934 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
78935 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
78936 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
78937 if (!error)
78938 printk("okay\n");
78939 else {
78940 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
78941 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
78942 if (error == -ENOENT)
78943 printk("/initrd does not exist. Ignored.\n");
78944 else
78945 printk("failed\n");
78946 printk(KERN_NOTICE "Unmounting old root\n");
78947 - sys_umount("/old", MNT_DETACH);
78948 + sys_umount((char __force_user *)"/old", MNT_DETACH);
78949 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
78950 if (fd < 0) {
78951 error = fd;
78952 @@ -127,11 +127,11 @@ int __init initrd_load(void)
78953 * mounted in the normal path.
78954 */
78955 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
78956 - sys_unlink("/initrd.image");
78957 + sys_unlink((const char __force_user *)"/initrd.image");
78958 handle_initrd();
78959 return 1;
78960 }
78961 }
78962 - sys_unlink("/initrd.image");
78963 + sys_unlink((const char __force_user *)"/initrd.image");
78964 return 0;
78965 }
78966 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
78967 index 8cb6db5..d729f50 100644
78968 --- a/init/do_mounts_md.c
78969 +++ b/init/do_mounts_md.c
78970 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
78971 partitioned ? "_d" : "", minor,
78972 md_setup_args[ent].device_names);
78973
78974 - fd = sys_open(name, 0, 0);
78975 + fd = sys_open((char __force_user *)name, 0, 0);
78976 if (fd < 0) {
78977 printk(KERN_ERR "md: open failed - cannot start "
78978 "array %s\n", name);
78979 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
78980 * array without it
78981 */
78982 sys_close(fd);
78983 - fd = sys_open(name, 0, 0);
78984 + fd = sys_open((char __force_user *)name, 0, 0);
78985 sys_ioctl(fd, BLKRRPART, 0);
78986 }
78987 sys_close(fd);
78988 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
78989
78990 wait_for_device_probe();
78991
78992 - fd = sys_open("/dev/md0", 0, 0);
78993 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
78994 if (fd >= 0) {
78995 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
78996 sys_close(fd);
78997 diff --git a/init/init_task.c b/init/init_task.c
78998 index ba0a7f36..2bcf1d5 100644
78999 --- a/init/init_task.c
79000 +++ b/init/init_task.c
79001 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
79002 * Initial thread structure. Alignment of this is handled by a special
79003 * linker map entry.
79004 */
79005 +#ifdef CONFIG_X86
79006 +union thread_union init_thread_union __init_task_data;
79007 +#else
79008 union thread_union init_thread_union __init_task_data =
79009 { INIT_THREAD_INFO(init_task) };
79010 +#endif
79011 diff --git a/init/initramfs.c b/init/initramfs.c
79012 index a67ef9d..2d17ed9 100644
79013 --- a/init/initramfs.c
79014 +++ b/init/initramfs.c
79015 @@ -84,7 +84,7 @@ static void __init free_hash(void)
79016 }
79017 }
79018
79019 -static long __init do_utime(char *filename, time_t mtime)
79020 +static long __init do_utime(char __force_user *filename, time_t mtime)
79021 {
79022 struct timespec t[2];
79023
79024 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
79025 struct dir_entry *de, *tmp;
79026 list_for_each_entry_safe(de, tmp, &dir_list, list) {
79027 list_del(&de->list);
79028 - do_utime(de->name, de->mtime);
79029 + do_utime((char __force_user *)de->name, de->mtime);
79030 kfree(de->name);
79031 kfree(de);
79032 }
79033 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
79034 if (nlink >= 2) {
79035 char *old = find_link(major, minor, ino, mode, collected);
79036 if (old)
79037 - return (sys_link(old, collected) < 0) ? -1 : 1;
79038 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
79039 }
79040 return 0;
79041 }
79042 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
79043 {
79044 struct stat st;
79045
79046 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
79047 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
79048 if (S_ISDIR(st.st_mode))
79049 - sys_rmdir(path);
79050 + sys_rmdir((char __force_user *)path);
79051 else
79052 - sys_unlink(path);
79053 + sys_unlink((char __force_user *)path);
79054 }
79055 }
79056
79057 @@ -315,7 +315,7 @@ static int __init do_name(void)
79058 int openflags = O_WRONLY|O_CREAT;
79059 if (ml != 1)
79060 openflags |= O_TRUNC;
79061 - wfd = sys_open(collected, openflags, mode);
79062 + wfd = sys_open((char __force_user *)collected, openflags, mode);
79063
79064 if (wfd >= 0) {
79065 sys_fchown(wfd, uid, gid);
79066 @@ -327,17 +327,17 @@ static int __init do_name(void)
79067 }
79068 }
79069 } else if (S_ISDIR(mode)) {
79070 - sys_mkdir(collected, mode);
79071 - sys_chown(collected, uid, gid);
79072 - sys_chmod(collected, mode);
79073 + sys_mkdir((char __force_user *)collected, mode);
79074 + sys_chown((char __force_user *)collected, uid, gid);
79075 + sys_chmod((char __force_user *)collected, mode);
79076 dir_add(collected, mtime);
79077 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
79078 S_ISFIFO(mode) || S_ISSOCK(mode)) {
79079 if (maybe_link() == 0) {
79080 - sys_mknod(collected, mode, rdev);
79081 - sys_chown(collected, uid, gid);
79082 - sys_chmod(collected, mode);
79083 - do_utime(collected, mtime);
79084 + sys_mknod((char __force_user *)collected, mode, rdev);
79085 + sys_chown((char __force_user *)collected, uid, gid);
79086 + sys_chmod((char __force_user *)collected, mode);
79087 + do_utime((char __force_user *)collected, mtime);
79088 }
79089 }
79090 return 0;
79091 @@ -346,15 +346,15 @@ static int __init do_name(void)
79092 static int __init do_copy(void)
79093 {
79094 if (count >= body_len) {
79095 - sys_write(wfd, victim, body_len);
79096 + sys_write(wfd, (char __force_user *)victim, body_len);
79097 sys_close(wfd);
79098 - do_utime(vcollected, mtime);
79099 + do_utime((char __force_user *)vcollected, mtime);
79100 kfree(vcollected);
79101 eat(body_len);
79102 state = SkipIt;
79103 return 0;
79104 } else {
79105 - sys_write(wfd, victim, count);
79106 + sys_write(wfd, (char __force_user *)victim, count);
79107 body_len -= count;
79108 eat(count);
79109 return 1;
79110 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
79111 {
79112 collected[N_ALIGN(name_len) + body_len] = '\0';
79113 clean_path(collected, 0);
79114 - sys_symlink(collected + N_ALIGN(name_len), collected);
79115 - sys_lchown(collected, uid, gid);
79116 - do_utime(collected, mtime);
79117 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
79118 + sys_lchown((char __force_user *)collected, uid, gid);
79119 + do_utime((char __force_user *)collected, mtime);
79120 state = SkipIt;
79121 next_state = Reset;
79122 return 0;
79123 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
79124 {
79125 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
79126 if (err)
79127 - panic(err); /* Failed to decompress INTERNAL initramfs */
79128 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
79129 if (initrd_start) {
79130 #ifdef CONFIG_BLK_DEV_RAM
79131 int fd;
79132 diff --git a/init/main.c b/init/main.c
79133 index 586cd33..f1af30f 100644
79134 --- a/init/main.c
79135 +++ b/init/main.c
79136 @@ -102,6 +102,8 @@ static inline void mark_rodata_ro(void) { }
79137 extern void tc_init(void);
79138 #endif
79139
79140 +extern void grsecurity_init(void);
79141 +
79142 /*
79143 * Debug helper: via this flag we know that we are in 'early bootup code'
79144 * where only the boot processor is running with IRQ disabled. This means
79145 @@ -155,6 +157,74 @@ static int __init set_reset_devices(char *str)
79146
79147 __setup("reset_devices", set_reset_devices);
79148
79149 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
79150 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
79151 +static int __init setup_grsec_proc_gid(char *str)
79152 +{
79153 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
79154 + return 1;
79155 +}
79156 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
79157 +#endif
79158 +
79159 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
79160 +unsigned long pax_user_shadow_base __read_only;
79161 +EXPORT_SYMBOL(pax_user_shadow_base);
79162 +extern char pax_enter_kernel_user[];
79163 +extern char pax_exit_kernel_user[];
79164 +#endif
79165 +
79166 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
79167 +static int __init setup_pax_nouderef(char *str)
79168 +{
79169 +#ifdef CONFIG_X86_32
79170 + unsigned int cpu;
79171 + struct desc_struct *gdt;
79172 +
79173 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
79174 + gdt = get_cpu_gdt_table(cpu);
79175 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
79176 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
79177 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
79178 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
79179 + }
79180 + loadsegment(ds, __KERNEL_DS);
79181 + loadsegment(es, __KERNEL_DS);
79182 + loadsegment(ss, __KERNEL_DS);
79183 +#else
79184 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
79185 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
79186 + clone_pgd_mask = ~(pgdval_t)0UL;
79187 + pax_user_shadow_base = 0UL;
79188 + setup_clear_cpu_cap(X86_FEATURE_PCID);
79189 +#endif
79190 +
79191 + return 0;
79192 +}
79193 +early_param("pax_nouderef", setup_pax_nouderef);
79194 +
79195 +#ifdef CONFIG_X86_64
79196 +static int __init setup_pax_weakuderef(char *str)
79197 +{
79198 + if (clone_pgd_mask != ~(pgdval_t)0UL)
79199 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
79200 + return 1;
79201 +}
79202 +__setup("pax_weakuderef", setup_pax_weakuderef);
79203 +#endif
79204 +#endif
79205 +
79206 +#ifdef CONFIG_PAX_SOFTMODE
79207 +int pax_softmode;
79208 +
79209 +static int __init setup_pax_softmode(char *str)
79210 +{
79211 + get_option(&str, &pax_softmode);
79212 + return 1;
79213 +}
79214 +__setup("pax_softmode=", setup_pax_softmode);
79215 +#endif
79216 +
79217 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
79218 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
79219 static const char *panic_later, *panic_param;
79220 @@ -680,25 +750,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
79221 {
79222 int count = preempt_count();
79223 int ret;
79224 - char msgbuf[64];
79225 + const char *msg1 = "", *msg2 = "";
79226
79227 if (initcall_debug)
79228 ret = do_one_initcall_debug(fn);
79229 else
79230 ret = fn();
79231
79232 - msgbuf[0] = 0;
79233 -
79234 if (preempt_count() != count) {
79235 - sprintf(msgbuf, "preemption imbalance ");
79236 + msg1 = " preemption imbalance";
79237 preempt_count() = count;
79238 }
79239 if (irqs_disabled()) {
79240 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
79241 + msg2 = " disabled interrupts";
79242 local_irq_enable();
79243 }
79244 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
79245 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
79246
79247 + add_latent_entropy();
79248 return ret;
79249 }
79250
79251 @@ -805,8 +874,8 @@ static int run_init_process(const char *init_filename)
79252 {
79253 argv_init[0] = init_filename;
79254 return do_execve(init_filename,
79255 - (const char __user *const __user *)argv_init,
79256 - (const char __user *const __user *)envp_init);
79257 + (const char __user *const __force_user *)argv_init,
79258 + (const char __user *const __force_user *)envp_init);
79259 }
79260
79261 static noinline void __init kernel_init_freeable(void);
79262 @@ -883,7 +952,7 @@ static noinline void __init kernel_init_freeable(void)
79263 do_basic_setup();
79264
79265 /* Open the /dev/console on the rootfs, this should never fail */
79266 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
79267 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
79268 pr_err("Warning: unable to open an initial console.\n");
79269
79270 (void) sys_dup(0);
79271 @@ -896,11 +965,13 @@ static noinline void __init kernel_init_freeable(void)
79272 if (!ramdisk_execute_command)
79273 ramdisk_execute_command = "/init";
79274
79275 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
79276 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
79277 ramdisk_execute_command = NULL;
79278 prepare_namespace();
79279 }
79280
79281 + grsecurity_init();
79282 +
79283 /*
79284 * Ok, we have completed the initial bootup, and
79285 * we're essentially up and running. Get rid of the
79286 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
79287 index 130dfec..cc88451 100644
79288 --- a/ipc/ipc_sysctl.c
79289 +++ b/ipc/ipc_sysctl.c
79290 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
79291 static int proc_ipc_dointvec(ctl_table *table, int write,
79292 void __user *buffer, size_t *lenp, loff_t *ppos)
79293 {
79294 - struct ctl_table ipc_table;
79295 + ctl_table_no_const ipc_table;
79296
79297 memcpy(&ipc_table, table, sizeof(ipc_table));
79298 ipc_table.data = get_ipc(table);
79299 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
79300 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
79301 void __user *buffer, size_t *lenp, loff_t *ppos)
79302 {
79303 - struct ctl_table ipc_table;
79304 + ctl_table_no_const ipc_table;
79305
79306 memcpy(&ipc_table, table, sizeof(ipc_table));
79307 ipc_table.data = get_ipc(table);
79308 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
79309 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79310 void __user *buffer, size_t *lenp, loff_t *ppos)
79311 {
79312 - struct ctl_table ipc_table;
79313 + ctl_table_no_const ipc_table;
79314 size_t lenp_bef = *lenp;
79315 int rc;
79316
79317 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79318 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
79319 void __user *buffer, size_t *lenp, loff_t *ppos)
79320 {
79321 - struct ctl_table ipc_table;
79322 + ctl_table_no_const ipc_table;
79323 memcpy(&ipc_table, table, sizeof(ipc_table));
79324 ipc_table.data = get_ipc(table);
79325
79326 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
79327 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
79328 void __user *buffer, size_t *lenp, loff_t *ppos)
79329 {
79330 - struct ctl_table ipc_table;
79331 + ctl_table_no_const ipc_table;
79332 size_t lenp_bef = *lenp;
79333 int oldval;
79334 int rc;
79335 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
79336 index 383d638..943fdbb 100644
79337 --- a/ipc/mq_sysctl.c
79338 +++ b/ipc/mq_sysctl.c
79339 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
79340 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
79341 void __user *buffer, size_t *lenp, loff_t *ppos)
79342 {
79343 - struct ctl_table mq_table;
79344 + ctl_table_no_const mq_table;
79345 memcpy(&mq_table, table, sizeof(mq_table));
79346 mq_table.data = get_mq(table);
79347
79348 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
79349 index ae1996d..a35f2cc 100644
79350 --- a/ipc/mqueue.c
79351 +++ b/ipc/mqueue.c
79352 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
79353 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
79354 info->attr.mq_msgsize);
79355
79356 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
79357 spin_lock(&mq_lock);
79358 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
79359 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
79360 diff --git a/ipc/msg.c b/ipc/msg.c
79361 index 558aa91..359e718 100644
79362 --- a/ipc/msg.c
79363 +++ b/ipc/msg.c
79364 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
79365 return security_msg_queue_associate(msq, msgflg);
79366 }
79367
79368 +static struct ipc_ops msg_ops = {
79369 + .getnew = newque,
79370 + .associate = msg_security,
79371 + .more_checks = NULL
79372 +};
79373 +
79374 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
79375 {
79376 struct ipc_namespace *ns;
79377 - struct ipc_ops msg_ops;
79378 struct ipc_params msg_params;
79379
79380 ns = current->nsproxy->ipc_ns;
79381
79382 - msg_ops.getnew = newque;
79383 - msg_ops.associate = msg_security;
79384 - msg_ops.more_checks = NULL;
79385 -
79386 msg_params.key = key;
79387 msg_params.flg = msgflg;
79388
79389 diff --git a/ipc/sem.c b/ipc/sem.c
79390 index 8e2bf30..a711151 100644
79391 --- a/ipc/sem.c
79392 +++ b/ipc/sem.c
79393 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
79394 return 0;
79395 }
79396
79397 +static struct ipc_ops sem_ops = {
79398 + .getnew = newary,
79399 + .associate = sem_security,
79400 + .more_checks = sem_more_checks
79401 +};
79402 +
79403 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79404 {
79405 struct ipc_namespace *ns;
79406 - struct ipc_ops sem_ops;
79407 struct ipc_params sem_params;
79408
79409 ns = current->nsproxy->ipc_ns;
79410 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79411 if (nsems < 0 || nsems > ns->sc_semmsl)
79412 return -EINVAL;
79413
79414 - sem_ops.getnew = newary;
79415 - sem_ops.associate = sem_security;
79416 - sem_ops.more_checks = sem_more_checks;
79417 -
79418 sem_params.key = key;
79419 sem_params.flg = semflg;
79420 sem_params.u.nsems = nsems;
79421 diff --git a/ipc/shm.c b/ipc/shm.c
79422 index d697396..40e887d 100644
79423 --- a/ipc/shm.c
79424 +++ b/ipc/shm.c
79425 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
79426 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
79427 #endif
79428
79429 +#ifdef CONFIG_GRKERNSEC
79430 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79431 + const time_t shm_createtime, const kuid_t cuid,
79432 + const int shmid);
79433 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79434 + const time_t shm_createtime);
79435 +#endif
79436 +
79437 void shm_init_ns(struct ipc_namespace *ns)
79438 {
79439 ns->shm_ctlmax = SHMMAX;
79440 @@ -551,6 +559,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
79441 shp->shm_lprid = 0;
79442 shp->shm_atim = shp->shm_dtim = 0;
79443 shp->shm_ctim = get_seconds();
79444 +#ifdef CONFIG_GRKERNSEC
79445 + {
79446 + struct timespec timeval;
79447 + do_posix_clock_monotonic_gettime(&timeval);
79448 +
79449 + shp->shm_createtime = timeval.tv_sec;
79450 + }
79451 +#endif
79452 shp->shm_segsz = size;
79453 shp->shm_nattch = 0;
79454 shp->shm_file = file;
79455 @@ -604,18 +620,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
79456 return 0;
79457 }
79458
79459 +static struct ipc_ops shm_ops = {
79460 + .getnew = newseg,
79461 + .associate = shm_security,
79462 + .more_checks = shm_more_checks
79463 +};
79464 +
79465 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
79466 {
79467 struct ipc_namespace *ns;
79468 - struct ipc_ops shm_ops;
79469 struct ipc_params shm_params;
79470
79471 ns = current->nsproxy->ipc_ns;
79472
79473 - shm_ops.getnew = newseg;
79474 - shm_ops.associate = shm_security;
79475 - shm_ops.more_checks = shm_more_checks;
79476 -
79477 shm_params.key = key;
79478 shm_params.flg = shmflg;
79479 shm_params.u.size = size;
79480 @@ -1076,6 +1093,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79481 f_mode = FMODE_READ | FMODE_WRITE;
79482 }
79483 if (shmflg & SHM_EXEC) {
79484 +
79485 +#ifdef CONFIG_PAX_MPROTECT
79486 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
79487 + goto out;
79488 +#endif
79489 +
79490 prot |= PROT_EXEC;
79491 acc_mode |= S_IXUGO;
79492 }
79493 @@ -1100,10 +1123,22 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79494 if (err)
79495 goto out_unlock;
79496
79497 +#ifdef CONFIG_GRKERNSEC
79498 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
79499 + shp->shm_perm.cuid, shmid) ||
79500 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
79501 + err = -EACCES;
79502 + goto out_unlock;
79503 + }
79504 +#endif
79505 +
79506 ipc_lock_object(&shp->shm_perm);
79507 path = shp->shm_file->f_path;
79508 path_get(&path);
79509 shp->shm_nattch++;
79510 +#ifdef CONFIG_GRKERNSEC
79511 + shp->shm_lapid = current->pid;
79512 +#endif
79513 size = i_size_read(path.dentry->d_inode);
79514 ipc_unlock_object(&shp->shm_perm);
79515 rcu_read_unlock();
79516 diff --git a/ipc/util.c b/ipc/util.c
79517 index fdb8ae7..f1cb373 100644
79518 --- a/ipc/util.c
79519 +++ b/ipc/util.c
79520 @@ -56,6 +56,8 @@ struct ipc_proc_iface {
79521 int (*show)(struct seq_file *, void *);
79522 };
79523
79524 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
79525 +
79526 static void ipc_memory_notifier(struct work_struct *work)
79527 {
79528 ipcns_notify(IPCNS_MEMCHANGED);
79529 @@ -545,6 +547,9 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
79530 granted_mode >>= 6;
79531 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
79532 granted_mode >>= 3;
79533 + else if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
79534 + return -1;
79535 +
79536 /* is there some bit set in requested_mode but not in granted_mode? */
79537 if ((requested_mode & ~granted_mode & 0007) &&
79538 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
79539 diff --git a/kernel/acct.c b/kernel/acct.c
79540 index 8d6e145..33e0b1e 100644
79541 --- a/kernel/acct.c
79542 +++ b/kernel/acct.c
79543 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
79544 */
79545 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
79546 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
79547 - file->f_op->write(file, (char *)&ac,
79548 + file->f_op->write(file, (char __force_user *)&ac,
79549 sizeof(acct_t), &file->f_pos);
79550 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
79551 set_fs(fs);
79552 diff --git a/kernel/audit.c b/kernel/audit.c
79553 index 7b0e23a..f4d172f 100644
79554 --- a/kernel/audit.c
79555 +++ b/kernel/audit.c
79556 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
79557 3) suppressed due to audit_rate_limit
79558 4) suppressed due to audit_backlog_limit
79559 */
79560 -static atomic_t audit_lost = ATOMIC_INIT(0);
79561 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
79562
79563 /* The netlink socket. */
79564 static struct sock *audit_sock;
79565 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
79566 unsigned long now;
79567 int print;
79568
79569 - atomic_inc(&audit_lost);
79570 + atomic_inc_unchecked(&audit_lost);
79571
79572 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
79573
79574 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
79575 printk(KERN_WARNING
79576 "audit: audit_lost=%d audit_rate_limit=%d "
79577 "audit_backlog_limit=%d\n",
79578 - atomic_read(&audit_lost),
79579 + atomic_read_unchecked(&audit_lost),
79580 audit_rate_limit,
79581 audit_backlog_limit);
79582 audit_panic(message);
79583 @@ -659,18 +659,19 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79584
79585 switch (msg_type) {
79586 case AUDIT_GET:
79587 + status_set.mask = 0;
79588 status_set.enabled = audit_enabled;
79589 status_set.failure = audit_failure;
79590 status_set.pid = audit_pid;
79591 status_set.rate_limit = audit_rate_limit;
79592 status_set.backlog_limit = audit_backlog_limit;
79593 - status_set.lost = atomic_read(&audit_lost);
79594 + status_set.lost = atomic_read_unchecked(&audit_lost);
79595 status_set.backlog = skb_queue_len(&audit_skb_queue);
79596 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
79597 &status_set, sizeof(status_set));
79598 break;
79599 case AUDIT_SET:
79600 - if (nlh->nlmsg_len < sizeof(struct audit_status))
79601 + if (nlmsg_len(nlh) < sizeof(struct audit_status))
79602 return -EINVAL;
79603 status_get = (struct audit_status *)data;
79604 if (status_get->mask & AUDIT_STATUS_ENABLED) {
79605 @@ -832,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79606
79607 memset(&s, 0, sizeof(s));
79608 /* guard against past and future API changes */
79609 - memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
79610 + memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
79611 if ((s.enabled != 0 && s.enabled != 1) ||
79612 (s.log_passwd != 0 && s.log_passwd != 1))
79613 return -EINVAL;
79614 @@ -1251,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
79615 int i, avail, new_len;
79616 unsigned char *ptr;
79617 struct sk_buff *skb;
79618 - static const unsigned char *hex = "0123456789ABCDEF";
79619 + static const unsigned char hex[] = "0123456789ABCDEF";
79620
79621 if (!ab)
79622 return;
79623 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
79624 index 9845cb3..3ec9369 100644
79625 --- a/kernel/auditsc.c
79626 +++ b/kernel/auditsc.c
79627 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
79628 }
79629
79630 /* global counter which is incremented every time something logs in */
79631 -static atomic_t session_id = ATOMIC_INIT(0);
79632 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
79633
79634 /**
79635 * audit_set_loginuid - set current task's audit_context loginuid
79636 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
79637 return -EPERM;
79638 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
79639
79640 - sessionid = atomic_inc_return(&session_id);
79641 + sessionid = atomic_inc_return_unchecked(&session_id);
79642 if (context && context->in_syscall) {
79643 struct audit_buffer *ab;
79644
79645 diff --git a/kernel/capability.c b/kernel/capability.c
79646 index f6c2ce5..982c0f9 100644
79647 --- a/kernel/capability.c
79648 +++ b/kernel/capability.c
79649 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
79650 * before modification is attempted and the application
79651 * fails.
79652 */
79653 + if (tocopy > ARRAY_SIZE(kdata))
79654 + return -EFAULT;
79655 +
79656 if (copy_to_user(dataptr, kdata, tocopy
79657 * sizeof(struct __user_cap_data_struct))) {
79658 return -EFAULT;
79659 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
79660 int ret;
79661
79662 rcu_read_lock();
79663 - ret = security_capable(__task_cred(t), ns, cap);
79664 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
79665 + gr_task_is_capable(t, __task_cred(t), cap);
79666 rcu_read_unlock();
79667
79668 - return (ret == 0);
79669 + return ret;
79670 }
79671
79672 /**
79673 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
79674 int ret;
79675
79676 rcu_read_lock();
79677 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
79678 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
79679 rcu_read_unlock();
79680
79681 - return (ret == 0);
79682 + return ret;
79683 }
79684
79685 /**
79686 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
79687 BUG();
79688 }
79689
79690 - if (security_capable(current_cred(), ns, cap) == 0) {
79691 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
79692 current->flags |= PF_SUPERPRIV;
79693 return true;
79694 }
79695 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
79696 }
79697 EXPORT_SYMBOL(ns_capable);
79698
79699 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
79700 +{
79701 + if (unlikely(!cap_valid(cap))) {
79702 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
79703 + BUG();
79704 + }
79705 +
79706 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
79707 + current->flags |= PF_SUPERPRIV;
79708 + return true;
79709 + }
79710 + return false;
79711 +}
79712 +EXPORT_SYMBOL(ns_capable_nolog);
79713 +
79714 /**
79715 * file_ns_capable - Determine if the file's opener had a capability in effect
79716 * @file: The file we want to check
79717 @@ -432,6 +451,12 @@ bool capable(int cap)
79718 }
79719 EXPORT_SYMBOL(capable);
79720
79721 +bool capable_nolog(int cap)
79722 +{
79723 + return ns_capable_nolog(&init_user_ns, cap);
79724 +}
79725 +EXPORT_SYMBOL(capable_nolog);
79726 +
79727 /**
79728 * nsown_capable - Check superior capability to one's own user_ns
79729 * @cap: The capability in question
79730 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
79731
79732 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79733 }
79734 +
79735 +bool inode_capable_nolog(const struct inode *inode, int cap)
79736 +{
79737 + struct user_namespace *ns = current_user_ns();
79738 +
79739 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79740 +}
79741 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
79742 index d22f597..35f58e2 100644
79743 --- a/kernel/cgroup.c
79744 +++ b/kernel/cgroup.c
79745 @@ -5623,7 +5623,7 @@ static int cgroup_css_links_read(struct cgroup *cgrp,
79746 struct css_set *cset = link->cset;
79747 struct task_struct *task;
79748 int count = 0;
79749 - seq_printf(seq, "css_set %p\n", cset);
79750 + seq_printf(seq, "css_set %pK\n", cset);
79751 list_for_each_entry(task, &cset->tasks, cg_list) {
79752 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
79753 seq_puts(seq, " ...\n");
79754 diff --git a/kernel/compat.c b/kernel/compat.c
79755 index 0a09e48..f44f3f0 100644
79756 --- a/kernel/compat.c
79757 +++ b/kernel/compat.c
79758 @@ -13,6 +13,7 @@
79759
79760 #include <linux/linkage.h>
79761 #include <linux/compat.h>
79762 +#include <linux/module.h>
79763 #include <linux/errno.h>
79764 #include <linux/time.h>
79765 #include <linux/signal.h>
79766 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
79767 mm_segment_t oldfs;
79768 long ret;
79769
79770 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
79771 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
79772 oldfs = get_fs();
79773 set_fs(KERNEL_DS);
79774 ret = hrtimer_nanosleep_restart(restart);
79775 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
79776 oldfs = get_fs();
79777 set_fs(KERNEL_DS);
79778 ret = hrtimer_nanosleep(&tu,
79779 - rmtp ? (struct timespec __user *)&rmt : NULL,
79780 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
79781 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
79782 set_fs(oldfs);
79783
79784 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
79785 mm_segment_t old_fs = get_fs();
79786
79787 set_fs(KERNEL_DS);
79788 - ret = sys_sigpending((old_sigset_t __user *) &s);
79789 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
79790 set_fs(old_fs);
79791 if (ret == 0)
79792 ret = put_user(s, set);
79793 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
79794 mm_segment_t old_fs = get_fs();
79795
79796 set_fs(KERNEL_DS);
79797 - ret = sys_old_getrlimit(resource, &r);
79798 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
79799 set_fs(old_fs);
79800
79801 if (!ret) {
79802 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
79803 set_fs (KERNEL_DS);
79804 ret = sys_wait4(pid,
79805 (stat_addr ?
79806 - (unsigned int __user *) &status : NULL),
79807 - options, (struct rusage __user *) &r);
79808 + (unsigned int __force_user *) &status : NULL),
79809 + options, (struct rusage __force_user *) &r);
79810 set_fs (old_fs);
79811
79812 if (ret > 0) {
79813 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
79814 memset(&info, 0, sizeof(info));
79815
79816 set_fs(KERNEL_DS);
79817 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
79818 - uru ? (struct rusage __user *)&ru : NULL);
79819 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
79820 + uru ? (struct rusage __force_user *)&ru : NULL);
79821 set_fs(old_fs);
79822
79823 if ((ret < 0) || (info.si_signo == 0))
79824 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
79825 oldfs = get_fs();
79826 set_fs(KERNEL_DS);
79827 err = sys_timer_settime(timer_id, flags,
79828 - (struct itimerspec __user *) &newts,
79829 - (struct itimerspec __user *) &oldts);
79830 + (struct itimerspec __force_user *) &newts,
79831 + (struct itimerspec __force_user *) &oldts);
79832 set_fs(oldfs);
79833 if (!err && old && put_compat_itimerspec(old, &oldts))
79834 return -EFAULT;
79835 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
79836 oldfs = get_fs();
79837 set_fs(KERNEL_DS);
79838 err = sys_timer_gettime(timer_id,
79839 - (struct itimerspec __user *) &ts);
79840 + (struct itimerspec __force_user *) &ts);
79841 set_fs(oldfs);
79842 if (!err && put_compat_itimerspec(setting, &ts))
79843 return -EFAULT;
79844 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
79845 oldfs = get_fs();
79846 set_fs(KERNEL_DS);
79847 err = sys_clock_settime(which_clock,
79848 - (struct timespec __user *) &ts);
79849 + (struct timespec __force_user *) &ts);
79850 set_fs(oldfs);
79851 return err;
79852 }
79853 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
79854 oldfs = get_fs();
79855 set_fs(KERNEL_DS);
79856 err = sys_clock_gettime(which_clock,
79857 - (struct timespec __user *) &ts);
79858 + (struct timespec __force_user *) &ts);
79859 set_fs(oldfs);
79860 if (!err && put_compat_timespec(&ts, tp))
79861 return -EFAULT;
79862 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
79863
79864 oldfs = get_fs();
79865 set_fs(KERNEL_DS);
79866 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
79867 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
79868 set_fs(oldfs);
79869
79870 err = compat_put_timex(utp, &txc);
79871 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
79872 oldfs = get_fs();
79873 set_fs(KERNEL_DS);
79874 err = sys_clock_getres(which_clock,
79875 - (struct timespec __user *) &ts);
79876 + (struct timespec __force_user *) &ts);
79877 set_fs(oldfs);
79878 if (!err && tp && put_compat_timespec(&ts, tp))
79879 return -EFAULT;
79880 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
79881 long err;
79882 mm_segment_t oldfs;
79883 struct timespec tu;
79884 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
79885 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
79886
79887 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
79888 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
79889 oldfs = get_fs();
79890 set_fs(KERNEL_DS);
79891 err = clock_nanosleep_restart(restart);
79892 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
79893 oldfs = get_fs();
79894 set_fs(KERNEL_DS);
79895 err = sys_clock_nanosleep(which_clock, flags,
79896 - (struct timespec __user *) &in,
79897 - (struct timespec __user *) &out);
79898 + (struct timespec __force_user *) &in,
79899 + (struct timespec __force_user *) &out);
79900 set_fs(oldfs);
79901
79902 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
79903 diff --git a/kernel/configs.c b/kernel/configs.c
79904 index c18b1f1..b9a0132 100644
79905 --- a/kernel/configs.c
79906 +++ b/kernel/configs.c
79907 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
79908 struct proc_dir_entry *entry;
79909
79910 /* create the current config file */
79911 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
79912 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
79913 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
79914 + &ikconfig_file_ops);
79915 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
79916 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
79917 + &ikconfig_file_ops);
79918 +#endif
79919 +#else
79920 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
79921 &ikconfig_file_ops);
79922 +#endif
79923 +
79924 if (!entry)
79925 return -ENOMEM;
79926
79927 diff --git a/kernel/cred.c b/kernel/cred.c
79928 index e0573a4..3874e41 100644
79929 --- a/kernel/cred.c
79930 +++ b/kernel/cred.c
79931 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
79932 validate_creds(cred);
79933 alter_cred_subscribers(cred, -1);
79934 put_cred(cred);
79935 +
79936 +#ifdef CONFIG_GRKERNSEC_SETXID
79937 + cred = (struct cred *) tsk->delayed_cred;
79938 + if (cred != NULL) {
79939 + tsk->delayed_cred = NULL;
79940 + validate_creds(cred);
79941 + alter_cred_subscribers(cred, -1);
79942 + put_cred(cred);
79943 + }
79944 +#endif
79945 }
79946
79947 /**
79948 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
79949 * Always returns 0 thus allowing this function to be tail-called at the end
79950 * of, say, sys_setgid().
79951 */
79952 -int commit_creds(struct cred *new)
79953 +static int __commit_creds(struct cred *new)
79954 {
79955 struct task_struct *task = current;
79956 const struct cred *old = task->real_cred;
79957 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
79958
79959 get_cred(new); /* we will require a ref for the subj creds too */
79960
79961 + gr_set_role_label(task, new->uid, new->gid);
79962 +
79963 /* dumpability changes */
79964 if (!uid_eq(old->euid, new->euid) ||
79965 !gid_eq(old->egid, new->egid) ||
79966 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
79967 put_cred(old);
79968 return 0;
79969 }
79970 +#ifdef CONFIG_GRKERNSEC_SETXID
79971 +extern int set_user(struct cred *new);
79972 +
79973 +void gr_delayed_cred_worker(void)
79974 +{
79975 + const struct cred *new = current->delayed_cred;
79976 + struct cred *ncred;
79977 +
79978 + current->delayed_cred = NULL;
79979 +
79980 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
79981 + // from doing get_cred on it when queueing this
79982 + put_cred(new);
79983 + return;
79984 + } else if (new == NULL)
79985 + return;
79986 +
79987 + ncred = prepare_creds();
79988 + if (!ncred)
79989 + goto die;
79990 + // uids
79991 + ncred->uid = new->uid;
79992 + ncred->euid = new->euid;
79993 + ncred->suid = new->suid;
79994 + ncred->fsuid = new->fsuid;
79995 + // gids
79996 + ncred->gid = new->gid;
79997 + ncred->egid = new->egid;
79998 + ncred->sgid = new->sgid;
79999 + ncred->fsgid = new->fsgid;
80000 + // groups
80001 + if (set_groups(ncred, new->group_info) < 0) {
80002 + abort_creds(ncred);
80003 + goto die;
80004 + }
80005 + // caps
80006 + ncred->securebits = new->securebits;
80007 + ncred->cap_inheritable = new->cap_inheritable;
80008 + ncred->cap_permitted = new->cap_permitted;
80009 + ncred->cap_effective = new->cap_effective;
80010 + ncred->cap_bset = new->cap_bset;
80011 +
80012 + if (set_user(ncred)) {
80013 + abort_creds(ncred);
80014 + goto die;
80015 + }
80016 +
80017 + // from doing get_cred on it when queueing this
80018 + put_cred(new);
80019 +
80020 + __commit_creds(ncred);
80021 + return;
80022 +die:
80023 + // from doing get_cred on it when queueing this
80024 + put_cred(new);
80025 + do_group_exit(SIGKILL);
80026 +}
80027 +#endif
80028 +
80029 +int commit_creds(struct cred *new)
80030 +{
80031 +#ifdef CONFIG_GRKERNSEC_SETXID
80032 + int ret;
80033 + int schedule_it = 0;
80034 + struct task_struct *t;
80035 +
80036 + /* we won't get called with tasklist_lock held for writing
80037 + and interrupts disabled as the cred struct in that case is
80038 + init_cred
80039 + */
80040 + if (grsec_enable_setxid && !current_is_single_threaded() &&
80041 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
80042 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
80043 + schedule_it = 1;
80044 + }
80045 + ret = __commit_creds(new);
80046 + if (schedule_it) {
80047 + rcu_read_lock();
80048 + read_lock(&tasklist_lock);
80049 + for (t = next_thread(current); t != current;
80050 + t = next_thread(t)) {
80051 + if (t->delayed_cred == NULL) {
80052 + t->delayed_cred = get_cred(new);
80053 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
80054 + set_tsk_need_resched(t);
80055 + }
80056 + }
80057 + read_unlock(&tasklist_lock);
80058 + rcu_read_unlock();
80059 + }
80060 + return ret;
80061 +#else
80062 + return __commit_creds(new);
80063 +#endif
80064 +}
80065 +
80066 EXPORT_SYMBOL(commit_creds);
80067
80068 /**
80069 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
80070 index 0506d44..2c20034 100644
80071 --- a/kernel/debug/debug_core.c
80072 +++ b/kernel/debug/debug_core.c
80073 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
80074 */
80075 static atomic_t masters_in_kgdb;
80076 static atomic_t slaves_in_kgdb;
80077 -static atomic_t kgdb_break_tasklet_var;
80078 +static atomic_unchecked_t kgdb_break_tasklet_var;
80079 atomic_t kgdb_setting_breakpoint;
80080
80081 struct task_struct *kgdb_usethread;
80082 @@ -133,7 +133,7 @@ int kgdb_single_step;
80083 static pid_t kgdb_sstep_pid;
80084
80085 /* to keep track of the CPU which is doing the single stepping*/
80086 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80087 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80088
80089 /*
80090 * If you are debugging a problem where roundup (the collection of
80091 @@ -541,7 +541,7 @@ return_normal:
80092 * kernel will only try for the value of sstep_tries before
80093 * giving up and continuing on.
80094 */
80095 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
80096 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
80097 (kgdb_info[cpu].task &&
80098 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
80099 atomic_set(&kgdb_active, -1);
80100 @@ -635,8 +635,8 @@ cpu_master_loop:
80101 }
80102
80103 kgdb_restore:
80104 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
80105 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
80106 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
80107 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
80108 if (kgdb_info[sstep_cpu].task)
80109 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
80110 else
80111 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
80112 static void kgdb_tasklet_bpt(unsigned long ing)
80113 {
80114 kgdb_breakpoint();
80115 - atomic_set(&kgdb_break_tasklet_var, 0);
80116 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
80117 }
80118
80119 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
80120
80121 void kgdb_schedule_breakpoint(void)
80122 {
80123 - if (atomic_read(&kgdb_break_tasklet_var) ||
80124 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
80125 atomic_read(&kgdb_active) != -1 ||
80126 atomic_read(&kgdb_setting_breakpoint))
80127 return;
80128 - atomic_inc(&kgdb_break_tasklet_var);
80129 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
80130 tasklet_schedule(&kgdb_tasklet_breakpoint);
80131 }
80132 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
80133 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
80134 index 00eb8f7..d7e3244 100644
80135 --- a/kernel/debug/kdb/kdb_main.c
80136 +++ b/kernel/debug/kdb/kdb_main.c
80137 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
80138 continue;
80139
80140 kdb_printf("%-20s%8u 0x%p ", mod->name,
80141 - mod->core_size, (void *)mod);
80142 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
80143 #ifdef CONFIG_MODULE_UNLOAD
80144 kdb_printf("%4ld ", module_refcount(mod));
80145 #endif
80146 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
80147 kdb_printf(" (Loading)");
80148 else
80149 kdb_printf(" (Live)");
80150 - kdb_printf(" 0x%p", mod->module_core);
80151 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
80152
80153 #ifdef CONFIG_MODULE_UNLOAD
80154 {
80155 diff --git a/kernel/events/core.c b/kernel/events/core.c
80156 index f86599e..b18b180 100644
80157 --- a/kernel/events/core.c
80158 +++ b/kernel/events/core.c
80159 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
80160 * 0 - disallow raw tracepoint access for unpriv
80161 * 1 - disallow cpu events for unpriv
80162 * 2 - disallow kernel profiling for unpriv
80163 + * 3 - disallow all unpriv perf event use
80164 */
80165 -int sysctl_perf_event_paranoid __read_mostly = 1;
80166 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80167 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
80168 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
80169 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
80170 +#else
80171 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
80172 +#endif
80173
80174 /* Minimum for 512 kiB + 1 user control page */
80175 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
80176 @@ -270,7 +277,7 @@ void perf_sample_event_took(u64 sample_len_ns)
80177 update_perf_cpu_limits();
80178 }
80179
80180 -static atomic64_t perf_event_id;
80181 +static atomic64_unchecked_t perf_event_id;
80182
80183 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
80184 enum event_type_t event_type);
80185 @@ -2936,7 +2943,7 @@ static void __perf_event_read(void *info)
80186
80187 static inline u64 perf_event_count(struct perf_event *event)
80188 {
80189 - return local64_read(&event->count) + atomic64_read(&event->child_count);
80190 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
80191 }
80192
80193 static u64 perf_event_read(struct perf_event *event)
80194 @@ -3282,9 +3289,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
80195 mutex_lock(&event->child_mutex);
80196 total += perf_event_read(event);
80197 *enabled += event->total_time_enabled +
80198 - atomic64_read(&event->child_total_time_enabled);
80199 + atomic64_read_unchecked(&event->child_total_time_enabled);
80200 *running += event->total_time_running +
80201 - atomic64_read(&event->child_total_time_running);
80202 + atomic64_read_unchecked(&event->child_total_time_running);
80203
80204 list_for_each_entry(child, &event->child_list, child_list) {
80205 total += perf_event_read(child);
80206 @@ -3670,10 +3677,10 @@ void perf_event_update_userpage(struct perf_event *event)
80207 userpg->offset -= local64_read(&event->hw.prev_count);
80208
80209 userpg->time_enabled = enabled +
80210 - atomic64_read(&event->child_total_time_enabled);
80211 + atomic64_read_unchecked(&event->child_total_time_enabled);
80212
80213 userpg->time_running = running +
80214 - atomic64_read(&event->child_total_time_running);
80215 + atomic64_read_unchecked(&event->child_total_time_running);
80216
80217 arch_perf_update_userpage(userpg, now);
80218
80219 @@ -4223,7 +4230,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
80220
80221 /* Data. */
80222 sp = perf_user_stack_pointer(regs);
80223 - rem = __output_copy_user(handle, (void *) sp, dump_size);
80224 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
80225 dyn_size = dump_size - rem;
80226
80227 perf_output_skip(handle, rem);
80228 @@ -4311,11 +4318,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
80229 values[n++] = perf_event_count(event);
80230 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
80231 values[n++] = enabled +
80232 - atomic64_read(&event->child_total_time_enabled);
80233 + atomic64_read_unchecked(&event->child_total_time_enabled);
80234 }
80235 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
80236 values[n++] = running +
80237 - atomic64_read(&event->child_total_time_running);
80238 + atomic64_read_unchecked(&event->child_total_time_running);
80239 }
80240 if (read_format & PERF_FORMAT_ID)
80241 values[n++] = primary_event_id(event);
80242 @@ -5024,12 +5031,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
80243 * need to add enough zero bytes after the string to handle
80244 * the 64bit alignment we do later.
80245 */
80246 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
80247 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
80248 if (!buf) {
80249 name = strncpy(tmp, "//enomem", sizeof(tmp));
80250 goto got_name;
80251 }
80252 - name = d_path(&file->f_path, buf, PATH_MAX);
80253 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
80254 if (IS_ERR(name)) {
80255 name = strncpy(tmp, "//toolong", sizeof(tmp));
80256 goto got_name;
80257 @@ -6498,7 +6505,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
80258 event->parent = parent_event;
80259
80260 event->ns = get_pid_ns(task_active_pid_ns(current));
80261 - event->id = atomic64_inc_return(&perf_event_id);
80262 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
80263
80264 event->state = PERF_EVENT_STATE_INACTIVE;
80265
80266 @@ -6807,6 +6814,11 @@ SYSCALL_DEFINE5(perf_event_open,
80267 if (flags & ~PERF_FLAG_ALL)
80268 return -EINVAL;
80269
80270 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80271 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
80272 + return -EACCES;
80273 +#endif
80274 +
80275 err = perf_copy_attr(attr_uptr, &attr);
80276 if (err)
80277 return err;
80278 @@ -7139,10 +7151,10 @@ static void sync_child_event(struct perf_event *child_event,
80279 /*
80280 * Add back the child's count to the parent's count:
80281 */
80282 - atomic64_add(child_val, &parent_event->child_count);
80283 - atomic64_add(child_event->total_time_enabled,
80284 + atomic64_add_unchecked(child_val, &parent_event->child_count);
80285 + atomic64_add_unchecked(child_event->total_time_enabled,
80286 &parent_event->child_total_time_enabled);
80287 - atomic64_add(child_event->total_time_running,
80288 + atomic64_add_unchecked(child_event->total_time_running,
80289 &parent_event->child_total_time_running);
80290
80291 /*
80292 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
80293 index ca65997..60df03d 100644
80294 --- a/kernel/events/internal.h
80295 +++ b/kernel/events/internal.h
80296 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
80297 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
80298 }
80299
80300 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
80301 -static inline unsigned int \
80302 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
80303 +static inline unsigned long \
80304 func_name(struct perf_output_handle *handle, \
80305 - const void *buf, unsigned int len) \
80306 + const void user *buf, unsigned long len) \
80307 { \
80308 unsigned long size, written; \
80309 \
80310 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
80311 return n;
80312 }
80313
80314 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
80315 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
80316
80317 #define MEMCPY_SKIP(dst, src, n) (n)
80318
80319 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
80320 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
80321
80322 #ifndef arch_perf_out_copy_user
80323 #define arch_perf_out_copy_user __copy_from_user_inatomic
80324 #endif
80325
80326 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
80327 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
80328
80329 /* Callchain handling */
80330 extern struct perf_callchain_entry *
80331 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
80332 index ad8e1bd..fed7ba9 100644
80333 --- a/kernel/events/uprobes.c
80334 +++ b/kernel/events/uprobes.c
80335 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
80336 {
80337 struct page *page;
80338 uprobe_opcode_t opcode;
80339 - int result;
80340 + long result;
80341
80342 pagefault_disable();
80343 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
80344 diff --git a/kernel/exit.c b/kernel/exit.c
80345 index a949819..a5f127d 100644
80346 --- a/kernel/exit.c
80347 +++ b/kernel/exit.c
80348 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
80349 struct task_struct *leader;
80350 int zap_leader;
80351 repeat:
80352 +#ifdef CONFIG_NET
80353 + gr_del_task_from_ip_table(p);
80354 +#endif
80355 +
80356 /* don't need to get the RCU readlock here - the process is dead and
80357 * can't be modifying its own credentials. But shut RCU-lockdep up */
80358 rcu_read_lock();
80359 @@ -329,7 +333,7 @@ int allow_signal(int sig)
80360 * know it'll be handled, so that they don't get converted to
80361 * SIGKILL or just silently dropped.
80362 */
80363 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
80364 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
80365 recalc_sigpending();
80366 spin_unlock_irq(&current->sighand->siglock);
80367 return 0;
80368 @@ -698,6 +702,8 @@ void do_exit(long code)
80369 struct task_struct *tsk = current;
80370 int group_dead;
80371
80372 + set_fs(USER_DS);
80373 +
80374 profile_task_exit(tsk);
80375
80376 WARN_ON(blk_needs_flush_plug(tsk));
80377 @@ -714,7 +720,6 @@ void do_exit(long code)
80378 * mm_release()->clear_child_tid() from writing to a user-controlled
80379 * kernel address.
80380 */
80381 - set_fs(USER_DS);
80382
80383 ptrace_event(PTRACE_EVENT_EXIT, code);
80384
80385 @@ -773,6 +778,9 @@ void do_exit(long code)
80386 tsk->exit_code = code;
80387 taskstats_exit(tsk, group_dead);
80388
80389 + gr_acl_handle_psacct(tsk, code);
80390 + gr_acl_handle_exit();
80391 +
80392 exit_mm(tsk);
80393
80394 if (group_dead)
80395 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
80396 * Take down every thread in the group. This is called by fatal signals
80397 * as well as by sys_exit_group (below).
80398 */
80399 -void
80400 +__noreturn void
80401 do_group_exit(int exit_code)
80402 {
80403 struct signal_struct *sig = current->signal;
80404 diff --git a/kernel/fork.c b/kernel/fork.c
80405 index 200a7a2..43e52da 100644
80406 --- a/kernel/fork.c
80407 +++ b/kernel/fork.c
80408 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
80409 *stackend = STACK_END_MAGIC; /* for overflow detection */
80410
80411 #ifdef CONFIG_CC_STACKPROTECTOR
80412 - tsk->stack_canary = get_random_int();
80413 + tsk->stack_canary = pax_get_random_long();
80414 #endif
80415
80416 /*
80417 @@ -345,13 +345,81 @@ free_tsk:
80418 }
80419
80420 #ifdef CONFIG_MMU
80421 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80422 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
80423 {
80424 - struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80425 - struct rb_node **rb_link, *rb_parent;
80426 - int retval;
80427 + struct vm_area_struct *tmp;
80428 unsigned long charge;
80429 struct mempolicy *pol;
80430 + struct file *file;
80431 +
80432 + charge = 0;
80433 + if (mpnt->vm_flags & VM_ACCOUNT) {
80434 + unsigned long len = vma_pages(mpnt);
80435 +
80436 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80437 + goto fail_nomem;
80438 + charge = len;
80439 + }
80440 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80441 + if (!tmp)
80442 + goto fail_nomem;
80443 + *tmp = *mpnt;
80444 + tmp->vm_mm = mm;
80445 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
80446 + pol = mpol_dup(vma_policy(mpnt));
80447 + if (IS_ERR(pol))
80448 + goto fail_nomem_policy;
80449 + vma_set_policy(tmp, pol);
80450 + if (anon_vma_fork(tmp, mpnt))
80451 + goto fail_nomem_anon_vma_fork;
80452 + tmp->vm_flags &= ~VM_LOCKED;
80453 + tmp->vm_next = tmp->vm_prev = NULL;
80454 + tmp->vm_mirror = NULL;
80455 + file = tmp->vm_file;
80456 + if (file) {
80457 + struct inode *inode = file_inode(file);
80458 + struct address_space *mapping = file->f_mapping;
80459 +
80460 + get_file(file);
80461 + if (tmp->vm_flags & VM_DENYWRITE)
80462 + atomic_dec(&inode->i_writecount);
80463 + mutex_lock(&mapping->i_mmap_mutex);
80464 + if (tmp->vm_flags & VM_SHARED)
80465 + mapping->i_mmap_writable++;
80466 + flush_dcache_mmap_lock(mapping);
80467 + /* insert tmp into the share list, just after mpnt */
80468 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80469 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
80470 + else
80471 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
80472 + flush_dcache_mmap_unlock(mapping);
80473 + mutex_unlock(&mapping->i_mmap_mutex);
80474 + }
80475 +
80476 + /*
80477 + * Clear hugetlb-related page reserves for children. This only
80478 + * affects MAP_PRIVATE mappings. Faults generated by the child
80479 + * are not guaranteed to succeed, even if read-only
80480 + */
80481 + if (is_vm_hugetlb_page(tmp))
80482 + reset_vma_resv_huge_pages(tmp);
80483 +
80484 + return tmp;
80485 +
80486 +fail_nomem_anon_vma_fork:
80487 + mpol_put(pol);
80488 +fail_nomem_policy:
80489 + kmem_cache_free(vm_area_cachep, tmp);
80490 +fail_nomem:
80491 + vm_unacct_memory(charge);
80492 + return NULL;
80493 +}
80494 +
80495 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80496 +{
80497 + struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80498 + struct rb_node **rb_link, *rb_parent;
80499 + int retval;
80500
80501 uprobe_start_dup_mmap();
80502 down_write(&oldmm->mmap_sem);
80503 @@ -380,57 +448,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80504
80505 prev = NULL;
80506 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
80507 - struct file *file;
80508 -
80509 if (mpnt->vm_flags & VM_DONTCOPY) {
80510 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
80511 -vma_pages(mpnt));
80512 continue;
80513 }
80514 - charge = 0;
80515 - if (mpnt->vm_flags & VM_ACCOUNT) {
80516 - unsigned long len = vma_pages(mpnt);
80517 -
80518 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80519 - goto fail_nomem;
80520 - charge = len;
80521 - }
80522 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80523 - if (!tmp)
80524 - goto fail_nomem;
80525 - *tmp = *mpnt;
80526 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
80527 - pol = mpol_dup(vma_policy(mpnt));
80528 - retval = PTR_ERR(pol);
80529 - if (IS_ERR(pol))
80530 - goto fail_nomem_policy;
80531 - vma_set_policy(tmp, pol);
80532 - tmp->vm_mm = mm;
80533 - if (anon_vma_fork(tmp, mpnt))
80534 - goto fail_nomem_anon_vma_fork;
80535 - tmp->vm_flags &= ~VM_LOCKED;
80536 - tmp->vm_next = tmp->vm_prev = NULL;
80537 - file = tmp->vm_file;
80538 - if (file) {
80539 - struct inode *inode = file_inode(file);
80540 - struct address_space *mapping = file->f_mapping;
80541 -
80542 - get_file(file);
80543 - if (tmp->vm_flags & VM_DENYWRITE)
80544 - atomic_dec(&inode->i_writecount);
80545 - mutex_lock(&mapping->i_mmap_mutex);
80546 - if (tmp->vm_flags & VM_SHARED)
80547 - mapping->i_mmap_writable++;
80548 - flush_dcache_mmap_lock(mapping);
80549 - /* insert tmp into the share list, just after mpnt */
80550 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80551 - vma_nonlinear_insert(tmp,
80552 - &mapping->i_mmap_nonlinear);
80553 - else
80554 - vma_interval_tree_insert_after(tmp, mpnt,
80555 - &mapping->i_mmap);
80556 - flush_dcache_mmap_unlock(mapping);
80557 - mutex_unlock(&mapping->i_mmap_mutex);
80558 + tmp = dup_vma(mm, oldmm, mpnt);
80559 + if (!tmp) {
80560 + retval = -ENOMEM;
80561 + goto out;
80562 }
80563
80564 /*
80565 @@ -462,6 +488,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80566 if (retval)
80567 goto out;
80568 }
80569 +
80570 +#ifdef CONFIG_PAX_SEGMEXEC
80571 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
80572 + struct vm_area_struct *mpnt_m;
80573 +
80574 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
80575 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
80576 +
80577 + if (!mpnt->vm_mirror)
80578 + continue;
80579 +
80580 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
80581 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
80582 + mpnt->vm_mirror = mpnt_m;
80583 + } else {
80584 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
80585 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
80586 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
80587 + mpnt->vm_mirror->vm_mirror = mpnt;
80588 + }
80589 + }
80590 + BUG_ON(mpnt_m);
80591 + }
80592 +#endif
80593 +
80594 /* a new mm has just been created */
80595 arch_dup_mmap(oldmm, mm);
80596 retval = 0;
80597 @@ -471,14 +522,6 @@ out:
80598 up_write(&oldmm->mmap_sem);
80599 uprobe_end_dup_mmap();
80600 return retval;
80601 -fail_nomem_anon_vma_fork:
80602 - mpol_put(pol);
80603 -fail_nomem_policy:
80604 - kmem_cache_free(vm_area_cachep, tmp);
80605 -fail_nomem:
80606 - retval = -ENOMEM;
80607 - vm_unacct_memory(charge);
80608 - goto out;
80609 }
80610
80611 static inline int mm_alloc_pgd(struct mm_struct *mm)
80612 @@ -691,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
80613 return ERR_PTR(err);
80614
80615 mm = get_task_mm(task);
80616 - if (mm && mm != current->mm &&
80617 - !ptrace_may_access(task, mode)) {
80618 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
80619 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
80620 mmput(mm);
80621 mm = ERR_PTR(-EACCES);
80622 }
80623 @@ -914,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
80624 spin_unlock(&fs->lock);
80625 return -EAGAIN;
80626 }
80627 - fs->users++;
80628 + atomic_inc(&fs->users);
80629 spin_unlock(&fs->lock);
80630 return 0;
80631 }
80632 tsk->fs = copy_fs_struct(fs);
80633 if (!tsk->fs)
80634 return -ENOMEM;
80635 + /* Carry through gr_chroot_dentry and is_chrooted instead
80636 + of recomputing it here. Already copied when the task struct
80637 + is duplicated. This allows pivot_root to not be treated as
80638 + a chroot
80639 + */
80640 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
80641 +
80642 return 0;
80643 }
80644
80645 @@ -1131,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
80646 * parts of the process environment (as per the clone
80647 * flags). The actual kick-off is left to the caller.
80648 */
80649 -static struct task_struct *copy_process(unsigned long clone_flags,
80650 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
80651 unsigned long stack_start,
80652 unsigned long stack_size,
80653 int __user *child_tidptr,
80654 @@ -1201,6 +1251,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80655 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
80656 #endif
80657 retval = -EAGAIN;
80658 +
80659 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
80660 +
80661 if (atomic_read(&p->real_cred->user->processes) >=
80662 task_rlimit(p, RLIMIT_NPROC)) {
80663 if (p->real_cred->user != INIT_USER &&
80664 @@ -1450,6 +1503,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80665 goto bad_fork_free_pid;
80666 }
80667
80668 + /* synchronizes with gr_set_acls()
80669 + we need to call this past the point of no return for fork()
80670 + */
80671 + gr_copy_label(p);
80672 +
80673 if (likely(p->pid)) {
80674 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
80675
80676 @@ -1535,6 +1593,8 @@ bad_fork_cleanup_count:
80677 bad_fork_free:
80678 free_task(p);
80679 fork_out:
80680 + gr_log_forkfail(retval);
80681 +
80682 return ERR_PTR(retval);
80683 }
80684
80685 @@ -1605,6 +1665,7 @@ long do_fork(unsigned long clone_flags,
80686
80687 p = copy_process(clone_flags, stack_start, stack_size,
80688 child_tidptr, NULL, trace);
80689 + add_latent_entropy();
80690 /*
80691 * Do this prior waking up the new thread - the thread pointer
80692 * might get invalid after that point, if the thread exits quickly.
80693 @@ -1619,6 +1680,8 @@ long do_fork(unsigned long clone_flags,
80694 if (clone_flags & CLONE_PARENT_SETTID)
80695 put_user(nr, parent_tidptr);
80696
80697 + gr_handle_brute_check();
80698 +
80699 if (clone_flags & CLONE_VFORK) {
80700 p->vfork_done = &vfork;
80701 init_completion(&vfork);
80702 @@ -1735,7 +1798,7 @@ void __init proc_caches_init(void)
80703 mm_cachep = kmem_cache_create("mm_struct",
80704 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
80705 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
80706 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
80707 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
80708 mmap_init();
80709 nsproxy_cache_init();
80710 }
80711 @@ -1775,7 +1838,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
80712 return 0;
80713
80714 /* don't need lock here; in the worst case we'll do useless copy */
80715 - if (fs->users == 1)
80716 + if (atomic_read(&fs->users) == 1)
80717 return 0;
80718
80719 *new_fsp = copy_fs_struct(fs);
80720 @@ -1887,7 +1950,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
80721 fs = current->fs;
80722 spin_lock(&fs->lock);
80723 current->fs = new_fs;
80724 - if (--fs->users)
80725 + gr_set_chroot_entries(current, &current->fs->root);
80726 + if (atomic_dec_return(&fs->users))
80727 new_fs = NULL;
80728 else
80729 new_fs = fs;
80730 diff --git a/kernel/futex.c b/kernel/futex.c
80731 index c3a1a55..e32b4a98 100644
80732 --- a/kernel/futex.c
80733 +++ b/kernel/futex.c
80734 @@ -54,6 +54,7 @@
80735 #include <linux/mount.h>
80736 #include <linux/pagemap.h>
80737 #include <linux/syscalls.h>
80738 +#include <linux/ptrace.h>
80739 #include <linux/signal.h>
80740 #include <linux/export.h>
80741 #include <linux/magic.h>
80742 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
80743 struct page *page, *page_head;
80744 int err, ro = 0;
80745
80746 +#ifdef CONFIG_PAX_SEGMEXEC
80747 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
80748 + return -EFAULT;
80749 +#endif
80750 +
80751 /*
80752 * The futex address must be "naturally" aligned.
80753 */
80754 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
80755
80756 static int get_futex_value_locked(u32 *dest, u32 __user *from)
80757 {
80758 - int ret;
80759 + unsigned long ret;
80760
80761 pagefault_disable();
80762 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
80763 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
80764 {
80765 u32 curval;
80766 int i;
80767 + mm_segment_t oldfs;
80768
80769 /*
80770 * This will fail and we want it. Some arch implementations do
80771 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
80772 * implementation, the non-functional ones will return
80773 * -ENOSYS.
80774 */
80775 + oldfs = get_fs();
80776 + set_fs(USER_DS);
80777 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
80778 futex_cmpxchg_enabled = 1;
80779 + set_fs(oldfs);
80780
80781 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
80782 plist_head_init(&futex_queues[i].chain);
80783 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
80784 index f9f44fd..29885e4 100644
80785 --- a/kernel/futex_compat.c
80786 +++ b/kernel/futex_compat.c
80787 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
80788 return 0;
80789 }
80790
80791 -static void __user *futex_uaddr(struct robust_list __user *entry,
80792 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
80793 compat_long_t futex_offset)
80794 {
80795 compat_uptr_t base = ptr_to_compat(entry);
80796 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
80797 index 9b22d03..6295b62 100644
80798 --- a/kernel/gcov/base.c
80799 +++ b/kernel/gcov/base.c
80800 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
80801 }
80802
80803 #ifdef CONFIG_MODULES
80804 -static inline int within(void *addr, void *start, unsigned long size)
80805 -{
80806 - return ((addr >= start) && (addr < start + size));
80807 -}
80808 -
80809 /* Update list and generate events when modules are unloaded. */
80810 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80811 void *data)
80812 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80813 prev = NULL;
80814 /* Remove entries located in module from linked list. */
80815 for (info = gcov_info_head; info; info = info->next) {
80816 - if (within(info, mod->module_core, mod->core_size)) {
80817 + if (within_module_core_rw((unsigned long)info, mod)) {
80818 if (prev)
80819 prev->next = info->next;
80820 else
80821 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
80822 index 383319b..56ebb13 100644
80823 --- a/kernel/hrtimer.c
80824 +++ b/kernel/hrtimer.c
80825 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
80826 local_irq_restore(flags);
80827 }
80828
80829 -static void run_hrtimer_softirq(struct softirq_action *h)
80830 +static __latent_entropy void run_hrtimer_softirq(void)
80831 {
80832 hrtimer_peek_ahead_timers();
80833 }
80834 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
80835 index 55fcce6..0e4cf34 100644
80836 --- a/kernel/irq_work.c
80837 +++ b/kernel/irq_work.c
80838 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
80839 return NOTIFY_OK;
80840 }
80841
80842 -static struct notifier_block cpu_notify;
80843 +static struct notifier_block cpu_notify = {
80844 + .notifier_call = irq_work_cpu_notify,
80845 + .priority = 0,
80846 +};
80847
80848 static __init int irq_work_init_cpu_notifier(void)
80849 {
80850 - cpu_notify.notifier_call = irq_work_cpu_notify;
80851 - cpu_notify.priority = 0;
80852 register_cpu_notifier(&cpu_notify);
80853 return 0;
80854 }
80855 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
80856 index 60f48fa..7f3a770 100644
80857 --- a/kernel/jump_label.c
80858 +++ b/kernel/jump_label.c
80859 @@ -13,6 +13,7 @@
80860 #include <linux/sort.h>
80861 #include <linux/err.h>
80862 #include <linux/static_key.h>
80863 +#include <linux/mm.h>
80864
80865 #ifdef HAVE_JUMP_LABEL
80866
80867 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
80868
80869 size = (((unsigned long)stop - (unsigned long)start)
80870 / sizeof(struct jump_entry));
80871 + pax_open_kernel();
80872 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
80873 + pax_close_kernel();
80874 }
80875
80876 static void jump_label_update(struct static_key *key, int enable);
80877 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
80878 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
80879 struct jump_entry *iter;
80880
80881 + pax_open_kernel();
80882 for (iter = iter_start; iter < iter_stop; iter++) {
80883 if (within_module_init(iter->code, mod))
80884 iter->code = 0;
80885 }
80886 + pax_close_kernel();
80887 }
80888
80889 static int
80890 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
80891 index 3127ad5..159d880 100644
80892 --- a/kernel/kallsyms.c
80893 +++ b/kernel/kallsyms.c
80894 @@ -11,6 +11,9 @@
80895 * Changed the compression method from stem compression to "table lookup"
80896 * compression (see scripts/kallsyms.c for a more complete description)
80897 */
80898 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80899 +#define __INCLUDED_BY_HIDESYM 1
80900 +#endif
80901 #include <linux/kallsyms.h>
80902 #include <linux/module.h>
80903 #include <linux/init.h>
80904 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
80905
80906 static inline int is_kernel_inittext(unsigned long addr)
80907 {
80908 + if (system_state != SYSTEM_BOOTING)
80909 + return 0;
80910 +
80911 if (addr >= (unsigned long)_sinittext
80912 && addr <= (unsigned long)_einittext)
80913 return 1;
80914 return 0;
80915 }
80916
80917 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80918 +#ifdef CONFIG_MODULES
80919 +static inline int is_module_text(unsigned long addr)
80920 +{
80921 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
80922 + return 1;
80923 +
80924 + addr = ktla_ktva(addr);
80925 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
80926 +}
80927 +#else
80928 +static inline int is_module_text(unsigned long addr)
80929 +{
80930 + return 0;
80931 +}
80932 +#endif
80933 +#endif
80934 +
80935 static inline int is_kernel_text(unsigned long addr)
80936 {
80937 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
80938 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
80939
80940 static inline int is_kernel(unsigned long addr)
80941 {
80942 +
80943 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80944 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
80945 + return 1;
80946 +
80947 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
80948 +#else
80949 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
80950 +#endif
80951 +
80952 return 1;
80953 return in_gate_area_no_mm(addr);
80954 }
80955
80956 static int is_ksym_addr(unsigned long addr)
80957 {
80958 +
80959 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80960 + if (is_module_text(addr))
80961 + return 0;
80962 +#endif
80963 +
80964 if (all_var)
80965 return is_kernel(addr);
80966
80967 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
80968
80969 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
80970 {
80971 - iter->name[0] = '\0';
80972 iter->nameoff = get_symbol_offset(new_pos);
80973 iter->pos = new_pos;
80974 }
80975 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
80976 {
80977 struct kallsym_iter *iter = m->private;
80978
80979 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80980 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
80981 + return 0;
80982 +#endif
80983 +
80984 /* Some debugging symbols have no name. Ignore them. */
80985 if (!iter->name[0])
80986 return 0;
80987 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
80988 */
80989 type = iter->exported ? toupper(iter->type) :
80990 tolower(iter->type);
80991 +
80992 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
80993 type, iter->name, iter->module_name);
80994 } else
80995 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
80996 struct kallsym_iter *iter;
80997 int ret;
80998
80999 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
81000 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
81001 if (!iter)
81002 return -ENOMEM;
81003 reset_iter(iter, 0);
81004 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
81005 index e30ac0f..3528cac 100644
81006 --- a/kernel/kcmp.c
81007 +++ b/kernel/kcmp.c
81008 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
81009 struct task_struct *task1, *task2;
81010 int ret;
81011
81012 +#ifdef CONFIG_GRKERNSEC
81013 + return -ENOSYS;
81014 +#endif
81015 +
81016 rcu_read_lock();
81017
81018 /*
81019 diff --git a/kernel/kexec.c b/kernel/kexec.c
81020 index 59f7b55..4022f65 100644
81021 --- a/kernel/kexec.c
81022 +++ b/kernel/kexec.c
81023 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
81024 unsigned long flags)
81025 {
81026 struct compat_kexec_segment in;
81027 - struct kexec_segment out, __user *ksegments;
81028 + struct kexec_segment out;
81029 + struct kexec_segment __user *ksegments;
81030 unsigned long i, result;
81031
81032 /* Don't allow clients that don't understand the native
81033 diff --git a/kernel/kmod.c b/kernel/kmod.c
81034 index b086006..a27913b 100644
81035 --- a/kernel/kmod.c
81036 +++ b/kernel/kmod.c
81037 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
81038 kfree(info->argv);
81039 }
81040
81041 -static int call_modprobe(char *module_name, int wait)
81042 +static int call_modprobe(char *module_name, char *module_param, int wait)
81043 {
81044 struct subprocess_info *info;
81045 static char *envp[] = {
81046 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
81047 NULL
81048 };
81049
81050 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
81051 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
81052 if (!argv)
81053 goto out;
81054
81055 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
81056 argv[1] = "-q";
81057 argv[2] = "--";
81058 argv[3] = module_name; /* check free_modprobe_argv() */
81059 - argv[4] = NULL;
81060 + argv[4] = module_param;
81061 + argv[5] = NULL;
81062
81063 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
81064 NULL, free_modprobe_argv, NULL);
81065 @@ -129,9 +130,8 @@ out:
81066 * If module auto-loading support is disabled then this function
81067 * becomes a no-operation.
81068 */
81069 -int __request_module(bool wait, const char *fmt, ...)
81070 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
81071 {
81072 - va_list args;
81073 char module_name[MODULE_NAME_LEN];
81074 unsigned int max_modprobes;
81075 int ret;
81076 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
81077 if (!modprobe_path[0])
81078 return 0;
81079
81080 - va_start(args, fmt);
81081 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
81082 - va_end(args);
81083 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
81084 if (ret >= MODULE_NAME_LEN)
81085 return -ENAMETOOLONG;
81086
81087 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
81088 if (ret)
81089 return ret;
81090
81091 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81092 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81093 + /* hack to workaround consolekit/udisks stupidity */
81094 + read_lock(&tasklist_lock);
81095 + if (!strcmp(current->comm, "mount") &&
81096 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
81097 + read_unlock(&tasklist_lock);
81098 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
81099 + return -EPERM;
81100 + }
81101 + read_unlock(&tasklist_lock);
81102 + }
81103 +#endif
81104 +
81105 /* If modprobe needs a service that is in a module, we get a recursive
81106 * loop. Limit the number of running kmod threads to max_threads/2 or
81107 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
81108 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
81109
81110 trace_module_request(module_name, wait, _RET_IP_);
81111
81112 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81113 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81114
81115 atomic_dec(&kmod_concurrent);
81116 return ret;
81117 }
81118 +
81119 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
81120 +{
81121 + va_list args;
81122 + int ret;
81123 +
81124 + va_start(args, fmt);
81125 + ret = ____request_module(wait, module_param, fmt, args);
81126 + va_end(args);
81127 +
81128 + return ret;
81129 +}
81130 +
81131 +int __request_module(bool wait, const char *fmt, ...)
81132 +{
81133 + va_list args;
81134 + int ret;
81135 +
81136 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81137 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81138 + char module_param[MODULE_NAME_LEN];
81139 +
81140 + memset(module_param, 0, sizeof(module_param));
81141 +
81142 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
81143 +
81144 + va_start(args, fmt);
81145 + ret = ____request_module(wait, module_param, fmt, args);
81146 + va_end(args);
81147 +
81148 + return ret;
81149 + }
81150 +#endif
81151 +
81152 + va_start(args, fmt);
81153 + ret = ____request_module(wait, NULL, fmt, args);
81154 + va_end(args);
81155 +
81156 + return ret;
81157 +}
81158 +
81159 EXPORT_SYMBOL(__request_module);
81160 #endif /* CONFIG_MODULES */
81161
81162 @@ -303,7 +356,7 @@ static int wait_for_helper(void *data)
81163 *
81164 * Thus the __user pointer cast is valid here.
81165 */
81166 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
81167 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
81168
81169 /*
81170 * If ret is 0, either ____call_usermodehelper failed and the
81171 @@ -650,7 +703,7 @@ EXPORT_SYMBOL(call_usermodehelper);
81172 static int proc_cap_handler(struct ctl_table *table, int write,
81173 void __user *buffer, size_t *lenp, loff_t *ppos)
81174 {
81175 - struct ctl_table t;
81176 + ctl_table_no_const t;
81177 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
81178 kernel_cap_t new_cap;
81179 int err, i;
81180 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
81181 index 6e33498..3133bd3 100644
81182 --- a/kernel/kprobes.c
81183 +++ b/kernel/kprobes.c
81184 @@ -31,6 +31,9 @@
81185 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
81186 * <prasanna@in.ibm.com> added function-return probes.
81187 */
81188 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81189 +#define __INCLUDED_BY_HIDESYM 1
81190 +#endif
81191 #include <linux/kprobes.h>
81192 #include <linux/hash.h>
81193 #include <linux/init.h>
81194 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
81195 * kernel image and loaded module images reside. This is required
81196 * so x86_64 can correctly handle the %rip-relative fixups.
81197 */
81198 - kip->insns = module_alloc(PAGE_SIZE);
81199 + kip->insns = module_alloc_exec(PAGE_SIZE);
81200 if (!kip->insns) {
81201 kfree(kip);
81202 return NULL;
81203 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
81204 */
81205 if (!list_is_singular(&kip->list)) {
81206 list_del(&kip->list);
81207 - module_free(NULL, kip->insns);
81208 + module_free_exec(NULL, kip->insns);
81209 kfree(kip);
81210 }
81211 return 1;
81212 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
81213 {
81214 int i, err = 0;
81215 unsigned long offset = 0, size = 0;
81216 - char *modname, namebuf[128];
81217 + char *modname, namebuf[KSYM_NAME_LEN];
81218 const char *symbol_name;
81219 void *addr;
81220 struct kprobe_blackpoint *kb;
81221 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
81222 kprobe_type = "k";
81223
81224 if (sym)
81225 - seq_printf(pi, "%p %s %s+0x%x %s ",
81226 + seq_printf(pi, "%pK %s %s+0x%x %s ",
81227 p->addr, kprobe_type, sym, offset,
81228 (modname ? modname : " "));
81229 else
81230 - seq_printf(pi, "%p %s %p ",
81231 + seq_printf(pi, "%pK %s %pK ",
81232 p->addr, kprobe_type, p->addr);
81233
81234 if (!pp)
81235 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
81236 const char *sym = NULL;
81237 unsigned int i = *(loff_t *) v;
81238 unsigned long offset = 0;
81239 - char *modname, namebuf[128];
81240 + char *modname, namebuf[KSYM_NAME_LEN];
81241
81242 head = &kprobe_table[i];
81243 preempt_disable();
81244 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
81245 index 6ada93c..dce7d5d 100644
81246 --- a/kernel/ksysfs.c
81247 +++ b/kernel/ksysfs.c
81248 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
81249 {
81250 if (count+1 > UEVENT_HELPER_PATH_LEN)
81251 return -ENOENT;
81252 + if (!capable(CAP_SYS_ADMIN))
81253 + return -EPERM;
81254 memcpy(uevent_helper, buf, count);
81255 uevent_helper[count] = '\0';
81256 if (count && uevent_helper[count-1] == '\n')
81257 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
81258 return count;
81259 }
81260
81261 -static struct bin_attribute notes_attr = {
81262 +static bin_attribute_no_const notes_attr __read_only = {
81263 .attr = {
81264 .name = "notes",
81265 .mode = S_IRUGO,
81266 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
81267 index e16c45b..6f49c48 100644
81268 --- a/kernel/lockdep.c
81269 +++ b/kernel/lockdep.c
81270 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
81271 end = (unsigned long) &_end,
81272 addr = (unsigned long) obj;
81273
81274 +#ifdef CONFIG_PAX_KERNEXEC
81275 + start = ktla_ktva(start);
81276 +#endif
81277 +
81278 /*
81279 * static variable?
81280 */
81281 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
81282 if (!static_obj(lock->key)) {
81283 debug_locks_off();
81284 printk("INFO: trying to register non-static key.\n");
81285 + printk("lock:%pS key:%pS.\n", lock, lock->key);
81286 printk("the code is fine but needs lockdep annotation.\n");
81287 printk("turning off the locking correctness validator.\n");
81288 dump_stack();
81289 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
81290 if (!class)
81291 return 0;
81292 }
81293 - atomic_inc((atomic_t *)&class->ops);
81294 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
81295 if (very_verbose(class)) {
81296 printk("\nacquire class [%p] %s", class->key, class->name);
81297 if (class->name_version > 1)
81298 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
81299 index b2c71c5..7b88d63 100644
81300 --- a/kernel/lockdep_proc.c
81301 +++ b/kernel/lockdep_proc.c
81302 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
81303 return 0;
81304 }
81305
81306 - seq_printf(m, "%p", class->key);
81307 + seq_printf(m, "%pK", class->key);
81308 #ifdef CONFIG_DEBUG_LOCKDEP
81309 seq_printf(m, " OPS:%8ld", class->ops);
81310 #endif
81311 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
81312
81313 list_for_each_entry(entry, &class->locks_after, entry) {
81314 if (entry->distance == 1) {
81315 - seq_printf(m, " -> [%p] ", entry->class->key);
81316 + seq_printf(m, " -> [%pK] ", entry->class->key);
81317 print_name(m, entry->class);
81318 seq_puts(m, "\n");
81319 }
81320 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
81321 if (!class->key)
81322 continue;
81323
81324 - seq_printf(m, "[%p] ", class->key);
81325 + seq_printf(m, "[%pK] ", class->key);
81326 print_name(m, class);
81327 seq_puts(m, "\n");
81328 }
81329 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81330 if (!i)
81331 seq_line(m, '-', 40-namelen, namelen);
81332
81333 - snprintf(ip, sizeof(ip), "[<%p>]",
81334 + snprintf(ip, sizeof(ip), "[<%pK>]",
81335 (void *)class->contention_point[i]);
81336 seq_printf(m, "%40s %14lu %29s %pS\n",
81337 name, stats->contention_point[i],
81338 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81339 if (!i)
81340 seq_line(m, '-', 40-namelen, namelen);
81341
81342 - snprintf(ip, sizeof(ip), "[<%p>]",
81343 + snprintf(ip, sizeof(ip), "[<%pK>]",
81344 (void *)class->contending_point[i]);
81345 seq_printf(m, "%40s %14lu %29s %pS\n",
81346 name, stats->contending_point[i],
81347 diff --git a/kernel/module.c b/kernel/module.c
81348 index 2069158..71101bb 100644
81349 --- a/kernel/module.c
81350 +++ b/kernel/module.c
81351 @@ -61,6 +61,7 @@
81352 #include <linux/pfn.h>
81353 #include <linux/bsearch.h>
81354 #include <linux/fips.h>
81355 +#include <linux/grsecurity.h>
81356 #include <uapi/linux/module.h>
81357 #include "module-internal.h"
81358
81359 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
81360
81361 /* Bounds of module allocation, for speeding __module_address.
81362 * Protected by module_mutex. */
81363 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
81364 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
81365 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
81366
81367 int register_module_notifier(struct notifier_block * nb)
81368 {
81369 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81370 return true;
81371
81372 list_for_each_entry_rcu(mod, &modules, list) {
81373 - struct symsearch arr[] = {
81374 + struct symsearch modarr[] = {
81375 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
81376 NOT_GPL_ONLY, false },
81377 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
81378 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81379 if (mod->state == MODULE_STATE_UNFORMED)
81380 continue;
81381
81382 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
81383 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
81384 return true;
81385 }
81386 return false;
81387 @@ -490,7 +492,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
81388 if (!pcpusec->sh_size)
81389 return 0;
81390
81391 - if (align > PAGE_SIZE) {
81392 + if (align-1 >= PAGE_SIZE) {
81393 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
81394 mod->name, align, PAGE_SIZE);
81395 align = PAGE_SIZE;
81396 @@ -1096,7 +1098,7 @@ struct module_attribute module_uevent =
81397 static ssize_t show_coresize(struct module_attribute *mattr,
81398 struct module_kobject *mk, char *buffer)
81399 {
81400 - return sprintf(buffer, "%u\n", mk->mod->core_size);
81401 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
81402 }
81403
81404 static struct module_attribute modinfo_coresize =
81405 @@ -1105,7 +1107,7 @@ static struct module_attribute modinfo_coresize =
81406 static ssize_t show_initsize(struct module_attribute *mattr,
81407 struct module_kobject *mk, char *buffer)
81408 {
81409 - return sprintf(buffer, "%u\n", mk->mod->init_size);
81410 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
81411 }
81412
81413 static struct module_attribute modinfo_initsize =
81414 @@ -1320,7 +1322,7 @@ resolve_symbol_wait(struct module *mod,
81415 */
81416 #ifdef CONFIG_SYSFS
81417
81418 -#ifdef CONFIG_KALLSYMS
81419 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81420 static inline bool sect_empty(const Elf_Shdr *sect)
81421 {
81422 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
81423 @@ -1460,7 +1462,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
81424 {
81425 unsigned int notes, loaded, i;
81426 struct module_notes_attrs *notes_attrs;
81427 - struct bin_attribute *nattr;
81428 + bin_attribute_no_const *nattr;
81429
81430 /* failed to create section attributes, so can't create notes */
81431 if (!mod->sect_attrs)
81432 @@ -1572,7 +1574,7 @@ static void del_usage_links(struct module *mod)
81433 static int module_add_modinfo_attrs(struct module *mod)
81434 {
81435 struct module_attribute *attr;
81436 - struct module_attribute *temp_attr;
81437 + module_attribute_no_const *temp_attr;
81438 int error = 0;
81439 int i;
81440
81441 @@ -1786,21 +1788,21 @@ static void set_section_ro_nx(void *base,
81442
81443 static void unset_module_core_ro_nx(struct module *mod)
81444 {
81445 - set_page_attributes(mod->module_core + mod->core_text_size,
81446 - mod->module_core + mod->core_size,
81447 + set_page_attributes(mod->module_core_rw,
81448 + mod->module_core_rw + mod->core_size_rw,
81449 set_memory_x);
81450 - set_page_attributes(mod->module_core,
81451 - mod->module_core + mod->core_ro_size,
81452 + set_page_attributes(mod->module_core_rx,
81453 + mod->module_core_rx + mod->core_size_rx,
81454 set_memory_rw);
81455 }
81456
81457 static void unset_module_init_ro_nx(struct module *mod)
81458 {
81459 - set_page_attributes(mod->module_init + mod->init_text_size,
81460 - mod->module_init + mod->init_size,
81461 + set_page_attributes(mod->module_init_rw,
81462 + mod->module_init_rw + mod->init_size_rw,
81463 set_memory_x);
81464 - set_page_attributes(mod->module_init,
81465 - mod->module_init + mod->init_ro_size,
81466 + set_page_attributes(mod->module_init_rx,
81467 + mod->module_init_rx + mod->init_size_rx,
81468 set_memory_rw);
81469 }
81470
81471 @@ -1813,14 +1815,14 @@ void set_all_modules_text_rw(void)
81472 list_for_each_entry_rcu(mod, &modules, list) {
81473 if (mod->state == MODULE_STATE_UNFORMED)
81474 continue;
81475 - if ((mod->module_core) && (mod->core_text_size)) {
81476 - set_page_attributes(mod->module_core,
81477 - mod->module_core + mod->core_text_size,
81478 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81479 + set_page_attributes(mod->module_core_rx,
81480 + mod->module_core_rx + mod->core_size_rx,
81481 set_memory_rw);
81482 }
81483 - if ((mod->module_init) && (mod->init_text_size)) {
81484 - set_page_attributes(mod->module_init,
81485 - mod->module_init + mod->init_text_size,
81486 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81487 + set_page_attributes(mod->module_init_rx,
81488 + mod->module_init_rx + mod->init_size_rx,
81489 set_memory_rw);
81490 }
81491 }
81492 @@ -1836,14 +1838,14 @@ void set_all_modules_text_ro(void)
81493 list_for_each_entry_rcu(mod, &modules, list) {
81494 if (mod->state == MODULE_STATE_UNFORMED)
81495 continue;
81496 - if ((mod->module_core) && (mod->core_text_size)) {
81497 - set_page_attributes(mod->module_core,
81498 - mod->module_core + mod->core_text_size,
81499 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81500 + set_page_attributes(mod->module_core_rx,
81501 + mod->module_core_rx + mod->core_size_rx,
81502 set_memory_ro);
81503 }
81504 - if ((mod->module_init) && (mod->init_text_size)) {
81505 - set_page_attributes(mod->module_init,
81506 - mod->module_init + mod->init_text_size,
81507 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81508 + set_page_attributes(mod->module_init_rx,
81509 + mod->module_init_rx + mod->init_size_rx,
81510 set_memory_ro);
81511 }
81512 }
81513 @@ -1894,16 +1896,19 @@ static void free_module(struct module *mod)
81514
81515 /* This may be NULL, but that's OK */
81516 unset_module_init_ro_nx(mod);
81517 - module_free(mod, mod->module_init);
81518 + module_free(mod, mod->module_init_rw);
81519 + module_free_exec(mod, mod->module_init_rx);
81520 kfree(mod->args);
81521 percpu_modfree(mod);
81522
81523 /* Free lock-classes: */
81524 - lockdep_free_key_range(mod->module_core, mod->core_size);
81525 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
81526 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
81527
81528 /* Finally, free the core (containing the module structure) */
81529 unset_module_core_ro_nx(mod);
81530 - module_free(mod, mod->module_core);
81531 + module_free_exec(mod, mod->module_core_rx);
81532 + module_free(mod, mod->module_core_rw);
81533
81534 #ifdef CONFIG_MPU
81535 update_protections(current->mm);
81536 @@ -1973,9 +1978,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81537 int ret = 0;
81538 const struct kernel_symbol *ksym;
81539
81540 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81541 + int is_fs_load = 0;
81542 + int register_filesystem_found = 0;
81543 + char *p;
81544 +
81545 + p = strstr(mod->args, "grsec_modharden_fs");
81546 + if (p) {
81547 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
81548 + /* copy \0 as well */
81549 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
81550 + is_fs_load = 1;
81551 + }
81552 +#endif
81553 +
81554 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
81555 const char *name = info->strtab + sym[i].st_name;
81556
81557 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81558 + /* it's a real shame this will never get ripped and copied
81559 + upstream! ;(
81560 + */
81561 + if (is_fs_load && !strcmp(name, "register_filesystem"))
81562 + register_filesystem_found = 1;
81563 +#endif
81564 +
81565 switch (sym[i].st_shndx) {
81566 case SHN_COMMON:
81567 /* We compiled with -fno-common. These are not
81568 @@ -1996,7 +2023,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81569 ksym = resolve_symbol_wait(mod, info, name);
81570 /* Ok if resolved. */
81571 if (ksym && !IS_ERR(ksym)) {
81572 + pax_open_kernel();
81573 sym[i].st_value = ksym->value;
81574 + pax_close_kernel();
81575 break;
81576 }
81577
81578 @@ -2015,11 +2044,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81579 secbase = (unsigned long)mod_percpu(mod);
81580 else
81581 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
81582 + pax_open_kernel();
81583 sym[i].st_value += secbase;
81584 + pax_close_kernel();
81585 break;
81586 }
81587 }
81588
81589 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81590 + if (is_fs_load && !register_filesystem_found) {
81591 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
81592 + ret = -EPERM;
81593 + }
81594 +#endif
81595 +
81596 return ret;
81597 }
81598
81599 @@ -2103,22 +2141,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
81600 || s->sh_entsize != ~0UL
81601 || strstarts(sname, ".init"))
81602 continue;
81603 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
81604 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81605 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
81606 + else
81607 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
81608 pr_debug("\t%s\n", sname);
81609 }
81610 - switch (m) {
81611 - case 0: /* executable */
81612 - mod->core_size = debug_align(mod->core_size);
81613 - mod->core_text_size = mod->core_size;
81614 - break;
81615 - case 1: /* RO: text and ro-data */
81616 - mod->core_size = debug_align(mod->core_size);
81617 - mod->core_ro_size = mod->core_size;
81618 - break;
81619 - case 3: /* whole core */
81620 - mod->core_size = debug_align(mod->core_size);
81621 - break;
81622 - }
81623 }
81624
81625 pr_debug("Init section allocation order:\n");
81626 @@ -2132,23 +2160,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
81627 || s->sh_entsize != ~0UL
81628 || !strstarts(sname, ".init"))
81629 continue;
81630 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
81631 - | INIT_OFFSET_MASK);
81632 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81633 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
81634 + else
81635 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
81636 + s->sh_entsize |= INIT_OFFSET_MASK;
81637 pr_debug("\t%s\n", sname);
81638 }
81639 - switch (m) {
81640 - case 0: /* executable */
81641 - mod->init_size = debug_align(mod->init_size);
81642 - mod->init_text_size = mod->init_size;
81643 - break;
81644 - case 1: /* RO: text and ro-data */
81645 - mod->init_size = debug_align(mod->init_size);
81646 - mod->init_ro_size = mod->init_size;
81647 - break;
81648 - case 3: /* whole init */
81649 - mod->init_size = debug_align(mod->init_size);
81650 - break;
81651 - }
81652 }
81653 }
81654
81655 @@ -2321,7 +2339,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81656
81657 /* Put symbol section at end of init part of module. */
81658 symsect->sh_flags |= SHF_ALLOC;
81659 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
81660 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
81661 info->index.sym) | INIT_OFFSET_MASK;
81662 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
81663
81664 @@ -2338,13 +2356,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81665 }
81666
81667 /* Append room for core symbols at end of core part. */
81668 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
81669 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
81670 - mod->core_size += strtab_size;
81671 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
81672 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
81673 + mod->core_size_rx += strtab_size;
81674
81675 /* Put string table section at end of init part of module. */
81676 strsect->sh_flags |= SHF_ALLOC;
81677 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
81678 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
81679 info->index.str) | INIT_OFFSET_MASK;
81680 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
81681 }
81682 @@ -2362,12 +2380,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81683 /* Make sure we get permanent strtab: don't use info->strtab. */
81684 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
81685
81686 + pax_open_kernel();
81687 +
81688 /* Set types up while we still have access to sections. */
81689 for (i = 0; i < mod->num_symtab; i++)
81690 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
81691
81692 - mod->core_symtab = dst = mod->module_core + info->symoffs;
81693 - mod->core_strtab = s = mod->module_core + info->stroffs;
81694 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
81695 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
81696 src = mod->symtab;
81697 for (ndst = i = 0; i < mod->num_symtab; i++) {
81698 if (i == 0 ||
81699 @@ -2379,6 +2399,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81700 }
81701 }
81702 mod->core_num_syms = ndst;
81703 +
81704 + pax_close_kernel();
81705 }
81706 #else
81707 static inline void layout_symtab(struct module *mod, struct load_info *info)
81708 @@ -2412,17 +2434,33 @@ void * __weak module_alloc(unsigned long size)
81709 return vmalloc_exec(size);
81710 }
81711
81712 -static void *module_alloc_update_bounds(unsigned long size)
81713 +static void *module_alloc_update_bounds_rw(unsigned long size)
81714 {
81715 void *ret = module_alloc(size);
81716
81717 if (ret) {
81718 mutex_lock(&module_mutex);
81719 /* Update module bounds. */
81720 - if ((unsigned long)ret < module_addr_min)
81721 - module_addr_min = (unsigned long)ret;
81722 - if ((unsigned long)ret + size > module_addr_max)
81723 - module_addr_max = (unsigned long)ret + size;
81724 + if ((unsigned long)ret < module_addr_min_rw)
81725 + module_addr_min_rw = (unsigned long)ret;
81726 + if ((unsigned long)ret + size > module_addr_max_rw)
81727 + module_addr_max_rw = (unsigned long)ret + size;
81728 + mutex_unlock(&module_mutex);
81729 + }
81730 + return ret;
81731 +}
81732 +
81733 +static void *module_alloc_update_bounds_rx(unsigned long size)
81734 +{
81735 + void *ret = module_alloc_exec(size);
81736 +
81737 + if (ret) {
81738 + mutex_lock(&module_mutex);
81739 + /* Update module bounds. */
81740 + if ((unsigned long)ret < module_addr_min_rx)
81741 + module_addr_min_rx = (unsigned long)ret;
81742 + if ((unsigned long)ret + size > module_addr_max_rx)
81743 + module_addr_max_rx = (unsigned long)ret + size;
81744 mutex_unlock(&module_mutex);
81745 }
81746 return ret;
81747 @@ -2698,8 +2736,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
81748 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81749 {
81750 const char *modmagic = get_modinfo(info, "vermagic");
81751 + const char *license = get_modinfo(info, "license");
81752 int err;
81753
81754 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
81755 + if (!license || !license_is_gpl_compatible(license))
81756 + return -ENOEXEC;
81757 +#endif
81758 +
81759 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
81760 modmagic = NULL;
81761
81762 @@ -2725,7 +2769,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81763 }
81764
81765 /* Set up license info based on the info section */
81766 - set_license(mod, get_modinfo(info, "license"));
81767 + set_license(mod, license);
81768
81769 return 0;
81770 }
81771 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
81772 void *ptr;
81773
81774 /* Do the allocs. */
81775 - ptr = module_alloc_update_bounds(mod->core_size);
81776 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
81777 /*
81778 * The pointer to this block is stored in the module structure
81779 * which is inside the block. Just mark it as not being a
81780 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
81781 if (!ptr)
81782 return -ENOMEM;
81783
81784 - memset(ptr, 0, mod->core_size);
81785 - mod->module_core = ptr;
81786 + memset(ptr, 0, mod->core_size_rw);
81787 + mod->module_core_rw = ptr;
81788
81789 - if (mod->init_size) {
81790 - ptr = module_alloc_update_bounds(mod->init_size);
81791 + if (mod->init_size_rw) {
81792 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
81793 /*
81794 * The pointer to this block is stored in the module structure
81795 * which is inside the block. This block doesn't need to be
81796 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
81797 */
81798 kmemleak_ignore(ptr);
81799 if (!ptr) {
81800 - module_free(mod, mod->module_core);
81801 + module_free(mod, mod->module_core_rw);
81802 return -ENOMEM;
81803 }
81804 - memset(ptr, 0, mod->init_size);
81805 - mod->module_init = ptr;
81806 + memset(ptr, 0, mod->init_size_rw);
81807 + mod->module_init_rw = ptr;
81808 } else
81809 - mod->module_init = NULL;
81810 + mod->module_init_rw = NULL;
81811 +
81812 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
81813 + kmemleak_not_leak(ptr);
81814 + if (!ptr) {
81815 + if (mod->module_init_rw)
81816 + module_free(mod, mod->module_init_rw);
81817 + module_free(mod, mod->module_core_rw);
81818 + return -ENOMEM;
81819 + }
81820 +
81821 + pax_open_kernel();
81822 + memset(ptr, 0, mod->core_size_rx);
81823 + pax_close_kernel();
81824 + mod->module_core_rx = ptr;
81825 +
81826 + if (mod->init_size_rx) {
81827 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
81828 + kmemleak_ignore(ptr);
81829 + if (!ptr && mod->init_size_rx) {
81830 + module_free_exec(mod, mod->module_core_rx);
81831 + if (mod->module_init_rw)
81832 + module_free(mod, mod->module_init_rw);
81833 + module_free(mod, mod->module_core_rw);
81834 + return -ENOMEM;
81835 + }
81836 +
81837 + pax_open_kernel();
81838 + memset(ptr, 0, mod->init_size_rx);
81839 + pax_close_kernel();
81840 + mod->module_init_rx = ptr;
81841 + } else
81842 + mod->module_init_rx = NULL;
81843
81844 /* Transfer each section which specifies SHF_ALLOC */
81845 pr_debug("final section addresses:\n");
81846 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
81847 if (!(shdr->sh_flags & SHF_ALLOC))
81848 continue;
81849
81850 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
81851 - dest = mod->module_init
81852 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81853 - else
81854 - dest = mod->module_core + shdr->sh_entsize;
81855 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
81856 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81857 + dest = mod->module_init_rw
81858 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81859 + else
81860 + dest = mod->module_init_rx
81861 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81862 + } else {
81863 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81864 + dest = mod->module_core_rw + shdr->sh_entsize;
81865 + else
81866 + dest = mod->module_core_rx + shdr->sh_entsize;
81867 + }
81868 +
81869 + if (shdr->sh_type != SHT_NOBITS) {
81870 +
81871 +#ifdef CONFIG_PAX_KERNEXEC
81872 +#ifdef CONFIG_X86_64
81873 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
81874 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
81875 +#endif
81876 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
81877 + pax_open_kernel();
81878 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81879 + pax_close_kernel();
81880 + } else
81881 +#endif
81882
81883 - if (shdr->sh_type != SHT_NOBITS)
81884 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81885 + }
81886 /* Update sh_addr to point to copy in image. */
81887 - shdr->sh_addr = (unsigned long)dest;
81888 +
81889 +#ifdef CONFIG_PAX_KERNEXEC
81890 + if (shdr->sh_flags & SHF_EXECINSTR)
81891 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
81892 + else
81893 +#endif
81894 +
81895 + shdr->sh_addr = (unsigned long)dest;
81896 pr_debug("\t0x%lx %s\n",
81897 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
81898 }
81899 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
81900 * Do it before processing of module parameters, so the module
81901 * can provide parameter accessor functions of its own.
81902 */
81903 - if (mod->module_init)
81904 - flush_icache_range((unsigned long)mod->module_init,
81905 - (unsigned long)mod->module_init
81906 - + mod->init_size);
81907 - flush_icache_range((unsigned long)mod->module_core,
81908 - (unsigned long)mod->module_core + mod->core_size);
81909 + if (mod->module_init_rx)
81910 + flush_icache_range((unsigned long)mod->module_init_rx,
81911 + (unsigned long)mod->module_init_rx
81912 + + mod->init_size_rx);
81913 + flush_icache_range((unsigned long)mod->module_core_rx,
81914 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
81915
81916 set_fs(old_fs);
81917 }
81918 @@ -2974,8 +3079,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
81919 static void module_deallocate(struct module *mod, struct load_info *info)
81920 {
81921 percpu_modfree(mod);
81922 - module_free(mod, mod->module_init);
81923 - module_free(mod, mod->module_core);
81924 + module_free_exec(mod, mod->module_init_rx);
81925 + module_free_exec(mod, mod->module_core_rx);
81926 + module_free(mod, mod->module_init_rw);
81927 + module_free(mod, mod->module_core_rw);
81928 }
81929
81930 int __weak module_finalize(const Elf_Ehdr *hdr,
81931 @@ -2988,7 +3095,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
81932 static int post_relocation(struct module *mod, const struct load_info *info)
81933 {
81934 /* Sort exception table now relocations are done. */
81935 + pax_open_kernel();
81936 sort_extable(mod->extable, mod->extable + mod->num_exentries);
81937 + pax_close_kernel();
81938
81939 /* Copy relocated percpu area over. */
81940 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
81941 @@ -3042,16 +3151,16 @@ static int do_init_module(struct module *mod)
81942 MODULE_STATE_COMING, mod);
81943
81944 /* Set RO and NX regions for core */
81945 - set_section_ro_nx(mod->module_core,
81946 - mod->core_text_size,
81947 - mod->core_ro_size,
81948 - mod->core_size);
81949 + set_section_ro_nx(mod->module_core_rx,
81950 + mod->core_size_rx,
81951 + mod->core_size_rx,
81952 + mod->core_size_rx);
81953
81954 /* Set RO and NX regions for init */
81955 - set_section_ro_nx(mod->module_init,
81956 - mod->init_text_size,
81957 - mod->init_ro_size,
81958 - mod->init_size);
81959 + set_section_ro_nx(mod->module_init_rx,
81960 + mod->init_size_rx,
81961 + mod->init_size_rx,
81962 + mod->init_size_rx);
81963
81964 do_mod_ctors(mod);
81965 /* Start the module */
81966 @@ -3113,11 +3222,12 @@ static int do_init_module(struct module *mod)
81967 mod->strtab = mod->core_strtab;
81968 #endif
81969 unset_module_init_ro_nx(mod);
81970 - module_free(mod, mod->module_init);
81971 - mod->module_init = NULL;
81972 - mod->init_size = 0;
81973 - mod->init_ro_size = 0;
81974 - mod->init_text_size = 0;
81975 + module_free(mod, mod->module_init_rw);
81976 + module_free_exec(mod, mod->module_init_rx);
81977 + mod->module_init_rw = NULL;
81978 + mod->module_init_rx = NULL;
81979 + mod->init_size_rw = 0;
81980 + mod->init_size_rx = 0;
81981 mutex_unlock(&module_mutex);
81982 wake_up_all(&module_wq);
81983
81984 @@ -3261,9 +3371,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
81985 if (err)
81986 goto free_unload;
81987
81988 + /* Now copy in args */
81989 + mod->args = strndup_user(uargs, ~0UL >> 1);
81990 + if (IS_ERR(mod->args)) {
81991 + err = PTR_ERR(mod->args);
81992 + goto free_unload;
81993 + }
81994 +
81995 /* Set up MODINFO_ATTR fields */
81996 setup_modinfo(mod, info);
81997
81998 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81999 + {
82000 + char *p, *p2;
82001 +
82002 + if (strstr(mod->args, "grsec_modharden_netdev")) {
82003 + 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);
82004 + err = -EPERM;
82005 + goto free_modinfo;
82006 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
82007 + p += sizeof("grsec_modharden_normal") - 1;
82008 + p2 = strstr(p, "_");
82009 + if (p2) {
82010 + *p2 = '\0';
82011 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
82012 + *p2 = '_';
82013 + }
82014 + err = -EPERM;
82015 + goto free_modinfo;
82016 + }
82017 + }
82018 +#endif
82019 +
82020 /* Fix up syms, so that st_value is a pointer to location. */
82021 err = simplify_symbols(mod, info);
82022 if (err < 0)
82023 @@ -3279,13 +3418,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
82024
82025 flush_module_icache(mod);
82026
82027 - /* Now copy in args */
82028 - mod->args = strndup_user(uargs, ~0UL >> 1);
82029 - if (IS_ERR(mod->args)) {
82030 - err = PTR_ERR(mod->args);
82031 - goto free_arch_cleanup;
82032 - }
82033 -
82034 dynamic_debug_setup(info->debug, info->num_debug);
82035
82036 /* Finally it's fully formed, ready to start executing. */
82037 @@ -3320,11 +3452,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
82038 ddebug_cleanup:
82039 dynamic_debug_remove(info->debug);
82040 synchronize_sched();
82041 - kfree(mod->args);
82042 - free_arch_cleanup:
82043 module_arch_cleanup(mod);
82044 free_modinfo:
82045 free_modinfo(mod);
82046 + kfree(mod->args);
82047 free_unload:
82048 module_unload_free(mod);
82049 unlink_mod:
82050 @@ -3407,10 +3538,16 @@ static const char *get_ksymbol(struct module *mod,
82051 unsigned long nextval;
82052
82053 /* At worse, next value is at end of module */
82054 - if (within_module_init(addr, mod))
82055 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
82056 + if (within_module_init_rx(addr, mod))
82057 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
82058 + else if (within_module_init_rw(addr, mod))
82059 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
82060 + else if (within_module_core_rx(addr, mod))
82061 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
82062 + else if (within_module_core_rw(addr, mod))
82063 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
82064 else
82065 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
82066 + return NULL;
82067
82068 /* Scan for closest preceding symbol, and next symbol. (ELF
82069 starts real symbols at 1). */
82070 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
82071 return 0;
82072
82073 seq_printf(m, "%s %u",
82074 - mod->name, mod->init_size + mod->core_size);
82075 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
82076 print_unload_info(m, mod);
82077
82078 /* Informative for users. */
82079 @@ -3670,7 +3807,7 @@ static int m_show(struct seq_file *m, void *p)
82080 mod->state == MODULE_STATE_COMING ? "Loading":
82081 "Live");
82082 /* Used by oprofile and other similar tools. */
82083 - seq_printf(m, " 0x%pK", mod->module_core);
82084 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
82085
82086 /* Taints info */
82087 if (mod->taints)
82088 @@ -3706,7 +3843,17 @@ static const struct file_operations proc_modules_operations = {
82089
82090 static int __init proc_modules_init(void)
82091 {
82092 +#ifndef CONFIG_GRKERNSEC_HIDESYM
82093 +#ifdef CONFIG_GRKERNSEC_PROC_USER
82094 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82095 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82096 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
82097 +#else
82098 proc_create("modules", 0, NULL, &proc_modules_operations);
82099 +#endif
82100 +#else
82101 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82102 +#endif
82103 return 0;
82104 }
82105 module_init(proc_modules_init);
82106 @@ -3767,14 +3914,14 @@ struct module *__module_address(unsigned long addr)
82107 {
82108 struct module *mod;
82109
82110 - if (addr < module_addr_min || addr > module_addr_max)
82111 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
82112 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
82113 return NULL;
82114
82115 list_for_each_entry_rcu(mod, &modules, list) {
82116 if (mod->state == MODULE_STATE_UNFORMED)
82117 continue;
82118 - if (within_module_core(addr, mod)
82119 - || within_module_init(addr, mod))
82120 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
82121 return mod;
82122 }
82123 return NULL;
82124 @@ -3809,11 +3956,20 @@ bool is_module_text_address(unsigned long addr)
82125 */
82126 struct module *__module_text_address(unsigned long addr)
82127 {
82128 - struct module *mod = __module_address(addr);
82129 + struct module *mod;
82130 +
82131 +#ifdef CONFIG_X86_32
82132 + addr = ktla_ktva(addr);
82133 +#endif
82134 +
82135 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
82136 + return NULL;
82137 +
82138 + mod = __module_address(addr);
82139 +
82140 if (mod) {
82141 /* Make sure it's within the text section. */
82142 - if (!within(addr, mod->module_init, mod->init_text_size)
82143 - && !within(addr, mod->module_core, mod->core_text_size))
82144 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
82145 mod = NULL;
82146 }
82147 return mod;
82148 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
82149 index 7e3443f..b2a1e6b 100644
82150 --- a/kernel/mutex-debug.c
82151 +++ b/kernel/mutex-debug.c
82152 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
82153 }
82154
82155 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82156 - struct thread_info *ti)
82157 + struct task_struct *task)
82158 {
82159 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
82160
82161 /* Mark the current thread as blocked on the lock: */
82162 - ti->task->blocked_on = waiter;
82163 + task->blocked_on = waiter;
82164 }
82165
82166 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82167 - struct thread_info *ti)
82168 + struct task_struct *task)
82169 {
82170 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
82171 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
82172 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
82173 - ti->task->blocked_on = NULL;
82174 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
82175 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
82176 + task->blocked_on = NULL;
82177
82178 list_del_init(&waiter->list);
82179 waiter->task = NULL;
82180 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
82181 index 0799fd3..d06ae3b 100644
82182 --- a/kernel/mutex-debug.h
82183 +++ b/kernel/mutex-debug.h
82184 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
82185 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
82186 extern void debug_mutex_add_waiter(struct mutex *lock,
82187 struct mutex_waiter *waiter,
82188 - struct thread_info *ti);
82189 + struct task_struct *task);
82190 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82191 - struct thread_info *ti);
82192 + struct task_struct *task);
82193 extern void debug_mutex_unlock(struct mutex *lock);
82194 extern void debug_mutex_init(struct mutex *lock, const char *name,
82195 struct lock_class_key *key);
82196 diff --git a/kernel/mutex.c b/kernel/mutex.c
82197 index a2b80f1..e91d35c 100644
82198 --- a/kernel/mutex.c
82199 +++ b/kernel/mutex.c
82200 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
82201 node->locked = 1;
82202 return;
82203 }
82204 - ACCESS_ONCE(prev->next) = node;
82205 + ACCESS_ONCE_RW(prev->next) = node;
82206 smp_wmb();
82207 /* Wait until the lock holder passes the lock down */
82208 while (!ACCESS_ONCE(node->locked))
82209 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
82210 while (!(next = ACCESS_ONCE(node->next)))
82211 arch_mutex_cpu_relax();
82212 }
82213 - ACCESS_ONCE(next->locked) = 1;
82214 + ACCESS_ONCE_RW(next->locked) = 1;
82215 smp_wmb();
82216 }
82217
82218 @@ -514,7 +514,7 @@ slowpath:
82219 spin_lock_mutex(&lock->wait_lock, flags);
82220
82221 debug_mutex_lock_common(lock, &waiter);
82222 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
82223 + debug_mutex_add_waiter(lock, &waiter, task);
82224
82225 /* add waiting tasks to the end of the waitqueue (FIFO): */
82226 list_add_tail(&waiter.list, &lock->wait_list);
82227 @@ -565,7 +565,7 @@ slowpath:
82228 done:
82229 lock_acquired(&lock->dep_map, ip);
82230 /* got the lock - rejoice! */
82231 - mutex_remove_waiter(lock, &waiter, current_thread_info());
82232 + mutex_remove_waiter(lock, &waiter, task);
82233 mutex_set_owner(lock);
82234
82235 if (use_ww_ctx) {
82236 @@ -604,7 +604,7 @@ done:
82237 return 0;
82238
82239 err:
82240 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
82241 + mutex_remove_waiter(lock, &waiter, task);
82242 spin_unlock_mutex(&lock->wait_lock, flags);
82243 debug_mutex_free_waiter(&waiter);
82244 mutex_release(&lock->dep_map, 1, ip);
82245 diff --git a/kernel/notifier.c b/kernel/notifier.c
82246 index 2d5cc4c..d9ea600 100644
82247 --- a/kernel/notifier.c
82248 +++ b/kernel/notifier.c
82249 @@ -5,6 +5,7 @@
82250 #include <linux/rcupdate.h>
82251 #include <linux/vmalloc.h>
82252 #include <linux/reboot.h>
82253 +#include <linux/mm.h>
82254
82255 /*
82256 * Notifier list for kernel code which wants to be called
82257 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
82258 while ((*nl) != NULL) {
82259 if (n->priority > (*nl)->priority)
82260 break;
82261 - nl = &((*nl)->next);
82262 + nl = (struct notifier_block **)&((*nl)->next);
82263 }
82264 - n->next = *nl;
82265 + pax_open_kernel();
82266 + *(const void **)&n->next = *nl;
82267 rcu_assign_pointer(*nl, n);
82268 + pax_close_kernel();
82269 return 0;
82270 }
82271
82272 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
82273 return 0;
82274 if (n->priority > (*nl)->priority)
82275 break;
82276 - nl = &((*nl)->next);
82277 + nl = (struct notifier_block **)&((*nl)->next);
82278 }
82279 - n->next = *nl;
82280 + pax_open_kernel();
82281 + *(const void **)&n->next = *nl;
82282 rcu_assign_pointer(*nl, n);
82283 + pax_close_kernel();
82284 return 0;
82285 }
82286
82287 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
82288 {
82289 while ((*nl) != NULL) {
82290 if ((*nl) == n) {
82291 + pax_open_kernel();
82292 rcu_assign_pointer(*nl, n->next);
82293 + pax_close_kernel();
82294 return 0;
82295 }
82296 - nl = &((*nl)->next);
82297 + nl = (struct notifier_block **)&((*nl)->next);
82298 }
82299 return -ENOENT;
82300 }
82301 diff --git a/kernel/panic.c b/kernel/panic.c
82302 index 8018646..b6a5b4f 100644
82303 --- a/kernel/panic.c
82304 +++ b/kernel/panic.c
82305 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
82306 disable_trace_on_warning();
82307
82308 pr_warn("------------[ cut here ]------------\n");
82309 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
82310 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
82311 raw_smp_processor_id(), current->pid, file, line, caller);
82312
82313 if (args)
82314 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
82315 */
82316 void __stack_chk_fail(void)
82317 {
82318 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
82319 + dump_stack();
82320 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
82321 __builtin_return_address(0));
82322 }
82323 EXPORT_SYMBOL(__stack_chk_fail);
82324 diff --git a/kernel/pid.c b/kernel/pid.c
82325 index ebe5e80..5d6d634 100644
82326 --- a/kernel/pid.c
82327 +++ b/kernel/pid.c
82328 @@ -33,6 +33,7 @@
82329 #include <linux/rculist.h>
82330 #include <linux/bootmem.h>
82331 #include <linux/hash.h>
82332 +#include <linux/security.h>
82333 #include <linux/pid_namespace.h>
82334 #include <linux/init_task.h>
82335 #include <linux/syscalls.h>
82336 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
82337
82338 int pid_max = PID_MAX_DEFAULT;
82339
82340 -#define RESERVED_PIDS 300
82341 +#define RESERVED_PIDS 500
82342
82343 int pid_max_min = RESERVED_PIDS + 1;
82344 int pid_max_max = PID_MAX_LIMIT;
82345 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
82346 */
82347 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
82348 {
82349 + struct task_struct *task;
82350 +
82351 rcu_lockdep_assert(rcu_read_lock_held(),
82352 "find_task_by_pid_ns() needs rcu_read_lock()"
82353 " protection");
82354 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82355 +
82356 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82357 +
82358 + if (gr_pid_is_chrooted(task))
82359 + return NULL;
82360 +
82361 + return task;
82362 }
82363
82364 struct task_struct *find_task_by_vpid(pid_t vnr)
82365 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
82366 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
82367 }
82368
82369 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
82370 +{
82371 + rcu_lockdep_assert(rcu_read_lock_held(),
82372 + "find_task_by_pid_ns() needs rcu_read_lock()"
82373 + " protection");
82374 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
82375 +}
82376 +
82377 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
82378 {
82379 struct pid *pid;
82380 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
82381 index 601bb36..f7e6f34 100644
82382 --- a/kernel/pid_namespace.c
82383 +++ b/kernel/pid_namespace.c
82384 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
82385 void __user *buffer, size_t *lenp, loff_t *ppos)
82386 {
82387 struct pid_namespace *pid_ns = task_active_pid_ns(current);
82388 - struct ctl_table tmp = *table;
82389 + ctl_table_no_const tmp = *table;
82390
82391 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
82392 return -EPERM;
82393 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
82394 index c7f31aa..2b44977 100644
82395 --- a/kernel/posix-cpu-timers.c
82396 +++ b/kernel/posix-cpu-timers.c
82397 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
82398
82399 static __init int init_posix_cpu_timers(void)
82400 {
82401 - struct k_clock process = {
82402 + static struct k_clock process = {
82403 .clock_getres = process_cpu_clock_getres,
82404 .clock_get = process_cpu_clock_get,
82405 .timer_create = process_cpu_timer_create,
82406 .nsleep = process_cpu_nsleep,
82407 .nsleep_restart = process_cpu_nsleep_restart,
82408 };
82409 - struct k_clock thread = {
82410 + static struct k_clock thread = {
82411 .clock_getres = thread_cpu_clock_getres,
82412 .clock_get = thread_cpu_clock_get,
82413 .timer_create = thread_cpu_timer_create,
82414 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
82415 index 424c2d4..679242f 100644
82416 --- a/kernel/posix-timers.c
82417 +++ b/kernel/posix-timers.c
82418 @@ -43,6 +43,7 @@
82419 #include <linux/hash.h>
82420 #include <linux/posix-clock.h>
82421 #include <linux/posix-timers.h>
82422 +#include <linux/grsecurity.h>
82423 #include <linux/syscalls.h>
82424 #include <linux/wait.h>
82425 #include <linux/workqueue.h>
82426 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
82427 * which we beg off on and pass to do_sys_settimeofday().
82428 */
82429
82430 -static struct k_clock posix_clocks[MAX_CLOCKS];
82431 +static struct k_clock *posix_clocks[MAX_CLOCKS];
82432
82433 /*
82434 * These ones are defined below.
82435 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
82436 */
82437 static __init int init_posix_timers(void)
82438 {
82439 - struct k_clock clock_realtime = {
82440 + static struct k_clock clock_realtime = {
82441 .clock_getres = hrtimer_get_res,
82442 .clock_get = posix_clock_realtime_get,
82443 .clock_set = posix_clock_realtime_set,
82444 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
82445 .timer_get = common_timer_get,
82446 .timer_del = common_timer_del,
82447 };
82448 - struct k_clock clock_monotonic = {
82449 + static struct k_clock clock_monotonic = {
82450 .clock_getres = hrtimer_get_res,
82451 .clock_get = posix_ktime_get_ts,
82452 .nsleep = common_nsleep,
82453 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
82454 .timer_get = common_timer_get,
82455 .timer_del = common_timer_del,
82456 };
82457 - struct k_clock clock_monotonic_raw = {
82458 + static struct k_clock clock_monotonic_raw = {
82459 .clock_getres = hrtimer_get_res,
82460 .clock_get = posix_get_monotonic_raw,
82461 };
82462 - struct k_clock clock_realtime_coarse = {
82463 + static struct k_clock clock_realtime_coarse = {
82464 .clock_getres = posix_get_coarse_res,
82465 .clock_get = posix_get_realtime_coarse,
82466 };
82467 - struct k_clock clock_monotonic_coarse = {
82468 + static struct k_clock clock_monotonic_coarse = {
82469 .clock_getres = posix_get_coarse_res,
82470 .clock_get = posix_get_monotonic_coarse,
82471 };
82472 - struct k_clock clock_tai = {
82473 + static struct k_clock clock_tai = {
82474 .clock_getres = hrtimer_get_res,
82475 .clock_get = posix_get_tai,
82476 .nsleep = common_nsleep,
82477 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
82478 .timer_get = common_timer_get,
82479 .timer_del = common_timer_del,
82480 };
82481 - struct k_clock clock_boottime = {
82482 + static struct k_clock clock_boottime = {
82483 .clock_getres = hrtimer_get_res,
82484 .clock_get = posix_get_boottime,
82485 .nsleep = common_nsleep,
82486 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
82487 return;
82488 }
82489
82490 - posix_clocks[clock_id] = *new_clock;
82491 + posix_clocks[clock_id] = new_clock;
82492 }
82493 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
82494
82495 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
82496 return (id & CLOCKFD_MASK) == CLOCKFD ?
82497 &clock_posix_dynamic : &clock_posix_cpu;
82498
82499 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
82500 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
82501 return NULL;
82502 - return &posix_clocks[id];
82503 + return posix_clocks[id];
82504 }
82505
82506 static int common_timer_create(struct k_itimer *new_timer)
82507 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
82508 struct k_clock *kc = clockid_to_kclock(which_clock);
82509 struct k_itimer *new_timer;
82510 int error, new_timer_id;
82511 - sigevent_t event;
82512 + sigevent_t event = { };
82513 int it_id_set = IT_ID_NOT_SET;
82514
82515 if (!kc)
82516 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
82517 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
82518 return -EFAULT;
82519
82520 + /* only the CLOCK_REALTIME clock can be set, all other clocks
82521 + have their clock_set fptr set to a nosettime dummy function
82522 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
82523 + call common_clock_set, which calls do_sys_settimeofday, which
82524 + we hook
82525 + */
82526 +
82527 return kc->clock_set(which_clock, &new_tp);
82528 }
82529
82530 diff --git a/kernel/power/process.c b/kernel/power/process.c
82531 index 06ec886..9dba35e 100644
82532 --- a/kernel/power/process.c
82533 +++ b/kernel/power/process.c
82534 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
82535 unsigned int elapsed_msecs;
82536 bool wakeup = false;
82537 int sleep_usecs = USEC_PER_MSEC;
82538 + bool timedout = false;
82539
82540 do_gettimeofday(&start);
82541
82542 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
82543
82544 while (true) {
82545 todo = 0;
82546 + if (time_after(jiffies, end_time))
82547 + timedout = true;
82548 read_lock(&tasklist_lock);
82549 do_each_thread(g, p) {
82550 if (p == current || !freeze_task(p))
82551 continue;
82552
82553 - if (!freezer_should_skip(p))
82554 + if (!freezer_should_skip(p)) {
82555 todo++;
82556 + if (timedout) {
82557 + printk(KERN_ERR "Task refusing to freeze:\n");
82558 + sched_show_task(p);
82559 + }
82560 + }
82561 } while_each_thread(g, p);
82562 read_unlock(&tasklist_lock);
82563
82564 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
82565 todo += wq_busy;
82566 }
82567
82568 - if (!todo || time_after(jiffies, end_time))
82569 + if (!todo || timedout)
82570 break;
82571
82572 if (pm_wakeup_pending()) {
82573 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
82574 index 5b5a708..ec7637e 100644
82575 --- a/kernel/printk/printk.c
82576 +++ b/kernel/printk/printk.c
82577 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
82578 if (from_file && type != SYSLOG_ACTION_OPEN)
82579 return 0;
82580
82581 +#ifdef CONFIG_GRKERNSEC_DMESG
82582 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
82583 + return -EPERM;
82584 +#endif
82585 +
82586 if (syslog_action_restricted(type)) {
82587 if (capable(CAP_SYSLOG))
82588 return 0;
82589 diff --git a/kernel/profile.c b/kernel/profile.c
82590 index 6631e1e..310c266 100644
82591 --- a/kernel/profile.c
82592 +++ b/kernel/profile.c
82593 @@ -37,7 +37,7 @@ struct profile_hit {
82594 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
82595 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
82596
82597 -static atomic_t *prof_buffer;
82598 +static atomic_unchecked_t *prof_buffer;
82599 static unsigned long prof_len, prof_shift;
82600
82601 int prof_on __read_mostly;
82602 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
82603 hits[i].pc = 0;
82604 continue;
82605 }
82606 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82607 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82608 hits[i].hits = hits[i].pc = 0;
82609 }
82610 }
82611 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82612 * Add the current hit(s) and flush the write-queue out
82613 * to the global buffer:
82614 */
82615 - atomic_add(nr_hits, &prof_buffer[pc]);
82616 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
82617 for (i = 0; i < NR_PROFILE_HIT; ++i) {
82618 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82619 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82620 hits[i].pc = hits[i].hits = 0;
82621 }
82622 out:
82623 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82624 {
82625 unsigned long pc;
82626 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
82627 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82628 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82629 }
82630 #endif /* !CONFIG_SMP */
82631
82632 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
82633 return -EFAULT;
82634 buf++; p++; count--; read++;
82635 }
82636 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
82637 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
82638 if (copy_to_user(buf, (void *)pnt, count))
82639 return -EFAULT;
82640 read += count;
82641 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
82642 }
82643 #endif
82644 profile_discard_flip_buffers();
82645 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
82646 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
82647 return count;
82648 }
82649
82650 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
82651 index a146ee3..ffed4c3 100644
82652 --- a/kernel/ptrace.c
82653 +++ b/kernel/ptrace.c
82654 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
82655 if (seize)
82656 flags |= PT_SEIZED;
82657 rcu_read_lock();
82658 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82659 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82660 flags |= PT_PTRACE_CAP;
82661 rcu_read_unlock();
82662 task->ptrace = flags;
82663 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
82664 break;
82665 return -EIO;
82666 }
82667 - if (copy_to_user(dst, buf, retval))
82668 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
82669 return -EFAULT;
82670 copied += retval;
82671 src += retval;
82672 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
82673 bool seized = child->ptrace & PT_SEIZED;
82674 int ret = -EIO;
82675 siginfo_t siginfo, *si;
82676 - void __user *datavp = (void __user *) data;
82677 + void __user *datavp = (__force void __user *) data;
82678 unsigned long __user *datalp = datavp;
82679 unsigned long flags;
82680
82681 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
82682 goto out;
82683 }
82684
82685 + if (gr_handle_ptrace(child, request)) {
82686 + ret = -EPERM;
82687 + goto out_put_task_struct;
82688 + }
82689 +
82690 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82691 ret = ptrace_attach(child, request, addr, data);
82692 /*
82693 * Some architectures need to do book-keeping after
82694 * a ptrace attach.
82695 */
82696 - if (!ret)
82697 + if (!ret) {
82698 arch_ptrace_attach(child);
82699 + gr_audit_ptrace(child);
82700 + }
82701 goto out_put_task_struct;
82702 }
82703
82704 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
82705 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
82706 if (copied != sizeof(tmp))
82707 return -EIO;
82708 - return put_user(tmp, (unsigned long __user *)data);
82709 + return put_user(tmp, (__force unsigned long __user *)data);
82710 }
82711
82712 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
82713 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
82714 }
82715
82716 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82717 - compat_long_t addr, compat_long_t data)
82718 + compat_ulong_t addr, compat_ulong_t data)
82719 {
82720 struct task_struct *child;
82721 long ret;
82722 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82723 goto out;
82724 }
82725
82726 + if (gr_handle_ptrace(child, request)) {
82727 + ret = -EPERM;
82728 + goto out_put_task_struct;
82729 + }
82730 +
82731 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82732 ret = ptrace_attach(child, request, addr, data);
82733 /*
82734 * Some architectures need to do book-keeping after
82735 * a ptrace attach.
82736 */
82737 - if (!ret)
82738 + if (!ret) {
82739 arch_ptrace_attach(child);
82740 + gr_audit_ptrace(child);
82741 + }
82742 goto out_put_task_struct;
82743 }
82744
82745 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
82746 index cce6ba8..7c758b1f 100644
82747 --- a/kernel/rcupdate.c
82748 +++ b/kernel/rcupdate.c
82749 @@ -412,10 +412,10 @@ int rcu_jiffies_till_stall_check(void)
82750 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
82751 */
82752 if (till_stall_check < 3) {
82753 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
82754 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
82755 till_stall_check = 3;
82756 } else if (till_stall_check > 300) {
82757 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
82758 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
82759 till_stall_check = 300;
82760 }
82761 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
82762 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
82763 index aa34411..4832cd4 100644
82764 --- a/kernel/rcutiny.c
82765 +++ b/kernel/rcutiny.c
82766 @@ -45,7 +45,7 @@
82767 /* Forward declarations for rcutiny_plugin.h. */
82768 struct rcu_ctrlblk;
82769 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
82770 -static void rcu_process_callbacks(struct softirq_action *unused);
82771 +static void rcu_process_callbacks(void);
82772 static void __call_rcu(struct rcu_head *head,
82773 void (*func)(struct rcu_head *rcu),
82774 struct rcu_ctrlblk *rcp);
82775 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
82776 false));
82777 }
82778
82779 -static void rcu_process_callbacks(struct softirq_action *unused)
82780 +static __latent_entropy void rcu_process_callbacks(void)
82781 {
82782 __rcu_process_callbacks(&rcu_sched_ctrlblk);
82783 __rcu_process_callbacks(&rcu_bh_ctrlblk);
82784 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
82785 index f4871e5..8ef5741 100644
82786 --- a/kernel/rcutorture.c
82787 +++ b/kernel/rcutorture.c
82788 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
82789 { 0 };
82790 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
82791 { 0 };
82792 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82793 -static atomic_t n_rcu_torture_alloc;
82794 -static atomic_t n_rcu_torture_alloc_fail;
82795 -static atomic_t n_rcu_torture_free;
82796 -static atomic_t n_rcu_torture_mberror;
82797 -static atomic_t n_rcu_torture_error;
82798 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82799 +static atomic_unchecked_t n_rcu_torture_alloc;
82800 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
82801 +static atomic_unchecked_t n_rcu_torture_free;
82802 +static atomic_unchecked_t n_rcu_torture_mberror;
82803 +static atomic_unchecked_t n_rcu_torture_error;
82804 static long n_rcu_torture_barrier_error;
82805 static long n_rcu_torture_boost_ktrerror;
82806 static long n_rcu_torture_boost_rterror;
82807 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
82808
82809 spin_lock_bh(&rcu_torture_lock);
82810 if (list_empty(&rcu_torture_freelist)) {
82811 - atomic_inc(&n_rcu_torture_alloc_fail);
82812 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
82813 spin_unlock_bh(&rcu_torture_lock);
82814 return NULL;
82815 }
82816 - atomic_inc(&n_rcu_torture_alloc);
82817 + atomic_inc_unchecked(&n_rcu_torture_alloc);
82818 p = rcu_torture_freelist.next;
82819 list_del_init(p);
82820 spin_unlock_bh(&rcu_torture_lock);
82821 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
82822 static void
82823 rcu_torture_free(struct rcu_torture *p)
82824 {
82825 - atomic_inc(&n_rcu_torture_free);
82826 + atomic_inc_unchecked(&n_rcu_torture_free);
82827 spin_lock_bh(&rcu_torture_lock);
82828 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
82829 spin_unlock_bh(&rcu_torture_lock);
82830 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
82831 i = rp->rtort_pipe_count;
82832 if (i > RCU_TORTURE_PIPE_LEN)
82833 i = RCU_TORTURE_PIPE_LEN;
82834 - atomic_inc(&rcu_torture_wcount[i]);
82835 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82836 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82837 rp->rtort_mbtest = 0;
82838 rcu_torture_free(rp);
82839 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
82840 i = rp->rtort_pipe_count;
82841 if (i > RCU_TORTURE_PIPE_LEN)
82842 i = RCU_TORTURE_PIPE_LEN;
82843 - atomic_inc(&rcu_torture_wcount[i]);
82844 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82845 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82846 rp->rtort_mbtest = 0;
82847 list_del(&rp->rtort_free);
82848 @@ -952,7 +952,7 @@ rcu_torture_writer(void *arg)
82849 i = old_rp->rtort_pipe_count;
82850 if (i > RCU_TORTURE_PIPE_LEN)
82851 i = RCU_TORTURE_PIPE_LEN;
82852 - atomic_inc(&rcu_torture_wcount[i]);
82853 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82854 old_rp->rtort_pipe_count++;
82855 cur_ops->deferred_free(old_rp);
82856 }
82857 @@ -1038,7 +1038,7 @@ static void rcu_torture_timer(unsigned long unused)
82858 return;
82859 }
82860 if (p->rtort_mbtest == 0)
82861 - atomic_inc(&n_rcu_torture_mberror);
82862 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82863 spin_lock(&rand_lock);
82864 cur_ops->read_delay(&rand);
82865 n_rcu_torture_timers++;
82866 @@ -1108,7 +1108,7 @@ rcu_torture_reader(void *arg)
82867 continue;
82868 }
82869 if (p->rtort_mbtest == 0)
82870 - atomic_inc(&n_rcu_torture_mberror);
82871 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82872 cur_ops->read_delay(&rand);
82873 preempt_disable();
82874 pipe_count = p->rtort_pipe_count;
82875 @@ -1171,11 +1171,11 @@ rcu_torture_printk(char *page)
82876 rcu_torture_current,
82877 rcu_torture_current_version,
82878 list_empty(&rcu_torture_freelist),
82879 - atomic_read(&n_rcu_torture_alloc),
82880 - atomic_read(&n_rcu_torture_alloc_fail),
82881 - atomic_read(&n_rcu_torture_free));
82882 + atomic_read_unchecked(&n_rcu_torture_alloc),
82883 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
82884 + atomic_read_unchecked(&n_rcu_torture_free));
82885 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
82886 - atomic_read(&n_rcu_torture_mberror),
82887 + atomic_read_unchecked(&n_rcu_torture_mberror),
82888 n_rcu_torture_boost_ktrerror,
82889 n_rcu_torture_boost_rterror);
82890 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
82891 @@ -1194,14 +1194,14 @@ rcu_torture_printk(char *page)
82892 n_barrier_attempts,
82893 n_rcu_torture_barrier_error);
82894 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
82895 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
82896 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
82897 n_rcu_torture_barrier_error != 0 ||
82898 n_rcu_torture_boost_ktrerror != 0 ||
82899 n_rcu_torture_boost_rterror != 0 ||
82900 n_rcu_torture_boost_failure != 0 ||
82901 i > 1) {
82902 cnt += sprintf(&page[cnt], "!!! ");
82903 - atomic_inc(&n_rcu_torture_error);
82904 + atomic_inc_unchecked(&n_rcu_torture_error);
82905 WARN_ON_ONCE(1);
82906 }
82907 cnt += sprintf(&page[cnt], "Reader Pipe: ");
82908 @@ -1215,7 +1215,7 @@ rcu_torture_printk(char *page)
82909 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
82910 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82911 cnt += sprintf(&page[cnt], " %d",
82912 - atomic_read(&rcu_torture_wcount[i]));
82913 + atomic_read_unchecked(&rcu_torture_wcount[i]));
82914 }
82915 cnt += sprintf(&page[cnt], "\n");
82916 if (cur_ops->stats)
82917 @@ -1924,7 +1924,7 @@ rcu_torture_cleanup(void)
82918
82919 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
82920
82921 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82922 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82923 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
82924 else if (n_online_successes != n_online_attempts ||
82925 n_offline_successes != n_offline_attempts)
82926 @@ -1992,18 +1992,18 @@ rcu_torture_init(void)
82927
82928 rcu_torture_current = NULL;
82929 rcu_torture_current_version = 0;
82930 - atomic_set(&n_rcu_torture_alloc, 0);
82931 - atomic_set(&n_rcu_torture_alloc_fail, 0);
82932 - atomic_set(&n_rcu_torture_free, 0);
82933 - atomic_set(&n_rcu_torture_mberror, 0);
82934 - atomic_set(&n_rcu_torture_error, 0);
82935 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
82936 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
82937 + atomic_set_unchecked(&n_rcu_torture_free, 0);
82938 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
82939 + atomic_set_unchecked(&n_rcu_torture_error, 0);
82940 n_rcu_torture_barrier_error = 0;
82941 n_rcu_torture_boost_ktrerror = 0;
82942 n_rcu_torture_boost_rterror = 0;
82943 n_rcu_torture_boost_failure = 0;
82944 n_rcu_torture_boosts = 0;
82945 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
82946 - atomic_set(&rcu_torture_wcount[i], 0);
82947 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
82948 for_each_possible_cpu(cpu) {
82949 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82950 per_cpu(rcu_torture_count, cpu)[i] = 0;
82951 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
82952 index 068de3a..5e7db2f 100644
82953 --- a/kernel/rcutree.c
82954 +++ b/kernel/rcutree.c
82955 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
82956 rcu_prepare_for_idle(smp_processor_id());
82957 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82958 smp_mb__before_atomic_inc(); /* See above. */
82959 - atomic_inc(&rdtp->dynticks);
82960 + atomic_inc_unchecked(&rdtp->dynticks);
82961 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
82962 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82963 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82964
82965 /*
82966 * It is illegal to enter an extended quiescent state while
82967 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
82968 int user)
82969 {
82970 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
82971 - atomic_inc(&rdtp->dynticks);
82972 + atomic_inc_unchecked(&rdtp->dynticks);
82973 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82974 smp_mb__after_atomic_inc(); /* See above. */
82975 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82976 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82977 rcu_cleanup_after_idle(smp_processor_id());
82978 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
82979 if (!user && !is_idle_task(current)) {
82980 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
82981 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
82982
82983 if (rdtp->dynticks_nmi_nesting == 0 &&
82984 - (atomic_read(&rdtp->dynticks) & 0x1))
82985 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
82986 return;
82987 rdtp->dynticks_nmi_nesting++;
82988 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
82989 - atomic_inc(&rdtp->dynticks);
82990 + atomic_inc_unchecked(&rdtp->dynticks);
82991 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82992 smp_mb__after_atomic_inc(); /* See above. */
82993 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82994 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82995 }
82996
82997 /**
82998 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
82999 return;
83000 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83001 smp_mb__before_atomic_inc(); /* See above. */
83002 - atomic_inc(&rdtp->dynticks);
83003 + atomic_inc_unchecked(&rdtp->dynticks);
83004 smp_mb__after_atomic_inc(); /* Force delay to next write. */
83005 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83006 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83007 }
83008
83009 /**
83010 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
83011 int ret;
83012
83013 preempt_disable();
83014 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83015 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83016 preempt_enable();
83017 return ret;
83018 }
83019 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
83020 */
83021 static int dyntick_save_progress_counter(struct rcu_data *rdp)
83022 {
83023 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
83024 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83025 return (rdp->dynticks_snap & 0x1) == 0;
83026 }
83027
83028 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
83029 unsigned int curr;
83030 unsigned int snap;
83031
83032 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
83033 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83034 snap = (unsigned int)rdp->dynticks_snap;
83035
83036 /*
83037 @@ -1351,9 +1351,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
83038 rdp = this_cpu_ptr(rsp->rda);
83039 rcu_preempt_check_blocked_tasks(rnp);
83040 rnp->qsmask = rnp->qsmaskinit;
83041 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
83042 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
83043 WARN_ON_ONCE(rnp->completed != rsp->completed);
83044 - ACCESS_ONCE(rnp->completed) = rsp->completed;
83045 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
83046 if (rnp == rdp->mynode)
83047 __note_gp_changes(rsp, rnp, rdp);
83048 rcu_preempt_boost_start_gp(rnp);
83049 @@ -1435,7 +1435,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
83050 */
83051 rcu_for_each_node_breadth_first(rsp, rnp) {
83052 raw_spin_lock_irq(&rnp->lock);
83053 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
83054 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
83055 rdp = this_cpu_ptr(rsp->rda);
83056 if (rnp == rdp->mynode)
83057 __note_gp_changes(rsp, rnp, rdp);
83058 @@ -1765,7 +1765,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
83059 rsp->qlen += rdp->qlen;
83060 rdp->n_cbs_orphaned += rdp->qlen;
83061 rdp->qlen_lazy = 0;
83062 - ACCESS_ONCE(rdp->qlen) = 0;
83063 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83064 }
83065
83066 /*
83067 @@ -2011,7 +2011,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
83068 }
83069 smp_mb(); /* List handling before counting for rcu_barrier(). */
83070 rdp->qlen_lazy -= count_lazy;
83071 - ACCESS_ONCE(rdp->qlen) -= count;
83072 + ACCESS_ONCE_RW(rdp->qlen) -= count;
83073 rdp->n_cbs_invoked += count;
83074
83075 /* Reinstate batch limit if we have worked down the excess. */
83076 @@ -2202,7 +2202,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
83077 /*
83078 * Do RCU core processing for the current CPU.
83079 */
83080 -static void rcu_process_callbacks(struct softirq_action *unused)
83081 +static __latent_entropy void rcu_process_callbacks(void)
83082 {
83083 struct rcu_state *rsp;
83084
83085 @@ -2325,7 +2325,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
83086 local_irq_restore(flags);
83087 return;
83088 }
83089 - ACCESS_ONCE(rdp->qlen)++;
83090 + ACCESS_ONCE_RW(rdp->qlen)++;
83091 if (lazy)
83092 rdp->qlen_lazy++;
83093 else
83094 @@ -2534,11 +2534,11 @@ void synchronize_sched_expedited(void)
83095 * counter wrap on a 32-bit system. Quite a few more CPUs would of
83096 * course be required on a 64-bit system.
83097 */
83098 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
83099 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
83100 (ulong)atomic_long_read(&rsp->expedited_done) +
83101 ULONG_MAX / 8)) {
83102 synchronize_sched();
83103 - atomic_long_inc(&rsp->expedited_wrap);
83104 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
83105 return;
83106 }
83107
83108 @@ -2546,7 +2546,7 @@ void synchronize_sched_expedited(void)
83109 * Take a ticket. Note that atomic_inc_return() implies a
83110 * full memory barrier.
83111 */
83112 - snap = atomic_long_inc_return(&rsp->expedited_start);
83113 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
83114 firstsnap = snap;
83115 get_online_cpus();
83116 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
83117 @@ -2559,14 +2559,14 @@ void synchronize_sched_expedited(void)
83118 synchronize_sched_expedited_cpu_stop,
83119 NULL) == -EAGAIN) {
83120 put_online_cpus();
83121 - atomic_long_inc(&rsp->expedited_tryfail);
83122 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
83123
83124 /* Check to see if someone else did our work for us. */
83125 s = atomic_long_read(&rsp->expedited_done);
83126 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83127 /* ensure test happens before caller kfree */
83128 smp_mb__before_atomic_inc(); /* ^^^ */
83129 - atomic_long_inc(&rsp->expedited_workdone1);
83130 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
83131 return;
83132 }
83133
83134 @@ -2575,7 +2575,7 @@ void synchronize_sched_expedited(void)
83135 udelay(trycount * num_online_cpus());
83136 } else {
83137 wait_rcu_gp(call_rcu_sched);
83138 - atomic_long_inc(&rsp->expedited_normal);
83139 + atomic_long_inc_unchecked(&rsp->expedited_normal);
83140 return;
83141 }
83142
83143 @@ -2584,7 +2584,7 @@ void synchronize_sched_expedited(void)
83144 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83145 /* ensure test happens before caller kfree */
83146 smp_mb__before_atomic_inc(); /* ^^^ */
83147 - atomic_long_inc(&rsp->expedited_workdone2);
83148 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
83149 return;
83150 }
83151
83152 @@ -2596,10 +2596,10 @@ void synchronize_sched_expedited(void)
83153 * period works for us.
83154 */
83155 get_online_cpus();
83156 - snap = atomic_long_read(&rsp->expedited_start);
83157 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
83158 smp_mb(); /* ensure read is before try_stop_cpus(). */
83159 }
83160 - atomic_long_inc(&rsp->expedited_stoppedcpus);
83161 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
83162
83163 /*
83164 * Everyone up to our most recent fetch is covered by our grace
83165 @@ -2608,16 +2608,16 @@ void synchronize_sched_expedited(void)
83166 * than we did already did their update.
83167 */
83168 do {
83169 - atomic_long_inc(&rsp->expedited_done_tries);
83170 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
83171 s = atomic_long_read(&rsp->expedited_done);
83172 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
83173 /* ensure test happens before caller kfree */
83174 smp_mb__before_atomic_inc(); /* ^^^ */
83175 - atomic_long_inc(&rsp->expedited_done_lost);
83176 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
83177 break;
83178 }
83179 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
83180 - atomic_long_inc(&rsp->expedited_done_exit);
83181 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
83182
83183 put_online_cpus();
83184 }
83185 @@ -2799,7 +2799,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83186 * ACCESS_ONCE() to prevent the compiler from speculating
83187 * the increment to precede the early-exit check.
83188 */
83189 - ACCESS_ONCE(rsp->n_barrier_done)++;
83190 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83191 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
83192 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
83193 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
83194 @@ -2849,7 +2849,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83195
83196 /* Increment ->n_barrier_done to prevent duplicate work. */
83197 smp_mb(); /* Keep increment after above mechanism. */
83198 - ACCESS_ONCE(rsp->n_barrier_done)++;
83199 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83200 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
83201 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
83202 smp_mb(); /* Keep increment before caller's subsequent code. */
83203 @@ -2894,10 +2894,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
83204 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
83205 init_callback_list(rdp);
83206 rdp->qlen_lazy = 0;
83207 - ACCESS_ONCE(rdp->qlen) = 0;
83208 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83209 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
83210 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
83211 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
83212 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
83213 rdp->cpu = cpu;
83214 rdp->rsp = rsp;
83215 rcu_boot_init_nocb_percpu_data(rdp);
83216 @@ -2930,8 +2930,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
83217 rdp->blimit = blimit;
83218 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
83219 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
83220 - atomic_set(&rdp->dynticks->dynticks,
83221 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
83222 + atomic_set_unchecked(&rdp->dynticks->dynticks,
83223 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
83224 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
83225
83226 /* Add CPU to rcu_node bitmasks. */
83227 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
83228 index b383258..2440c1e 100644
83229 --- a/kernel/rcutree.h
83230 +++ b/kernel/rcutree.h
83231 @@ -87,7 +87,7 @@ struct rcu_dynticks {
83232 long long dynticks_nesting; /* Track irq/process nesting level. */
83233 /* Process level is worth LLONG_MAX/2. */
83234 int dynticks_nmi_nesting; /* Track NMI nesting level. */
83235 - atomic_t dynticks; /* Even value for idle, else odd. */
83236 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
83237 #ifdef CONFIG_RCU_FAST_NO_HZ
83238 bool all_lazy; /* Are all CPU's CBs lazy? */
83239 unsigned long nonlazy_posted;
83240 @@ -419,17 +419,17 @@ struct rcu_state {
83241 /* _rcu_barrier(). */
83242 /* End of fields guarded by barrier_mutex. */
83243
83244 - atomic_long_t expedited_start; /* Starting ticket. */
83245 - atomic_long_t expedited_done; /* Done ticket. */
83246 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
83247 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
83248 - atomic_long_t expedited_workdone1; /* # done by others #1. */
83249 - atomic_long_t expedited_workdone2; /* # done by others #2. */
83250 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
83251 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
83252 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
83253 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
83254 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
83255 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
83256 + atomic_long_t expedited_done; /* Done ticket. */
83257 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
83258 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
83259 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
83260 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
83261 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
83262 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
83263 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
83264 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
83265 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
83266
83267 unsigned long jiffies_force_qs; /* Time at which to invoke */
83268 /* force_quiescent_state(). */
83269 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
83270 index 769e12e..7b2139b 100644
83271 --- a/kernel/rcutree_plugin.h
83272 +++ b/kernel/rcutree_plugin.h
83273 @@ -902,7 +902,7 @@ void synchronize_rcu_expedited(void)
83274
83275 /* Clean up and exit. */
83276 smp_mb(); /* ensure expedited GP seen before counter increment. */
83277 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
83278 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
83279 unlock_mb_ret:
83280 mutex_unlock(&sync_rcu_preempt_exp_mutex);
83281 mb_ret:
83282 @@ -1476,7 +1476,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
83283 free_cpumask_var(cm);
83284 }
83285
83286 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
83287 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
83288 .store = &rcu_cpu_kthread_task,
83289 .thread_should_run = rcu_cpu_kthread_should_run,
83290 .thread_fn = rcu_cpu_kthread,
83291 @@ -1941,7 +1941,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
83292 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
83293 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
83294 cpu, ticks_value, ticks_title,
83295 - atomic_read(&rdtp->dynticks) & 0xfff,
83296 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
83297 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
83298 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
83299 fast_no_hz);
83300 @@ -2104,7 +2104,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
83301
83302 /* Enqueue the callback on the nocb list and update counts. */
83303 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
83304 - ACCESS_ONCE(*old_rhpp) = rhp;
83305 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
83306 atomic_long_add(rhcount, &rdp->nocb_q_count);
83307 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
83308
83309 @@ -2244,12 +2244,12 @@ static int rcu_nocb_kthread(void *arg)
83310 * Extract queued callbacks, update counts, and wait
83311 * for a grace period to elapse.
83312 */
83313 - ACCESS_ONCE(rdp->nocb_head) = NULL;
83314 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
83315 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
83316 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
83317 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
83318 - ACCESS_ONCE(rdp->nocb_p_count) += c;
83319 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
83320 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
83321 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
83322 rcu_nocb_wait_gp(rdp);
83323
83324 /* Each pass through the following loop invokes a callback. */
83325 @@ -2271,8 +2271,8 @@ static int rcu_nocb_kthread(void *arg)
83326 list = next;
83327 }
83328 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
83329 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
83330 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
83331 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
83332 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
83333 rdp->n_nocbs_invoked += c;
83334 }
83335 return 0;
83336 @@ -2299,7 +2299,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
83337 t = kthread_run(rcu_nocb_kthread, rdp,
83338 "rcuo%c/%d", rsp->abbr, cpu);
83339 BUG_ON(IS_ERR(t));
83340 - ACCESS_ONCE(rdp->nocb_kthread) = t;
83341 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
83342 }
83343 }
83344
83345 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
83346 index cf6c174..a8f4b50 100644
83347 --- a/kernel/rcutree_trace.c
83348 +++ b/kernel/rcutree_trace.c
83349 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
83350 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
83351 rdp->passed_quiesce, rdp->qs_pending);
83352 seq_printf(m, " dt=%d/%llx/%d df=%lu",
83353 - atomic_read(&rdp->dynticks->dynticks),
83354 + atomic_read_unchecked(&rdp->dynticks->dynticks),
83355 rdp->dynticks->dynticks_nesting,
83356 rdp->dynticks->dynticks_nmi_nesting,
83357 rdp->dynticks_fqs);
83358 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
83359 struct rcu_state *rsp = (struct rcu_state *)m->private;
83360
83361 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",
83362 - atomic_long_read(&rsp->expedited_start),
83363 + atomic_long_read_unchecked(&rsp->expedited_start),
83364 atomic_long_read(&rsp->expedited_done),
83365 - atomic_long_read(&rsp->expedited_wrap),
83366 - atomic_long_read(&rsp->expedited_tryfail),
83367 - atomic_long_read(&rsp->expedited_workdone1),
83368 - atomic_long_read(&rsp->expedited_workdone2),
83369 - atomic_long_read(&rsp->expedited_normal),
83370 - atomic_long_read(&rsp->expedited_stoppedcpus),
83371 - atomic_long_read(&rsp->expedited_done_tries),
83372 - atomic_long_read(&rsp->expedited_done_lost),
83373 - atomic_long_read(&rsp->expedited_done_exit));
83374 + atomic_long_read_unchecked(&rsp->expedited_wrap),
83375 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
83376 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
83377 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
83378 + atomic_long_read_unchecked(&rsp->expedited_normal),
83379 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
83380 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
83381 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
83382 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
83383 return 0;
83384 }
83385
83386 diff --git a/kernel/resource.c b/kernel/resource.c
83387 index 3f285dc..5755f62 100644
83388 --- a/kernel/resource.c
83389 +++ b/kernel/resource.c
83390 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
83391
83392 static int __init ioresources_init(void)
83393 {
83394 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
83395 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83396 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
83397 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
83398 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83399 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
83400 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
83401 +#endif
83402 +#else
83403 proc_create("ioports", 0, NULL, &proc_ioports_operations);
83404 proc_create("iomem", 0, NULL, &proc_iomem_operations);
83405 +#endif
83406 return 0;
83407 }
83408 __initcall(ioresources_init);
83409 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
83410 index 1d96dd0..994ff19 100644
83411 --- a/kernel/rtmutex-tester.c
83412 +++ b/kernel/rtmutex-tester.c
83413 @@ -22,7 +22,7 @@
83414 #define MAX_RT_TEST_MUTEXES 8
83415
83416 static spinlock_t rttest_lock;
83417 -static atomic_t rttest_event;
83418 +static atomic_unchecked_t rttest_event;
83419
83420 struct test_thread_data {
83421 int opcode;
83422 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83423
83424 case RTTEST_LOCKCONT:
83425 td->mutexes[td->opdata] = 1;
83426 - td->event = atomic_add_return(1, &rttest_event);
83427 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83428 return 0;
83429
83430 case RTTEST_RESET:
83431 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83432 return 0;
83433
83434 case RTTEST_RESETEVENT:
83435 - atomic_set(&rttest_event, 0);
83436 + atomic_set_unchecked(&rttest_event, 0);
83437 return 0;
83438
83439 default:
83440 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83441 return ret;
83442
83443 td->mutexes[id] = 1;
83444 - td->event = atomic_add_return(1, &rttest_event);
83445 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83446 rt_mutex_lock(&mutexes[id]);
83447 - td->event = atomic_add_return(1, &rttest_event);
83448 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83449 td->mutexes[id] = 4;
83450 return 0;
83451
83452 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83453 return ret;
83454
83455 td->mutexes[id] = 1;
83456 - td->event = atomic_add_return(1, &rttest_event);
83457 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83458 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
83459 - td->event = atomic_add_return(1, &rttest_event);
83460 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83461 td->mutexes[id] = ret ? 0 : 4;
83462 return ret ? -EINTR : 0;
83463
83464 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83465 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
83466 return ret;
83467
83468 - td->event = atomic_add_return(1, &rttest_event);
83469 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83470 rt_mutex_unlock(&mutexes[id]);
83471 - td->event = atomic_add_return(1, &rttest_event);
83472 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83473 td->mutexes[id] = 0;
83474 return 0;
83475
83476 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83477 break;
83478
83479 td->mutexes[dat] = 2;
83480 - td->event = atomic_add_return(1, &rttest_event);
83481 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83482 break;
83483
83484 default:
83485 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83486 return;
83487
83488 td->mutexes[dat] = 3;
83489 - td->event = atomic_add_return(1, &rttest_event);
83490 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83491 break;
83492
83493 case RTTEST_LOCKNOWAIT:
83494 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83495 return;
83496
83497 td->mutexes[dat] = 1;
83498 - td->event = atomic_add_return(1, &rttest_event);
83499 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83500 return;
83501
83502 default:
83503 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
83504 index 4a07353..66b5291 100644
83505 --- a/kernel/sched/auto_group.c
83506 +++ b/kernel/sched/auto_group.c
83507 @@ -11,7 +11,7 @@
83508
83509 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
83510 static struct autogroup autogroup_default;
83511 -static atomic_t autogroup_seq_nr;
83512 +static atomic_unchecked_t autogroup_seq_nr;
83513
83514 void __init autogroup_init(struct task_struct *init_task)
83515 {
83516 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
83517
83518 kref_init(&ag->kref);
83519 init_rwsem(&ag->lock);
83520 - ag->id = atomic_inc_return(&autogroup_seq_nr);
83521 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
83522 ag->tg = tg;
83523 #ifdef CONFIG_RT_GROUP_SCHED
83524 /*
83525 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
83526 index 05c39f0..442e6fe 100644
83527 --- a/kernel/sched/core.c
83528 +++ b/kernel/sched/core.c
83529 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
83530 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83531 * or number of jiffies left till timeout) if completed.
83532 */
83533 -long __sched
83534 +long __sched __intentional_overflow(-1)
83535 wait_for_completion_interruptible_timeout(struct completion *x,
83536 unsigned long timeout)
83537 {
83538 @@ -2902,7 +2902,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
83539 *
83540 * Return: -ERESTARTSYS if interrupted, 0 if completed.
83541 */
83542 -int __sched wait_for_completion_killable(struct completion *x)
83543 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
83544 {
83545 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
83546 if (t == -ERESTARTSYS)
83547 @@ -2923,7 +2923,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
83548 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83549 * or number of jiffies left till timeout) if completed.
83550 */
83551 -long __sched
83552 +long __sched __intentional_overflow(-1)
83553 wait_for_completion_killable_timeout(struct completion *x,
83554 unsigned long timeout)
83555 {
83556 @@ -3149,6 +3149,8 @@ int can_nice(const struct task_struct *p, const int nice)
83557 /* convert nice value [19,-20] to rlimit style value [1,40] */
83558 int nice_rlim = 20 - nice;
83559
83560 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
83561 +
83562 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
83563 capable(CAP_SYS_NICE));
83564 }
83565 @@ -3182,7 +3184,8 @@ SYSCALL_DEFINE1(nice, int, increment)
83566 if (nice > 19)
83567 nice = 19;
83568
83569 - if (increment < 0 && !can_nice(current, nice))
83570 + if (increment < 0 && (!can_nice(current, nice) ||
83571 + gr_handle_chroot_nice()))
83572 return -EPERM;
83573
83574 retval = security_task_setnice(current, nice);
83575 @@ -3344,6 +3347,7 @@ recheck:
83576 unsigned long rlim_rtprio =
83577 task_rlimit(p, RLIMIT_RTPRIO);
83578
83579 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
83580 /* can't set/change the rt policy */
83581 if (policy != p->policy && !rlim_rtprio)
83582 return -EPERM;
83583 @@ -4473,7 +4477,7 @@ static void migrate_tasks(unsigned int dead_cpu)
83584
83585 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
83586
83587 -static struct ctl_table sd_ctl_dir[] = {
83588 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
83589 {
83590 .procname = "sched_domain",
83591 .mode = 0555,
83592 @@ -4490,17 +4494,17 @@ static struct ctl_table sd_ctl_root[] = {
83593 {}
83594 };
83595
83596 -static struct ctl_table *sd_alloc_ctl_entry(int n)
83597 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
83598 {
83599 - struct ctl_table *entry =
83600 + ctl_table_no_const *entry =
83601 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
83602
83603 return entry;
83604 }
83605
83606 -static void sd_free_ctl_entry(struct ctl_table **tablep)
83607 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
83608 {
83609 - struct ctl_table *entry;
83610 + ctl_table_no_const *entry;
83611
83612 /*
83613 * In the intermediate directories, both the child directory and
83614 @@ -4508,22 +4512,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
83615 * will always be set. In the lowest directory the names are
83616 * static strings and all have proc handlers.
83617 */
83618 - for (entry = *tablep; entry->mode; entry++) {
83619 - if (entry->child)
83620 - sd_free_ctl_entry(&entry->child);
83621 + for (entry = tablep; entry->mode; entry++) {
83622 + if (entry->child) {
83623 + sd_free_ctl_entry(entry->child);
83624 + pax_open_kernel();
83625 + entry->child = NULL;
83626 + pax_close_kernel();
83627 + }
83628 if (entry->proc_handler == NULL)
83629 kfree(entry->procname);
83630 }
83631
83632 - kfree(*tablep);
83633 - *tablep = NULL;
83634 + kfree(tablep);
83635 }
83636
83637 static int min_load_idx = 0;
83638 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
83639
83640 static void
83641 -set_table_entry(struct ctl_table *entry,
83642 +set_table_entry(ctl_table_no_const *entry,
83643 const char *procname, void *data, int maxlen,
83644 umode_t mode, proc_handler *proc_handler,
83645 bool load_idx)
83646 @@ -4543,7 +4550,7 @@ set_table_entry(struct ctl_table *entry,
83647 static struct ctl_table *
83648 sd_alloc_ctl_domain_table(struct sched_domain *sd)
83649 {
83650 - struct ctl_table *table = sd_alloc_ctl_entry(13);
83651 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
83652
83653 if (table == NULL)
83654 return NULL;
83655 @@ -4578,9 +4585,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
83656 return table;
83657 }
83658
83659 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
83660 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
83661 {
83662 - struct ctl_table *entry, *table;
83663 + ctl_table_no_const *entry, *table;
83664 struct sched_domain *sd;
83665 int domain_num = 0, i;
83666 char buf[32];
83667 @@ -4607,11 +4614,13 @@ static struct ctl_table_header *sd_sysctl_header;
83668 static void register_sched_domain_sysctl(void)
83669 {
83670 int i, cpu_num = num_possible_cpus();
83671 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
83672 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
83673 char buf[32];
83674
83675 WARN_ON(sd_ctl_dir[0].child);
83676 + pax_open_kernel();
83677 sd_ctl_dir[0].child = entry;
83678 + pax_close_kernel();
83679
83680 if (entry == NULL)
83681 return;
83682 @@ -4634,8 +4643,12 @@ static void unregister_sched_domain_sysctl(void)
83683 if (sd_sysctl_header)
83684 unregister_sysctl_table(sd_sysctl_header);
83685 sd_sysctl_header = NULL;
83686 - if (sd_ctl_dir[0].child)
83687 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
83688 + if (sd_ctl_dir[0].child) {
83689 + sd_free_ctl_entry(sd_ctl_dir[0].child);
83690 + pax_open_kernel();
83691 + sd_ctl_dir[0].child = NULL;
83692 + pax_close_kernel();
83693 + }
83694 }
83695 #else
83696 static void register_sched_domain_sysctl(void)
83697 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
83698 index 31cbc15..ba68c15 100644
83699 --- a/kernel/sched/fair.c
83700 +++ b/kernel/sched/fair.c
83701 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
83702
83703 static void reset_ptenuma_scan(struct task_struct *p)
83704 {
83705 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
83706 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
83707 p->mm->numa_scan_offset = 0;
83708 }
83709
83710 @@ -5727,7 +5727,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
83711 * run_rebalance_domains is triggered when needed from the scheduler tick.
83712 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
83713 */
83714 -static void run_rebalance_domains(struct softirq_action *h)
83715 +static __latent_entropy void run_rebalance_domains(void)
83716 {
83717 int this_cpu = smp_processor_id();
83718 struct rq *this_rq = cpu_rq(this_cpu);
83719 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
83720 index ef0a7b2..1b728c1 100644
83721 --- a/kernel/sched/sched.h
83722 +++ b/kernel/sched/sched.h
83723 @@ -1004,7 +1004,7 @@ struct sched_class {
83724 #ifdef CONFIG_FAIR_GROUP_SCHED
83725 void (*task_move_group) (struct task_struct *p, int on_rq);
83726 #endif
83727 -};
83728 +} __do_const;
83729
83730 #define sched_class_highest (&stop_sched_class)
83731 #define for_each_class(class) \
83732 diff --git a/kernel/signal.c b/kernel/signal.c
83733 index 50e4107..9409983 100644
83734 --- a/kernel/signal.c
83735 +++ b/kernel/signal.c
83736 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
83737
83738 int print_fatal_signals __read_mostly;
83739
83740 -static void __user *sig_handler(struct task_struct *t, int sig)
83741 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
83742 {
83743 return t->sighand->action[sig - 1].sa.sa_handler;
83744 }
83745
83746 -static int sig_handler_ignored(void __user *handler, int sig)
83747 +static int sig_handler_ignored(__sighandler_t handler, int sig)
83748 {
83749 /* Is it explicitly or implicitly ignored? */
83750 return handler == SIG_IGN ||
83751 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
83752
83753 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
83754 {
83755 - void __user *handler;
83756 + __sighandler_t handler;
83757
83758 handler = sig_handler(t, sig);
83759
83760 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
83761 atomic_inc(&user->sigpending);
83762 rcu_read_unlock();
83763
83764 + if (!override_rlimit)
83765 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
83766 +
83767 if (override_rlimit ||
83768 atomic_read(&user->sigpending) <=
83769 task_rlimit(t, RLIMIT_SIGPENDING)) {
83770 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
83771
83772 int unhandled_signal(struct task_struct *tsk, int sig)
83773 {
83774 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
83775 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
83776 if (is_global_init(tsk))
83777 return 1;
83778 if (handler != SIG_IGN && handler != SIG_DFL)
83779 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
83780 }
83781 }
83782
83783 + /* allow glibc communication via tgkill to other threads in our
83784 + thread group */
83785 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
83786 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
83787 + && gr_handle_signal(t, sig))
83788 + return -EPERM;
83789 +
83790 return security_task_kill(t, info, sig, 0);
83791 }
83792
83793 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83794 return send_signal(sig, info, p, 1);
83795 }
83796
83797 -static int
83798 +int
83799 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83800 {
83801 return send_signal(sig, info, t, 0);
83802 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83803 unsigned long int flags;
83804 int ret, blocked, ignored;
83805 struct k_sigaction *action;
83806 + int is_unhandled = 0;
83807
83808 spin_lock_irqsave(&t->sighand->siglock, flags);
83809 action = &t->sighand->action[sig-1];
83810 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83811 }
83812 if (action->sa.sa_handler == SIG_DFL)
83813 t->signal->flags &= ~SIGNAL_UNKILLABLE;
83814 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
83815 + is_unhandled = 1;
83816 ret = specific_send_sig_info(sig, info, t);
83817 spin_unlock_irqrestore(&t->sighand->siglock, flags);
83818
83819 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
83820 + normal operation */
83821 + if (is_unhandled) {
83822 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
83823 + gr_handle_crash(t, sig);
83824 + }
83825 +
83826 return ret;
83827 }
83828
83829 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83830 ret = check_kill_permission(sig, info, p);
83831 rcu_read_unlock();
83832
83833 - if (!ret && sig)
83834 + if (!ret && sig) {
83835 ret = do_send_sig_info(sig, info, p, true);
83836 + if (!ret)
83837 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
83838 + }
83839
83840 return ret;
83841 }
83842 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
83843 int error = -ESRCH;
83844
83845 rcu_read_lock();
83846 - p = find_task_by_vpid(pid);
83847 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
83848 + /* allow glibc communication via tgkill to other threads in our
83849 + thread group */
83850 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
83851 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
83852 + p = find_task_by_vpid_unrestricted(pid);
83853 + else
83854 +#endif
83855 + p = find_task_by_vpid(pid);
83856 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
83857 error = check_kill_permission(sig, info, p);
83858 /*
83859 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
83860 }
83861 seg = get_fs();
83862 set_fs(KERNEL_DS);
83863 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
83864 - (stack_t __force __user *) &uoss,
83865 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
83866 + (stack_t __force_user *) &uoss,
83867 compat_user_stack_pointer());
83868 set_fs(seg);
83869 if (ret >= 0 && uoss_ptr) {
83870 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
83871 index eb89e18..a4e6792 100644
83872 --- a/kernel/smpboot.c
83873 +++ b/kernel/smpboot.c
83874 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
83875 }
83876 smpboot_unpark_thread(plug_thread, cpu);
83877 }
83878 - list_add(&plug_thread->list, &hotplug_threads);
83879 + pax_list_add(&plug_thread->list, &hotplug_threads);
83880 out:
83881 mutex_unlock(&smpboot_threads_lock);
83882 return ret;
83883 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
83884 {
83885 get_online_cpus();
83886 mutex_lock(&smpboot_threads_lock);
83887 - list_del(&plug_thread->list);
83888 + pax_list_del(&plug_thread->list);
83889 smpboot_destroy_threads(plug_thread);
83890 mutex_unlock(&smpboot_threads_lock);
83891 put_online_cpus();
83892 diff --git a/kernel/softirq.c b/kernel/softirq.c
83893 index adf6c00..5d89b73 100644
83894 --- a/kernel/softirq.c
83895 +++ b/kernel/softirq.c
83896 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
83897 EXPORT_SYMBOL(irq_stat);
83898 #endif
83899
83900 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
83901 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
83902
83903 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
83904
83905 -char *softirq_to_name[NR_SOFTIRQS] = {
83906 +const char * const softirq_to_name[NR_SOFTIRQS] = {
83907 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
83908 "TASKLET", "SCHED", "HRTIMER", "RCU"
83909 };
83910 @@ -248,7 +248,7 @@ restart:
83911 kstat_incr_softirqs_this_cpu(vec_nr);
83912
83913 trace_softirq_entry(vec_nr);
83914 - h->action(h);
83915 + h->action();
83916 trace_softirq_exit(vec_nr);
83917 if (unlikely(prev_count != preempt_count())) {
83918 printk(KERN_ERR "huh, entered softirq %u %s %p"
83919 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
83920 or_softirq_pending(1UL << nr);
83921 }
83922
83923 -void open_softirq(int nr, void (*action)(struct softirq_action *))
83924 +void __init open_softirq(int nr, void (*action)(void))
83925 {
83926 softirq_vec[nr].action = action;
83927 }
83928 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
83929
83930 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
83931
83932 -static void tasklet_action(struct softirq_action *a)
83933 +static __latent_entropy void tasklet_action(void)
83934 {
83935 struct tasklet_struct *list;
83936
83937 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
83938 }
83939 }
83940
83941 -static void tasklet_hi_action(struct softirq_action *a)
83942 +static __latent_entropy void tasklet_hi_action(void)
83943 {
83944 struct tasklet_struct *list;
83945
83946 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
83947 .notifier_call = cpu_callback
83948 };
83949
83950 -static struct smp_hotplug_thread softirq_threads = {
83951 +static struct smp_hotplug_thread softirq_threads __read_only = {
83952 .store = &ksoftirqd,
83953 .thread_should_run = ksoftirqd_should_run,
83954 .thread_fn = run_ksoftirqd,
83955 diff --git a/kernel/srcu.c b/kernel/srcu.c
83956 index 01d5ccb..cdcbee6 100644
83957 --- a/kernel/srcu.c
83958 +++ b/kernel/srcu.c
83959 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
83960
83961 idx = ACCESS_ONCE(sp->completed) & 0x1;
83962 preempt_disable();
83963 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83964 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83965 smp_mb(); /* B */ /* Avoid leaking the critical section. */
83966 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83967 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83968 preempt_enable();
83969 return idx;
83970 }
83971 diff --git a/kernel/sys.c b/kernel/sys.c
83972 index 771129b..dc0c7e3 100644
83973 --- a/kernel/sys.c
83974 +++ b/kernel/sys.c
83975 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
83976 error = -EACCES;
83977 goto out;
83978 }
83979 +
83980 + if (gr_handle_chroot_setpriority(p, niceval)) {
83981 + error = -EACCES;
83982 + goto out;
83983 + }
83984 +
83985 no_nice = security_task_setnice(p, niceval);
83986 if (no_nice) {
83987 error = no_nice;
83988 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
83989 goto error;
83990 }
83991
83992 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
83993 + goto error;
83994 +
83995 if (rgid != (gid_t) -1 ||
83996 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
83997 new->sgid = new->egid;
83998 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
83999 old = current_cred();
84000
84001 retval = -EPERM;
84002 +
84003 + if (gr_check_group_change(kgid, kgid, kgid))
84004 + goto error;
84005 +
84006 if (nsown_capable(CAP_SETGID))
84007 new->gid = new->egid = new->sgid = new->fsgid = kgid;
84008 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
84009 @@ -404,7 +417,7 @@ error:
84010 /*
84011 * change the user struct in a credentials set to match the new UID
84012 */
84013 -static int set_user(struct cred *new)
84014 +int set_user(struct cred *new)
84015 {
84016 struct user_struct *new_user;
84017
84018 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
84019 goto error;
84020 }
84021
84022 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
84023 + goto error;
84024 +
84025 if (!uid_eq(new->uid, old->uid)) {
84026 retval = set_user(new);
84027 if (retval < 0)
84028 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
84029 old = current_cred();
84030
84031 retval = -EPERM;
84032 +
84033 + if (gr_check_crash_uid(kuid))
84034 + goto error;
84035 + if (gr_check_user_change(kuid, kuid, kuid))
84036 + goto error;
84037 +
84038 if (nsown_capable(CAP_SETUID)) {
84039 new->suid = new->uid = kuid;
84040 if (!uid_eq(kuid, old->uid)) {
84041 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
84042 goto error;
84043 }
84044
84045 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
84046 + goto error;
84047 +
84048 if (ruid != (uid_t) -1) {
84049 new->uid = kruid;
84050 if (!uid_eq(kruid, old->uid)) {
84051 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
84052 goto error;
84053 }
84054
84055 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
84056 + goto error;
84057 +
84058 if (rgid != (gid_t) -1)
84059 new->gid = krgid;
84060 if (egid != (gid_t) -1)
84061 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
84062 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
84063 nsown_capable(CAP_SETUID)) {
84064 if (!uid_eq(kuid, old->fsuid)) {
84065 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
84066 + goto error;
84067 +
84068 new->fsuid = kuid;
84069 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
84070 goto change_okay;
84071 }
84072 }
84073
84074 +error:
84075 abort_creds(new);
84076 return old_fsuid;
84077
84078 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
84079 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
84080 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
84081 nsown_capable(CAP_SETGID)) {
84082 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
84083 + goto error;
84084 +
84085 if (!gid_eq(kgid, old->fsgid)) {
84086 new->fsgid = kgid;
84087 goto change_okay;
84088 }
84089 }
84090
84091 +error:
84092 abort_creds(new);
84093 return old_fsgid;
84094
84095 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
84096 return -EFAULT;
84097
84098 down_read(&uts_sem);
84099 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
84100 + error = __copy_to_user(name->sysname, &utsname()->sysname,
84101 __OLD_UTS_LEN);
84102 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
84103 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
84104 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
84105 __OLD_UTS_LEN);
84106 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
84107 - error |= __copy_to_user(&name->release, &utsname()->release,
84108 + error |= __copy_to_user(name->release, &utsname()->release,
84109 __OLD_UTS_LEN);
84110 error |= __put_user(0, name->release + __OLD_UTS_LEN);
84111 - error |= __copy_to_user(&name->version, &utsname()->version,
84112 + error |= __copy_to_user(name->version, &utsname()->version,
84113 __OLD_UTS_LEN);
84114 error |= __put_user(0, name->version + __OLD_UTS_LEN);
84115 - error |= __copy_to_user(&name->machine, &utsname()->machine,
84116 + error |= __copy_to_user(name->machine, &utsname()->machine,
84117 __OLD_UTS_LEN);
84118 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
84119 up_read(&uts_sem);
84120 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
84121 */
84122 new_rlim->rlim_cur = 1;
84123 }
84124 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
84125 + is changed to a lower value. Since tasks can be created by the same
84126 + user in between this limit change and an execve by this task, force
84127 + a recheck only for this task by setting PF_NPROC_EXCEEDED
84128 + */
84129 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
84130 + tsk->flags |= PF_NPROC_EXCEEDED;
84131 }
84132 if (!retval) {
84133 if (old_rlim)
84134 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
84135 index 07f6fc4..65fb3d4 100644
84136 --- a/kernel/sysctl.c
84137 +++ b/kernel/sysctl.c
84138 @@ -93,7 +93,6 @@
84139
84140
84141 #if defined(CONFIG_SYSCTL)
84142 -
84143 /* External variables not in a header file. */
84144 extern int sysctl_overcommit_memory;
84145 extern int sysctl_overcommit_ratio;
84146 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
84147
84148 /* Constants used for minimum and maximum */
84149 #ifdef CONFIG_LOCKUP_DETECTOR
84150 -static int sixty = 60;
84151 +static int sixty __read_only = 60;
84152 #endif
84153
84154 -static int zero;
84155 -static int __maybe_unused one = 1;
84156 -static int __maybe_unused two = 2;
84157 -static int __maybe_unused three = 3;
84158 -static unsigned long one_ul = 1;
84159 -static int one_hundred = 100;
84160 +static int neg_one __read_only = -1;
84161 +static int zero __read_only = 0;
84162 +static int __maybe_unused one __read_only = 1;
84163 +static int __maybe_unused two __read_only = 2;
84164 +static int __maybe_unused three __read_only = 3;
84165 +static unsigned long one_ul __read_only = 1;
84166 +static int one_hundred __read_only = 100;
84167 #ifdef CONFIG_PRINTK
84168 -static int ten_thousand = 10000;
84169 +static int ten_thousand __read_only = 10000;
84170 #endif
84171
84172 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
84173 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
84174 void __user *buffer, size_t *lenp, loff_t *ppos);
84175 #endif
84176
84177 -#ifdef CONFIG_PRINTK
84178 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84179 void __user *buffer, size_t *lenp, loff_t *ppos);
84180 -#endif
84181
84182 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
84183 void __user *buffer, size_t *lenp, loff_t *ppos);
84184 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
84185
84186 #endif
84187
84188 +extern struct ctl_table grsecurity_table[];
84189 +
84190 static struct ctl_table kern_table[];
84191 static struct ctl_table vm_table[];
84192 static struct ctl_table fs_table[];
84193 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
84194 int sysctl_legacy_va_layout;
84195 #endif
84196
84197 +#ifdef CONFIG_PAX_SOFTMODE
84198 +static ctl_table pax_table[] = {
84199 + {
84200 + .procname = "softmode",
84201 + .data = &pax_softmode,
84202 + .maxlen = sizeof(unsigned int),
84203 + .mode = 0600,
84204 + .proc_handler = &proc_dointvec,
84205 + },
84206 +
84207 + { }
84208 +};
84209 +#endif
84210 +
84211 /* The default sysctl tables: */
84212
84213 static struct ctl_table sysctl_base_table[] = {
84214 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
84215 #endif
84216
84217 static struct ctl_table kern_table[] = {
84218 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
84219 + {
84220 + .procname = "grsecurity",
84221 + .mode = 0500,
84222 + .child = grsecurity_table,
84223 + },
84224 +#endif
84225 +
84226 +#ifdef CONFIG_PAX_SOFTMODE
84227 + {
84228 + .procname = "pax",
84229 + .mode = 0500,
84230 + .child = pax_table,
84231 + },
84232 +#endif
84233 +
84234 {
84235 .procname = "sched_child_runs_first",
84236 .data = &sysctl_sched_child_runs_first,
84237 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
84238 .data = &modprobe_path,
84239 .maxlen = KMOD_PATH_LEN,
84240 .mode = 0644,
84241 - .proc_handler = proc_dostring,
84242 + .proc_handler = proc_dostring_modpriv,
84243 },
84244 {
84245 .procname = "modules_disabled",
84246 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
84247 .extra1 = &zero,
84248 .extra2 = &one,
84249 },
84250 +#endif
84251 {
84252 .procname = "kptr_restrict",
84253 .data = &kptr_restrict,
84254 .maxlen = sizeof(int),
84255 .mode = 0644,
84256 .proc_handler = proc_dointvec_minmax_sysadmin,
84257 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84258 + .extra1 = &two,
84259 +#else
84260 .extra1 = &zero,
84261 +#endif
84262 .extra2 = &two,
84263 },
84264 -#endif
84265 {
84266 .procname = "ngroups_max",
84267 .data = &ngroups_max,
84268 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
84269 */
84270 {
84271 .procname = "perf_event_paranoid",
84272 - .data = &sysctl_perf_event_paranoid,
84273 - .maxlen = sizeof(sysctl_perf_event_paranoid),
84274 + .data = &sysctl_perf_event_legitimately_concerned,
84275 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
84276 .mode = 0644,
84277 - .proc_handler = proc_dointvec,
84278 + /* go ahead, be a hero */
84279 + .proc_handler = proc_dointvec_minmax_sysadmin,
84280 + .extra1 = &neg_one,
84281 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
84282 + .extra2 = &three,
84283 +#else
84284 + .extra2 = &two,
84285 +#endif
84286 },
84287 {
84288 .procname = "perf_event_mlock_kb",
84289 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
84290 .proc_handler = proc_dointvec_minmax,
84291 .extra1 = &zero,
84292 },
84293 + {
84294 + .procname = "heap_stack_gap",
84295 + .data = &sysctl_heap_stack_gap,
84296 + .maxlen = sizeof(sysctl_heap_stack_gap),
84297 + .mode = 0644,
84298 + .proc_handler = proc_doulongvec_minmax,
84299 + },
84300 #else
84301 {
84302 .procname = "nr_trim_pages",
84303 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
84304 buffer, lenp, ppos);
84305 }
84306
84307 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84308 + void __user *buffer, size_t *lenp, loff_t *ppos)
84309 +{
84310 + if (write && !capable(CAP_SYS_MODULE))
84311 + return -EPERM;
84312 +
84313 + return _proc_do_string(table->data, table->maxlen, write,
84314 + buffer, lenp, ppos);
84315 +}
84316 +
84317 static size_t proc_skip_spaces(char **buf)
84318 {
84319 size_t ret;
84320 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
84321 len = strlen(tmp);
84322 if (len > *size)
84323 len = *size;
84324 + if (len > sizeof(tmp))
84325 + len = sizeof(tmp);
84326 if (copy_to_user(*buf, tmp, len))
84327 return -EFAULT;
84328 *size -= len;
84329 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
84330 static int proc_taint(struct ctl_table *table, int write,
84331 void __user *buffer, size_t *lenp, loff_t *ppos)
84332 {
84333 - struct ctl_table t;
84334 + ctl_table_no_const t;
84335 unsigned long tmptaint = get_taint();
84336 int err;
84337
84338 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
84339 return err;
84340 }
84341
84342 -#ifdef CONFIG_PRINTK
84343 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84344 void __user *buffer, size_t *lenp, loff_t *ppos)
84345 {
84346 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84347
84348 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
84349 }
84350 -#endif
84351
84352 struct do_proc_dointvec_minmax_conv_param {
84353 int *min;
84354 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
84355 *i = val;
84356 } else {
84357 val = convdiv * (*i) / convmul;
84358 - if (!first)
84359 + if (!first) {
84360 err = proc_put_char(&buffer, &left, '\t');
84361 + if (err)
84362 + break;
84363 + }
84364 err = proc_put_long(&buffer, &left, val, false);
84365 if (err)
84366 break;
84367 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
84368 return -ENOSYS;
84369 }
84370
84371 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84372 + void __user *buffer, size_t *lenp, loff_t *ppos)
84373 +{
84374 + return -ENOSYS;
84375 +}
84376 +
84377 int proc_dointvec(struct ctl_table *table, int write,
84378 void __user *buffer, size_t *lenp, loff_t *ppos)
84379 {
84380 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
84381 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
84382 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
84383 EXPORT_SYMBOL(proc_dostring);
84384 +EXPORT_SYMBOL(proc_dostring_modpriv);
84385 EXPORT_SYMBOL(proc_doulongvec_minmax);
84386 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
84387 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
84388 index 145bb4d..b2aa969 100644
84389 --- a/kernel/taskstats.c
84390 +++ b/kernel/taskstats.c
84391 @@ -28,9 +28,12 @@
84392 #include <linux/fs.h>
84393 #include <linux/file.h>
84394 #include <linux/pid_namespace.h>
84395 +#include <linux/grsecurity.h>
84396 #include <net/genetlink.h>
84397 #include <linux/atomic.h>
84398
84399 +extern int gr_is_taskstats_denied(int pid);
84400 +
84401 /*
84402 * Maximum length of a cpumask that can be specified in
84403 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
84404 @@ -570,6 +573,9 @@ err:
84405
84406 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
84407 {
84408 + if (gr_is_taskstats_denied(current->pid))
84409 + return -EACCES;
84410 +
84411 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
84412 return cmd_attr_register_cpumask(info);
84413 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
84414 diff --git a/kernel/time.c b/kernel/time.c
84415 index 7c7964c..784a599 100644
84416 --- a/kernel/time.c
84417 +++ b/kernel/time.c
84418 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
84419 return error;
84420
84421 if (tz) {
84422 + /* we log in do_settimeofday called below, so don't log twice
84423 + */
84424 + if (!tv)
84425 + gr_log_timechange();
84426 +
84427 sys_tz = *tz;
84428 update_vsyscall_tz();
84429 if (firsttime) {
84430 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
84431 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
84432 * value to a scaled second value.
84433 */
84434 -unsigned long
84435 +unsigned long __intentional_overflow(-1)
84436 timespec_to_jiffies(const struct timespec *value)
84437 {
84438 unsigned long sec = value->tv_sec;
84439 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
84440 index eec50fc..65e5df6 100644
84441 --- a/kernel/time/alarmtimer.c
84442 +++ b/kernel/time/alarmtimer.c
84443 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
84444 struct platform_device *pdev;
84445 int error = 0;
84446 int i;
84447 - struct k_clock alarm_clock = {
84448 + static struct k_clock alarm_clock = {
84449 .clock_getres = alarm_clock_getres,
84450 .clock_get = alarm_clock_get,
84451 .timer_create = alarm_timer_create,
84452 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
84453 index 947ba25..20cbade 100644
84454 --- a/kernel/time/timekeeping.c
84455 +++ b/kernel/time/timekeeping.c
84456 @@ -15,6 +15,7 @@
84457 #include <linux/init.h>
84458 #include <linux/mm.h>
84459 #include <linux/sched.h>
84460 +#include <linux/grsecurity.h>
84461 #include <linux/syscore_ops.h>
84462 #include <linux/clocksource.h>
84463 #include <linux/jiffies.h>
84464 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
84465 if (!timespec_valid_strict(tv))
84466 return -EINVAL;
84467
84468 + gr_log_timechange();
84469 +
84470 raw_spin_lock_irqsave(&timekeeper_lock, flags);
84471 write_seqcount_begin(&timekeeper_seq);
84472
84473 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
84474 index 61ed862..3b52c65 100644
84475 --- a/kernel/time/timer_list.c
84476 +++ b/kernel/time/timer_list.c
84477 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
84478
84479 static void print_name_offset(struct seq_file *m, void *sym)
84480 {
84481 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84482 + SEQ_printf(m, "<%p>", NULL);
84483 +#else
84484 char symname[KSYM_NAME_LEN];
84485
84486 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
84487 SEQ_printf(m, "<%pK>", sym);
84488 else
84489 SEQ_printf(m, "%s", symname);
84490 +#endif
84491 }
84492
84493 static void
84494 @@ -119,7 +123,11 @@ next_one:
84495 static void
84496 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
84497 {
84498 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84499 + SEQ_printf(m, " .base: %p\n", NULL);
84500 +#else
84501 SEQ_printf(m, " .base: %pK\n", base);
84502 +#endif
84503 SEQ_printf(m, " .index: %d\n",
84504 base->index);
84505 SEQ_printf(m, " .resolution: %Lu nsecs\n",
84506 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
84507 {
84508 struct proc_dir_entry *pe;
84509
84510 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84511 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
84512 +#else
84513 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
84514 +#endif
84515 if (!pe)
84516 return -ENOMEM;
84517 return 0;
84518 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
84519 index 0b537f2..40d6c20 100644
84520 --- a/kernel/time/timer_stats.c
84521 +++ b/kernel/time/timer_stats.c
84522 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
84523 static unsigned long nr_entries;
84524 static struct entry entries[MAX_ENTRIES];
84525
84526 -static atomic_t overflow_count;
84527 +static atomic_unchecked_t overflow_count;
84528
84529 /*
84530 * The entries are in a hash-table, for fast lookup:
84531 @@ -140,7 +140,7 @@ static void reset_entries(void)
84532 nr_entries = 0;
84533 memset(entries, 0, sizeof(entries));
84534 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
84535 - atomic_set(&overflow_count, 0);
84536 + atomic_set_unchecked(&overflow_count, 0);
84537 }
84538
84539 static struct entry *alloc_entry(void)
84540 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84541 if (likely(entry))
84542 entry->count++;
84543 else
84544 - atomic_inc(&overflow_count);
84545 + atomic_inc_unchecked(&overflow_count);
84546
84547 out_unlock:
84548 raw_spin_unlock_irqrestore(lock, flags);
84549 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84550
84551 static void print_name_offset(struct seq_file *m, unsigned long addr)
84552 {
84553 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84554 + seq_printf(m, "<%p>", NULL);
84555 +#else
84556 char symname[KSYM_NAME_LEN];
84557
84558 if (lookup_symbol_name(addr, symname) < 0)
84559 - seq_printf(m, "<%p>", (void *)addr);
84560 + seq_printf(m, "<%pK>", (void *)addr);
84561 else
84562 seq_printf(m, "%s", symname);
84563 +#endif
84564 }
84565
84566 static int tstats_show(struct seq_file *m, void *v)
84567 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
84568
84569 seq_puts(m, "Timer Stats Version: v0.2\n");
84570 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
84571 - if (atomic_read(&overflow_count))
84572 + if (atomic_read_unchecked(&overflow_count))
84573 seq_printf(m, "Overflow: %d entries\n",
84574 - atomic_read(&overflow_count));
84575 + atomic_read_unchecked(&overflow_count));
84576
84577 for (i = 0; i < nr_entries; i++) {
84578 entry = entries + i;
84579 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
84580 {
84581 struct proc_dir_entry *pe;
84582
84583 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84584 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
84585 +#else
84586 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
84587 +#endif
84588 if (!pe)
84589 return -ENOMEM;
84590 return 0;
84591 diff --git a/kernel/timer.c b/kernel/timer.c
84592 index 4296d13..0164b04 100644
84593 --- a/kernel/timer.c
84594 +++ b/kernel/timer.c
84595 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
84596 /*
84597 * This function runs timers and the timer-tq in bottom half context.
84598 */
84599 -static void run_timer_softirq(struct softirq_action *h)
84600 +static __latent_entropy void run_timer_softirq(void)
84601 {
84602 struct tvec_base *base = __this_cpu_read(tvec_bases);
84603
84604 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
84605 *
84606 * In all cases the return value is guaranteed to be non-negative.
84607 */
84608 -signed long __sched schedule_timeout(signed long timeout)
84609 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
84610 {
84611 struct timer_list timer;
84612 unsigned long expire;
84613 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
84614 index b8b8560..75b1a09 100644
84615 --- a/kernel/trace/blktrace.c
84616 +++ b/kernel/trace/blktrace.c
84617 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
84618 struct blk_trace *bt = filp->private_data;
84619 char buf[16];
84620
84621 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
84622 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
84623
84624 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
84625 }
84626 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
84627 return 1;
84628
84629 bt = buf->chan->private_data;
84630 - atomic_inc(&bt->dropped);
84631 + atomic_inc_unchecked(&bt->dropped);
84632 return 0;
84633 }
84634
84635 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
84636
84637 bt->dir = dir;
84638 bt->dev = dev;
84639 - atomic_set(&bt->dropped, 0);
84640 + atomic_set_unchecked(&bt->dropped, 0);
84641
84642 ret = -EIO;
84643 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
84644 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
84645 index a6d098c..bb8cf65 100644
84646 --- a/kernel/trace/ftrace.c
84647 +++ b/kernel/trace/ftrace.c
84648 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
84649 if (unlikely(ftrace_disabled))
84650 return 0;
84651
84652 + ret = ftrace_arch_code_modify_prepare();
84653 + FTRACE_WARN_ON(ret);
84654 + if (ret)
84655 + return 0;
84656 +
84657 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
84658 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
84659 if (ret) {
84660 ftrace_bug(ret, ip);
84661 - return 0;
84662 }
84663 - return 1;
84664 + return ret ? 0 : 1;
84665 }
84666
84667 /*
84668 @@ -4028,8 +4033,10 @@ static int ftrace_process_locs(struct module *mod,
84669 if (!count)
84670 return 0;
84671
84672 + pax_open_kernel();
84673 sort(start, count, sizeof(*start),
84674 ftrace_cmp_ips, ftrace_swap_ips);
84675 + pax_close_kernel();
84676
84677 start_pg = ftrace_allocate_pages(count);
84678 if (!start_pg)
84679 @@ -4752,8 +4759,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
84680 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
84681
84682 static int ftrace_graph_active;
84683 -static struct notifier_block ftrace_suspend_notifier;
84684 -
84685 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
84686 {
84687 return 0;
84688 @@ -4897,6 +4902,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
84689 return NOTIFY_DONE;
84690 }
84691
84692 +static struct notifier_block ftrace_suspend_notifier = {
84693 + .notifier_call = ftrace_suspend_notifier_call
84694 +};
84695 +
84696 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84697 trace_func_graph_ent_t entryfunc)
84698 {
84699 @@ -4910,7 +4919,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84700 goto out;
84701 }
84702
84703 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
84704 register_pm_notifier(&ftrace_suspend_notifier);
84705
84706 ftrace_graph_active++;
84707 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
84708 index cc2f66f..05edd54 100644
84709 --- a/kernel/trace/ring_buffer.c
84710 +++ b/kernel/trace/ring_buffer.c
84711 @@ -352,9 +352,9 @@ struct buffer_data_page {
84712 */
84713 struct buffer_page {
84714 struct list_head list; /* list of buffer pages */
84715 - local_t write; /* index for next write */
84716 + local_unchecked_t write; /* index for next write */
84717 unsigned read; /* index for next read */
84718 - local_t entries; /* entries on this page */
84719 + local_unchecked_t entries; /* entries on this page */
84720 unsigned long real_end; /* real end of data */
84721 struct buffer_data_page *page; /* Actual data page */
84722 };
84723 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
84724 unsigned long last_overrun;
84725 local_t entries_bytes;
84726 local_t entries;
84727 - local_t overrun;
84728 - local_t commit_overrun;
84729 + local_unchecked_t overrun;
84730 + local_unchecked_t commit_overrun;
84731 local_t dropped_events;
84732 local_t committing;
84733 local_t commits;
84734 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84735 *
84736 * We add a counter to the write field to denote this.
84737 */
84738 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
84739 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
84740 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
84741 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
84742
84743 /*
84744 * Just make sure we have seen our old_write and synchronize
84745 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84746 * cmpxchg to only update if an interrupt did not already
84747 * do it for us. If the cmpxchg fails, we don't care.
84748 */
84749 - (void)local_cmpxchg(&next_page->write, old_write, val);
84750 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
84751 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
84752 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
84753
84754 /*
84755 * No need to worry about races with clearing out the commit.
84756 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
84757
84758 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
84759 {
84760 - return local_read(&bpage->entries) & RB_WRITE_MASK;
84761 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
84762 }
84763
84764 static inline unsigned long rb_page_write(struct buffer_page *bpage)
84765 {
84766 - return local_read(&bpage->write) & RB_WRITE_MASK;
84767 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
84768 }
84769
84770 static int
84771 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
84772 * bytes consumed in ring buffer from here.
84773 * Increment overrun to account for the lost events.
84774 */
84775 - local_add(page_entries, &cpu_buffer->overrun);
84776 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
84777 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84778 }
84779
84780 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
84781 * it is our responsibility to update
84782 * the counters.
84783 */
84784 - local_add(entries, &cpu_buffer->overrun);
84785 + local_add_unchecked(entries, &cpu_buffer->overrun);
84786 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84787
84788 /*
84789 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84790 if (tail == BUF_PAGE_SIZE)
84791 tail_page->real_end = 0;
84792
84793 - local_sub(length, &tail_page->write);
84794 + local_sub_unchecked(length, &tail_page->write);
84795 return;
84796 }
84797
84798 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84799 rb_event_set_padding(event);
84800
84801 /* Set the write back to the previous setting */
84802 - local_sub(length, &tail_page->write);
84803 + local_sub_unchecked(length, &tail_page->write);
84804 return;
84805 }
84806
84807 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84808
84809 /* Set write to end of buffer */
84810 length = (tail + length) - BUF_PAGE_SIZE;
84811 - local_sub(length, &tail_page->write);
84812 + local_sub_unchecked(length, &tail_page->write);
84813 }
84814
84815 /*
84816 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84817 * about it.
84818 */
84819 if (unlikely(next_page == commit_page)) {
84820 - local_inc(&cpu_buffer->commit_overrun);
84821 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84822 goto out_reset;
84823 }
84824
84825 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84826 cpu_buffer->tail_page) &&
84827 (cpu_buffer->commit_page ==
84828 cpu_buffer->reader_page))) {
84829 - local_inc(&cpu_buffer->commit_overrun);
84830 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84831 goto out_reset;
84832 }
84833 }
84834 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84835 length += RB_LEN_TIME_EXTEND;
84836
84837 tail_page = cpu_buffer->tail_page;
84838 - write = local_add_return(length, &tail_page->write);
84839 + write = local_add_return_unchecked(length, &tail_page->write);
84840
84841 /* set write to only the index of the write */
84842 write &= RB_WRITE_MASK;
84843 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84844 kmemcheck_annotate_bitfield(event, bitfield);
84845 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
84846
84847 - local_inc(&tail_page->entries);
84848 + local_inc_unchecked(&tail_page->entries);
84849
84850 /*
84851 * If this is the first commit on the page, then update
84852 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84853
84854 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
84855 unsigned long write_mask =
84856 - local_read(&bpage->write) & ~RB_WRITE_MASK;
84857 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
84858 unsigned long event_length = rb_event_length(event);
84859 /*
84860 * This is on the tail page. It is possible that
84861 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84862 */
84863 old_index += write_mask;
84864 new_index += write_mask;
84865 - index = local_cmpxchg(&bpage->write, old_index, new_index);
84866 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
84867 if (index == old_index) {
84868 /* update counters */
84869 local_sub(event_length, &cpu_buffer->entries_bytes);
84870 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84871
84872 /* Do the likely case first */
84873 if (likely(bpage->page == (void *)addr)) {
84874 - local_dec(&bpage->entries);
84875 + local_dec_unchecked(&bpage->entries);
84876 return;
84877 }
84878
84879 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84880 start = bpage;
84881 do {
84882 if (bpage->page == (void *)addr) {
84883 - local_dec(&bpage->entries);
84884 + local_dec_unchecked(&bpage->entries);
84885 return;
84886 }
84887 rb_inc_page(cpu_buffer, &bpage);
84888 @@ -3139,7 +3139,7 @@ static inline unsigned long
84889 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
84890 {
84891 return local_read(&cpu_buffer->entries) -
84892 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
84893 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
84894 }
84895
84896 /**
84897 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
84898 return 0;
84899
84900 cpu_buffer = buffer->buffers[cpu];
84901 - ret = local_read(&cpu_buffer->overrun);
84902 + ret = local_read_unchecked(&cpu_buffer->overrun);
84903
84904 return ret;
84905 }
84906 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
84907 return 0;
84908
84909 cpu_buffer = buffer->buffers[cpu];
84910 - ret = local_read(&cpu_buffer->commit_overrun);
84911 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
84912
84913 return ret;
84914 }
84915 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
84916 /* if you care about this being correct, lock the buffer */
84917 for_each_buffer_cpu(buffer, cpu) {
84918 cpu_buffer = buffer->buffers[cpu];
84919 - overruns += local_read(&cpu_buffer->overrun);
84920 + overruns += local_read_unchecked(&cpu_buffer->overrun);
84921 }
84922
84923 return overruns;
84924 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84925 /*
84926 * Reset the reader page to size zero.
84927 */
84928 - local_set(&cpu_buffer->reader_page->write, 0);
84929 - local_set(&cpu_buffer->reader_page->entries, 0);
84930 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84931 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84932 local_set(&cpu_buffer->reader_page->page->commit, 0);
84933 cpu_buffer->reader_page->real_end = 0;
84934
84935 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84936 * want to compare with the last_overrun.
84937 */
84938 smp_mb();
84939 - overwrite = local_read(&(cpu_buffer->overrun));
84940 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
84941
84942 /*
84943 * Here's the tricky part.
84944 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84945
84946 cpu_buffer->head_page
84947 = list_entry(cpu_buffer->pages, struct buffer_page, list);
84948 - local_set(&cpu_buffer->head_page->write, 0);
84949 - local_set(&cpu_buffer->head_page->entries, 0);
84950 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
84951 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
84952 local_set(&cpu_buffer->head_page->page->commit, 0);
84953
84954 cpu_buffer->head_page->read = 0;
84955 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84956
84957 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
84958 INIT_LIST_HEAD(&cpu_buffer->new_pages);
84959 - local_set(&cpu_buffer->reader_page->write, 0);
84960 - local_set(&cpu_buffer->reader_page->entries, 0);
84961 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84962 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84963 local_set(&cpu_buffer->reader_page->page->commit, 0);
84964 cpu_buffer->reader_page->read = 0;
84965
84966 local_set(&cpu_buffer->entries_bytes, 0);
84967 - local_set(&cpu_buffer->overrun, 0);
84968 - local_set(&cpu_buffer->commit_overrun, 0);
84969 + local_set_unchecked(&cpu_buffer->overrun, 0);
84970 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
84971 local_set(&cpu_buffer->dropped_events, 0);
84972 local_set(&cpu_buffer->entries, 0);
84973 local_set(&cpu_buffer->committing, 0);
84974 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
84975 rb_init_page(bpage);
84976 bpage = reader->page;
84977 reader->page = *data_page;
84978 - local_set(&reader->write, 0);
84979 - local_set(&reader->entries, 0);
84980 + local_set_unchecked(&reader->write, 0);
84981 + local_set_unchecked(&reader->entries, 0);
84982 reader->read = 0;
84983 *data_page = bpage;
84984
84985 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
84986 index 496f94d..754aeea 100644
84987 --- a/kernel/trace/trace.c
84988 +++ b/kernel/trace/trace.c
84989 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
84990 return 0;
84991 }
84992
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 /* do nothing if flag is already set */
84997 if (!!(trace_flags & mask) == !!enabled)
84998 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
84999 index afaae41..64871f8 100644
85000 --- a/kernel/trace/trace.h
85001 +++ b/kernel/trace/trace.h
85002 @@ -1025,7 +1025,7 @@ extern const char *__stop___trace_bprintk_fmt[];
85003 void trace_printk_init_buffers(void);
85004 void trace_printk_start_comm(void);
85005 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
85006 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
85007 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
85008
85009 /*
85010 * Normal trace_printk() and friends allocates special buffers
85011 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
85012 index 26dc348..8708ca7 100644
85013 --- a/kernel/trace/trace_clock.c
85014 +++ b/kernel/trace/trace_clock.c
85015 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
85016 return now;
85017 }
85018
85019 -static atomic64_t trace_counter;
85020 +static atomic64_unchecked_t trace_counter;
85021
85022 /*
85023 * trace_clock_counter(): simply an atomic counter.
85024 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
85025 */
85026 u64 notrace trace_clock_counter(void)
85027 {
85028 - return atomic64_add_return(1, &trace_counter);
85029 + return atomic64_inc_return_unchecked(&trace_counter);
85030 }
85031 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
85032 index 29a7ebc..eb473cf 100644
85033 --- a/kernel/trace/trace_events.c
85034 +++ b/kernel/trace/trace_events.c
85035 @@ -1778,10 +1778,6 @@ static LIST_HEAD(ftrace_module_file_list);
85036 struct ftrace_module_file_ops {
85037 struct list_head list;
85038 struct module *mod;
85039 - struct file_operations id;
85040 - struct file_operations enable;
85041 - struct file_operations format;
85042 - struct file_operations filter;
85043 };
85044
85045 static struct ftrace_module_file_ops *
85046 @@ -1822,17 +1818,12 @@ trace_create_file_ops(struct module *mod)
85047
85048 file_ops->mod = mod;
85049
85050 - file_ops->id = ftrace_event_id_fops;
85051 - file_ops->id.owner = mod;
85052 -
85053 - file_ops->enable = ftrace_enable_fops;
85054 - file_ops->enable.owner = mod;
85055 -
85056 - file_ops->filter = ftrace_event_filter_fops;
85057 - file_ops->filter.owner = mod;
85058 -
85059 - file_ops->format = ftrace_event_format_fops;
85060 - file_ops->format.owner = mod;
85061 + pax_open_kernel();
85062 + mod->trace_id.owner = mod;
85063 + mod->trace_enable.owner = mod;
85064 + mod->trace_filter.owner = mod;
85065 + mod->trace_format.owner = mod;
85066 + pax_close_kernel();
85067
85068 list_add(&file_ops->list, &ftrace_module_file_list);
85069
85070 @@ -1925,8 +1916,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
85071 struct ftrace_module_file_ops *file_ops)
85072 {
85073 return __trace_add_new_event(call, tr,
85074 - &file_ops->id, &file_ops->enable,
85075 - &file_ops->filter, &file_ops->format);
85076 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
85077 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
85078 }
85079
85080 #else
85081 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
85082 index b3dcfb2..ebee344 100644
85083 --- a/kernel/trace/trace_mmiotrace.c
85084 +++ b/kernel/trace/trace_mmiotrace.c
85085 @@ -24,7 +24,7 @@ struct header_iter {
85086 static struct trace_array *mmio_trace_array;
85087 static bool overrun_detected;
85088 static unsigned long prev_overruns;
85089 -static atomic_t dropped_count;
85090 +static atomic_unchecked_t dropped_count;
85091
85092 static void mmio_reset_data(struct trace_array *tr)
85093 {
85094 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
85095
85096 static unsigned long count_overruns(struct trace_iterator *iter)
85097 {
85098 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
85099 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
85100 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
85101
85102 if (over > prev_overruns)
85103 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
85104 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
85105 sizeof(*entry), 0, pc);
85106 if (!event) {
85107 - atomic_inc(&dropped_count);
85108 + atomic_inc_unchecked(&dropped_count);
85109 return;
85110 }
85111 entry = ring_buffer_event_data(event);
85112 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
85113 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
85114 sizeof(*entry), 0, pc);
85115 if (!event) {
85116 - atomic_inc(&dropped_count);
85117 + atomic_inc_unchecked(&dropped_count);
85118 return;
85119 }
85120 entry = ring_buffer_event_data(event);
85121 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
85122 index 34e7cba..6f9a729 100644
85123 --- a/kernel/trace/trace_output.c
85124 +++ b/kernel/trace/trace_output.c
85125 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
85126
85127 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
85128 if (!IS_ERR(p)) {
85129 - p = mangle_path(s->buffer + s->len, p, "\n");
85130 + p = mangle_path(s->buffer + s->len, p, "\n\\");
85131 if (p) {
85132 s->len = p - s->buffer;
85133 return 1;
85134 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
85135 goto out;
85136 }
85137
85138 + pax_open_kernel();
85139 if (event->funcs->trace == NULL)
85140 - event->funcs->trace = trace_nop_print;
85141 + *(void **)&event->funcs->trace = trace_nop_print;
85142 if (event->funcs->raw == NULL)
85143 - event->funcs->raw = trace_nop_print;
85144 + *(void **)&event->funcs->raw = trace_nop_print;
85145 if (event->funcs->hex == NULL)
85146 - event->funcs->hex = trace_nop_print;
85147 + *(void **)&event->funcs->hex = trace_nop_print;
85148 if (event->funcs->binary == NULL)
85149 - event->funcs->binary = trace_nop_print;
85150 + *(void **)&event->funcs->binary = trace_nop_print;
85151 + pax_close_kernel();
85152
85153 key = event->type & (EVENT_HASHSIZE - 1);
85154
85155 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
85156 index b20428c..4845a10 100644
85157 --- a/kernel/trace/trace_stack.c
85158 +++ b/kernel/trace/trace_stack.c
85159 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
85160 return;
85161
85162 /* we do not handle interrupt stacks yet */
85163 - if (!object_is_on_stack(stack))
85164 + if (!object_starts_on_stack(stack))
85165 return;
85166
85167 local_irq_save(flags);
85168 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
85169 index 9064b91..1f5d2f8 100644
85170 --- a/kernel/user_namespace.c
85171 +++ b/kernel/user_namespace.c
85172 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
85173 !kgid_has_mapping(parent_ns, group))
85174 return -EPERM;
85175
85176 +#ifdef CONFIG_GRKERNSEC
85177 + /*
85178 + * This doesn't really inspire confidence:
85179 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
85180 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
85181 + * Increases kernel attack surface in areas developers
85182 + * previously cared little about ("low importance due
85183 + * to requiring "root" capability")
85184 + * To be removed when this code receives *proper* review
85185 + */
85186 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
85187 + !capable(CAP_SETGID))
85188 + return -EPERM;
85189 +#endif
85190 +
85191 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
85192 if (!ns)
85193 return -ENOMEM;
85194 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
85195 if (atomic_read(&current->mm->mm_users) > 1)
85196 return -EINVAL;
85197
85198 - if (current->fs->users != 1)
85199 + if (atomic_read(&current->fs->users) != 1)
85200 return -EINVAL;
85201
85202 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
85203 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
85204 index 4f69f9a..7c6f8f8 100644
85205 --- a/kernel/utsname_sysctl.c
85206 +++ b/kernel/utsname_sysctl.c
85207 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
85208 static int proc_do_uts_string(ctl_table *table, int write,
85209 void __user *buffer, size_t *lenp, loff_t *ppos)
85210 {
85211 - struct ctl_table uts_table;
85212 + ctl_table_no_const uts_table;
85213 int r;
85214 memcpy(&uts_table, table, sizeof(uts_table));
85215 uts_table.data = get_uts(table, write);
85216 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
85217 index 1241d8c..d5cfc28 100644
85218 --- a/kernel/watchdog.c
85219 +++ b/kernel/watchdog.c
85220 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
85221 static void watchdog_nmi_disable(unsigned int cpu) { return; }
85222 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
85223
85224 -static struct smp_hotplug_thread watchdog_threads = {
85225 +static struct smp_hotplug_thread watchdog_threads __read_only = {
85226 .store = &softlockup_watchdog,
85227 .thread_should_run = watchdog_should_run,
85228 .thread_fn = watchdog,
85229 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
85230 index e93f7b9..989fcd7 100644
85231 --- a/kernel/workqueue.c
85232 +++ b/kernel/workqueue.c
85233 @@ -4627,7 +4627,7 @@ static void rebind_workers(struct worker_pool *pool)
85234 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
85235 worker_flags |= WORKER_REBOUND;
85236 worker_flags &= ~WORKER_UNBOUND;
85237 - ACCESS_ONCE(worker->flags) = worker_flags;
85238 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
85239 }
85240
85241 spin_unlock_irq(&pool->lock);
85242 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
85243 index 1501aa5..e771896 100644
85244 --- a/lib/Kconfig.debug
85245 +++ b/lib/Kconfig.debug
85246 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
85247
85248 config DEBUG_WW_MUTEX_SLOWPATH
85249 bool "Wait/wound mutex debugging: Slowpath testing"
85250 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85251 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85252 select DEBUG_LOCK_ALLOC
85253 select DEBUG_SPINLOCK
85254 select DEBUG_MUTEXES
85255 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
85256
85257 config DEBUG_LOCK_ALLOC
85258 bool "Lock debugging: detect incorrect freeing of live locks"
85259 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85260 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85261 select DEBUG_SPINLOCK
85262 select DEBUG_MUTEXES
85263 select LOCKDEP
85264 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
85265
85266 config PROVE_LOCKING
85267 bool "Lock debugging: prove locking correctness"
85268 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85269 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85270 select LOCKDEP
85271 select DEBUG_SPINLOCK
85272 select DEBUG_MUTEXES
85273 @@ -914,7 +914,7 @@ config LOCKDEP
85274
85275 config LOCK_STAT
85276 bool "Lock usage statistics"
85277 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85278 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85279 select LOCKDEP
85280 select DEBUG_SPINLOCK
85281 select DEBUG_MUTEXES
85282 @@ -1357,6 +1357,7 @@ config LATENCYTOP
85283 depends on DEBUG_KERNEL
85284 depends on STACKTRACE_SUPPORT
85285 depends on PROC_FS
85286 + depends on !GRKERNSEC_HIDESYM
85287 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
85288 select KALLSYMS
85289 select KALLSYMS_ALL
85290 @@ -1373,7 +1374,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85291 config DEBUG_STRICT_USER_COPY_CHECKS
85292 bool "Strict user copy size checks"
85293 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85294 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
85295 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
85296 help
85297 Enabling this option turns a certain set of sanity checks for user
85298 copy operations into compile time failures.
85299 @@ -1483,7 +1484,7 @@ endmenu # runtime tests
85300
85301 config PROVIDE_OHCI1394_DMA_INIT
85302 bool "Remote debugging over FireWire early on boot"
85303 - depends on PCI && X86
85304 + depends on PCI && X86 && !GRKERNSEC
85305 help
85306 If you want to debug problems which hang or crash the kernel early
85307 on boot and the crashing machine has a FireWire port, you can use
85308 @@ -1512,7 +1513,7 @@ config PROVIDE_OHCI1394_DMA_INIT
85309
85310 config FIREWIRE_OHCI_REMOTE_DMA
85311 bool "Remote debugging over FireWire with firewire-ohci"
85312 - depends on FIREWIRE_OHCI
85313 + depends on FIREWIRE_OHCI && !GRKERNSEC
85314 help
85315 This option lets you use the FireWire bus for remote debugging
85316 with help of the firewire-ohci driver. It enables unfiltered
85317 diff --git a/lib/Makefile b/lib/Makefile
85318 index 7baccfd..3ceb95f 100644
85319 --- a/lib/Makefile
85320 +++ b/lib/Makefile
85321 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
85322
85323 obj-$(CONFIG_BTREE) += btree.o
85324 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
85325 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
85326 +obj-y += list_debug.o
85327 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
85328
85329 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
85330 diff --git a/lib/bitmap.c b/lib/bitmap.c
85331 index 06f7e4f..f3cf2b0 100644
85332 --- a/lib/bitmap.c
85333 +++ b/lib/bitmap.c
85334 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
85335 {
85336 int c, old_c, totaldigits, ndigits, nchunks, nbits;
85337 u32 chunk;
85338 - const char __user __force *ubuf = (const char __user __force *)buf;
85339 + const char __user *ubuf = (const char __force_user *)buf;
85340
85341 bitmap_zero(maskp, nmaskbits);
85342
85343 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
85344 {
85345 if (!access_ok(VERIFY_READ, ubuf, ulen))
85346 return -EFAULT;
85347 - return __bitmap_parse((const char __force *)ubuf,
85348 + return __bitmap_parse((const char __force_kernel *)ubuf,
85349 ulen, 1, maskp, nmaskbits);
85350
85351 }
85352 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
85353 {
85354 unsigned a, b;
85355 int c, old_c, totaldigits;
85356 - const char __user __force *ubuf = (const char __user __force *)buf;
85357 + const char __user *ubuf = (const char __force_user *)buf;
85358 int exp_digit, in_range;
85359
85360 totaldigits = c = 0;
85361 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
85362 {
85363 if (!access_ok(VERIFY_READ, ubuf, ulen))
85364 return -EFAULT;
85365 - return __bitmap_parselist((const char __force *)ubuf,
85366 + return __bitmap_parselist((const char __force_kernel *)ubuf,
85367 ulen, 1, maskp, nmaskbits);
85368 }
85369 EXPORT_SYMBOL(bitmap_parselist_user);
85370 diff --git a/lib/bug.c b/lib/bug.c
85371 index 1686034..a9c00c8 100644
85372 --- a/lib/bug.c
85373 +++ b/lib/bug.c
85374 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
85375 return BUG_TRAP_TYPE_NONE;
85376
85377 bug = find_bug(bugaddr);
85378 + if (!bug)
85379 + return BUG_TRAP_TYPE_NONE;
85380
85381 file = NULL;
85382 line = 0;
85383 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
85384 index 37061ed..da83f48 100644
85385 --- a/lib/debugobjects.c
85386 +++ b/lib/debugobjects.c
85387 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
85388 if (limit > 4)
85389 return;
85390
85391 - is_on_stack = object_is_on_stack(addr);
85392 + is_on_stack = object_starts_on_stack(addr);
85393 if (is_on_stack == onstack)
85394 return;
85395
85396 diff --git a/lib/devres.c b/lib/devres.c
85397 index 8235331..5881053 100644
85398 --- a/lib/devres.c
85399 +++ b/lib/devres.c
85400 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
85401 void devm_iounmap(struct device *dev, void __iomem *addr)
85402 {
85403 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
85404 - (void *)addr));
85405 + (void __force *)addr));
85406 iounmap(addr);
85407 }
85408 EXPORT_SYMBOL(devm_iounmap);
85409 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
85410 {
85411 ioport_unmap(addr);
85412 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
85413 - devm_ioport_map_match, (void *)addr));
85414 + devm_ioport_map_match, (void __force *)addr));
85415 }
85416 EXPORT_SYMBOL(devm_ioport_unmap);
85417 #endif /* CONFIG_HAS_IOPORT */
85418 diff --git a/lib/div64.c b/lib/div64.c
85419 index a163b6c..9618fa5 100644
85420 --- a/lib/div64.c
85421 +++ b/lib/div64.c
85422 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
85423 EXPORT_SYMBOL(__div64_32);
85424
85425 #ifndef div_s64_rem
85426 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85427 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85428 {
85429 u64 quotient;
85430
85431 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
85432 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
85433 */
85434 #ifndef div64_u64
85435 -u64 div64_u64(u64 dividend, u64 divisor)
85436 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
85437 {
85438 u32 high = divisor >> 32;
85439 u64 quot;
85440 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
85441 index d87a17a..ac0d79a 100644
85442 --- a/lib/dma-debug.c
85443 +++ b/lib/dma-debug.c
85444 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
85445
85446 void dma_debug_add_bus(struct bus_type *bus)
85447 {
85448 - struct notifier_block *nb;
85449 + notifier_block_no_const *nb;
85450
85451 if (global_disable)
85452 return;
85453 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
85454
85455 static void check_for_stack(struct device *dev, void *addr)
85456 {
85457 - if (object_is_on_stack(addr))
85458 + if (object_starts_on_stack(addr))
85459 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
85460 "stack [addr=%p]\n", addr);
85461 }
85462 diff --git a/lib/inflate.c b/lib/inflate.c
85463 index 013a761..c28f3fc 100644
85464 --- a/lib/inflate.c
85465 +++ b/lib/inflate.c
85466 @@ -269,7 +269,7 @@ static void free(void *where)
85467 malloc_ptr = free_mem_ptr;
85468 }
85469 #else
85470 -#define malloc(a) kmalloc(a, GFP_KERNEL)
85471 +#define malloc(a) kmalloc((a), GFP_KERNEL)
85472 #define free(a) kfree(a)
85473 #endif
85474
85475 diff --git a/lib/ioremap.c b/lib/ioremap.c
85476 index 0c9216c..863bd89 100644
85477 --- a/lib/ioremap.c
85478 +++ b/lib/ioremap.c
85479 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
85480 unsigned long next;
85481
85482 phys_addr -= addr;
85483 - pmd = pmd_alloc(&init_mm, pud, addr);
85484 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85485 if (!pmd)
85486 return -ENOMEM;
85487 do {
85488 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
85489 unsigned long next;
85490
85491 phys_addr -= addr;
85492 - pud = pud_alloc(&init_mm, pgd, addr);
85493 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85494 if (!pud)
85495 return -ENOMEM;
85496 do {
85497 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
85498 index bd2bea9..6b3c95e 100644
85499 --- a/lib/is_single_threaded.c
85500 +++ b/lib/is_single_threaded.c
85501 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
85502 struct task_struct *p, *t;
85503 bool ret;
85504
85505 + if (!mm)
85506 + return true;
85507 +
85508 if (atomic_read(&task->signal->live) != 1)
85509 return false;
85510
85511 diff --git a/lib/kobject.c b/lib/kobject.c
85512 index 4a1f33d..2f3ca75 100644
85513 --- a/lib/kobject.c
85514 +++ b/lib/kobject.c
85515 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
85516
85517
85518 static DEFINE_SPINLOCK(kobj_ns_type_lock);
85519 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
85520 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
85521
85522 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85523 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85524 {
85525 enum kobj_ns_type type = ops->type;
85526 int error;
85527 diff --git a/lib/list_debug.c b/lib/list_debug.c
85528 index c24c2f7..f0296f4 100644
85529 --- a/lib/list_debug.c
85530 +++ b/lib/list_debug.c
85531 @@ -11,7 +11,9 @@
85532 #include <linux/bug.h>
85533 #include <linux/kernel.h>
85534 #include <linux/rculist.h>
85535 +#include <linux/mm.h>
85536
85537 +#ifdef CONFIG_DEBUG_LIST
85538 /*
85539 * Insert a new entry between two known consecutive entries.
85540 *
85541 @@ -19,21 +21,40 @@
85542 * the prev/next entries already!
85543 */
85544
85545 +static bool __list_add_debug(struct list_head *new,
85546 + struct list_head *prev,
85547 + struct list_head *next)
85548 +{
85549 + if (unlikely(next->prev != prev)) {
85550 + printk(KERN_ERR "list_add corruption. next->prev should be "
85551 + "prev (%p), but was %p. (next=%p).\n",
85552 + prev, next->prev, next);
85553 + BUG();
85554 + return false;
85555 + }
85556 + if (unlikely(prev->next != next)) {
85557 + printk(KERN_ERR "list_add corruption. prev->next should be "
85558 + "next (%p), but was %p. (prev=%p).\n",
85559 + next, prev->next, prev);
85560 + BUG();
85561 + return false;
85562 + }
85563 + if (unlikely(new == prev || new == next)) {
85564 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
85565 + new, prev, next);
85566 + BUG();
85567 + return false;
85568 + }
85569 + return true;
85570 +}
85571 +
85572 void __list_add(struct list_head *new,
85573 - struct list_head *prev,
85574 - struct list_head *next)
85575 + struct list_head *prev,
85576 + struct list_head *next)
85577 {
85578 - WARN(next->prev != prev,
85579 - "list_add corruption. next->prev should be "
85580 - "prev (%p), but was %p. (next=%p).\n",
85581 - prev, next->prev, next);
85582 - WARN(prev->next != next,
85583 - "list_add corruption. prev->next should be "
85584 - "next (%p), but was %p. (prev=%p).\n",
85585 - next, prev->next, prev);
85586 - WARN(new == prev || new == next,
85587 - "list_add double add: new=%p, prev=%p, next=%p.\n",
85588 - new, prev, next);
85589 + if (!__list_add_debug(new, prev, next))
85590 + return;
85591 +
85592 next->prev = new;
85593 new->next = next;
85594 new->prev = prev;
85595 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
85596 }
85597 EXPORT_SYMBOL(__list_add);
85598
85599 -void __list_del_entry(struct list_head *entry)
85600 +static bool __list_del_entry_debug(struct list_head *entry)
85601 {
85602 struct list_head *prev, *next;
85603
85604 prev = entry->prev;
85605 next = entry->next;
85606
85607 - if (WARN(next == LIST_POISON1,
85608 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
85609 - entry, LIST_POISON1) ||
85610 - WARN(prev == LIST_POISON2,
85611 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
85612 - entry, LIST_POISON2) ||
85613 - WARN(prev->next != entry,
85614 - "list_del corruption. prev->next should be %p, "
85615 - "but was %p\n", entry, prev->next) ||
85616 - WARN(next->prev != entry,
85617 - "list_del corruption. next->prev should be %p, "
85618 - "but was %p\n", entry, next->prev))
85619 + if (unlikely(next == LIST_POISON1)) {
85620 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
85621 + entry, LIST_POISON1);
85622 + BUG();
85623 + return false;
85624 + }
85625 + if (unlikely(prev == LIST_POISON2)) {
85626 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
85627 + entry, LIST_POISON2);
85628 + BUG();
85629 + return false;
85630 + }
85631 + if (unlikely(entry->prev->next != entry)) {
85632 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
85633 + "but was %p\n", entry, prev->next);
85634 + BUG();
85635 + return false;
85636 + }
85637 + if (unlikely(entry->next->prev != entry)) {
85638 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
85639 + "but was %p\n", entry, next->prev);
85640 + BUG();
85641 + return false;
85642 + }
85643 + return true;
85644 +}
85645 +
85646 +void __list_del_entry(struct list_head *entry)
85647 +{
85648 + if (!__list_del_entry_debug(entry))
85649 return;
85650
85651 - __list_del(prev, next);
85652 + __list_del(entry->prev, entry->next);
85653 }
85654 EXPORT_SYMBOL(__list_del_entry);
85655
85656 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
85657 void __list_add_rcu(struct list_head *new,
85658 struct list_head *prev, struct list_head *next)
85659 {
85660 - WARN(next->prev != prev,
85661 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
85662 - prev, next->prev, next);
85663 - WARN(prev->next != next,
85664 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
85665 - next, prev->next, prev);
85666 + if (!__list_add_debug(new, prev, next))
85667 + return;
85668 +
85669 new->next = next;
85670 new->prev = prev;
85671 rcu_assign_pointer(list_next_rcu(prev), new);
85672 next->prev = new;
85673 }
85674 EXPORT_SYMBOL(__list_add_rcu);
85675 +#endif
85676 +
85677 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
85678 +{
85679 +#ifdef CONFIG_DEBUG_LIST
85680 + if (!__list_add_debug(new, prev, next))
85681 + return;
85682 +#endif
85683 +
85684 + pax_open_kernel();
85685 + next->prev = new;
85686 + new->next = next;
85687 + new->prev = prev;
85688 + prev->next = new;
85689 + pax_close_kernel();
85690 +}
85691 +EXPORT_SYMBOL(__pax_list_add);
85692 +
85693 +void pax_list_del(struct list_head *entry)
85694 +{
85695 +#ifdef CONFIG_DEBUG_LIST
85696 + if (!__list_del_entry_debug(entry))
85697 + return;
85698 +#endif
85699 +
85700 + pax_open_kernel();
85701 + __list_del(entry->prev, entry->next);
85702 + entry->next = LIST_POISON1;
85703 + entry->prev = LIST_POISON2;
85704 + pax_close_kernel();
85705 +}
85706 +EXPORT_SYMBOL(pax_list_del);
85707 +
85708 +void pax_list_del_init(struct list_head *entry)
85709 +{
85710 + pax_open_kernel();
85711 + __list_del(entry->prev, entry->next);
85712 + INIT_LIST_HEAD(entry);
85713 + pax_close_kernel();
85714 +}
85715 +EXPORT_SYMBOL(pax_list_del_init);
85716 +
85717 +void __pax_list_add_rcu(struct list_head *new,
85718 + struct list_head *prev, struct list_head *next)
85719 +{
85720 +#ifdef CONFIG_DEBUG_LIST
85721 + if (!__list_add_debug(new, prev, next))
85722 + return;
85723 +#endif
85724 +
85725 + pax_open_kernel();
85726 + new->next = next;
85727 + new->prev = prev;
85728 + rcu_assign_pointer(list_next_rcu(prev), new);
85729 + next->prev = new;
85730 + pax_close_kernel();
85731 +}
85732 +EXPORT_SYMBOL(__pax_list_add_rcu);
85733 +
85734 +void pax_list_del_rcu(struct list_head *entry)
85735 +{
85736 +#ifdef CONFIG_DEBUG_LIST
85737 + if (!__list_del_entry_debug(entry))
85738 + return;
85739 +#endif
85740 +
85741 + pax_open_kernel();
85742 + __list_del(entry->prev, entry->next);
85743 + entry->next = LIST_POISON1;
85744 + entry->prev = LIST_POISON2;
85745 + pax_close_kernel();
85746 +}
85747 +EXPORT_SYMBOL(pax_list_del_rcu);
85748 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
85749 index 7deeb62..144eb47 100644
85750 --- a/lib/percpu-refcount.c
85751 +++ b/lib/percpu-refcount.c
85752 @@ -29,7 +29,7 @@
85753 * can't hit 0 before we've added up all the percpu refs.
85754 */
85755
85756 -#define PCPU_COUNT_BIAS (1U << 31)
85757 +#define PCPU_COUNT_BIAS (1U << 30)
85758
85759 /**
85760 * percpu_ref_init - initialize a percpu refcount
85761 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
85762 index e796429..6e38f9f 100644
85763 --- a/lib/radix-tree.c
85764 +++ b/lib/radix-tree.c
85765 @@ -92,7 +92,7 @@ struct radix_tree_preload {
85766 int nr;
85767 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
85768 };
85769 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
85770 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
85771
85772 static inline void *ptr_to_indirect(void *ptr)
85773 {
85774 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
85775 index bb2b201..46abaf9 100644
85776 --- a/lib/strncpy_from_user.c
85777 +++ b/lib/strncpy_from_user.c
85778 @@ -21,7 +21,7 @@
85779 */
85780 static inline long do_strncpy_from_user(char *dst, const char __user *src, 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 res = 0;
85785
85786 /*
85787 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
85788 index a28df52..3d55877 100644
85789 --- a/lib/strnlen_user.c
85790 +++ b/lib/strnlen_user.c
85791 @@ -26,7 +26,7 @@
85792 */
85793 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
85794 {
85795 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85796 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85797 long align, res = 0;
85798 unsigned long c;
85799
85800 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
85801 index d23762e..e21eab2 100644
85802 --- a/lib/swiotlb.c
85803 +++ b/lib/swiotlb.c
85804 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
85805
85806 void
85807 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
85808 - dma_addr_t dev_addr)
85809 + dma_addr_t dev_addr, struct dma_attrs *attrs)
85810 {
85811 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
85812
85813 diff --git a/lib/usercopy.c b/lib/usercopy.c
85814 index 4f5b1dd..7cab418 100644
85815 --- a/lib/usercopy.c
85816 +++ b/lib/usercopy.c
85817 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
85818 WARN(1, "Buffer overflow detected!\n");
85819 }
85820 EXPORT_SYMBOL(copy_from_user_overflow);
85821 +
85822 +void copy_to_user_overflow(void)
85823 +{
85824 + WARN(1, "Buffer overflow detected!\n");
85825 +}
85826 +EXPORT_SYMBOL(copy_to_user_overflow);
85827 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
85828 index 739a363..aa668d7 100644
85829 --- a/lib/vsprintf.c
85830 +++ b/lib/vsprintf.c
85831 @@ -16,6 +16,9 @@
85832 * - scnprintf and vscnprintf
85833 */
85834
85835 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85836 +#define __INCLUDED_BY_HIDESYM 1
85837 +#endif
85838 #include <stdarg.h>
85839 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
85840 #include <linux/types.h>
85841 @@ -1078,7 +1081,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
85842 return number(buf, end, *(const netdev_features_t *)addr, spec);
85843 }
85844
85845 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85846 +int kptr_restrict __read_mostly = 2;
85847 +#else
85848 int kptr_restrict __read_mostly;
85849 +#endif
85850
85851 /*
85852 * Show a '%p' thing. A kernel extension is that the '%p' is followed
85853 @@ -1091,6 +1098,7 @@ int kptr_restrict __read_mostly;
85854 * - 'f' For simple symbolic function names without offset
85855 * - 'S' For symbolic direct pointers with offset
85856 * - 's' For symbolic direct pointers without offset
85857 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
85858 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
85859 * - 'B' For backtraced symbolic direct pointers with offset
85860 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
85861 @@ -1155,12 +1163,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85862
85863 if (!ptr && *fmt != 'K') {
85864 /*
85865 - * Print (null) with the same width as a pointer so it makes
85866 + * Print (nil) with the same width as a pointer so it makes
85867 * tabular output look nice.
85868 */
85869 if (spec.field_width == -1)
85870 spec.field_width = default_width;
85871 - return string(buf, end, "(null)", spec);
85872 + return string(buf, end, "(nil)", spec);
85873 }
85874
85875 switch (*fmt) {
85876 @@ -1170,6 +1178,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85877 /* Fallthrough */
85878 case 'S':
85879 case 's':
85880 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85881 + break;
85882 +#else
85883 + return symbol_string(buf, end, ptr, spec, fmt);
85884 +#endif
85885 + case 'A':
85886 case 'B':
85887 return symbol_string(buf, end, ptr, spec, fmt);
85888 case 'R':
85889 @@ -1225,6 +1239,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85890 va_end(va);
85891 return buf;
85892 }
85893 + case 'P':
85894 + break;
85895 case 'K':
85896 /*
85897 * %pK cannot be used in IRQ context because its test
85898 @@ -1254,6 +1270,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85899 return number(buf, end,
85900 (unsigned long long) *((phys_addr_t *)ptr), spec);
85901 }
85902 +
85903 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85904 + /* 'P' = approved pointers to copy to userland,
85905 + as in the /proc/kallsyms case, as we make it display nothing
85906 + for non-root users, and the real contents for root users
85907 + Also ignore 'K' pointers, since we force their NULLing for non-root users
85908 + above
85909 + */
85910 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
85911 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
85912 + dump_stack();
85913 + ptr = NULL;
85914 + }
85915 +#endif
85916 +
85917 spec.flags |= SMALL;
85918 if (spec.field_width == -1) {
85919 spec.field_width = default_width;
85920 @@ -1977,11 +2008,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85921 typeof(type) value; \
85922 if (sizeof(type) == 8) { \
85923 args = PTR_ALIGN(args, sizeof(u32)); \
85924 - *(u32 *)&value = *(u32 *)args; \
85925 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
85926 + *(u32 *)&value = *(const u32 *)args; \
85927 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
85928 } else { \
85929 args = PTR_ALIGN(args, sizeof(type)); \
85930 - value = *(typeof(type) *)args; \
85931 + value = *(const typeof(type) *)args; \
85932 } \
85933 args += sizeof(type); \
85934 value; \
85935 @@ -2044,7 +2075,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85936 case FORMAT_TYPE_STR: {
85937 const char *str_arg = args;
85938 args += strlen(str_arg) + 1;
85939 - str = string(str, end, (char *)str_arg, spec);
85940 + str = string(str, end, str_arg, spec);
85941 break;
85942 }
85943
85944 diff --git a/localversion-grsec b/localversion-grsec
85945 new file mode 100644
85946 index 0000000..7cd6065
85947 --- /dev/null
85948 +++ b/localversion-grsec
85949 @@ -0,0 +1 @@
85950 +-grsec
85951 diff --git a/mm/Kconfig b/mm/Kconfig
85952 index 6509d27..3c15063 100644
85953 --- a/mm/Kconfig
85954 +++ b/mm/Kconfig
85955 @@ -317,10 +317,11 @@ config KSM
85956 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
85957
85958 config DEFAULT_MMAP_MIN_ADDR
85959 - int "Low address space to protect from user allocation"
85960 + int "Low address space to protect from user allocation"
85961 depends on MMU
85962 - default 4096
85963 - help
85964 + default 32768 if ALPHA || ARM || PARISC || SPARC32
85965 + default 65536
85966 + help
85967 This is the portion of low virtual memory which should be protected
85968 from userspace allocation. Keeping a user from writing to low pages
85969 can help reduce the impact of kernel NULL pointer bugs.
85970 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
85971
85972 config HWPOISON_INJECT
85973 tristate "HWPoison pages injector"
85974 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
85975 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
85976 select PROC_PAGE_MONITOR
85977
85978 config NOMMU_INITIAL_TRIM_EXCESS
85979 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
85980 index e04454c..ca5be3e 100644
85981 --- a/mm/backing-dev.c
85982 +++ b/mm/backing-dev.c
85983 @@ -12,7 +12,7 @@
85984 #include <linux/device.h>
85985 #include <trace/events/writeback.h>
85986
85987 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
85988 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
85989
85990 struct backing_dev_info default_backing_dev_info = {
85991 .name = "default",
85992 @@ -522,7 +522,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
85993 return err;
85994
85995 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
85996 - atomic_long_inc_return(&bdi_seq));
85997 + atomic_long_inc_return_unchecked(&bdi_seq));
85998 if (err) {
85999 bdi_destroy(bdi);
86000 return err;
86001 diff --git a/mm/filemap.c b/mm/filemap.c
86002 index 4b51ac1..5aa90ff 100644
86003 --- a/mm/filemap.c
86004 +++ b/mm/filemap.c
86005 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
86006 struct address_space *mapping = file->f_mapping;
86007
86008 if (!mapping->a_ops->readpage)
86009 - return -ENOEXEC;
86010 + return -ENODEV;
86011 file_accessed(file);
86012 vma->vm_ops = &generic_file_vm_ops;
86013 return 0;
86014 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
86015
86016 while (bytes) {
86017 char __user *buf = iov->iov_base + base;
86018 - int copy = min(bytes, iov->iov_len - base);
86019 + size_t copy = min(bytes, iov->iov_len - base);
86020
86021 base = 0;
86022 left = __copy_from_user_inatomic(vaddr, buf, copy);
86023 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
86024 BUG_ON(!in_atomic());
86025 kaddr = kmap_atomic(page);
86026 if (likely(i->nr_segs == 1)) {
86027 - int left;
86028 + size_t left;
86029 char __user *buf = i->iov->iov_base + i->iov_offset;
86030 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
86031 copied = bytes - left;
86032 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
86033
86034 kaddr = kmap(page);
86035 if (likely(i->nr_segs == 1)) {
86036 - int left;
86037 + size_t left;
86038 char __user *buf = i->iov->iov_base + i->iov_offset;
86039 left = __copy_from_user(kaddr + offset, buf, bytes);
86040 copied = bytes - left;
86041 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
86042 * zero-length segments (without overruning the iovec).
86043 */
86044 while (bytes || unlikely(i->count && !iov->iov_len)) {
86045 - int copy;
86046 + size_t copy;
86047
86048 copy = min(bytes, iov->iov_len - base);
86049 BUG_ON(!i->count || i->count < copy);
86050 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
86051 *pos = i_size_read(inode);
86052
86053 if (limit != RLIM_INFINITY) {
86054 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
86055 if (*pos >= limit) {
86056 send_sig(SIGXFSZ, current, 0);
86057 return -EFBIG;
86058 diff --git a/mm/fremap.c b/mm/fremap.c
86059 index 5bff081..d8189a9 100644
86060 --- a/mm/fremap.c
86061 +++ b/mm/fremap.c
86062 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
86063 retry:
86064 vma = find_vma(mm, start);
86065
86066 +#ifdef CONFIG_PAX_SEGMEXEC
86067 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
86068 + goto out;
86069 +#endif
86070 +
86071 /*
86072 * Make sure the vma is shared, that it supports prefaulting,
86073 * and that the remapped range is valid and fully within
86074 diff --git a/mm/highmem.c b/mm/highmem.c
86075 index b32b70c..e512eb0 100644
86076 --- a/mm/highmem.c
86077 +++ b/mm/highmem.c
86078 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
86079 * So no dangers, even with speculative execution.
86080 */
86081 page = pte_page(pkmap_page_table[i]);
86082 + pax_open_kernel();
86083 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
86084 -
86085 + pax_close_kernel();
86086 set_page_address(page, NULL);
86087 need_flush = 1;
86088 }
86089 @@ -198,9 +199,11 @@ start:
86090 }
86091 }
86092 vaddr = PKMAP_ADDR(last_pkmap_nr);
86093 +
86094 + pax_open_kernel();
86095 set_pte_at(&init_mm, vaddr,
86096 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
86097 -
86098 + pax_close_kernel();
86099 pkmap_count[last_pkmap_nr] = 1;
86100 set_page_address(page, (void *)vaddr);
86101
86102 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
86103 index b60f330..ee7de7e 100644
86104 --- a/mm/hugetlb.c
86105 +++ b/mm/hugetlb.c
86106 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
86107 struct hstate *h = &default_hstate;
86108 unsigned long tmp;
86109 int ret;
86110 + ctl_table_no_const hugetlb_table;
86111
86112 tmp = h->max_huge_pages;
86113
86114 if (write && h->order >= MAX_ORDER)
86115 return -EINVAL;
86116
86117 - table->data = &tmp;
86118 - table->maxlen = sizeof(unsigned long);
86119 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86120 + hugetlb_table = *table;
86121 + hugetlb_table.data = &tmp;
86122 + hugetlb_table.maxlen = sizeof(unsigned long);
86123 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86124 if (ret)
86125 goto out;
86126
86127 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
86128 struct hstate *h = &default_hstate;
86129 unsigned long tmp;
86130 int ret;
86131 + ctl_table_no_const hugetlb_table;
86132
86133 tmp = h->nr_overcommit_huge_pages;
86134
86135 if (write && h->order >= MAX_ORDER)
86136 return -EINVAL;
86137
86138 - table->data = &tmp;
86139 - table->maxlen = sizeof(unsigned long);
86140 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86141 + hugetlb_table = *table;
86142 + hugetlb_table.data = &tmp;
86143 + hugetlb_table.maxlen = sizeof(unsigned long);
86144 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86145 if (ret)
86146 goto out;
86147
86148 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
86149 return 1;
86150 }
86151
86152 +#ifdef CONFIG_PAX_SEGMEXEC
86153 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
86154 +{
86155 + struct mm_struct *mm = vma->vm_mm;
86156 + struct vm_area_struct *vma_m;
86157 + unsigned long address_m;
86158 + pte_t *ptep_m;
86159 +
86160 + vma_m = pax_find_mirror_vma(vma);
86161 + if (!vma_m)
86162 + return;
86163 +
86164 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86165 + address_m = address + SEGMEXEC_TASK_SIZE;
86166 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
86167 + get_page(page_m);
86168 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
86169 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
86170 +}
86171 +#endif
86172 +
86173 /*
86174 * Hugetlb_cow() should be called with page lock of the original hugepage held.
86175 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
86176 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
86177 make_huge_pte(vma, new_page, 1));
86178 page_remove_rmap(old_page);
86179 hugepage_add_new_anon_rmap(new_page, vma, address);
86180 +
86181 +#ifdef CONFIG_PAX_SEGMEXEC
86182 + pax_mirror_huge_pte(vma, address, new_page);
86183 +#endif
86184 +
86185 /* Make the old page be freed below */
86186 new_page = old_page;
86187 }
86188 @@ -2821,6 +2851,10 @@ retry:
86189 && (vma->vm_flags & VM_SHARED)));
86190 set_huge_pte_at(mm, address, ptep, new_pte);
86191
86192 +#ifdef CONFIG_PAX_SEGMEXEC
86193 + pax_mirror_huge_pte(vma, address, page);
86194 +#endif
86195 +
86196 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
86197 /* Optimization, do the COW without a second fault */
86198 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
86199 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86200 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
86201 struct hstate *h = hstate_vma(vma);
86202
86203 +#ifdef CONFIG_PAX_SEGMEXEC
86204 + struct vm_area_struct *vma_m;
86205 +#endif
86206 +
86207 address &= huge_page_mask(h);
86208
86209 ptep = huge_pte_offset(mm, address);
86210 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86211 VM_FAULT_SET_HINDEX(hstate_index(h));
86212 }
86213
86214 +#ifdef CONFIG_PAX_SEGMEXEC
86215 + vma_m = pax_find_mirror_vma(vma);
86216 + if (vma_m) {
86217 + unsigned long address_m;
86218 +
86219 + if (vma->vm_start > vma_m->vm_start) {
86220 + address_m = address;
86221 + address -= SEGMEXEC_TASK_SIZE;
86222 + vma = vma_m;
86223 + h = hstate_vma(vma);
86224 + } else
86225 + address_m = address + SEGMEXEC_TASK_SIZE;
86226 +
86227 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
86228 + return VM_FAULT_OOM;
86229 + address_m &= HPAGE_MASK;
86230 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
86231 + }
86232 +#endif
86233 +
86234 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
86235 if (!ptep)
86236 return VM_FAULT_OOM;
86237 diff --git a/mm/internal.h b/mm/internal.h
86238 index 4390ac6..fc60373c 100644
86239 --- a/mm/internal.h
86240 +++ b/mm/internal.h
86241 @@ -95,6 +95,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
86242 * in mm/page_alloc.c
86243 */
86244 extern void __free_pages_bootmem(struct page *page, unsigned int order);
86245 +extern void free_compound_page(struct page *page);
86246 extern void prep_compound_page(struct page *page, unsigned long order);
86247 #ifdef CONFIG_MEMORY_FAILURE
86248 extern bool is_free_buddy_page(struct page *page);
86249 @@ -350,7 +351,7 @@ extern u32 hwpoison_filter_enable;
86250
86251 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
86252 unsigned long, unsigned long,
86253 - unsigned long, unsigned long);
86254 + unsigned long, unsigned long) __intentional_overflow(-1);
86255
86256 extern void set_pageblock_order(void);
86257 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
86258 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
86259 index c8d7f31..2dbeffd 100644
86260 --- a/mm/kmemleak.c
86261 +++ b/mm/kmemleak.c
86262 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
86263
86264 for (i = 0; i < object->trace_len; i++) {
86265 void *ptr = (void *)object->trace[i];
86266 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
86267 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
86268 }
86269 }
86270
86271 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
86272 return -ENOMEM;
86273 }
86274
86275 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
86276 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
86277 &kmemleak_fops);
86278 if (!dentry)
86279 pr_warning("Failed to create the debugfs kmemleak file\n");
86280 diff --git a/mm/maccess.c b/mm/maccess.c
86281 index d53adf9..03a24bf 100644
86282 --- a/mm/maccess.c
86283 +++ b/mm/maccess.c
86284 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
86285 set_fs(KERNEL_DS);
86286 pagefault_disable();
86287 ret = __copy_from_user_inatomic(dst,
86288 - (__force const void __user *)src, size);
86289 + (const void __force_user *)src, size);
86290 pagefault_enable();
86291 set_fs(old_fs);
86292
86293 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
86294
86295 set_fs(KERNEL_DS);
86296 pagefault_disable();
86297 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
86298 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
86299 pagefault_enable();
86300 set_fs(old_fs);
86301
86302 diff --git a/mm/madvise.c b/mm/madvise.c
86303 index 7055883..aafb1ed 100644
86304 --- a/mm/madvise.c
86305 +++ b/mm/madvise.c
86306 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
86307 pgoff_t pgoff;
86308 unsigned long new_flags = vma->vm_flags;
86309
86310 +#ifdef CONFIG_PAX_SEGMEXEC
86311 + struct vm_area_struct *vma_m;
86312 +#endif
86313 +
86314 switch (behavior) {
86315 case MADV_NORMAL:
86316 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
86317 @@ -126,6 +130,13 @@ success:
86318 /*
86319 * vm_flags is protected by the mmap_sem held in write mode.
86320 */
86321 +
86322 +#ifdef CONFIG_PAX_SEGMEXEC
86323 + vma_m = pax_find_mirror_vma(vma);
86324 + if (vma_m)
86325 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
86326 +#endif
86327 +
86328 vma->vm_flags = new_flags;
86329
86330 out:
86331 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86332 struct vm_area_struct ** prev,
86333 unsigned long start, unsigned long end)
86334 {
86335 +
86336 +#ifdef CONFIG_PAX_SEGMEXEC
86337 + struct vm_area_struct *vma_m;
86338 +#endif
86339 +
86340 *prev = vma;
86341 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
86342 return -EINVAL;
86343 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86344 zap_page_range(vma, start, end - start, &details);
86345 } else
86346 zap_page_range(vma, start, end - start, NULL);
86347 +
86348 +#ifdef CONFIG_PAX_SEGMEXEC
86349 + vma_m = pax_find_mirror_vma(vma);
86350 + if (vma_m) {
86351 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
86352 + struct zap_details details = {
86353 + .nonlinear_vma = vma_m,
86354 + .last_index = ULONG_MAX,
86355 + };
86356 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
86357 + } else
86358 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
86359 + }
86360 +#endif
86361 +
86362 return 0;
86363 }
86364
86365 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
86366 if (end < start)
86367 return error;
86368
86369 +#ifdef CONFIG_PAX_SEGMEXEC
86370 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
86371 + if (end > SEGMEXEC_TASK_SIZE)
86372 + return error;
86373 + } else
86374 +#endif
86375 +
86376 + if (end > TASK_SIZE)
86377 + return error;
86378 +
86379 error = 0;
86380 if (end == start)
86381 return error;
86382 diff --git a/mm/memcontrol.c b/mm/memcontrol.c
86383 index aa44621..99011b3 100644
86384 --- a/mm/memcontrol.c
86385 +++ b/mm/memcontrol.c
86386 @@ -2772,6 +2772,8 @@ done:
86387 return 0;
86388 nomem:
86389 *ptr = NULL;
86390 + if (gfp_mask & __GFP_NOFAIL)
86391 + return 0;
86392 return -ENOMEM;
86393 bypass:
86394 *ptr = root_mem_cgroup;
86395 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
86396 index 2c13aa7..64cbc3f 100644
86397 --- a/mm/memory-failure.c
86398 +++ b/mm/memory-failure.c
86399 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
86400
86401 int sysctl_memory_failure_recovery __read_mostly = 1;
86402
86403 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86404 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86405
86406 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
86407
86408 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
86409 pfn, t->comm, t->pid);
86410 si.si_signo = SIGBUS;
86411 si.si_errno = 0;
86412 - si.si_addr = (void *)addr;
86413 + si.si_addr = (void __user *)addr;
86414 #ifdef __ARCH_SI_TRAPNO
86415 si.si_trapno = trapno;
86416 #endif
86417 @@ -760,7 +760,7 @@ static struct page_state {
86418 unsigned long res;
86419 char *msg;
86420 int (*action)(struct page *p, unsigned long pfn);
86421 -} error_states[] = {
86422 +} __do_const error_states[] = {
86423 { reserved, reserved, "reserved kernel", me_kernel },
86424 /*
86425 * free pages are specially detected outside this table:
86426 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86427 nr_pages = 1 << compound_order(hpage);
86428 else /* normal page or thp */
86429 nr_pages = 1;
86430 - atomic_long_add(nr_pages, &num_poisoned_pages);
86431 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
86432
86433 /*
86434 * We need/can do nothing about count=0 pages.
86435 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86436 if (!PageHWPoison(hpage)
86437 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
86438 || (p != hpage && TestSetPageHWPoison(hpage))) {
86439 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86440 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86441 return 0;
86442 }
86443 set_page_hwpoison_huge_page(hpage);
86444 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86445 }
86446 if (hwpoison_filter(p)) {
86447 if (TestClearPageHWPoison(p))
86448 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86449 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86450 unlock_page(hpage);
86451 put_page(hpage);
86452 return 0;
86453 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
86454 return 0;
86455 }
86456 if (TestClearPageHWPoison(p))
86457 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86458 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86459 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
86460 return 0;
86461 }
86462 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
86463 */
86464 if (TestClearPageHWPoison(page)) {
86465 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
86466 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86467 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86468 freeit = 1;
86469 if (PageHuge(page))
86470 clear_page_hwpoison_huge_page(page);
86471 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
86472 } else {
86473 set_page_hwpoison_huge_page(hpage);
86474 dequeue_hwpoisoned_huge_page(hpage);
86475 - atomic_long_add(1 << compound_trans_order(hpage),
86476 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86477 &num_poisoned_pages);
86478 }
86479 return ret;
86480 @@ -1551,11 +1551,11 @@ int soft_offline_page(struct page *page, int flags)
86481 if (PageHuge(page)) {
86482 set_page_hwpoison_huge_page(hpage);
86483 dequeue_hwpoisoned_huge_page(hpage);
86484 - atomic_long_add(1 << compound_trans_order(hpage),
86485 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86486 &num_poisoned_pages);
86487 } else {
86488 SetPageHWPoison(page);
86489 - atomic_long_inc(&num_poisoned_pages);
86490 + atomic_long_inc_unchecked(&num_poisoned_pages);
86491 }
86492 }
86493 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
86494 @@ -1595,7 +1595,7 @@ static int __soft_offline_page(struct page *page, int flags)
86495 put_page(page);
86496 pr_info("soft_offline: %#lx: invalidated\n", pfn);
86497 SetPageHWPoison(page);
86498 - atomic_long_inc(&num_poisoned_pages);
86499 + atomic_long_inc_unchecked(&num_poisoned_pages);
86500 return 0;
86501 }
86502
86503 @@ -1640,7 +1640,7 @@ static int __soft_offline_page(struct page *page, int flags)
86504 if (!is_free_buddy_page(page))
86505 pr_info("soft offline: %#lx: page leaked\n",
86506 pfn);
86507 - atomic_long_inc(&num_poisoned_pages);
86508 + atomic_long_inc_unchecked(&num_poisoned_pages);
86509 }
86510 } else {
86511 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
86512 diff --git a/mm/memory.c b/mm/memory.c
86513 index 168a090..bfa069a 100644
86514 --- a/mm/memory.c
86515 +++ b/mm/memory.c
86516 @@ -426,6 +426,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86517 free_pte_range(tlb, pmd, addr);
86518 } while (pmd++, addr = next, addr != end);
86519
86520 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
86521 start &= PUD_MASK;
86522 if (start < floor)
86523 return;
86524 @@ -440,6 +441,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86525 pmd = pmd_offset(pud, start);
86526 pud_clear(pud);
86527 pmd_free_tlb(tlb, pmd, start);
86528 +#endif
86529 +
86530 }
86531
86532 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86533 @@ -459,6 +462,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86534 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
86535 } while (pud++, addr = next, addr != end);
86536
86537 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
86538 start &= PGDIR_MASK;
86539 if (start < floor)
86540 return;
86541 @@ -473,6 +477,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86542 pud = pud_offset(pgd, start);
86543 pgd_clear(pgd);
86544 pud_free_tlb(tlb, pud, start);
86545 +#endif
86546 +
86547 }
86548
86549 /*
86550 @@ -1647,12 +1653,6 @@ no_page_table:
86551 return page;
86552 }
86553
86554 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
86555 -{
86556 - return stack_guard_page_start(vma, addr) ||
86557 - stack_guard_page_end(vma, addr+PAGE_SIZE);
86558 -}
86559 -
86560 /**
86561 * __get_user_pages() - pin user pages in memory
86562 * @tsk: task_struct of target task
86563 @@ -1739,10 +1739,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86564
86565 i = 0;
86566
86567 - do {
86568 + while (nr_pages) {
86569 struct vm_area_struct *vma;
86570
86571 - vma = find_extend_vma(mm, start);
86572 + vma = find_vma(mm, start);
86573 if (!vma && in_gate_area(mm, start)) {
86574 unsigned long pg = start & PAGE_MASK;
86575 pgd_t *pgd;
86576 @@ -1791,7 +1791,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86577 goto next_page;
86578 }
86579
86580 - if (!vma ||
86581 + if (!vma || start < vma->vm_start ||
86582 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
86583 !(vm_flags & vma->vm_flags))
86584 return i ? : -EFAULT;
86585 @@ -1820,11 +1820,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86586 int ret;
86587 unsigned int fault_flags = 0;
86588
86589 - /* For mlock, just skip the stack guard page. */
86590 - if (foll_flags & FOLL_MLOCK) {
86591 - if (stack_guard_page(vma, start))
86592 - goto next_page;
86593 - }
86594 if (foll_flags & FOLL_WRITE)
86595 fault_flags |= FAULT_FLAG_WRITE;
86596 if (nonblocking)
86597 @@ -1904,7 +1899,7 @@ next_page:
86598 start += page_increm * PAGE_SIZE;
86599 nr_pages -= page_increm;
86600 } while (nr_pages && start < vma->vm_end);
86601 - } while (nr_pages);
86602 + }
86603 return i;
86604 }
86605 EXPORT_SYMBOL(__get_user_pages);
86606 @@ -2111,6 +2106,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
86607 page_add_file_rmap(page);
86608 set_pte_at(mm, addr, pte, mk_pte(page, prot));
86609
86610 +#ifdef CONFIG_PAX_SEGMEXEC
86611 + pax_mirror_file_pte(vma, addr, page, ptl);
86612 +#endif
86613 +
86614 retval = 0;
86615 pte_unmap_unlock(pte, ptl);
86616 return retval;
86617 @@ -2155,9 +2154,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
86618 if (!page_count(page))
86619 return -EINVAL;
86620 if (!(vma->vm_flags & VM_MIXEDMAP)) {
86621 +
86622 +#ifdef CONFIG_PAX_SEGMEXEC
86623 + struct vm_area_struct *vma_m;
86624 +#endif
86625 +
86626 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
86627 BUG_ON(vma->vm_flags & VM_PFNMAP);
86628 vma->vm_flags |= VM_MIXEDMAP;
86629 +
86630 +#ifdef CONFIG_PAX_SEGMEXEC
86631 + vma_m = pax_find_mirror_vma(vma);
86632 + if (vma_m)
86633 + vma_m->vm_flags |= VM_MIXEDMAP;
86634 +#endif
86635 +
86636 }
86637 return insert_page(vma, addr, page, vma->vm_page_prot);
86638 }
86639 @@ -2240,6 +2251,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
86640 unsigned long pfn)
86641 {
86642 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
86643 + BUG_ON(vma->vm_mirror);
86644
86645 if (addr < vma->vm_start || addr >= vma->vm_end)
86646 return -EFAULT;
86647 @@ -2487,7 +2499,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
86648
86649 BUG_ON(pud_huge(*pud));
86650
86651 - pmd = pmd_alloc(mm, pud, addr);
86652 + pmd = (mm == &init_mm) ?
86653 + pmd_alloc_kernel(mm, pud, addr) :
86654 + pmd_alloc(mm, pud, addr);
86655 if (!pmd)
86656 return -ENOMEM;
86657 do {
86658 @@ -2507,7 +2521,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
86659 unsigned long next;
86660 int err;
86661
86662 - pud = pud_alloc(mm, pgd, addr);
86663 + pud = (mm == &init_mm) ?
86664 + pud_alloc_kernel(mm, pgd, addr) :
86665 + pud_alloc(mm, pgd, addr);
86666 if (!pud)
86667 return -ENOMEM;
86668 do {
86669 @@ -2595,6 +2611,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
86670 copy_user_highpage(dst, src, va, vma);
86671 }
86672
86673 +#ifdef CONFIG_PAX_SEGMEXEC
86674 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
86675 +{
86676 + struct mm_struct *mm = vma->vm_mm;
86677 + spinlock_t *ptl;
86678 + pte_t *pte, entry;
86679 +
86680 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
86681 + entry = *pte;
86682 + if (!pte_present(entry)) {
86683 + if (!pte_none(entry)) {
86684 + BUG_ON(pte_file(entry));
86685 + free_swap_and_cache(pte_to_swp_entry(entry));
86686 + pte_clear_not_present_full(mm, address, pte, 0);
86687 + }
86688 + } else {
86689 + struct page *page;
86690 +
86691 + flush_cache_page(vma, address, pte_pfn(entry));
86692 + entry = ptep_clear_flush(vma, address, pte);
86693 + BUG_ON(pte_dirty(entry));
86694 + page = vm_normal_page(vma, address, entry);
86695 + if (page) {
86696 + update_hiwater_rss(mm);
86697 + if (PageAnon(page))
86698 + dec_mm_counter_fast(mm, MM_ANONPAGES);
86699 + else
86700 + dec_mm_counter_fast(mm, MM_FILEPAGES);
86701 + page_remove_rmap(page);
86702 + page_cache_release(page);
86703 + }
86704 + }
86705 + pte_unmap_unlock(pte, ptl);
86706 +}
86707 +
86708 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
86709 + *
86710 + * the ptl of the lower mapped page is held on entry and is not released on exit
86711 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
86712 + */
86713 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86714 +{
86715 + struct mm_struct *mm = vma->vm_mm;
86716 + unsigned long address_m;
86717 + spinlock_t *ptl_m;
86718 + struct vm_area_struct *vma_m;
86719 + pmd_t *pmd_m;
86720 + pte_t *pte_m, entry_m;
86721 +
86722 + BUG_ON(!page_m || !PageAnon(page_m));
86723 +
86724 + vma_m = pax_find_mirror_vma(vma);
86725 + if (!vma_m)
86726 + return;
86727 +
86728 + BUG_ON(!PageLocked(page_m));
86729 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86730 + address_m = address + SEGMEXEC_TASK_SIZE;
86731 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86732 + pte_m = pte_offset_map(pmd_m, address_m);
86733 + ptl_m = pte_lockptr(mm, pmd_m);
86734 + if (ptl != ptl_m) {
86735 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86736 + if (!pte_none(*pte_m))
86737 + goto out;
86738 + }
86739 +
86740 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86741 + page_cache_get(page_m);
86742 + page_add_anon_rmap(page_m, vma_m, address_m);
86743 + inc_mm_counter_fast(mm, MM_ANONPAGES);
86744 + set_pte_at(mm, address_m, pte_m, entry_m);
86745 + update_mmu_cache(vma_m, address_m, pte_m);
86746 +out:
86747 + if (ptl != ptl_m)
86748 + spin_unlock(ptl_m);
86749 + pte_unmap(pte_m);
86750 + unlock_page(page_m);
86751 +}
86752 +
86753 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86754 +{
86755 + struct mm_struct *mm = vma->vm_mm;
86756 + unsigned long address_m;
86757 + spinlock_t *ptl_m;
86758 + struct vm_area_struct *vma_m;
86759 + pmd_t *pmd_m;
86760 + pte_t *pte_m, entry_m;
86761 +
86762 + BUG_ON(!page_m || PageAnon(page_m));
86763 +
86764 + vma_m = pax_find_mirror_vma(vma);
86765 + if (!vma_m)
86766 + return;
86767 +
86768 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86769 + address_m = address + SEGMEXEC_TASK_SIZE;
86770 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86771 + pte_m = pte_offset_map(pmd_m, address_m);
86772 + ptl_m = pte_lockptr(mm, pmd_m);
86773 + if (ptl != ptl_m) {
86774 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86775 + if (!pte_none(*pte_m))
86776 + goto out;
86777 + }
86778 +
86779 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86780 + page_cache_get(page_m);
86781 + page_add_file_rmap(page_m);
86782 + inc_mm_counter_fast(mm, MM_FILEPAGES);
86783 + set_pte_at(mm, address_m, pte_m, entry_m);
86784 + update_mmu_cache(vma_m, address_m, pte_m);
86785 +out:
86786 + if (ptl != ptl_m)
86787 + spin_unlock(ptl_m);
86788 + pte_unmap(pte_m);
86789 +}
86790 +
86791 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
86792 +{
86793 + struct mm_struct *mm = vma->vm_mm;
86794 + unsigned long address_m;
86795 + spinlock_t *ptl_m;
86796 + struct vm_area_struct *vma_m;
86797 + pmd_t *pmd_m;
86798 + pte_t *pte_m, entry_m;
86799 +
86800 + vma_m = pax_find_mirror_vma(vma);
86801 + if (!vma_m)
86802 + return;
86803 +
86804 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86805 + address_m = address + SEGMEXEC_TASK_SIZE;
86806 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86807 + pte_m = pte_offset_map(pmd_m, address_m);
86808 + ptl_m = pte_lockptr(mm, pmd_m);
86809 + if (ptl != ptl_m) {
86810 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86811 + if (!pte_none(*pte_m))
86812 + goto out;
86813 + }
86814 +
86815 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
86816 + set_pte_at(mm, address_m, pte_m, entry_m);
86817 +out:
86818 + if (ptl != ptl_m)
86819 + spin_unlock(ptl_m);
86820 + pte_unmap(pte_m);
86821 +}
86822 +
86823 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
86824 +{
86825 + struct page *page_m;
86826 + pte_t entry;
86827 +
86828 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
86829 + goto out;
86830 +
86831 + entry = *pte;
86832 + page_m = vm_normal_page(vma, address, entry);
86833 + if (!page_m)
86834 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
86835 + else if (PageAnon(page_m)) {
86836 + if (pax_find_mirror_vma(vma)) {
86837 + pte_unmap_unlock(pte, ptl);
86838 + lock_page(page_m);
86839 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
86840 + if (pte_same(entry, *pte))
86841 + pax_mirror_anon_pte(vma, address, page_m, ptl);
86842 + else
86843 + unlock_page(page_m);
86844 + }
86845 + } else
86846 + pax_mirror_file_pte(vma, address, page_m, ptl);
86847 +
86848 +out:
86849 + pte_unmap_unlock(pte, ptl);
86850 +}
86851 +#endif
86852 +
86853 /*
86854 * This routine handles present pages, when users try to write
86855 * to a shared page. It is done by copying the page to a new address
86856 @@ -2811,6 +3007,12 @@ gotten:
86857 */
86858 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86859 if (likely(pte_same(*page_table, orig_pte))) {
86860 +
86861 +#ifdef CONFIG_PAX_SEGMEXEC
86862 + if (pax_find_mirror_vma(vma))
86863 + BUG_ON(!trylock_page(new_page));
86864 +#endif
86865 +
86866 if (old_page) {
86867 if (!PageAnon(old_page)) {
86868 dec_mm_counter_fast(mm, MM_FILEPAGES);
86869 @@ -2862,6 +3064,10 @@ gotten:
86870 page_remove_rmap(old_page);
86871 }
86872
86873 +#ifdef CONFIG_PAX_SEGMEXEC
86874 + pax_mirror_anon_pte(vma, address, new_page, ptl);
86875 +#endif
86876 +
86877 /* Free the old page.. */
86878 new_page = old_page;
86879 ret |= VM_FAULT_WRITE;
86880 @@ -3139,6 +3345,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86881 swap_free(entry);
86882 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
86883 try_to_free_swap(page);
86884 +
86885 +#ifdef CONFIG_PAX_SEGMEXEC
86886 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
86887 +#endif
86888 +
86889 unlock_page(page);
86890 if (page != swapcache) {
86891 /*
86892 @@ -3162,6 +3373,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86893
86894 /* No need to invalidate - it was non-present before */
86895 update_mmu_cache(vma, address, page_table);
86896 +
86897 +#ifdef CONFIG_PAX_SEGMEXEC
86898 + pax_mirror_anon_pte(vma, address, page, ptl);
86899 +#endif
86900 +
86901 unlock:
86902 pte_unmap_unlock(page_table, ptl);
86903 out:
86904 @@ -3181,40 +3397,6 @@ out_release:
86905 }
86906
86907 /*
86908 - * This is like a special single-page "expand_{down|up}wards()",
86909 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
86910 - * doesn't hit another vma.
86911 - */
86912 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
86913 -{
86914 - address &= PAGE_MASK;
86915 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
86916 - struct vm_area_struct *prev = vma->vm_prev;
86917 -
86918 - /*
86919 - * Is there a mapping abutting this one below?
86920 - *
86921 - * That's only ok if it's the same stack mapping
86922 - * that has gotten split..
86923 - */
86924 - if (prev && prev->vm_end == address)
86925 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
86926 -
86927 - expand_downwards(vma, address - PAGE_SIZE);
86928 - }
86929 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
86930 - struct vm_area_struct *next = vma->vm_next;
86931 -
86932 - /* As VM_GROWSDOWN but s/below/above/ */
86933 - if (next && next->vm_start == address + PAGE_SIZE)
86934 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
86935 -
86936 - expand_upwards(vma, address + PAGE_SIZE);
86937 - }
86938 - return 0;
86939 -}
86940 -
86941 -/*
86942 * We enter with non-exclusive mmap_sem (to exclude vma changes,
86943 * but allow concurrent faults), and pte mapped but not yet locked.
86944 * We return with mmap_sem still held, but pte unmapped and unlocked.
86945 @@ -3223,27 +3405,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86946 unsigned long address, pte_t *page_table, pmd_t *pmd,
86947 unsigned int flags)
86948 {
86949 - struct page *page;
86950 + struct page *page = NULL;
86951 spinlock_t *ptl;
86952 pte_t entry;
86953
86954 - pte_unmap(page_table);
86955 -
86956 - /* Check if we need to add a guard page to the stack */
86957 - if (check_stack_guard_page(vma, address) < 0)
86958 - return VM_FAULT_SIGBUS;
86959 -
86960 - /* Use the zero-page for reads */
86961 if (!(flags & FAULT_FLAG_WRITE)) {
86962 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
86963 vma->vm_page_prot));
86964 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86965 + ptl = pte_lockptr(mm, pmd);
86966 + spin_lock(ptl);
86967 if (!pte_none(*page_table))
86968 goto unlock;
86969 goto setpte;
86970 }
86971
86972 /* Allocate our own private page. */
86973 + pte_unmap(page_table);
86974 +
86975 if (unlikely(anon_vma_prepare(vma)))
86976 goto oom;
86977 page = alloc_zeroed_user_highpage_movable(vma, address);
86978 @@ -3267,6 +3445,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86979 if (!pte_none(*page_table))
86980 goto release;
86981
86982 +#ifdef CONFIG_PAX_SEGMEXEC
86983 + if (pax_find_mirror_vma(vma))
86984 + BUG_ON(!trylock_page(page));
86985 +#endif
86986 +
86987 inc_mm_counter_fast(mm, MM_ANONPAGES);
86988 page_add_new_anon_rmap(page, vma, address);
86989 setpte:
86990 @@ -3274,6 +3457,12 @@ setpte:
86991
86992 /* No need to invalidate - it was non-present before */
86993 update_mmu_cache(vma, address, page_table);
86994 +
86995 +#ifdef CONFIG_PAX_SEGMEXEC
86996 + if (page)
86997 + pax_mirror_anon_pte(vma, address, page, ptl);
86998 +#endif
86999 +
87000 unlock:
87001 pte_unmap_unlock(page_table, ptl);
87002 return 0;
87003 @@ -3417,6 +3606,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87004 */
87005 /* Only go through if we didn't race with anybody else... */
87006 if (likely(pte_same(*page_table, orig_pte))) {
87007 +
87008 +#ifdef CONFIG_PAX_SEGMEXEC
87009 + if (anon && pax_find_mirror_vma(vma))
87010 + BUG_ON(!trylock_page(page));
87011 +#endif
87012 +
87013 flush_icache_page(vma, page);
87014 entry = mk_pte(page, vma->vm_page_prot);
87015 if (flags & FAULT_FLAG_WRITE)
87016 @@ -3438,6 +3633,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87017
87018 /* no need to invalidate: a not-present page won't be cached */
87019 update_mmu_cache(vma, address, page_table);
87020 +
87021 +#ifdef CONFIG_PAX_SEGMEXEC
87022 + if (anon)
87023 + pax_mirror_anon_pte(vma, address, page, ptl);
87024 + else
87025 + pax_mirror_file_pte(vma, address, page, ptl);
87026 +#endif
87027 +
87028 } else {
87029 if (cow_page)
87030 mem_cgroup_uncharge_page(cow_page);
87031 @@ -3748,6 +3951,12 @@ int handle_pte_fault(struct mm_struct *mm,
87032 if (flags & FAULT_FLAG_WRITE)
87033 flush_tlb_fix_spurious_fault(vma, address);
87034 }
87035 +
87036 +#ifdef CONFIG_PAX_SEGMEXEC
87037 + pax_mirror_pte(vma, address, pte, pmd, ptl);
87038 + return 0;
87039 +#endif
87040 +
87041 unlock:
87042 pte_unmap_unlock(pte, ptl);
87043 return 0;
87044 @@ -3764,6 +3973,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87045 pmd_t *pmd;
87046 pte_t *pte;
87047
87048 +#ifdef CONFIG_PAX_SEGMEXEC
87049 + struct vm_area_struct *vma_m;
87050 +#endif
87051 +
87052 __set_current_state(TASK_RUNNING);
87053
87054 count_vm_event(PGFAULT);
87055 @@ -3775,6 +3988,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87056 if (unlikely(is_vm_hugetlb_page(vma)))
87057 return hugetlb_fault(mm, vma, address, flags);
87058
87059 +#ifdef CONFIG_PAX_SEGMEXEC
87060 + vma_m = pax_find_mirror_vma(vma);
87061 + if (vma_m) {
87062 + unsigned long address_m;
87063 + pgd_t *pgd_m;
87064 + pud_t *pud_m;
87065 + pmd_t *pmd_m;
87066 +
87067 + if (vma->vm_start > vma_m->vm_start) {
87068 + address_m = address;
87069 + address -= SEGMEXEC_TASK_SIZE;
87070 + vma = vma_m;
87071 + } else
87072 + address_m = address + SEGMEXEC_TASK_SIZE;
87073 +
87074 + pgd_m = pgd_offset(mm, address_m);
87075 + pud_m = pud_alloc(mm, pgd_m, address_m);
87076 + if (!pud_m)
87077 + return VM_FAULT_OOM;
87078 + pmd_m = pmd_alloc(mm, pud_m, address_m);
87079 + if (!pmd_m)
87080 + return VM_FAULT_OOM;
87081 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
87082 + return VM_FAULT_OOM;
87083 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
87084 + }
87085 +#endif
87086 +
87087 retry:
87088 pgd = pgd_offset(mm, address);
87089 pud = pud_alloc(mm, pgd, address);
87090 @@ -3873,6 +4114,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87091 spin_unlock(&mm->page_table_lock);
87092 return 0;
87093 }
87094 +
87095 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87096 +{
87097 + pud_t *new = pud_alloc_one(mm, address);
87098 + if (!new)
87099 + return -ENOMEM;
87100 +
87101 + smp_wmb(); /* See comment in __pte_alloc */
87102 +
87103 + spin_lock(&mm->page_table_lock);
87104 + if (pgd_present(*pgd)) /* Another has populated it */
87105 + pud_free(mm, new);
87106 + else
87107 + pgd_populate_kernel(mm, pgd, new);
87108 + spin_unlock(&mm->page_table_lock);
87109 + return 0;
87110 +}
87111 #endif /* __PAGETABLE_PUD_FOLDED */
87112
87113 #ifndef __PAGETABLE_PMD_FOLDED
87114 @@ -3903,6 +4161,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
87115 spin_unlock(&mm->page_table_lock);
87116 return 0;
87117 }
87118 +
87119 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
87120 +{
87121 + pmd_t *new = pmd_alloc_one(mm, address);
87122 + if (!new)
87123 + return -ENOMEM;
87124 +
87125 + smp_wmb(); /* See comment in __pte_alloc */
87126 +
87127 + spin_lock(&mm->page_table_lock);
87128 +#ifndef __ARCH_HAS_4LEVEL_HACK
87129 + if (pud_present(*pud)) /* Another has populated it */
87130 + pmd_free(mm, new);
87131 + else
87132 + pud_populate_kernel(mm, pud, new);
87133 +#else
87134 + if (pgd_present(*pud)) /* Another has populated it */
87135 + pmd_free(mm, new);
87136 + else
87137 + pgd_populate_kernel(mm, pud, new);
87138 +#endif /* __ARCH_HAS_4LEVEL_HACK */
87139 + spin_unlock(&mm->page_table_lock);
87140 + return 0;
87141 +}
87142 #endif /* __PAGETABLE_PMD_FOLDED */
87143
87144 #if !defined(__HAVE_ARCH_GATE_AREA)
87145 @@ -3916,7 +4198,7 @@ static int __init gate_vma_init(void)
87146 gate_vma.vm_start = FIXADDR_USER_START;
87147 gate_vma.vm_end = FIXADDR_USER_END;
87148 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
87149 - gate_vma.vm_page_prot = __P101;
87150 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
87151
87152 return 0;
87153 }
87154 @@ -4050,8 +4332,8 @@ out:
87155 return ret;
87156 }
87157
87158 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87159 - void *buf, int len, int write)
87160 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87161 + void *buf, size_t len, int write)
87162 {
87163 resource_size_t phys_addr;
87164 unsigned long prot = 0;
87165 @@ -4077,8 +4359,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
87166 * Access another process' address space as given in mm. If non-NULL, use the
87167 * given task for page fault accounting.
87168 */
87169 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87170 - unsigned long addr, void *buf, int len, int write)
87171 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87172 + unsigned long addr, void *buf, size_t len, int write)
87173 {
87174 struct vm_area_struct *vma;
87175 void *old_buf = buf;
87176 @@ -4086,7 +4368,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87177 down_read(&mm->mmap_sem);
87178 /* ignore errors, just check how much was successfully transferred */
87179 while (len) {
87180 - int bytes, ret, offset;
87181 + ssize_t bytes, ret, offset;
87182 void *maddr;
87183 struct page *page = NULL;
87184
87185 @@ -4145,8 +4427,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87186 *
87187 * The caller must hold a reference on @mm.
87188 */
87189 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87190 - void *buf, int len, int write)
87191 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
87192 + void *buf, size_t len, int write)
87193 {
87194 return __access_remote_vm(NULL, mm, addr, buf, len, write);
87195 }
87196 @@ -4156,11 +4438,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87197 * Source/target buffer must be kernel space,
87198 * Do not walk the page table directly, use get_user_pages
87199 */
87200 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
87201 - void *buf, int len, int write)
87202 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
87203 + void *buf, size_t len, int write)
87204 {
87205 struct mm_struct *mm;
87206 - int ret;
87207 + ssize_t ret;
87208
87209 mm = get_task_mm(tsk);
87210 if (!mm)
87211 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
87212 index 4baf12e..5497066 100644
87213 --- a/mm/mempolicy.c
87214 +++ b/mm/mempolicy.c
87215 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87216 unsigned long vmstart;
87217 unsigned long vmend;
87218
87219 +#ifdef CONFIG_PAX_SEGMEXEC
87220 + struct vm_area_struct *vma_m;
87221 +#endif
87222 +
87223 vma = find_vma(mm, start);
87224 if (!vma || vma->vm_start > start)
87225 return -EFAULT;
87226 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87227 err = vma_replace_policy(vma, new_pol);
87228 if (err)
87229 goto out;
87230 +
87231 +#ifdef CONFIG_PAX_SEGMEXEC
87232 + vma_m = pax_find_mirror_vma(vma);
87233 + if (vma_m) {
87234 + err = vma_replace_policy(vma_m, new_pol);
87235 + if (err)
87236 + goto out;
87237 + }
87238 +#endif
87239 +
87240 }
87241
87242 out:
87243 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
87244
87245 if (end < start)
87246 return -EINVAL;
87247 +
87248 +#ifdef CONFIG_PAX_SEGMEXEC
87249 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
87250 + if (end > SEGMEXEC_TASK_SIZE)
87251 + return -EINVAL;
87252 + } else
87253 +#endif
87254 +
87255 + if (end > TASK_SIZE)
87256 + return -EINVAL;
87257 +
87258 if (end == start)
87259 return 0;
87260
87261 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87262 */
87263 tcred = __task_cred(task);
87264 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87265 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87266 - !capable(CAP_SYS_NICE)) {
87267 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87268 rcu_read_unlock();
87269 err = -EPERM;
87270 goto out_put;
87271 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87272 goto out;
87273 }
87274
87275 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
87276 + if (mm != current->mm &&
87277 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
87278 + mmput(mm);
87279 + err = -EPERM;
87280 + goto out;
87281 + }
87282 +#endif
87283 +
87284 err = do_migrate_pages(mm, old, new,
87285 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
87286
87287 diff --git a/mm/migrate.c b/mm/migrate.c
87288 index d22f6f0..f12a8d0 100644
87289 --- a/mm/migrate.c
87290 +++ b/mm/migrate.c
87291 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
87292 */
87293 tcred = __task_cred(task);
87294 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87295 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87296 - !capable(CAP_SYS_NICE)) {
87297 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87298 rcu_read_unlock();
87299 err = -EPERM;
87300 goto out;
87301 diff --git a/mm/mlock.c b/mm/mlock.c
87302 index 79b7cf7..37472bf 100644
87303 --- a/mm/mlock.c
87304 +++ b/mm/mlock.c
87305 @@ -13,6 +13,7 @@
87306 #include <linux/pagemap.h>
87307 #include <linux/mempolicy.h>
87308 #include <linux/syscalls.h>
87309 +#include <linux/security.h>
87310 #include <linux/sched.h>
87311 #include <linux/export.h>
87312 #include <linux/rmap.h>
87313 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
87314 {
87315 unsigned long nstart, end, tmp;
87316 struct vm_area_struct * vma, * prev;
87317 - int error;
87318 + int error = 0;
87319
87320 VM_BUG_ON(start & ~PAGE_MASK);
87321 VM_BUG_ON(len != PAGE_ALIGN(len));
87322 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
87323 return -EINVAL;
87324 if (end == start)
87325 return 0;
87326 + if (end > TASK_SIZE)
87327 + return -EINVAL;
87328 +
87329 vma = find_vma(current->mm, start);
87330 if (!vma || vma->vm_start > start)
87331 return -ENOMEM;
87332 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
87333 for (nstart = start ; ; ) {
87334 vm_flags_t newflags;
87335
87336 +#ifdef CONFIG_PAX_SEGMEXEC
87337 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87338 + break;
87339 +#endif
87340 +
87341 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
87342
87343 newflags = vma->vm_flags & ~VM_LOCKED;
87344 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
87345 lock_limit >>= PAGE_SHIFT;
87346
87347 /* check against resource limits */
87348 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
87349 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
87350 error = do_mlock(start, len, 1);
87351 up_write(&current->mm->mmap_sem);
87352 @@ -500,12 +510,18 @@ static int do_mlockall(int flags)
87353 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
87354 vm_flags_t newflags;
87355
87356 +#ifdef CONFIG_PAX_SEGMEXEC
87357 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87358 + break;
87359 +#endif
87360 +
87361 newflags = vma->vm_flags & ~VM_LOCKED;
87362 if (flags & MCL_CURRENT)
87363 newflags |= VM_LOCKED;
87364
87365 /* Ignore errors */
87366 mlock_fixup(vma, &prev, vma->vm_start, vma->vm_end, newflags);
87367 + cond_resched();
87368 }
87369 out:
87370 return 0;
87371 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
87372 lock_limit >>= PAGE_SHIFT;
87373
87374 ret = -ENOMEM;
87375 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
87376 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
87377 capable(CAP_IPC_LOCK))
87378 ret = do_mlockall(flags);
87379 diff --git a/mm/mmap.c b/mm/mmap.c
87380 index f9c97d1..3468d3b 100644
87381 --- a/mm/mmap.c
87382 +++ b/mm/mmap.c
87383 @@ -36,6 +36,7 @@
87384 #include <linux/sched/sysctl.h>
87385 #include <linux/notifier.h>
87386 #include <linux/memory.h>
87387 +#include <linux/random.h>
87388
87389 #include <asm/uaccess.h>
87390 #include <asm/cacheflush.h>
87391 @@ -52,6 +53,16 @@
87392 #define arch_rebalance_pgtables(addr, len) (addr)
87393 #endif
87394
87395 +static inline void verify_mm_writelocked(struct mm_struct *mm)
87396 +{
87397 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
87398 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
87399 + up_read(&mm->mmap_sem);
87400 + BUG();
87401 + }
87402 +#endif
87403 +}
87404 +
87405 static void unmap_region(struct mm_struct *mm,
87406 struct vm_area_struct *vma, struct vm_area_struct *prev,
87407 unsigned long start, unsigned long end);
87408 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
87409 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
87410 *
87411 */
87412 -pgprot_t protection_map[16] = {
87413 +pgprot_t protection_map[16] __read_only = {
87414 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
87415 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
87416 };
87417
87418 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
87419 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
87420 {
87421 - return __pgprot(pgprot_val(protection_map[vm_flags &
87422 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
87423 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
87424 pgprot_val(arch_vm_get_page_prot(vm_flags)));
87425 +
87426 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87427 + if (!(__supported_pte_mask & _PAGE_NX) &&
87428 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
87429 + (vm_flags & (VM_READ | VM_WRITE)))
87430 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
87431 +#endif
87432 +
87433 + return prot;
87434 }
87435 EXPORT_SYMBOL(vm_get_page_prot);
87436
87437 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
87438 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
87439 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
87440 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
87441 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
87442 /*
87443 * Make sure vm_committed_as in one cacheline and not cacheline shared with
87444 * other variables. It can be updated by several CPUs frequently.
87445 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
87446 struct vm_area_struct *next = vma->vm_next;
87447
87448 might_sleep();
87449 + BUG_ON(vma->vm_mirror);
87450 if (vma->vm_ops && vma->vm_ops->close)
87451 vma->vm_ops->close(vma);
87452 if (vma->vm_file)
87453 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
87454 * not page aligned -Ram Gupta
87455 */
87456 rlim = rlimit(RLIMIT_DATA);
87457 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
87458 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
87459 (mm->end_data - mm->start_data) > rlim)
87460 goto out;
87461 @@ -933,6 +956,12 @@ static int
87462 can_vma_merge_before(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_start == 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 if (vma->vm_pgoff == vm_pgoff)
87474 @@ -952,6 +981,12 @@ static int
87475 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87476 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87477 {
87478 +
87479 +#ifdef CONFIG_PAX_SEGMEXEC
87480 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
87481 + return 0;
87482 +#endif
87483 +
87484 if (is_mergeable_vma(vma, file, vm_flags) &&
87485 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87486 pgoff_t vm_pglen;
87487 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87488 struct vm_area_struct *vma_merge(struct mm_struct *mm,
87489 struct vm_area_struct *prev, unsigned long addr,
87490 unsigned long end, unsigned long vm_flags,
87491 - struct anon_vma *anon_vma, struct file *file,
87492 + struct anon_vma *anon_vma, struct file *file,
87493 pgoff_t pgoff, struct mempolicy *policy)
87494 {
87495 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
87496 struct vm_area_struct *area, *next;
87497 int err;
87498
87499 +#ifdef CONFIG_PAX_SEGMEXEC
87500 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
87501 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
87502 +
87503 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
87504 +#endif
87505 +
87506 /*
87507 * We later require that vma->vm_flags == vm_flags,
87508 * so this tests vma->vm_flags & VM_SPECIAL, too.
87509 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87510 if (next && next->vm_end == end) /* cases 6, 7, 8 */
87511 next = next->vm_next;
87512
87513 +#ifdef CONFIG_PAX_SEGMEXEC
87514 + if (prev)
87515 + prev_m = pax_find_mirror_vma(prev);
87516 + if (area)
87517 + area_m = pax_find_mirror_vma(area);
87518 + if (next)
87519 + next_m = pax_find_mirror_vma(next);
87520 +#endif
87521 +
87522 /*
87523 * Can it merge with the predecessor?
87524 */
87525 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87526 /* cases 1, 6 */
87527 err = vma_adjust(prev, prev->vm_start,
87528 next->vm_end, prev->vm_pgoff, NULL);
87529 - } else /* cases 2, 5, 7 */
87530 +
87531 +#ifdef CONFIG_PAX_SEGMEXEC
87532 + if (!err && prev_m)
87533 + err = vma_adjust(prev_m, prev_m->vm_start,
87534 + next_m->vm_end, prev_m->vm_pgoff, NULL);
87535 +#endif
87536 +
87537 + } else { /* cases 2, 5, 7 */
87538 err = vma_adjust(prev, prev->vm_start,
87539 end, prev->vm_pgoff, NULL);
87540 +
87541 +#ifdef CONFIG_PAX_SEGMEXEC
87542 + if (!err && prev_m)
87543 + err = vma_adjust(prev_m, prev_m->vm_start,
87544 + end_m, prev_m->vm_pgoff, NULL);
87545 +#endif
87546 +
87547 + }
87548 if (err)
87549 return NULL;
87550 khugepaged_enter_vma_merge(prev);
87551 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87552 mpol_equal(policy, vma_policy(next)) &&
87553 can_vma_merge_before(next, vm_flags,
87554 anon_vma, file, pgoff+pglen)) {
87555 - if (prev && addr < prev->vm_end) /* case 4 */
87556 + if (prev && addr < prev->vm_end) { /* case 4 */
87557 err = vma_adjust(prev, prev->vm_start,
87558 addr, prev->vm_pgoff, NULL);
87559 - else /* cases 3, 8 */
87560 +
87561 +#ifdef CONFIG_PAX_SEGMEXEC
87562 + if (!err && prev_m)
87563 + err = vma_adjust(prev_m, prev_m->vm_start,
87564 + addr_m, prev_m->vm_pgoff, NULL);
87565 +#endif
87566 +
87567 + } else { /* cases 3, 8 */
87568 err = vma_adjust(area, addr, next->vm_end,
87569 next->vm_pgoff - pglen, NULL);
87570 +
87571 +#ifdef CONFIG_PAX_SEGMEXEC
87572 + if (!err && area_m)
87573 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
87574 + next_m->vm_pgoff - pglen, NULL);
87575 +#endif
87576 +
87577 + }
87578 if (err)
87579 return NULL;
87580 khugepaged_enter_vma_merge(area);
87581 @@ -1165,8 +1246,10 @@ none:
87582 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87583 struct file *file, long pages)
87584 {
87585 - const unsigned long stack_flags
87586 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
87587 +
87588 +#ifdef CONFIG_PAX_RANDMMAP
87589 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87590 +#endif
87591
87592 mm->total_vm += pages;
87593
87594 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87595 mm->shared_vm += pages;
87596 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
87597 mm->exec_vm += pages;
87598 - } else if (flags & stack_flags)
87599 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
87600 mm->stack_vm += pages;
87601 }
87602 #endif /* CONFIG_PROC_FS */
87603 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87604 * (the exception is when the underlying filesystem is noexec
87605 * mounted, in which case we dont add PROT_EXEC.)
87606 */
87607 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87608 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87609 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
87610 prot |= PROT_EXEC;
87611
87612 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87613 /* Obtain the address to map to. we verify (or select) it and ensure
87614 * that it represents a valid section of the address space.
87615 */
87616 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
87617 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
87618 if (addr & ~PAGE_MASK)
87619 return addr;
87620
87621 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87622 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
87623 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
87624
87625 +#ifdef CONFIG_PAX_MPROTECT
87626 + if (mm->pax_flags & MF_PAX_MPROTECT) {
87627 +
87628 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
87629 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
87630 + mm->binfmt->handle_mmap)
87631 + mm->binfmt->handle_mmap(file);
87632 +#endif
87633 +
87634 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
87635 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
87636 + gr_log_rwxmmap(file);
87637 +
87638 +#ifdef CONFIG_PAX_EMUPLT
87639 + vm_flags &= ~VM_EXEC;
87640 +#else
87641 + return -EPERM;
87642 +#endif
87643 +
87644 + }
87645 +
87646 + if (!(vm_flags & VM_EXEC))
87647 + vm_flags &= ~VM_MAYEXEC;
87648 +#else
87649 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
87650 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
87651 +#endif
87652 + else
87653 + vm_flags &= ~VM_MAYWRITE;
87654 + }
87655 +#endif
87656 +
87657 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87658 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
87659 + vm_flags &= ~VM_PAGEEXEC;
87660 +#endif
87661 +
87662 if (flags & MAP_LOCKED)
87663 if (!can_do_mlock())
87664 return -EPERM;
87665 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87666 locked += mm->locked_vm;
87667 lock_limit = rlimit(RLIMIT_MEMLOCK);
87668 lock_limit >>= PAGE_SHIFT;
87669 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87670 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
87671 return -EAGAIN;
87672 }
87673 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87674 vm_flags |= VM_NORESERVE;
87675 }
87676
87677 + if (!gr_acl_handle_mmap(file, prot))
87678 + return -EACCES;
87679 +
87680 addr = mmap_region(file, addr, len, vm_flags, pgoff);
87681 if (!IS_ERR_VALUE(addr) &&
87682 ((vm_flags & VM_LOCKED) ||
87683 @@ -1434,7 +1558,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
87684 vm_flags_t vm_flags = vma->vm_flags;
87685
87686 /* If it was private or non-writable, the write bit is already clear */
87687 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
87688 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
87689 return 0;
87690
87691 /* The backer wishes to know when pages are first written to? */
87692 @@ -1482,7 +1606,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87693 unsigned long charged = 0;
87694 struct inode *inode = file ? file_inode(file) : NULL;
87695
87696 +#ifdef CONFIG_PAX_SEGMEXEC
87697 + struct vm_area_struct *vma_m = NULL;
87698 +#endif
87699 +
87700 + /*
87701 + * mm->mmap_sem is required to protect against another thread
87702 + * changing the mappings in case we sleep.
87703 + */
87704 + verify_mm_writelocked(mm);
87705 +
87706 /* Check against address space limit. */
87707 +
87708 +#ifdef CONFIG_PAX_RANDMMAP
87709 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87710 +#endif
87711 +
87712 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
87713 unsigned long nr_pages;
87714
87715 @@ -1501,11 +1640,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87716
87717 /* Clear old maps */
87718 error = -ENOMEM;
87719 -munmap_back:
87720 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
87721 if (do_munmap(mm, addr, len))
87722 return -ENOMEM;
87723 - goto munmap_back;
87724 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
87725 }
87726
87727 /*
87728 @@ -1536,6 +1674,16 @@ munmap_back:
87729 goto unacct_error;
87730 }
87731
87732 +#ifdef CONFIG_PAX_SEGMEXEC
87733 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
87734 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87735 + if (!vma_m) {
87736 + error = -ENOMEM;
87737 + goto free_vma;
87738 + }
87739 + }
87740 +#endif
87741 +
87742 vma->vm_mm = mm;
87743 vma->vm_start = addr;
87744 vma->vm_end = addr + len;
87745 @@ -1560,6 +1708,13 @@ munmap_back:
87746 if (error)
87747 goto unmap_and_free_vma;
87748
87749 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87750 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
87751 + vma->vm_flags |= VM_PAGEEXEC;
87752 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
87753 + }
87754 +#endif
87755 +
87756 /* Can addr have changed??
87757 *
87758 * Answer: Yes, several device drivers can do it in their
87759 @@ -1598,6 +1753,11 @@ munmap_back:
87760 vma_link(mm, vma, prev, rb_link, rb_parent);
87761 file = vma->vm_file;
87762
87763 +#ifdef CONFIG_PAX_SEGMEXEC
87764 + if (vma_m)
87765 + BUG_ON(pax_mirror_vma(vma_m, vma));
87766 +#endif
87767 +
87768 /* Once vma denies write, undo our temporary denial count */
87769 if (correct_wcount)
87770 atomic_inc(&inode->i_writecount);
87771 @@ -1605,6 +1765,7 @@ out:
87772 perf_event_mmap(vma);
87773
87774 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
87775 + track_exec_limit(mm, addr, addr + len, vm_flags);
87776 if (vm_flags & VM_LOCKED) {
87777 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
87778 vma == get_gate_vma(current->mm)))
87779 @@ -1628,6 +1789,12 @@ unmap_and_free_vma:
87780 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
87781 charged = 0;
87782 free_vma:
87783 +
87784 +#ifdef CONFIG_PAX_SEGMEXEC
87785 + if (vma_m)
87786 + kmem_cache_free(vm_area_cachep, vma_m);
87787 +#endif
87788 +
87789 kmem_cache_free(vm_area_cachep, vma);
87790 unacct_error:
87791 if (charged)
87792 @@ -1635,7 +1802,63 @@ unacct_error:
87793 return error;
87794 }
87795
87796 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87797 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
87798 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
87799 +{
87800 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
87801 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
87802 +
87803 + return 0;
87804 +}
87805 +#endif
87806 +
87807 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
87808 +{
87809 + if (!vma) {
87810 +#ifdef CONFIG_STACK_GROWSUP
87811 + if (addr > sysctl_heap_stack_gap)
87812 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
87813 + else
87814 + vma = find_vma(current->mm, 0);
87815 + if (vma && (vma->vm_flags & VM_GROWSUP))
87816 + return false;
87817 +#endif
87818 + return true;
87819 + }
87820 +
87821 + if (addr + len > vma->vm_start)
87822 + return false;
87823 +
87824 + if (vma->vm_flags & VM_GROWSDOWN)
87825 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
87826 +#ifdef CONFIG_STACK_GROWSUP
87827 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
87828 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
87829 +#endif
87830 + else if (offset)
87831 + return offset <= vma->vm_start - addr - len;
87832 +
87833 + return true;
87834 +}
87835 +
87836 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
87837 +{
87838 + if (vma->vm_start < len)
87839 + return -ENOMEM;
87840 +
87841 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
87842 + if (offset <= vma->vm_start - len)
87843 + return vma->vm_start - len - offset;
87844 + else
87845 + return -ENOMEM;
87846 + }
87847 +
87848 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
87849 + return vma->vm_start - len - sysctl_heap_stack_gap;
87850 + return -ENOMEM;
87851 +}
87852 +
87853 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
87854 {
87855 /*
87856 * We implement the search by looking for an rbtree node that
87857 @@ -1683,11 +1906,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87858 }
87859 }
87860
87861 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
87862 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
87863 check_current:
87864 /* Check if current node has a suitable gap */
87865 if (gap_start > high_limit)
87866 return -ENOMEM;
87867 +
87868 + if (gap_end - gap_start > info->threadstack_offset)
87869 + gap_start += info->threadstack_offset;
87870 + else
87871 + gap_start = gap_end;
87872 +
87873 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87874 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87875 + gap_start += sysctl_heap_stack_gap;
87876 + else
87877 + gap_start = gap_end;
87878 + }
87879 + if (vma->vm_flags & VM_GROWSDOWN) {
87880 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87881 + gap_end -= sysctl_heap_stack_gap;
87882 + else
87883 + gap_end = gap_start;
87884 + }
87885 if (gap_end >= low_limit && gap_end - gap_start >= length)
87886 goto found;
87887
87888 @@ -1737,7 +1978,7 @@ found:
87889 return gap_start;
87890 }
87891
87892 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
87893 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
87894 {
87895 struct mm_struct *mm = current->mm;
87896 struct vm_area_struct *vma;
87897 @@ -1791,6 +2032,24 @@ check_current:
87898 gap_end = vma->vm_start;
87899 if (gap_end < low_limit)
87900 return -ENOMEM;
87901 +
87902 + if (gap_end - gap_start > info->threadstack_offset)
87903 + gap_end -= info->threadstack_offset;
87904 + else
87905 + gap_end = gap_start;
87906 +
87907 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87908 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87909 + gap_start += sysctl_heap_stack_gap;
87910 + else
87911 + gap_start = gap_end;
87912 + }
87913 + if (vma->vm_flags & VM_GROWSDOWN) {
87914 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87915 + gap_end -= sysctl_heap_stack_gap;
87916 + else
87917 + gap_end = gap_start;
87918 + }
87919 if (gap_start <= high_limit && gap_end - gap_start >= length)
87920 goto found;
87921
87922 @@ -1854,6 +2113,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87923 struct mm_struct *mm = current->mm;
87924 struct vm_area_struct *vma;
87925 struct vm_unmapped_area_info info;
87926 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87927
87928 if (len > TASK_SIZE)
87929 return -ENOMEM;
87930 @@ -1861,19 +2121,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87931 if (flags & MAP_FIXED)
87932 return addr;
87933
87934 +#ifdef CONFIG_PAX_RANDMMAP
87935 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87936 +#endif
87937 +
87938 if (addr) {
87939 addr = PAGE_ALIGN(addr);
87940 vma = find_vma(mm, addr);
87941 - if (TASK_SIZE - len >= addr &&
87942 - (!vma || addr + len <= vma->vm_start))
87943 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87944 return addr;
87945 }
87946
87947 info.flags = 0;
87948 info.length = len;
87949 info.low_limit = TASK_UNMAPPED_BASE;
87950 +
87951 +#ifdef CONFIG_PAX_RANDMMAP
87952 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87953 + info.low_limit += mm->delta_mmap;
87954 +#endif
87955 +
87956 info.high_limit = TASK_SIZE;
87957 info.align_mask = 0;
87958 + info.threadstack_offset = offset;
87959 return vm_unmapped_area(&info);
87960 }
87961 #endif
87962 @@ -1892,6 +2162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87963 struct mm_struct *mm = current->mm;
87964 unsigned long addr = addr0;
87965 struct vm_unmapped_area_info info;
87966 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87967
87968 /* requested length too big for entire address space */
87969 if (len > TASK_SIZE)
87970 @@ -1900,12 +2171,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87971 if (flags & MAP_FIXED)
87972 return addr;
87973
87974 +#ifdef CONFIG_PAX_RANDMMAP
87975 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87976 +#endif
87977 +
87978 /* requesting a specific address */
87979 if (addr) {
87980 addr = PAGE_ALIGN(addr);
87981 vma = find_vma(mm, addr);
87982 - if (TASK_SIZE - len >= addr &&
87983 - (!vma || addr + len <= vma->vm_start))
87984 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87985 return addr;
87986 }
87987
87988 @@ -1914,6 +2188,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87989 info.low_limit = PAGE_SIZE;
87990 info.high_limit = mm->mmap_base;
87991 info.align_mask = 0;
87992 + info.threadstack_offset = offset;
87993 addr = vm_unmapped_area(&info);
87994
87995 /*
87996 @@ -1926,6 +2201,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87997 VM_BUG_ON(addr != -ENOMEM);
87998 info.flags = 0;
87999 info.low_limit = TASK_UNMAPPED_BASE;
88000 +
88001 +#ifdef CONFIG_PAX_RANDMMAP
88002 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88003 + info.low_limit += mm->delta_mmap;
88004 +#endif
88005 +
88006 info.high_limit = TASK_SIZE;
88007 addr = vm_unmapped_area(&info);
88008 }
88009 @@ -2027,6 +2308,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
88010 return vma;
88011 }
88012
88013 +#ifdef CONFIG_PAX_SEGMEXEC
88014 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
88015 +{
88016 + struct vm_area_struct *vma_m;
88017 +
88018 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
88019 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
88020 + BUG_ON(vma->vm_mirror);
88021 + return NULL;
88022 + }
88023 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
88024 + vma_m = vma->vm_mirror;
88025 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
88026 + BUG_ON(vma->vm_file != vma_m->vm_file);
88027 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
88028 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
88029 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
88030 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
88031 + return vma_m;
88032 +}
88033 +#endif
88034 +
88035 /*
88036 * Verify that the stack growth is acceptable and
88037 * update accounting. This is shared with both the
88038 @@ -2043,6 +2346,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88039 return -ENOMEM;
88040
88041 /* Stack limit test */
88042 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
88043 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
88044 return -ENOMEM;
88045
88046 @@ -2053,6 +2357,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88047 locked = mm->locked_vm + grow;
88048 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
88049 limit >>= PAGE_SHIFT;
88050 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88051 if (locked > limit && !capable(CAP_IPC_LOCK))
88052 return -ENOMEM;
88053 }
88054 @@ -2082,37 +2387,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88055 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
88056 * vma is the last one with address > vma->vm_end. Have to extend vma.
88057 */
88058 +#ifndef CONFIG_IA64
88059 +static
88060 +#endif
88061 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88062 {
88063 int error;
88064 + bool locknext;
88065
88066 if (!(vma->vm_flags & VM_GROWSUP))
88067 return -EFAULT;
88068
88069 + /* Also guard against wrapping around to address 0. */
88070 + if (address < PAGE_ALIGN(address+1))
88071 + address = PAGE_ALIGN(address+1);
88072 + else
88073 + return -ENOMEM;
88074 +
88075 /*
88076 * We must make sure the anon_vma is allocated
88077 * so that the anon_vma locking is not a noop.
88078 */
88079 if (unlikely(anon_vma_prepare(vma)))
88080 return -ENOMEM;
88081 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
88082 + if (locknext && anon_vma_prepare(vma->vm_next))
88083 + return -ENOMEM;
88084 vma_lock_anon_vma(vma);
88085 + if (locknext)
88086 + vma_lock_anon_vma(vma->vm_next);
88087
88088 /*
88089 * vma->vm_start/vm_end cannot change under us because the caller
88090 * is required to hold the mmap_sem in read mode. We need the
88091 - * anon_vma lock to serialize against concurrent expand_stacks.
88092 - * Also guard against wrapping around to address 0.
88093 + * anon_vma locks to serialize against concurrent expand_stacks
88094 + * and expand_upwards.
88095 */
88096 - if (address < PAGE_ALIGN(address+4))
88097 - address = PAGE_ALIGN(address+4);
88098 - else {
88099 - vma_unlock_anon_vma(vma);
88100 - return -ENOMEM;
88101 - }
88102 error = 0;
88103
88104 /* Somebody else might have raced and expanded it already */
88105 - if (address > vma->vm_end) {
88106 + 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)
88107 + error = -ENOMEM;
88108 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
88109 unsigned long size, grow;
88110
88111 size = address - vma->vm_start;
88112 @@ -2147,6 +2463,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88113 }
88114 }
88115 }
88116 + if (locknext)
88117 + vma_unlock_anon_vma(vma->vm_next);
88118 vma_unlock_anon_vma(vma);
88119 khugepaged_enter_vma_merge(vma);
88120 validate_mm(vma->vm_mm);
88121 @@ -2161,6 +2479,8 @@ int expand_downwards(struct vm_area_struct *vma,
88122 unsigned long address)
88123 {
88124 int error;
88125 + bool lockprev = false;
88126 + struct vm_area_struct *prev;
88127
88128 /*
88129 * We must make sure the anon_vma is allocated
88130 @@ -2174,6 +2494,15 @@ int expand_downwards(struct vm_area_struct *vma,
88131 if (error)
88132 return error;
88133
88134 + prev = vma->vm_prev;
88135 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
88136 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
88137 +#endif
88138 + if (lockprev && anon_vma_prepare(prev))
88139 + return -ENOMEM;
88140 + if (lockprev)
88141 + vma_lock_anon_vma(prev);
88142 +
88143 vma_lock_anon_vma(vma);
88144
88145 /*
88146 @@ -2183,9 +2512,17 @@ int expand_downwards(struct vm_area_struct *vma,
88147 */
88148
88149 /* Somebody else might have raced and expanded it already */
88150 - if (address < vma->vm_start) {
88151 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
88152 + error = -ENOMEM;
88153 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
88154 unsigned long size, grow;
88155
88156 +#ifdef CONFIG_PAX_SEGMEXEC
88157 + struct vm_area_struct *vma_m;
88158 +
88159 + vma_m = pax_find_mirror_vma(vma);
88160 +#endif
88161 +
88162 size = vma->vm_end - address;
88163 grow = (vma->vm_start - address) >> PAGE_SHIFT;
88164
88165 @@ -2210,13 +2547,27 @@ int expand_downwards(struct vm_area_struct *vma,
88166 vma->vm_pgoff -= grow;
88167 anon_vma_interval_tree_post_update_vma(vma);
88168 vma_gap_update(vma);
88169 +
88170 +#ifdef CONFIG_PAX_SEGMEXEC
88171 + if (vma_m) {
88172 + anon_vma_interval_tree_pre_update_vma(vma_m);
88173 + vma_m->vm_start -= grow << PAGE_SHIFT;
88174 + vma_m->vm_pgoff -= grow;
88175 + anon_vma_interval_tree_post_update_vma(vma_m);
88176 + vma_gap_update(vma_m);
88177 + }
88178 +#endif
88179 +
88180 spin_unlock(&vma->vm_mm->page_table_lock);
88181
88182 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
88183 perf_event_mmap(vma);
88184 }
88185 }
88186 }
88187 vma_unlock_anon_vma(vma);
88188 + if (lockprev)
88189 + vma_unlock_anon_vma(prev);
88190 khugepaged_enter_vma_merge(vma);
88191 validate_mm(vma->vm_mm);
88192 return error;
88193 @@ -2314,6 +2665,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
88194 do {
88195 long nrpages = vma_pages(vma);
88196
88197 +#ifdef CONFIG_PAX_SEGMEXEC
88198 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
88199 + vma = remove_vma(vma);
88200 + continue;
88201 + }
88202 +#endif
88203 +
88204 if (vma->vm_flags & VM_ACCOUNT)
88205 nr_accounted += nrpages;
88206 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
88207 @@ -2358,6 +2716,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
88208 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
88209 vma->vm_prev = NULL;
88210 do {
88211 +
88212 +#ifdef CONFIG_PAX_SEGMEXEC
88213 + if (vma->vm_mirror) {
88214 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
88215 + vma->vm_mirror->vm_mirror = NULL;
88216 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
88217 + vma->vm_mirror = NULL;
88218 + }
88219 +#endif
88220 +
88221 vma_rb_erase(vma, &mm->mm_rb);
88222 mm->map_count--;
88223 tail_vma = vma;
88224 @@ -2384,14 +2752,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88225 struct vm_area_struct *new;
88226 int err = -ENOMEM;
88227
88228 +#ifdef CONFIG_PAX_SEGMEXEC
88229 + struct vm_area_struct *vma_m, *new_m = NULL;
88230 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
88231 +#endif
88232 +
88233 if (is_vm_hugetlb_page(vma) && (addr &
88234 ~(huge_page_mask(hstate_vma(vma)))))
88235 return -EINVAL;
88236
88237 +#ifdef CONFIG_PAX_SEGMEXEC
88238 + vma_m = pax_find_mirror_vma(vma);
88239 +#endif
88240 +
88241 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88242 if (!new)
88243 goto out_err;
88244
88245 +#ifdef CONFIG_PAX_SEGMEXEC
88246 + if (vma_m) {
88247 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88248 + if (!new_m) {
88249 + kmem_cache_free(vm_area_cachep, new);
88250 + goto out_err;
88251 + }
88252 + }
88253 +#endif
88254 +
88255 /* most fields are the same, copy all, and then fixup */
88256 *new = *vma;
88257
88258 @@ -2404,6 +2791,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88259 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
88260 }
88261
88262 +#ifdef CONFIG_PAX_SEGMEXEC
88263 + if (vma_m) {
88264 + *new_m = *vma_m;
88265 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
88266 + new_m->vm_mirror = new;
88267 + new->vm_mirror = new_m;
88268 +
88269 + if (new_below)
88270 + new_m->vm_end = addr_m;
88271 + else {
88272 + new_m->vm_start = addr_m;
88273 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
88274 + }
88275 + }
88276 +#endif
88277 +
88278 pol = mpol_dup(vma_policy(vma));
88279 if (IS_ERR(pol)) {
88280 err = PTR_ERR(pol);
88281 @@ -2426,6 +2829,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88282 else
88283 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
88284
88285 +#ifdef CONFIG_PAX_SEGMEXEC
88286 + if (!err && vma_m) {
88287 + if (anon_vma_clone(new_m, vma_m))
88288 + goto out_free_mpol;
88289 +
88290 + mpol_get(pol);
88291 + vma_set_policy(new_m, pol);
88292 +
88293 + if (new_m->vm_file)
88294 + get_file(new_m->vm_file);
88295 +
88296 + if (new_m->vm_ops && new_m->vm_ops->open)
88297 + new_m->vm_ops->open(new_m);
88298 +
88299 + if (new_below)
88300 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
88301 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
88302 + else
88303 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
88304 +
88305 + if (err) {
88306 + if (new_m->vm_ops && new_m->vm_ops->close)
88307 + new_m->vm_ops->close(new_m);
88308 + if (new_m->vm_file)
88309 + fput(new_m->vm_file);
88310 + mpol_put(pol);
88311 + }
88312 + }
88313 +#endif
88314 +
88315 /* Success. */
88316 if (!err)
88317 return 0;
88318 @@ -2435,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88319 new->vm_ops->close(new);
88320 if (new->vm_file)
88321 fput(new->vm_file);
88322 - unlink_anon_vmas(new);
88323 out_free_mpol:
88324 mpol_put(pol);
88325 out_free_vma:
88326 +
88327 +#ifdef CONFIG_PAX_SEGMEXEC
88328 + if (new_m) {
88329 + unlink_anon_vmas(new_m);
88330 + kmem_cache_free(vm_area_cachep, new_m);
88331 + }
88332 +#endif
88333 +
88334 + unlink_anon_vmas(new);
88335 kmem_cache_free(vm_area_cachep, new);
88336 out_err:
88337 return err;
88338 @@ -2451,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88339 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88340 unsigned long addr, int new_below)
88341 {
88342 +
88343 +#ifdef CONFIG_PAX_SEGMEXEC
88344 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88345 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
88346 + if (mm->map_count >= sysctl_max_map_count-1)
88347 + return -ENOMEM;
88348 + } else
88349 +#endif
88350 +
88351 if (mm->map_count >= sysctl_max_map_count)
88352 return -ENOMEM;
88353
88354 @@ -2462,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88355 * work. This now handles partial unmappings.
88356 * Jeremy Fitzhardinge <jeremy@goop.org>
88357 */
88358 +#ifdef CONFIG_PAX_SEGMEXEC
88359 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88360 {
88361 + int ret = __do_munmap(mm, start, len);
88362 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
88363 + return ret;
88364 +
88365 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
88366 +}
88367 +
88368 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88369 +#else
88370 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88371 +#endif
88372 +{
88373 unsigned long end;
88374 struct vm_area_struct *vma, *prev, *last;
88375
88376 + /*
88377 + * mm->mmap_sem is required to protect against another thread
88378 + * changing the mappings in case we sleep.
88379 + */
88380 + verify_mm_writelocked(mm);
88381 +
88382 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
88383 return -EINVAL;
88384
88385 @@ -2541,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88386 /* Fix up all other VM information */
88387 remove_vma_list(mm, vma);
88388
88389 + track_exec_limit(mm, start, end, 0UL);
88390 +
88391 return 0;
88392 }
88393
88394 @@ -2549,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
88395 int ret;
88396 struct mm_struct *mm = current->mm;
88397
88398 +
88399 +#ifdef CONFIG_PAX_SEGMEXEC
88400 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
88401 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
88402 + return -EINVAL;
88403 +#endif
88404 +
88405 down_write(&mm->mmap_sem);
88406 ret = do_munmap(mm, start, len);
88407 up_write(&mm->mmap_sem);
88408 @@ -2562,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
88409 return vm_munmap(addr, len);
88410 }
88411
88412 -static inline void verify_mm_writelocked(struct mm_struct *mm)
88413 -{
88414 -#ifdef CONFIG_DEBUG_VM
88415 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88416 - WARN_ON(1);
88417 - up_read(&mm->mmap_sem);
88418 - }
88419 -#endif
88420 -}
88421 -
88422 /*
88423 * this is really a simplified "do_mmap". it only handles
88424 * anonymous maps. eventually we may be able to do some
88425 @@ -2585,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88426 struct rb_node ** rb_link, * rb_parent;
88427 pgoff_t pgoff = addr >> PAGE_SHIFT;
88428 int error;
88429 + unsigned long charged;
88430
88431 len = PAGE_ALIGN(len);
88432 if (!len)
88433 @@ -2592,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88434
88435 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
88436
88437 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
88438 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
88439 + flags &= ~VM_EXEC;
88440 +
88441 +#ifdef CONFIG_PAX_MPROTECT
88442 + if (mm->pax_flags & MF_PAX_MPROTECT)
88443 + flags &= ~VM_MAYEXEC;
88444 +#endif
88445 +
88446 + }
88447 +#endif
88448 +
88449 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
88450 if (error & ~PAGE_MASK)
88451 return error;
88452
88453 + charged = len >> PAGE_SHIFT;
88454 +
88455 /*
88456 * mlock MCL_FUTURE?
88457 */
88458 if (mm->def_flags & VM_LOCKED) {
88459 unsigned long locked, lock_limit;
88460 - locked = len >> PAGE_SHIFT;
88461 + locked = charged;
88462 locked += mm->locked_vm;
88463 lock_limit = rlimit(RLIMIT_MEMLOCK);
88464 lock_limit >>= PAGE_SHIFT;
88465 @@ -2618,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88466 /*
88467 * Clear old maps. this also does some error checking for us
88468 */
88469 - munmap_back:
88470 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88471 if (do_munmap(mm, addr, len))
88472 return -ENOMEM;
88473 - goto munmap_back;
88474 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88475 }
88476
88477 /* Check against address space limits *after* clearing old maps... */
88478 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
88479 + if (!may_expand_vm(mm, charged))
88480 return -ENOMEM;
88481
88482 if (mm->map_count > sysctl_max_map_count)
88483 return -ENOMEM;
88484
88485 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
88486 + if (security_vm_enough_memory_mm(mm, charged))
88487 return -ENOMEM;
88488
88489 /* Can we just expand an old private anonymous mapping? */
88490 @@ -2646,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88491 */
88492 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88493 if (!vma) {
88494 - vm_unacct_memory(len >> PAGE_SHIFT);
88495 + vm_unacct_memory(charged);
88496 return -ENOMEM;
88497 }
88498
88499 @@ -2660,9 +3142,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88500 vma_link(mm, vma, prev, rb_link, rb_parent);
88501 out:
88502 perf_event_mmap(vma);
88503 - mm->total_vm += len >> PAGE_SHIFT;
88504 + mm->total_vm += charged;
88505 if (flags & VM_LOCKED)
88506 - mm->locked_vm += (len >> PAGE_SHIFT);
88507 + mm->locked_vm += charged;
88508 + track_exec_limit(mm, addr, addr + len, flags);
88509 return addr;
88510 }
88511
88512 @@ -2724,6 +3207,7 @@ void exit_mmap(struct mm_struct *mm)
88513 while (vma) {
88514 if (vma->vm_flags & VM_ACCOUNT)
88515 nr_accounted += vma_pages(vma);
88516 + vma->vm_mirror = NULL;
88517 vma = remove_vma(vma);
88518 }
88519 vm_unacct_memory(nr_accounted);
88520 @@ -2740,6 +3224,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88521 struct vm_area_struct *prev;
88522 struct rb_node **rb_link, *rb_parent;
88523
88524 +#ifdef CONFIG_PAX_SEGMEXEC
88525 + struct vm_area_struct *vma_m = NULL;
88526 +#endif
88527 +
88528 + if (security_mmap_addr(vma->vm_start))
88529 + return -EPERM;
88530 +
88531 /*
88532 * The vm_pgoff of a purely anonymous vma should be irrelevant
88533 * until its first write fault, when page's anon_vma and index
88534 @@ -2763,7 +3254,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88535 security_vm_enough_memory_mm(mm, vma_pages(vma)))
88536 return -ENOMEM;
88537
88538 +#ifdef CONFIG_PAX_SEGMEXEC
88539 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
88540 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88541 + if (!vma_m)
88542 + return -ENOMEM;
88543 + }
88544 +#endif
88545 +
88546 vma_link(mm, vma, prev, rb_link, rb_parent);
88547 +
88548 +#ifdef CONFIG_PAX_SEGMEXEC
88549 + if (vma_m)
88550 + BUG_ON(pax_mirror_vma(vma_m, vma));
88551 +#endif
88552 +
88553 return 0;
88554 }
88555
88556 @@ -2783,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88557 struct mempolicy *pol;
88558 bool faulted_in_anon_vma = true;
88559
88560 + BUG_ON(vma->vm_mirror);
88561 +
88562 /*
88563 * If anonymous vma has not yet been faulted, update new pgoff
88564 * to match new location, to increase its chance of merging.
88565 @@ -2849,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88566 return NULL;
88567 }
88568
88569 +#ifdef CONFIG_PAX_SEGMEXEC
88570 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
88571 +{
88572 + struct vm_area_struct *prev_m;
88573 + struct rb_node **rb_link_m, *rb_parent_m;
88574 + struct mempolicy *pol_m;
88575 +
88576 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
88577 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
88578 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
88579 + *vma_m = *vma;
88580 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
88581 + if (anon_vma_clone(vma_m, vma))
88582 + return -ENOMEM;
88583 + pol_m = vma_policy(vma_m);
88584 + mpol_get(pol_m);
88585 + vma_set_policy(vma_m, pol_m);
88586 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
88587 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
88588 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
88589 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
88590 + if (vma_m->vm_file)
88591 + get_file(vma_m->vm_file);
88592 + if (vma_m->vm_ops && vma_m->vm_ops->open)
88593 + vma_m->vm_ops->open(vma_m);
88594 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
88595 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
88596 + vma_m->vm_mirror = vma;
88597 + vma->vm_mirror = vma_m;
88598 + return 0;
88599 +}
88600 +#endif
88601 +
88602 /*
88603 * Return true if the calling process may expand its vm space by the passed
88604 * number of pages
88605 @@ -2860,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
88606
88607 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
88608
88609 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
88610 if (cur + npages > lim)
88611 return 0;
88612 return 1;
88613 @@ -2930,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
88614 vma->vm_start = addr;
88615 vma->vm_end = addr + len;
88616
88617 +#ifdef CONFIG_PAX_MPROTECT
88618 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88619 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88620 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
88621 + return -EPERM;
88622 + if (!(vm_flags & VM_EXEC))
88623 + vm_flags &= ~VM_MAYEXEC;
88624 +#else
88625 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88626 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88627 +#endif
88628 + else
88629 + vm_flags &= ~VM_MAYWRITE;
88630 + }
88631 +#endif
88632 +
88633 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
88634 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88635
88636 diff --git a/mm/mprotect.c b/mm/mprotect.c
88637 index 412ba2b..cb41d42 100644
88638 --- a/mm/mprotect.c
88639 +++ b/mm/mprotect.c
88640 @@ -23,10 +23,18 @@
88641 #include <linux/mmu_notifier.h>
88642 #include <linux/migrate.h>
88643 #include <linux/perf_event.h>
88644 +#include <linux/sched/sysctl.h>
88645 +
88646 +#ifdef CONFIG_PAX_MPROTECT
88647 +#include <linux/elf.h>
88648 +#include <linux/binfmts.h>
88649 +#endif
88650 +
88651 #include <asm/uaccess.h>
88652 #include <asm/pgtable.h>
88653 #include <asm/cacheflush.h>
88654 #include <asm/tlbflush.h>
88655 +#include <asm/mmu_context.h>
88656
88657 #ifndef pgprot_modify
88658 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
88659 @@ -236,6 +244,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
88660 return pages;
88661 }
88662
88663 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88664 +/* called while holding the mmap semaphor for writing except stack expansion */
88665 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
88666 +{
88667 + unsigned long oldlimit, newlimit = 0UL;
88668 +
88669 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
88670 + return;
88671 +
88672 + spin_lock(&mm->page_table_lock);
88673 + oldlimit = mm->context.user_cs_limit;
88674 + if ((prot & VM_EXEC) && oldlimit < end)
88675 + /* USER_CS limit moved up */
88676 + newlimit = end;
88677 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
88678 + /* USER_CS limit moved down */
88679 + newlimit = start;
88680 +
88681 + if (newlimit) {
88682 + mm->context.user_cs_limit = newlimit;
88683 +
88684 +#ifdef CONFIG_SMP
88685 + wmb();
88686 + cpus_clear(mm->context.cpu_user_cs_mask);
88687 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
88688 +#endif
88689 +
88690 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
88691 + }
88692 + spin_unlock(&mm->page_table_lock);
88693 + if (newlimit == end) {
88694 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
88695 +
88696 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
88697 + if (is_vm_hugetlb_page(vma))
88698 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
88699 + else
88700 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
88701 + }
88702 +}
88703 +#endif
88704 +
88705 int
88706 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88707 unsigned long start, unsigned long end, unsigned long newflags)
88708 @@ -248,11 +298,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88709 int error;
88710 int dirty_accountable = 0;
88711
88712 +#ifdef CONFIG_PAX_SEGMEXEC
88713 + struct vm_area_struct *vma_m = NULL;
88714 + unsigned long start_m, end_m;
88715 +
88716 + start_m = start + SEGMEXEC_TASK_SIZE;
88717 + end_m = end + SEGMEXEC_TASK_SIZE;
88718 +#endif
88719 +
88720 if (newflags == oldflags) {
88721 *pprev = vma;
88722 return 0;
88723 }
88724
88725 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
88726 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
88727 +
88728 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
88729 + return -ENOMEM;
88730 +
88731 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
88732 + return -ENOMEM;
88733 + }
88734 +
88735 /*
88736 * If we make a private mapping writable we increase our commit;
88737 * but (without finer accounting) cannot reduce our commit if we
88738 @@ -269,6 +337,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88739 }
88740 }
88741
88742 +#ifdef CONFIG_PAX_SEGMEXEC
88743 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
88744 + if (start != vma->vm_start) {
88745 + error = split_vma(mm, vma, start, 1);
88746 + if (error)
88747 + goto fail;
88748 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
88749 + *pprev = (*pprev)->vm_next;
88750 + }
88751 +
88752 + if (end != vma->vm_end) {
88753 + error = split_vma(mm, vma, end, 0);
88754 + if (error)
88755 + goto fail;
88756 + }
88757 +
88758 + if (pax_find_mirror_vma(vma)) {
88759 + error = __do_munmap(mm, start_m, end_m - start_m);
88760 + if (error)
88761 + goto fail;
88762 + } else {
88763 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88764 + if (!vma_m) {
88765 + error = -ENOMEM;
88766 + goto fail;
88767 + }
88768 + vma->vm_flags = newflags;
88769 + error = pax_mirror_vma(vma_m, vma);
88770 + if (error) {
88771 + vma->vm_flags = oldflags;
88772 + goto fail;
88773 + }
88774 + }
88775 + }
88776 +#endif
88777 +
88778 /*
88779 * First try to merge with previous and/or next vma.
88780 */
88781 @@ -299,9 +403,21 @@ success:
88782 * vm_flags and vm_page_prot are protected by the mmap_sem
88783 * held in write mode.
88784 */
88785 +
88786 +#ifdef CONFIG_PAX_SEGMEXEC
88787 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
88788 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
88789 +#endif
88790 +
88791 vma->vm_flags = newflags;
88792 +
88793 +#ifdef CONFIG_PAX_MPROTECT
88794 + if (mm->binfmt && mm->binfmt->handle_mprotect)
88795 + mm->binfmt->handle_mprotect(vma, newflags);
88796 +#endif
88797 +
88798 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
88799 - vm_get_page_prot(newflags));
88800 + vm_get_page_prot(vma->vm_flags));
88801
88802 if (vma_wants_writenotify(vma)) {
88803 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
88804 @@ -340,6 +456,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88805 end = start + len;
88806 if (end <= start)
88807 return -ENOMEM;
88808 +
88809 +#ifdef CONFIG_PAX_SEGMEXEC
88810 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88811 + if (end > SEGMEXEC_TASK_SIZE)
88812 + return -EINVAL;
88813 + } else
88814 +#endif
88815 +
88816 + if (end > TASK_SIZE)
88817 + return -EINVAL;
88818 +
88819 if (!arch_validate_prot(prot))
88820 return -EINVAL;
88821
88822 @@ -347,7 +474,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88823 /*
88824 * Does the application expect PROT_READ to imply PROT_EXEC:
88825 */
88826 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88827 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88828 prot |= PROT_EXEC;
88829
88830 vm_flags = calc_vm_prot_bits(prot);
88831 @@ -379,6 +506,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88832 if (start > vma->vm_start)
88833 prev = vma;
88834
88835 +#ifdef CONFIG_PAX_MPROTECT
88836 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
88837 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
88838 +#endif
88839 +
88840 for (nstart = start ; ; ) {
88841 unsigned long newflags;
88842
88843 @@ -389,6 +521,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88844
88845 /* newflags >> 4 shift VM_MAY% in place of VM_% */
88846 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
88847 + if (prot & (PROT_WRITE | PROT_EXEC))
88848 + gr_log_rwxmprotect(vma);
88849 +
88850 + error = -EACCES;
88851 + goto out;
88852 + }
88853 +
88854 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
88855 error = -EACCES;
88856 goto out;
88857 }
88858 @@ -403,6 +543,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88859 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
88860 if (error)
88861 goto out;
88862 +
88863 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
88864 +
88865 nstart = tmp;
88866
88867 if (nstart < prev->vm_end)
88868 diff --git a/mm/mremap.c b/mm/mremap.c
88869 index 0843feb..4f5b2e6 100644
88870 --- a/mm/mremap.c
88871 +++ b/mm/mremap.c
88872 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
88873 continue;
88874 pte = ptep_get_and_clear(mm, old_addr, old_pte);
88875 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
88876 +
88877 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88878 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
88879 + pte = pte_exprotect(pte);
88880 +#endif
88881 +
88882 pte = move_soft_dirty_pte(pte);
88883 set_pte_at(mm, new_addr, new_pte, pte);
88884 }
88885 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
88886 if (is_vm_hugetlb_page(vma))
88887 goto Einval;
88888
88889 +#ifdef CONFIG_PAX_SEGMEXEC
88890 + if (pax_find_mirror_vma(vma))
88891 + goto Einval;
88892 +#endif
88893 +
88894 /* We can't remap across vm area boundaries */
88895 if (old_len > vma->vm_end - addr)
88896 goto Efault;
88897 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
88898 unsigned long ret = -EINVAL;
88899 unsigned long charged = 0;
88900 unsigned long map_flags;
88901 + unsigned long pax_task_size = TASK_SIZE;
88902
88903 if (new_addr & ~PAGE_MASK)
88904 goto out;
88905
88906 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
88907 +#ifdef CONFIG_PAX_SEGMEXEC
88908 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88909 + pax_task_size = SEGMEXEC_TASK_SIZE;
88910 +#endif
88911 +
88912 + pax_task_size -= PAGE_SIZE;
88913 +
88914 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
88915 goto out;
88916
88917 /* Check if the location we're moving into overlaps the
88918 * old location at all, and fail if it does.
88919 */
88920 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
88921 - goto out;
88922 -
88923 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
88924 + if (addr + old_len > new_addr && new_addr + new_len > addr)
88925 goto out;
88926
88927 ret = do_munmap(mm, new_addr, new_len);
88928 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88929 unsigned long ret = -EINVAL;
88930 unsigned long charged = 0;
88931 bool locked = false;
88932 + unsigned long pax_task_size = TASK_SIZE;
88933
88934 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
88935 return ret;
88936 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88937 if (!new_len)
88938 return ret;
88939
88940 +#ifdef CONFIG_PAX_SEGMEXEC
88941 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88942 + pax_task_size = SEGMEXEC_TASK_SIZE;
88943 +#endif
88944 +
88945 + pax_task_size -= PAGE_SIZE;
88946 +
88947 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
88948 + old_len > pax_task_size || addr > pax_task_size-old_len)
88949 + return ret;
88950 +
88951 down_write(&current->mm->mmap_sem);
88952
88953 if (flags & MREMAP_FIXED) {
88954 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88955 new_addr = addr;
88956 }
88957 ret = addr;
88958 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
88959 goto out;
88960 }
88961 }
88962 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88963 goto out;
88964 }
88965
88966 + map_flags = vma->vm_flags;
88967 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
88968 + if (!(ret & ~PAGE_MASK)) {
88969 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
88970 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
88971 + }
88972 }
88973 out:
88974 if (ret & ~PAGE_MASK)
88975 diff --git a/mm/nommu.c b/mm/nommu.c
88976 index ecd1f15..77039bd 100644
88977 --- a/mm/nommu.c
88978 +++ b/mm/nommu.c
88979 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
88980 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
88981 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88982 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88983 -int heap_stack_gap = 0;
88984
88985 atomic_long_t mmap_pages_allocated;
88986
88987 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
88988 EXPORT_SYMBOL(find_vma);
88989
88990 /*
88991 - * find a VMA
88992 - * - we don't extend stack VMAs under NOMMU conditions
88993 - */
88994 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
88995 -{
88996 - return find_vma(mm, addr);
88997 -}
88998 -
88999 -/*
89000 * expand a stack to a given address
89001 * - not supported under NOMMU conditions
89002 */
89003 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89004
89005 /* most fields are the same, copy all, and then fixup */
89006 *new = *vma;
89007 + INIT_LIST_HEAD(&new->anon_vma_chain);
89008 *region = *vma->vm_region;
89009 new->vm_region = region;
89010
89011 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
89012 }
89013 EXPORT_SYMBOL(generic_file_remap_pages);
89014
89015 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89016 - unsigned long addr, void *buf, int len, int write)
89017 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89018 + unsigned long addr, void *buf, size_t len, int write)
89019 {
89020 struct vm_area_struct *vma;
89021
89022 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89023 *
89024 * The caller must hold a reference on @mm.
89025 */
89026 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89027 - void *buf, int len, int write)
89028 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
89029 + void *buf, size_t len, int write)
89030 {
89031 return __access_remote_vm(NULL, mm, addr, buf, len, write);
89032 }
89033 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89034 * Access another process' address space.
89035 * - source/target buffer must be kernel space
89036 */
89037 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
89038 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
89039 {
89040 struct mm_struct *mm;
89041
89042 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
89043 index 241a746..41cd05d 100644
89044 --- a/mm/page-writeback.c
89045 +++ b/mm/page-writeback.c
89046 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
89047 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
89048 * - the bdi dirty thresh drops quickly due to change of JBOD workload
89049 */
89050 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
89051 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
89052 unsigned long thresh,
89053 unsigned long bg_thresh,
89054 unsigned long dirty,
89055 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
89056 index b100255..54b13c5 100644
89057 --- a/mm/page_alloc.c
89058 +++ b/mm/page_alloc.c
89059 @@ -60,6 +60,7 @@
89060 #include <linux/page-debug-flags.h>
89061 #include <linux/hugetlb.h>
89062 #include <linux/sched/rt.h>
89063 +#include <linux/random.h>
89064
89065 #include <asm/sections.h>
89066 #include <asm/tlbflush.h>
89067 @@ -353,7 +354,7 @@ out:
89068 * This usage means that zero-order pages may not be compound.
89069 */
89070
89071 -static void free_compound_page(struct page *page)
89072 +void free_compound_page(struct page *page)
89073 {
89074 __free_pages_ok(page, compound_order(page));
89075 }
89076 @@ -710,6 +711,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89077 int i;
89078 int bad = 0;
89079
89080 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89081 + unsigned long index = 1UL << order;
89082 +#endif
89083 +
89084 trace_mm_page_free(page, order);
89085 kmemcheck_free_shadow(page, order);
89086
89087 @@ -725,6 +730,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89088 debug_check_no_obj_freed(page_address(page),
89089 PAGE_SIZE << order);
89090 }
89091 +
89092 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89093 + for (; index; --index)
89094 + sanitize_highpage(page + index - 1);
89095 +#endif
89096 +
89097 arch_free_page(page, order);
89098 kernel_map_pages(page, 1 << order, 0);
89099
89100 @@ -747,6 +758,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
89101 local_irq_restore(flags);
89102 }
89103
89104 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89105 +bool __meminitdata extra_latent_entropy;
89106 +
89107 +static int __init setup_pax_extra_latent_entropy(char *str)
89108 +{
89109 + extra_latent_entropy = true;
89110 + return 0;
89111 +}
89112 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
89113 +
89114 +volatile u64 latent_entropy __latent_entropy;
89115 +EXPORT_SYMBOL(latent_entropy);
89116 +#endif
89117 +
89118 void __init __free_pages_bootmem(struct page *page, unsigned int order)
89119 {
89120 unsigned int nr_pages = 1 << order;
89121 @@ -762,6 +787,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
89122 set_page_count(p, 0);
89123 }
89124
89125 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89126 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
89127 + u64 hash = 0;
89128 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
89129 + const u64 *data = lowmem_page_address(page);
89130 +
89131 + for (index = 0; index < end; index++)
89132 + hash ^= hash + data[index];
89133 + latent_entropy ^= hash;
89134 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
89135 + }
89136 +#endif
89137 +
89138 page_zone(page)->managed_pages += 1 << order;
89139 set_page_refcounted(page);
89140 __free_pages(page, order);
89141 @@ -867,8 +905,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
89142 arch_alloc_page(page, order);
89143 kernel_map_pages(page, 1 << order, 1);
89144
89145 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
89146 if (gfp_flags & __GFP_ZERO)
89147 prep_zero_page(page, order, gfp_flags);
89148 +#endif
89149
89150 if (order && (gfp_flags & __GFP_COMP))
89151 prep_compound_page(page, order);
89152 diff --git a/mm/page_io.c b/mm/page_io.c
89153 index ba05b64..ef2f314 100644
89154 --- a/mm/page_io.c
89155 +++ b/mm/page_io.c
89156 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
89157 struct file *swap_file = sis->swap_file;
89158 struct address_space *mapping = swap_file->f_mapping;
89159 struct iovec iov = {
89160 - .iov_base = kmap(page),
89161 + .iov_base = (void __force_user *)kmap(page),
89162 .iov_len = PAGE_SIZE,
89163 };
89164
89165 diff --git a/mm/percpu.c b/mm/percpu.c
89166 index 8c8e08f..73a5cda 100644
89167 --- a/mm/percpu.c
89168 +++ b/mm/percpu.c
89169 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
89170 static unsigned int pcpu_high_unit_cpu __read_mostly;
89171
89172 /* the address of the first chunk which starts with the kernel static area */
89173 -void *pcpu_base_addr __read_mostly;
89174 +void *pcpu_base_addr __read_only;
89175 EXPORT_SYMBOL_GPL(pcpu_base_addr);
89176
89177 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
89178 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
89179 index fd26d04..0cea1b0 100644
89180 --- a/mm/process_vm_access.c
89181 +++ b/mm/process_vm_access.c
89182 @@ -13,6 +13,7 @@
89183 #include <linux/uio.h>
89184 #include <linux/sched.h>
89185 #include <linux/highmem.h>
89186 +#include <linux/security.h>
89187 #include <linux/ptrace.h>
89188 #include <linux/slab.h>
89189 #include <linux/syscalls.h>
89190 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89191 size_t iov_l_curr_offset = 0;
89192 ssize_t iov_len;
89193
89194 + return -ENOSYS; // PaX: until properly audited
89195 +
89196 /*
89197 * Work out how many pages of struct pages we're going to need
89198 * when eventually calling get_user_pages
89199 */
89200 for (i = 0; i < riovcnt; i++) {
89201 iov_len = rvec[i].iov_len;
89202 - if (iov_len > 0) {
89203 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
89204 - + iov_len)
89205 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
89206 - / PAGE_SIZE + 1;
89207 - nr_pages = max(nr_pages, nr_pages_iov);
89208 - }
89209 + if (iov_len <= 0)
89210 + continue;
89211 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
89212 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
89213 + nr_pages = max(nr_pages, nr_pages_iov);
89214 }
89215
89216 if (nr_pages == 0)
89217 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89218 goto free_proc_pages;
89219 }
89220
89221 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
89222 + rc = -EPERM;
89223 + goto put_task_struct;
89224 + }
89225 +
89226 mm = mm_access(task, PTRACE_MODE_ATTACH);
89227 if (!mm || IS_ERR(mm)) {
89228 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
89229 diff --git a/mm/rmap.c b/mm/rmap.c
89230 index b2e29ac..4168491 100644
89231 --- a/mm/rmap.c
89232 +++ b/mm/rmap.c
89233 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89234 struct anon_vma *anon_vma = vma->anon_vma;
89235 struct anon_vma_chain *avc;
89236
89237 +#ifdef CONFIG_PAX_SEGMEXEC
89238 + struct anon_vma_chain *avc_m = NULL;
89239 +#endif
89240 +
89241 might_sleep();
89242 if (unlikely(!anon_vma)) {
89243 struct mm_struct *mm = vma->vm_mm;
89244 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89245 if (!avc)
89246 goto out_enomem;
89247
89248 +#ifdef CONFIG_PAX_SEGMEXEC
89249 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
89250 + if (!avc_m)
89251 + goto out_enomem_free_avc;
89252 +#endif
89253 +
89254 anon_vma = find_mergeable_anon_vma(vma);
89255 allocated = NULL;
89256 if (!anon_vma) {
89257 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89258 /* page_table_lock to protect against threads */
89259 spin_lock(&mm->page_table_lock);
89260 if (likely(!vma->anon_vma)) {
89261 +
89262 +#ifdef CONFIG_PAX_SEGMEXEC
89263 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
89264 +
89265 + if (vma_m) {
89266 + BUG_ON(vma_m->anon_vma);
89267 + vma_m->anon_vma = anon_vma;
89268 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
89269 + avc_m = NULL;
89270 + }
89271 +#endif
89272 +
89273 vma->anon_vma = anon_vma;
89274 anon_vma_chain_link(vma, avc, anon_vma);
89275 allocated = NULL;
89276 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89277
89278 if (unlikely(allocated))
89279 put_anon_vma(allocated);
89280 +
89281 +#ifdef CONFIG_PAX_SEGMEXEC
89282 + if (unlikely(avc_m))
89283 + anon_vma_chain_free(avc_m);
89284 +#endif
89285 +
89286 if (unlikely(avc))
89287 anon_vma_chain_free(avc);
89288 }
89289 return 0;
89290
89291 out_enomem_free_avc:
89292 +
89293 +#ifdef CONFIG_PAX_SEGMEXEC
89294 + if (avc_m)
89295 + anon_vma_chain_free(avc_m);
89296 +#endif
89297 +
89298 anon_vma_chain_free(avc);
89299 out_enomem:
89300 return -ENOMEM;
89301 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
89302 * Attach the anon_vmas from src to dst.
89303 * Returns 0 on success, -ENOMEM on failure.
89304 */
89305 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89306 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
89307 {
89308 struct anon_vma_chain *avc, *pavc;
89309 struct anon_vma *root = NULL;
89310 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89311 * the corresponding VMA in the parent process is attached to.
89312 * Returns 0 on success, non-zero on failure.
89313 */
89314 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
89315 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
89316 {
89317 struct anon_vma_chain *avc;
89318 struct anon_vma *anon_vma;
89319 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
89320 void __init anon_vma_init(void)
89321 {
89322 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
89323 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
89324 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
89325 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
89326 + anon_vma_ctor);
89327 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
89328 + SLAB_PANIC|SLAB_NO_SANITIZE);
89329 }
89330
89331 /*
89332 diff --git a/mm/shmem.c b/mm/shmem.c
89333 index e43dc55..930e3a2 100644
89334 --- a/mm/shmem.c
89335 +++ b/mm/shmem.c
89336 @@ -33,7 +33,7 @@
89337 #include <linux/swap.h>
89338 #include <linux/aio.h>
89339
89340 -static struct vfsmount *shm_mnt;
89341 +struct vfsmount *shm_mnt;
89342
89343 #ifdef CONFIG_SHMEM
89344 /*
89345 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
89346 #define BOGO_DIRENT_SIZE 20
89347
89348 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
89349 -#define SHORT_SYMLINK_LEN 128
89350 +#define SHORT_SYMLINK_LEN 64
89351
89352 /*
89353 * shmem_fallocate and shmem_writepage communicate via inode->i_private
89354 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
89355 static int shmem_xattr_validate(const char *name)
89356 {
89357 struct { const char *prefix; size_t len; } arr[] = {
89358 +
89359 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89360 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
89361 +#endif
89362 +
89363 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
89364 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
89365 };
89366 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
89367 if (err)
89368 return err;
89369
89370 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89371 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
89372 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
89373 + return -EOPNOTSUPP;
89374 + if (size > 8)
89375 + return -EINVAL;
89376 + }
89377 +#endif
89378 +
89379 return simple_xattr_set(&info->xattrs, name, value, size, flags);
89380 }
89381
89382 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
89383 int err = -ENOMEM;
89384
89385 /* Round up to L1_CACHE_BYTES to resist false sharing */
89386 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
89387 - L1_CACHE_BYTES), GFP_KERNEL);
89388 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
89389 if (!sbinfo)
89390 return -ENOMEM;
89391
89392 diff --git a/mm/slab.c b/mm/slab.c
89393 index 2580db0..0523956 100644
89394 --- a/mm/slab.c
89395 +++ b/mm/slab.c
89396 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89397 if ((x)->max_freeable < i) \
89398 (x)->max_freeable = i; \
89399 } while (0)
89400 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
89401 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
89402 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
89403 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
89404 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
89405 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
89406 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
89407 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
89408 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
89409 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
89410 #else
89411 #define STATS_INC_ACTIVE(x) do { } while (0)
89412 #define STATS_DEC_ACTIVE(x) do { } while (0)
89413 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89414 #define STATS_INC_ALLOCMISS(x) do { } while (0)
89415 #define STATS_INC_FREEHIT(x) do { } while (0)
89416 #define STATS_INC_FREEMISS(x) do { } while (0)
89417 +#define STATS_INC_SANITIZED(x) do { } while (0)
89418 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
89419 #endif
89420
89421 #if DEBUG
89422 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
89423 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
89424 */
89425 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
89426 - const struct slab *slab, void *obj)
89427 + const struct slab *slab, const void *obj)
89428 {
89429 u32 offset = (obj - slab->s_mem);
89430 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
89431 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
89432 */
89433
89434 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
89435 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
89436 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89437
89438 if (INDEX_AC != INDEX_NODE)
89439 kmalloc_caches[INDEX_NODE] =
89440 create_kmalloc_cache("kmalloc-node",
89441 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
89442 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89443
89444 slab_early_init = 0;
89445
89446 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
89447 struct array_cache *ac = cpu_cache_get(cachep);
89448
89449 check_irq_off();
89450 +
89451 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89452 + if (pax_sanitize_slab) {
89453 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
89454 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
89455 +
89456 + if (cachep->ctor)
89457 + cachep->ctor(objp);
89458 +
89459 + STATS_INC_SANITIZED(cachep);
89460 + } else
89461 + STATS_INC_NOT_SANITIZED(cachep);
89462 + }
89463 +#endif
89464 +
89465 kmemleak_free_recursive(objp, cachep->flags);
89466 objp = cache_free_debugcheck(cachep, objp, caller);
89467
89468 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
89469
89470 if (unlikely(ZERO_OR_NULL_PTR(objp)))
89471 return;
89472 + VM_BUG_ON(!virt_addr_valid(objp));
89473 local_irq_save(flags);
89474 kfree_debugcheck(objp);
89475 c = virt_to_cache(objp);
89476 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
89477 }
89478 /* cpu stats */
89479 {
89480 - unsigned long allochit = atomic_read(&cachep->allochit);
89481 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
89482 - unsigned long freehit = atomic_read(&cachep->freehit);
89483 - unsigned long freemiss = atomic_read(&cachep->freemiss);
89484 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
89485 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
89486 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
89487 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
89488
89489 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
89490 allochit, allocmiss, freehit, freemiss);
89491 }
89492 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89493 + {
89494 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
89495 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
89496 +
89497 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
89498 + }
89499 +#endif
89500 #endif
89501 }
89502
89503 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
89504 static int __init slab_proc_init(void)
89505 {
89506 #ifdef CONFIG_DEBUG_SLAB_LEAK
89507 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
89508 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
89509 #endif
89510 return 0;
89511 }
89512 module_init(slab_proc_init);
89513 #endif
89514
89515 +bool is_usercopy_object(const void *ptr)
89516 +{
89517 + struct page *page;
89518 + struct kmem_cache *cachep;
89519 +
89520 + if (ZERO_OR_NULL_PTR(ptr))
89521 + return false;
89522 +
89523 + if (!slab_is_available())
89524 + return false;
89525 +
89526 + if (!virt_addr_valid(ptr))
89527 + return false;
89528 +
89529 + page = virt_to_head_page(ptr);
89530 +
89531 + if (!PageSlab(page))
89532 + return false;
89533 +
89534 + cachep = page->slab_cache;
89535 + return cachep->flags & SLAB_USERCOPY;
89536 +}
89537 +
89538 +#ifdef CONFIG_PAX_USERCOPY
89539 +const char *check_heap_object(const void *ptr, unsigned long n)
89540 +{
89541 + struct page *page;
89542 + struct kmem_cache *cachep;
89543 + struct slab *slabp;
89544 + unsigned int objnr;
89545 + unsigned long offset;
89546 +
89547 + if (ZERO_OR_NULL_PTR(ptr))
89548 + return "<null>";
89549 +
89550 + if (!virt_addr_valid(ptr))
89551 + return NULL;
89552 +
89553 + page = virt_to_head_page(ptr);
89554 +
89555 + if (!PageSlab(page))
89556 + return NULL;
89557 +
89558 + cachep = page->slab_cache;
89559 + if (!(cachep->flags & SLAB_USERCOPY))
89560 + return cachep->name;
89561 +
89562 + slabp = page->slab_page;
89563 + objnr = obj_to_index(cachep, slabp, ptr);
89564 + BUG_ON(objnr >= cachep->num);
89565 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
89566 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
89567 + return NULL;
89568 +
89569 + return cachep->name;
89570 +}
89571 +#endif
89572 +
89573 /**
89574 * ksize - get the actual amount of memory allocated for a given object
89575 * @objp: Pointer to the object
89576 diff --git a/mm/slab.h b/mm/slab.h
89577 index a535033..2f98fe5 100644
89578 --- a/mm/slab.h
89579 +++ b/mm/slab.h
89580 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
89581 /* The slab cache that manages slab cache information */
89582 extern struct kmem_cache *kmem_cache;
89583
89584 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89585 +#ifdef CONFIG_X86_64
89586 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
89587 +#else
89588 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
89589 +#endif
89590 +extern bool pax_sanitize_slab;
89591 +#endif
89592 +
89593 unsigned long calculate_alignment(unsigned long flags,
89594 unsigned long align, unsigned long size);
89595
89596 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89597
89598 /* Legal flag mask for kmem_cache_create(), for various configurations */
89599 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
89600 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
89601 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
89602 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
89603
89604 #if defined(CONFIG_DEBUG_SLAB)
89605 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
89606 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
89607 return s;
89608
89609 page = virt_to_head_page(x);
89610 +
89611 + BUG_ON(!PageSlab(page));
89612 +
89613 cachep = page->slab_cache;
89614 if (slab_equal_or_root(cachep, s))
89615 return cachep;
89616 diff --git a/mm/slab_common.c b/mm/slab_common.c
89617 index 538bade..36fed99 100644
89618 --- a/mm/slab_common.c
89619 +++ b/mm/slab_common.c
89620 @@ -22,11 +22,22 @@
89621
89622 #include "slab.h"
89623
89624 -enum slab_state slab_state;
89625 +enum slab_state slab_state __read_only;
89626 LIST_HEAD(slab_caches);
89627 DEFINE_MUTEX(slab_mutex);
89628 struct kmem_cache *kmem_cache;
89629
89630 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89631 +bool pax_sanitize_slab __read_only = true;
89632 +static int __init pax_sanitize_slab_setup(char *str)
89633 +{
89634 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
89635 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
89636 + return 1;
89637 +}
89638 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
89639 +#endif
89640 +
89641 #ifdef CONFIG_DEBUG_VM
89642 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
89643 size_t size)
89644 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
89645
89646 err = __kmem_cache_create(s, flags);
89647 if (!err) {
89648 - s->refcount = 1;
89649 + atomic_set(&s->refcount, 1);
89650 list_add(&s->list, &slab_caches);
89651 memcg_cache_list_add(memcg, s);
89652 } else {
89653 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
89654
89655 get_online_cpus();
89656 mutex_lock(&slab_mutex);
89657 - s->refcount--;
89658 - if (!s->refcount) {
89659 + if (atomic_dec_and_test(&s->refcount)) {
89660 list_del(&s->list);
89661
89662 if (!__kmem_cache_shutdown(s)) {
89663 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
89664 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
89665 name, size, err);
89666
89667 - s->refcount = -1; /* Exempt from merging for now */
89668 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
89669 }
89670
89671 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89672 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89673
89674 create_boot_cache(s, name, size, flags);
89675 list_add(&s->list, &slab_caches);
89676 - s->refcount = 1;
89677 + atomic_set(&s->refcount, 1);
89678 return s;
89679 }
89680
89681 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
89682 EXPORT_SYMBOL(kmalloc_dma_caches);
89683 #endif
89684
89685 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89686 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
89687 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
89688 +#endif
89689 +
89690 /*
89691 * Conversion table for small slabs sizes / 8 to the index in the
89692 * kmalloc array. This is necessary for slabs < 192 since we have non power
89693 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
89694 return kmalloc_dma_caches[index];
89695
89696 #endif
89697 +
89698 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89699 + if (unlikely((flags & GFP_USERCOPY)))
89700 + return kmalloc_usercopy_caches[index];
89701 +
89702 +#endif
89703 +
89704 return kmalloc_caches[index];
89705 }
89706
89707 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
89708 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
89709 if (!kmalloc_caches[i]) {
89710 kmalloc_caches[i] = create_kmalloc_cache(NULL,
89711 - 1 << i, flags);
89712 + 1 << i, SLAB_USERCOPY | flags);
89713 }
89714
89715 /*
89716 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
89717 * earlier power of two caches
89718 */
89719 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
89720 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
89721 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
89722
89723 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
89724 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
89725 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
89726 }
89727
89728 /* Kmalloc array is now usable */
89729 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
89730 }
89731 }
89732 #endif
89733 +
89734 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89735 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
89736 + struct kmem_cache *s = kmalloc_caches[i];
89737 +
89738 + if (s) {
89739 + int size = kmalloc_size(i);
89740 + char *n = kasprintf(GFP_NOWAIT,
89741 + "usercopy-kmalloc-%d", size);
89742 +
89743 + BUG_ON(!n);
89744 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
89745 + size, SLAB_USERCOPY | flags);
89746 + }
89747 + }
89748 +#endif
89749 +
89750 }
89751 #endif /* !CONFIG_SLOB */
89752
89753 @@ -523,6 +562,9 @@ void print_slabinfo_header(struct seq_file *m)
89754 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
89755 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
89756 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
89757 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89758 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
89759 +#endif
89760 #endif
89761 seq_putc(m, '\n');
89762 }
89763 diff --git a/mm/slob.c b/mm/slob.c
89764 index 91bd3f2..e2f549e 100644
89765 --- a/mm/slob.c
89766 +++ b/mm/slob.c
89767 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
89768 /*
89769 * Return the size of a slob block.
89770 */
89771 -static slobidx_t slob_units(slob_t *s)
89772 +static slobidx_t slob_units(const slob_t *s)
89773 {
89774 if (s->units > 0)
89775 return s->units;
89776 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
89777 /*
89778 * Return the next free slob block pointer after this one.
89779 */
89780 -static slob_t *slob_next(slob_t *s)
89781 +static slob_t *slob_next(const slob_t *s)
89782 {
89783 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
89784 slobidx_t next;
89785 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
89786 /*
89787 * Returns true if s is the last free block in its page.
89788 */
89789 -static int slob_last(slob_t *s)
89790 +static int slob_last(const slob_t *s)
89791 {
89792 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
89793 }
89794
89795 -static void *slob_new_pages(gfp_t gfp, int order, int node)
89796 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
89797 {
89798 - void *page;
89799 + struct page *page;
89800
89801 #ifdef CONFIG_NUMA
89802 if (node != NUMA_NO_NODE)
89803 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
89804 if (!page)
89805 return NULL;
89806
89807 - return page_address(page);
89808 + __SetPageSlab(page);
89809 + return page;
89810 }
89811
89812 -static void slob_free_pages(void *b, int order)
89813 +static void slob_free_pages(struct page *sp, int order)
89814 {
89815 if (current->reclaim_state)
89816 current->reclaim_state->reclaimed_slab += 1 << order;
89817 - free_pages((unsigned long)b, order);
89818 + __ClearPageSlab(sp);
89819 + page_mapcount_reset(sp);
89820 + sp->private = 0;
89821 + __free_pages(sp, order);
89822 }
89823
89824 /*
89825 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
89826
89827 /* Not enough space: must allocate a new page */
89828 if (!b) {
89829 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89830 - if (!b)
89831 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89832 + if (!sp)
89833 return NULL;
89834 - sp = virt_to_page(b);
89835 - __SetPageSlab(sp);
89836 + b = page_address(sp);
89837
89838 spin_lock_irqsave(&slob_lock, flags);
89839 sp->units = SLOB_UNITS(PAGE_SIZE);
89840 sp->freelist = b;
89841 + sp->private = 0;
89842 INIT_LIST_HEAD(&sp->list);
89843 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
89844 set_slob_page_free(sp, slob_list);
89845 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
89846 if (slob_page_free(sp))
89847 clear_slob_page_free(sp);
89848 spin_unlock_irqrestore(&slob_lock, flags);
89849 - __ClearPageSlab(sp);
89850 - page_mapcount_reset(sp);
89851 - slob_free_pages(b, 0);
89852 + slob_free_pages(sp, 0);
89853 return;
89854 }
89855
89856 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89857 + if (pax_sanitize_slab)
89858 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
89859 +#endif
89860 +
89861 if (!slob_page_free(sp)) {
89862 /* This slob page is about to become partially free. Easy! */
89863 sp->units = units;
89864 @@ -424,11 +431,10 @@ out:
89865 */
89866
89867 static __always_inline void *
89868 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89869 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
89870 {
89871 - unsigned int *m;
89872 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89873 - void *ret;
89874 + slob_t *m;
89875 + void *ret = NULL;
89876
89877 gfp &= gfp_allowed_mask;
89878
89879 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89880
89881 if (!m)
89882 return NULL;
89883 - *m = size;
89884 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
89885 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
89886 + m[0].units = size;
89887 + m[1].units = align;
89888 ret = (void *)m + align;
89889
89890 trace_kmalloc_node(caller, ret,
89891 size, size + align, gfp, node);
89892 } else {
89893 unsigned int order = get_order(size);
89894 + struct page *page;
89895
89896 if (likely(order))
89897 gfp |= __GFP_COMP;
89898 - ret = slob_new_pages(gfp, order, node);
89899 + page = slob_new_pages(gfp, order, node);
89900 + if (page) {
89901 + ret = page_address(page);
89902 + page->private = size;
89903 + }
89904
89905 trace_kmalloc_node(caller, ret,
89906 size, PAGE_SIZE << order, gfp, node);
89907 }
89908
89909 - kmemleak_alloc(ret, size, 1, gfp);
89910 + return ret;
89911 +}
89912 +
89913 +static __always_inline void *
89914 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89915 +{
89916 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89917 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
89918 +
89919 + if (!ZERO_OR_NULL_PTR(ret))
89920 + kmemleak_alloc(ret, size, 1, gfp);
89921 return ret;
89922 }
89923
89924 @@ -493,34 +517,112 @@ void kfree(const void *block)
89925 return;
89926 kmemleak_free(block);
89927
89928 + VM_BUG_ON(!virt_addr_valid(block));
89929 sp = virt_to_page(block);
89930 - if (PageSlab(sp)) {
89931 + VM_BUG_ON(!PageSlab(sp));
89932 + if (!sp->private) {
89933 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89934 - unsigned int *m = (unsigned int *)(block - align);
89935 - slob_free(m, *m + align);
89936 - } else
89937 + slob_t *m = (slob_t *)(block - align);
89938 + slob_free(m, m[0].units + align);
89939 + } else {
89940 + __ClearPageSlab(sp);
89941 + page_mapcount_reset(sp);
89942 + sp->private = 0;
89943 __free_pages(sp, compound_order(sp));
89944 + }
89945 }
89946 EXPORT_SYMBOL(kfree);
89947
89948 +bool is_usercopy_object(const void *ptr)
89949 +{
89950 + if (!slab_is_available())
89951 + return false;
89952 +
89953 + // PAX: TODO
89954 +
89955 + return false;
89956 +}
89957 +
89958 +#ifdef CONFIG_PAX_USERCOPY
89959 +const char *check_heap_object(const void *ptr, unsigned long n)
89960 +{
89961 + struct page *page;
89962 + const slob_t *free;
89963 + const void *base;
89964 + unsigned long flags;
89965 +
89966 + if (ZERO_OR_NULL_PTR(ptr))
89967 + return "<null>";
89968 +
89969 + if (!virt_addr_valid(ptr))
89970 + return NULL;
89971 +
89972 + page = virt_to_head_page(ptr);
89973 + if (!PageSlab(page))
89974 + return NULL;
89975 +
89976 + if (page->private) {
89977 + base = page;
89978 + if (base <= ptr && n <= page->private - (ptr - base))
89979 + return NULL;
89980 + return "<slob>";
89981 + }
89982 +
89983 + /* some tricky double walking to find the chunk */
89984 + spin_lock_irqsave(&slob_lock, flags);
89985 + base = (void *)((unsigned long)ptr & PAGE_MASK);
89986 + free = page->freelist;
89987 +
89988 + while (!slob_last(free) && (void *)free <= ptr) {
89989 + base = free + slob_units(free);
89990 + free = slob_next(free);
89991 + }
89992 +
89993 + while (base < (void *)free) {
89994 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
89995 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
89996 + int offset;
89997 +
89998 + if (ptr < base + align)
89999 + break;
90000 +
90001 + offset = ptr - base - align;
90002 + if (offset >= m) {
90003 + base += size;
90004 + continue;
90005 + }
90006 +
90007 + if (n > m - offset)
90008 + break;
90009 +
90010 + spin_unlock_irqrestore(&slob_lock, flags);
90011 + return NULL;
90012 + }
90013 +
90014 + spin_unlock_irqrestore(&slob_lock, flags);
90015 + return "<slob>";
90016 +}
90017 +#endif
90018 +
90019 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
90020 size_t ksize(const void *block)
90021 {
90022 struct page *sp;
90023 int align;
90024 - unsigned int *m;
90025 + slob_t *m;
90026
90027 BUG_ON(!block);
90028 if (unlikely(block == ZERO_SIZE_PTR))
90029 return 0;
90030
90031 sp = virt_to_page(block);
90032 - if (unlikely(!PageSlab(sp)))
90033 - return PAGE_SIZE << compound_order(sp);
90034 + VM_BUG_ON(!PageSlab(sp));
90035 + if (sp->private)
90036 + return sp->private;
90037
90038 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90039 - m = (unsigned int *)(block - align);
90040 - return SLOB_UNITS(*m) * SLOB_UNIT;
90041 + m = (slob_t *)(block - align);
90042 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
90043 }
90044 EXPORT_SYMBOL(ksize);
90045
90046 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
90047
90048 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
90049 {
90050 - void *b;
90051 + void *b = NULL;
90052
90053 flags &= gfp_allowed_mask;
90054
90055 lockdep_trace_alloc(flags);
90056
90057 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90058 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
90059 +#else
90060 if (c->size < PAGE_SIZE) {
90061 b = slob_alloc(c->size, flags, c->align, node);
90062 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90063 SLOB_UNITS(c->size) * SLOB_UNIT,
90064 flags, node);
90065 } else {
90066 - b = slob_new_pages(flags, get_order(c->size), node);
90067 + struct page *sp;
90068 +
90069 + sp = slob_new_pages(flags, get_order(c->size), node);
90070 + if (sp) {
90071 + b = page_address(sp);
90072 + sp->private = c->size;
90073 + }
90074 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90075 PAGE_SIZE << get_order(c->size),
90076 flags, node);
90077 }
90078 +#endif
90079
90080 if (b && c->ctor)
90081 c->ctor(b);
90082 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
90083
90084 static void __kmem_cache_free(void *b, int size)
90085 {
90086 - if (size < PAGE_SIZE)
90087 + struct page *sp;
90088 +
90089 + sp = virt_to_page(b);
90090 + BUG_ON(!PageSlab(sp));
90091 + if (!sp->private)
90092 slob_free(b, size);
90093 else
90094 - slob_free_pages(b, get_order(size));
90095 + slob_free_pages(sp, get_order(size));
90096 }
90097
90098 static void kmem_rcu_free(struct rcu_head *head)
90099 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
90100
90101 void kmem_cache_free(struct kmem_cache *c, void *b)
90102 {
90103 + int size = c->size;
90104 +
90105 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90106 + if (size + c->align < PAGE_SIZE) {
90107 + size += c->align;
90108 + b -= c->align;
90109 + }
90110 +#endif
90111 +
90112 kmemleak_free_recursive(b, c->flags);
90113 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
90114 struct slob_rcu *slob_rcu;
90115 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
90116 - slob_rcu->size = c->size;
90117 + slob_rcu = b + (size - sizeof(struct slob_rcu));
90118 + slob_rcu->size = size;
90119 call_rcu(&slob_rcu->head, kmem_rcu_free);
90120 } else {
90121 - __kmem_cache_free(b, c->size);
90122 + __kmem_cache_free(b, size);
90123 }
90124
90125 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90126 + trace_kfree(_RET_IP_, b);
90127 +#else
90128 trace_kmem_cache_free(_RET_IP_, b);
90129 +#endif
90130 +
90131 }
90132 EXPORT_SYMBOL(kmem_cache_free);
90133
90134 diff --git a/mm/slub.c b/mm/slub.c
90135 index e3ba1f2..bd45dac 100644
90136 --- a/mm/slub.c
90137 +++ b/mm/slub.c
90138 @@ -207,7 +207,7 @@ struct track {
90139
90140 enum track_item { TRACK_ALLOC, TRACK_FREE };
90141
90142 -#ifdef CONFIG_SYSFS
90143 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90144 static int sysfs_slab_add(struct kmem_cache *);
90145 static int sysfs_slab_alias(struct kmem_cache *, const char *);
90146 static void sysfs_slab_remove(struct kmem_cache *);
90147 @@ -528,7 +528,7 @@ static void print_track(const char *s, struct track *t)
90148 if (!t->addr)
90149 return;
90150
90151 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
90152 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
90153 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
90154 #ifdef CONFIG_STACKTRACE
90155 {
90156 @@ -2609,6 +2609,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
90157
90158 slab_free_hook(s, x);
90159
90160 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90161 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
90162 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
90163 + if (s->ctor)
90164 + s->ctor(x);
90165 + }
90166 +#endif
90167 +
90168 redo:
90169 /*
90170 * Determine the currently cpus per cpu slab.
90171 @@ -2676,7 +2684,7 @@ static int slub_min_objects;
90172 * Merge control. If this is set then no merging of slab caches will occur.
90173 * (Could be removed. This was introduced to pacify the merge skeptics.)
90174 */
90175 -static int slub_nomerge;
90176 +static int slub_nomerge = 1;
90177
90178 /*
90179 * Calculate the order of allocation given an slab object size.
90180 @@ -2953,6 +2961,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
90181 s->inuse = size;
90182
90183 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
90184 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90185 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
90186 +#endif
90187 s->ctor)) {
90188 /*
90189 * Relocate free pointer after the object if it is not
90190 @@ -3298,6 +3309,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
90191 EXPORT_SYMBOL(__kmalloc_node);
90192 #endif
90193
90194 +bool is_usercopy_object(const void *ptr)
90195 +{
90196 + struct page *page;
90197 + struct kmem_cache *s;
90198 +
90199 + if (ZERO_OR_NULL_PTR(ptr))
90200 + return false;
90201 +
90202 + if (!slab_is_available())
90203 + return false;
90204 +
90205 + if (!virt_addr_valid(ptr))
90206 + return false;
90207 +
90208 + page = virt_to_head_page(ptr);
90209 +
90210 + if (!PageSlab(page))
90211 + return false;
90212 +
90213 + s = page->slab_cache;
90214 + return s->flags & SLAB_USERCOPY;
90215 +}
90216 +
90217 +#ifdef CONFIG_PAX_USERCOPY
90218 +const char *check_heap_object(const void *ptr, unsigned long n)
90219 +{
90220 + struct page *page;
90221 + struct kmem_cache *s;
90222 + unsigned long offset;
90223 +
90224 + if (ZERO_OR_NULL_PTR(ptr))
90225 + return "<null>";
90226 +
90227 + if (!virt_addr_valid(ptr))
90228 + return NULL;
90229 +
90230 + page = virt_to_head_page(ptr);
90231 +
90232 + if (!PageSlab(page))
90233 + return NULL;
90234 +
90235 + s = page->slab_cache;
90236 + if (!(s->flags & SLAB_USERCOPY))
90237 + return s->name;
90238 +
90239 + offset = (ptr - page_address(page)) % s->size;
90240 + if (offset <= s->object_size && n <= s->object_size - offset)
90241 + return NULL;
90242 +
90243 + return s->name;
90244 +}
90245 +#endif
90246 +
90247 size_t ksize(const void *object)
90248 {
90249 struct page *page;
90250 @@ -3362,6 +3426,7 @@ void kfree(const void *x)
90251 if (unlikely(ZERO_OR_NULL_PTR(x)))
90252 return;
90253
90254 + VM_BUG_ON(!virt_addr_valid(x));
90255 page = virt_to_head_page(x);
90256 if (unlikely(!PageSlab(page))) {
90257 BUG_ON(!PageCompound(page));
90258 @@ -3667,7 +3732,7 @@ static int slab_unmergeable(struct kmem_cache *s)
90259 /*
90260 * We may have set a slab to be unmergeable during bootstrap.
90261 */
90262 - if (s->refcount < 0)
90263 + if (atomic_read(&s->refcount) < 0)
90264 return 1;
90265
90266 return 0;
90267 @@ -3725,7 +3790,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90268
90269 s = find_mergeable(memcg, size, align, flags, name, ctor);
90270 if (s) {
90271 - s->refcount++;
90272 + atomic_inc(&s->refcount);
90273 /*
90274 * Adjust the object sizes so that we clear
90275 * the complete object on kzalloc.
90276 @@ -3734,7 +3799,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90277 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
90278
90279 if (sysfs_slab_alias(s, name)) {
90280 - s->refcount--;
90281 + atomic_dec(&s->refcount);
90282 s = NULL;
90283 }
90284 }
90285 @@ -3854,7 +3919,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
90286 }
90287 #endif
90288
90289 -#ifdef CONFIG_SYSFS
90290 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90291 static int count_inuse(struct page *page)
90292 {
90293 return page->inuse;
90294 @@ -4241,12 +4306,12 @@ static void resiliency_test(void)
90295 validate_slab_cache(kmalloc_caches[9]);
90296 }
90297 #else
90298 -#ifdef CONFIG_SYSFS
90299 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90300 static void resiliency_test(void) {};
90301 #endif
90302 #endif
90303
90304 -#ifdef CONFIG_SYSFS
90305 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90306 enum slab_stat_type {
90307 SL_ALL, /* All slabs */
90308 SL_PARTIAL, /* Only partially allocated slabs */
90309 @@ -4490,7 +4555,7 @@ SLAB_ATTR_RO(ctor);
90310
90311 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
90312 {
90313 - return sprintf(buf, "%d\n", s->refcount - 1);
90314 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
90315 }
90316 SLAB_ATTR_RO(aliases);
90317
90318 @@ -4578,6 +4643,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
90319 SLAB_ATTR_RO(cache_dma);
90320 #endif
90321
90322 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90323 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
90324 +{
90325 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
90326 +}
90327 +SLAB_ATTR_RO(usercopy);
90328 +#endif
90329 +
90330 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
90331 {
90332 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
90333 @@ -4912,6 +4985,9 @@ static struct attribute *slab_attrs[] = {
90334 #ifdef CONFIG_ZONE_DMA
90335 &cache_dma_attr.attr,
90336 #endif
90337 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90338 + &usercopy_attr.attr,
90339 +#endif
90340 #ifdef CONFIG_NUMA
90341 &remote_node_defrag_ratio_attr.attr,
90342 #endif
90343 @@ -5143,6 +5219,7 @@ static char *create_unique_id(struct kmem_cache *s)
90344 return name;
90345 }
90346
90347 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90348 static int sysfs_slab_add(struct kmem_cache *s)
90349 {
90350 int err;
90351 @@ -5166,7 +5243,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
90352 }
90353
90354 s->kobj.kset = slab_kset;
90355 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
90356 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
90357 if (err) {
90358 kobject_put(&s->kobj);
90359 return err;
90360 @@ -5200,6 +5277,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
90361 kobject_del(&s->kobj);
90362 kobject_put(&s->kobj);
90363 }
90364 +#endif
90365
90366 /*
90367 * Need to buffer aliases during bootup until sysfs becomes
90368 @@ -5213,6 +5291,7 @@ struct saved_alias {
90369
90370 static struct saved_alias *alias_list;
90371
90372 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90373 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90374 {
90375 struct saved_alias *al;
90376 @@ -5235,6 +5314,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90377 alias_list = al;
90378 return 0;
90379 }
90380 +#endif
90381
90382 static int __init slab_sysfs_init(void)
90383 {
90384 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
90385 index 27eeab3..7c3f7f2 100644
90386 --- a/mm/sparse-vmemmap.c
90387 +++ b/mm/sparse-vmemmap.c
90388 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
90389 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90390 if (!p)
90391 return NULL;
90392 - pud_populate(&init_mm, pud, p);
90393 + pud_populate_kernel(&init_mm, pud, p);
90394 }
90395 return pud;
90396 }
90397 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
90398 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90399 if (!p)
90400 return NULL;
90401 - pgd_populate(&init_mm, pgd, p);
90402 + pgd_populate_kernel(&init_mm, pgd, p);
90403 }
90404 return pgd;
90405 }
90406 diff --git a/mm/sparse.c b/mm/sparse.c
90407 index 308d503..3dbbd04 100644
90408 --- a/mm/sparse.c
90409 +++ b/mm/sparse.c
90410 @@ -764,7 +764,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
90411
90412 for (i = 0; i < PAGES_PER_SECTION; i++) {
90413 if (PageHWPoison(&memmap[i])) {
90414 - atomic_long_sub(1, &num_poisoned_pages);
90415 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
90416 ClearPageHWPoison(&memmap[i]);
90417 }
90418 }
90419 diff --git a/mm/swap.c b/mm/swap.c
90420 index c899502..d4dc2cd 100644
90421 --- a/mm/swap.c
90422 +++ b/mm/swap.c
90423 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
90424
90425 __page_cache_release(page);
90426 dtor = get_compound_page_dtor(page);
90427 + if (!PageHuge(page))
90428 + BUG_ON(dtor != free_compound_page);
90429 (*dtor)(page);
90430 }
90431
90432 diff --git a/mm/swapfile.c b/mm/swapfile.c
90433 index 6cf2e60..d204b3e 100644
90434 --- a/mm/swapfile.c
90435 +++ b/mm/swapfile.c
90436 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
90437
90438 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
90439 /* Activity counter to indicate that a swapon or swapoff has occurred */
90440 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
90441 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
90442
90443 static inline unsigned char swap_count(unsigned char ent)
90444 {
90445 @@ -1699,7 +1699,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
90446 }
90447 filp_close(swap_file, NULL);
90448 err = 0;
90449 - atomic_inc(&proc_poll_event);
90450 + atomic_inc_unchecked(&proc_poll_event);
90451 wake_up_interruptible(&proc_poll_wait);
90452
90453 out_dput:
90454 @@ -1716,8 +1716,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
90455
90456 poll_wait(file, &proc_poll_wait, wait);
90457
90458 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
90459 - seq->poll_event = atomic_read(&proc_poll_event);
90460 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
90461 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90462 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
90463 }
90464
90465 @@ -1815,7 +1815,7 @@ static int swaps_open(struct inode *inode, struct file *file)
90466 return ret;
90467
90468 seq = file->private_data;
90469 - seq->poll_event = atomic_read(&proc_poll_event);
90470 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90471 return 0;
90472 }
90473
90474 @@ -2203,7 +2203,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
90475 (frontswap_map) ? "FS" : "");
90476
90477 mutex_unlock(&swapon_mutex);
90478 - atomic_inc(&proc_poll_event);
90479 + atomic_inc_unchecked(&proc_poll_event);
90480 wake_up_interruptible(&proc_poll_wait);
90481
90482 if (S_ISREG(inode->i_mode))
90483 diff --git a/mm/util.c b/mm/util.c
90484 index 7441c41..c3de793 100644
90485 --- a/mm/util.c
90486 +++ b/mm/util.c
90487 @@ -294,6 +294,12 @@ done:
90488 void arch_pick_mmap_layout(struct mm_struct *mm)
90489 {
90490 mm->mmap_base = TASK_UNMAPPED_BASE;
90491 +
90492 +#ifdef CONFIG_PAX_RANDMMAP
90493 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90494 + mm->mmap_base += mm->delta_mmap;
90495 +#endif
90496 +
90497 mm->get_unmapped_area = arch_get_unmapped_area;
90498 }
90499 #endif
90500 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
90501 index 13a5495..6707d97 100644
90502 --- a/mm/vmalloc.c
90503 +++ b/mm/vmalloc.c
90504 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
90505
90506 pte = pte_offset_kernel(pmd, addr);
90507 do {
90508 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90509 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90510 +
90511 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90512 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
90513 + BUG_ON(!pte_exec(*pte));
90514 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
90515 + continue;
90516 + }
90517 +#endif
90518 +
90519 + {
90520 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90521 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90522 + }
90523 } while (pte++, addr += PAGE_SIZE, addr != end);
90524 }
90525
90526 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
90527 pte = pte_alloc_kernel(pmd, addr);
90528 if (!pte)
90529 return -ENOMEM;
90530 +
90531 + pax_open_kernel();
90532 do {
90533 struct page *page = pages[*nr];
90534
90535 - if (WARN_ON(!pte_none(*pte)))
90536 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90537 + if (pgprot_val(prot) & _PAGE_NX)
90538 +#endif
90539 +
90540 + if (!pte_none(*pte)) {
90541 + pax_close_kernel();
90542 + WARN_ON(1);
90543 return -EBUSY;
90544 - if (WARN_ON(!page))
90545 + }
90546 + if (!page) {
90547 + pax_close_kernel();
90548 + WARN_ON(1);
90549 return -ENOMEM;
90550 + }
90551 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
90552 (*nr)++;
90553 } while (pte++, addr += PAGE_SIZE, addr != end);
90554 + pax_close_kernel();
90555 return 0;
90556 }
90557
90558 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
90559 pmd_t *pmd;
90560 unsigned long next;
90561
90562 - pmd = pmd_alloc(&init_mm, pud, addr);
90563 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
90564 if (!pmd)
90565 return -ENOMEM;
90566 do {
90567 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
90568 pud_t *pud;
90569 unsigned long next;
90570
90571 - pud = pud_alloc(&init_mm, pgd, addr);
90572 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
90573 if (!pud)
90574 return -ENOMEM;
90575 do {
90576 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
90577 if (addr >= MODULES_VADDR && addr < MODULES_END)
90578 return 1;
90579 #endif
90580 +
90581 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90582 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
90583 + return 1;
90584 +#endif
90585 +
90586 return is_vmalloc_addr(x);
90587 }
90588
90589 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
90590
90591 if (!pgd_none(*pgd)) {
90592 pud_t *pud = pud_offset(pgd, addr);
90593 +#ifdef CONFIG_X86
90594 + if (!pud_large(*pud))
90595 +#endif
90596 if (!pud_none(*pud)) {
90597 pmd_t *pmd = pmd_offset(pud, addr);
90598 +#ifdef CONFIG_X86
90599 + if (!pmd_large(*pmd))
90600 +#endif
90601 if (!pmd_none(*pmd)) {
90602 pte_t *ptep, pte;
90603
90604 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
90605 * Allocate a region of KVA of the specified size and alignment, within the
90606 * vstart and vend.
90607 */
90608 -static struct vmap_area *alloc_vmap_area(unsigned long size,
90609 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
90610 unsigned long align,
90611 unsigned long vstart, unsigned long vend,
90612 int node, gfp_t gfp_mask)
90613 @@ -1308,6 +1344,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
90614 struct vm_struct *area;
90615
90616 BUG_ON(in_interrupt());
90617 +
90618 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90619 + if (flags & VM_KERNEXEC) {
90620 + if (start != VMALLOC_START || end != VMALLOC_END)
90621 + return NULL;
90622 + start = (unsigned long)MODULES_EXEC_VADDR;
90623 + end = (unsigned long)MODULES_EXEC_END;
90624 + }
90625 +#endif
90626 +
90627 if (flags & VM_IOREMAP)
90628 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
90629
90630 @@ -1533,6 +1579,11 @@ void *vmap(struct page **pages, unsigned int count,
90631 if (count > totalram_pages)
90632 return NULL;
90633
90634 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90635 + if (!(pgprot_val(prot) & _PAGE_NX))
90636 + flags |= VM_KERNEXEC;
90637 +#endif
90638 +
90639 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
90640 __builtin_return_address(0));
90641 if (!area)
90642 @@ -1634,6 +1685,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
90643 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
90644 goto fail;
90645
90646 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90647 + if (!(pgprot_val(prot) & _PAGE_NX))
90648 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
90649 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
90650 + else
90651 +#endif
90652 +
90653 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
90654 start, end, node, gfp_mask, caller);
90655 if (!area)
90656 @@ -1810,10 +1868,9 @@ EXPORT_SYMBOL(vzalloc_node);
90657 * For tight control over page level allocator and protection flags
90658 * use __vmalloc() instead.
90659 */
90660 -
90661 void *vmalloc_exec(unsigned long size)
90662 {
90663 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
90664 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
90665 NUMA_NO_NODE, __builtin_return_address(0));
90666 }
90667
90668 @@ -2120,6 +2177,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
90669 {
90670 struct vm_struct *area;
90671
90672 + BUG_ON(vma->vm_mirror);
90673 +
90674 size = PAGE_ALIGN(size);
90675
90676 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
90677 @@ -2605,7 +2664,11 @@ static int s_show(struct seq_file *m, void *p)
90678 v->addr, v->addr + v->size, v->size);
90679
90680 if (v->caller)
90681 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90682 + seq_printf(m, " %pK", v->caller);
90683 +#else
90684 seq_printf(m, " %pS", v->caller);
90685 +#endif
90686
90687 if (v->nr_pages)
90688 seq_printf(m, " pages=%d", v->nr_pages);
90689 diff --git a/mm/vmstat.c b/mm/vmstat.c
90690 index 20c2ef4..15e7ab7 100644
90691 --- a/mm/vmstat.c
90692 +++ b/mm/vmstat.c
90693 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
90694 *
90695 * vm_stat contains the global counters
90696 */
90697 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90698 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90699 EXPORT_SYMBOL(vm_stat);
90700
90701 #ifdef CONFIG_SMP
90702 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
90703 v = p->vm_stat_diff[i];
90704 p->vm_stat_diff[i] = 0;
90705 local_irq_restore(flags);
90706 - atomic_long_add(v, &zone->vm_stat[i]);
90707 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90708 global_diff[i] += v;
90709 #ifdef CONFIG_NUMA
90710 /* 3 seconds idle till flush */
90711 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
90712
90713 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
90714 if (global_diff[i])
90715 - atomic_long_add(global_diff[i], &vm_stat[i]);
90716 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
90717 }
90718
90719 /*
90720 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
90721 if (pset->vm_stat_diff[i]) {
90722 int v = pset->vm_stat_diff[i];
90723 pset->vm_stat_diff[i] = 0;
90724 - atomic_long_add(v, &zone->vm_stat[i]);
90725 - atomic_long_add(v, &vm_stat[i]);
90726 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90727 + atomic_long_add_unchecked(v, &vm_stat[i]);
90728 }
90729 }
90730 #endif
90731 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
90732 start_cpu_timer(cpu);
90733 #endif
90734 #ifdef CONFIG_PROC_FS
90735 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
90736 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
90737 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
90738 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
90739 + {
90740 + mode_t gr_mode = S_IRUGO;
90741 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
90742 + gr_mode = S_IRUSR;
90743 +#endif
90744 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
90745 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
90746 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
90747 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
90748 +#else
90749 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
90750 +#endif
90751 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
90752 + }
90753 #endif
90754 return 0;
90755 }
90756 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
90757 index 2fb2d88..8c06e40 100644
90758 --- a/net/8021q/vlan.c
90759 +++ b/net/8021q/vlan.c
90760 @@ -469,7 +469,7 @@ out:
90761 return NOTIFY_DONE;
90762 }
90763
90764 -static struct notifier_block vlan_notifier_block __read_mostly = {
90765 +static struct notifier_block vlan_notifier_block = {
90766 .notifier_call = vlan_device_event,
90767 };
90768
90769 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
90770 err = -EPERM;
90771 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
90772 break;
90773 - if ((args.u.name_type >= 0) &&
90774 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
90775 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
90776 struct vlan_net *vn;
90777
90778 vn = net_generic(net, vlan_net_id);
90779 diff --git a/net/9p/mod.c b/net/9p/mod.c
90780 index 6ab36ae..6f1841b 100644
90781 --- a/net/9p/mod.c
90782 +++ b/net/9p/mod.c
90783 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
90784 void v9fs_register_trans(struct p9_trans_module *m)
90785 {
90786 spin_lock(&v9fs_trans_lock);
90787 - list_add_tail(&m->list, &v9fs_trans_list);
90788 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
90789 spin_unlock(&v9fs_trans_lock);
90790 }
90791 EXPORT_SYMBOL(v9fs_register_trans);
90792 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
90793 void v9fs_unregister_trans(struct p9_trans_module *m)
90794 {
90795 spin_lock(&v9fs_trans_lock);
90796 - list_del_init(&m->list);
90797 + pax_list_del_init((struct list_head *)&m->list);
90798 spin_unlock(&v9fs_trans_lock);
90799 }
90800 EXPORT_SYMBOL(v9fs_unregister_trans);
90801 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
90802 index 3ffda1b..fceac96 100644
90803 --- a/net/9p/trans_fd.c
90804 +++ b/net/9p/trans_fd.c
90805 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
90806 oldfs = get_fs();
90807 set_fs(get_ds());
90808 /* The cast to a user pointer is valid due to the set_fs() */
90809 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
90810 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
90811 set_fs(oldfs);
90812
90813 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
90814 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
90815 index 876fbe8..8bbea9f 100644
90816 --- a/net/atm/atm_misc.c
90817 +++ b/net/atm/atm_misc.c
90818 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
90819 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
90820 return 1;
90821 atm_return(vcc, truesize);
90822 - atomic_inc(&vcc->stats->rx_drop);
90823 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90824 return 0;
90825 }
90826 EXPORT_SYMBOL(atm_charge);
90827 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
90828 }
90829 }
90830 atm_return(vcc, guess);
90831 - atomic_inc(&vcc->stats->rx_drop);
90832 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90833 return NULL;
90834 }
90835 EXPORT_SYMBOL(atm_alloc_charge);
90836 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
90837
90838 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90839 {
90840 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90841 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90842 __SONET_ITEMS
90843 #undef __HANDLE_ITEM
90844 }
90845 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
90846
90847 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90848 {
90849 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90850 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
90851 __SONET_ITEMS
90852 #undef __HANDLE_ITEM
90853 }
90854 diff --git a/net/atm/lec.h b/net/atm/lec.h
90855 index 4149db1..f2ab682 100644
90856 --- a/net/atm/lec.h
90857 +++ b/net/atm/lec.h
90858 @@ -48,7 +48,7 @@ struct lane2_ops {
90859 const u8 *tlvs, u32 sizeoftlvs);
90860 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
90861 const u8 *tlvs, u32 sizeoftlvs);
90862 -};
90863 +} __no_const;
90864
90865 /*
90866 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
90867 diff --git a/net/atm/proc.c b/net/atm/proc.c
90868 index bbb6461..cf04016 100644
90869 --- a/net/atm/proc.c
90870 +++ b/net/atm/proc.c
90871 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
90872 const struct k_atm_aal_stats *stats)
90873 {
90874 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
90875 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
90876 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
90877 - atomic_read(&stats->rx_drop));
90878 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
90879 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
90880 + atomic_read_unchecked(&stats->rx_drop));
90881 }
90882
90883 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
90884 diff --git a/net/atm/resources.c b/net/atm/resources.c
90885 index 0447d5d..3cf4728 100644
90886 --- a/net/atm/resources.c
90887 +++ b/net/atm/resources.c
90888 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
90889 static void copy_aal_stats(struct k_atm_aal_stats *from,
90890 struct atm_aal_stats *to)
90891 {
90892 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90893 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90894 __AAL_STAT_ITEMS
90895 #undef __HANDLE_ITEM
90896 }
90897 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
90898 static void subtract_aal_stats(struct k_atm_aal_stats *from,
90899 struct atm_aal_stats *to)
90900 {
90901 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90902 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
90903 __AAL_STAT_ITEMS
90904 #undef __HANDLE_ITEM
90905 }
90906 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
90907 index 919a5ce..cc6b444 100644
90908 --- a/net/ax25/sysctl_net_ax25.c
90909 +++ b/net/ax25/sysctl_net_ax25.c
90910 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
90911 {
90912 char path[sizeof("net/ax25/") + IFNAMSIZ];
90913 int k;
90914 - struct ctl_table *table;
90915 + ctl_table_no_const *table;
90916
90917 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
90918 if (!table)
90919 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
90920 index 62da527..aa27535 100644
90921 --- a/net/batman-adv/bat_iv_ogm.c
90922 +++ b/net/batman-adv/bat_iv_ogm.c
90923 @@ -120,7 +120,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
90924
90925 /* randomize initial seqno to avoid collision */
90926 get_random_bytes(&random_seqno, sizeof(random_seqno));
90927 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90928 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90929
90930 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
90931 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
90932 @@ -701,9 +701,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
90933 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
90934
90935 /* change sequence number to network order */
90936 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
90937 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
90938 batadv_ogm_packet->seqno = htonl(seqno);
90939 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
90940 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
90941
90942 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
90943 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
90944 @@ -1109,7 +1109,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
90945 return;
90946
90947 /* could be changed by schedule_own_packet() */
90948 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
90949 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
90950
90951 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
90952 has_directlink_flag = 1;
90953 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
90954 index c478e6b..469fd2f 100644
90955 --- a/net/batman-adv/hard-interface.c
90956 +++ b/net/batman-adv/hard-interface.c
90957 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
90958 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
90959 dev_add_pack(&hard_iface->batman_adv_ptype);
90960
90961 - atomic_set(&hard_iface->frag_seqno, 1);
90962 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
90963 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
90964 hard_iface->net_dev->name);
90965
90966 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
90967 index 33b6144..3212ac5 100644
90968 --- a/net/batman-adv/soft-interface.c
90969 +++ b/net/batman-adv/soft-interface.c
90970 @@ -261,7 +261,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
90971 primary_if->net_dev->dev_addr, ETH_ALEN);
90972
90973 /* set broadcast sequence number */
90974 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
90975 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
90976 bcast_packet->seqno = htonl(seqno);
90977
90978 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
90979 @@ -481,7 +481,7 @@ static int batadv_softif_init_late(struct net_device *dev)
90980 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
90981
90982 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
90983 - atomic_set(&bat_priv->bcast_seqno, 1);
90984 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
90985 atomic_set(&bat_priv->tt.vn, 0);
90986 atomic_set(&bat_priv->tt.local_changes, 0);
90987 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
90988 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
90989 index b2c94e1..3d47e07 100644
90990 --- a/net/batman-adv/types.h
90991 +++ b/net/batman-adv/types.h
90992 @@ -51,7 +51,7 @@
90993 struct batadv_hard_iface_bat_iv {
90994 unsigned char *ogm_buff;
90995 int ogm_buff_len;
90996 - atomic_t ogm_seqno;
90997 + atomic_unchecked_t ogm_seqno;
90998 };
90999
91000 /**
91001 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
91002 int16_t if_num;
91003 char if_status;
91004 struct net_device *net_dev;
91005 - atomic_t frag_seqno;
91006 + atomic_unchecked_t frag_seqno;
91007 uint8_t num_bcasts;
91008 struct kobject *hardif_obj;
91009 atomic_t refcount;
91010 @@ -560,7 +560,7 @@ struct batadv_priv {
91011 #ifdef CONFIG_BATMAN_ADV_DEBUG
91012 atomic_t log_level;
91013 #endif
91014 - atomic_t bcast_seqno;
91015 + atomic_unchecked_t bcast_seqno;
91016 atomic_t bcast_queue_left;
91017 atomic_t batman_queue_left;
91018 char num_ifaces;
91019 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
91020 index 857e1b8..5ad07b2 100644
91021 --- a/net/batman-adv/unicast.c
91022 +++ b/net/batman-adv/unicast.c
91023 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
91024 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
91025 frag2->flags = large_tail;
91026
91027 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
91028 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
91029 frag1->seqno = htons(seqno - 1);
91030 frag2->seqno = htons(seqno);
91031
91032 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
91033 index 9bd7d95..6c4884f 100644
91034 --- a/net/bluetooth/hci_sock.c
91035 +++ b/net/bluetooth/hci_sock.c
91036 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
91037 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
91038 }
91039
91040 - len = min_t(unsigned int, len, sizeof(uf));
91041 + len = min((size_t)len, sizeof(uf));
91042 if (copy_from_user(&uf, optval, len)) {
91043 err = -EFAULT;
91044 break;
91045 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
91046 index 8c3499b..2661c6a 100644
91047 --- a/net/bluetooth/l2cap_core.c
91048 +++ b/net/bluetooth/l2cap_core.c
91049 @@ -3510,8 +3510,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
91050 break;
91051
91052 case L2CAP_CONF_RFC:
91053 - if (olen == sizeof(rfc))
91054 - memcpy(&rfc, (void *)val, olen);
91055 + if (olen != sizeof(rfc))
91056 + break;
91057 +
91058 + memcpy(&rfc, (void *)val, olen);
91059
91060 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
91061 rfc.mode != chan->mode)
91062 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
91063 index 0098af8..fb5a31f 100644
91064 --- a/net/bluetooth/l2cap_sock.c
91065 +++ b/net/bluetooth/l2cap_sock.c
91066 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91067 struct sock *sk = sock->sk;
91068 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
91069 struct l2cap_options opts;
91070 - int len, err = 0;
91071 + int err = 0;
91072 + size_t len = optlen;
91073 u32 opt;
91074
91075 BT_DBG("sk %p", sk);
91076 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91077 opts.max_tx = chan->max_tx;
91078 opts.txwin_size = chan->tx_win;
91079
91080 - len = min_t(unsigned int, sizeof(opts), optlen);
91081 + len = min(sizeof(opts), len);
91082 if (copy_from_user((char *) &opts, optval, len)) {
91083 err = -EFAULT;
91084 break;
91085 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91086 struct bt_security sec;
91087 struct bt_power pwr;
91088 struct l2cap_conn *conn;
91089 - int len, err = 0;
91090 + int err = 0;
91091 + size_t len = optlen;
91092 u32 opt;
91093
91094 BT_DBG("sk %p", sk);
91095 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91096
91097 sec.level = BT_SECURITY_LOW;
91098
91099 - len = min_t(unsigned int, sizeof(sec), optlen);
91100 + len = min(sizeof(sec), len);
91101 if (copy_from_user((char *) &sec, optval, len)) {
91102 err = -EFAULT;
91103 break;
91104 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91105
91106 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
91107
91108 - len = min_t(unsigned int, sizeof(pwr), optlen);
91109 + len = min(sizeof(pwr), len);
91110 if (copy_from_user((char *) &pwr, optval, len)) {
91111 err = -EFAULT;
91112 break;
91113 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
91114 index 30b3721..c1bd0a0 100644
91115 --- a/net/bluetooth/rfcomm/sock.c
91116 +++ b/net/bluetooth/rfcomm/sock.c
91117 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91118 struct sock *sk = sock->sk;
91119 struct bt_security sec;
91120 int err = 0;
91121 - size_t len;
91122 + size_t len = optlen;
91123 u32 opt;
91124
91125 BT_DBG("sk %p", sk);
91126 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91127
91128 sec.level = BT_SECURITY_LOW;
91129
91130 - len = min_t(unsigned int, sizeof(sec), optlen);
91131 + len = min(sizeof(sec), len);
91132 if (copy_from_user((char *) &sec, optval, len)) {
91133 err = -EFAULT;
91134 break;
91135 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
91136 index b6e44ad..5b0d514 100644
91137 --- a/net/bluetooth/rfcomm/tty.c
91138 +++ b/net/bluetooth/rfcomm/tty.c
91139 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
91140 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
91141
91142 spin_lock_irqsave(&dev->port.lock, flags);
91143 - if (dev->port.count > 0) {
91144 + if (atomic_read(&dev->port.count) > 0) {
91145 spin_unlock_irqrestore(&dev->port.lock, flags);
91146 return;
91147 }
91148 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
91149 return -ENODEV;
91150
91151 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
91152 - dev->channel, dev->port.count);
91153 + dev->channel, atomic_read(&dev->port.count));
91154
91155 spin_lock_irqsave(&dev->port.lock, flags);
91156 - if (++dev->port.count > 1) {
91157 + if (atomic_inc_return(&dev->port.count) > 1) {
91158 spin_unlock_irqrestore(&dev->port.lock, flags);
91159 return 0;
91160 }
91161 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
91162 return;
91163
91164 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
91165 - dev->port.count);
91166 + atomic_read(&dev->port.count));
91167
91168 spin_lock_irqsave(&dev->port.lock, flags);
91169 - if (!--dev->port.count) {
91170 + if (!atomic_dec_return(&dev->port.count)) {
91171 spin_unlock_irqrestore(&dev->port.lock, flags);
91172 if (dev->tty_dev->parent)
91173 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
91174 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
91175 index 5180938..7c470c3 100644
91176 --- a/net/bridge/netfilter/ebt_ulog.c
91177 +++ b/net/bridge/netfilter/ebt_ulog.c
91178 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91179 ub->qlen++;
91180
91181 pm = nlmsg_data(nlh);
91182 + memset(pm, 0, sizeof(*pm));
91183
91184 /* Fill in the ulog data */
91185 pm->version = EBT_ULOG_VERSION;
91186 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91187 pm->hook = hooknr;
91188 if (uloginfo->prefix != NULL)
91189 strcpy(pm->prefix, uloginfo->prefix);
91190 - else
91191 - *(pm->prefix) = '\0';
91192
91193 if (in) {
91194 strcpy(pm->physindev, in->name);
91195 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91196 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
91197 else
91198 strcpy(pm->indev, in->name);
91199 - } else
91200 - pm->indev[0] = pm->physindev[0] = '\0';
91201 + }
91202
91203 if (out) {
91204 /* If out exists, then out is a bridge port */
91205 strcpy(pm->physoutdev, out->name);
91206 /* rcu_read_lock()ed by nf_hook_slow */
91207 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
91208 - } else
91209 - pm->outdev[0] = pm->physoutdev[0] = '\0';
91210 + }
91211
91212 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
91213 BUG();
91214 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
91215 index ac78024..161a80c 100644
91216 --- a/net/bridge/netfilter/ebtables.c
91217 +++ b/net/bridge/netfilter/ebtables.c
91218 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91219 tmp.valid_hooks = t->table->valid_hooks;
91220 }
91221 mutex_unlock(&ebt_mutex);
91222 - if (copy_to_user(user, &tmp, *len) != 0){
91223 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
91224 BUGPRINT("c2u Didn't work\n");
91225 ret = -EFAULT;
91226 break;
91227 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91228 goto out;
91229 tmp.valid_hooks = t->valid_hooks;
91230
91231 - if (copy_to_user(user, &tmp, *len) != 0) {
91232 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91233 ret = -EFAULT;
91234 break;
91235 }
91236 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91237 tmp.entries_size = t->table->entries_size;
91238 tmp.valid_hooks = t->table->valid_hooks;
91239
91240 - if (copy_to_user(user, &tmp, *len) != 0) {
91241 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91242 ret = -EFAULT;
91243 break;
91244 }
91245 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
91246 index 0f45522..dab651f 100644
91247 --- a/net/caif/cfctrl.c
91248 +++ b/net/caif/cfctrl.c
91249 @@ -10,6 +10,7 @@
91250 #include <linux/spinlock.h>
91251 #include <linux/slab.h>
91252 #include <linux/pkt_sched.h>
91253 +#include <linux/sched.h>
91254 #include <net/caif/caif_layer.h>
91255 #include <net/caif/cfpkt.h>
91256 #include <net/caif/cfctrl.h>
91257 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
91258 memset(&dev_info, 0, sizeof(dev_info));
91259 dev_info.id = 0xff;
91260 cfsrvl_init(&this->serv, 0, &dev_info, false);
91261 - atomic_set(&this->req_seq_no, 1);
91262 - atomic_set(&this->rsp_seq_no, 1);
91263 + atomic_set_unchecked(&this->req_seq_no, 1);
91264 + atomic_set_unchecked(&this->rsp_seq_no, 1);
91265 this->serv.layer.receive = cfctrl_recv;
91266 sprintf(this->serv.layer.name, "ctrl");
91267 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
91268 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
91269 struct cfctrl_request_info *req)
91270 {
91271 spin_lock_bh(&ctrl->info_list_lock);
91272 - atomic_inc(&ctrl->req_seq_no);
91273 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
91274 + atomic_inc_unchecked(&ctrl->req_seq_no);
91275 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
91276 list_add_tail(&req->list, &ctrl->list);
91277 spin_unlock_bh(&ctrl->info_list_lock);
91278 }
91279 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
91280 if (p != first)
91281 pr_warn("Requests are not received in order\n");
91282
91283 - atomic_set(&ctrl->rsp_seq_no,
91284 + atomic_set_unchecked(&ctrl->rsp_seq_no,
91285 p->sequence_no);
91286 list_del(&p->list);
91287 goto out;
91288 diff --git a/net/can/af_can.c b/net/can/af_can.c
91289 index 3ab8dd2..b9aef13 100644
91290 --- a/net/can/af_can.c
91291 +++ b/net/can/af_can.c
91292 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
91293 };
91294
91295 /* notifier block for netdevice event */
91296 -static struct notifier_block can_netdev_notifier __read_mostly = {
91297 +static struct notifier_block can_netdev_notifier = {
91298 .notifier_call = can_notifier,
91299 };
91300
91301 diff --git a/net/can/gw.c b/net/can/gw.c
91302 index 2f291f9..98c986a 100644
91303 --- a/net/can/gw.c
91304 +++ b/net/can/gw.c
91305 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
91306 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
91307
91308 static HLIST_HEAD(cgw_list);
91309 -static struct notifier_block notifier;
91310
91311 static struct kmem_cache *cgw_cache __read_mostly;
91312
91313 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
91314 return err;
91315 }
91316
91317 +static struct notifier_block notifier = {
91318 + .notifier_call = cgw_notifier
91319 +};
91320 +
91321 static __init int cgw_module_init(void)
91322 {
91323 /* sanitize given module parameter */
91324 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
91325 return -ENOMEM;
91326
91327 /* set notifier */
91328 - notifier.notifier_call = cgw_notifier;
91329 register_netdevice_notifier(&notifier);
91330
91331 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
91332 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
91333 index eb0a46a..5f3bae8 100644
91334 --- a/net/ceph/messenger.c
91335 +++ b/net/ceph/messenger.c
91336 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
91337 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
91338
91339 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
91340 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
91341 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
91342
91343 static struct page *zero_page; /* used in certain error cases */
91344
91345 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
91346 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
91347 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
91348
91349 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91350 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91351 s = addr_str[i];
91352
91353 switch (ss->ss_family) {
91354 diff --git a/net/compat.c b/net/compat.c
91355 index 8903258..24e30e5 100644
91356 --- a/net/compat.c
91357 +++ b/net/compat.c
91358 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
91359 return -EFAULT;
91360 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
91361 return -EINVAL;
91362 - kmsg->msg_name = compat_ptr(tmp1);
91363 - kmsg->msg_iov = compat_ptr(tmp2);
91364 - kmsg->msg_control = compat_ptr(tmp3);
91365 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
91366 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
91367 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
91368 return 0;
91369 }
91370
91371 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91372
91373 if (kern_msg->msg_namelen) {
91374 if (mode == VERIFY_READ) {
91375 - int err = move_addr_to_kernel(kern_msg->msg_name,
91376 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
91377 kern_msg->msg_namelen,
91378 kern_address);
91379 if (err < 0)
91380 @@ -98,7 +98,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91381 kern_msg->msg_name = NULL;
91382
91383 tot_len = iov_from_user_compat_to_kern(kern_iov,
91384 - (struct compat_iovec __user *)kern_msg->msg_iov,
91385 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
91386 kern_msg->msg_iovlen);
91387 if (tot_len >= 0)
91388 kern_msg->msg_iov = kern_iov;
91389 @@ -118,20 +118,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91390
91391 #define CMSG_COMPAT_FIRSTHDR(msg) \
91392 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
91393 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
91394 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
91395 (struct compat_cmsghdr __user *)NULL)
91396
91397 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
91398 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
91399 (ucmlen) <= (unsigned long) \
91400 ((mhdr)->msg_controllen - \
91401 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
91402 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
91403
91404 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
91405 struct compat_cmsghdr __user *cmsg, int cmsg_len)
91406 {
91407 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
91408 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
91409 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
91410 msg->msg_controllen)
91411 return NULL;
91412 return (struct compat_cmsghdr __user *)ptr;
91413 @@ -221,7 +221,7 @@ Efault:
91414
91415 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
91416 {
91417 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91418 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91419 struct compat_cmsghdr cmhdr;
91420 struct compat_timeval ctv;
91421 struct compat_timespec cts[3];
91422 @@ -277,7 +277,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
91423
91424 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
91425 {
91426 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91427 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91428 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
91429 int fdnum = scm->fp->count;
91430 struct file **fp = scm->fp->fp;
91431 @@ -365,7 +365,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
91432 return -EFAULT;
91433 old_fs = get_fs();
91434 set_fs(KERNEL_DS);
91435 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
91436 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
91437 set_fs(old_fs);
91438
91439 return err;
91440 @@ -426,7 +426,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
91441 len = sizeof(ktime);
91442 old_fs = get_fs();
91443 set_fs(KERNEL_DS);
91444 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
91445 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
91446 set_fs(old_fs);
91447
91448 if (!err) {
91449 @@ -569,7 +569,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91450 case MCAST_JOIN_GROUP:
91451 case MCAST_LEAVE_GROUP:
91452 {
91453 - struct compat_group_req __user *gr32 = (void *)optval;
91454 + struct compat_group_req __user *gr32 = (void __user *)optval;
91455 struct group_req __user *kgr =
91456 compat_alloc_user_space(sizeof(struct group_req));
91457 u32 interface;
91458 @@ -590,7 +590,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91459 case MCAST_BLOCK_SOURCE:
91460 case MCAST_UNBLOCK_SOURCE:
91461 {
91462 - struct compat_group_source_req __user *gsr32 = (void *)optval;
91463 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
91464 struct group_source_req __user *kgsr = compat_alloc_user_space(
91465 sizeof(struct group_source_req));
91466 u32 interface;
91467 @@ -611,7 +611,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91468 }
91469 case MCAST_MSFILTER:
91470 {
91471 - struct compat_group_filter __user *gf32 = (void *)optval;
91472 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91473 struct group_filter __user *kgf;
91474 u32 interface, fmode, numsrc;
91475
91476 @@ -649,7 +649,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
91477 char __user *optval, int __user *optlen,
91478 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
91479 {
91480 - struct compat_group_filter __user *gf32 = (void *)optval;
91481 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91482 struct group_filter __user *kgf;
91483 int __user *koptlen;
91484 u32 interface, fmode, numsrc;
91485 @@ -807,7 +807,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
91486
91487 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
91488 return -EINVAL;
91489 - if (copy_from_user(a, args, nas[call]))
91490 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
91491 return -EFAULT;
91492 a0 = a[0];
91493 a1 = a[1];
91494 diff --git a/net/core/datagram.c b/net/core/datagram.c
91495 index 8ab48cd..57b1a80 100644
91496 --- a/net/core/datagram.c
91497 +++ b/net/core/datagram.c
91498 @@ -300,7 +300,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
91499 }
91500
91501 kfree_skb(skb);
91502 - atomic_inc(&sk->sk_drops);
91503 + atomic_inc_unchecked(&sk->sk_drops);
91504 sk_mem_reclaim_partial(sk);
91505
91506 return err;
91507 diff --git a/net/core/dev.c b/net/core/dev.c
91508 index 26755dd..2a232de 100644
91509 --- a/net/core/dev.c
91510 +++ b/net/core/dev.c
91511 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
91512 {
91513 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
91514 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
91515 - atomic_long_inc(&dev->rx_dropped);
91516 + atomic_long_inc_unchecked(&dev->rx_dropped);
91517 kfree_skb(skb);
91518 return NET_RX_DROP;
91519 }
91520 }
91521
91522 if (unlikely(!is_skb_forwardable(dev, skb))) {
91523 - atomic_long_inc(&dev->rx_dropped);
91524 + atomic_long_inc_unchecked(&dev->rx_dropped);
91525 kfree_skb(skb);
91526 return NET_RX_DROP;
91527 }
91528 @@ -2431,7 +2431,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
91529
91530 struct dev_gso_cb {
91531 void (*destructor)(struct sk_buff *skb);
91532 -};
91533 +} __no_const;
91534
91535 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
91536
91537 @@ -3206,7 +3206,7 @@ enqueue:
91538
91539 local_irq_restore(flags);
91540
91541 - atomic_long_inc(&skb->dev->rx_dropped);
91542 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91543 kfree_skb(skb);
91544 return NET_RX_DROP;
91545 }
91546 @@ -3278,7 +3278,7 @@ int netif_rx_ni(struct sk_buff *skb)
91547 }
91548 EXPORT_SYMBOL(netif_rx_ni);
91549
91550 -static void net_tx_action(struct softirq_action *h)
91551 +static __latent_entropy void net_tx_action(void)
91552 {
91553 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91554
91555 @@ -3612,7 +3612,7 @@ ncls:
91556 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
91557 } else {
91558 drop:
91559 - atomic_long_inc(&skb->dev->rx_dropped);
91560 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91561 kfree_skb(skb);
91562 /* Jamal, now you will not able to escape explaining
91563 * me how you were going to use this. :-)
91564 @@ -4272,7 +4272,7 @@ void netif_napi_del(struct napi_struct *napi)
91565 }
91566 EXPORT_SYMBOL(netif_napi_del);
91567
91568 -static void net_rx_action(struct softirq_action *h)
91569 +static __latent_entropy void net_rx_action(void)
91570 {
91571 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91572 unsigned long time_limit = jiffies + 2;
91573 @@ -5730,7 +5730,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
91574 } else {
91575 netdev_stats_to_stats64(storage, &dev->stats);
91576 }
91577 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
91578 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
91579 return storage;
91580 }
91581 EXPORT_SYMBOL(dev_get_stats);
91582 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
91583 index 5b7d0e1..cb960fc 100644
91584 --- a/net/core/dev_ioctl.c
91585 +++ b/net/core/dev_ioctl.c
91586 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
91587 if (no_module && capable(CAP_NET_ADMIN))
91588 no_module = request_module("netdev-%s", name);
91589 if (no_module && capable(CAP_SYS_MODULE)) {
91590 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
91591 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
91592 +#else
91593 if (!request_module("%s", name))
91594 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
91595 name);
91596 +#endif
91597 }
91598 }
91599 EXPORT_SYMBOL(dev_load);
91600 diff --git a/net/core/flow.c b/net/core/flow.c
91601 index dfa602c..3103d88 100644
91602 --- a/net/core/flow.c
91603 +++ b/net/core/flow.c
91604 @@ -61,7 +61,7 @@ struct flow_cache {
91605 struct timer_list rnd_timer;
91606 };
91607
91608 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
91609 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
91610 EXPORT_SYMBOL(flow_cache_genid);
91611 static struct flow_cache flow_cache_global;
91612 static struct kmem_cache *flow_cachep __read_mostly;
91613 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
91614
91615 static int flow_entry_valid(struct flow_cache_entry *fle)
91616 {
91617 - if (atomic_read(&flow_cache_genid) != fle->genid)
91618 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
91619 return 0;
91620 if (fle->object && !fle->object->ops->check(fle->object))
91621 return 0;
91622 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
91623 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
91624 fcp->hash_count++;
91625 }
91626 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
91627 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
91628 flo = fle->object;
91629 if (!flo)
91630 goto ret_object;
91631 @@ -279,7 +279,7 @@ nocache:
91632 }
91633 flo = resolver(net, key, family, dir, flo, ctx);
91634 if (fle) {
91635 - fle->genid = atomic_read(&flow_cache_genid);
91636 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
91637 if (!IS_ERR(flo))
91638 fle->object = flo;
91639 else
91640 diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
91641 index 52d0f83..4a1d064 100644
91642 --- a/net/core/flow_dissector.c
91643 +++ b/net/core/flow_dissector.c
91644 @@ -40,7 +40,7 @@ again:
91645 struct iphdr _iph;
91646 ip:
91647 iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
91648 - if (!iph)
91649 + if (!iph || iph->ihl < 5)
91650 return false;
91651
91652 if (ip_is_fragment(iph))
91653 diff --git a/net/core/iovec.c b/net/core/iovec.c
91654 index de178e4..1dabd8b 100644
91655 --- a/net/core/iovec.c
91656 +++ b/net/core/iovec.c
91657 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91658 if (m->msg_namelen) {
91659 if (mode == VERIFY_READ) {
91660 void __user *namep;
91661 - namep = (void __user __force *) m->msg_name;
91662 + namep = (void __force_user *) m->msg_name;
91663 err = move_addr_to_kernel(namep, m->msg_namelen,
91664 address);
91665 if (err < 0)
91666 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91667 }
91668
91669 size = m->msg_iovlen * sizeof(struct iovec);
91670 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
91671 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
91672 return -EFAULT;
91673
91674 m->msg_iov = iov;
91675 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
91676 index 60533db..14842cc 100644
91677 --- a/net/core/neighbour.c
91678 +++ b/net/core/neighbour.c
91679 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
91680 void __user *buffer, size_t *lenp, loff_t *ppos)
91681 {
91682 int size, ret;
91683 - struct ctl_table tmp = *ctl;
91684 + ctl_table_no_const tmp = *ctl;
91685
91686 tmp.extra1 = &zero;
91687 tmp.extra2 = &unres_qlen_max;
91688 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
91689 index 2bf8329..7960607 100644
91690 --- a/net/core/net-procfs.c
91691 +++ b/net/core/net-procfs.c
91692 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
91693 else
91694 seq_printf(seq, "%04x", ntohs(pt->type));
91695
91696 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91697 + seq_printf(seq, " %-8s %pf\n",
91698 + pt->dev ? pt->dev->name : "", NULL);
91699 +#else
91700 seq_printf(seq, " %-8s %pf\n",
91701 pt->dev ? pt->dev->name : "", pt->func);
91702 +#endif
91703 }
91704
91705 return 0;
91706 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
91707 index 981fed3..536af34 100644
91708 --- a/net/core/net-sysfs.c
91709 +++ b/net/core/net-sysfs.c
91710 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
91711 }
91712 EXPORT_SYMBOL(netdev_class_remove_file);
91713
91714 -int netdev_kobject_init(void)
91715 +int __init netdev_kobject_init(void)
91716 {
91717 kobj_ns_type_register(&net_ns_type_operations);
91718 return class_register(&net_class);
91719 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
91720 index f9765203..9feaef8 100644
91721 --- a/net/core/net_namespace.c
91722 +++ b/net/core/net_namespace.c
91723 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
91724 int error;
91725 LIST_HEAD(net_exit_list);
91726
91727 - list_add_tail(&ops->list, list);
91728 + pax_list_add_tail((struct list_head *)&ops->list, list);
91729 if (ops->init || (ops->id && ops->size)) {
91730 for_each_net(net) {
91731 error = ops_init(ops, net);
91732 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
91733
91734 out_undo:
91735 /* If I have an error cleanup all namespaces I initialized */
91736 - list_del(&ops->list);
91737 + pax_list_del((struct list_head *)&ops->list);
91738 ops_exit_list(ops, &net_exit_list);
91739 ops_free_list(ops, &net_exit_list);
91740 return error;
91741 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
91742 struct net *net;
91743 LIST_HEAD(net_exit_list);
91744
91745 - list_del(&ops->list);
91746 + pax_list_del((struct list_head *)&ops->list);
91747 for_each_net(net)
91748 list_add_tail(&net->exit_list, &net_exit_list);
91749 ops_exit_list(ops, &net_exit_list);
91750 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
91751 mutex_lock(&net_mutex);
91752 error = register_pernet_operations(&pernet_list, ops);
91753 if (!error && (first_device == &pernet_list))
91754 - first_device = &ops->list;
91755 + first_device = (struct list_head *)&ops->list;
91756 mutex_unlock(&net_mutex);
91757 return error;
91758 }
91759 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
91760 index fc75c9e..8c8e9be 100644
91761 --- a/net/core/netpoll.c
91762 +++ b/net/core/netpoll.c
91763 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91764 struct udphdr *udph;
91765 struct iphdr *iph;
91766 struct ethhdr *eth;
91767 - static atomic_t ip_ident;
91768 + static atomic_unchecked_t ip_ident;
91769 struct ipv6hdr *ip6h;
91770
91771 udp_len = len + sizeof(*udph);
91772 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91773 put_unaligned(0x45, (unsigned char *)iph);
91774 iph->tos = 0;
91775 put_unaligned(htons(ip_len), &(iph->tot_len));
91776 - iph->id = htons(atomic_inc_return(&ip_ident));
91777 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
91778 iph->frag_off = 0;
91779 iph->ttl = 64;
91780 iph->protocol = IPPROTO_UDP;
91781 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
91782 index ca198c1d1..125372f 100644
91783 --- a/net/core/rtnetlink.c
91784 +++ b/net/core/rtnetlink.c
91785 @@ -58,7 +58,7 @@ struct rtnl_link {
91786 rtnl_doit_func doit;
91787 rtnl_dumpit_func dumpit;
91788 rtnl_calcit_func calcit;
91789 -};
91790 +} __no_const;
91791
91792 static DEFINE_MUTEX(rtnl_mutex);
91793
91794 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
91795 if (rtnl_link_ops_get(ops->kind))
91796 return -EEXIST;
91797
91798 - if (!ops->dellink)
91799 - ops->dellink = unregister_netdevice_queue;
91800 + if (!ops->dellink) {
91801 + pax_open_kernel();
91802 + *(void **)&ops->dellink = unregister_netdevice_queue;
91803 + pax_close_kernel();
91804 + }
91805
91806 - list_add_tail(&ops->list, &link_ops);
91807 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
91808 return 0;
91809 }
91810 EXPORT_SYMBOL_GPL(__rtnl_link_register);
91811 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
91812 for_each_net(net) {
91813 __rtnl_kill_links(net, ops);
91814 }
91815 - list_del(&ops->list);
91816 + pax_list_del((struct list_head *)&ops->list);
91817 }
91818 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
91819
91820 diff --git a/net/core/scm.c b/net/core/scm.c
91821 index b4da80b..98d6bdb 100644
91822 --- a/net/core/scm.c
91823 +++ b/net/core/scm.c
91824 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
91825 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91826 {
91827 struct cmsghdr __user *cm
91828 - = (__force struct cmsghdr __user *)msg->msg_control;
91829 + = (struct cmsghdr __force_user *)msg->msg_control;
91830 struct cmsghdr cmhdr;
91831 int cmlen = CMSG_LEN(len);
91832 int err;
91833 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91834 err = -EFAULT;
91835 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
91836 goto out;
91837 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
91838 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
91839 goto out;
91840 cmlen = CMSG_SPACE(len);
91841 if (msg->msg_controllen < cmlen)
91842 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
91843 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91844 {
91845 struct cmsghdr __user *cm
91846 - = (__force struct cmsghdr __user*)msg->msg_control;
91847 + = (struct cmsghdr __force_user *)msg->msg_control;
91848
91849 int fdmax = 0;
91850 int fdnum = scm->fp->count;
91851 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91852 if (fdnum < fdmax)
91853 fdmax = fdnum;
91854
91855 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
91856 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
91857 i++, cmfptr++)
91858 {
91859 struct socket *sock;
91860 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
91861 index 2c3d0f5..f5a326f 100644
91862 --- a/net/core/skbuff.c
91863 +++ b/net/core/skbuff.c
91864 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
91865 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
91866 sizeof(struct sk_buff),
91867 0,
91868 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91869 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91870 + SLAB_NO_SANITIZE,
91871 NULL);
91872 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
91873 (2*sizeof(struct sk_buff)) +
91874 sizeof(atomic_t),
91875 0,
91876 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91877 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91878 + SLAB_NO_SANITIZE,
91879 NULL);
91880 }
91881
91882 diff --git a/net/core/sock.c b/net/core/sock.c
91883 index 8729d91..4a20427 100644
91884 --- a/net/core/sock.c
91885 +++ b/net/core/sock.c
91886 @@ -392,7 +392,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91887 struct sk_buff_head *list = &sk->sk_receive_queue;
91888
91889 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
91890 - atomic_inc(&sk->sk_drops);
91891 + atomic_inc_unchecked(&sk->sk_drops);
91892 trace_sock_rcvqueue_full(sk, skb);
91893 return -ENOMEM;
91894 }
91895 @@ -402,7 +402,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91896 return err;
91897
91898 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
91899 - atomic_inc(&sk->sk_drops);
91900 + atomic_inc_unchecked(&sk->sk_drops);
91901 return -ENOBUFS;
91902 }
91903
91904 @@ -422,7 +422,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91905 skb_dst_force(skb);
91906
91907 spin_lock_irqsave(&list->lock, flags);
91908 - skb->dropcount = atomic_read(&sk->sk_drops);
91909 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
91910 __skb_queue_tail(list, skb);
91911 spin_unlock_irqrestore(&list->lock, flags);
91912
91913 @@ -442,7 +442,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91914 skb->dev = NULL;
91915
91916 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
91917 - atomic_inc(&sk->sk_drops);
91918 + atomic_inc_unchecked(&sk->sk_drops);
91919 goto discard_and_relse;
91920 }
91921 if (nested)
91922 @@ -460,7 +460,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91923 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
91924 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
91925 bh_unlock_sock(sk);
91926 - atomic_inc(&sk->sk_drops);
91927 + atomic_inc_unchecked(&sk->sk_drops);
91928 goto discard_and_relse;
91929 }
91930
91931 @@ -948,12 +948,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91932 struct timeval tm;
91933 } v;
91934
91935 - int lv = sizeof(int);
91936 - int len;
91937 + unsigned int lv = sizeof(int);
91938 + unsigned int len;
91939
91940 if (get_user(len, optlen))
91941 return -EFAULT;
91942 - if (len < 0)
91943 + if (len > INT_MAX)
91944 return -EINVAL;
91945
91946 memset(&v, 0, sizeof(v));
91947 @@ -1105,11 +1105,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91948
91949 case SO_PEERNAME:
91950 {
91951 - char address[128];
91952 + char address[_K_SS_MAXSIZE];
91953
91954 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
91955 return -ENOTCONN;
91956 - if (lv < len)
91957 + if (lv < len || sizeof address < len)
91958 return -EINVAL;
91959 if (copy_to_user(optval, address, len))
91960 return -EFAULT;
91961 @@ -1182,7 +1182,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91962
91963 if (len > lv)
91964 len = lv;
91965 - if (copy_to_user(optval, &v, len))
91966 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
91967 return -EFAULT;
91968 lenout:
91969 if (put_user(len, optlen))
91970 @@ -2304,7 +2304,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
91971 */
91972 smp_wmb();
91973 atomic_set(&sk->sk_refcnt, 1);
91974 - atomic_set(&sk->sk_drops, 0);
91975 + atomic_set_unchecked(&sk->sk_drops, 0);
91976 }
91977 EXPORT_SYMBOL(sock_init_data);
91978
91979 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
91980 index a0e9cf6..ef7f9ed 100644
91981 --- a/net/core/sock_diag.c
91982 +++ b/net/core/sock_diag.c
91983 @@ -9,26 +9,33 @@
91984 #include <linux/inet_diag.h>
91985 #include <linux/sock_diag.h>
91986
91987 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
91988 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
91989 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
91990 static DEFINE_MUTEX(sock_diag_table_mutex);
91991
91992 int sock_diag_check_cookie(void *sk, __u32 *cookie)
91993 {
91994 +#ifndef CONFIG_GRKERNSEC_HIDESYM
91995 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
91996 cookie[1] != INET_DIAG_NOCOOKIE) &&
91997 ((u32)(unsigned long)sk != cookie[0] ||
91998 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
91999 return -ESTALE;
92000 else
92001 +#endif
92002 return 0;
92003 }
92004 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
92005
92006 void sock_diag_save_cookie(void *sk, __u32 *cookie)
92007 {
92008 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92009 + cookie[0] = 0;
92010 + cookie[1] = 0;
92011 +#else
92012 cookie[0] = (u32)(unsigned long)sk;
92013 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
92014 +#endif
92015 }
92016 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
92017
92018 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
92019 mutex_lock(&sock_diag_table_mutex);
92020 if (sock_diag_handlers[hndl->family])
92021 err = -EBUSY;
92022 - else
92023 + else {
92024 + pax_open_kernel();
92025 sock_diag_handlers[hndl->family] = hndl;
92026 + pax_close_kernel();
92027 + }
92028 mutex_unlock(&sock_diag_table_mutex);
92029
92030 return err;
92031 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
92032
92033 mutex_lock(&sock_diag_table_mutex);
92034 BUG_ON(sock_diag_handlers[family] != hnld);
92035 + pax_open_kernel();
92036 sock_diag_handlers[family] = NULL;
92037 + pax_close_kernel();
92038 mutex_unlock(&sock_diag_table_mutex);
92039 }
92040 EXPORT_SYMBOL_GPL(sock_diag_unregister);
92041 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
92042 index 31107ab..ae03d5a 100644
92043 --- a/net/core/sysctl_net_core.c
92044 +++ b/net/core/sysctl_net_core.c
92045 @@ -31,7 +31,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
92046 {
92047 unsigned int orig_size, size;
92048 int ret, i;
92049 - struct ctl_table tmp = {
92050 + ctl_table_no_const tmp = {
92051 .data = &size,
92052 .maxlen = sizeof(size),
92053 .mode = table->mode
92054 @@ -350,13 +350,12 @@ static struct ctl_table netns_core_table[] = {
92055
92056 static __net_init int sysctl_core_net_init(struct net *net)
92057 {
92058 - struct ctl_table *tbl;
92059 + ctl_table_no_const *tbl = NULL;
92060
92061 net->core.sysctl_somaxconn = SOMAXCONN;
92062
92063 - tbl = netns_core_table;
92064 if (!net_eq(net, &init_net)) {
92065 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
92066 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
92067 if (tbl == NULL)
92068 goto err_dup;
92069
92070 @@ -366,17 +365,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
92071 if (net->user_ns != &init_user_ns) {
92072 tbl[0].procname = NULL;
92073 }
92074 - }
92075 -
92076 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92077 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92078 + } else
92079 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
92080 if (net->core.sysctl_hdr == NULL)
92081 goto err_reg;
92082
92083 return 0;
92084
92085 err_reg:
92086 - if (tbl != netns_core_table)
92087 - kfree(tbl);
92088 + kfree(tbl);
92089 err_dup:
92090 return -ENOMEM;
92091 }
92092 @@ -391,7 +389,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
92093 kfree(tbl);
92094 }
92095
92096 -static __net_initdata struct pernet_operations sysctl_core_ops = {
92097 +static __net_initconst struct pernet_operations sysctl_core_ops = {
92098 .init = sysctl_core_net_init,
92099 .exit = sysctl_core_net_exit,
92100 };
92101 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
92102 index dd4d506..fb2fb87 100644
92103 --- a/net/decnet/af_decnet.c
92104 +++ b/net/decnet/af_decnet.c
92105 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
92106 .sysctl_rmem = sysctl_decnet_rmem,
92107 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
92108 .obj_size = sizeof(struct dn_sock),
92109 + .slab_flags = SLAB_USERCOPY,
92110 };
92111
92112 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
92113 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
92114 index 5325b54..a0d4d69 100644
92115 --- a/net/decnet/sysctl_net_decnet.c
92116 +++ b/net/decnet/sysctl_net_decnet.c
92117 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
92118
92119 if (len > *lenp) len = *lenp;
92120
92121 - if (copy_to_user(buffer, addr, len))
92122 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
92123 return -EFAULT;
92124
92125 *lenp = len;
92126 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
92127
92128 if (len > *lenp) len = *lenp;
92129
92130 - if (copy_to_user(buffer, devname, len))
92131 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
92132 return -EFAULT;
92133
92134 *lenp = len;
92135 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
92136 index 3b9d5f2..d7015c6 100644
92137 --- a/net/ieee802154/6lowpan.c
92138 +++ b/net/ieee802154/6lowpan.c
92139 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
92140 hc06_ptr += 3;
92141 } else {
92142 /* compress nothing */
92143 - memcpy(hc06_ptr, &hdr, 4);
92144 + memcpy(hc06_ptr, hdr, 4);
92145 /* replace the top byte with new ECN | DSCP format */
92146 *hc06_ptr = tmp;
92147 hc06_ptr += 4;
92148 diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c
92149 index 581a595..1865fdf 100644
92150 --- a/net/ieee802154/dgram.c
92151 +++ b/net/ieee802154/dgram.c
92152 @@ -315,9 +315,8 @@ static int dgram_recvmsg(struct kiocb *iocb, struct sock *sk,
92153 if (saddr) {
92154 saddr->family = AF_IEEE802154;
92155 saddr->addr = mac_cb(skb)->sa;
92156 - }
92157 - if (addr_len)
92158 *addr_len = sizeof(*saddr);
92159 + }
92160
92161 if (flags & MSG_TRUNC)
92162 copied = skb->len;
92163 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
92164 index dd6b523..dfe558f 100644
92165 --- a/net/ipv4/af_inet.c
92166 +++ b/net/ipv4/af_inet.c
92167 @@ -1687,13 +1687,9 @@ static int __init inet_init(void)
92168
92169 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
92170
92171 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
92172 - if (!sysctl_local_reserved_ports)
92173 - goto out;
92174 -
92175 rc = proto_register(&tcp_prot, 1);
92176 if (rc)
92177 - goto out_free_reserved_ports;
92178 + goto out;
92179
92180 rc = proto_register(&udp_prot, 1);
92181 if (rc)
92182 @@ -1802,8 +1798,6 @@ out_unregister_udp_proto:
92183 proto_unregister(&udp_prot);
92184 out_unregister_tcp_proto:
92185 proto_unregister(&tcp_prot);
92186 -out_free_reserved_ports:
92187 - kfree(sysctl_local_reserved_ports);
92188 goto out;
92189 }
92190
92191 diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
92192 index b28e863..19e3637 100644
92193 --- a/net/ipv4/datagram.c
92194 +++ b/net/ipv4/datagram.c
92195 @@ -57,7 +57,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
92196 if (IS_ERR(rt)) {
92197 err = PTR_ERR(rt);
92198 if (err == -ENETUNREACH)
92199 - IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
92200 + IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
92201 goto out;
92202 }
92203
92204 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
92205 index 34ca6d5..b6421e8 100644
92206 --- a/net/ipv4/devinet.c
92207 +++ b/net/ipv4/devinet.c
92208 @@ -1532,7 +1532,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
92209 idx = 0;
92210 head = &net->dev_index_head[h];
92211 rcu_read_lock();
92212 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92213 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92214 net->dev_base_seq;
92215 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92216 if (idx < s_idx)
92217 @@ -1843,7 +1843,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
92218 idx = 0;
92219 head = &net->dev_index_head[h];
92220 rcu_read_lock();
92221 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92222 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92223 net->dev_base_seq;
92224 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92225 if (idx < s_idx)
92226 @@ -2068,7 +2068,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
92227 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
92228 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
92229
92230 -static struct devinet_sysctl_table {
92231 +static const struct devinet_sysctl_table {
92232 struct ctl_table_header *sysctl_header;
92233 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
92234 } devinet_sysctl = {
92235 @@ -2186,7 +2186,7 @@ static __net_init int devinet_init_net(struct net *net)
92236 int err;
92237 struct ipv4_devconf *all, *dflt;
92238 #ifdef CONFIG_SYSCTL
92239 - struct ctl_table *tbl = ctl_forward_entry;
92240 + ctl_table_no_const *tbl = NULL;
92241 struct ctl_table_header *forw_hdr;
92242 #endif
92243
92244 @@ -2204,7 +2204,7 @@ static __net_init int devinet_init_net(struct net *net)
92245 goto err_alloc_dflt;
92246
92247 #ifdef CONFIG_SYSCTL
92248 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
92249 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
92250 if (tbl == NULL)
92251 goto err_alloc_ctl;
92252
92253 @@ -2224,7 +2224,10 @@ static __net_init int devinet_init_net(struct net *net)
92254 goto err_reg_dflt;
92255
92256 err = -ENOMEM;
92257 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92258 + if (!net_eq(net, &init_net))
92259 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92260 + else
92261 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
92262 if (forw_hdr == NULL)
92263 goto err_reg_ctl;
92264 net->ipv4.forw_hdr = forw_hdr;
92265 @@ -2240,8 +2243,7 @@ err_reg_ctl:
92266 err_reg_dflt:
92267 __devinet_sysctl_unregister(all);
92268 err_reg_all:
92269 - if (tbl != ctl_forward_entry)
92270 - kfree(tbl);
92271 + kfree(tbl);
92272 err_alloc_ctl:
92273 #endif
92274 if (dflt != &ipv4_devconf_dflt)
92275 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
92276 index b3f627a..b0f3e99 100644
92277 --- a/net/ipv4/fib_frontend.c
92278 +++ b/net/ipv4/fib_frontend.c
92279 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
92280 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92281 fib_sync_up(dev);
92282 #endif
92283 - atomic_inc(&net->ipv4.dev_addr_genid);
92284 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92285 rt_cache_flush(dev_net(dev));
92286 break;
92287 case NETDEV_DOWN:
92288 fib_del_ifaddr(ifa, NULL);
92289 - atomic_inc(&net->ipv4.dev_addr_genid);
92290 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92291 if (ifa->ifa_dev->ifa_list == NULL) {
92292 /* Last address was deleted from this interface.
92293 * Disable IP.
92294 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
92295 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92296 fib_sync_up(dev);
92297 #endif
92298 - atomic_inc(&net->ipv4.dev_addr_genid);
92299 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92300 rt_cache_flush(net);
92301 break;
92302 case NETDEV_DOWN:
92303 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
92304 index d5dbca5..6251d5f 100644
92305 --- a/net/ipv4/fib_semantics.c
92306 +++ b/net/ipv4/fib_semantics.c
92307 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
92308 nh->nh_saddr = inet_select_addr(nh->nh_dev,
92309 nh->nh_gw,
92310 nh->nh_parent->fib_scope);
92311 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
92312 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
92313
92314 return nh->nh_saddr;
92315 }
92316 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
92317 index 6acb541..9ea617d 100644
92318 --- a/net/ipv4/inet_connection_sock.c
92319 +++ b/net/ipv4/inet_connection_sock.c
92320 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
92321 .range = { 32768, 61000 },
92322 };
92323
92324 -unsigned long *sysctl_local_reserved_ports;
92325 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
92326 EXPORT_SYMBOL(sysctl_local_reserved_ports);
92327
92328 void inet_get_local_port_range(int *low, int *high)
92329 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
92330 index 96da9c7..b956690 100644
92331 --- a/net/ipv4/inet_hashtables.c
92332 +++ b/net/ipv4/inet_hashtables.c
92333 @@ -18,12 +18,15 @@
92334 #include <linux/sched.h>
92335 #include <linux/slab.h>
92336 #include <linux/wait.h>
92337 +#include <linux/security.h>
92338
92339 #include <net/inet_connection_sock.h>
92340 #include <net/inet_hashtables.h>
92341 #include <net/secure_seq.h>
92342 #include <net/ip.h>
92343
92344 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
92345 +
92346 /*
92347 * Allocate and initialize a new local port bind bucket.
92348 * The bindhash mutex for snum's hash chain must be held here.
92349 @@ -554,6 +557,8 @@ ok:
92350 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
92351 spin_unlock(&head->lock);
92352
92353 + gr_update_task_in_ip_table(current, inet_sk(sk));
92354 +
92355 if (tw) {
92356 inet_twsk_deschedule(tw, death_row);
92357 while (twrefcnt) {
92358 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
92359 index 33d5537..da337a4 100644
92360 --- a/net/ipv4/inetpeer.c
92361 +++ b/net/ipv4/inetpeer.c
92362 @@ -503,8 +503,8 @@ relookup:
92363 if (p) {
92364 p->daddr = *daddr;
92365 atomic_set(&p->refcnt, 1);
92366 - atomic_set(&p->rid, 0);
92367 - atomic_set(&p->ip_id_count,
92368 + atomic_set_unchecked(&p->rid, 0);
92369 + atomic_set_unchecked(&p->ip_id_count,
92370 (daddr->family == AF_INET) ?
92371 secure_ip_id(daddr->addr.a4) :
92372 secure_ipv6_id(daddr->addr.a6));
92373 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
92374 index b66910a..cfe416e 100644
92375 --- a/net/ipv4/ip_fragment.c
92376 +++ b/net/ipv4/ip_fragment.c
92377 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
92378 return 0;
92379
92380 start = qp->rid;
92381 - end = atomic_inc_return(&peer->rid);
92382 + end = atomic_inc_return_unchecked(&peer->rid);
92383 qp->rid = end;
92384
92385 rc = qp->q.fragments && (end - start) > max;
92386 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
92387
92388 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92389 {
92390 - struct ctl_table *table;
92391 + ctl_table_no_const *table = NULL;
92392 struct ctl_table_header *hdr;
92393
92394 - table = ip4_frags_ns_ctl_table;
92395 if (!net_eq(net, &init_net)) {
92396 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92397 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92398 if (table == NULL)
92399 goto err_alloc;
92400
92401 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92402 /* Don't export sysctls to unprivileged users */
92403 if (net->user_ns != &init_user_ns)
92404 table[0].procname = NULL;
92405 - }
92406 + hdr = register_net_sysctl(net, "net/ipv4", table);
92407 + } else
92408 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
92409
92410 - hdr = register_net_sysctl(net, "net/ipv4", table);
92411 if (hdr == NULL)
92412 goto err_reg;
92413
92414 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92415 return 0;
92416
92417 err_reg:
92418 - if (!net_eq(net, &init_net))
92419 - kfree(table);
92420 + kfree(table);
92421 err_alloc:
92422 return -ENOMEM;
92423 }
92424 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
92425 index 8d6939e..19d0a95 100644
92426 --- a/net/ipv4/ip_gre.c
92427 +++ b/net/ipv4/ip_gre.c
92428 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
92429 module_param(log_ecn_error, bool, 0644);
92430 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92431
92432 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
92433 +static struct rtnl_link_ops ipgre_link_ops;
92434 static int ipgre_tunnel_init(struct net_device *dev);
92435
92436 static int ipgre_net_id __read_mostly;
92437 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
92438 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
92439 };
92440
92441 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92442 +static struct rtnl_link_ops ipgre_link_ops = {
92443 .kind = "gre",
92444 .maxtype = IFLA_GRE_MAX,
92445 .policy = ipgre_policy,
92446 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92447 .fill_info = ipgre_fill_info,
92448 };
92449
92450 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
92451 +static struct rtnl_link_ops ipgre_tap_ops = {
92452 .kind = "gretap",
92453 .maxtype = IFLA_GRE_MAX,
92454 .policy = ipgre_policy,
92455 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
92456 index d9c4f11..02b82dbc 100644
92457 --- a/net/ipv4/ip_sockglue.c
92458 +++ b/net/ipv4/ip_sockglue.c
92459 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92460 len = min_t(unsigned int, len, opt->optlen);
92461 if (put_user(len, optlen))
92462 return -EFAULT;
92463 - if (copy_to_user(optval, opt->__data, len))
92464 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
92465 + copy_to_user(optval, opt->__data, len))
92466 return -EFAULT;
92467 return 0;
92468 }
92469 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92470 if (sk->sk_type != SOCK_STREAM)
92471 return -ENOPROTOOPT;
92472
92473 - msg.msg_control = optval;
92474 + msg.msg_control = (void __force_kernel *)optval;
92475 msg.msg_controllen = len;
92476 msg.msg_flags = flags;
92477
92478 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
92479 index 0656041..d6ecb60 100644
92480 --- a/net/ipv4/ip_vti.c
92481 +++ b/net/ipv4/ip_vti.c
92482 @@ -47,7 +47,7 @@
92483 #define HASH_SIZE 16
92484 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
92485
92486 -static struct rtnl_link_ops vti_link_ops __read_mostly;
92487 +static struct rtnl_link_ops vti_link_ops;
92488
92489 static int vti_net_id __read_mostly;
92490 struct vti_net {
92491 @@ -848,7 +848,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
92492 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
92493 };
92494
92495 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
92496 +static struct rtnl_link_ops vti_link_ops = {
92497 .kind = "vti",
92498 .maxtype = IFLA_VTI_MAX,
92499 .policy = vti_policy,
92500 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
92501 index efa1138..20dbba0 100644
92502 --- a/net/ipv4/ipconfig.c
92503 +++ b/net/ipv4/ipconfig.c
92504 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
92505
92506 mm_segment_t oldfs = get_fs();
92507 set_fs(get_ds());
92508 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92509 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92510 set_fs(oldfs);
92511 return res;
92512 }
92513 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
92514
92515 mm_segment_t oldfs = get_fs();
92516 set_fs(get_ds());
92517 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92518 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92519 set_fs(oldfs);
92520 return res;
92521 }
92522 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
92523
92524 mm_segment_t oldfs = get_fs();
92525 set_fs(get_ds());
92526 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
92527 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
92528 set_fs(oldfs);
92529 return res;
92530 }
92531 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
92532 index b3ac3c3..ec6bd95 100644
92533 --- a/net/ipv4/ipip.c
92534 +++ b/net/ipv4/ipip.c
92535 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92536 static int ipip_net_id __read_mostly;
92537
92538 static int ipip_tunnel_init(struct net_device *dev);
92539 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
92540 +static struct rtnl_link_ops ipip_link_ops;
92541
92542 static int ipip_err(struct sk_buff *skb, u32 info)
92543 {
92544 @@ -409,7 +409,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
92545 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
92546 };
92547
92548 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
92549 +static struct rtnl_link_ops ipip_link_ops = {
92550 .kind = "ipip",
92551 .maxtype = IFLA_IPTUN_MAX,
92552 .policy = ipip_policy,
92553 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
92554 index 85a4f21..1beb1f5 100644
92555 --- a/net/ipv4/netfilter/arp_tables.c
92556 +++ b/net/ipv4/netfilter/arp_tables.c
92557 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
92558 #endif
92559
92560 static int get_info(struct net *net, void __user *user,
92561 - const int *len, int compat)
92562 + int len, int compat)
92563 {
92564 char name[XT_TABLE_MAXNAMELEN];
92565 struct xt_table *t;
92566 int ret;
92567
92568 - if (*len != sizeof(struct arpt_getinfo)) {
92569 - duprintf("length %u != %Zu\n", *len,
92570 + if (len != sizeof(struct arpt_getinfo)) {
92571 + duprintf("length %u != %Zu\n", len,
92572 sizeof(struct arpt_getinfo));
92573 return -EINVAL;
92574 }
92575 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
92576 info.size = private->size;
92577 strcpy(info.name, name);
92578
92579 - if (copy_to_user(user, &info, *len) != 0)
92580 + if (copy_to_user(user, &info, len) != 0)
92581 ret = -EFAULT;
92582 else
92583 ret = 0;
92584 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
92585
92586 switch (cmd) {
92587 case ARPT_SO_GET_INFO:
92588 - ret = get_info(sock_net(sk), user, len, 1);
92589 + ret = get_info(sock_net(sk), user, *len, 1);
92590 break;
92591 case ARPT_SO_GET_ENTRIES:
92592 ret = compat_get_entries(sock_net(sk), user, len);
92593 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
92594
92595 switch (cmd) {
92596 case ARPT_SO_GET_INFO:
92597 - ret = get_info(sock_net(sk), user, len, 0);
92598 + ret = get_info(sock_net(sk), user, *len, 0);
92599 break;
92600
92601 case ARPT_SO_GET_ENTRIES:
92602 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
92603 index d23118d..6ad7277 100644
92604 --- a/net/ipv4/netfilter/ip_tables.c
92605 +++ b/net/ipv4/netfilter/ip_tables.c
92606 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
92607 #endif
92608
92609 static int get_info(struct net *net, void __user *user,
92610 - const int *len, int compat)
92611 + int len, int compat)
92612 {
92613 char name[XT_TABLE_MAXNAMELEN];
92614 struct xt_table *t;
92615 int ret;
92616
92617 - if (*len != sizeof(struct ipt_getinfo)) {
92618 - duprintf("length %u != %zu\n", *len,
92619 + if (len != sizeof(struct ipt_getinfo)) {
92620 + duprintf("length %u != %zu\n", len,
92621 sizeof(struct ipt_getinfo));
92622 return -EINVAL;
92623 }
92624 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
92625 info.size = private->size;
92626 strcpy(info.name, name);
92627
92628 - if (copy_to_user(user, &info, *len) != 0)
92629 + if (copy_to_user(user, &info, len) != 0)
92630 ret = -EFAULT;
92631 else
92632 ret = 0;
92633 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92634
92635 switch (cmd) {
92636 case IPT_SO_GET_INFO:
92637 - ret = get_info(sock_net(sk), user, len, 1);
92638 + ret = get_info(sock_net(sk), user, *len, 1);
92639 break;
92640 case IPT_SO_GET_ENTRIES:
92641 ret = compat_get_entries(sock_net(sk), user, len);
92642 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92643
92644 switch (cmd) {
92645 case IPT_SO_GET_INFO:
92646 - ret = get_info(sock_net(sk), user, len, 0);
92647 + ret = get_info(sock_net(sk), user, *len, 0);
92648 break;
92649
92650 case IPT_SO_GET_ENTRIES:
92651 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
92652 index cbc2215..9cb993c 100644
92653 --- a/net/ipv4/netfilter/ipt_ULOG.c
92654 +++ b/net/ipv4/netfilter/ipt_ULOG.c
92655 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
92656 ub->qlen++;
92657
92658 pm = nlmsg_data(nlh);
92659 + memset(pm, 0, sizeof(*pm));
92660
92661 /* We might not have a timestamp, get one */
92662 if (skb->tstamp.tv64 == 0)
92663 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
92664 }
92665 else if (loginfo->prefix[0] != '\0')
92666 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
92667 - else
92668 - *(pm->prefix) = '\0';
92669
92670 if (in && in->hard_header_len > 0 &&
92671 skb->mac_header != skb->network_header &&
92672 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
92673
92674 if (in)
92675 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
92676 - else
92677 - pm->indev_name[0] = '\0';
92678
92679 if (out)
92680 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
92681 - else
92682 - pm->outdev_name[0] = '\0';
92683
92684 /* copy_len <= skb->len, so can't fail. */
92685 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
92686 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
92687 index 746427c..a4b35c2 100644
92688 --- a/net/ipv4/ping.c
92689 +++ b/net/ipv4/ping.c
92690 @@ -55,7 +55,7 @@
92691
92692
92693 struct ping_table ping_table;
92694 -struct pingv6_ops pingv6_ops;
92695 +struct pingv6_ops *pingv6_ops;
92696 EXPORT_SYMBOL_GPL(pingv6_ops);
92697
92698 static u16 ping_port_rover;
92699 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
92700 return -ENODEV;
92701 }
92702 }
92703 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
92704 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
92705 scoped);
92706 rcu_read_unlock();
92707
92708 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92709 }
92710 #if IS_ENABLED(CONFIG_IPV6)
92711 } else if (skb->protocol == htons(ETH_P_IPV6)) {
92712 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
92713 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
92714 #endif
92715 }
92716
92717 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92718 info, (u8 *)icmph);
92719 #if IS_ENABLED(CONFIG_IPV6)
92720 } else if (family == AF_INET6) {
92721 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
92722 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
92723 info, (u8 *)icmph);
92724 #endif
92725 }
92726 @@ -827,8 +827,6 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92727 {
92728 struct inet_sock *isk = inet_sk(sk);
92729 int family = sk->sk_family;
92730 - struct sockaddr_in *sin;
92731 - struct sockaddr_in6 *sin6;
92732 struct sk_buff *skb;
92733 int copied, err;
92734
92735 @@ -838,19 +836,12 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92736 if (flags & MSG_OOB)
92737 goto out;
92738
92739 - if (addr_len) {
92740 - if (family == AF_INET)
92741 - *addr_len = sizeof(*sin);
92742 - else if (family == AF_INET6 && addr_len)
92743 - *addr_len = sizeof(*sin6);
92744 - }
92745 -
92746 if (flags & MSG_ERRQUEUE) {
92747 if (family == AF_INET) {
92748 return ip_recv_error(sk, msg, len);
92749 #if IS_ENABLED(CONFIG_IPV6)
92750 } else if (family == AF_INET6) {
92751 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
92752 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
92753 #endif
92754 }
92755 }
92756 @@ -874,11 +865,15 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92757
92758 /* Copy the address and add cmsg data. */
92759 if (family == AF_INET) {
92760 - sin = (struct sockaddr_in *) msg->msg_name;
92761 - sin->sin_family = AF_INET;
92762 - sin->sin_port = 0 /* skb->h.uh->source */;
92763 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
92764 - memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
92765 + struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
92766 +
92767 + if (sin) {
92768 + sin->sin_family = AF_INET;
92769 + sin->sin_port = 0 /* skb->h.uh->source */;
92770 + sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
92771 + memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
92772 + *addr_len = sizeof(*sin);
92773 + }
92774
92775 if (isk->cmsg_flags)
92776 ip_cmsg_recv(msg, skb);
92777 @@ -887,20 +882,24 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92778 } else if (family == AF_INET6) {
92779 struct ipv6_pinfo *np = inet6_sk(sk);
92780 struct ipv6hdr *ip6 = ipv6_hdr(skb);
92781 - sin6 = (struct sockaddr_in6 *) msg->msg_name;
92782 - sin6->sin6_family = AF_INET6;
92783 - sin6->sin6_port = 0;
92784 - sin6->sin6_addr = ip6->saddr;
92785 + struct sockaddr_in6 *sin6 =
92786 + (struct sockaddr_in6 *)msg->msg_name;
92787
92788 - sin6->sin6_flowinfo = 0;
92789 - if (np->sndflow)
92790 - sin6->sin6_flowinfo = ip6_flowinfo(ip6);
92791 -
92792 - sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr,
92793 - IP6CB(skb)->iif);
92794 + if (sin6) {
92795 + sin6->sin6_family = AF_INET6;
92796 + sin6->sin6_port = 0;
92797 + sin6->sin6_addr = ip6->saddr;
92798 + sin6->sin6_flowinfo = 0;
92799 + if (np->sndflow)
92800 + sin6->sin6_flowinfo = ip6_flowinfo(ip6);
92801 + sin6->sin6_scope_id =
92802 + ipv6_iface_scope_id(&sin6->sin6_addr,
92803 + IP6CB(skb)->iif);
92804 + *addr_len = sizeof(*sin6);
92805 + }
92806
92807 if (inet6_sk(sk)->rxopt.all)
92808 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
92809 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
92810 #endif
92811 } else {
92812 BUG();
92813 @@ -1090,7 +1089,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
92814 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
92815 0, sock_i_ino(sp),
92816 atomic_read(&sp->sk_refcnt), sp,
92817 - atomic_read(&sp->sk_drops), len);
92818 + atomic_read_unchecked(&sp->sk_drops), len);
92819 }
92820
92821 static int ping_v4_seq_show(struct seq_file *seq, void *v)
92822 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
92823 index 6fb2337..0442cca 100644
92824 --- a/net/ipv4/raw.c
92825 +++ b/net/ipv4/raw.c
92826 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
92827 int raw_rcv(struct sock *sk, struct sk_buff *skb)
92828 {
92829 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
92830 - atomic_inc(&sk->sk_drops);
92831 + atomic_inc_unchecked(&sk->sk_drops);
92832 kfree_skb(skb);
92833 return NET_RX_DROP;
92834 }
92835 @@ -692,9 +692,6 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92836 if (flags & MSG_OOB)
92837 goto out;
92838
92839 - if (addr_len)
92840 - *addr_len = sizeof(*sin);
92841 -
92842 if (flags & MSG_ERRQUEUE) {
92843 err = ip_recv_error(sk, msg, len);
92844 goto out;
92845 @@ -722,6 +719,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92846 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
92847 sin->sin_port = 0;
92848 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
92849 + *addr_len = sizeof(*sin);
92850 }
92851 if (inet->cmsg_flags)
92852 ip_cmsg_recv(msg, skb);
92853 @@ -746,16 +744,20 @@ static int raw_init(struct sock *sk)
92854
92855 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
92856 {
92857 + struct icmp_filter filter;
92858 +
92859 if (optlen > sizeof(struct icmp_filter))
92860 optlen = sizeof(struct icmp_filter);
92861 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
92862 + if (copy_from_user(&filter, optval, optlen))
92863 return -EFAULT;
92864 + raw_sk(sk)->filter = filter;
92865 return 0;
92866 }
92867
92868 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
92869 {
92870 int len, ret = -EFAULT;
92871 + struct icmp_filter filter;
92872
92873 if (get_user(len, optlen))
92874 goto out;
92875 @@ -765,8 +767,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
92876 if (len > sizeof(struct icmp_filter))
92877 len = sizeof(struct icmp_filter);
92878 ret = -EFAULT;
92879 - if (put_user(len, optlen) ||
92880 - copy_to_user(optval, &raw_sk(sk)->filter, len))
92881 + filter = raw_sk(sk)->filter;
92882 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
92883 goto out;
92884 ret = 0;
92885 out: return ret;
92886 @@ -995,7 +997,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
92887 0, 0L, 0,
92888 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
92889 0, sock_i_ino(sp),
92890 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
92891 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
92892 }
92893
92894 static int raw_seq_show(struct seq_file *seq, void *v)
92895 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
92896 index 2de16d9..da558c7 100644
92897 --- a/net/ipv4/route.c
92898 +++ b/net/ipv4/route.c
92899 @@ -2615,34 +2615,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
92900 .maxlen = sizeof(int),
92901 .mode = 0200,
92902 .proc_handler = ipv4_sysctl_rtcache_flush,
92903 + .extra1 = &init_net,
92904 },
92905 { },
92906 };
92907
92908 static __net_init int sysctl_route_net_init(struct net *net)
92909 {
92910 - struct ctl_table *tbl;
92911 + ctl_table_no_const *tbl = NULL;
92912
92913 - tbl = ipv4_route_flush_table;
92914 if (!net_eq(net, &init_net)) {
92915 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92916 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92917 if (tbl == NULL)
92918 goto err_dup;
92919
92920 /* Don't export sysctls to unprivileged users */
92921 if (net->user_ns != &init_user_ns)
92922 tbl[0].procname = NULL;
92923 - }
92924 - tbl[0].extra1 = net;
92925 + tbl[0].extra1 = net;
92926 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92927 + } else
92928 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
92929
92930 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92931 if (net->ipv4.route_hdr == NULL)
92932 goto err_reg;
92933 return 0;
92934
92935 err_reg:
92936 - if (tbl != ipv4_route_flush_table)
92937 - kfree(tbl);
92938 + kfree(tbl);
92939 err_dup:
92940 return -ENOMEM;
92941 }
92942 @@ -2665,8 +2665,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
92943
92944 static __net_init int rt_genid_init(struct net *net)
92945 {
92946 - atomic_set(&net->rt_genid, 0);
92947 - atomic_set(&net->fnhe_genid, 0);
92948 + atomic_set_unchecked(&net->rt_genid, 0);
92949 + atomic_set_unchecked(&net->fnhe_genid, 0);
92950 get_random_bytes(&net->ipv4.dev_addr_genid,
92951 sizeof(net->ipv4.dev_addr_genid));
92952 return 0;
92953 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
92954 index 6900b8b..7832c6b 100644
92955 --- a/net/ipv4/sysctl_net_ipv4.c
92956 +++ b/net/ipv4/sysctl_net_ipv4.c
92957 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
92958 {
92959 int ret;
92960 int range[2];
92961 - struct ctl_table tmp = {
92962 + ctl_table_no_const tmp = {
92963 .data = &range,
92964 .maxlen = sizeof(range),
92965 .mode = table->mode,
92966 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
92967 int ret;
92968 gid_t urange[2];
92969 kgid_t low, high;
92970 - struct ctl_table tmp = {
92971 + ctl_table_no_const tmp = {
92972 .data = &urange,
92973 .maxlen = sizeof(urange),
92974 .mode = table->mode,
92975 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
92976 void __user *buffer, size_t *lenp, loff_t *ppos)
92977 {
92978 char val[TCP_CA_NAME_MAX];
92979 - struct ctl_table tbl = {
92980 + ctl_table_no_const tbl = {
92981 .data = val,
92982 .maxlen = TCP_CA_NAME_MAX,
92983 };
92984 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
92985 void __user *buffer, size_t *lenp,
92986 loff_t *ppos)
92987 {
92988 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
92989 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
92990 int ret;
92991
92992 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92993 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
92994 void __user *buffer, size_t *lenp,
92995 loff_t *ppos)
92996 {
92997 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
92998 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
92999 int ret;
93000
93001 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
93002 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
93003 struct mem_cgroup *memcg;
93004 #endif
93005
93006 - struct ctl_table tmp = {
93007 + ctl_table_no_const tmp = {
93008 .data = &vec,
93009 .maxlen = sizeof(vec),
93010 .mode = ctl->mode,
93011 };
93012
93013 if (!write) {
93014 - ctl->data = &net->ipv4.sysctl_tcp_mem;
93015 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
93016 + ctl_table_no_const tcp_mem = *ctl;
93017 +
93018 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
93019 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
93020 }
93021
93022 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
93023 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
93024 void __user *buffer, size_t *lenp,
93025 loff_t *ppos)
93026 {
93027 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93028 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93029 struct tcp_fastopen_context *ctxt;
93030 int ret;
93031 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
93032 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
93033 },
93034 {
93035 .procname = "ip_local_reserved_ports",
93036 - .data = NULL, /* initialized in sysctl_ipv4_init */
93037 + .data = sysctl_local_reserved_ports,
93038 .maxlen = 65536,
93039 .mode = 0644,
93040 .proc_handler = proc_do_large_bitmap,
93041 @@ -857,11 +859,10 @@ static struct ctl_table ipv4_net_table[] = {
93042
93043 static __net_init int ipv4_sysctl_init_net(struct net *net)
93044 {
93045 - struct ctl_table *table;
93046 + ctl_table_no_const *table = NULL;
93047
93048 - table = ipv4_net_table;
93049 if (!net_eq(net, &init_net)) {
93050 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
93051 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
93052 if (table == NULL)
93053 goto err_alloc;
93054
93055 @@ -896,15 +897,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
93056
93057 tcp_init_mem(net);
93058
93059 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93060 + if (!net_eq(net, &init_net))
93061 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93062 + else
93063 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
93064 if (net->ipv4.ipv4_hdr == NULL)
93065 goto err_reg;
93066
93067 return 0;
93068
93069 err_reg:
93070 - if (!net_eq(net, &init_net))
93071 - kfree(table);
93072 + kfree(table);
93073 err_alloc:
93074 return -ENOMEM;
93075 }
93076 @@ -926,16 +929,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
93077 static __init int sysctl_ipv4_init(void)
93078 {
93079 struct ctl_table_header *hdr;
93080 - struct ctl_table *i;
93081 -
93082 - for (i = ipv4_table; i->procname; i++) {
93083 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
93084 - i->data = sysctl_local_reserved_ports;
93085 - break;
93086 - }
93087 - }
93088 - if (!i->procname)
93089 - return -EINVAL;
93090
93091 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
93092 if (hdr == NULL)
93093 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
93094 index 723951a..61cf1cc 100644
93095 --- a/net/ipv4/tcp_input.c
93096 +++ b/net/ipv4/tcp_input.c
93097 @@ -4412,7 +4412,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
93098 * simplifies code)
93099 */
93100 static void
93101 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93102 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93103 struct sk_buff *head, struct sk_buff *tail,
93104 u32 start, u32 end)
93105 {
93106 @@ -5498,6 +5498,7 @@ discard:
93107 tcp_paws_reject(&tp->rx_opt, 0))
93108 goto discard_and_undo;
93109
93110 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
93111 if (th->syn) {
93112 /* We see SYN without ACK. It is attempt of
93113 * simultaneous connect with crossed SYNs.
93114 @@ -5548,6 +5549,7 @@ discard:
93115 goto discard;
93116 #endif
93117 }
93118 +#endif
93119 /* "fifth, if neither of the SYN or RST bits is set then
93120 * drop the segment and return."
93121 */
93122 @@ -5593,7 +5595,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
93123 goto discard;
93124
93125 if (th->syn) {
93126 - if (th->fin)
93127 + if (th->fin || th->urg || th->psh)
93128 goto discard;
93129 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
93130 return 1;
93131 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
93132 index b299da5..097db06 100644
93133 --- a/net/ipv4/tcp_ipv4.c
93134 +++ b/net/ipv4/tcp_ipv4.c
93135 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
93136 EXPORT_SYMBOL(sysctl_tcp_low_latency);
93137
93138
93139 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93140 +extern int grsec_enable_blackhole;
93141 +#endif
93142 +
93143 #ifdef CONFIG_TCP_MD5SIG
93144 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
93145 __be32 daddr, __be32 saddr, const struct tcphdr *th);
93146 @@ -1830,6 +1834,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
93147 return 0;
93148
93149 reset:
93150 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93151 + if (!grsec_enable_blackhole)
93152 +#endif
93153 tcp_v4_send_reset(rsk, skb);
93154 discard:
93155 kfree_skb(skb);
93156 @@ -1975,12 +1982,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
93157 TCP_SKB_CB(skb)->sacked = 0;
93158
93159 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93160 - if (!sk)
93161 + if (!sk) {
93162 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93163 + ret = 1;
93164 +#endif
93165 goto no_tcp_socket;
93166 -
93167 + }
93168 process:
93169 - if (sk->sk_state == TCP_TIME_WAIT)
93170 + if (sk->sk_state == TCP_TIME_WAIT) {
93171 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93172 + ret = 2;
93173 +#endif
93174 goto do_time_wait;
93175 + }
93176
93177 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
93178 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93179 @@ -2034,6 +2048,10 @@ csum_error:
93180 bad_packet:
93181 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93182 } else {
93183 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93184 + if (!grsec_enable_blackhole || (ret == 1 &&
93185 + (skb->dev->flags & IFF_LOOPBACK)))
93186 +#endif
93187 tcp_v4_send_reset(NULL, skb);
93188 }
93189
93190 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
93191 index ab1c086..2a8d76b 100644
93192 --- a/net/ipv4/tcp_minisocks.c
93193 +++ b/net/ipv4/tcp_minisocks.c
93194 @@ -27,6 +27,10 @@
93195 #include <net/inet_common.h>
93196 #include <net/xfrm.h>
93197
93198 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93199 +extern int grsec_enable_blackhole;
93200 +#endif
93201 +
93202 int sysctl_tcp_syncookies __read_mostly = 1;
93203 EXPORT_SYMBOL(sysctl_tcp_syncookies);
93204
93205 @@ -715,7 +719,10 @@ embryonic_reset:
93206 * avoid becoming vulnerable to outside attack aiming at
93207 * resetting legit local connections.
93208 */
93209 - req->rsk_ops->send_reset(sk, skb);
93210 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93211 + if (!grsec_enable_blackhole)
93212 +#endif
93213 + req->rsk_ops->send_reset(sk, skb);
93214 } else if (fastopen) { /* received a valid RST pkt */
93215 reqsk_fastopen_remove(sk, req, true);
93216 tcp_reset(sk);
93217 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
93218 index d4943f6..e7a74a5 100644
93219 --- a/net/ipv4/tcp_probe.c
93220 +++ b/net/ipv4/tcp_probe.c
93221 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
93222 if (cnt + width >= len)
93223 break;
93224
93225 - if (copy_to_user(buf + cnt, tbuf, width))
93226 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
93227 return -EFAULT;
93228 cnt += width;
93229 }
93230 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
93231 index 4b85e6f..22f9ac9 100644
93232 --- a/net/ipv4/tcp_timer.c
93233 +++ b/net/ipv4/tcp_timer.c
93234 @@ -22,6 +22,10 @@
93235 #include <linux/gfp.h>
93236 #include <net/tcp.h>
93237
93238 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93239 +extern int grsec_lastack_retries;
93240 +#endif
93241 +
93242 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
93243 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
93244 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
93245 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
93246 }
93247 }
93248
93249 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93250 + if ((sk->sk_state == TCP_LAST_ACK) &&
93251 + (grsec_lastack_retries > 0) &&
93252 + (grsec_lastack_retries < retry_until))
93253 + retry_until = grsec_lastack_retries;
93254 +#endif
93255 +
93256 if (retransmits_timed_out(sk, retry_until,
93257 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
93258 /* Has it gone just too far? */
93259 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
93260 index 766e6ba..57db761 100644
93261 --- a/net/ipv4/udp.c
93262 +++ b/net/ipv4/udp.c
93263 @@ -87,6 +87,7 @@
93264 #include <linux/types.h>
93265 #include <linux/fcntl.h>
93266 #include <linux/module.h>
93267 +#include <linux/security.h>
93268 #include <linux/socket.h>
93269 #include <linux/sockios.h>
93270 #include <linux/igmp.h>
93271 @@ -112,6 +113,10 @@
93272 #include <net/busy_poll.h>
93273 #include "udp_impl.h"
93274
93275 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93276 +extern int grsec_enable_blackhole;
93277 +#endif
93278 +
93279 struct udp_table udp_table __read_mostly;
93280 EXPORT_SYMBOL(udp_table);
93281
93282 @@ -595,6 +600,9 @@ found:
93283 return s;
93284 }
93285
93286 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
93287 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
93288 +
93289 /*
93290 * This routine is called by the ICMP module when it gets some
93291 * sort of error condition. If err < 0 then the socket should
93292 @@ -891,9 +899,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93293 dport = usin->sin_port;
93294 if (dport == 0)
93295 return -EINVAL;
93296 +
93297 + err = gr_search_udp_sendmsg(sk, usin);
93298 + if (err)
93299 + return err;
93300 } else {
93301 if (sk->sk_state != TCP_ESTABLISHED)
93302 return -EDESTADDRREQ;
93303 +
93304 + err = gr_search_udp_sendmsg(sk, NULL);
93305 + if (err)
93306 + return err;
93307 +
93308 daddr = inet->inet_daddr;
93309 dport = inet->inet_dport;
93310 /* Open fast path for connected socket.
93311 @@ -1137,7 +1154,7 @@ static unsigned int first_packet_length(struct sock *sk)
93312 IS_UDPLITE(sk));
93313 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93314 IS_UDPLITE(sk));
93315 - atomic_inc(&sk->sk_drops);
93316 + atomic_inc_unchecked(&sk->sk_drops);
93317 __skb_unlink(skb, rcvq);
93318 __skb_queue_tail(&list_kill, skb);
93319 }
93320 @@ -1208,12 +1225,6 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93321 int is_udplite = IS_UDPLITE(sk);
93322 bool slow;
93323
93324 - /*
93325 - * Check any passed addresses
93326 - */
93327 - if (addr_len)
93328 - *addr_len = sizeof(*sin);
93329 -
93330 if (flags & MSG_ERRQUEUE)
93331 return ip_recv_error(sk, msg, len);
93332
93333 @@ -1223,6 +1234,10 @@ try_again:
93334 if (!skb)
93335 goto out;
93336
93337 + err = gr_search_udp_recvmsg(sk, skb);
93338 + if (err)
93339 + goto out_free;
93340 +
93341 ulen = skb->len - sizeof(struct udphdr);
93342 copied = len;
93343 if (copied > ulen)
93344 @@ -1256,7 +1271,7 @@ try_again:
93345 if (unlikely(err)) {
93346 trace_kfree_skb(skb, udp_recvmsg);
93347 if (!peeked) {
93348 - atomic_inc(&sk->sk_drops);
93349 + atomic_inc_unchecked(&sk->sk_drops);
93350 UDP_INC_STATS_USER(sock_net(sk),
93351 UDP_MIB_INERRORS, is_udplite);
93352 }
93353 @@ -1275,6 +1290,7 @@ try_again:
93354 sin->sin_port = udp_hdr(skb)->source;
93355 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
93356 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
93357 + *addr_len = sizeof(*sin);
93358 }
93359 if (inet->cmsg_flags)
93360 ip_cmsg_recv(msg, skb);
93361 @@ -1543,7 +1559,7 @@ csum_error:
93362 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93363 drop:
93364 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93365 - atomic_inc(&sk->sk_drops);
93366 + atomic_inc_unchecked(&sk->sk_drops);
93367 kfree_skb(skb);
93368 return -1;
93369 }
93370 @@ -1562,7 +1578,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93371 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93372
93373 if (!skb1) {
93374 - atomic_inc(&sk->sk_drops);
93375 + atomic_inc_unchecked(&sk->sk_drops);
93376 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93377 IS_UDPLITE(sk));
93378 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93379 @@ -1734,6 +1750,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93380 goto csum_error;
93381
93382 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93383 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93384 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93385 +#endif
93386 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
93387
93388 /*
93389 @@ -2166,7 +2185,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
93390 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93391 0, sock_i_ino(sp),
93392 atomic_read(&sp->sk_refcnt), sp,
93393 - atomic_read(&sp->sk_drops), len);
93394 + atomic_read_unchecked(&sp->sk_drops), len);
93395 }
93396
93397 int udp4_seq_show(struct seq_file *seq, void *v)
93398 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
93399 index 9a459be..c7bc04c 100644
93400 --- a/net/ipv4/xfrm4_policy.c
93401 +++ b/net/ipv4/xfrm4_policy.c
93402 @@ -181,11 +181,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
93403 fl4->flowi4_tos = iph->tos;
93404 }
93405
93406 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
93407 +static int xfrm4_garbage_collect(struct dst_ops *ops)
93408 {
93409 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
93410
93411 - xfrm4_policy_afinfo.garbage_collect(net);
93412 + xfrm_garbage_collect_deferred(net);
93413 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
93414 }
93415
93416 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
93417
93418 static int __net_init xfrm4_net_init(struct net *net)
93419 {
93420 - struct ctl_table *table;
93421 + ctl_table_no_const *table = NULL;
93422 struct ctl_table_header *hdr;
93423
93424 - table = xfrm4_policy_table;
93425 if (!net_eq(net, &init_net)) {
93426 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93427 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93428 if (!table)
93429 goto err_alloc;
93430
93431 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
93432 - }
93433 -
93434 - hdr = register_net_sysctl(net, "net/ipv4", table);
93435 + hdr = register_net_sysctl(net, "net/ipv4", table);
93436 + } else
93437 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
93438 if (!hdr)
93439 goto err_reg;
93440
93441 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
93442 return 0;
93443
93444 err_reg:
93445 - if (!net_eq(net, &init_net))
93446 - kfree(table);
93447 + kfree(table);
93448 err_alloc:
93449 return -ENOMEM;
93450 }
93451 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
93452 index 0f99f7b..9375cf5 100644
93453 --- a/net/ipv6/addrconf.c
93454 +++ b/net/ipv6/addrconf.c
93455 @@ -618,7 +618,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
93456 idx = 0;
93457 head = &net->dev_index_head[h];
93458 rcu_read_lock();
93459 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
93460 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
93461 net->dev_base_seq;
93462 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93463 if (idx < s_idx)
93464 @@ -2408,7 +2408,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
93465 p.iph.ihl = 5;
93466 p.iph.protocol = IPPROTO_IPV6;
93467 p.iph.ttl = 64;
93468 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
93469 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
93470
93471 if (ops->ndo_do_ioctl) {
93472 mm_segment_t oldfs = get_fs();
93473 @@ -4057,7 +4057,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
93474 s_ip_idx = ip_idx = cb->args[2];
93475
93476 rcu_read_lock();
93477 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93478 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93479 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
93480 idx = 0;
93481 head = &net->dev_index_head[h];
93482 @@ -4678,7 +4678,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93483 dst_free(&ifp->rt->dst);
93484 break;
93485 }
93486 - atomic_inc(&net->ipv6.dev_addr_genid);
93487 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
93488 }
93489
93490 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93491 @@ -4698,7 +4698,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
93492 int *valp = ctl->data;
93493 int val = *valp;
93494 loff_t pos = *ppos;
93495 - struct ctl_table lctl;
93496 + ctl_table_no_const lctl;
93497 int ret;
93498
93499 /*
93500 @@ -4783,7 +4783,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
93501 int *valp = ctl->data;
93502 int val = *valp;
93503 loff_t pos = *ppos;
93504 - struct ctl_table lctl;
93505 + ctl_table_no_const lctl;
93506 int ret;
93507
93508 /*
93509 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
93510 index 197e6f4..16d8396 100644
93511 --- a/net/ipv6/datagram.c
93512 +++ b/net/ipv6/datagram.c
93513 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
93514 0,
93515 sock_i_ino(sp),
93516 atomic_read(&sp->sk_refcnt), sp,
93517 - atomic_read(&sp->sk_drops));
93518 + atomic_read_unchecked(&sp->sk_drops));
93519 }
93520 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
93521 index 7cfc8d2..c5394b6 100644
93522 --- a/net/ipv6/icmp.c
93523 +++ b/net/ipv6/icmp.c
93524 @@ -989,7 +989,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
93525
93526 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
93527 {
93528 - struct ctl_table *table;
93529 + ctl_table_no_const *table;
93530
93531 table = kmemdup(ipv6_icmp_table_template,
93532 sizeof(ipv6_icmp_table_template),
93533 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
93534 index 8bc717b..76fbb5d 100644
93535 --- a/net/ipv6/ip6_gre.c
93536 +++ b/net/ipv6/ip6_gre.c
93537 @@ -74,7 +74,7 @@ struct ip6gre_net {
93538 struct net_device *fb_tunnel_dev;
93539 };
93540
93541 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
93542 +static struct rtnl_link_ops ip6gre_link_ops;
93543 static int ip6gre_tunnel_init(struct net_device *dev);
93544 static void ip6gre_tunnel_setup(struct net_device *dev);
93545 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
93546 @@ -1288,7 +1288,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
93547 }
93548
93549
93550 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
93551 +static struct inet6_protocol ip6gre_protocol = {
93552 .handler = ip6gre_rcv,
93553 .err_handler = ip6gre_err,
93554 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
93555 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
93556 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
93557 };
93558
93559 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93560 +static struct rtnl_link_ops ip6gre_link_ops = {
93561 .kind = "ip6gre",
93562 .maxtype = IFLA_GRE_MAX,
93563 .policy = ip6gre_policy,
93564 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93565 .fill_info = ip6gre_fill_info,
93566 };
93567
93568 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
93569 +static struct rtnl_link_ops ip6gre_tap_ops = {
93570 .kind = "ip6gretap",
93571 .maxtype = IFLA_GRE_MAX,
93572 .policy = ip6gre_policy,
93573 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
93574 index cf5d490..30946f0 100644
93575 --- a/net/ipv6/ip6_tunnel.c
93576 +++ b/net/ipv6/ip6_tunnel.c
93577 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
93578
93579 static int ip6_tnl_dev_init(struct net_device *dev);
93580 static void ip6_tnl_dev_setup(struct net_device *dev);
93581 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
93582 +static struct rtnl_link_ops ip6_link_ops;
93583
93584 static int ip6_tnl_net_id __read_mostly;
93585 struct ip6_tnl_net {
93586 @@ -1678,7 +1678,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
93587 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
93588 };
93589
93590 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
93591 +static struct rtnl_link_ops ip6_link_ops = {
93592 .kind = "ip6tnl",
93593 .maxtype = IFLA_IPTUN_MAX,
93594 .policy = ip6_tnl_policy,
93595 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
93596 index d1e2e8e..51c19ae 100644
93597 --- a/net/ipv6/ipv6_sockglue.c
93598 +++ b/net/ipv6/ipv6_sockglue.c
93599 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
93600 if (sk->sk_type != SOCK_STREAM)
93601 return -ENOPROTOOPT;
93602
93603 - msg.msg_control = optval;
93604 + msg.msg_control = (void __force_kernel *)optval;
93605 msg.msg_controllen = len;
93606 msg.msg_flags = flags;
93607
93608 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
93609 index 44400c2..8e11f52 100644
93610 --- a/net/ipv6/netfilter/ip6_tables.c
93611 +++ b/net/ipv6/netfilter/ip6_tables.c
93612 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
93613 #endif
93614
93615 static int get_info(struct net *net, void __user *user,
93616 - const int *len, int compat)
93617 + int len, int compat)
93618 {
93619 char name[XT_TABLE_MAXNAMELEN];
93620 struct xt_table *t;
93621 int ret;
93622
93623 - if (*len != sizeof(struct ip6t_getinfo)) {
93624 - duprintf("length %u != %zu\n", *len,
93625 + if (len != sizeof(struct ip6t_getinfo)) {
93626 + duprintf("length %u != %zu\n", len,
93627 sizeof(struct ip6t_getinfo));
93628 return -EINVAL;
93629 }
93630 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
93631 info.size = private->size;
93632 strcpy(info.name, name);
93633
93634 - if (copy_to_user(user, &info, *len) != 0)
93635 + if (copy_to_user(user, &info, len) != 0)
93636 ret = -EFAULT;
93637 else
93638 ret = 0;
93639 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93640
93641 switch (cmd) {
93642 case IP6T_SO_GET_INFO:
93643 - ret = get_info(sock_net(sk), user, len, 1);
93644 + ret = get_info(sock_net(sk), user, *len, 1);
93645 break;
93646 case IP6T_SO_GET_ENTRIES:
93647 ret = compat_get_entries(sock_net(sk), user, len);
93648 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93649
93650 switch (cmd) {
93651 case IP6T_SO_GET_INFO:
93652 - ret = get_info(sock_net(sk), user, len, 0);
93653 + ret = get_info(sock_net(sk), user, *len, 0);
93654 break;
93655
93656 case IP6T_SO_GET_ENTRIES:
93657 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
93658 index dffdc1a..ccc6678 100644
93659 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
93660 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
93661 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
93662
93663 static int nf_ct_frag6_sysctl_register(struct net *net)
93664 {
93665 - struct ctl_table *table;
93666 + ctl_table_no_const *table = NULL;
93667 struct ctl_table_header *hdr;
93668
93669 - table = nf_ct_frag6_sysctl_table;
93670 if (!net_eq(net, &init_net)) {
93671 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
93672 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
93673 GFP_KERNEL);
93674 if (table == NULL)
93675 goto err_alloc;
93676 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93677 table[0].data = &net->nf_frag.frags.timeout;
93678 table[1].data = &net->nf_frag.frags.low_thresh;
93679 table[2].data = &net->nf_frag.frags.high_thresh;
93680 - }
93681 -
93682 - hdr = register_net_sysctl(net, "net/netfilter", table);
93683 + hdr = register_net_sysctl(net, "net/netfilter", table);
93684 + } else
93685 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
93686 if (hdr == NULL)
93687 goto err_reg;
93688
93689 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93690 return 0;
93691
93692 err_reg:
93693 - if (!net_eq(net, &init_net))
93694 - kfree(table);
93695 + kfree(table);
93696 err_alloc:
93697 return -ENOMEM;
93698 }
93699 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
93700 index ab92a36..bb4a528 100644
93701 --- a/net/ipv6/output_core.c
93702 +++ b/net/ipv6/output_core.c
93703 @@ -8,8 +8,8 @@
93704
93705 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93706 {
93707 - static atomic_t ipv6_fragmentation_id;
93708 - int old, new;
93709 + static atomic_unchecked_t ipv6_fragmentation_id;
93710 + int id;
93711
93712 #if IS_ENABLED(CONFIG_IPV6)
93713 if (rt && !(rt->dst.flags & DST_NOPEER)) {
93714 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93715 }
93716 }
93717 #endif
93718 - do {
93719 - old = atomic_read(&ipv6_fragmentation_id);
93720 - new = old + 1;
93721 - if (!new)
93722 - new = 1;
93723 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
93724 - fhdr->identification = htonl(new);
93725 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93726 + if (!id)
93727 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93728 + fhdr->identification = htonl(id);
93729 }
93730 EXPORT_SYMBOL(ipv6_select_ident);
93731
93732 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
93733 index 18f19df..b46ada1 100644
93734 --- a/net/ipv6/ping.c
93735 +++ b/net/ipv6/ping.c
93736 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
93737 };
93738 #endif
93739
93740 +static struct pingv6_ops real_pingv6_ops = {
93741 + .ipv6_recv_error = ipv6_recv_error,
93742 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
93743 + .icmpv6_err_convert = icmpv6_err_convert,
93744 + .ipv6_icmp_error = ipv6_icmp_error,
93745 + .ipv6_chk_addr = ipv6_chk_addr,
93746 +};
93747 +
93748 +static struct pingv6_ops dummy_pingv6_ops = {
93749 + .ipv6_recv_error = dummy_ipv6_recv_error,
93750 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
93751 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
93752 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
93753 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
93754 +};
93755 +
93756 int __init pingv6_init(void)
93757 {
93758 #ifdef CONFIG_PROC_FS
93759 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
93760 if (ret)
93761 return ret;
93762 #endif
93763 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
93764 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
93765 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
93766 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
93767 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
93768 + pingv6_ops = &real_pingv6_ops;
93769 return inet6_register_protosw(&pingv6_protosw);
93770 }
93771
93772 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
93773 */
93774 void pingv6_exit(void)
93775 {
93776 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
93777 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
93778 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
93779 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
93780 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
93781 + pingv6_ops = &dummy_pingv6_ops;
93782 #ifdef CONFIG_PROC_FS
93783 unregister_pernet_subsys(&ping_v6_net_ops);
93784 #endif
93785 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
93786 index cdaed47..0650c7f 100644
93787 --- a/net/ipv6/raw.c
93788 +++ b/net/ipv6/raw.c
93789 @@ -108,7 +108,7 @@ found:
93790 */
93791 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
93792 {
93793 - struct icmp6hdr *_hdr;
93794 + struct icmp6hdr _hdr;
93795 const struct icmp6hdr *hdr;
93796
93797 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
93798 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
93799 {
93800 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
93801 skb_checksum_complete(skb)) {
93802 - atomic_inc(&sk->sk_drops);
93803 + atomic_inc_unchecked(&sk->sk_drops);
93804 kfree_skb(skb);
93805 return NET_RX_DROP;
93806 }
93807 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93808 struct raw6_sock *rp = raw6_sk(sk);
93809
93810 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
93811 - atomic_inc(&sk->sk_drops);
93812 + atomic_inc_unchecked(&sk->sk_drops);
93813 kfree_skb(skb);
93814 return NET_RX_DROP;
93815 }
93816 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93817
93818 if (inet->hdrincl) {
93819 if (skb_checksum_complete(skb)) {
93820 - atomic_inc(&sk->sk_drops);
93821 + atomic_inc_unchecked(&sk->sk_drops);
93822 kfree_skb(skb);
93823 return NET_RX_DROP;
93824 }
93825 @@ -459,9 +459,6 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
93826 if (flags & MSG_OOB)
93827 return -EOPNOTSUPP;
93828
93829 - if (addr_len)
93830 - *addr_len=sizeof(*sin6);
93831 -
93832 if (flags & MSG_ERRQUEUE)
93833 return ipv6_recv_error(sk, msg, len);
93834
93835 @@ -500,6 +497,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
93836 sin6->sin6_flowinfo = 0;
93837 sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr,
93838 IP6CB(skb)->iif);
93839 + *addr_len = sizeof(*sin6);
93840 }
93841
93842 sock_recv_ts_and_drops(msg, sk, skb);
93843 @@ -602,7 +600,7 @@ out:
93844 return err;
93845 }
93846
93847 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
93848 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
93849 struct flowi6 *fl6, struct dst_entry **dstp,
93850 unsigned int flags)
93851 {
93852 @@ -915,12 +913,15 @@ do_confirm:
93853 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
93854 char __user *optval, int optlen)
93855 {
93856 + struct icmp6_filter filter;
93857 +
93858 switch (optname) {
93859 case ICMPV6_FILTER:
93860 if (optlen > sizeof(struct icmp6_filter))
93861 optlen = sizeof(struct icmp6_filter);
93862 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
93863 + if (copy_from_user(&filter, optval, optlen))
93864 return -EFAULT;
93865 + raw6_sk(sk)->filter = filter;
93866 return 0;
93867 default:
93868 return -ENOPROTOOPT;
93869 @@ -933,6 +934,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93870 char __user *optval, int __user *optlen)
93871 {
93872 int len;
93873 + struct icmp6_filter filter;
93874
93875 switch (optname) {
93876 case ICMPV6_FILTER:
93877 @@ -944,7 +946,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93878 len = sizeof(struct icmp6_filter);
93879 if (put_user(len, optlen))
93880 return -EFAULT;
93881 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
93882 + filter = raw6_sk(sk)->filter;
93883 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
93884 return -EFAULT;
93885 return 0;
93886 default:
93887 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
93888 index 1aeb473..bea761c 100644
93889 --- a/net/ipv6/reassembly.c
93890 +++ b/net/ipv6/reassembly.c
93891 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
93892
93893 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93894 {
93895 - struct ctl_table *table;
93896 + ctl_table_no_const *table = NULL;
93897 struct ctl_table_header *hdr;
93898
93899 - table = ip6_frags_ns_ctl_table;
93900 if (!net_eq(net, &init_net)) {
93901 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93902 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93903 if (table == NULL)
93904 goto err_alloc;
93905
93906 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93907 /* Don't export sysctls to unprivileged users */
93908 if (net->user_ns != &init_user_ns)
93909 table[0].procname = NULL;
93910 - }
93911 + hdr = register_net_sysctl(net, "net/ipv6", table);
93912 + } else
93913 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
93914
93915 - hdr = register_net_sysctl(net, "net/ipv6", table);
93916 if (hdr == NULL)
93917 goto err_reg;
93918
93919 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93920 return 0;
93921
93922 err_reg:
93923 - if (!net_eq(net, &init_net))
93924 - kfree(table);
93925 + kfree(table);
93926 err_alloc:
93927 return -ENOMEM;
93928 }
93929 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
93930 index 1e32d5c..cbe3b46 100644
93931 --- a/net/ipv6/route.c
93932 +++ b/net/ipv6/route.c
93933 @@ -2954,7 +2954,7 @@ struct ctl_table ipv6_route_table_template[] = {
93934
93935 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
93936 {
93937 - struct ctl_table *table;
93938 + ctl_table_no_const *table;
93939
93940 table = kmemdup(ipv6_route_table_template,
93941 sizeof(ipv6_route_table_template),
93942 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
93943 index a51ad07..a90bc19 100644
93944 --- a/net/ipv6/sit.c
93945 +++ b/net/ipv6/sit.c
93946 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
93947 static void ipip6_dev_free(struct net_device *dev);
93948 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
93949 __be32 *v4dst);
93950 -static struct rtnl_link_ops sit_link_ops __read_mostly;
93951 +static struct rtnl_link_ops sit_link_ops;
93952
93953 static int sit_net_id __read_mostly;
93954 struct sit_net {
93955 @@ -1601,7 +1601,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
93956 #endif
93957 };
93958
93959 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
93960 +static struct rtnl_link_ops sit_link_ops = {
93961 .kind = "sit",
93962 .maxtype = IFLA_IPTUN_MAX,
93963 .policy = ipip6_policy,
93964 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
93965 index 107b2f1..72741a9 100644
93966 --- a/net/ipv6/sysctl_net_ipv6.c
93967 +++ b/net/ipv6/sysctl_net_ipv6.c
93968 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
93969
93970 static int __net_init ipv6_sysctl_net_init(struct net *net)
93971 {
93972 - struct ctl_table *ipv6_table;
93973 + ctl_table_no_const *ipv6_table;
93974 struct ctl_table *ipv6_route_table;
93975 struct ctl_table *ipv6_icmp_table;
93976 int err;
93977 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
93978 index 6e1649d..75ddb4c 100644
93979 --- a/net/ipv6/tcp_ipv6.c
93980 +++ b/net/ipv6/tcp_ipv6.c
93981 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
93982 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
93983 }
93984
93985 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93986 +extern int grsec_enable_blackhole;
93987 +#endif
93988 +
93989 static void tcp_v6_hash(struct sock *sk)
93990 {
93991 if (sk->sk_state != TCP_CLOSE) {
93992 @@ -1399,6 +1403,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
93993 return 0;
93994
93995 reset:
93996 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93997 + if (!grsec_enable_blackhole)
93998 +#endif
93999 tcp_v6_send_reset(sk, skb);
94000 discard:
94001 if (opt_skb)
94002 @@ -1427,7 +1434,7 @@ ipv6_pktoptions:
94003 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
94004 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
94005 if (np->rxopt.bits.rxtclass)
94006 - np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
94007 + np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
94008 if (ipv6_opt_accepted(sk, opt_skb)) {
94009 skb_set_owner_r(opt_skb, sk);
94010 opt_skb = xchg(&np->pktoptions, opt_skb);
94011 @@ -1481,12 +1488,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
94012 TCP_SKB_CB(skb)->sacked = 0;
94013
94014 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94015 - if (!sk)
94016 + if (!sk) {
94017 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94018 + ret = 1;
94019 +#endif
94020 goto no_tcp_socket;
94021 + }
94022
94023 process:
94024 - if (sk->sk_state == TCP_TIME_WAIT)
94025 + if (sk->sk_state == TCP_TIME_WAIT) {
94026 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94027 + ret = 2;
94028 +#endif
94029 goto do_time_wait;
94030 + }
94031
94032 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
94033 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94034 @@ -1538,6 +1553,10 @@ csum_error:
94035 bad_packet:
94036 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94037 } else {
94038 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94039 + if (!grsec_enable_blackhole || (ret == 1 &&
94040 + (skb->dev->flags & IFF_LOOPBACK)))
94041 +#endif
94042 tcp_v6_send_reset(NULL, skb);
94043 }
94044
94045 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
94046 index f405815..8f25d2a 100644
94047 --- a/net/ipv6/udp.c
94048 +++ b/net/ipv6/udp.c
94049 @@ -53,6 +53,10 @@
94050 #include <trace/events/skb.h>
94051 #include "udp_impl.h"
94052
94053 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94054 +extern int grsec_enable_blackhole;
94055 +#endif
94056 +
94057 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
94058 {
94059 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
94060 @@ -374,9 +378,6 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
94061 int is_udp4;
94062 bool slow;
94063
94064 - if (addr_len)
94065 - *addr_len = sizeof(struct sockaddr_in6);
94066 -
94067 if (flags & MSG_ERRQUEUE)
94068 return ipv6_recv_error(sk, msg, len);
94069
94070 @@ -420,7 +421,7 @@ try_again:
94071 if (unlikely(err)) {
94072 trace_kfree_skb(skb, udpv6_recvmsg);
94073 if (!peeked) {
94074 - atomic_inc(&sk->sk_drops);
94075 + atomic_inc_unchecked(&sk->sk_drops);
94076 if (is_udp4)
94077 UDP_INC_STATS_USER(sock_net(sk),
94078 UDP_MIB_INERRORS,
94079 @@ -462,7 +463,7 @@ try_again:
94080 ipv6_iface_scope_id(&sin6->sin6_addr,
94081 IP6CB(skb)->iif);
94082 }
94083 -
94084 + *addr_len = sizeof(*sin6);
94085 }
94086 if (is_udp4) {
94087 if (inet->cmsg_flags)
94088 @@ -666,7 +667,7 @@ csum_error:
94089 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94090 drop:
94091 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94092 - atomic_inc(&sk->sk_drops);
94093 + atomic_inc_unchecked(&sk->sk_drops);
94094 kfree_skb(skb);
94095 return -1;
94096 }
94097 @@ -724,7 +725,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94098 if (likely(skb1 == NULL))
94099 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94100 if (!skb1) {
94101 - atomic_inc(&sk->sk_drops);
94102 + atomic_inc_unchecked(&sk->sk_drops);
94103 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94104 IS_UDPLITE(sk));
94105 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94106 @@ -864,6 +865,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94107 goto csum_error;
94108
94109 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94110 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94111 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94112 +#endif
94113 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
94114
94115 kfree_skb(skb);
94116 diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
94117 index 5d1b8d7..657914b 100644
94118 --- a/net/ipv6/udp_offload.c
94119 +++ b/net/ipv6/udp_offload.c
94120 @@ -86,7 +86,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
94121
94122 /* Check if there is enough headroom to insert fragment header. */
94123 tnl_hlen = skb_tnl_header_len(skb);
94124 - if (skb_headroom(skb) < (tnl_hlen + frag_hdr_sz)) {
94125 + if (skb->mac_header < (tnl_hlen + frag_hdr_sz)) {
94126 if (gso_pskb_expand_head(skb, tnl_hlen + frag_hdr_sz))
94127 goto out;
94128 }
94129 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
94130 index 23ed03d..6532e67 100644
94131 --- a/net/ipv6/xfrm6_policy.c
94132 +++ b/net/ipv6/xfrm6_policy.c
94133 @@ -207,11 +207,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
94134 }
94135 }
94136
94137 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
94138 +static int xfrm6_garbage_collect(struct dst_ops *ops)
94139 {
94140 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
94141
94142 - xfrm6_policy_afinfo.garbage_collect(net);
94143 + xfrm_garbage_collect_deferred(net);
94144 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
94145 }
94146
94147 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
94148
94149 static int __net_init xfrm6_net_init(struct net *net)
94150 {
94151 - struct ctl_table *table;
94152 + ctl_table_no_const *table = NULL;
94153 struct ctl_table_header *hdr;
94154
94155 - table = xfrm6_policy_table;
94156 if (!net_eq(net, &init_net)) {
94157 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94158 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94159 if (!table)
94160 goto err_alloc;
94161
94162 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
94163 - }
94164 + hdr = register_net_sysctl(net, "net/ipv6", table);
94165 + } else
94166 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
94167
94168 - hdr = register_net_sysctl(net, "net/ipv6", table);
94169 if (!hdr)
94170 goto err_reg;
94171
94172 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
94173 return 0;
94174
94175 err_reg:
94176 - if (!net_eq(net, &init_net))
94177 - kfree(table);
94178 + kfree(table);
94179 err_alloc:
94180 return -ENOMEM;
94181 }
94182 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
94183 index 41ac7938..75e3bb1 100644
94184 --- a/net/irda/ircomm/ircomm_tty.c
94185 +++ b/net/irda/ircomm/ircomm_tty.c
94186 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94187 add_wait_queue(&port->open_wait, &wait);
94188
94189 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
94190 - __FILE__, __LINE__, tty->driver->name, port->count);
94191 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94192
94193 spin_lock_irqsave(&port->lock, flags);
94194 if (!tty_hung_up_p(filp))
94195 - port->count--;
94196 + atomic_dec(&port->count);
94197 port->blocked_open++;
94198 spin_unlock_irqrestore(&port->lock, flags);
94199
94200 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94201 }
94202
94203 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
94204 - __FILE__, __LINE__, tty->driver->name, port->count);
94205 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94206
94207 schedule();
94208 }
94209 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94210
94211 spin_lock_irqsave(&port->lock, flags);
94212 if (!tty_hung_up_p(filp))
94213 - port->count++;
94214 + atomic_inc(&port->count);
94215 port->blocked_open--;
94216 spin_unlock_irqrestore(&port->lock, flags);
94217
94218 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
94219 - __FILE__, __LINE__, tty->driver->name, port->count);
94220 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94221
94222 if (!retval)
94223 port->flags |= ASYNC_NORMAL_ACTIVE;
94224 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
94225
94226 /* ++ is not atomic, so this should be protected - Jean II */
94227 spin_lock_irqsave(&self->port.lock, flags);
94228 - self->port.count++;
94229 + atomic_inc(&self->port.count);
94230 spin_unlock_irqrestore(&self->port.lock, flags);
94231 tty_port_tty_set(&self->port, tty);
94232
94233 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
94234 - self->line, self->port.count);
94235 + self->line, atomic_read(&self->port.count));
94236
94237 /* Not really used by us, but lets do it anyway */
94238 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
94239 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
94240 tty_kref_put(port->tty);
94241 }
94242 port->tty = NULL;
94243 - port->count = 0;
94244 + atomic_set(&port->count, 0);
94245 spin_unlock_irqrestore(&port->lock, flags);
94246
94247 wake_up_interruptible(&port->open_wait);
94248 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
94249 seq_putc(m, '\n');
94250
94251 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
94252 - seq_printf(m, "Open count: %d\n", self->port.count);
94253 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
94254 seq_printf(m, "Max data size: %d\n", self->max_data_size);
94255 seq_printf(m, "Max header size: %d\n", self->max_header_size);
94256
94257 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
94258 index 168aff5..9d43132 100644
94259 --- a/net/iucv/af_iucv.c
94260 +++ b/net/iucv/af_iucv.c
94261 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
94262
94263 write_lock_bh(&iucv_sk_list.lock);
94264
94265 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
94266 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94267 while (__iucv_get_sock_by_name(name)) {
94268 sprintf(name, "%08x",
94269 - atomic_inc_return(&iucv_sk_list.autobind_name));
94270 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94271 }
94272
94273 write_unlock_bh(&iucv_sk_list.lock);
94274 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
94275 index cd5b8ec..f205e6b 100644
94276 --- a/net/iucv/iucv.c
94277 +++ b/net/iucv/iucv.c
94278 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
94279 return NOTIFY_OK;
94280 }
94281
94282 -static struct notifier_block __refdata iucv_cpu_notifier = {
94283 +static struct notifier_block iucv_cpu_notifier = {
94284 .notifier_call = iucv_cpu_notify,
94285 };
94286
94287 diff --git a/net/key/af_key.c b/net/key/af_key.c
94288 index ab8bd2c..3a3eb81 100644
94289 --- a/net/key/af_key.c
94290 +++ b/net/key/af_key.c
94291 @@ -1098,7 +1098,8 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
94292
94293 x->id.proto = proto;
94294 x->id.spi = sa->sadb_sa_spi;
94295 - x->props.replay_window = sa->sadb_sa_replay;
94296 + x->props.replay_window = min_t(unsigned int, sa->sadb_sa_replay,
94297 + (sizeof(x->replay.bitmap) * 8));
94298 if (sa->sadb_sa_flags & SADB_SAFLAGS_NOECN)
94299 x->props.flags |= XFRM_STATE_NOECN;
94300 if (sa->sadb_sa_flags & SADB_SAFLAGS_DECAP_DSCP)
94301 @@ -3048,10 +3049,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
94302 static u32 get_acqseq(void)
94303 {
94304 u32 res;
94305 - static atomic_t acqseq;
94306 + static atomic_unchecked_t acqseq;
94307
94308 do {
94309 - res = atomic_inc_return(&acqseq);
94310 + res = atomic_inc_return_unchecked(&acqseq);
94311 } while (!res);
94312 return res;
94313 }
94314 diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
94315 index b076e83..793e6ff 100644
94316 --- a/net/l2tp/l2tp_core.c
94317 +++ b/net/l2tp/l2tp_core.c
94318 @@ -501,6 +501,7 @@ out:
94319 static inline int l2tp_verify_udp_checksum(struct sock *sk,
94320 struct sk_buff *skb)
94321 {
94322 + struct l2tp_tunnel *tunnel = (struct l2tp_tunnel *)sk->sk_user_data;
94323 struct udphdr *uh = udp_hdr(skb);
94324 u16 ulen = ntohs(uh->len);
94325 __wsum psum;
94326 diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
94327 index 571db8d..da1a1ce 100644
94328 --- a/net/l2tp/l2tp_ip.c
94329 +++ b/net/l2tp/l2tp_ip.c
94330 @@ -518,9 +518,6 @@ static int l2tp_ip_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
94331 if (flags & MSG_OOB)
94332 goto out;
94333
94334 - if (addr_len)
94335 - *addr_len = sizeof(*sin);
94336 -
94337 skb = skb_recv_datagram(sk, flags, noblock, &err);
94338 if (!skb)
94339 goto out;
94340 @@ -543,6 +540,7 @@ static int l2tp_ip_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
94341 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
94342 sin->sin_port = 0;
94343 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
94344 + *addr_len = sizeof(*sin);
94345 }
94346 if (inet->cmsg_flags)
94347 ip_cmsg_recv(msg, skb);
94348 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
94349 index a4b2154..b2fef6f 100644
94350 --- a/net/mac80211/cfg.c
94351 +++ b/net/mac80211/cfg.c
94352 @@ -820,7 +820,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
94353 ret = ieee80211_vif_use_channel(sdata, chandef,
94354 IEEE80211_CHANCTX_EXCLUSIVE);
94355 }
94356 - } else if (local->open_count == local->monitors) {
94357 + } else if (local_read(&local->open_count) == local->monitors) {
94358 local->_oper_chandef = *chandef;
94359 ieee80211_hw_config(local, 0);
94360 }
94361 @@ -2941,7 +2941,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
94362 else
94363 local->probe_req_reg--;
94364
94365 - if (!local->open_count)
94366 + if (!local_read(&local->open_count))
94367 break;
94368
94369 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
94370 @@ -3404,8 +3404,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
94371 if (chanctx_conf) {
94372 *chandef = chanctx_conf->def;
94373 ret = 0;
94374 - } else if (local->open_count > 0 &&
94375 - local->open_count == local->monitors &&
94376 + } else if (local_read(&local->open_count) > 0 &&
94377 + local_read(&local->open_count) == local->monitors &&
94378 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
94379 if (local->use_chanctx)
94380 *chandef = local->monitor_chandef;
94381 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
94382 index 8c0f8e6..438e580 100644
94383 --- a/net/mac80211/ieee80211_i.h
94384 +++ b/net/mac80211/ieee80211_i.h
94385 @@ -28,6 +28,7 @@
94386 #include <net/ieee80211_radiotap.h>
94387 #include <net/cfg80211.h>
94388 #include <net/mac80211.h>
94389 +#include <asm/local.h>
94390 #include "key.h"
94391 #include "sta_info.h"
94392 #include "debug.h"
94393 @@ -910,7 +911,7 @@ struct ieee80211_local {
94394 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
94395 spinlock_t queue_stop_reason_lock;
94396
94397 - int open_count;
94398 + local_t open_count;
94399 int monitors, cooked_mntrs;
94400 /* number of interfaces with corresponding FIF_ flags */
94401 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
94402 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
94403 index cc11759..11d5541 100644
94404 --- a/net/mac80211/iface.c
94405 +++ b/net/mac80211/iface.c
94406 @@ -511,7 +511,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94407 break;
94408 }
94409
94410 - if (local->open_count == 0) {
94411 + if (local_read(&local->open_count) == 0) {
94412 res = drv_start(local);
94413 if (res)
94414 goto err_del_bss;
94415 @@ -558,7 +558,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94416 res = drv_add_interface(local, sdata);
94417 if (res)
94418 goto err_stop;
94419 - } else if (local->monitors == 0 && local->open_count == 0) {
94420 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
94421 res = ieee80211_add_virtual_monitor(local);
94422 if (res)
94423 goto err_stop;
94424 @@ -666,7 +666,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94425 atomic_inc(&local->iff_promiscs);
94426
94427 if (coming_up)
94428 - local->open_count++;
94429 + local_inc(&local->open_count);
94430
94431 if (hw_reconf_flags)
94432 ieee80211_hw_config(local, hw_reconf_flags);
94433 @@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94434 err_del_interface:
94435 drv_remove_interface(local, sdata);
94436 err_stop:
94437 - if (!local->open_count)
94438 + if (!local_read(&local->open_count))
94439 drv_stop(local);
94440 err_del_bss:
94441 sdata->bss = NULL;
94442 @@ -841,7 +841,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94443 }
94444
94445 if (going_down)
94446 - local->open_count--;
94447 + local_dec(&local->open_count);
94448
94449 switch (sdata->vif.type) {
94450 case NL80211_IFTYPE_AP_VLAN:
94451 @@ -908,7 +908,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94452 }
94453 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
94454
94455 - if (local->open_count == 0)
94456 + if (local_read(&local->open_count) == 0)
94457 ieee80211_clear_tx_pending(local);
94458
94459 /*
94460 @@ -948,7 +948,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94461
94462 ieee80211_recalc_ps(local, -1);
94463
94464 - if (local->open_count == 0) {
94465 + if (local_read(&local->open_count) == 0) {
94466 ieee80211_stop_device(local);
94467
94468 /* no reconfiguring after stop! */
94469 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94470 ieee80211_configure_filter(local);
94471 ieee80211_hw_config(local, hw_reconf_flags);
94472
94473 - if (local->monitors == local->open_count)
94474 + if (local->monitors == local_read(&local->open_count))
94475 ieee80211_add_virtual_monitor(local);
94476 }
94477
94478 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
94479 index 091088a..daf43c7 100644
94480 --- a/net/mac80211/main.c
94481 +++ b/net/mac80211/main.c
94482 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
94483 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
94484 IEEE80211_CONF_CHANGE_POWER);
94485
94486 - if (changed && local->open_count) {
94487 + if (changed && local_read(&local->open_count)) {
94488 ret = drv_config(local, changed);
94489 /*
94490 * Goal:
94491 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
94492 index 3401262..d5cd68d 100644
94493 --- a/net/mac80211/pm.c
94494 +++ b/net/mac80211/pm.c
94495 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94496 struct ieee80211_sub_if_data *sdata;
94497 struct sta_info *sta;
94498
94499 - if (!local->open_count)
94500 + if (!local_read(&local->open_count))
94501 goto suspend;
94502
94503 ieee80211_scan_cancel(local);
94504 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94505 cancel_work_sync(&local->dynamic_ps_enable_work);
94506 del_timer_sync(&local->dynamic_ps_timer);
94507
94508 - local->wowlan = wowlan && local->open_count;
94509 + local->wowlan = wowlan && local_read(&local->open_count);
94510 if (local->wowlan) {
94511 int err = drv_suspend(local, wowlan);
94512 if (err < 0) {
94513 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94514 WARN_ON(!list_empty(&local->chanctx_list));
94515
94516 /* stop hardware - this must stop RX */
94517 - if (local->open_count)
94518 + if (local_read(&local->open_count))
94519 ieee80211_stop_device(local);
94520
94521 suspend:
94522 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
94523 index 30d58d2..449ac8e 100644
94524 --- a/net/mac80211/rate.c
94525 +++ b/net/mac80211/rate.c
94526 @@ -718,7 +718,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
94527
94528 ASSERT_RTNL();
94529
94530 - if (local->open_count)
94531 + if (local_read(&local->open_count))
94532 return -EBUSY;
94533
94534 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
94535 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
94536 index c97a065..ff61928 100644
94537 --- a/net/mac80211/rc80211_pid_debugfs.c
94538 +++ b/net/mac80211/rc80211_pid_debugfs.c
94539 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
94540
94541 spin_unlock_irqrestore(&events->lock, status);
94542
94543 - if (copy_to_user(buf, pb, p))
94544 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
94545 return -EFAULT;
94546
94547 return p;
94548 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
94549 index 31e78ae..f2a7381 100644
94550 --- a/net/mac80211/util.c
94551 +++ b/net/mac80211/util.c
94552 @@ -1452,7 +1452,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94553 }
94554 #endif
94555 /* everything else happens only if HW was up & running */
94556 - if (!local->open_count)
94557 + if (!local_read(&local->open_count))
94558 goto wake_up;
94559
94560 /*
94561 @@ -1677,7 +1677,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94562 local->in_reconfig = false;
94563 barrier();
94564
94565 - if (local->monitors == local->open_count && local->monitors > 0)
94566 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
94567 ieee80211_add_virtual_monitor(local);
94568
94569 /*
94570 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
94571 index 56d22ca..87c778f 100644
94572 --- a/net/netfilter/Kconfig
94573 +++ b/net/netfilter/Kconfig
94574 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
94575
94576 To compile it as a module, choose M here. If unsure, say N.
94577
94578 +config NETFILTER_XT_MATCH_GRADM
94579 + tristate '"gradm" match support'
94580 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
94581 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
94582 + ---help---
94583 + The gradm match allows to match on grsecurity RBAC being enabled.
94584 + It is useful when iptables rules are applied early on bootup to
94585 + prevent connections to the machine (except from a trusted host)
94586 + while the RBAC system is disabled.
94587 +
94588 config NETFILTER_XT_MATCH_HASHLIMIT
94589 tristate '"hashlimit" match support'
94590 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
94591 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
94592 index a1abf87..dbcb7ee 100644
94593 --- a/net/netfilter/Makefile
94594 +++ b/net/netfilter/Makefile
94595 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
94596 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
94597 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
94598 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
94599 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
94600 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
94601 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
94602 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
94603 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
94604 index f771390..145b765 100644
94605 --- a/net/netfilter/ipset/ip_set_core.c
94606 +++ b/net/netfilter/ipset/ip_set_core.c
94607 @@ -1820,7 +1820,7 @@ done:
94608 return ret;
94609 }
94610
94611 -static struct nf_sockopt_ops so_set __read_mostly = {
94612 +static struct nf_sockopt_ops so_set = {
94613 .pf = PF_INET,
94614 .get_optmin = SO_IP_SET,
94615 .get_optmax = SO_IP_SET + 1,
94616 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
94617 index 4c8e5c0..5a79b4d 100644
94618 --- a/net/netfilter/ipvs/ip_vs_conn.c
94619 +++ b/net/netfilter/ipvs/ip_vs_conn.c
94620 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
94621 /* Increase the refcnt counter of the dest */
94622 ip_vs_dest_hold(dest);
94623
94624 - conn_flags = atomic_read(&dest->conn_flags);
94625 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
94626 if (cp->protocol != IPPROTO_UDP)
94627 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
94628 flags = cp->flags;
94629 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
94630
94631 cp->control = NULL;
94632 atomic_set(&cp->n_control, 0);
94633 - atomic_set(&cp->in_pkts, 0);
94634 + atomic_set_unchecked(&cp->in_pkts, 0);
94635
94636 cp->packet_xmit = NULL;
94637 cp->app = NULL;
94638 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
94639
94640 /* Don't drop the entry if its number of incoming packets is not
94641 located in [0, 8] */
94642 - i = atomic_read(&cp->in_pkts);
94643 + i = atomic_read_unchecked(&cp->in_pkts);
94644 if (i > 8 || i < 0) return 0;
94645
94646 if (!todrop_rate[i]) return 0;
94647 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
94648 index 4f69e83..da2d8bf 100644
94649 --- a/net/netfilter/ipvs/ip_vs_core.c
94650 +++ b/net/netfilter/ipvs/ip_vs_core.c
94651 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
94652 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
94653 /* do not touch skb anymore */
94654
94655 - atomic_inc(&cp->in_pkts);
94656 + atomic_inc_unchecked(&cp->in_pkts);
94657 ip_vs_conn_put(cp);
94658 return ret;
94659 }
94660 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
94661 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
94662 pkts = sysctl_sync_threshold(ipvs);
94663 else
94664 - pkts = atomic_add_return(1, &cp->in_pkts);
94665 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94666
94667 if (ipvs->sync_state & IP_VS_STATE_MASTER)
94668 ip_vs_sync_conn(net, cp, pkts);
94669 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
94670 index c8148e4..eff604f 100644
94671 --- a/net/netfilter/ipvs/ip_vs_ctl.c
94672 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
94673 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
94674 */
94675 ip_vs_rs_hash(ipvs, dest);
94676 }
94677 - atomic_set(&dest->conn_flags, conn_flags);
94678 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
94679
94680 /* bind the service */
94681 if (!dest->svc) {
94682 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
94683 * align with netns init in ip_vs_control_net_init()
94684 */
94685
94686 -static struct ctl_table vs_vars[] = {
94687 +static ctl_table_no_const vs_vars[] __read_only = {
94688 {
94689 .procname = "amemthresh",
94690 .maxlen = sizeof(int),
94691 @@ -2078,7 +2078,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94692 " %-7s %-6d %-10d %-10d\n",
94693 &dest->addr.in6,
94694 ntohs(dest->port),
94695 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94696 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94697 atomic_read(&dest->weight),
94698 atomic_read(&dest->activeconns),
94699 atomic_read(&dest->inactconns));
94700 @@ -2089,7 +2089,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94701 "%-7s %-6d %-10d %-10d\n",
94702 ntohl(dest->addr.ip),
94703 ntohs(dest->port),
94704 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94705 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94706 atomic_read(&dest->weight),
94707 atomic_read(&dest->activeconns),
94708 atomic_read(&dest->inactconns));
94709 @@ -2567,7 +2567,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
94710
94711 entry.addr = dest->addr.ip;
94712 entry.port = dest->port;
94713 - entry.conn_flags = atomic_read(&dest->conn_flags);
94714 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
94715 entry.weight = atomic_read(&dest->weight);
94716 entry.u_threshold = dest->u_threshold;
94717 entry.l_threshold = dest->l_threshold;
94718 @@ -3110,7 +3110,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
94719 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
94720 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
94721 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
94722 - (atomic_read(&dest->conn_flags) &
94723 + (atomic_read_unchecked(&dest->conn_flags) &
94724 IP_VS_CONN_F_FWD_MASK)) ||
94725 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
94726 atomic_read(&dest->weight)) ||
94727 @@ -3700,7 +3700,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
94728 {
94729 int idx;
94730 struct netns_ipvs *ipvs = net_ipvs(net);
94731 - struct ctl_table *tbl;
94732 + ctl_table_no_const *tbl;
94733
94734 atomic_set(&ipvs->dropentry, 0);
94735 spin_lock_init(&ipvs->dropentry_lock);
94736 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
94737 index 1383b0e..a486da1 100644
94738 --- a/net/netfilter/ipvs/ip_vs_lblc.c
94739 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
94740 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
94741 * IPVS LBLC sysctl table
94742 */
94743 #ifdef CONFIG_SYSCTL
94744 -static struct ctl_table vs_vars_table[] = {
94745 +static ctl_table_no_const vs_vars_table[] __read_only = {
94746 {
94747 .procname = "lblc_expiration",
94748 .data = NULL,
94749 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
94750 index 3cd85b2..dfab2b8 100644
94751 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
94752 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
94753 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
94754 * IPVS LBLCR sysctl table
94755 */
94756
94757 -static struct ctl_table vs_vars_table[] = {
94758 +static ctl_table_no_const vs_vars_table[] __read_only = {
94759 {
94760 .procname = "lblcr_expiration",
94761 .data = NULL,
94762 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
94763 index f448471..995f131 100644
94764 --- a/net/netfilter/ipvs/ip_vs_sync.c
94765 +++ b/net/netfilter/ipvs/ip_vs_sync.c
94766 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
94767 cp = cp->control;
94768 if (cp) {
94769 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94770 - pkts = atomic_add_return(1, &cp->in_pkts);
94771 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94772 else
94773 pkts = sysctl_sync_threshold(ipvs);
94774 ip_vs_sync_conn(net, cp->control, pkts);
94775 @@ -771,7 +771,7 @@ control:
94776 if (!cp)
94777 return;
94778 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94779 - pkts = atomic_add_return(1, &cp->in_pkts);
94780 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94781 else
94782 pkts = sysctl_sync_threshold(ipvs);
94783 goto sloop;
94784 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
94785
94786 if (opt)
94787 memcpy(&cp->in_seq, opt, sizeof(*opt));
94788 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94789 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94790 cp->state = state;
94791 cp->old_state = cp->state;
94792 /*
94793 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
94794 index c47444e..b0961c6 100644
94795 --- a/net/netfilter/ipvs/ip_vs_xmit.c
94796 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
94797 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
94798 else
94799 rc = NF_ACCEPT;
94800 /* do not touch skb anymore */
94801 - atomic_inc(&cp->in_pkts);
94802 + atomic_inc_unchecked(&cp->in_pkts);
94803 goto out;
94804 }
94805
94806 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
94807 else
94808 rc = NF_ACCEPT;
94809 /* do not touch skb anymore */
94810 - atomic_inc(&cp->in_pkts);
94811 + atomic_inc_unchecked(&cp->in_pkts);
94812 goto out;
94813 }
94814
94815 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
94816 index 2d3030a..7ba1c0a 100644
94817 --- a/net/netfilter/nf_conntrack_acct.c
94818 +++ b/net/netfilter/nf_conntrack_acct.c
94819 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
94820 #ifdef CONFIG_SYSCTL
94821 static int nf_conntrack_acct_init_sysctl(struct net *net)
94822 {
94823 - struct ctl_table *table;
94824 + ctl_table_no_const *table;
94825
94826 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
94827 GFP_KERNEL);
94828 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
94829 index 0283bae..5febcb0 100644
94830 --- a/net/netfilter/nf_conntrack_core.c
94831 +++ b/net/netfilter/nf_conntrack_core.c
94832 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
94833 #define DYING_NULLS_VAL ((1<<30)+1)
94834 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
94835
94836 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94837 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
94838 +#endif
94839 +
94840 int nf_conntrack_init_net(struct net *net)
94841 {
94842 int ret;
94843 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
94844 goto err_stat;
94845 }
94846
94847 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94848 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
94849 +#else
94850 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
94851 +#endif
94852 if (!net->ct.slabname) {
94853 ret = -ENOMEM;
94854 goto err_slabname;
94855 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
94856 index 1df1761..ce8b88a 100644
94857 --- a/net/netfilter/nf_conntrack_ecache.c
94858 +++ b/net/netfilter/nf_conntrack_ecache.c
94859 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
94860 #ifdef CONFIG_SYSCTL
94861 static int nf_conntrack_event_init_sysctl(struct net *net)
94862 {
94863 - struct ctl_table *table;
94864 + ctl_table_no_const *table;
94865
94866 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
94867 GFP_KERNEL);
94868 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
94869 index 974a2a4..52cc6ff 100644
94870 --- a/net/netfilter/nf_conntrack_helper.c
94871 +++ b/net/netfilter/nf_conntrack_helper.c
94872 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
94873
94874 static int nf_conntrack_helper_init_sysctl(struct net *net)
94875 {
94876 - struct ctl_table *table;
94877 + ctl_table_no_const *table;
94878
94879 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
94880 GFP_KERNEL);
94881 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
94882 index 0ab9636..cea3c6a 100644
94883 --- a/net/netfilter/nf_conntrack_proto.c
94884 +++ b/net/netfilter/nf_conntrack_proto.c
94885 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
94886
94887 static void
94888 nf_ct_unregister_sysctl(struct ctl_table_header **header,
94889 - struct ctl_table **table,
94890 + ctl_table_no_const **table,
94891 unsigned int users)
94892 {
94893 if (users > 0)
94894 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
94895 index a99b6c3..cb372f9 100644
94896 --- a/net/netfilter/nf_conntrack_proto_dccp.c
94897 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
94898 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94899 const char *msg;
94900 u_int8_t state;
94901
94902 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94903 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94904 BUG_ON(dh == NULL);
94905
94906 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
94907 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94908 out_invalid:
94909 if (LOG_INVALID(net, IPPROTO_DCCP))
94910 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
94911 - NULL, msg);
94912 + NULL, "%s", msg);
94913 return false;
94914 }
94915
94916 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
94917 u_int8_t type, old_state, new_state;
94918 enum ct_dccp_roles role;
94919
94920 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94921 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94922 BUG_ON(dh == NULL);
94923 type = dh->dccph_type;
94924
94925 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94926 unsigned int cscov;
94927 const char *msg;
94928
94929 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94930 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94931 if (dh == NULL) {
94932 msg = "nf_ct_dccp: short packet ";
94933 goto out_invalid;
94934 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94935
94936 out_invalid:
94937 if (LOG_INVALID(net, IPPROTO_DCCP))
94938 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
94939 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
94940 return -NF_ACCEPT;
94941 }
94942
94943 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
94944 index f641751..d3c5b51 100644
94945 --- a/net/netfilter/nf_conntrack_standalone.c
94946 +++ b/net/netfilter/nf_conntrack_standalone.c
94947 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
94948
94949 static int nf_conntrack_standalone_init_sysctl(struct net *net)
94950 {
94951 - struct ctl_table *table;
94952 + ctl_table_no_const *table;
94953
94954 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
94955 GFP_KERNEL);
94956 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
94957 index 902fb0a..87f7fdb 100644
94958 --- a/net/netfilter/nf_conntrack_timestamp.c
94959 +++ b/net/netfilter/nf_conntrack_timestamp.c
94960 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
94961 #ifdef CONFIG_SYSCTL
94962 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
94963 {
94964 - struct ctl_table *table;
94965 + ctl_table_no_const *table;
94966
94967 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
94968 GFP_KERNEL);
94969 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
94970 index 85296d4..8becdec 100644
94971 --- a/net/netfilter/nf_log.c
94972 +++ b/net/netfilter/nf_log.c
94973 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
94974
94975 #ifdef CONFIG_SYSCTL
94976 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
94977 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
94978 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
94979
94980 static int nf_log_proc_dostring(struct ctl_table *table, int write,
94981 void __user *buffer, size_t *lenp, loff_t *ppos)
94982 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
94983 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
94984 mutex_unlock(&nf_log_mutex);
94985 } else {
94986 + ctl_table_no_const nf_log_table = *table;
94987 +
94988 mutex_lock(&nf_log_mutex);
94989 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
94990 lockdep_is_held(&nf_log_mutex));
94991 if (!logger)
94992 - table->data = "NONE";
94993 + nf_log_table.data = "NONE";
94994 else
94995 - table->data = logger->name;
94996 - r = proc_dostring(table, write, buffer, lenp, ppos);
94997 + nf_log_table.data = logger->name;
94998 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
94999 mutex_unlock(&nf_log_mutex);
95000 }
95001
95002 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
95003 index f042ae5..30ea486 100644
95004 --- a/net/netfilter/nf_sockopt.c
95005 +++ b/net/netfilter/nf_sockopt.c
95006 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
95007 }
95008 }
95009
95010 - list_add(&reg->list, &nf_sockopts);
95011 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
95012 out:
95013 mutex_unlock(&nf_sockopt_mutex);
95014 return ret;
95015 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
95016 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
95017 {
95018 mutex_lock(&nf_sockopt_mutex);
95019 - list_del(&reg->list);
95020 + pax_list_del((struct list_head *)&reg->list);
95021 mutex_unlock(&nf_sockopt_mutex);
95022 }
95023 EXPORT_SYMBOL(nf_unregister_sockopt);
95024 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
95025 index d92cc31..e46f350 100644
95026 --- a/net/netfilter/nfnetlink_log.c
95027 +++ b/net/netfilter/nfnetlink_log.c
95028 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
95029 struct nfnl_log_net {
95030 spinlock_t instances_lock;
95031 struct hlist_head instance_table[INSTANCE_BUCKETS];
95032 - atomic_t global_seq;
95033 + atomic_unchecked_t global_seq;
95034 };
95035
95036 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
95037 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
95038 /* global sequence number */
95039 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
95040 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
95041 - htonl(atomic_inc_return(&log->global_seq))))
95042 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
95043 goto nla_put_failure;
95044
95045 if (data_len) {
95046 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
95047 new file mode 100644
95048 index 0000000..c566332
95049 --- /dev/null
95050 +++ b/net/netfilter/xt_gradm.c
95051 @@ -0,0 +1,51 @@
95052 +/*
95053 + * gradm match for netfilter
95054 + * Copyright © Zbigniew Krzystolik, 2010
95055 + *
95056 + * This program is free software; you can redistribute it and/or modify
95057 + * it under the terms of the GNU General Public License; either version
95058 + * 2 or 3 as published by the Free Software Foundation.
95059 + */
95060 +#include <linux/module.h>
95061 +#include <linux/moduleparam.h>
95062 +#include <linux/skbuff.h>
95063 +#include <linux/netfilter/x_tables.h>
95064 +#include <linux/grsecurity.h>
95065 +#include <linux/netfilter/xt_gradm.h>
95066 +
95067 +static bool
95068 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
95069 +{
95070 + const struct xt_gradm_mtinfo *info = par->matchinfo;
95071 + bool retval = false;
95072 + if (gr_acl_is_enabled())
95073 + retval = true;
95074 + return retval ^ info->invflags;
95075 +}
95076 +
95077 +static struct xt_match gradm_mt_reg __read_mostly = {
95078 + .name = "gradm",
95079 + .revision = 0,
95080 + .family = NFPROTO_UNSPEC,
95081 + .match = gradm_mt,
95082 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
95083 + .me = THIS_MODULE,
95084 +};
95085 +
95086 +static int __init gradm_mt_init(void)
95087 +{
95088 + return xt_register_match(&gradm_mt_reg);
95089 +}
95090 +
95091 +static void __exit gradm_mt_exit(void)
95092 +{
95093 + xt_unregister_match(&gradm_mt_reg);
95094 +}
95095 +
95096 +module_init(gradm_mt_init);
95097 +module_exit(gradm_mt_exit);
95098 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
95099 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
95100 +MODULE_LICENSE("GPL");
95101 +MODULE_ALIAS("ipt_gradm");
95102 +MODULE_ALIAS("ip6t_gradm");
95103 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
95104 index 4fe4fb4..87a89e5 100644
95105 --- a/net/netfilter/xt_statistic.c
95106 +++ b/net/netfilter/xt_statistic.c
95107 @@ -19,7 +19,7 @@
95108 #include <linux/module.h>
95109
95110 struct xt_statistic_priv {
95111 - atomic_t count;
95112 + atomic_unchecked_t count;
95113 } ____cacheline_aligned_in_smp;
95114
95115 MODULE_LICENSE("GPL");
95116 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
95117 break;
95118 case XT_STATISTIC_MODE_NTH:
95119 do {
95120 - oval = atomic_read(&info->master->count);
95121 + oval = atomic_read_unchecked(&info->master->count);
95122 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
95123 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
95124 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
95125 if (nval == 0)
95126 ret = !ret;
95127 break;
95128 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
95129 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
95130 if (info->master == NULL)
95131 return -ENOMEM;
95132 - atomic_set(&info->master->count, info->u.nth.count);
95133 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
95134
95135 return 0;
95136 }
95137 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
95138 index 0c61b59..941bddd 100644
95139 --- a/net/netlink/af_netlink.c
95140 +++ b/net/netlink/af_netlink.c
95141 @@ -219,7 +219,7 @@ static void netlink_overrun(struct sock *sk)
95142 sk->sk_error_report(sk);
95143 }
95144 }
95145 - atomic_inc(&sk->sk_drops);
95146 + atomic_inc_unchecked(&sk->sk_drops);
95147 }
95148
95149 static void netlink_rcv_wake(struct sock *sk)
95150 @@ -2925,7 +2925,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
95151 sk_wmem_alloc_get(s),
95152 nlk->cb,
95153 atomic_read(&s->sk_refcnt),
95154 - atomic_read(&s->sk_drops),
95155 + atomic_read_unchecked(&s->sk_drops),
95156 sock_i_ino(s)
95157 );
95158
95159 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
95160 index 0c741ce..f8c8ca7 100644
95161 --- a/net/netlink/genetlink.c
95162 +++ b/net/netlink/genetlink.c
95163 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
95164 goto errout;
95165 }
95166
95167 + pax_open_kernel();
95168 if (ops->dumpit)
95169 - ops->flags |= GENL_CMD_CAP_DUMP;
95170 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
95171 if (ops->doit)
95172 - ops->flags |= GENL_CMD_CAP_DO;
95173 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
95174 if (ops->policy)
95175 - ops->flags |= GENL_CMD_CAP_HASPOL;
95176 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
95177 + pax_close_kernel();
95178
95179 genl_lock_all();
95180 - list_add_tail(&ops->ops_list, &family->ops_list);
95181 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
95182 genl_unlock_all();
95183
95184 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
95185 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
95186 err = 0;
95187 errout:
95188 return err;
95189 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
95190 genl_lock_all();
95191 list_for_each_entry(rc, &family->ops_list, ops_list) {
95192 if (rc == ops) {
95193 - list_del(&ops->ops_list);
95194 + pax_list_del((struct list_head *)&ops->ops_list);
95195 genl_unlock_all();
95196 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
95197 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
95198 return 0;
95199 }
95200 }
95201 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
95202 index 698814b..7cfde4e 100644
95203 --- a/net/netrom/af_netrom.c
95204 +++ b/net/netrom/af_netrom.c
95205 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
95206 *uaddr_len = sizeof(struct full_sockaddr_ax25);
95207 } else {
95208 sax->fsa_ax25.sax25_family = AF_NETROM;
95209 - sax->fsa_ax25.sax25_ndigis = 0;
95210 sax->fsa_ax25.sax25_call = nr->source_addr;
95211 *uaddr_len = sizeof(struct sockaddr_ax25);
95212 }
95213 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
95214 index 75c8bbf..ee9be59 100644
95215 --- a/net/packet/af_packet.c
95216 +++ b/net/packet/af_packet.c
95217 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95218
95219 spin_lock(&sk->sk_receive_queue.lock);
95220 po->stats.stats1.tp_packets++;
95221 - skb->dropcount = atomic_read(&sk->sk_drops);
95222 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
95223 __skb_queue_tail(&sk->sk_receive_queue, skb);
95224 spin_unlock(&sk->sk_receive_queue.lock);
95225 sk->sk_data_ready(sk, skb->len);
95226 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95227 drop_n_acct:
95228 spin_lock(&sk->sk_receive_queue.lock);
95229 po->stats.stats1.tp_drops++;
95230 - atomic_inc(&sk->sk_drops);
95231 + atomic_inc_unchecked(&sk->sk_drops);
95232 spin_unlock(&sk->sk_receive_queue.lock);
95233
95234 drop_n_restore:
95235 @@ -2640,6 +2640,7 @@ out:
95236
95237 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95238 {
95239 + struct sock_extended_err ee;
95240 struct sock_exterr_skb *serr;
95241 struct sk_buff *skb, *skb2;
95242 int copied, err;
95243 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95244 sock_recv_timestamp(msg, sk, skb);
95245
95246 serr = SKB_EXT_ERR(skb);
95247 + ee = serr->ee;
95248 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
95249 - sizeof(serr->ee), &serr->ee);
95250 + sizeof ee, &ee);
95251
95252 msg->msg_flags |= MSG_ERRQUEUE;
95253 err = copied;
95254 @@ -3283,7 +3285,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95255 case PACKET_HDRLEN:
95256 if (len > sizeof(int))
95257 len = sizeof(int);
95258 - if (copy_from_user(&val, optval, len))
95259 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
95260 return -EFAULT;
95261 switch (val) {
95262 case TPACKET_V1:
95263 @@ -3326,7 +3328,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95264 len = lv;
95265 if (put_user(len, optlen))
95266 return -EFAULT;
95267 - if (copy_to_user(optval, data, len))
95268 + if (len > sizeof(st) || copy_to_user(optval, data, len))
95269 return -EFAULT;
95270 return 0;
95271 }
95272 diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c
95273 index 12c30f3..38946b2 100644
95274 --- a/net/phonet/datagram.c
95275 +++ b/net/phonet/datagram.c
95276 @@ -139,9 +139,6 @@ static int pn_recvmsg(struct kiocb *iocb, struct sock *sk,
95277 MSG_CMSG_COMPAT))
95278 goto out_nofree;
95279
95280 - if (addr_len)
95281 - *addr_len = sizeof(sa);
95282 -
95283 skb = skb_recv_datagram(sk, flags, noblock, &rval);
95284 if (skb == NULL)
95285 goto out_nofree;
95286 @@ -162,8 +159,10 @@ static int pn_recvmsg(struct kiocb *iocb, struct sock *sk,
95287
95288 rval = (flags & MSG_TRUNC) ? skb->len : copylen;
95289
95290 - if (msg->msg_name != NULL)
95291 - memcpy(msg->msg_name, &sa, sizeof(struct sockaddr_pn));
95292 + if (msg->msg_name != NULL) {
95293 + memcpy(msg->msg_name, &sa, sizeof(sa));
95294 + *addr_len = sizeof(sa);
95295 + }
95296
95297 out:
95298 skb_free_datagram(sk, skb);
95299 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
95300 index e774117..900b8b7 100644
95301 --- a/net/phonet/pep.c
95302 +++ b/net/phonet/pep.c
95303 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95304
95305 case PNS_PEP_CTRL_REQ:
95306 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
95307 - atomic_inc(&sk->sk_drops);
95308 + atomic_inc_unchecked(&sk->sk_drops);
95309 break;
95310 }
95311 __skb_pull(skb, 4);
95312 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95313 }
95314
95315 if (pn->rx_credits == 0) {
95316 - atomic_inc(&sk->sk_drops);
95317 + atomic_inc_unchecked(&sk->sk_drops);
95318 err = -ENOBUFS;
95319 break;
95320 }
95321 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
95322 }
95323
95324 if (pn->rx_credits == 0) {
95325 - atomic_inc(&sk->sk_drops);
95326 + atomic_inc_unchecked(&sk->sk_drops);
95327 err = NET_RX_DROP;
95328 break;
95329 }
95330 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
95331 index 1afd138..0b42453 100644
95332 --- a/net/phonet/socket.c
95333 +++ b/net/phonet/socket.c
95334 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
95335 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
95336 sock_i_ino(sk),
95337 atomic_read(&sk->sk_refcnt), sk,
95338 - atomic_read(&sk->sk_drops), &len);
95339 + atomic_read_unchecked(&sk->sk_drops), &len);
95340 }
95341 seq_printf(seq, "%*s\n", 127 - len, "");
95342 return 0;
95343 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
95344 index c02a8c4..3c5b600 100644
95345 --- a/net/phonet/sysctl.c
95346 +++ b/net/phonet/sysctl.c
95347 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
95348 {
95349 int ret;
95350 int range[2] = {local_port_range[0], local_port_range[1]};
95351 - struct ctl_table tmp = {
95352 + ctl_table_no_const tmp = {
95353 .data = &range,
95354 .maxlen = sizeof(range),
95355 .mode = table->mode,
95356 diff --git a/net/rds/cong.c b/net/rds/cong.c
95357 index e5b65ac..f3b6fb7 100644
95358 --- a/net/rds/cong.c
95359 +++ b/net/rds/cong.c
95360 @@ -78,7 +78,7 @@
95361 * finds that the saved generation number is smaller than the global generation
95362 * number, it wakes up the process.
95363 */
95364 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
95365 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
95366
95367 /*
95368 * Congestion monitoring
95369 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
95370 rdsdebug("waking map %p for %pI4\n",
95371 map, &map->m_addr);
95372 rds_stats_inc(s_cong_update_received);
95373 - atomic_inc(&rds_cong_generation);
95374 + atomic_inc_unchecked(&rds_cong_generation);
95375 if (waitqueue_active(&map->m_waitq))
95376 wake_up(&map->m_waitq);
95377 if (waitqueue_active(&rds_poll_waitq))
95378 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
95379
95380 int rds_cong_updated_since(unsigned long *recent)
95381 {
95382 - unsigned long gen = atomic_read(&rds_cong_generation);
95383 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
95384
95385 if (likely(*recent == gen))
95386 return 0;
95387 diff --git a/net/rds/ib.h b/net/rds/ib.h
95388 index 7280ab8..e04f4ea 100644
95389 --- a/net/rds/ib.h
95390 +++ b/net/rds/ib.h
95391 @@ -128,7 +128,7 @@ struct rds_ib_connection {
95392 /* sending acks */
95393 unsigned long i_ack_flags;
95394 #ifdef KERNEL_HAS_ATOMIC64
95395 - atomic64_t i_ack_next; /* next ACK to send */
95396 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95397 #else
95398 spinlock_t i_ack_lock; /* protect i_ack_next */
95399 u64 i_ack_next; /* next ACK to send */
95400 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
95401 index 31b74f5..dc1fbfa 100644
95402 --- a/net/rds/ib_cm.c
95403 +++ b/net/rds/ib_cm.c
95404 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
95405 /* Clear the ACK state */
95406 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95407 #ifdef KERNEL_HAS_ATOMIC64
95408 - atomic64_set(&ic->i_ack_next, 0);
95409 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95410 #else
95411 ic->i_ack_next = 0;
95412 #endif
95413 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
95414 index 8eb9501..0c386ff 100644
95415 --- a/net/rds/ib_recv.c
95416 +++ b/net/rds/ib_recv.c
95417 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95418 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
95419 int ack_required)
95420 {
95421 - atomic64_set(&ic->i_ack_next, seq);
95422 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95423 if (ack_required) {
95424 smp_mb__before_clear_bit();
95425 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95426 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95427 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95428 smp_mb__after_clear_bit();
95429
95430 - return atomic64_read(&ic->i_ack_next);
95431 + return atomic64_read_unchecked(&ic->i_ack_next);
95432 }
95433 #endif
95434
95435 diff --git a/net/rds/iw.h b/net/rds/iw.h
95436 index 04ce3b1..48119a6 100644
95437 --- a/net/rds/iw.h
95438 +++ b/net/rds/iw.h
95439 @@ -134,7 +134,7 @@ struct rds_iw_connection {
95440 /* sending acks */
95441 unsigned long i_ack_flags;
95442 #ifdef KERNEL_HAS_ATOMIC64
95443 - atomic64_t i_ack_next; /* next ACK to send */
95444 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95445 #else
95446 spinlock_t i_ack_lock; /* protect i_ack_next */
95447 u64 i_ack_next; /* next ACK to send */
95448 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
95449 index a91e1db..cf3053f 100644
95450 --- a/net/rds/iw_cm.c
95451 +++ b/net/rds/iw_cm.c
95452 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
95453 /* Clear the ACK state */
95454 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95455 #ifdef KERNEL_HAS_ATOMIC64
95456 - atomic64_set(&ic->i_ack_next, 0);
95457 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95458 #else
95459 ic->i_ack_next = 0;
95460 #endif
95461 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
95462 index 4503335..db566b4 100644
95463 --- a/net/rds/iw_recv.c
95464 +++ b/net/rds/iw_recv.c
95465 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95466 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
95467 int ack_required)
95468 {
95469 - atomic64_set(&ic->i_ack_next, seq);
95470 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95471 if (ack_required) {
95472 smp_mb__before_clear_bit();
95473 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95474 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95475 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95476 smp_mb__after_clear_bit();
95477
95478 - return atomic64_read(&ic->i_ack_next);
95479 + return atomic64_read_unchecked(&ic->i_ack_next);
95480 }
95481 #endif
95482
95483 diff --git a/net/rds/rds.h b/net/rds/rds.h
95484 index ec1d731..90a3a8d 100644
95485 --- a/net/rds/rds.h
95486 +++ b/net/rds/rds.h
95487 @@ -449,7 +449,7 @@ struct rds_transport {
95488 void (*sync_mr)(void *trans_private, int direction);
95489 void (*free_mr)(void *trans_private, int invalidate);
95490 void (*flush_mrs)(void);
95491 -};
95492 +} __do_const;
95493
95494 struct rds_sock {
95495 struct sock rs_sk;
95496 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
95497 index edac9ef..16bcb98 100644
95498 --- a/net/rds/tcp.c
95499 +++ b/net/rds/tcp.c
95500 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
95501 int val = 1;
95502
95503 set_fs(KERNEL_DS);
95504 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
95505 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
95506 sizeof(val));
95507 set_fs(oldfs);
95508 }
95509 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
95510 index 81cf5a4..b5826ff 100644
95511 --- a/net/rds/tcp_send.c
95512 +++ b/net/rds/tcp_send.c
95513 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
95514
95515 oldfs = get_fs();
95516 set_fs(KERNEL_DS);
95517 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
95518 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
95519 sizeof(val));
95520 set_fs(oldfs);
95521 }
95522 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
95523 index e61aa60..f07cc89 100644
95524 --- a/net/rxrpc/af_rxrpc.c
95525 +++ b/net/rxrpc/af_rxrpc.c
95526 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
95527 __be32 rxrpc_epoch;
95528
95529 /* current debugging ID */
95530 -atomic_t rxrpc_debug_id;
95531 +atomic_unchecked_t rxrpc_debug_id;
95532
95533 /* count of skbs currently in use */
95534 atomic_t rxrpc_n_skbs;
95535 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
95536 index e4d9cbc..b229649 100644
95537 --- a/net/rxrpc/ar-ack.c
95538 +++ b/net/rxrpc/ar-ack.c
95539 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95540
95541 _enter("{%d,%d,%d,%d},",
95542 call->acks_hard, call->acks_unacked,
95543 - atomic_read(&call->sequence),
95544 + atomic_read_unchecked(&call->sequence),
95545 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
95546
95547 stop = 0;
95548 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95549
95550 /* each Tx packet has a new serial number */
95551 sp->hdr.serial =
95552 - htonl(atomic_inc_return(&call->conn->serial));
95553 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
95554
95555 hdr = (struct rxrpc_header *) txb->head;
95556 hdr->serial = sp->hdr.serial;
95557 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
95558 */
95559 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
95560 {
95561 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
95562 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
95563 }
95564
95565 /*
95566 @@ -629,7 +629,7 @@ process_further:
95567
95568 latest = ntohl(sp->hdr.serial);
95569 hard = ntohl(ack.firstPacket);
95570 - tx = atomic_read(&call->sequence);
95571 + tx = atomic_read_unchecked(&call->sequence);
95572
95573 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95574 latest,
95575 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
95576 goto maybe_reschedule;
95577
95578 send_ACK_with_skew:
95579 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
95580 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
95581 ntohl(ack.serial));
95582 send_ACK:
95583 mtu = call->conn->trans->peer->if_mtu;
95584 @@ -1173,7 +1173,7 @@ send_ACK:
95585 ackinfo.rxMTU = htonl(5692);
95586 ackinfo.jumbo_max = htonl(4);
95587
95588 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95589 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95590 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95591 ntohl(hdr.serial),
95592 ntohs(ack.maxSkew),
95593 @@ -1191,7 +1191,7 @@ send_ACK:
95594 send_message:
95595 _debug("send message");
95596
95597 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95598 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95599 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
95600 send_message_2:
95601
95602 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
95603 index a3bbb36..3341fb9 100644
95604 --- a/net/rxrpc/ar-call.c
95605 +++ b/net/rxrpc/ar-call.c
95606 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
95607 spin_lock_init(&call->lock);
95608 rwlock_init(&call->state_lock);
95609 atomic_set(&call->usage, 1);
95610 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
95611 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95612 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
95613
95614 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
95615 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
95616 index 4106ca9..a338d7a 100644
95617 --- a/net/rxrpc/ar-connection.c
95618 +++ b/net/rxrpc/ar-connection.c
95619 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
95620 rwlock_init(&conn->lock);
95621 spin_lock_init(&conn->state_lock);
95622 atomic_set(&conn->usage, 1);
95623 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
95624 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95625 conn->avail_calls = RXRPC_MAXCALLS;
95626 conn->size_align = 4;
95627 conn->header_size = sizeof(struct rxrpc_header);
95628 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
95629 index e7ed43a..6afa140 100644
95630 --- a/net/rxrpc/ar-connevent.c
95631 +++ b/net/rxrpc/ar-connevent.c
95632 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
95633
95634 len = iov[0].iov_len + iov[1].iov_len;
95635
95636 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95637 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95638 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
95639
95640 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95641 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
95642 index 529572f..c758ca7 100644
95643 --- a/net/rxrpc/ar-input.c
95644 +++ b/net/rxrpc/ar-input.c
95645 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
95646 /* track the latest serial number on this connection for ACK packet
95647 * information */
95648 serial = ntohl(sp->hdr.serial);
95649 - hi_serial = atomic_read(&call->conn->hi_serial);
95650 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
95651 while (serial > hi_serial)
95652 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
95653 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
95654 serial);
95655
95656 /* request ACK generation for any ACK or DATA packet that requests
95657 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
95658 index a693aca..81e7293 100644
95659 --- a/net/rxrpc/ar-internal.h
95660 +++ b/net/rxrpc/ar-internal.h
95661 @@ -272,8 +272,8 @@ struct rxrpc_connection {
95662 int error; /* error code for local abort */
95663 int debug_id; /* debug ID for printks */
95664 unsigned int call_counter; /* call ID counter */
95665 - atomic_t serial; /* packet serial number counter */
95666 - atomic_t hi_serial; /* highest serial number received */
95667 + atomic_unchecked_t serial; /* packet serial number counter */
95668 + atomic_unchecked_t hi_serial; /* highest serial number received */
95669 u8 avail_calls; /* number of calls available */
95670 u8 size_align; /* data size alignment (for security) */
95671 u8 header_size; /* rxrpc + security header size */
95672 @@ -346,7 +346,7 @@ struct rxrpc_call {
95673 spinlock_t lock;
95674 rwlock_t state_lock; /* lock for state transition */
95675 atomic_t usage;
95676 - atomic_t sequence; /* Tx data packet sequence counter */
95677 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
95678 u32 abort_code; /* local/remote abort code */
95679 enum { /* current state of call */
95680 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
95681 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
95682 */
95683 extern atomic_t rxrpc_n_skbs;
95684 extern __be32 rxrpc_epoch;
95685 -extern atomic_t rxrpc_debug_id;
95686 +extern atomic_unchecked_t rxrpc_debug_id;
95687 extern struct workqueue_struct *rxrpc_workqueue;
95688
95689 /*
95690 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
95691 index 87f7135..74d3703 100644
95692 --- a/net/rxrpc/ar-local.c
95693 +++ b/net/rxrpc/ar-local.c
95694 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
95695 spin_lock_init(&local->lock);
95696 rwlock_init(&local->services_lock);
95697 atomic_set(&local->usage, 1);
95698 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
95699 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95700 memcpy(&local->srx, srx, sizeof(*srx));
95701 }
95702
95703 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
95704 index e1ac183..b43e10e 100644
95705 --- a/net/rxrpc/ar-output.c
95706 +++ b/net/rxrpc/ar-output.c
95707 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
95708 sp->hdr.cid = call->cid;
95709 sp->hdr.callNumber = call->call_id;
95710 sp->hdr.seq =
95711 - htonl(atomic_inc_return(&call->sequence));
95712 + htonl(atomic_inc_return_unchecked(&call->sequence));
95713 sp->hdr.serial =
95714 - htonl(atomic_inc_return(&conn->serial));
95715 + htonl(atomic_inc_return_unchecked(&conn->serial));
95716 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
95717 sp->hdr.userStatus = 0;
95718 sp->hdr.securityIndex = conn->security_ix;
95719 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
95720 index bebaa43..2644591 100644
95721 --- a/net/rxrpc/ar-peer.c
95722 +++ b/net/rxrpc/ar-peer.c
95723 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
95724 INIT_LIST_HEAD(&peer->error_targets);
95725 spin_lock_init(&peer->lock);
95726 atomic_set(&peer->usage, 1);
95727 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
95728 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95729 memcpy(&peer->srx, srx, sizeof(*srx));
95730
95731 rxrpc_assess_MTU_size(peer);
95732 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
95733 index 38047f7..9f48511 100644
95734 --- a/net/rxrpc/ar-proc.c
95735 +++ b/net/rxrpc/ar-proc.c
95736 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
95737 atomic_read(&conn->usage),
95738 rxrpc_conn_states[conn->state],
95739 key_serial(conn->key),
95740 - atomic_read(&conn->serial),
95741 - atomic_read(&conn->hi_serial));
95742 + atomic_read_unchecked(&conn->serial),
95743 + atomic_read_unchecked(&conn->hi_serial));
95744
95745 return 0;
95746 }
95747 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
95748 index 92df566..87ec1bf 100644
95749 --- a/net/rxrpc/ar-transport.c
95750 +++ b/net/rxrpc/ar-transport.c
95751 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
95752 spin_lock_init(&trans->client_lock);
95753 rwlock_init(&trans->conn_lock);
95754 atomic_set(&trans->usage, 1);
95755 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
95756 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95757
95758 if (peer->srx.transport.family == AF_INET) {
95759 switch (peer->srx.transport_type) {
95760 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
95761 index f226709..0e735a8 100644
95762 --- a/net/rxrpc/rxkad.c
95763 +++ b/net/rxrpc/rxkad.c
95764 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
95765
95766 len = iov[0].iov_len + iov[1].iov_len;
95767
95768 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95769 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95770 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
95771
95772 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95773 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
95774
95775 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
95776
95777 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
95778 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95779 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
95780
95781 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
95782 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
95783 index 547a461e..ea606e3 100644
95784 --- a/net/sctp/ipv6.c
95785 +++ b/net/sctp/ipv6.c
95786 @@ -968,7 +968,7 @@ static const struct inet6_protocol sctpv6_protocol = {
95787 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
95788 };
95789
95790 -static struct sctp_af sctp_af_inet6 = {
95791 +static struct sctp_af sctp_af_inet6 __read_only = {
95792 .sa_family = AF_INET6,
95793 .sctp_xmit = sctp_v6_xmit,
95794 .setsockopt = ipv6_setsockopt,
95795 @@ -1000,7 +1000,7 @@ static struct sctp_af sctp_af_inet6 = {
95796 #endif
95797 };
95798
95799 -static struct sctp_pf sctp_pf_inet6 = {
95800 +static struct sctp_pf sctp_pf_inet6 __read_only = {
95801 .event_msgname = sctp_inet6_event_msgname,
95802 .skb_msgname = sctp_inet6_skb_msgname,
95803 .af_supported = sctp_inet6_af_supported,
95804 @@ -1025,7 +1025,7 @@ void sctp_v6_pf_init(void)
95805
95806 void sctp_v6_pf_exit(void)
95807 {
95808 - list_del(&sctp_af_inet6.list);
95809 + pax_list_del(&sctp_af_inet6.list);
95810 }
95811
95812 /* Initialize IPv6 support and register with socket layer. */
95813 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
95814 index 62526c4..36a13c5 100644
95815 --- a/net/sctp/proc.c
95816 +++ b/net/sctp/proc.c
95817 @@ -343,7 +343,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
95818 seq_printf(seq,
95819 "%8pK %8pK %-3d %-3d %-2d %-4d "
95820 "%4d %8d %8d %7d %5lu %-5d %5d ",
95821 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
95822 + assoc, sk,
95823 + sctp_sk(sk)->type, sk->sk_state,
95824 assoc->state, hash,
95825 assoc->assoc_id,
95826 assoc->sndbuf_used,
95827 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
95828 index 4a17494d..f7e3fa0 100644
95829 --- a/net/sctp/protocol.c
95830 +++ b/net/sctp/protocol.c
95831 @@ -838,8 +838,10 @@ int sctp_register_af(struct sctp_af *af)
95832 return 0;
95833 }
95834
95835 + pax_open_kernel();
95836 INIT_LIST_HEAD(&af->list);
95837 - list_add_tail(&af->list, &sctp_address_families);
95838 + pax_close_kernel();
95839 + pax_list_add_tail(&af->list, &sctp_address_families);
95840 return 1;
95841 }
95842
95843 @@ -969,7 +971,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
95844
95845 static struct sctp_af sctp_af_inet;
95846
95847 -static struct sctp_pf sctp_pf_inet = {
95848 +static struct sctp_pf sctp_pf_inet __read_only = {
95849 .event_msgname = sctp_inet_event_msgname,
95850 .skb_msgname = sctp_inet_skb_msgname,
95851 .af_supported = sctp_inet_af_supported,
95852 @@ -1040,7 +1042,7 @@ static const struct net_protocol sctp_protocol = {
95853 };
95854
95855 /* IPv4 address related functions. */
95856 -static struct sctp_af sctp_af_inet = {
95857 +static struct sctp_af sctp_af_inet __read_only = {
95858 .sa_family = AF_INET,
95859 .sctp_xmit = sctp_v4_xmit,
95860 .setsockopt = ip_setsockopt,
95861 @@ -1125,7 +1127,7 @@ static void sctp_v4_pf_init(void)
95862
95863 static void sctp_v4_pf_exit(void)
95864 {
95865 - list_del(&sctp_af_inet.list);
95866 + pax_list_del(&sctp_af_inet.list);
95867 }
95868
95869 static int sctp_v4_protosw_init(void)
95870 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
95871 index 9da6885..7571898 100644
95872 --- a/net/sctp/sm_sideeffect.c
95873 +++ b/net/sctp/sm_sideeffect.c
95874 @@ -446,7 +446,7 @@ static void sctp_generate_sack_event(unsigned long data)
95875 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
95876 }
95877
95878 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95879 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95880 NULL,
95881 sctp_generate_t1_cookie_event,
95882 sctp_generate_t1_init_event,
95883 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
95884 index cf6c6b0..b978b65 100644
95885 --- a/net/sctp/socket.c
95886 +++ b/net/sctp/socket.c
95887 @@ -2159,11 +2159,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
95888 {
95889 struct sctp_association *asoc;
95890 struct sctp_ulpevent *event;
95891 + struct sctp_event_subscribe subscribe;
95892
95893 if (optlen > sizeof(struct sctp_event_subscribe))
95894 return -EINVAL;
95895 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
95896 + if (copy_from_user(&subscribe, optval, optlen))
95897 return -EFAULT;
95898 + sctp_sk(sk)->subscribe = subscribe;
95899
95900 /*
95901 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
95902 @@ -4219,13 +4221,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
95903 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95904 int __user *optlen)
95905 {
95906 + struct sctp_event_subscribe subscribe;
95907 +
95908 if (len <= 0)
95909 return -EINVAL;
95910 if (len > sizeof(struct sctp_event_subscribe))
95911 len = sizeof(struct sctp_event_subscribe);
95912 if (put_user(len, optlen))
95913 return -EFAULT;
95914 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
95915 + subscribe = sctp_sk(sk)->subscribe;
95916 + if (copy_to_user(optval, &subscribe, len))
95917 return -EFAULT;
95918 return 0;
95919 }
95920 @@ -4243,6 +4248,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95921 */
95922 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
95923 {
95924 + __u32 autoclose;
95925 +
95926 /* Applicable to UDP-style socket only */
95927 if (sctp_style(sk, TCP))
95928 return -EOPNOTSUPP;
95929 @@ -4251,7 +4258,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
95930 len = sizeof(int);
95931 if (put_user(len, optlen))
95932 return -EFAULT;
95933 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
95934 + autoclose = sctp_sk(sk)->autoclose;
95935 + if (copy_to_user(optval, &autoclose, sizeof(int)))
95936 return -EFAULT;
95937 return 0;
95938 }
95939 @@ -4623,12 +4631,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
95940 */
95941 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
95942 {
95943 + struct sctp_initmsg initmsg;
95944 +
95945 if (len < sizeof(struct sctp_initmsg))
95946 return -EINVAL;
95947 len = sizeof(struct sctp_initmsg);
95948 if (put_user(len, optlen))
95949 return -EFAULT;
95950 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
95951 + initmsg = sctp_sk(sk)->initmsg;
95952 + if (copy_to_user(optval, &initmsg, len))
95953 return -EFAULT;
95954 return 0;
95955 }
95956 @@ -4669,6 +4680,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
95957 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
95958 if (space_left < addrlen)
95959 return -ENOMEM;
95960 + if (addrlen > sizeof(temp) || addrlen < 0)
95961 + return -EFAULT;
95962 if (copy_to_user(to, &temp, addrlen))
95963 return -EFAULT;
95964 to += addrlen;
95965 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
95966 index 9a5c4c9..46e4b29 100644
95967 --- a/net/sctp/sysctl.c
95968 +++ b/net/sctp/sysctl.c
95969 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95970 {
95971 struct net *net = current->nsproxy->net_ns;
95972 char tmp[8];
95973 - struct ctl_table tbl;
95974 + ctl_table_no_const tbl;
95975 int ret;
95976 int changed = 0;
95977 char *none = "none";
95978 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95979
95980 int sctp_sysctl_net_register(struct net *net)
95981 {
95982 - struct ctl_table *table;
95983 + ctl_table_no_const *table;
95984 int i;
95985
95986 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
95987 diff --git a/net/socket.c b/net/socket.c
95988 index 4b94643..f703b02 100644
95989 --- a/net/socket.c
95990 +++ b/net/socket.c
95991 @@ -88,6 +88,7 @@
95992 #include <linux/magic.h>
95993 #include <linux/slab.h>
95994 #include <linux/xattr.h>
95995 +#include <linux/in.h>
95996
95997 #include <asm/uaccess.h>
95998 #include <asm/unistd.h>
95999 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
96000 unsigned int sysctl_net_busy_poll __read_mostly;
96001 #endif
96002
96003 +#include <linux/grsock.h>
96004 +
96005 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
96006 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
96007 unsigned long nr_segs, loff_t pos);
96008 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
96009 */
96010
96011 static DEFINE_SPINLOCK(net_family_lock);
96012 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96013 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96014
96015 /*
96016 * Statistics counters of the socket lists
96017 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
96018 &sockfs_dentry_operations, SOCKFS_MAGIC);
96019 }
96020
96021 -static struct vfsmount *sock_mnt __read_mostly;
96022 +struct vfsmount *sock_mnt __read_mostly;
96023
96024 static struct file_system_type sock_fs_type = {
96025 .name = "sockfs",
96026 @@ -1263,6 +1266,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96027 return -EAFNOSUPPORT;
96028 if (type < 0 || type >= SOCK_MAX)
96029 return -EINVAL;
96030 + if (protocol < 0)
96031 + return -EINVAL;
96032
96033 /* Compatibility.
96034
96035 @@ -1283,6 +1288,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96036 if (err)
96037 return err;
96038
96039 + if(!kern && !gr_search_socket(family, type, protocol)) {
96040 + if (rcu_access_pointer(net_families[family]) == NULL)
96041 + return -EAFNOSUPPORT;
96042 + else
96043 + return -EACCES;
96044 + }
96045 +
96046 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
96047 + if (rcu_access_pointer(net_families[family]) == NULL)
96048 + return -EAFNOSUPPORT;
96049 + else
96050 + return -EACCES;
96051 + }
96052 +
96053 /*
96054 * Allocate the socket and allow the family to set things up. if
96055 * the protocol is 0, the family is instructed to select an appropriate
96056 @@ -1521,6 +1540,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96057 if (sock) {
96058 err = move_addr_to_kernel(umyaddr, addrlen, &address);
96059 if (err >= 0) {
96060 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
96061 + err = -EACCES;
96062 + goto error;
96063 + }
96064 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
96065 + if (err)
96066 + goto error;
96067 +
96068 err = security_socket_bind(sock,
96069 (struct sockaddr *)&address,
96070 addrlen);
96071 @@ -1529,6 +1556,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96072 (struct sockaddr *)
96073 &address, addrlen);
96074 }
96075 +error:
96076 fput_light(sock->file, fput_needed);
96077 }
96078 return err;
96079 @@ -1552,10 +1580,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
96080 if ((unsigned int)backlog > somaxconn)
96081 backlog = somaxconn;
96082
96083 + if (gr_handle_sock_server_other(sock->sk)) {
96084 + err = -EPERM;
96085 + goto error;
96086 + }
96087 +
96088 + err = gr_search_listen(sock);
96089 + if (err)
96090 + goto error;
96091 +
96092 err = security_socket_listen(sock, backlog);
96093 if (!err)
96094 err = sock->ops->listen(sock, backlog);
96095
96096 +error:
96097 fput_light(sock->file, fput_needed);
96098 }
96099 return err;
96100 @@ -1599,6 +1637,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96101 newsock->type = sock->type;
96102 newsock->ops = sock->ops;
96103
96104 + if (gr_handle_sock_server_other(sock->sk)) {
96105 + err = -EPERM;
96106 + sock_release(newsock);
96107 + goto out_put;
96108 + }
96109 +
96110 + err = gr_search_accept(sock);
96111 + if (err) {
96112 + sock_release(newsock);
96113 + goto out_put;
96114 + }
96115 +
96116 /*
96117 * We don't need try_module_get here, as the listening socket (sock)
96118 * has the protocol module (sock->ops->owner) held.
96119 @@ -1644,6 +1694,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96120 fd_install(newfd, newfile);
96121 err = newfd;
96122
96123 + gr_attach_curr_ip(newsock->sk);
96124 +
96125 out_put:
96126 fput_light(sock->file, fput_needed);
96127 out:
96128 @@ -1676,6 +1728,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96129 int, addrlen)
96130 {
96131 struct socket *sock;
96132 + struct sockaddr *sck;
96133 struct sockaddr_storage address;
96134 int err, fput_needed;
96135
96136 @@ -1686,6 +1739,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96137 if (err < 0)
96138 goto out_put;
96139
96140 + sck = (struct sockaddr *)&address;
96141 +
96142 + if (gr_handle_sock_client(sck)) {
96143 + err = -EACCES;
96144 + goto out_put;
96145 + }
96146 +
96147 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
96148 + if (err)
96149 + goto out_put;
96150 +
96151 err =
96152 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
96153 if (err)
96154 @@ -1767,6 +1831,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
96155 * the protocol.
96156 */
96157
96158 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
96159 +
96160 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
96161 unsigned int, flags, struct sockaddr __user *, addr,
96162 int, addr_len)
96163 @@ -1833,7 +1899,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
96164 struct socket *sock;
96165 struct iovec iov;
96166 struct msghdr msg;
96167 - struct sockaddr_storage address;
96168 + struct sockaddr_storage address = { };
96169 int err, err2;
96170 int fput_needed;
96171
96172 @@ -2053,7 +2119,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
96173 * checking falls down on this.
96174 */
96175 if (copy_from_user(ctl_buf,
96176 - (void __user __force *)msg_sys->msg_control,
96177 + (void __force_user *)msg_sys->msg_control,
96178 ctl_len))
96179 goto out_freectl;
96180 msg_sys->msg_control = ctl_buf;
96181 @@ -2204,7 +2270,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96182 int err, total_len, len;
96183
96184 /* kernel mode address */
96185 - struct sockaddr_storage addr;
96186 + struct sockaddr_storage addr = { };
96187
96188 /* user mode address pointers */
96189 struct sockaddr __user *uaddr;
96190 @@ -2235,7 +2301,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96191 * kernel msghdr to use the kernel address space)
96192 */
96193
96194 - uaddr = (__force void __user *)msg_sys->msg_name;
96195 + uaddr = (void __force_user *)msg_sys->msg_name;
96196 uaddr_len = COMPAT_NAMELEN(msg);
96197 if (MSG_CMSG_COMPAT & flags) {
96198 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
96199 @@ -2990,7 +3056,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
96200 old_fs = get_fs();
96201 set_fs(KERNEL_DS);
96202 err = dev_ioctl(net, cmd,
96203 - (struct ifreq __user __force *) &kifr);
96204 + (struct ifreq __force_user *) &kifr);
96205 set_fs(old_fs);
96206
96207 return err;
96208 @@ -3099,7 +3165,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
96209
96210 old_fs = get_fs();
96211 set_fs(KERNEL_DS);
96212 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
96213 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
96214 set_fs(old_fs);
96215
96216 if (cmd == SIOCGIFMAP && !err) {
96217 @@ -3204,7 +3270,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
96218 ret |= __get_user(rtdev, &(ur4->rt_dev));
96219 if (rtdev) {
96220 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
96221 - r4.rt_dev = (char __user __force *)devname;
96222 + r4.rt_dev = (char __force_user *)devname;
96223 devname[15] = 0;
96224 } else
96225 r4.rt_dev = NULL;
96226 @@ -3430,8 +3496,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
96227 int __user *uoptlen;
96228 int err;
96229
96230 - uoptval = (char __user __force *) optval;
96231 - uoptlen = (int __user __force *) optlen;
96232 + uoptval = (char __force_user *) optval;
96233 + uoptlen = (int __force_user *) optlen;
96234
96235 set_fs(KERNEL_DS);
96236 if (level == SOL_SOCKET)
96237 @@ -3451,7 +3517,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
96238 char __user *uoptval;
96239 int err;
96240
96241 - uoptval = (char __user __force *) optval;
96242 + uoptval = (char __force_user *) optval;
96243
96244 set_fs(KERNEL_DS);
96245 if (level == SOL_SOCKET)
96246 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
96247 index 09fb638..2e6a5c5 100644
96248 --- a/net/sunrpc/auth_gss/svcauth_gss.c
96249 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
96250 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96251 uint64_t *handle)
96252 {
96253 struct rsc rsci, *rscp = NULL;
96254 - static atomic64_t ctxhctr;
96255 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
96256 long long ctxh;
96257 struct gss_api_mech *gm = NULL;
96258 time_t expiry;
96259 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96260 status = -ENOMEM;
96261 /* the handle needs to be just a unique id,
96262 * use a static counter */
96263 - ctxh = atomic64_inc_return(&ctxhctr);
96264 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
96265
96266 /* make a copy for the caller */
96267 *handle = ctxh;
96268 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
96269 index ecbc4e3..098e564 100644
96270 --- a/net/sunrpc/clnt.c
96271 +++ b/net/sunrpc/clnt.c
96272 @@ -645,14 +645,16 @@ EXPORT_SYMBOL_GPL(rpc_shutdown_client);
96273 /*
96274 * Free an RPC client
96275 */
96276 -static void
96277 +static struct rpc_clnt *
96278 rpc_free_client(struct rpc_clnt *clnt)
96279 {
96280 + struct rpc_clnt *parent = NULL;
96281 +
96282 dprintk_rcu("RPC: destroying %s client for %s\n",
96283 clnt->cl_protname,
96284 rcu_dereference(clnt->cl_xprt)->servername);
96285 if (clnt->cl_parent != clnt)
96286 - rpc_release_client(clnt->cl_parent);
96287 + parent = clnt->cl_parent;
96288 rpc_clnt_remove_pipedir(clnt);
96289 rpc_unregister_client(clnt);
96290 rpc_free_iostats(clnt->cl_metrics);
96291 @@ -661,18 +663,17 @@ rpc_free_client(struct rpc_clnt *clnt)
96292 xprt_put(rcu_dereference_raw(clnt->cl_xprt));
96293 rpciod_down();
96294 kfree(clnt);
96295 + return parent;
96296 }
96297
96298 /*
96299 * Free an RPC client
96300 */
96301 -static void
96302 +static struct rpc_clnt *
96303 rpc_free_auth(struct rpc_clnt *clnt)
96304 {
96305 - if (clnt->cl_auth == NULL) {
96306 - rpc_free_client(clnt);
96307 - return;
96308 - }
96309 + if (clnt->cl_auth == NULL)
96310 + return rpc_free_client(clnt);
96311
96312 /*
96313 * Note: RPCSEC_GSS may need to send NULL RPC calls in order to
96314 @@ -683,7 +684,8 @@ rpc_free_auth(struct rpc_clnt *clnt)
96315 rpcauth_release(clnt->cl_auth);
96316 clnt->cl_auth = NULL;
96317 if (atomic_dec_and_test(&clnt->cl_count))
96318 - rpc_free_client(clnt);
96319 + return rpc_free_client(clnt);
96320 + return NULL;
96321 }
96322
96323 /*
96324 @@ -694,10 +696,13 @@ rpc_release_client(struct rpc_clnt *clnt)
96325 {
96326 dprintk("RPC: rpc_release_client(%p)\n", clnt);
96327
96328 - if (list_empty(&clnt->cl_tasks))
96329 - wake_up(&destroy_wait);
96330 - if (atomic_dec_and_test(&clnt->cl_count))
96331 - rpc_free_auth(clnt);
96332 + do {
96333 + if (list_empty(&clnt->cl_tasks))
96334 + wake_up(&destroy_wait);
96335 + if (!atomic_dec_and_test(&clnt->cl_count))
96336 + break;
96337 + clnt = rpc_free_auth(clnt);
96338 + } while (clnt != NULL);
96339 }
96340 EXPORT_SYMBOL_GPL(rpc_release_client);
96341
96342 @@ -1304,7 +1309,9 @@ call_start(struct rpc_task *task)
96343 (RPC_IS_ASYNC(task) ? "async" : "sync"));
96344
96345 /* Increment call count */
96346 - task->tk_msg.rpc_proc->p_count++;
96347 + pax_open_kernel();
96348 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
96349 + pax_close_kernel();
96350 clnt->cl_stats->rpccnt++;
96351 task->tk_action = call_reserve;
96352 }
96353 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
96354 index 93a7a4e..3b98b9f 100644
96355 --- a/net/sunrpc/sched.c
96356 +++ b/net/sunrpc/sched.c
96357 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
96358 #ifdef RPC_DEBUG
96359 static void rpc_task_set_debuginfo(struct rpc_task *task)
96360 {
96361 - static atomic_t rpc_pid;
96362 + static atomic_unchecked_t rpc_pid;
96363
96364 - task->tk_pid = atomic_inc_return(&rpc_pid);
96365 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
96366 }
96367 #else
96368 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
96369 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
96370 index b974571..678ed90 100644
96371 --- a/net/sunrpc/svc.c
96372 +++ b/net/sunrpc/svc.c
96373 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
96374 svc_putnl(resv, RPC_SUCCESS);
96375
96376 /* Bump per-procedure stats counter */
96377 - procp->pc_count++;
96378 + pax_open_kernel();
96379 + (*(unsigned int *)&procp->pc_count)++;
96380 + pax_close_kernel();
96381
96382 /* Initialize storage for argp and resp */
96383 memset(rqstp->rq_argp, 0, procp->pc_argsize);
96384 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
96385 index c1b6270..05089c1 100644
96386 --- a/net/sunrpc/xprtrdma/svc_rdma.c
96387 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
96388 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
96389 static unsigned int min_max_inline = 4096;
96390 static unsigned int max_max_inline = 65536;
96391
96392 -atomic_t rdma_stat_recv;
96393 -atomic_t rdma_stat_read;
96394 -atomic_t rdma_stat_write;
96395 -atomic_t rdma_stat_sq_starve;
96396 -atomic_t rdma_stat_rq_starve;
96397 -atomic_t rdma_stat_rq_poll;
96398 -atomic_t rdma_stat_rq_prod;
96399 -atomic_t rdma_stat_sq_poll;
96400 -atomic_t rdma_stat_sq_prod;
96401 +atomic_unchecked_t rdma_stat_recv;
96402 +atomic_unchecked_t rdma_stat_read;
96403 +atomic_unchecked_t rdma_stat_write;
96404 +atomic_unchecked_t rdma_stat_sq_starve;
96405 +atomic_unchecked_t rdma_stat_rq_starve;
96406 +atomic_unchecked_t rdma_stat_rq_poll;
96407 +atomic_unchecked_t rdma_stat_rq_prod;
96408 +atomic_unchecked_t rdma_stat_sq_poll;
96409 +atomic_unchecked_t rdma_stat_sq_prod;
96410
96411 /* Temporary NFS request map and context caches */
96412 struct kmem_cache *svc_rdma_map_cachep;
96413 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
96414 len -= *ppos;
96415 if (len > *lenp)
96416 len = *lenp;
96417 - if (len && copy_to_user(buffer, str_buf, len))
96418 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
96419 return -EFAULT;
96420 *lenp = len;
96421 *ppos += len;
96422 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
96423 {
96424 .procname = "rdma_stat_read",
96425 .data = &rdma_stat_read,
96426 - .maxlen = sizeof(atomic_t),
96427 + .maxlen = sizeof(atomic_unchecked_t),
96428 .mode = 0644,
96429 .proc_handler = read_reset_stat,
96430 },
96431 {
96432 .procname = "rdma_stat_recv",
96433 .data = &rdma_stat_recv,
96434 - .maxlen = sizeof(atomic_t),
96435 + .maxlen = sizeof(atomic_unchecked_t),
96436 .mode = 0644,
96437 .proc_handler = read_reset_stat,
96438 },
96439 {
96440 .procname = "rdma_stat_write",
96441 .data = &rdma_stat_write,
96442 - .maxlen = sizeof(atomic_t),
96443 + .maxlen = sizeof(atomic_unchecked_t),
96444 .mode = 0644,
96445 .proc_handler = read_reset_stat,
96446 },
96447 {
96448 .procname = "rdma_stat_sq_starve",
96449 .data = &rdma_stat_sq_starve,
96450 - .maxlen = sizeof(atomic_t),
96451 + .maxlen = sizeof(atomic_unchecked_t),
96452 .mode = 0644,
96453 .proc_handler = read_reset_stat,
96454 },
96455 {
96456 .procname = "rdma_stat_rq_starve",
96457 .data = &rdma_stat_rq_starve,
96458 - .maxlen = sizeof(atomic_t),
96459 + .maxlen = sizeof(atomic_unchecked_t),
96460 .mode = 0644,
96461 .proc_handler = read_reset_stat,
96462 },
96463 {
96464 .procname = "rdma_stat_rq_poll",
96465 .data = &rdma_stat_rq_poll,
96466 - .maxlen = sizeof(atomic_t),
96467 + .maxlen = sizeof(atomic_unchecked_t),
96468 .mode = 0644,
96469 .proc_handler = read_reset_stat,
96470 },
96471 {
96472 .procname = "rdma_stat_rq_prod",
96473 .data = &rdma_stat_rq_prod,
96474 - .maxlen = sizeof(atomic_t),
96475 + .maxlen = sizeof(atomic_unchecked_t),
96476 .mode = 0644,
96477 .proc_handler = read_reset_stat,
96478 },
96479 {
96480 .procname = "rdma_stat_sq_poll",
96481 .data = &rdma_stat_sq_poll,
96482 - .maxlen = sizeof(atomic_t),
96483 + .maxlen = sizeof(atomic_unchecked_t),
96484 .mode = 0644,
96485 .proc_handler = read_reset_stat,
96486 },
96487 {
96488 .procname = "rdma_stat_sq_prod",
96489 .data = &rdma_stat_sq_prod,
96490 - .maxlen = sizeof(atomic_t),
96491 + .maxlen = sizeof(atomic_unchecked_t),
96492 .mode = 0644,
96493 .proc_handler = read_reset_stat,
96494 },
96495 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96496 index 0ce7552..d074459 100644
96497 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96498 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96499 @@ -501,7 +501,7 @@ next_sge:
96500 svc_rdma_put_context(ctxt, 0);
96501 goto out;
96502 }
96503 - atomic_inc(&rdma_stat_read);
96504 + atomic_inc_unchecked(&rdma_stat_read);
96505
96506 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
96507 chl_map->ch[ch_no].count -= read_wr.num_sge;
96508 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96509 dto_q);
96510 list_del_init(&ctxt->dto_q);
96511 } else {
96512 - atomic_inc(&rdma_stat_rq_starve);
96513 + atomic_inc_unchecked(&rdma_stat_rq_starve);
96514 clear_bit(XPT_DATA, &xprt->xpt_flags);
96515 ctxt = NULL;
96516 }
96517 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96518 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
96519 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
96520 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
96521 - atomic_inc(&rdma_stat_recv);
96522 + atomic_inc_unchecked(&rdma_stat_recv);
96523
96524 /* Build up the XDR from the receive buffers. */
96525 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
96526 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96527 index c1d124d..acfc59e 100644
96528 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96529 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96530 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
96531 write_wr.wr.rdma.remote_addr = to;
96532
96533 /* Post It */
96534 - atomic_inc(&rdma_stat_write);
96535 + atomic_inc_unchecked(&rdma_stat_write);
96536 if (svc_rdma_send(xprt, &write_wr))
96537 goto err;
96538 return 0;
96539 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96540 index 62e4f9b..dd3f2d7 100644
96541 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
96542 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96543 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96544 return;
96545
96546 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
96547 - atomic_inc(&rdma_stat_rq_poll);
96548 + atomic_inc_unchecked(&rdma_stat_rq_poll);
96549
96550 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
96551 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
96552 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96553 }
96554
96555 if (ctxt)
96556 - atomic_inc(&rdma_stat_rq_prod);
96557 + atomic_inc_unchecked(&rdma_stat_rq_prod);
96558
96559 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
96560 /*
96561 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96562 return;
96563
96564 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
96565 - atomic_inc(&rdma_stat_sq_poll);
96566 + atomic_inc_unchecked(&rdma_stat_sq_poll);
96567 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
96568 if (wc.status != IB_WC_SUCCESS)
96569 /* Close the transport */
96570 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96571 }
96572
96573 if (ctxt)
96574 - atomic_inc(&rdma_stat_sq_prod);
96575 + atomic_inc_unchecked(&rdma_stat_sq_prod);
96576 }
96577
96578 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
96579 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
96580 spin_lock_bh(&xprt->sc_lock);
96581 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
96582 spin_unlock_bh(&xprt->sc_lock);
96583 - atomic_inc(&rdma_stat_sq_starve);
96584 + atomic_inc_unchecked(&rdma_stat_sq_starve);
96585
96586 /* See if we can opportunistically reap SQ WR to make room */
96587 sq_cq_reap(xprt);
96588 diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
96589 index ddf0602..e865e08 100644
96590 --- a/net/sunrpc/xprtsock.c
96591 +++ b/net/sunrpc/xprtsock.c
96592 @@ -391,8 +391,10 @@ static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen,
96593 return kernel_sendmsg(sock, &msg, NULL, 0, 0);
96594 }
96595
96596 -static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more)
96597 +static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more, bool zerocopy)
96598 {
96599 + ssize_t (*do_sendpage)(struct socket *sock, struct page *page,
96600 + int offset, size_t size, int flags);
96601 struct page **ppage;
96602 unsigned int remainder;
96603 int err, sent = 0;
96604 @@ -401,6 +403,9 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
96605 base += xdr->page_base;
96606 ppage = xdr->pages + (base >> PAGE_SHIFT);
96607 base &= ~PAGE_MASK;
96608 + do_sendpage = sock->ops->sendpage;
96609 + if (!zerocopy)
96610 + do_sendpage = sock_no_sendpage;
96611 for(;;) {
96612 unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);
96613 int flags = XS_SENDMSG_FLAGS;
96614 @@ -408,7 +413,7 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
96615 remainder -= len;
96616 if (remainder != 0 || more)
96617 flags |= MSG_MORE;
96618 - err = sock->ops->sendpage(sock, *ppage, base, len, flags);
96619 + err = do_sendpage(sock, *ppage, base, len, flags);
96620 if (remainder == 0 || err != len)
96621 break;
96622 sent += err;
96623 @@ -429,9 +434,10 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
96624 * @addrlen: UDP only -- length of destination address
96625 * @xdr: buffer containing this request
96626 * @base: starting position in the buffer
96627 + * @zerocopy: true if it is safe to use sendpage()
96628 *
96629 */
96630 -static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base)
96631 +static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, bool zerocopy)
96632 {
96633 unsigned int remainder = xdr->len - base;
96634 int err, sent = 0;
96635 @@ -459,7 +465,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
96636 if (base < xdr->page_len) {
96637 unsigned int len = xdr->page_len - base;
96638 remainder -= len;
96639 - err = xs_send_pagedata(sock, xdr, base, remainder != 0);
96640 + err = xs_send_pagedata(sock, xdr, base, remainder != 0, zerocopy);
96641 if (remainder == 0 || err != len)
96642 goto out;
96643 sent += err;
96644 @@ -562,7 +568,7 @@ static int xs_local_send_request(struct rpc_task *task)
96645 req->rq_svec->iov_base, req->rq_svec->iov_len);
96646
96647 status = xs_sendpages(transport->sock, NULL, 0,
96648 - xdr, req->rq_bytes_sent);
96649 + xdr, req->rq_bytes_sent, true);
96650 dprintk("RPC: %s(%u) = %d\n",
96651 __func__, xdr->len - req->rq_bytes_sent, status);
96652 if (likely(status >= 0)) {
96653 @@ -618,7 +624,7 @@ static int xs_udp_send_request(struct rpc_task *task)
96654 status = xs_sendpages(transport->sock,
96655 xs_addr(xprt),
96656 xprt->addrlen, xdr,
96657 - req->rq_bytes_sent);
96658 + req->rq_bytes_sent, true);
96659
96660 dprintk("RPC: xs_udp_send_request(%u) = %d\n",
96661 xdr->len - req->rq_bytes_sent, status);
96662 @@ -689,6 +695,7 @@ static int xs_tcp_send_request(struct rpc_task *task)
96663 struct rpc_xprt *xprt = req->rq_xprt;
96664 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
96665 struct xdr_buf *xdr = &req->rq_snd_buf;
96666 + bool zerocopy = true;
96667 int status;
96668
96669 xs_encode_stream_record_marker(&req->rq_snd_buf);
96670 @@ -696,13 +703,20 @@ static int xs_tcp_send_request(struct rpc_task *task)
96671 xs_pktdump("packet data:",
96672 req->rq_svec->iov_base,
96673 req->rq_svec->iov_len);
96674 + /* Don't use zero copy if this is a resend. If the RPC call
96675 + * completes while the socket holds a reference to the pages,
96676 + * then we may end up resending corrupted data.
96677 + */
96678 + if (task->tk_flags & RPC_TASK_SENT)
96679 + zerocopy = false;
96680
96681 /* Continue transmitting the packet/record. We must be careful
96682 * to cope with writespace callbacks arriving _after_ we have
96683 * called sendmsg(). */
96684 while (1) {
96685 status = xs_sendpages(transport->sock,
96686 - NULL, 0, xdr, req->rq_bytes_sent);
96687 + NULL, 0, xdr, req->rq_bytes_sent,
96688 + zerocopy);
96689
96690 dprintk("RPC: xs_tcp_send_request(%u) = %d\n",
96691 xdr->len - req->rq_bytes_sent, status);
96692 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
96693 index e7000be..e3b0ba7 100644
96694 --- a/net/sysctl_net.c
96695 +++ b/net/sysctl_net.c
96696 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
96697 kgid_t root_gid = make_kgid(net->user_ns, 0);
96698
96699 /* Allow network administrator to have same access as root. */
96700 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
96701 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
96702 uid_eq(root_uid, current_euid())) {
96703 int mode = (table->mode >> 6) & 7;
96704 return (mode << 6) | (mode << 3) | mode;
96705 diff --git a/net/tipc/link.c b/net/tipc/link.c
96706 index 0cc3d90..cc42021 100644
96707 --- a/net/tipc/link.c
96708 +++ b/net/tipc/link.c
96709 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
96710 struct tipc_msg fragm_hdr;
96711 struct sk_buff *buf, *buf_chain, *prev;
96712 u32 fragm_crs, fragm_rest, hsz, sect_rest;
96713 - const unchar *sect_crs;
96714 + const unchar __user *sect_crs;
96715 int curr_sect;
96716 u32 fragm_no;
96717 int res = 0;
96718 @@ -1207,7 +1207,7 @@ again:
96719
96720 if (!sect_rest) {
96721 sect_rest = msg_sect[++curr_sect].iov_len;
96722 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
96723 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
96724 }
96725
96726 if (sect_rest < fragm_rest)
96727 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
96728 index ced60e2..54eab6c 100644
96729 --- a/net/tipc/msg.c
96730 +++ b/net/tipc/msg.c
96731 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
96732 skb_copy_to_linear_data(*buf, hdr, hsz);
96733 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
96734 skb_copy_to_linear_data_offset(*buf, pos,
96735 - msg_sect[cnt].iov_base,
96736 + (const void __force_kernel *)msg_sect[cnt].iov_base,
96737 msg_sect[cnt].iov_len);
96738 pos += msg_sect[cnt].iov_len;
96739 }
96740 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
96741 index d38bb45..4fd6ac6 100644
96742 --- a/net/tipc/subscr.c
96743 +++ b/net/tipc/subscr.c
96744 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
96745 struct kvec msg_sect;
96746 int ret;
96747
96748 - msg_sect.iov_base = (void *)&sub->evt;
96749 + msg_sect.iov_base = (void __force_user *)&sub->evt;
96750 msg_sect.iov_len = sizeof(struct tipc_event);
96751
96752 sub->evt.event = htohl(event, sub->swap);
96753 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
96754 index e64bbcf..9c3ba79 100644
96755 --- a/net/unix/af_unix.c
96756 +++ b/net/unix/af_unix.c
96757 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
96758 err = -ECONNREFUSED;
96759 if (!S_ISSOCK(inode->i_mode))
96760 goto put_fail;
96761 +
96762 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
96763 + err = -EACCES;
96764 + goto put_fail;
96765 + }
96766 +
96767 u = unix_find_socket_byinode(inode);
96768 if (!u)
96769 goto put_fail;
96770 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
96771 if (u) {
96772 struct dentry *dentry;
96773 dentry = unix_sk(u)->path.dentry;
96774 +
96775 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
96776 + err = -EPERM;
96777 + sock_put(u);
96778 + goto fail;
96779 + }
96780 +
96781 if (dentry)
96782 touch_atime(&unix_sk(u)->path);
96783 } else
96784 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
96785 */
96786 err = security_path_mknod(&path, dentry, mode, 0);
96787 if (!err) {
96788 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
96789 + err = -EACCES;
96790 + goto out;
96791 + }
96792 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
96793 if (!err) {
96794 res->mnt = mntget(path.mnt);
96795 res->dentry = dget(dentry);
96796 + gr_handle_create(dentry, path.mnt);
96797 }
96798 }
96799 +out:
96800 done_path_create(&path, dentry);
96801 return err;
96802 }
96803 @@ -2335,9 +2354,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96804 seq_puts(seq, "Num RefCount Protocol Flags Type St "
96805 "Inode Path\n");
96806 else {
96807 - struct sock *s = v;
96808 + struct sock *s = v, *peer;
96809 struct unix_sock *u = unix_sk(s);
96810 unix_state_lock(s);
96811 + peer = unix_peer(s);
96812 + unix_state_unlock(s);
96813 +
96814 + unix_state_double_lock(s, peer);
96815
96816 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
96817 s,
96818 @@ -2364,8 +2387,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96819 }
96820 for ( ; i < len; i++)
96821 seq_putc(seq, u->addr->name->sun_path[i]);
96822 - }
96823 - unix_state_unlock(s);
96824 + } else if (peer)
96825 + seq_printf(seq, " P%lu", sock_i_ino(peer));
96826 +
96827 + unix_state_double_unlock(s, peer);
96828 seq_putc(seq, '\n');
96829 }
96830
96831 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
96832 index b3d5150..ff3a837 100644
96833 --- a/net/unix/sysctl_net_unix.c
96834 +++ b/net/unix/sysctl_net_unix.c
96835 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
96836
96837 int __net_init unix_sysctl_register(struct net *net)
96838 {
96839 - struct ctl_table *table;
96840 + ctl_table_no_const *table;
96841
96842 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
96843 if (table == NULL)
96844 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
96845 index c8717c1..08539f5 100644
96846 --- a/net/wireless/wext-core.c
96847 +++ b/net/wireless/wext-core.c
96848 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96849 */
96850
96851 /* Support for very large requests */
96852 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
96853 - (user_length > descr->max_tokens)) {
96854 + if (user_length > descr->max_tokens) {
96855 /* Allow userspace to GET more than max so
96856 * we can support any size GET requests.
96857 * There is still a limit : -ENOMEM.
96858 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96859 }
96860 }
96861
96862 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
96863 - /*
96864 - * If this is a GET, but not NOMAX, it means that the extra
96865 - * data is not bounded by userspace, but by max_tokens. Thus
96866 - * set the length to max_tokens. This matches the extra data
96867 - * allocation.
96868 - * The driver should fill it with the number of tokens it
96869 - * provided, and it may check iwp->length rather than having
96870 - * knowledge of max_tokens. If the driver doesn't change the
96871 - * iwp->length, this ioctl just copies back max_token tokens
96872 - * filled with zeroes. Hopefully the driver isn't claiming
96873 - * them to be valid data.
96874 - */
96875 - iwp->length = descr->max_tokens;
96876 - }
96877 -
96878 err = handler(dev, info, (union iwreq_data *) iwp, extra);
96879
96880 iwp->length += essid_compat;
96881 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
96882 index f77c371..b0cb010 100644
96883 --- a/net/xfrm/xfrm_policy.c
96884 +++ b/net/xfrm/xfrm_policy.c
96885 @@ -332,9 +332,10 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
96886 {
96887 policy->walk.dead = 1;
96888
96889 - atomic_inc(&policy->genid);
96890 + atomic_inc_unchecked(&policy->genid);
96891
96892 - del_timer(&policy->polq.hold_timer);
96893 + if (del_timer(&policy->polq.hold_timer))
96894 + xfrm_pol_put(policy);
96895 xfrm_queue_purge(&policy->polq.hold_queue);
96896
96897 if (del_timer(&policy->timer))
96898 @@ -589,7 +590,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96899
96900 spin_lock_bh(&pq->hold_queue.lock);
96901 skb_queue_splice_init(&pq->hold_queue, &list);
96902 - del_timer(&pq->hold_timer);
96903 + if (del_timer(&pq->hold_timer))
96904 + xfrm_pol_put(old);
96905 spin_unlock_bh(&pq->hold_queue.lock);
96906
96907 if (skb_queue_empty(&list))
96908 @@ -600,7 +602,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96909 spin_lock_bh(&pq->hold_queue.lock);
96910 skb_queue_splice(&list, &pq->hold_queue);
96911 pq->timeout = XFRM_QUEUE_TMO_MIN;
96912 - mod_timer(&pq->hold_timer, jiffies);
96913 + if (!mod_timer(&pq->hold_timer, jiffies))
96914 + xfrm_pol_hold(new);
96915 spin_unlock_bh(&pq->hold_queue.lock);
96916 }
96917
96918 @@ -657,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
96919 hlist_add_head(&policy->bydst, chain);
96920 xfrm_pol_hold(policy);
96921 net->xfrm.policy_count[dir]++;
96922 - atomic_inc(&flow_cache_genid);
96923 + atomic_inc_unchecked(&flow_cache_genid);
96924 rt_genid_bump(net);
96925 if (delpol) {
96926 xfrm_policy_requeue(delpol, policy);
96927 @@ -1627,7 +1630,7 @@ free_dst:
96928 goto out;
96929 }
96930
96931 -static int inline
96932 +static inline int
96933 xfrm_dst_alloc_copy(void **target, const void *src, int size)
96934 {
96935 if (!*target) {
96936 @@ -1639,7 +1642,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
96937 return 0;
96938 }
96939
96940 -static int inline
96941 +static inline int
96942 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96943 {
96944 #ifdef CONFIG_XFRM_SUB_POLICY
96945 @@ -1651,7 +1654,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96946 #endif
96947 }
96948
96949 -static int inline
96950 +static inline int
96951 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
96952 {
96953 #ifdef CONFIG_XFRM_SUB_POLICY
96954 @@ -1745,7 +1748,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
96955
96956 xdst->num_pols = num_pols;
96957 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
96958 - xdst->policy_genid = atomic_read(&pols[0]->genid);
96959 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
96960
96961 return xdst;
96962 }
96963 @@ -1763,6 +1766,10 @@ static void xfrm_policy_queue_process(unsigned long arg)
96964
96965 spin_lock(&pq->hold_queue.lock);
96966 skb = skb_peek(&pq->hold_queue);
96967 + if (!skb) {
96968 + spin_unlock(&pq->hold_queue.lock);
96969 + goto out;
96970 + }
96971 dst = skb_dst(skb);
96972 sk = skb->sk;
96973 xfrm_decode_session(skb, &fl, dst->ops->family);
96974 @@ -1781,8 +1788,9 @@ static void xfrm_policy_queue_process(unsigned long arg)
96975 goto purge_queue;
96976
96977 pq->timeout = pq->timeout << 1;
96978 - mod_timer(&pq->hold_timer, jiffies + pq->timeout);
96979 - return;
96980 + if (!mod_timer(&pq->hold_timer, jiffies + pq->timeout))
96981 + xfrm_pol_hold(pol);
96982 + goto out;
96983 }
96984
96985 dst_release(dst);
96986 @@ -1813,11 +1821,14 @@ static void xfrm_policy_queue_process(unsigned long arg)
96987 err = dst_output(skb);
96988 }
96989
96990 +out:
96991 + xfrm_pol_put(pol);
96992 return;
96993
96994 purge_queue:
96995 pq->timeout = 0;
96996 xfrm_queue_purge(&pq->hold_queue);
96997 + xfrm_pol_put(pol);
96998 }
96999
97000 static int xdst_queue_output(struct sk_buff *skb)
97001 @@ -1825,7 +1836,8 @@ static int xdst_queue_output(struct sk_buff *skb)
97002 unsigned long sched_next;
97003 struct dst_entry *dst = skb_dst(skb);
97004 struct xfrm_dst *xdst = (struct xfrm_dst *) dst;
97005 - struct xfrm_policy_queue *pq = &xdst->pols[0]->polq;
97006 + struct xfrm_policy *pol = xdst->pols[0];
97007 + struct xfrm_policy_queue *pq = &pol->polq;
97008
97009 if (pq->hold_queue.qlen > XFRM_MAX_QUEUE_LEN) {
97010 kfree_skb(skb);
97011 @@ -1844,10 +1856,12 @@ static int xdst_queue_output(struct sk_buff *skb)
97012 if (del_timer(&pq->hold_timer)) {
97013 if (time_before(pq->hold_timer.expires, sched_next))
97014 sched_next = pq->hold_timer.expires;
97015 + xfrm_pol_put(pol);
97016 }
97017
97018 __skb_queue_tail(&pq->hold_queue, skb);
97019 - mod_timer(&pq->hold_timer, sched_next);
97020 + if (!mod_timer(&pq->hold_timer, sched_next))
97021 + xfrm_pol_hold(pol);
97022
97023 spin_unlock_bh(&pq->hold_queue.lock);
97024
97025 @@ -2557,11 +2571,12 @@ void xfrm_garbage_collect(struct net *net)
97026 }
97027 EXPORT_SYMBOL(xfrm_garbage_collect);
97028
97029 -static void xfrm_garbage_collect_deferred(struct net *net)
97030 +void xfrm_garbage_collect_deferred(struct net *net)
97031 {
97032 flow_cache_flush_deferred();
97033 __xfrm_garbage_collect(net);
97034 }
97035 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
97036
97037 static void xfrm_init_pmtu(struct dst_entry *dst)
97038 {
97039 @@ -2611,7 +2626,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
97040 if (xdst->xfrm_genid != dst->xfrm->genid)
97041 return 0;
97042 if (xdst->num_pols > 0 &&
97043 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
97044 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
97045 return 0;
97046
97047 mtu = dst_mtu(dst->child);
97048 @@ -2699,8 +2714,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
97049 dst_ops->link_failure = xfrm_link_failure;
97050 if (likely(dst_ops->neigh_lookup == NULL))
97051 dst_ops->neigh_lookup = xfrm_neigh_lookup;
97052 - if (likely(afinfo->garbage_collect == NULL))
97053 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
97054 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
97055 }
97056 spin_unlock(&xfrm_policy_afinfo_lock);
97057 @@ -2754,7 +2767,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
97058 dst_ops->check = NULL;
97059 dst_ops->negative_advice = NULL;
97060 dst_ops->link_failure = NULL;
97061 - afinfo->garbage_collect = NULL;
97062 }
97063 return err;
97064 }
97065 @@ -3137,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
97066 sizeof(pol->xfrm_vec[i].saddr));
97067 pol->xfrm_vec[i].encap_family = mp->new_family;
97068 /* flush bundles */
97069 - atomic_inc(&pol->genid);
97070 + atomic_inc_unchecked(&pol->genid);
97071 }
97072 }
97073
97074 diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c
97075 index 8dafe6d3..dab57da 100644
97076 --- a/net/xfrm/xfrm_replay.c
97077 +++ b/net/xfrm/xfrm_replay.c
97078 @@ -61,9 +61,9 @@ static void xfrm_replay_notify(struct xfrm_state *x, int event)
97079
97080 switch (event) {
97081 case XFRM_REPLAY_UPDATE:
97082 - if (x->replay_maxdiff &&
97083 - (x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
97084 - (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff)) {
97085 + if (!x->replay_maxdiff ||
97086 + ((x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
97087 + (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff))) {
97088 if (x->xflags & XFRM_TIME_DEFER)
97089 event = XFRM_REPLAY_TIMEOUT;
97090 else
97091 @@ -129,8 +129,7 @@ static int xfrm_replay_check(struct xfrm_state *x,
97092 return 0;
97093
97094 diff = x->replay.seq - seq;
97095 - if (diff >= min_t(unsigned int, x->props.replay_window,
97096 - sizeof(x->replay.bitmap) * 8)) {
97097 + if (diff >= x->props.replay_window) {
97098 x->stats.replay_window++;
97099 goto err;
97100 }
97101 @@ -302,9 +301,10 @@ static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event)
97102
97103 switch (event) {
97104 case XFRM_REPLAY_UPDATE:
97105 - if (x->replay_maxdiff &&
97106 - (replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
97107 - (replay_esn->oseq - preplay_esn->oseq < x->replay_maxdiff)) {
97108 + if (!x->replay_maxdiff ||
97109 + ((replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
97110 + (replay_esn->oseq - preplay_esn->oseq
97111 + < x->replay_maxdiff))) {
97112 if (x->xflags & XFRM_TIME_DEFER)
97113 event = XFRM_REPLAY_TIMEOUT;
97114 else
97115 @@ -353,28 +353,30 @@ static void xfrm_replay_notify_esn(struct xfrm_state *x, int event)
97116
97117 switch (event) {
97118 case XFRM_REPLAY_UPDATE:
97119 - if (!x->replay_maxdiff)
97120 - break;
97121 -
97122 - if (replay_esn->seq_hi == preplay_esn->seq_hi)
97123 - seq_diff = replay_esn->seq - preplay_esn->seq;
97124 - else
97125 - seq_diff = ~preplay_esn->seq + replay_esn->seq + 1;
97126 -
97127 - if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
97128 - oseq_diff = replay_esn->oseq - preplay_esn->oseq;
97129 - else
97130 - oseq_diff = ~preplay_esn->oseq + replay_esn->oseq + 1;
97131 -
97132 - if (seq_diff < x->replay_maxdiff &&
97133 - oseq_diff < x->replay_maxdiff) {
97134 + if (x->replay_maxdiff) {
97135 + if (replay_esn->seq_hi == preplay_esn->seq_hi)
97136 + seq_diff = replay_esn->seq - preplay_esn->seq;
97137 + else
97138 + seq_diff = ~preplay_esn->seq + replay_esn->seq
97139 + + 1;
97140
97141 - if (x->xflags & XFRM_TIME_DEFER)
97142 - event = XFRM_REPLAY_TIMEOUT;
97143 + if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
97144 + oseq_diff = replay_esn->oseq
97145 + - preplay_esn->oseq;
97146 else
97147 - return;
97148 + oseq_diff = ~preplay_esn->oseq
97149 + + replay_esn->oseq + 1;
97150 +
97151 + if (seq_diff >= x->replay_maxdiff ||
97152 + oseq_diff >= x->replay_maxdiff)
97153 + break;
97154 }
97155
97156 + if (x->xflags & XFRM_TIME_DEFER)
97157 + event = XFRM_REPLAY_TIMEOUT;
97158 + else
97159 + return;
97160 +
97161 break;
97162
97163 case XFRM_REPLAY_TIMEOUT:
97164 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
97165 index 54c0acd..56814bd 100644
97166 --- a/net/xfrm/xfrm_state.c
97167 +++ b/net/xfrm/xfrm_state.c
97168 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
97169
97170 if (unlikely(afinfo == NULL))
97171 return -EAFNOSUPPORT;
97172 - typemap = afinfo->type_map;
97173 + typemap = (const struct xfrm_type **)afinfo->type_map;
97174 spin_lock_bh(&xfrm_type_lock);
97175
97176 - if (likely(typemap[type->proto] == NULL))
97177 + if (likely(typemap[type->proto] == NULL)) {
97178 + pax_open_kernel();
97179 typemap[type->proto] = type;
97180 - else
97181 + pax_close_kernel();
97182 + } else
97183 err = -EEXIST;
97184 spin_unlock_bh(&xfrm_type_lock);
97185 xfrm_state_put_afinfo(afinfo);
97186 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
97187
97188 if (unlikely(afinfo == NULL))
97189 return -EAFNOSUPPORT;
97190 - typemap = afinfo->type_map;
97191 + typemap = (const struct xfrm_type **)afinfo->type_map;
97192 spin_lock_bh(&xfrm_type_lock);
97193
97194 if (unlikely(typemap[type->proto] != type))
97195 err = -ENOENT;
97196 - else
97197 + else {
97198 + pax_open_kernel();
97199 typemap[type->proto] = NULL;
97200 + pax_close_kernel();
97201 + }
97202 spin_unlock_bh(&xfrm_type_lock);
97203 xfrm_state_put_afinfo(afinfo);
97204 return err;
97205 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
97206 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
97207 {
97208 struct xfrm_state_afinfo *afinfo;
97209 - const struct xfrm_type **typemap;
97210 const struct xfrm_type *type;
97211 int modload_attempted = 0;
97212
97213 @@ -219,9 +223,8 @@ retry:
97214 afinfo = xfrm_state_get_afinfo(family);
97215 if (unlikely(afinfo == NULL))
97216 return NULL;
97217 - typemap = afinfo->type_map;
97218
97219 - type = typemap[proto];
97220 + type = afinfo->type_map[proto];
97221 if (unlikely(type && !try_module_get(type->owner)))
97222 type = NULL;
97223 if (!type && !modload_attempted) {
97224 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97225 return -EAFNOSUPPORT;
97226
97227 err = -EEXIST;
97228 - modemap = afinfo->mode_map;
97229 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97230 spin_lock_bh(&xfrm_mode_lock);
97231 if (modemap[mode->encap])
97232 goto out;
97233 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97234 if (!try_module_get(afinfo->owner))
97235 goto out;
97236
97237 - mode->afinfo = afinfo;
97238 + pax_open_kernel();
97239 + *(const void **)&mode->afinfo = afinfo;
97240 modemap[mode->encap] = mode;
97241 + pax_close_kernel();
97242 err = 0;
97243
97244 out:
97245 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
97246 return -EAFNOSUPPORT;
97247
97248 err = -ENOENT;
97249 - modemap = afinfo->mode_map;
97250 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97251 spin_lock_bh(&xfrm_mode_lock);
97252 if (likely(modemap[mode->encap] == mode)) {
97253 + pax_open_kernel();
97254 modemap[mode->encap] = NULL;
97255 + pax_close_kernel();
97256 module_put(mode->afinfo->owner);
97257 err = 0;
97258 }
97259 @@ -1483,10 +1490,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
97260 u32 xfrm_get_acqseq(void)
97261 {
97262 u32 res;
97263 - static atomic_t acqseq;
97264 + static atomic_unchecked_t acqseq;
97265
97266 do {
97267 - res = atomic_inc_return(&acqseq);
97268 + res = atomic_inc_return_unchecked(&acqseq);
97269 } while (!res);
97270
97271 return res;
97272 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
97273 index 05a6e3d..6716ec9 100644
97274 --- a/net/xfrm/xfrm_sysctl.c
97275 +++ b/net/xfrm/xfrm_sysctl.c
97276 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
97277
97278 int __net_init xfrm_sysctl_init(struct net *net)
97279 {
97280 - struct ctl_table *table;
97281 + ctl_table_no_const *table;
97282
97283 __xfrm_sysctl_init(net);
97284
97285 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
97286 index 3f565e4..f964d4c 100644
97287 --- a/net/xfrm/xfrm_user.c
97288 +++ b/net/xfrm/xfrm_user.c
97289 @@ -446,7 +446,8 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *
97290 memcpy(&x->sel, &p->sel, sizeof(x->sel));
97291 memcpy(&x->lft, &p->lft, sizeof(x->lft));
97292 x->props.mode = p->mode;
97293 - x->props.replay_window = p->replay_window;
97294 + x->props.replay_window = min_t(unsigned int, p->replay_window,
97295 + sizeof(x->replay.bitmap) * 8);
97296 x->props.reqid = p->reqid;
97297 x->props.family = p->family;
97298 memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr));
97299 @@ -1856,7 +1857,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
97300 if (x->km.state != XFRM_STATE_VALID)
97301 goto out;
97302
97303 - err = xfrm_replay_verify_len(x->replay_esn, rp);
97304 + err = xfrm_replay_verify_len(x->replay_esn, re);
97305 if (err)
97306 goto out;
97307
97308 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
97309 index d5d859c..781cbcb 100644
97310 --- a/scripts/Makefile.build
97311 +++ b/scripts/Makefile.build
97312 @@ -111,7 +111,7 @@ endif
97313 endif
97314
97315 # Do not include host rules unless needed
97316 -ifneq ($(hostprogs-y)$(hostprogs-m),)
97317 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
97318 include scripts/Makefile.host
97319 endif
97320
97321 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
97322 index 686cb0d..9d653bf 100644
97323 --- a/scripts/Makefile.clean
97324 +++ b/scripts/Makefile.clean
97325 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
97326 __clean-files := $(extra-y) $(always) \
97327 $(targets) $(clean-files) \
97328 $(host-progs) \
97329 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
97330 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
97331 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
97332
97333 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
97334
97335 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
97336 index 1ac414f..38575f7 100644
97337 --- a/scripts/Makefile.host
97338 +++ b/scripts/Makefile.host
97339 @@ -31,6 +31,8 @@
97340 # Note: Shared libraries consisting of C++ files are not supported
97341
97342 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
97343 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
97344 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
97345
97346 # C code
97347 # Executables compiled from a single .c file
97348 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
97349 # Shared libaries (only .c supported)
97350 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
97351 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
97352 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
97353 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
97354 # Remove .so files from "xxx-objs"
97355 host-cobjs := $(filter-out %.so,$(host-cobjs))
97356 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
97357
97358 -#Object (.o) files used by the shared libaries
97359 +# Object (.o) files used by the shared libaries
97360 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
97361 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
97362
97363 # output directory for programs/.o files
97364 # hostprogs-y := tools/build may have been specified. Retrieve directory
97365 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
97366 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
97367 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
97368 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
97369 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
97370 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
97371 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
97372 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
97373
97374 obj-dirs += $(host-objdirs)
97375 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
97376 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
97377 $(call if_changed_dep,host-cshobjs)
97378
97379 +# Compile .c file, create position independent .o file
97380 +# host-cxxshobjs -> .o
97381 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
97382 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
97383 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
97384 + $(call if_changed_dep,host-cxxshobjs)
97385 +
97386 # Link a shared library, based on position independent .o files
97387 # *.o -> .so shared library (host-cshlib)
97388 quiet_cmd_host-cshlib = HOSTLLD -shared $@
97389 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
97390 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
97391 $(call if_changed,host-cshlib)
97392
97393 +# Link a shared library, based on position independent .o files
97394 +# *.o -> .so shared library (host-cxxshlib)
97395 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
97396 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
97397 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
97398 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
97399 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
97400 + $(call if_changed,host-cxxshlib)
97401 +
97402 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
97403 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
97404 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
97405
97406 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
97407 index 078fe1d..fbdb363 100644
97408 --- a/scripts/basic/fixdep.c
97409 +++ b/scripts/basic/fixdep.c
97410 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
97411 /*
97412 * Lookup a value in the configuration string.
97413 */
97414 -static int is_defined_config(const char *name, int len, unsigned int hash)
97415 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
97416 {
97417 struct item *aux;
97418
97419 @@ -211,10 +211,10 @@ static void clear_config(void)
97420 /*
97421 * Record the use of a CONFIG_* word.
97422 */
97423 -static void use_config(const char *m, int slen)
97424 +static void use_config(const char *m, unsigned int slen)
97425 {
97426 unsigned int hash = strhash(m, slen);
97427 - int c, i;
97428 + unsigned int c, i;
97429
97430 if (is_defined_config(m, slen, hash))
97431 return;
97432 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
97433
97434 static void parse_config_file(const char *map, size_t len)
97435 {
97436 - const int *end = (const int *) (map + len);
97437 + const unsigned int *end = (const unsigned int *) (map + len);
97438 /* start at +1, so that p can never be < map */
97439 - const int *m = (const int *) map + 1;
97440 + const unsigned int *m = (const unsigned int *) map + 1;
97441 const char *p, *q;
97442
97443 for (; m < end; m++) {
97444 @@ -435,7 +435,7 @@ static void print_deps(void)
97445 static void traps(void)
97446 {
97447 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
97448 - int *p = (int *)test;
97449 + unsigned int *p = (unsigned int *)test;
97450
97451 if (*p != INT_CONF) {
97452 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
97453 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
97454 new file mode 100644
97455 index 0000000..5e0222d
97456 --- /dev/null
97457 +++ b/scripts/gcc-plugin.sh
97458 @@ -0,0 +1,17 @@
97459 +#!/bin/bash
97460 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
97461 +#include "gcc-plugin.h"
97462 +#include "tree.h"
97463 +#include "tm.h"
97464 +#include "rtl.h"
97465 +#ifdef ENABLE_BUILD_WITH_CXX
97466 +#warning $2
97467 +#else
97468 +#warning $1
97469 +#endif
97470 +EOF`
97471 +if [ $? -eq 0 ]
97472 +then
97473 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
97474 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
97475 +fi
97476 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
97477 index 5de5660..d3deb89 100644
97478 --- a/scripts/headers_install.sh
97479 +++ b/scripts/headers_install.sh
97480 @@ -32,6 +32,7 @@ do
97481 FILE="$(basename "$i")"
97482 sed -r \
97483 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
97484 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
97485 -e 's/__attribute_const__([ \t]|$)/\1/g' \
97486 -e 's@^#include <linux/compiler.h>@@' \
97487 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
97488 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
97489 index 32b10f5..0d8d2ee 100644
97490 --- a/scripts/link-vmlinux.sh
97491 +++ b/scripts/link-vmlinux.sh
97492 @@ -160,7 +160,7 @@ else
97493 fi;
97494
97495 # final build of init/
97496 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
97497 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
97498
97499 kallsymso=""
97500 kallsyms_vmlinux=""
97501 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
97502 index 2370863..212fbca 100644
97503 --- a/scripts/mod/file2alias.c
97504 +++ b/scripts/mod/file2alias.c
97505 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
97506 unsigned long size, unsigned long id_size,
97507 void *symval)
97508 {
97509 - int i;
97510 + unsigned int i;
97511
97512 if (size % id_size || size < id_size) {
97513 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
97514 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
97515 /* USB is special because the bcdDevice can be matched against a numeric range */
97516 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
97517 static void do_usb_entry(void *symval,
97518 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
97519 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
97520 unsigned char range_lo, unsigned char range_hi,
97521 unsigned char max, struct module *mod)
97522 {
97523 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
97524 {
97525 unsigned int devlo, devhi;
97526 unsigned char chi, clo, max;
97527 - int ndigits;
97528 + unsigned int ndigits;
97529
97530 DEF_FIELD(symval, usb_device_id, match_flags);
97531 DEF_FIELD(symval, usb_device_id, idVendor);
97532 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
97533 for (i = 0; i < count; i++) {
97534 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
97535 char acpi_id[sizeof(*id)];
97536 - int j;
97537 + unsigned int j;
97538
97539 buf_printf(&mod->dev_table_buf,
97540 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
97541 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97542
97543 for (j = 0; j < PNP_MAX_DEVICES; j++) {
97544 const char *id = (char *)(*devs)[j].id;
97545 - int i2, j2;
97546 + unsigned int i2, j2;
97547 int dup = 0;
97548
97549 if (!id[0])
97550 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97551 /* add an individual alias for every device entry */
97552 if (!dup) {
97553 char acpi_id[PNP_ID_LEN];
97554 - int k;
97555 + unsigned int k;
97556
97557 buf_printf(&mod->dev_table_buf,
97558 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
97559 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
97560 static int do_dmi_entry(const char *filename, void *symval,
97561 char *alias)
97562 {
97563 - int i, j;
97564 + unsigned int i, j;
97565 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
97566 sprintf(alias, "dmi*");
97567
97568 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
97569 index 6216434..050cf89 100644
97570 --- a/scripts/mod/modpost.c
97571 +++ b/scripts/mod/modpost.c
97572 @@ -930,6 +930,7 @@ enum mismatch {
97573 ANY_INIT_TO_ANY_EXIT,
97574 ANY_EXIT_TO_ANY_INIT,
97575 EXPORT_TO_INIT_EXIT,
97576 + DATA_TO_TEXT
97577 };
97578
97579 struct sectioncheck {
97580 @@ -1016,6 +1017,12 @@ const struct sectioncheck sectioncheck[] = {
97581 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
97582 .mismatch = EXPORT_TO_INIT_EXIT,
97583 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
97584 +},
97585 +/* Do not reference code from writable data */
97586 +{
97587 + .fromsec = { DATA_SECTIONS, NULL },
97588 + .tosec = { TEXT_SECTIONS, NULL },
97589 + .mismatch = DATA_TO_TEXT
97590 }
97591 };
97592
97593 @@ -1136,10 +1143,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
97594 continue;
97595 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
97596 continue;
97597 - if (sym->st_value == addr)
97598 - return sym;
97599 /* Find a symbol nearby - addr are maybe negative */
97600 d = sym->st_value - addr;
97601 + if (d == 0)
97602 + return sym;
97603 if (d < 0)
97604 d = addr - sym->st_value;
97605 if (d < distance) {
97606 @@ -1417,6 +1424,14 @@ static void report_sec_mismatch(const char *modname,
97607 tosym, prl_to, prl_to, tosym);
97608 free(prl_to);
97609 break;
97610 + case DATA_TO_TEXT:
97611 +#if 0
97612 + fprintf(stderr,
97613 + "The %s %s:%s references\n"
97614 + "the %s %s:%s%s\n",
97615 + from, fromsec, fromsym, to, tosec, tosym, to_p);
97616 +#endif
97617 + break;
97618 }
97619 fprintf(stderr, "\n");
97620 }
97621 @@ -1651,7 +1666,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
97622 static void check_sec_ref(struct module *mod, const char *modname,
97623 struct elf_info *elf)
97624 {
97625 - int i;
97626 + unsigned int i;
97627 Elf_Shdr *sechdrs = elf->sechdrs;
97628
97629 /* Walk through all sections */
97630 @@ -1770,7 +1785,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
97631 va_end(ap);
97632 }
97633
97634 -void buf_write(struct buffer *buf, const char *s, int len)
97635 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
97636 {
97637 if (buf->size - buf->pos < len) {
97638 buf->size += len + SZ;
97639 @@ -1989,7 +2004,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
97640 if (fstat(fileno(file), &st) < 0)
97641 goto close_write;
97642
97643 - if (st.st_size != b->pos)
97644 + if (st.st_size != (off_t)b->pos)
97645 goto close_write;
97646
97647 tmp = NOFAIL(malloc(b->pos));
97648 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
97649 index 51207e4..f7d603d 100644
97650 --- a/scripts/mod/modpost.h
97651 +++ b/scripts/mod/modpost.h
97652 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
97653
97654 struct buffer {
97655 char *p;
97656 - int pos;
97657 - int size;
97658 + unsigned int pos;
97659 + unsigned int size;
97660 };
97661
97662 void __attribute__((format(printf, 2, 3)))
97663 buf_printf(struct buffer *buf, const char *fmt, ...);
97664
97665 void
97666 -buf_write(struct buffer *buf, const char *s, int len);
97667 +buf_write(struct buffer *buf, const char *s, unsigned int len);
97668
97669 struct module {
97670 struct module *next;
97671 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
97672 index 9dfcd6d..099068e 100644
97673 --- a/scripts/mod/sumversion.c
97674 +++ b/scripts/mod/sumversion.c
97675 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
97676 goto out;
97677 }
97678
97679 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
97680 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
97681 warn("writing sum in %s failed: %s\n",
97682 filename, strerror(errno));
97683 goto out;
97684 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
97685 index 0865b3e..7235dd4 100644
97686 --- a/scripts/module-common.lds
97687 +++ b/scripts/module-common.lds
97688 @@ -6,6 +6,10 @@
97689 SECTIONS {
97690 /DISCARD/ : { *(.discard) }
97691
97692 + .rodata : {
97693 + *(.rodata) *(.rodata.*)
97694 + *(.data..read_only)
97695 + }
97696 __ksymtab : { *(SORT(___ksymtab+*)) }
97697 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
97698 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
97699 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
97700 index acb8650..b8c5f02 100644
97701 --- a/scripts/package/builddeb
97702 +++ b/scripts/package/builddeb
97703 @@ -246,6 +246,7 @@ fi
97704 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
97705 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
97706 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
97707 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
97708 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
97709 mkdir -p "$destdir"
97710 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
97711 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
97712 index 68bb4ef..2f419e1 100644
97713 --- a/scripts/pnmtologo.c
97714 +++ b/scripts/pnmtologo.c
97715 @@ -244,14 +244,14 @@ static void write_header(void)
97716 fprintf(out, " * Linux logo %s\n", logoname);
97717 fputs(" */\n\n", out);
97718 fputs("#include <linux/linux_logo.h>\n\n", out);
97719 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
97720 + fprintf(out, "static unsigned char %s_data[] = {\n",
97721 logoname);
97722 }
97723
97724 static void write_footer(void)
97725 {
97726 fputs("\n};\n\n", out);
97727 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
97728 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
97729 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
97730 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
97731 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
97732 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
97733 fputs("\n};\n\n", out);
97734
97735 /* write logo clut */
97736 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
97737 + fprintf(out, "static unsigned char %s_clut[] = {\n",
97738 logoname);
97739 write_hex_cnt = 0;
97740 for (i = 0; i < logo_clutsize; i++) {
97741 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
97742 index f5eb43d..1814de8 100644
97743 --- a/scripts/sortextable.h
97744 +++ b/scripts/sortextable.h
97745 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
97746 const char *secstrtab;
97747 const char *strtab;
97748 char *extab_image;
97749 - int extab_index = 0;
97750 - int i;
97751 - int idx;
97752 + unsigned int extab_index = 0;
97753 + unsigned int i;
97754 + unsigned int idx;
97755
97756 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
97757 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
97758 diff --git a/security/Kconfig b/security/Kconfig
97759 index e9c6ac7..031a726 100644
97760 --- a/security/Kconfig
97761 +++ b/security/Kconfig
97762 @@ -4,6 +4,960 @@
97763
97764 menu "Security options"
97765
97766 +menu "Grsecurity"
97767 +
97768 + config ARCH_TRACK_EXEC_LIMIT
97769 + bool
97770 +
97771 + config PAX_KERNEXEC_PLUGIN
97772 + bool
97773 +
97774 + config PAX_PER_CPU_PGD
97775 + bool
97776 +
97777 + config TASK_SIZE_MAX_SHIFT
97778 + int
97779 + depends on X86_64
97780 + default 47 if !PAX_PER_CPU_PGD
97781 + default 42 if PAX_PER_CPU_PGD
97782 +
97783 + config PAX_ENABLE_PAE
97784 + bool
97785 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
97786 +
97787 + config PAX_USERCOPY_SLABS
97788 + bool
97789 +
97790 +config GRKERNSEC
97791 + bool "Grsecurity"
97792 + select CRYPTO
97793 + select CRYPTO_SHA256
97794 + select PROC_FS
97795 + select STOP_MACHINE
97796 + select TTY
97797 + select DEBUG_LIST
97798 + help
97799 + If you say Y here, you will be able to configure many features
97800 + that will enhance the security of your system. It is highly
97801 + recommended that you say Y here and read through the help
97802 + for each option so that you fully understand the features and
97803 + can evaluate their usefulness for your machine.
97804 +
97805 +choice
97806 + prompt "Configuration Method"
97807 + depends on GRKERNSEC
97808 + default GRKERNSEC_CONFIG_CUSTOM
97809 + help
97810 +
97811 +config GRKERNSEC_CONFIG_AUTO
97812 + bool "Automatic"
97813 + help
97814 + If you choose this configuration method, you'll be able to answer a small
97815 + number of simple questions about how you plan to use this kernel.
97816 + The settings of grsecurity and PaX will be automatically configured for
97817 + the highest commonly-used settings within the provided constraints.
97818 +
97819 + If you require additional configuration, custom changes can still be made
97820 + from the "custom configuration" menu.
97821 +
97822 +config GRKERNSEC_CONFIG_CUSTOM
97823 + bool "Custom"
97824 + help
97825 + If you choose this configuration method, you'll be able to configure all
97826 + grsecurity and PaX settings manually. Via this method, no options are
97827 + automatically enabled.
97828 +
97829 +endchoice
97830 +
97831 +choice
97832 + prompt "Usage Type"
97833 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97834 + default GRKERNSEC_CONFIG_SERVER
97835 + help
97836 +
97837 +config GRKERNSEC_CONFIG_SERVER
97838 + bool "Server"
97839 + help
97840 + Choose this option if you plan to use this kernel on a server.
97841 +
97842 +config GRKERNSEC_CONFIG_DESKTOP
97843 + bool "Desktop"
97844 + help
97845 + Choose this option if you plan to use this kernel on a desktop.
97846 +
97847 +endchoice
97848 +
97849 +choice
97850 + prompt "Virtualization Type"
97851 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
97852 + default GRKERNSEC_CONFIG_VIRT_NONE
97853 + help
97854 +
97855 +config GRKERNSEC_CONFIG_VIRT_NONE
97856 + bool "None"
97857 + help
97858 + Choose this option if this kernel will be run on bare metal.
97859 +
97860 +config GRKERNSEC_CONFIG_VIRT_GUEST
97861 + bool "Guest"
97862 + help
97863 + Choose this option if this kernel will be run as a VM guest.
97864 +
97865 +config GRKERNSEC_CONFIG_VIRT_HOST
97866 + bool "Host"
97867 + help
97868 + Choose this option if this kernel will be run as a VM host.
97869 +
97870 +endchoice
97871 +
97872 +choice
97873 + prompt "Virtualization Hardware"
97874 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97875 + help
97876 +
97877 +config GRKERNSEC_CONFIG_VIRT_EPT
97878 + bool "EPT/RVI Processor Support"
97879 + depends on X86
97880 + help
97881 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
97882 + hardware virtualization. This allows for additional kernel hardening protections
97883 + to operate without additional performance impact.
97884 +
97885 + To see if your Intel processor supports EPT, see:
97886 + http://ark.intel.com/Products/VirtualizationTechnology
97887 + (Most Core i3/5/7 support EPT)
97888 +
97889 + To see if your AMD processor supports RVI, see:
97890 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
97891 +
97892 +config GRKERNSEC_CONFIG_VIRT_SOFT
97893 + bool "First-gen/No Hardware Virtualization"
97894 + help
97895 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
97896 + support hardware virtualization or doesn't support the EPT/RVI extensions.
97897 +
97898 +endchoice
97899 +
97900 +choice
97901 + prompt "Virtualization Software"
97902 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97903 + help
97904 +
97905 +config GRKERNSEC_CONFIG_VIRT_XEN
97906 + bool "Xen"
97907 + help
97908 + Choose this option if this kernel is running as a Xen guest or host.
97909 +
97910 +config GRKERNSEC_CONFIG_VIRT_VMWARE
97911 + bool "VMWare"
97912 + help
97913 + Choose this option if this kernel is running as a VMWare guest or host.
97914 +
97915 +config GRKERNSEC_CONFIG_VIRT_KVM
97916 + bool "KVM"
97917 + help
97918 + Choose this option if this kernel is running as a KVM guest or host.
97919 +
97920 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
97921 + bool "VirtualBox"
97922 + help
97923 + Choose this option if this kernel is running as a VirtualBox guest or host.
97924 +
97925 +endchoice
97926 +
97927 +choice
97928 + prompt "Required Priorities"
97929 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97930 + default GRKERNSEC_CONFIG_PRIORITY_PERF
97931 + help
97932 +
97933 +config GRKERNSEC_CONFIG_PRIORITY_PERF
97934 + bool "Performance"
97935 + help
97936 + Choose this option if performance is of highest priority for this deployment
97937 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
97938 + clearing of structures intended for userland, and freed memory sanitizing will
97939 + be disabled.
97940 +
97941 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
97942 + bool "Security"
97943 + help
97944 + Choose this option if security is of highest priority for this deployment of
97945 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
97946 + for userland, and freed memory sanitizing will be enabled for this kernel.
97947 + In a worst-case scenario, these features can introduce a 20% performance hit
97948 + (UDEREF on x64 contributing half of this hit).
97949 +
97950 +endchoice
97951 +
97952 +menu "Default Special Groups"
97953 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97954 +
97955 +config GRKERNSEC_PROC_GID
97956 + int "GID exempted from /proc restrictions"
97957 + default 1001
97958 + help
97959 + Setting this GID determines which group will be exempted from
97960 + grsecurity's /proc restrictions, allowing users of the specified
97961 + group to view network statistics and the existence of other users'
97962 + processes on the system. This GID may also be chosen at boot time
97963 + via "grsec_proc_gid=" on the kernel commandline.
97964 +
97965 +config GRKERNSEC_TPE_UNTRUSTED_GID
97966 + int "GID for TPE-untrusted users"
97967 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
97968 + default 1005
97969 + help
97970 + Setting this GID determines which group untrusted users should
97971 + be added to. These users will be placed under grsecurity's Trusted Path
97972 + Execution mechanism, preventing them from executing their own binaries.
97973 + The users will only be able to execute binaries in directories owned and
97974 + writable only by the root user. If the sysctl option is enabled, a sysctl
97975 + option with name "tpe_gid" is created.
97976 +
97977 +config GRKERNSEC_TPE_TRUSTED_GID
97978 + int "GID for TPE-trusted users"
97979 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
97980 + default 1005
97981 + help
97982 + Setting this GID determines what group TPE restrictions will be
97983 + *disabled* for. If the sysctl option is enabled, a sysctl option
97984 + with name "tpe_gid" is created.
97985 +
97986 +config GRKERNSEC_SYMLINKOWN_GID
97987 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
97988 + depends on GRKERNSEC_CONFIG_SERVER
97989 + default 1006
97990 + help
97991 + Setting this GID determines what group kernel-enforced
97992 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
97993 + is enabled, a sysctl option with name "symlinkown_gid" is created.
97994 +
97995 +
97996 +endmenu
97997 +
97998 +menu "Customize Configuration"
97999 +depends on GRKERNSEC
98000 +
98001 +menu "PaX"
98002 +
98003 +config PAX
98004 + bool "Enable various PaX features"
98005 + default y if GRKERNSEC_CONFIG_AUTO
98006 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
98007 + help
98008 + This allows you to enable various PaX features. PaX adds
98009 + intrusion prevention mechanisms to the kernel that reduce
98010 + the risks posed by exploitable memory corruption bugs.
98011 +
98012 +menu "PaX Control"
98013 + depends on PAX
98014 +
98015 +config PAX_SOFTMODE
98016 + bool 'Support soft mode'
98017 + help
98018 + Enabling this option will allow you to run PaX in soft mode, that
98019 + is, PaX features will not be enforced by default, only on executables
98020 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
98021 + support as they are the only way to mark executables for soft mode use.
98022 +
98023 + Soft mode can be activated by using the "pax_softmode=1" kernel command
98024 + line option on boot. Furthermore you can control various PaX features
98025 + at runtime via the entries in /proc/sys/kernel/pax.
98026 +
98027 +config PAX_EI_PAX
98028 + bool 'Use legacy ELF header marking'
98029 + default y if GRKERNSEC_CONFIG_AUTO
98030 + help
98031 + Enabling this option will allow you to control PaX features on
98032 + a per executable basis via the 'chpax' utility available at
98033 + http://pax.grsecurity.net/. The control flags will be read from
98034 + an otherwise reserved part of the ELF header. This marking has
98035 + numerous drawbacks (no support for soft-mode, toolchain does not
98036 + know about the non-standard use of the ELF header) therefore it
98037 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
98038 + support.
98039 +
98040 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
98041 + support as well, they will override the legacy EI_PAX marks.
98042 +
98043 + If you enable none of the marking options then all applications
98044 + will run with PaX enabled on them by default.
98045 +
98046 +config PAX_PT_PAX_FLAGS
98047 + bool 'Use ELF program header marking'
98048 + default y if GRKERNSEC_CONFIG_AUTO
98049 + help
98050 + Enabling this option will allow you to control PaX features on
98051 + a per executable basis via the 'paxctl' utility available at
98052 + http://pax.grsecurity.net/. The control flags will be read from
98053 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
98054 + has the benefits of supporting both soft mode and being fully
98055 + integrated into the toolchain (the binutils patch is available
98056 + from http://pax.grsecurity.net).
98057 +
98058 + Note that if you enable the legacy EI_PAX marking support as well,
98059 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
98060 +
98061 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98062 + must make sure that the marks are the same if a binary has both marks.
98063 +
98064 + If you enable none of the marking options then all applications
98065 + will run with PaX enabled on them by default.
98066 +
98067 +config PAX_XATTR_PAX_FLAGS
98068 + bool 'Use filesystem extended attributes marking'
98069 + default y if GRKERNSEC_CONFIG_AUTO
98070 + select CIFS_XATTR if CIFS
98071 + select EXT2_FS_XATTR if EXT2_FS
98072 + select EXT3_FS_XATTR if EXT3_FS
98073 + select EXT4_FS_XATTR if EXT4_FS
98074 + select JFFS2_FS_XATTR if JFFS2_FS
98075 + select REISERFS_FS_XATTR if REISERFS_FS
98076 + select SQUASHFS_XATTR if SQUASHFS
98077 + select TMPFS_XATTR if TMPFS
98078 + select UBIFS_FS_XATTR if UBIFS_FS
98079 + help
98080 + Enabling this option will allow you to control PaX features on
98081 + a per executable basis via the 'setfattr' utility. The control
98082 + flags will be read from the user.pax.flags extended attribute of
98083 + the file. This marking has the benefit of supporting binary-only
98084 + applications that self-check themselves (e.g., skype) and would
98085 + not tolerate chpax/paxctl changes. The main drawback is that
98086 + extended attributes are not supported by some filesystems (e.g.,
98087 + isofs, udf, vfat) so copying files through such filesystems will
98088 + lose the extended attributes and these PaX markings.
98089 +
98090 + Note that if you enable the legacy EI_PAX marking support as well,
98091 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
98092 +
98093 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98094 + must make sure that the marks are the same if a binary has both marks.
98095 +
98096 + If you enable none of the marking options then all applications
98097 + will run with PaX enabled on them by default.
98098 +
98099 +choice
98100 + prompt 'MAC system integration'
98101 + default PAX_HAVE_ACL_FLAGS
98102 + help
98103 + Mandatory Access Control systems have the option of controlling
98104 + PaX flags on a per executable basis, choose the method supported
98105 + by your particular system.
98106 +
98107 + - "none": if your MAC system does not interact with PaX,
98108 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
98109 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
98110 +
98111 + NOTE: this option is for developers/integrators only.
98112 +
98113 + config PAX_NO_ACL_FLAGS
98114 + bool 'none'
98115 +
98116 + config PAX_HAVE_ACL_FLAGS
98117 + bool 'direct'
98118 +
98119 + config PAX_HOOK_ACL_FLAGS
98120 + bool 'hook'
98121 +endchoice
98122 +
98123 +endmenu
98124 +
98125 +menu "Non-executable pages"
98126 + depends on PAX
98127 +
98128 +config PAX_NOEXEC
98129 + bool "Enforce non-executable pages"
98130 + default y if GRKERNSEC_CONFIG_AUTO
98131 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
98132 + help
98133 + By design some architectures do not allow for protecting memory
98134 + pages against execution or even if they do, Linux does not make
98135 + use of this feature. In practice this means that if a page is
98136 + readable (such as the stack or heap) it is also executable.
98137 +
98138 + There is a well known exploit technique that makes use of this
98139 + fact and a common programming mistake where an attacker can
98140 + introduce code of his choice somewhere in the attacked program's
98141 + memory (typically the stack or the heap) and then execute it.
98142 +
98143 + If the attacked program was running with different (typically
98144 + higher) privileges than that of the attacker, then he can elevate
98145 + his own privilege level (e.g. get a root shell, write to files for
98146 + which he does not have write access to, etc).
98147 +
98148 + Enabling this option will let you choose from various features
98149 + that prevent the injection and execution of 'foreign' code in
98150 + a program.
98151 +
98152 + This will also break programs that rely on the old behaviour and
98153 + expect that dynamically allocated memory via the malloc() family
98154 + of functions is executable (which it is not). Notable examples
98155 + are the XFree86 4.x server, the java runtime and wine.
98156 +
98157 +config PAX_PAGEEXEC
98158 + bool "Paging based non-executable pages"
98159 + default y if GRKERNSEC_CONFIG_AUTO
98160 + 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)
98161 + select ARCH_TRACK_EXEC_LIMIT if X86_32
98162 + help
98163 + This implementation is based on the paging feature of the CPU.
98164 + On i386 without hardware non-executable bit support there is a
98165 + variable but usually low performance impact, however on Intel's
98166 + P4 core based CPUs it is very high so you should not enable this
98167 + for kernels meant to be used on such CPUs.
98168 +
98169 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
98170 + with hardware non-executable bit support there is no performance
98171 + impact, on ppc the impact is negligible.
98172 +
98173 + Note that several architectures require various emulations due to
98174 + badly designed userland ABIs, this will cause a performance impact
98175 + but will disappear as soon as userland is fixed. For example, ppc
98176 + userland MUST have been built with secure-plt by a recent toolchain.
98177 +
98178 +config PAX_SEGMEXEC
98179 + bool "Segmentation based non-executable pages"
98180 + default y if GRKERNSEC_CONFIG_AUTO
98181 + depends on PAX_NOEXEC && X86_32
98182 + help
98183 + This implementation is based on the segmentation feature of the
98184 + CPU and has a very small performance impact, however applications
98185 + will be limited to a 1.5 GB address space instead of the normal
98186 + 3 GB.
98187 +
98188 +config PAX_EMUTRAMP
98189 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
98190 + default y if PARISC
98191 + help
98192 + There are some programs and libraries that for one reason or
98193 + another attempt to execute special small code snippets from
98194 + non-executable memory pages. Most notable examples are the
98195 + signal handler return code generated by the kernel itself and
98196 + the GCC trampolines.
98197 +
98198 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
98199 + such programs will no longer work under your kernel.
98200 +
98201 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
98202 + utilities to enable trampoline emulation for the affected programs
98203 + yet still have the protection provided by the non-executable pages.
98204 +
98205 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
98206 + your system will not even boot.
98207 +
98208 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
98209 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
98210 + for the affected files.
98211 +
98212 + NOTE: enabling this feature *may* open up a loophole in the
98213 + protection provided by non-executable pages that an attacker
98214 + could abuse. Therefore the best solution is to not have any
98215 + files on your system that would require this option. This can
98216 + be achieved by not using libc5 (which relies on the kernel
98217 + signal handler return code) and not using or rewriting programs
98218 + that make use of the nested function implementation of GCC.
98219 + Skilled users can just fix GCC itself so that it implements
98220 + nested function calls in a way that does not interfere with PaX.
98221 +
98222 +config PAX_EMUSIGRT
98223 + bool "Automatically emulate sigreturn trampolines"
98224 + depends on PAX_EMUTRAMP && PARISC
98225 + default y
98226 + help
98227 + Enabling this option will have the kernel automatically detect
98228 + and emulate signal return trampolines executing on the stack
98229 + that would otherwise lead to task termination.
98230 +
98231 + This solution is intended as a temporary one for users with
98232 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
98233 + Modula-3 runtime, etc) or executables linked to such, basically
98234 + everything that does not specify its own SA_RESTORER function in
98235 + normal executable memory like glibc 2.1+ does.
98236 +
98237 + On parisc you MUST enable this option, otherwise your system will
98238 + not even boot.
98239 +
98240 + NOTE: this feature cannot be disabled on a per executable basis
98241 + and since it *does* open up a loophole in the protection provided
98242 + by non-executable pages, the best solution is to not have any
98243 + files on your system that would require this option.
98244 +
98245 +config PAX_MPROTECT
98246 + bool "Restrict mprotect()"
98247 + default y if GRKERNSEC_CONFIG_AUTO
98248 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
98249 + help
98250 + Enabling this option will prevent programs from
98251 + - changing the executable status of memory pages that were
98252 + not originally created as executable,
98253 + - making read-only executable pages writable again,
98254 + - creating executable pages from anonymous memory,
98255 + - making read-only-after-relocations (RELRO) data pages writable again.
98256 +
98257 + You should say Y here to complete the protection provided by
98258 + the enforcement of non-executable pages.
98259 +
98260 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98261 + this feature on a per file basis.
98262 +
98263 +config PAX_MPROTECT_COMPAT
98264 + bool "Use legacy/compat protection demoting (read help)"
98265 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98266 + depends on PAX_MPROTECT
98267 + help
98268 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
98269 + by sending the proper error code to the application. For some broken
98270 + userland, this can cause problems with Python or other applications. The
98271 + current implementation however allows for applications like clamav to
98272 + detect if JIT compilation/execution is allowed and to fall back gracefully
98273 + to an interpreter-based mode if it does not. While we encourage everyone
98274 + to use the current implementation as-is and push upstream to fix broken
98275 + userland (note that the RWX logging option can assist with this), in some
98276 + environments this may not be possible. Having to disable MPROTECT
98277 + completely on certain binaries reduces the security benefit of PaX,
98278 + so this option is provided for those environments to revert to the old
98279 + behavior.
98280 +
98281 +config PAX_ELFRELOCS
98282 + bool "Allow ELF text relocations (read help)"
98283 + depends on PAX_MPROTECT
98284 + default n
98285 + help
98286 + Non-executable pages and mprotect() restrictions are effective
98287 + in preventing the introduction of new executable code into an
98288 + attacked task's address space. There remain only two venues
98289 + for this kind of attack: if the attacker can execute already
98290 + existing code in the attacked task then he can either have it
98291 + create and mmap() a file containing his code or have it mmap()
98292 + an already existing ELF library that does not have position
98293 + independent code in it and use mprotect() on it to make it
98294 + writable and copy his code there. While protecting against
98295 + the former approach is beyond PaX, the latter can be prevented
98296 + by having only PIC ELF libraries on one's system (which do not
98297 + need to relocate their code). If you are sure this is your case,
98298 + as is the case with all modern Linux distributions, then leave
98299 + this option disabled. You should say 'n' here.
98300 +
98301 +config PAX_ETEXECRELOCS
98302 + bool "Allow ELF ET_EXEC text relocations"
98303 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
98304 + select PAX_ELFRELOCS
98305 + default y
98306 + help
98307 + On some architectures there are incorrectly created applications
98308 + that require text relocations and would not work without enabling
98309 + this option. If you are an alpha, ia64 or parisc user, you should
98310 + enable this option and disable it once you have made sure that
98311 + none of your applications need it.
98312 +
98313 +config PAX_EMUPLT
98314 + bool "Automatically emulate ELF PLT"
98315 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
98316 + default y
98317 + help
98318 + Enabling this option will have the kernel automatically detect
98319 + and emulate the Procedure Linkage Table entries in ELF files.
98320 + On some architectures such entries are in writable memory, and
98321 + become non-executable leading to task termination. Therefore
98322 + it is mandatory that you enable this option on alpha, parisc,
98323 + sparc and sparc64, otherwise your system would not even boot.
98324 +
98325 + NOTE: this feature *does* open up a loophole in the protection
98326 + provided by the non-executable pages, therefore the proper
98327 + solution is to modify the toolchain to produce a PLT that does
98328 + not need to be writable.
98329 +
98330 +config PAX_DLRESOLVE
98331 + bool 'Emulate old glibc resolver stub'
98332 + depends on PAX_EMUPLT && SPARC
98333 + default n
98334 + help
98335 + This option is needed if userland has an old glibc (before 2.4)
98336 + that puts a 'save' instruction into the runtime generated resolver
98337 + stub that needs special emulation.
98338 +
98339 +config PAX_KERNEXEC
98340 + bool "Enforce non-executable kernel pages"
98341 + 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))
98342 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
98343 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
98344 + select PAX_KERNEXEC_PLUGIN if X86_64
98345 + help
98346 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
98347 + that is, enabling this option will make it harder to inject
98348 + and execute 'foreign' code in kernel memory itself.
98349 +
98350 +choice
98351 + prompt "Return Address Instrumentation Method"
98352 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
98353 + depends on PAX_KERNEXEC_PLUGIN
98354 + help
98355 + Select the method used to instrument function pointer dereferences.
98356 + Note that binary modules cannot be instrumented by this approach.
98357 +
98358 + Note that the implementation 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.
98361 +
98362 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
98363 + bool "bts"
98364 + help
98365 + This method is compatible with binary only modules but has
98366 + a higher runtime overhead.
98367 +
98368 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
98369 + bool "or"
98370 + depends on !PARAVIRT
98371 + help
98372 + This method is incompatible with binary only modules but has
98373 + a lower runtime overhead.
98374 +endchoice
98375 +
98376 +config PAX_KERNEXEC_PLUGIN_METHOD
98377 + string
98378 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
98379 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
98380 + default ""
98381 +
98382 +config PAX_KERNEXEC_MODULE_TEXT
98383 + int "Minimum amount of memory reserved for module code"
98384 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
98385 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98386 + depends on PAX_KERNEXEC && X86_32
98387 + help
98388 + Due to implementation details the kernel must reserve a fixed
98389 + amount of memory for runtime allocated code (such as modules)
98390 + at compile time that cannot be changed at runtime. Here you
98391 + can specify the minimum amount in MB that will be reserved.
98392 + Due to the same implementation details this size will always
98393 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
98394 + the actually available memory for runtime allocated code will
98395 + usually be more than this minimum.
98396 +
98397 + The default 4 MB should be enough for most users but if you have
98398 + an excessive number of modules (e.g., most distribution configs
98399 + compile many drivers as modules) or use huge modules such as
98400 + nvidia's kernel driver, you will need to adjust this amount.
98401 + A good rule of thumb is to look at your currently loaded kernel
98402 + modules and add up their sizes.
98403 +
98404 +endmenu
98405 +
98406 +menu "Address Space Layout Randomization"
98407 + depends on PAX
98408 +
98409 +config PAX_ASLR
98410 + bool "Address Space Layout Randomization"
98411 + default y if GRKERNSEC_CONFIG_AUTO
98412 + help
98413 + Many if not most exploit techniques rely on the knowledge of
98414 + certain addresses in the attacked program. The following options
98415 + will allow the kernel to apply a certain amount of randomization
98416 + to specific parts of the program thereby forcing an attacker to
98417 + guess them in most cases. Any failed guess will most likely crash
98418 + the attacked program which allows the kernel to detect such attempts
98419 + and react on them. PaX itself provides no reaction mechanisms,
98420 + instead it is strongly encouraged that you make use of Nergal's
98421 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
98422 + (http://www.grsecurity.net/) built-in crash detection features or
98423 + develop one yourself.
98424 +
98425 + By saying Y here you can choose to randomize the following areas:
98426 + - top of the task's kernel stack
98427 + - top of the task's userland stack
98428 + - base address for mmap() requests that do not specify one
98429 + (this includes all libraries)
98430 + - base address of the main executable
98431 +
98432 + It is strongly recommended to say Y here as address space layout
98433 + randomization has negligible impact on performance yet it provides
98434 + a very effective protection.
98435 +
98436 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98437 + this feature on a per file basis.
98438 +
98439 +config PAX_RANDKSTACK
98440 + bool "Randomize kernel stack base"
98441 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
98442 + depends on X86_TSC && X86
98443 + help
98444 + By saying Y here the kernel will randomize every task's kernel
98445 + stack on every system call. This will not only force an attacker
98446 + to guess it but also prevent him from making use of possible
98447 + leaked information about it.
98448 +
98449 + Since the kernel stack is a rather scarce resource, randomization
98450 + may cause unexpected stack overflows, therefore you should very
98451 + carefully test your system. Note that once enabled in the kernel
98452 + configuration, this feature cannot be disabled on a per file basis.
98453 +
98454 +config PAX_RANDUSTACK
98455 + bool "Randomize user stack base"
98456 + default y if GRKERNSEC_CONFIG_AUTO
98457 + depends on PAX_ASLR
98458 + help
98459 + By saying Y here the kernel will randomize every task's userland
98460 + stack. The randomization is done in two steps where the second
98461 + one may apply a big amount of shift to the top of the stack and
98462 + cause problems for programs that want to use lots of memory (more
98463 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
98464 + For this reason the second step can be controlled by 'chpax' or
98465 + 'paxctl' on a per file basis.
98466 +
98467 +config PAX_RANDMMAP
98468 + bool "Randomize mmap() base"
98469 + default y if GRKERNSEC_CONFIG_AUTO
98470 + depends on PAX_ASLR
98471 + help
98472 + By saying Y here the kernel will use a randomized base address for
98473 + mmap() requests that do not specify one themselves. As a result
98474 + all dynamically loaded libraries will appear at random addresses
98475 + and therefore be harder to exploit by a technique where an attacker
98476 + attempts to execute library code for his purposes (e.g. spawn a
98477 + shell from an exploited program that is running at an elevated
98478 + privilege level).
98479 +
98480 + Furthermore, if a program is relinked as a dynamic ELF file, its
98481 + base address will be randomized as well, completing the full
98482 + randomization of the address space layout. Attacking such programs
98483 + becomes a guess game. You can find an example of doing this at
98484 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
98485 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
98486 +
98487 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
98488 + feature on a per file basis.
98489 +
98490 +endmenu
98491 +
98492 +menu "Miscellaneous hardening features"
98493 +
98494 +config PAX_MEMORY_SANITIZE
98495 + bool "Sanitize all freed memory"
98496 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98497 + depends on !HIBERNATION
98498 + help
98499 + By saying Y here the kernel will erase memory pages and slab objects
98500 + as soon as they are freed. This in turn reduces the lifetime of data
98501 + stored in them, making it less likely that sensitive information such
98502 + as passwords, cryptographic secrets, etc stay in memory for too long.
98503 +
98504 + This is especially useful for programs whose runtime is short, long
98505 + lived processes and the kernel itself benefit from this as long as
98506 + they ensure timely freeing of memory that may hold sensitive
98507 + information.
98508 +
98509 + A nice side effect of the sanitization of slab objects is the
98510 + reduction of possible info leaks caused by padding bytes within the
98511 + leaky structures. Use-after-free bugs for structures containing
98512 + pointers can also be detected as dereferencing the sanitized pointer
98513 + will generate an access violation.
98514 +
98515 + The tradeoff is performance impact, on a single CPU system kernel
98516 + compilation sees a 3% slowdown, other systems and workloads may vary
98517 + and you are advised to test this feature on your expected workload
98518 + before deploying it.
98519 +
98520 + To reduce the performance penalty by sanitizing pages only, albeit
98521 + limiting the effectiveness of this feature at the same time, slab
98522 + sanitization can be disabled with the kernel commandline parameter
98523 + "pax_sanitize_slab=0".
98524 +
98525 + Note that this feature does not protect data stored in live pages,
98526 + e.g., process memory swapped to disk may stay there for a long time.
98527 +
98528 +config PAX_MEMORY_STACKLEAK
98529 + bool "Sanitize kernel stack"
98530 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98531 + depends on X86
98532 + help
98533 + By saying Y here the kernel will erase the kernel stack before it
98534 + returns from a system call. This in turn reduces the information
98535 + that a kernel stack leak bug can reveal.
98536 +
98537 + Note that such a bug can still leak information that was put on
98538 + the stack by the current system call (the one eventually triggering
98539 + the bug) but traces of earlier system calls on the kernel stack
98540 + cannot leak anymore.
98541 +
98542 + The tradeoff is performance impact: on a single CPU system kernel
98543 + compilation sees a 1% slowdown, other systems and workloads may vary
98544 + and you are advised to test this feature on your expected workload
98545 + before deploying it.
98546 +
98547 + Note that the full feature requires a gcc with plugin support,
98548 + i.e., gcc 4.5 or newer. You may need to install the supporting
98549 + headers explicitly in addition to the normal gcc package. Using
98550 + older gcc versions means that functions with large enough stack
98551 + frames may leave uninitialized memory behind that may be exposed
98552 + to a later syscall leaking the stack.
98553 +
98554 +config PAX_MEMORY_STRUCTLEAK
98555 + bool "Forcibly initialize local variables copied to userland"
98556 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98557 + help
98558 + By saying Y here the kernel will zero initialize some local
98559 + variables that are going to be copied to userland. This in
98560 + turn prevents unintended information leakage from the kernel
98561 + stack should later code forget to explicitly set all parts of
98562 + the copied variable.
98563 +
98564 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
98565 + at a much smaller coverage.
98566 +
98567 + Note that the implementation requires a gcc with plugin support,
98568 + i.e., gcc 4.5 or newer. You may need to install the supporting
98569 + headers explicitly in addition to the normal gcc package.
98570 +
98571 +config PAX_MEMORY_UDEREF
98572 + bool "Prevent invalid userland pointer dereference"
98573 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
98574 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
98575 + select PAX_PER_CPU_PGD if X86_64
98576 + help
98577 + By saying Y here the kernel will be prevented from dereferencing
98578 + userland pointers in contexts where the kernel expects only kernel
98579 + pointers. This is both a useful runtime debugging feature and a
98580 + security measure that prevents exploiting a class of kernel bugs.
98581 +
98582 + The tradeoff is that some virtualization solutions may experience
98583 + a huge slowdown and therefore you should not enable this feature
98584 + for kernels meant to run in such environments. Whether a given VM
98585 + solution is affected or not is best determined by simply trying it
98586 + out, the performance impact will be obvious right on boot as this
98587 + mechanism engages from very early on. A good rule of thumb is that
98588 + VMs running on CPUs without hardware virtualization support (i.e.,
98589 + the majority of IA-32 CPUs) will likely experience the slowdown.
98590 +
98591 + On X86_64 the kernel will make use of PCID support when available
98592 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
98593 + or performance impact. Pass pax_weakuderef on the kernel command
98594 + line to choose the latter.
98595 +
98596 +config PAX_REFCOUNT
98597 + bool "Prevent various kernel object reference counter overflows"
98598 + default y if GRKERNSEC_CONFIG_AUTO
98599 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
98600 + help
98601 + By saying Y here the kernel will detect and prevent overflowing
98602 + various (but not all) kinds of object reference counters. Such
98603 + overflows can normally occur due to bugs only and are often, if
98604 + not always, exploitable.
98605 +
98606 + The tradeoff is that data structures protected by an overflowed
98607 + refcount will never be freed and therefore will leak memory. Note
98608 + that this leak also happens even without this protection but in
98609 + that case the overflow can eventually trigger the freeing of the
98610 + data structure while it is still being used elsewhere, resulting
98611 + in the exploitable situation that this feature prevents.
98612 +
98613 + Since this has a negligible performance impact, you should enable
98614 + this feature.
98615 +
98616 +config PAX_CONSTIFY_PLUGIN
98617 + bool "Automatically constify eligible structures"
98618 + default y
98619 + depends on !UML && PAX_KERNEXEC
98620 + help
98621 + By saying Y here the compiler will automatically constify a class
98622 + of types that contain only function pointers. This reduces the
98623 + kernel's attack surface and also produces a better memory layout.
98624 +
98625 + Note that the implementation requires a gcc with plugin support,
98626 + i.e., gcc 4.5 or newer. You may need to install the supporting
98627 + headers explicitly in addition to the normal gcc package.
98628 +
98629 + Note that if some code really has to modify constified variables
98630 + then the source code will have to be patched to allow it. Examples
98631 + can be found in PaX itself (the no_const attribute) and for some
98632 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
98633 +
98634 +config PAX_USERCOPY
98635 + bool "Harden heap object copies between kernel and userland"
98636 + default y if GRKERNSEC_CONFIG_AUTO
98637 + depends on ARM || IA64 || PPC || SPARC || X86
98638 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
98639 + select PAX_USERCOPY_SLABS
98640 + help
98641 + By saying Y here the kernel will enforce the size of heap objects
98642 + when they are copied in either direction between the kernel and
98643 + userland, even if only a part of the heap object is copied.
98644 +
98645 + Specifically, this checking prevents information leaking from the
98646 + kernel heap during kernel to userland copies (if the kernel heap
98647 + object is otherwise fully initialized) and prevents kernel heap
98648 + overflows during userland to kernel copies.
98649 +
98650 + Note that the current implementation provides the strictest bounds
98651 + checks for the SLUB allocator.
98652 +
98653 + Enabling this option also enables per-slab cache protection against
98654 + data in a given cache being copied into/out of via userland
98655 + accessors. Though the whitelist of regions will be reduced over
98656 + time, it notably protects important data structures like task structs.
98657 +
98658 + If frame pointers are enabled on x86, this option will also restrict
98659 + copies into and out of the kernel stack to local variables within a
98660 + single frame.
98661 +
98662 + Since this has a negligible performance impact, you should enable
98663 + this feature.
98664 +
98665 +config PAX_USERCOPY_DEBUG
98666 + bool
98667 + depends on X86 && PAX_USERCOPY
98668 + default n
98669 +
98670 +config PAX_SIZE_OVERFLOW
98671 + bool "Prevent various integer overflows in function size parameters"
98672 + default y if GRKERNSEC_CONFIG_AUTO
98673 + depends on X86
98674 + help
98675 + By saying Y here the kernel recomputes expressions of function
98676 + arguments marked by a size_overflow attribute with double integer
98677 + precision (DImode/TImode for 32/64 bit integer types).
98678 +
98679 + The recomputed argument is checked against TYPE_MAX and an event
98680 + is logged on overflow and the triggering process is killed.
98681 +
98682 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
98683 +
98684 + Note that the implementation requires a gcc with plugin support,
98685 + i.e., gcc 4.5 or newer. You may need to install the supporting
98686 + headers explicitly in addition to the normal gcc package.
98687 +
98688 +config PAX_LATENT_ENTROPY
98689 + bool "Generate some entropy during boot and runtime"
98690 + default y if GRKERNSEC_CONFIG_AUTO
98691 + help
98692 + By saying Y here the kernel will instrument some kernel code to
98693 + extract some entropy from both original and artificially created
98694 + program state. This will help especially embedded systems where
98695 + there is little 'natural' source of entropy normally. The cost
98696 + is some slowdown of the boot process and fork and irq processing.
98697 +
98698 + When pax_extra_latent_entropy is passed on the kernel command line,
98699 + entropy will be extracted from up to the first 4GB of RAM while the
98700 + runtime memory allocator is being initialized. This costs even more
98701 + slowdown of the boot process.
98702 +
98703 + Note that the implementation requires a gcc with plugin support,
98704 + i.e., gcc 4.5 or newer. You may need to install the supporting
98705 + headers explicitly in addition to the normal gcc package.
98706 +
98707 + Note that entropy extracted this way is not cryptographically
98708 + secure!
98709 +
98710 +endmenu
98711 +
98712 +endmenu
98713 +
98714 +source grsecurity/Kconfig
98715 +
98716 +endmenu
98717 +
98718 +endmenu
98719 +
98720 source security/keys/Kconfig
98721
98722 config SECURITY_DMESG_RESTRICT
98723 @@ -103,7 +1057,7 @@ config INTEL_TXT
98724 config LSM_MMAP_MIN_ADDR
98725 int "Low address space for LSM to protect from user allocation"
98726 depends on SECURITY && SECURITY_SELINUX
98727 - default 32768 if ARM
98728 + default 32768 if ALPHA || ARM || PARISC || SPARC32
98729 default 65536
98730 help
98731 This is the portion of low virtual memory which should be protected
98732 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
98733 index 9b9013b..51ebf96 100644
98734 --- a/security/apparmor/Kconfig
98735 +++ b/security/apparmor/Kconfig
98736 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
98737 boot.
98738
98739 If you are unsure how to answer this question, answer 1.
98740 +
98741 +config SECURITY_APPARMOR_COMPAT_24
98742 + bool "Enable AppArmor 2.4 compatability"
98743 + depends on SECURITY_APPARMOR
98744 + default y
98745 + help
98746 + This option enables compatability with AppArmor 2.4. It is
98747 + recommended if compatability with older versions of AppArmor
98748 + is desired.
98749 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
98750 index 16c15ec..42b7c9f 100644
98751 --- a/security/apparmor/apparmorfs.c
98752 +++ b/security/apparmor/apparmorfs.c
98753 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
98754 .release = single_release,
98755 };
98756
98757 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98758 +/**
98759 + * __next_namespace - find the next namespace to list
98760 + * @root: root namespace to stop search at (NOT NULL)
98761 + * @ns: current ns position (NOT NULL)
98762 + *
98763 + * Find the next namespace from @ns under @root and handle all locking needed
98764 + * while switching current namespace.
98765 + *
98766 + * Returns: next namespace or NULL if at last namespace under @root
98767 + * NOTE: will not unlock root->lock
98768 + */
98769 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
98770 + struct aa_namespace *ns)
98771 +{
98772 + struct aa_namespace *parent;
98773 +
98774 + /* is next namespace a child */
98775 + if (!list_empty(&ns->sub_ns)) {
98776 + struct aa_namespace *next;
98777 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
98778 + read_lock(&next->lock);
98779 + return next;
98780 + }
98781 +
98782 + /* check if the next ns is a sibling, parent, gp, .. */
98783 + parent = ns->parent;
98784 + while (parent) {
98785 + read_unlock(&ns->lock);
98786 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
98787 + read_lock(&ns->lock);
98788 + return ns;
98789 + }
98790 + if (parent == root)
98791 + return NULL;
98792 + ns = parent;
98793 + parent = parent->parent;
98794 + }
98795 +
98796 + return NULL;
98797 +}
98798 +
98799 +/**
98800 + * __first_profile - find the first profile in a namespace
98801 + * @root: namespace that is root of profiles being displayed (NOT NULL)
98802 + * @ns: namespace to start in (NOT NULL)
98803 + *
98804 + * Returns: unrefcounted profile or NULL if no profile
98805 + */
98806 +static struct aa_profile *__first_profile(struct aa_namespace *root,
98807 + struct aa_namespace *ns)
98808 +{
98809 + for ( ; ns; ns = __next_namespace(root, ns)) {
98810 + if (!list_empty(&ns->base.profiles))
98811 + return list_first_entry(&ns->base.profiles,
98812 + struct aa_profile, base.list);
98813 + }
98814 + return NULL;
98815 +}
98816 +
98817 +/**
98818 + * __next_profile - step to the next profile in a profile tree
98819 + * @profile: current profile in tree (NOT NULL)
98820 + *
98821 + * Perform a depth first taversal on the profile tree in a namespace
98822 + *
98823 + * Returns: next profile or NULL if done
98824 + * Requires: profile->ns.lock to be held
98825 + */
98826 +static struct aa_profile *__next_profile(struct aa_profile *p)
98827 +{
98828 + struct aa_profile *parent;
98829 + struct aa_namespace *ns = p->ns;
98830 +
98831 + /* is next profile a child */
98832 + if (!list_empty(&p->base.profiles))
98833 + return list_first_entry(&p->base.profiles, typeof(*p),
98834 + base.list);
98835 +
98836 + /* is next profile a sibling, parent sibling, gp, subling, .. */
98837 + parent = p->parent;
98838 + while (parent) {
98839 + list_for_each_entry_continue(p, &parent->base.profiles,
98840 + base.list)
98841 + return p;
98842 + p = parent;
98843 + parent = parent->parent;
98844 + }
98845 +
98846 + /* is next another profile in the namespace */
98847 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
98848 + return p;
98849 +
98850 + return NULL;
98851 +}
98852 +
98853 +/**
98854 + * next_profile - step to the next profile in where ever it may be
98855 + * @root: root namespace (NOT NULL)
98856 + * @profile: current profile (NOT NULL)
98857 + *
98858 + * Returns: next profile or NULL if there isn't one
98859 + */
98860 +static struct aa_profile *next_profile(struct aa_namespace *root,
98861 + struct aa_profile *profile)
98862 +{
98863 + struct aa_profile *next = __next_profile(profile);
98864 + if (next)
98865 + return next;
98866 +
98867 + /* finished all profiles in namespace move to next namespace */
98868 + return __first_profile(root, __next_namespace(root, profile->ns));
98869 +}
98870 +
98871 +/**
98872 + * p_start - start a depth first traversal of profile tree
98873 + * @f: seq_file to fill
98874 + * @pos: current position
98875 + *
98876 + * Returns: first profile under current namespace or NULL if none found
98877 + *
98878 + * acquires first ns->lock
98879 + */
98880 +static void *p_start(struct seq_file *f, loff_t *pos)
98881 + __acquires(root->lock)
98882 +{
98883 + struct aa_profile *profile = NULL;
98884 + struct aa_namespace *root = aa_current_profile()->ns;
98885 + loff_t l = *pos;
98886 + f->private = aa_get_namespace(root);
98887 +
98888 +
98889 + /* find the first profile */
98890 + read_lock(&root->lock);
98891 + profile = __first_profile(root, root);
98892 +
98893 + /* skip to position */
98894 + for (; profile && l > 0; l--)
98895 + profile = next_profile(root, profile);
98896 +
98897 + return profile;
98898 +}
98899 +
98900 +/**
98901 + * p_next - read the next profile entry
98902 + * @f: seq_file to fill
98903 + * @p: profile previously returned
98904 + * @pos: current position
98905 + *
98906 + * Returns: next profile after @p or NULL if none
98907 + *
98908 + * may acquire/release locks in namespace tree as necessary
98909 + */
98910 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
98911 +{
98912 + struct aa_profile *profile = p;
98913 + struct aa_namespace *root = f->private;
98914 + (*pos)++;
98915 +
98916 + return next_profile(root, profile);
98917 +}
98918 +
98919 +/**
98920 + * p_stop - stop depth first traversal
98921 + * @f: seq_file we are filling
98922 + * @p: the last profile writen
98923 + *
98924 + * Release all locking done by p_start/p_next on namespace tree
98925 + */
98926 +static void p_stop(struct seq_file *f, void *p)
98927 + __releases(root->lock)
98928 +{
98929 + struct aa_profile *profile = p;
98930 + struct aa_namespace *root = f->private, *ns;
98931 +
98932 + if (profile) {
98933 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
98934 + read_unlock(&ns->lock);
98935 + }
98936 + read_unlock(&root->lock);
98937 + aa_put_namespace(root);
98938 +}
98939 +
98940 +/**
98941 + * seq_show_profile - show a profile entry
98942 + * @f: seq_file to file
98943 + * @p: current position (profile) (NOT NULL)
98944 + *
98945 + * Returns: error on failure
98946 + */
98947 +static int seq_show_profile(struct seq_file *f, void *p)
98948 +{
98949 + struct aa_profile *profile = (struct aa_profile *)p;
98950 + struct aa_namespace *root = f->private;
98951 +
98952 + if (profile->ns != root)
98953 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
98954 + seq_printf(f, "%s (%s)\n", profile->base.hname,
98955 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
98956 +
98957 + return 0;
98958 +}
98959 +
98960 +static const struct seq_operations aa_fs_profiles_op = {
98961 + .start = p_start,
98962 + .next = p_next,
98963 + .stop = p_stop,
98964 + .show = seq_show_profile,
98965 +};
98966 +
98967 +static int profiles_open(struct inode *inode, struct file *file)
98968 +{
98969 + return seq_open(file, &aa_fs_profiles_op);
98970 +}
98971 +
98972 +static int profiles_release(struct inode *inode, struct file *file)
98973 +{
98974 + return seq_release(inode, file);
98975 +}
98976 +
98977 +const struct file_operations aa_fs_profiles_fops = {
98978 + .open = profiles_open,
98979 + .read = seq_read,
98980 + .llseek = seq_lseek,
98981 + .release = profiles_release,
98982 +};
98983 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
98984 +
98985 /** Base file system setup **/
98986
98987 static struct aa_fs_entry aa_fs_entry_file[] = {
98988 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
98989 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
98990 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
98991 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
98992 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98993 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
98994 +#endif
98995 AA_FS_DIR("features", aa_fs_entry_features),
98996 { }
98997 };
98998 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
98999 index 2e2a0dd..a0cbc44 100644
99000 --- a/security/apparmor/lsm.c
99001 +++ b/security/apparmor/lsm.c
99002 @@ -613,7 +613,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
99003 return error;
99004 }
99005
99006 -static struct security_operations apparmor_ops = {
99007 +static struct security_operations apparmor_ops __read_only = {
99008 .name = "apparmor",
99009
99010 .ptrace_access_check = apparmor_ptrace_access_check,
99011 diff --git a/security/commoncap.c b/security/commoncap.c
99012 index c44b6fe..932df30 100644
99013 --- a/security/commoncap.c
99014 +++ b/security/commoncap.c
99015 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
99016 return 0;
99017 }
99018
99019 +/* returns:
99020 + 1 for suid privilege
99021 + 2 for sgid privilege
99022 + 3 for fscap privilege
99023 +*/
99024 +int is_privileged_binary(const struct dentry *dentry)
99025 +{
99026 + struct cpu_vfs_cap_data capdata;
99027 + struct inode *inode = dentry->d_inode;
99028 +
99029 + if (!inode || S_ISDIR(inode->i_mode))
99030 + return 0;
99031 +
99032 + if (inode->i_mode & S_ISUID)
99033 + return 1;
99034 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
99035 + return 2;
99036 +
99037 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
99038 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
99039 + return 3;
99040 + }
99041 +
99042 + return 0;
99043 +}
99044 +
99045 /*
99046 * Attempt to get the on-exec apply capability sets for an executable file from
99047 * its xattrs and, if present, apply them to the proposed credentials being
99048 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
99049 const struct cred *cred = current_cred();
99050 kuid_t root_uid = make_kuid(cred->user_ns, 0);
99051
99052 + if (gr_acl_enable_at_secure())
99053 + return 1;
99054 +
99055 if (!uid_eq(cred->uid, root_uid)) {
99056 if (bprm->cap_effective)
99057 return 1;
99058 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
99059 index b3dd616..4bb17f3 100644
99060 --- a/security/integrity/ima/ima.h
99061 +++ b/security/integrity/ima/ima.h
99062 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
99063 extern spinlock_t ima_queue_lock;
99064
99065 struct ima_h_table {
99066 - atomic_long_t len; /* number of stored measurements in the list */
99067 - atomic_long_t violations;
99068 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
99069 + atomic_long_unchecked_t violations;
99070 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
99071 };
99072 extern struct ima_h_table ima_htable;
99073 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
99074 index 1c03e8f1..398a941 100644
99075 --- a/security/integrity/ima/ima_api.c
99076 +++ b/security/integrity/ima/ima_api.c
99077 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
99078 int result;
99079
99080 /* can overflow, only indicator */
99081 - atomic_long_inc(&ima_htable.violations);
99082 + atomic_long_inc_unchecked(&ima_htable.violations);
99083
99084 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
99085 if (!entry) {
99086 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
99087 index 38477c9..87a60c7 100644
99088 --- a/security/integrity/ima/ima_fs.c
99089 +++ b/security/integrity/ima/ima_fs.c
99090 @@ -28,12 +28,12 @@
99091 static int valid_policy = 1;
99092 #define TMPBUFLEN 12
99093 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
99094 - loff_t *ppos, atomic_long_t *val)
99095 + loff_t *ppos, atomic_long_unchecked_t *val)
99096 {
99097 char tmpbuf[TMPBUFLEN];
99098 ssize_t len;
99099
99100 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
99101 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
99102 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
99103 }
99104
99105 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
99106 index ff63fe0..809cd96 100644
99107 --- a/security/integrity/ima/ima_queue.c
99108 +++ b/security/integrity/ima/ima_queue.c
99109 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
99110 INIT_LIST_HEAD(&qe->later);
99111 list_add_tail_rcu(&qe->later, &ima_measurements);
99112
99113 - atomic_long_inc(&ima_htable.len);
99114 + atomic_long_inc_unchecked(&ima_htable.len);
99115 key = ima_hash_key(entry->digest);
99116 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
99117 return 0;
99118 diff --git a/security/keys/compat.c b/security/keys/compat.c
99119 index d65fa7f..cbfe366 100644
99120 --- a/security/keys/compat.c
99121 +++ b/security/keys/compat.c
99122 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
99123 if (ret == 0)
99124 goto no_payload_free;
99125
99126 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99127 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99128 err:
99129 if (iov != iovstack)
99130 kfree(iov);
99131 diff --git a/security/keys/internal.h b/security/keys/internal.h
99132 index d4f1468..cc52f92 100644
99133 --- a/security/keys/internal.h
99134 +++ b/security/keys/internal.h
99135 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
99136 extern long keyctl_invalidate_key(key_serial_t);
99137
99138 extern long keyctl_instantiate_key_common(key_serial_t,
99139 - const struct iovec *,
99140 + const struct iovec __user *,
99141 unsigned, size_t, key_serial_t);
99142
99143 /*
99144 diff --git a/security/keys/key.c b/security/keys/key.c
99145 index 8fb7c7b..ba3610d 100644
99146 --- a/security/keys/key.c
99147 +++ b/security/keys/key.c
99148 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
99149
99150 atomic_set(&key->usage, 1);
99151 init_rwsem(&key->sem);
99152 - lockdep_set_class(&key->sem, &type->lock_class);
99153 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
99154 key->type = type;
99155 key->user = user;
99156 key->quotalen = quotalen;
99157 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
99158 struct key_type *p;
99159 int ret;
99160
99161 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
99162 + pax_open_kernel();
99163 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
99164 + pax_close_kernel();
99165
99166 ret = -EEXIST;
99167 down_write(&key_types_sem);
99168 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
99169 }
99170
99171 /* store the type */
99172 - list_add(&ktype->link, &key_types_list);
99173 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
99174
99175 pr_notice("Key type %s registered\n", ktype->name);
99176 ret = 0;
99177 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
99178 void unregister_key_type(struct key_type *ktype)
99179 {
99180 down_write(&key_types_sem);
99181 - list_del_init(&ktype->link);
99182 + pax_list_del_init((struct list_head *)&ktype->link);
99183 downgrade_write(&key_types_sem);
99184 key_gc_keytype(ktype);
99185 pr_notice("Key type %s unregistered\n", ktype->name);
99186 @@ -1084,10 +1086,10 @@ void __init key_init(void)
99187 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
99188
99189 /* add the special key types */
99190 - list_add_tail(&key_type_keyring.link, &key_types_list);
99191 - list_add_tail(&key_type_dead.link, &key_types_list);
99192 - list_add_tail(&key_type_user.link, &key_types_list);
99193 - list_add_tail(&key_type_logon.link, &key_types_list);
99194 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
99195 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
99196 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
99197 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
99198
99199 /* record the root user tracking */
99200 rb_link_node(&root_key_user.node,
99201 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
99202 index 33cfd27..842fc5a 100644
99203 --- a/security/keys/keyctl.c
99204 +++ b/security/keys/keyctl.c
99205 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
99206 /*
99207 * Copy the iovec data from userspace
99208 */
99209 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99210 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
99211 unsigned ioc)
99212 {
99213 for (; ioc > 0; ioc--) {
99214 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99215 * If successful, 0 will be returned.
99216 */
99217 long keyctl_instantiate_key_common(key_serial_t id,
99218 - const struct iovec *payload_iov,
99219 + const struct iovec __user *payload_iov,
99220 unsigned ioc,
99221 size_t plen,
99222 key_serial_t ringid)
99223 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
99224 [0].iov_len = plen
99225 };
99226
99227 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
99228 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
99229 }
99230
99231 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
99232 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
99233 if (ret == 0)
99234 goto no_payload_free;
99235
99236 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99237 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99238 err:
99239 if (iov != iovstack)
99240 kfree(iov);
99241 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
99242 index 6ece7f2..ecdb55c 100644
99243 --- a/security/keys/keyring.c
99244 +++ b/security/keys/keyring.c
99245 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
99246 ret = -EFAULT;
99247
99248 for (loop = 0; loop < klist->nkeys; loop++) {
99249 + key_serial_t serial;
99250 key = rcu_deref_link_locked(klist, loop,
99251 keyring);
99252 + serial = key->serial;
99253
99254 tmp = sizeof(key_serial_t);
99255 if (tmp > buflen)
99256 tmp = buflen;
99257
99258 - if (copy_to_user(buffer,
99259 - &key->serial,
99260 - tmp) != 0)
99261 + if (copy_to_user(buffer, &serial, tmp))
99262 goto error;
99263
99264 buflen -= tmp;
99265 diff --git a/security/min_addr.c b/security/min_addr.c
99266 index f728728..6457a0c 100644
99267 --- a/security/min_addr.c
99268 +++ b/security/min_addr.c
99269 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
99270 */
99271 static void update_mmap_min_addr(void)
99272 {
99273 +#ifndef SPARC
99274 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
99275 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
99276 mmap_min_addr = dac_mmap_min_addr;
99277 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
99278 #else
99279 mmap_min_addr = dac_mmap_min_addr;
99280 #endif
99281 +#endif
99282 }
99283
99284 /*
99285 diff --git a/security/security.c b/security/security.c
99286 index 94b35ae..f4e7751 100644
99287 --- a/security/security.c
99288 +++ b/security/security.c
99289 @@ -33,8 +33,8 @@
99290 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
99291 CONFIG_DEFAULT_SECURITY;
99292
99293 -static struct security_operations *security_ops;
99294 -static struct security_operations default_security_ops = {
99295 +struct security_operations *security_ops __read_only;
99296 +struct security_operations default_security_ops __read_only = {
99297 .name = "default",
99298 };
99299
99300 @@ -73,11 +73,6 @@ int __init security_init(void)
99301 return 0;
99302 }
99303
99304 -void reset_security_ops(void)
99305 -{
99306 - security_ops = &default_security_ops;
99307 -}
99308 -
99309 /* Save user chosen LSM */
99310 static int __init choose_lsm(char *str)
99311 {
99312 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
99313 index dad36a6..7e5ffbf 100644
99314 --- a/security/selinux/avc.c
99315 +++ b/security/selinux/avc.c
99316 @@ -59,7 +59,7 @@ struct avc_node {
99317 struct avc_cache {
99318 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
99319 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
99320 - atomic_t lru_hint; /* LRU hint for reclaim scan */
99321 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
99322 atomic_t active_nodes;
99323 u32 latest_notif; /* latest revocation notification */
99324 };
99325 @@ -167,7 +167,7 @@ void __init avc_init(void)
99326 spin_lock_init(&avc_cache.slots_lock[i]);
99327 }
99328 atomic_set(&avc_cache.active_nodes, 0);
99329 - atomic_set(&avc_cache.lru_hint, 0);
99330 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
99331
99332 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
99333 0, SLAB_PANIC, NULL);
99334 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
99335 spinlock_t *lock;
99336
99337 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
99338 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99339 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99340 head = &avc_cache.slots[hvalue];
99341 lock = &avc_cache.slots_lock[hvalue];
99342
99343 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
99344 index c956390..1899f06 100644
99345 --- a/security/selinux/hooks.c
99346 +++ b/security/selinux/hooks.c
99347 @@ -97,8 +97,6 @@
99348
99349 #define NUM_SEL_MNT_OPTS 5
99350
99351 -extern struct security_operations *security_ops;
99352 -
99353 /* SECMARK reference count */
99354 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
99355
99356 @@ -5609,7 +5607,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
99357
99358 #endif
99359
99360 -static struct security_operations selinux_ops = {
99361 +static struct security_operations selinux_ops __read_only = {
99362 .name = "selinux",
99363
99364 .ptrace_access_check = selinux_ptrace_access_check,
99365 @@ -5961,6 +5959,9 @@ static void selinux_nf_ip_exit(void)
99366 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
99367 static int selinux_disabled;
99368
99369 +extern struct security_operations *security_ops;
99370 +extern struct security_operations default_security_ops;
99371 +
99372 int selinux_disable(void)
99373 {
99374 if (ss_initialized) {
99375 @@ -5978,7 +5979,9 @@ int selinux_disable(void)
99376 selinux_disabled = 1;
99377 selinux_enabled = 0;
99378
99379 - reset_security_ops();
99380 + pax_open_kernel();
99381 + security_ops = &default_security_ops;
99382 + pax_close_kernel();
99383
99384 /* Try to destroy the avc node cache */
99385 avc_disable();
99386 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
99387 index 65f67cb..3f141ef 100644
99388 --- a/security/selinux/include/xfrm.h
99389 +++ b/security/selinux/include/xfrm.h
99390 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
99391
99392 static inline void selinux_xfrm_notify_policyload(void)
99393 {
99394 - atomic_inc(&flow_cache_genid);
99395 + atomic_inc_unchecked(&flow_cache_genid);
99396 rt_genid_bump(&init_net);
99397 }
99398 #else
99399 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
99400 index eefbd10..9f10ddb 100644
99401 --- a/security/smack/smack_lsm.c
99402 +++ b/security/smack/smack_lsm.c
99403 @@ -3711,7 +3711,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
99404 return 0;
99405 }
99406
99407 -struct security_operations smack_ops = {
99408 +struct security_operations smack_ops __read_only = {
99409 .name = "smack",
99410
99411 .ptrace_access_check = smack_ptrace_access_check,
99412 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
99413 index 390c646..f2f8db3 100644
99414 --- a/security/tomoyo/mount.c
99415 +++ b/security/tomoyo/mount.c
99416 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
99417 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
99418 need_dev = -1; /* dev_name is a directory */
99419 } else {
99420 + if (!capable(CAP_SYS_ADMIN)) {
99421 + error = -EPERM;
99422 + goto out;
99423 + }
99424 fstype = get_fs_type(type);
99425 if (!fstype) {
99426 error = -ENODEV;
99427 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
99428 index f0b756e..b129202 100644
99429 --- a/security/tomoyo/tomoyo.c
99430 +++ b/security/tomoyo/tomoyo.c
99431 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
99432 * tomoyo_security_ops is a "struct security_operations" which is used for
99433 * registering TOMOYO.
99434 */
99435 -static struct security_operations tomoyo_security_ops = {
99436 +static struct security_operations tomoyo_security_ops __read_only = {
99437 .name = "tomoyo",
99438 .cred_alloc_blank = tomoyo_cred_alloc_blank,
99439 .cred_prepare = tomoyo_cred_prepare,
99440 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
99441 index 20ef514..4182bed 100644
99442 --- a/security/yama/Kconfig
99443 +++ b/security/yama/Kconfig
99444 @@ -1,6 +1,6 @@
99445 config SECURITY_YAMA
99446 bool "Yama support"
99447 - depends on SECURITY
99448 + depends on SECURITY && !GRKERNSEC
99449 select SECURITYFS
99450 select SECURITY_PATH
99451 default n
99452 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
99453 index 13c88fbc..f8c115e 100644
99454 --- a/security/yama/yama_lsm.c
99455 +++ b/security/yama/yama_lsm.c
99456 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
99457 }
99458
99459 #ifndef CONFIG_SECURITY_YAMA_STACKED
99460 -static struct security_operations yama_ops = {
99461 +static struct security_operations yama_ops __read_only = {
99462 .name = "yama",
99463
99464 .ptrace_access_check = yama_ptrace_access_check,
99465 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
99466 #endif
99467
99468 #ifdef CONFIG_SYSCTL
99469 +static int zero __read_only;
99470 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
99471 +
99472 static int yama_dointvec_minmax(struct ctl_table *table, int write,
99473 void __user *buffer, size_t *lenp, loff_t *ppos)
99474 {
99475 - int rc;
99476 + ctl_table_no_const yama_table;
99477
99478 if (write && !capable(CAP_SYS_PTRACE))
99479 return -EPERM;
99480
99481 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
99482 - if (rc)
99483 - return rc;
99484 -
99485 + yama_table = *table;
99486 /* Lock the max value if it ever gets set. */
99487 - if (write && *(int *)table->data == *(int *)table->extra2)
99488 - table->extra1 = table->extra2;
99489 -
99490 - return rc;
99491 + if (ptrace_scope == max_scope)
99492 + yama_table.extra1 = &max_scope;
99493 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
99494 }
99495
99496 -static int zero;
99497 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
99498 -
99499 struct ctl_path yama_sysctl_path[] = {
99500 { .procname = "kernel", },
99501 { .procname = "yama", },
99502 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
99503 index 4cedc69..e59d8a3 100644
99504 --- a/sound/aoa/codecs/onyx.c
99505 +++ b/sound/aoa/codecs/onyx.c
99506 @@ -54,7 +54,7 @@ struct onyx {
99507 spdif_locked:1,
99508 analog_locked:1,
99509 original_mute:2;
99510 - int open_count;
99511 + local_t open_count;
99512 struct codec_info *codec_info;
99513
99514 /* mutex serializes concurrent access to the device
99515 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
99516 struct onyx *onyx = cii->codec_data;
99517
99518 mutex_lock(&onyx->mutex);
99519 - onyx->open_count++;
99520 + local_inc(&onyx->open_count);
99521 mutex_unlock(&onyx->mutex);
99522
99523 return 0;
99524 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
99525 struct onyx *onyx = cii->codec_data;
99526
99527 mutex_lock(&onyx->mutex);
99528 - onyx->open_count--;
99529 - if (!onyx->open_count)
99530 + if (local_dec_and_test(&onyx->open_count))
99531 onyx->spdif_locked = onyx->analog_locked = 0;
99532 mutex_unlock(&onyx->mutex);
99533
99534 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
99535 index ffd2025..df062c9 100644
99536 --- a/sound/aoa/codecs/onyx.h
99537 +++ b/sound/aoa/codecs/onyx.h
99538 @@ -11,6 +11,7 @@
99539 #include <linux/i2c.h>
99540 #include <asm/pmac_low_i2c.h>
99541 #include <asm/prom.h>
99542 +#include <asm/local.h>
99543
99544 /* PCM3052 register definitions */
99545
99546 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
99547 index 4c1cc51..16040040 100644
99548 --- a/sound/core/oss/pcm_oss.c
99549 +++ b/sound/core/oss/pcm_oss.c
99550 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
99551 if (in_kernel) {
99552 mm_segment_t fs;
99553 fs = snd_enter_user();
99554 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99555 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99556 snd_leave_user(fs);
99557 } else {
99558 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99559 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99560 }
99561 if (ret != -EPIPE && ret != -ESTRPIPE)
99562 break;
99563 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
99564 if (in_kernel) {
99565 mm_segment_t fs;
99566 fs = snd_enter_user();
99567 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99568 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99569 snd_leave_user(fs);
99570 } else {
99571 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99572 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99573 }
99574 if (ret == -EPIPE) {
99575 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
99576 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
99577 struct snd_pcm_plugin_channel *channels;
99578 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
99579 if (!in_kernel) {
99580 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
99581 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
99582 return -EFAULT;
99583 buf = runtime->oss.buffer;
99584 }
99585 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
99586 }
99587 } else {
99588 tmp = snd_pcm_oss_write2(substream,
99589 - (const char __force *)buf,
99590 + (const char __force_kernel *)buf,
99591 runtime->oss.period_bytes, 0);
99592 if (tmp <= 0)
99593 goto err;
99594 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
99595 struct snd_pcm_runtime *runtime = substream->runtime;
99596 snd_pcm_sframes_t frames, frames1;
99597 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
99598 - char __user *final_dst = (char __force __user *)buf;
99599 + char __user *final_dst = (char __force_user *)buf;
99600 if (runtime->oss.plugin_first) {
99601 struct snd_pcm_plugin_channel *channels;
99602 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
99603 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
99604 xfer += tmp;
99605 runtime->oss.buffer_used -= tmp;
99606 } else {
99607 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
99608 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
99609 runtime->oss.period_bytes, 0);
99610 if (tmp <= 0)
99611 goto err;
99612 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
99613 size1);
99614 size1 /= runtime->channels; /* frames */
99615 fs = snd_enter_user();
99616 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
99617 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
99618 snd_leave_user(fs);
99619 }
99620 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
99621 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
99622 index af49721..e85058e 100644
99623 --- a/sound/core/pcm_compat.c
99624 +++ b/sound/core/pcm_compat.c
99625 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
99626 int err;
99627
99628 fs = snd_enter_user();
99629 - err = snd_pcm_delay(substream, &delay);
99630 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
99631 snd_leave_user(fs);
99632 if (err < 0)
99633 return err;
99634 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
99635 index a68d4c6..72af3cf 100644
99636 --- a/sound/core/pcm_native.c
99637 +++ b/sound/core/pcm_native.c
99638 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
99639 switch (substream->stream) {
99640 case SNDRV_PCM_STREAM_PLAYBACK:
99641 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
99642 - (void __user *)arg);
99643 + (void __force_user *)arg);
99644 break;
99645 case SNDRV_PCM_STREAM_CAPTURE:
99646 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
99647 - (void __user *)arg);
99648 + (void __force_user *)arg);
99649 break;
99650 default:
99651 result = -EINVAL;
99652 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
99653 index 040c60e..989a19a 100644
99654 --- a/sound/core/seq/seq_device.c
99655 +++ b/sound/core/seq/seq_device.c
99656 @@ -64,7 +64,7 @@ struct ops_list {
99657 int argsize; /* argument size */
99658
99659 /* operators */
99660 - struct snd_seq_dev_ops ops;
99661 + struct snd_seq_dev_ops *ops;
99662
99663 /* registered devices */
99664 struct list_head dev_list; /* list of devices */
99665 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
99666
99667 mutex_lock(&ops->reg_mutex);
99668 /* copy driver operators */
99669 - ops->ops = *entry;
99670 + ops->ops = entry;
99671 ops->driver |= DRIVER_LOADED;
99672 ops->argsize = argsize;
99673
99674 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99675 dev->name, ops->id, ops->argsize, dev->argsize);
99676 return -EINVAL;
99677 }
99678 - if (ops->ops.init_device(dev) >= 0) {
99679 + if (ops->ops->init_device(dev) >= 0) {
99680 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99681 ops->num_init_devices++;
99682 } else {
99683 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99684 dev->name, ops->id, ops->argsize, dev->argsize);
99685 return -EINVAL;
99686 }
99687 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99688 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99689 dev->status = SNDRV_SEQ_DEVICE_FREE;
99690 dev->driver_data = NULL;
99691 ops->num_init_devices--;
99692 diff --git a/sound/core/sound.c b/sound/core/sound.c
99693 index f002bd9..c462985 100644
99694 --- a/sound/core/sound.c
99695 +++ b/sound/core/sound.c
99696 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99697 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99698 default: return;
99699 }
99700 - request_module(str);
99701 + request_module("%s", str);
99702 }
99703
99704 #endif /* modular kernel */
99705 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99706 index 4e0dd22..7a1f32c 100644
99707 --- a/sound/drivers/mts64.c
99708 +++ b/sound/drivers/mts64.c
99709 @@ -29,6 +29,7 @@
99710 #include <sound/initval.h>
99711 #include <sound/rawmidi.h>
99712 #include <sound/control.h>
99713 +#include <asm/local.h>
99714
99715 #define CARD_NAME "Miditerminal 4140"
99716 #define DRIVER_NAME "MTS64"
99717 @@ -67,7 +68,7 @@ struct mts64 {
99718 struct pardevice *pardev;
99719 int pardev_claimed;
99720
99721 - int open_count;
99722 + local_t open_count;
99723 int current_midi_output_port;
99724 int current_midi_input_port;
99725 u8 mode[MTS64_NUM_INPUT_PORTS];
99726 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99727 {
99728 struct mts64 *mts = substream->rmidi->private_data;
99729
99730 - if (mts->open_count == 0) {
99731 + if (local_read(&mts->open_count) == 0) {
99732 /* We don't need a spinlock here, because this is just called
99733 if the device has not been opened before.
99734 So there aren't any IRQs from the device */
99735 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99736
99737 msleep(50);
99738 }
99739 - ++(mts->open_count);
99740 + local_inc(&mts->open_count);
99741
99742 return 0;
99743 }
99744 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99745 struct mts64 *mts = substream->rmidi->private_data;
99746 unsigned long flags;
99747
99748 - --(mts->open_count);
99749 - if (mts->open_count == 0) {
99750 + if (local_dec_return(&mts->open_count) == 0) {
99751 /* We need the spinlock_irqsave here because we can still
99752 have IRQs at this point */
99753 spin_lock_irqsave(&mts->lock, flags);
99754 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99755
99756 msleep(500);
99757
99758 - } else if (mts->open_count < 0)
99759 - mts->open_count = 0;
99760 + } else if (local_read(&mts->open_count) < 0)
99761 + local_set(&mts->open_count, 0);
99762
99763 return 0;
99764 }
99765 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
99766 index b953fb4..1999c01 100644
99767 --- a/sound/drivers/opl4/opl4_lib.c
99768 +++ b/sound/drivers/opl4/opl4_lib.c
99769 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
99770 MODULE_DESCRIPTION("OPL4 driver");
99771 MODULE_LICENSE("GPL");
99772
99773 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
99774 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
99775 {
99776 int timeout = 10;
99777 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
99778 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
99779 index 991018d..8984740 100644
99780 --- a/sound/drivers/portman2x4.c
99781 +++ b/sound/drivers/portman2x4.c
99782 @@ -48,6 +48,7 @@
99783 #include <sound/initval.h>
99784 #include <sound/rawmidi.h>
99785 #include <sound/control.h>
99786 +#include <asm/local.h>
99787
99788 #define CARD_NAME "Portman 2x4"
99789 #define DRIVER_NAME "portman"
99790 @@ -85,7 +86,7 @@ struct portman {
99791 struct pardevice *pardev;
99792 int pardev_claimed;
99793
99794 - int open_count;
99795 + local_t open_count;
99796 int mode[PORTMAN_NUM_INPUT_PORTS];
99797 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
99798 };
99799 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
99800 index ea995af..f1bfa37 100644
99801 --- a/sound/firewire/amdtp.c
99802 +++ b/sound/firewire/amdtp.c
99803 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
99804 ptr = s->pcm_buffer_pointer + data_blocks;
99805 if (ptr >= pcm->runtime->buffer_size)
99806 ptr -= pcm->runtime->buffer_size;
99807 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
99808 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
99809
99810 s->pcm_period_pointer += data_blocks;
99811 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
99812 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
99813 */
99814 void amdtp_out_stream_update(struct amdtp_out_stream *s)
99815 {
99816 - ACCESS_ONCE(s->source_node_id_field) =
99817 + ACCESS_ONCE_RW(s->source_node_id_field) =
99818 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
99819 }
99820 EXPORT_SYMBOL(amdtp_out_stream_update);
99821 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
99822 index f6103d6..4843fbf 100644
99823 --- a/sound/firewire/amdtp.h
99824 +++ b/sound/firewire/amdtp.h
99825 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
99826 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
99827 struct snd_pcm_substream *pcm)
99828 {
99829 - ACCESS_ONCE(s->pcm) = pcm;
99830 + ACCESS_ONCE_RW(s->pcm) = pcm;
99831 }
99832
99833 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
99834 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
99835 index 58a5afe..af5bd64 100644
99836 --- a/sound/firewire/isight.c
99837 +++ b/sound/firewire/isight.c
99838 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
99839 ptr += count;
99840 if (ptr >= runtime->buffer_size)
99841 ptr -= runtime->buffer_size;
99842 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
99843 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
99844
99845 isight->period_counter += count;
99846 if (isight->period_counter >= runtime->period_size) {
99847 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
99848 if (err < 0)
99849 return err;
99850
99851 - ACCESS_ONCE(isight->pcm_active) = true;
99852 + ACCESS_ONCE_RW(isight->pcm_active) = true;
99853
99854 return 0;
99855 }
99856 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
99857 {
99858 struct isight *isight = substream->private_data;
99859
99860 - ACCESS_ONCE(isight->pcm_active) = false;
99861 + ACCESS_ONCE_RW(isight->pcm_active) = false;
99862
99863 mutex_lock(&isight->mutex);
99864 isight_stop_streaming(isight);
99865 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
99866
99867 switch (cmd) {
99868 case SNDRV_PCM_TRIGGER_START:
99869 - ACCESS_ONCE(isight->pcm_running) = true;
99870 + ACCESS_ONCE_RW(isight->pcm_running) = true;
99871 break;
99872 case SNDRV_PCM_TRIGGER_STOP:
99873 - ACCESS_ONCE(isight->pcm_running) = false;
99874 + ACCESS_ONCE_RW(isight->pcm_running) = false;
99875 break;
99876 default:
99877 return -EINVAL;
99878 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
99879 index 505fc81..62e569e 100644
99880 --- a/sound/firewire/scs1x.c
99881 +++ b/sound/firewire/scs1x.c
99882 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
99883 {
99884 struct scs *scs = stream->rmidi->private_data;
99885
99886 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
99887 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
99888 if (up) {
99889 scs->output_idle = false;
99890 tasklet_schedule(&scs->tasklet);
99891 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
99892 {
99893 struct scs *scs = stream->rmidi->private_data;
99894
99895 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
99896 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
99897 }
99898
99899 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
99900 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
99901
99902 snd_card_disconnect(scs->card);
99903
99904 - ACCESS_ONCE(scs->output) = NULL;
99905 - ACCESS_ONCE(scs->input) = NULL;
99906 + ACCESS_ONCE_RW(scs->output) = NULL;
99907 + ACCESS_ONCE_RW(scs->input) = NULL;
99908
99909 wait_event(scs->idle_wait, scs->output_idle);
99910
99911 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
99912 index 048439a..3be9f6f 100644
99913 --- a/sound/oss/sb_audio.c
99914 +++ b/sound/oss/sb_audio.c
99915 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
99916 buf16 = (signed short *)(localbuf + localoffs);
99917 while (c)
99918 {
99919 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99920 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99921 if (copy_from_user(lbuf8,
99922 userbuf+useroffs + p,
99923 locallen))
99924 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
99925 index 7d8803a..559f8d0 100644
99926 --- a/sound/oss/swarm_cs4297a.c
99927 +++ b/sound/oss/swarm_cs4297a.c
99928 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
99929 {
99930 struct cs4297a_state *s;
99931 u32 pwr, id;
99932 - mm_segment_t fs;
99933 int rval;
99934 #ifndef CONFIG_BCM_CS4297A_CSWARM
99935 u64 cfg;
99936 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
99937 if (!rval) {
99938 char *sb1250_duart_present;
99939
99940 +#if 0
99941 + mm_segment_t fs;
99942 fs = get_fs();
99943 set_fs(KERNEL_DS);
99944 -#if 0
99945 val = SOUND_MASK_LINE;
99946 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
99947 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
99948 val = initvol[i].vol;
99949 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
99950 }
99951 + set_fs(fs);
99952 // cs4297a_write_ac97(s, 0x18, 0x0808);
99953 #else
99954 // cs4297a_write_ac97(s, 0x5e, 0x180);
99955 cs4297a_write_ac97(s, 0x02, 0x0808);
99956 cs4297a_write_ac97(s, 0x18, 0x0808);
99957 #endif
99958 - set_fs(fs);
99959
99960 list_add(&s->list, &cs4297a_devs);
99961
99962 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
99963 index 7c9e7dc..3b2bd95 100644
99964 --- a/sound/pci/hda/hda_codec.c
99965 +++ b/sound/pci/hda/hda_codec.c
99966 @@ -918,14 +918,10 @@ find_codec_preset(struct hda_codec *codec)
99967 mutex_unlock(&preset_mutex);
99968
99969 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
99970 - char name[32];
99971 if (!mod_requested)
99972 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
99973 - codec->vendor_id);
99974 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
99975 else
99976 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
99977 - (codec->vendor_id >> 16) & 0xffff);
99978 - request_module(name);
99979 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
99980 mod_requested++;
99981 goto again;
99982 }
99983 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
99984 index 4631a23..001ae57 100644
99985 --- a/sound/pci/ymfpci/ymfpci.h
99986 +++ b/sound/pci/ymfpci/ymfpci.h
99987 @@ -358,7 +358,7 @@ struct snd_ymfpci {
99988 spinlock_t reg_lock;
99989 spinlock_t voice_lock;
99990 wait_queue_head_t interrupt_sleep;
99991 - atomic_t interrupt_sleep_count;
99992 + atomic_unchecked_t interrupt_sleep_count;
99993 struct snd_info_entry *proc_entry;
99994 const struct firmware *dsp_microcode;
99995 const struct firmware *controller_microcode;
99996 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
99997 index d591c15..8cb8f94 100644
99998 --- a/sound/pci/ymfpci/ymfpci_main.c
99999 +++ b/sound/pci/ymfpci/ymfpci_main.c
100000 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
100001 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
100002 break;
100003 }
100004 - if (atomic_read(&chip->interrupt_sleep_count)) {
100005 - atomic_set(&chip->interrupt_sleep_count, 0);
100006 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100007 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100008 wake_up(&chip->interrupt_sleep);
100009 }
100010 __end:
100011 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
100012 continue;
100013 init_waitqueue_entry(&wait, current);
100014 add_wait_queue(&chip->interrupt_sleep, &wait);
100015 - atomic_inc(&chip->interrupt_sleep_count);
100016 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
100017 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
100018 remove_wait_queue(&chip->interrupt_sleep, &wait);
100019 }
100020 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
100021 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
100022 spin_unlock(&chip->reg_lock);
100023
100024 - if (atomic_read(&chip->interrupt_sleep_count)) {
100025 - atomic_set(&chip->interrupt_sleep_count, 0);
100026 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100027 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100028 wake_up(&chip->interrupt_sleep);
100029 }
100030 }
100031 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
100032 spin_lock_init(&chip->reg_lock);
100033 spin_lock_init(&chip->voice_lock);
100034 init_waitqueue_head(&chip->interrupt_sleep);
100035 - atomic_set(&chip->interrupt_sleep_count, 0);
100036 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100037 chip->card = card;
100038 chip->pci = pci;
100039 chip->irq = -1;
100040 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
100041 index 2f2d837..3e3f1f6 100644
100042 --- a/sound/soc/fsl/fsl_ssi.c
100043 +++ b/sound/soc/fsl/fsl_ssi.c
100044 @@ -656,7 +656,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
100045 {
100046 struct fsl_ssi_private *ssi_private;
100047 int ret = 0;
100048 - struct device_attribute *dev_attr = NULL;
100049 + device_attribute_no_const *dev_attr = NULL;
100050 struct device_node *np = pdev->dev.of_node;
100051 const char *p, *sprop;
100052 const uint32_t *iprop;
100053 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
100054 new file mode 100644
100055 index 0000000..50f2f2f
100056 --- /dev/null
100057 +++ b/tools/gcc/.gitignore
100058 @@ -0,0 +1 @@
100059 +size_overflow_hash.h
100060 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
100061 new file mode 100644
100062 index 0000000..144dbee
100063 --- /dev/null
100064 +++ b/tools/gcc/Makefile
100065 @@ -0,0 +1,45 @@
100066 +#CC := gcc
100067 +#PLUGIN_SOURCE_FILES := pax_plugin.c
100068 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
100069 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
100070 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
100071 +
100072 +ifeq ($(PLUGINCC),$(HOSTCC))
100073 +HOSTLIBS := hostlibs
100074 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
100075 +else
100076 +HOSTLIBS := hostcxxlibs
100077 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
100078 +endif
100079 +
100080 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
100081 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
100082 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
100083 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
100084 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
100085 +$(HOSTLIBS)-y += colorize_plugin.so
100086 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
100087 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
100088 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
100089 +
100090 +always := $($(HOSTLIBS)-y)
100091 +
100092 +constify_plugin-objs := constify_plugin.o
100093 +stackleak_plugin-objs := stackleak_plugin.o
100094 +kallocstat_plugin-objs := kallocstat_plugin.o
100095 +kernexec_plugin-objs := kernexec_plugin.o
100096 +checker_plugin-objs := checker_plugin.o
100097 +colorize_plugin-objs := colorize_plugin.o
100098 +size_overflow_plugin-objs := size_overflow_plugin.o
100099 +latent_entropy_plugin-objs := latent_entropy_plugin.o
100100 +structleak_plugin-objs := structleak_plugin.o
100101 +
100102 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
100103 +
100104 +quiet_cmd_build_size_overflow_hash = GENHASH $@
100105 + cmd_build_size_overflow_hash = \
100106 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
100107 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
100108 + $(call if_changed,build_size_overflow_hash)
100109 +
100110 +targets += size_overflow_hash.h
100111 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
100112 new file mode 100644
100113 index 0000000..22f03c0
100114 --- /dev/null
100115 +++ b/tools/gcc/checker_plugin.c
100116 @@ -0,0 +1,172 @@
100117 +/*
100118 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
100119 + * Licensed under the GPL v2
100120 + *
100121 + * Note: the choice of the license means that the compilation process is
100122 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100123 + * but for the kernel it doesn't matter since it doesn't link against
100124 + * any of the gcc libraries
100125 + *
100126 + * gcc plugin to implement various sparse (source code checker) features
100127 + *
100128 + * TODO:
100129 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
100130 + *
100131 + * BUGS:
100132 + * - none known
100133 + */
100134 +#include "gcc-plugin.h"
100135 +#include "config.h"
100136 +#include "system.h"
100137 +#include "coretypes.h"
100138 +#include "tree.h"
100139 +#include "tree-pass.h"
100140 +#include "flags.h"
100141 +#include "intl.h"
100142 +#include "toplev.h"
100143 +#include "plugin.h"
100144 +//#include "expr.h" where are you...
100145 +#include "diagnostic.h"
100146 +#include "plugin-version.h"
100147 +#include "tm.h"
100148 +#include "function.h"
100149 +#include "basic-block.h"
100150 +#include "gimple.h"
100151 +#include "rtl.h"
100152 +#include "emit-rtl.h"
100153 +#include "tree-flow.h"
100154 +#include "target.h"
100155 +
100156 +extern void c_register_addr_space (const char *str, addr_space_t as);
100157 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
100158 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
100159 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
100160 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
100161 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
100162 +
100163 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100164 +extern rtx emit_move_insn(rtx x, rtx y);
100165 +
100166 +int plugin_is_GPL_compatible;
100167 +
100168 +static struct plugin_info checker_plugin_info = {
100169 + .version = "201111150100",
100170 + .help = NULL,
100171 +};
100172 +
100173 +#define ADDR_SPACE_KERNEL 0
100174 +#define ADDR_SPACE_FORCE_KERNEL 1
100175 +#define ADDR_SPACE_USER 2
100176 +#define ADDR_SPACE_FORCE_USER 3
100177 +#define ADDR_SPACE_IOMEM 0
100178 +#define ADDR_SPACE_FORCE_IOMEM 0
100179 +#define ADDR_SPACE_PERCPU 0
100180 +#define ADDR_SPACE_FORCE_PERCPU 0
100181 +#define ADDR_SPACE_RCU 0
100182 +#define ADDR_SPACE_FORCE_RCU 0
100183 +
100184 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
100185 +{
100186 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
100187 +}
100188 +
100189 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
100190 +{
100191 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
100192 +}
100193 +
100194 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
100195 +{
100196 + return default_addr_space_valid_pointer_mode(mode, as);
100197 +}
100198 +
100199 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
100200 +{
100201 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
100202 +}
100203 +
100204 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
100205 +{
100206 + return default_addr_space_legitimize_address(x, oldx, mode, as);
100207 +}
100208 +
100209 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
100210 +{
100211 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
100212 + return true;
100213 +
100214 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
100215 + return true;
100216 +
100217 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
100218 + return true;
100219 +
100220 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
100221 + return true;
100222 +
100223 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
100224 + return true;
100225 +
100226 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
100227 + return true;
100228 +
100229 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
100230 + return true;
100231 +
100232 + return subset == superset;
100233 +}
100234 +
100235 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
100236 +{
100237 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
100238 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
100239 +
100240 + return op;
100241 +}
100242 +
100243 +static void register_checker_address_spaces(void *event_data, void *data)
100244 +{
100245 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
100246 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
100247 + c_register_addr_space("__user", ADDR_SPACE_USER);
100248 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
100249 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
100250 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
100251 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
100252 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
100253 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
100254 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
100255 +
100256 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
100257 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
100258 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
100259 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
100260 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
100261 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
100262 + targetm.addr_space.convert = checker_addr_space_convert;
100263 +}
100264 +
100265 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100266 +{
100267 + const char * const plugin_name = plugin_info->base_name;
100268 + const int argc = plugin_info->argc;
100269 + const struct plugin_argument * const argv = plugin_info->argv;
100270 + int i;
100271 +
100272 + if (!plugin_default_version_check(version, &gcc_version)) {
100273 + error(G_("incompatible gcc/plugin versions"));
100274 + return 1;
100275 + }
100276 +
100277 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
100278 +
100279 + for (i = 0; i < argc; ++i)
100280 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100281 +
100282 + if (TARGET_64BIT == 0)
100283 + return 0;
100284 +
100285 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
100286 +
100287 + return 0;
100288 +}
100289 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
100290 new file mode 100644
100291 index 0000000..414fe5e
100292 --- /dev/null
100293 +++ b/tools/gcc/colorize_plugin.c
100294 @@ -0,0 +1,151 @@
100295 +/*
100296 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
100297 + * Licensed under the GPL v2
100298 + *
100299 + * Note: the choice of the license means that the compilation process is
100300 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100301 + * but for the kernel it doesn't matter since it doesn't link against
100302 + * any of the gcc libraries
100303 + *
100304 + * gcc plugin to colorize diagnostic output
100305 + *
100306 + */
100307 +
100308 +#include "gcc-plugin.h"
100309 +#include "config.h"
100310 +#include "system.h"
100311 +#include "coretypes.h"
100312 +#include "tree.h"
100313 +#include "tree-pass.h"
100314 +#include "flags.h"
100315 +#include "intl.h"
100316 +#include "toplev.h"
100317 +#include "plugin.h"
100318 +#include "diagnostic.h"
100319 +#include "plugin-version.h"
100320 +#include "tm.h"
100321 +
100322 +int plugin_is_GPL_compatible;
100323 +
100324 +static struct plugin_info colorize_plugin_info = {
100325 + .version = "201302112000",
100326 + .help = NULL,
100327 +};
100328 +
100329 +#define GREEN "\033[32m\033[2m"
100330 +#define LIGHTGREEN "\033[32m\033[1m"
100331 +#define YELLOW "\033[33m\033[2m"
100332 +#define LIGHTYELLOW "\033[33m\033[1m"
100333 +#define RED "\033[31m\033[2m"
100334 +#define LIGHTRED "\033[31m\033[1m"
100335 +#define BLUE "\033[34m\033[2m"
100336 +#define LIGHTBLUE "\033[34m\033[1m"
100337 +#define BRIGHT "\033[m\033[1m"
100338 +#define NORMAL "\033[m"
100339 +
100340 +static diagnostic_starter_fn old_starter;
100341 +static diagnostic_finalizer_fn old_finalizer;
100342 +
100343 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100344 +{
100345 + const char *color;
100346 + char *newprefix;
100347 +
100348 + switch (diagnostic->kind) {
100349 + case DK_NOTE:
100350 + color = LIGHTBLUE;
100351 + break;
100352 +
100353 + case DK_PEDWARN:
100354 + case DK_WARNING:
100355 + color = LIGHTYELLOW;
100356 + break;
100357 +
100358 + case DK_ERROR:
100359 + case DK_FATAL:
100360 + case DK_ICE:
100361 + case DK_PERMERROR:
100362 + case DK_SORRY:
100363 + color = LIGHTRED;
100364 + break;
100365 +
100366 + default:
100367 + color = NORMAL;
100368 + }
100369 +
100370 + old_starter(context, diagnostic);
100371 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
100372 + return;
100373 + pp_destroy_prefix(context->printer);
100374 + pp_set_prefix(context->printer, newprefix);
100375 +}
100376 +
100377 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100378 +{
100379 + old_finalizer(context, diagnostic);
100380 +}
100381 +
100382 +static void colorize_arm(void)
100383 +{
100384 + old_starter = diagnostic_starter(global_dc);
100385 + old_finalizer = diagnostic_finalizer(global_dc);
100386 +
100387 + diagnostic_starter(global_dc) = start_colorize;
100388 + diagnostic_finalizer(global_dc) = finalize_colorize;
100389 +}
100390 +
100391 +static unsigned int execute_colorize_rearm(void)
100392 +{
100393 + if (diagnostic_starter(global_dc) == start_colorize)
100394 + return 0;
100395 +
100396 + colorize_arm();
100397 + return 0;
100398 +}
100399 +
100400 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
100401 + .pass = {
100402 + .type = SIMPLE_IPA_PASS,
100403 + .name = "colorize_rearm",
100404 +#if BUILDING_GCC_VERSION >= 4008
100405 + .optinfo_flags = OPTGROUP_NONE,
100406 +#endif
100407 + .gate = NULL,
100408 + .execute = execute_colorize_rearm,
100409 + .sub = NULL,
100410 + .next = NULL,
100411 + .static_pass_number = 0,
100412 + .tv_id = TV_NONE,
100413 + .properties_required = 0,
100414 + .properties_provided = 0,
100415 + .properties_destroyed = 0,
100416 + .todo_flags_start = 0,
100417 + .todo_flags_finish = 0
100418 + }
100419 +};
100420 +
100421 +static void colorize_start_unit(void *gcc_data, void *user_data)
100422 +{
100423 + colorize_arm();
100424 +}
100425 +
100426 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100427 +{
100428 + const char * const plugin_name = plugin_info->base_name;
100429 + struct register_pass_info colorize_rearm_pass_info = {
100430 + .pass = &pass_ipa_colorize_rearm.pass,
100431 + .reference_pass_name = "*free_lang_data",
100432 + .ref_pass_instance_number = 1,
100433 + .pos_op = PASS_POS_INSERT_AFTER
100434 + };
100435 +
100436 + if (!plugin_default_version_check(version, &gcc_version)) {
100437 + error(G_("incompatible gcc/plugin versions"));
100438 + return 1;
100439 + }
100440 +
100441 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
100442 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
100443 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
100444 + return 0;
100445 +}
100446 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
100447 new file mode 100644
100448 index 0000000..c17312d
100449 --- /dev/null
100450 +++ b/tools/gcc/constify_plugin.c
100451 @@ -0,0 +1,560 @@
100452 +/*
100453 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
100454 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
100455 + * Licensed under the GPL v2, or (at your option) v3
100456 + *
100457 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
100458 + *
100459 + * Homepage:
100460 + * http://www.grsecurity.net/~ephox/const_plugin/
100461 + *
100462 + * Usage:
100463 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
100464 + * $ gcc -fplugin=constify_plugin.so test.c -O2
100465 + */
100466 +
100467 +#include "gcc-plugin.h"
100468 +#include "config.h"
100469 +#include "system.h"
100470 +#include "coretypes.h"
100471 +#include "tree.h"
100472 +#include "tree-pass.h"
100473 +#include "flags.h"
100474 +#include "intl.h"
100475 +#include "toplev.h"
100476 +#include "plugin.h"
100477 +#include "diagnostic.h"
100478 +#include "plugin-version.h"
100479 +#include "tm.h"
100480 +#include "function.h"
100481 +#include "basic-block.h"
100482 +#include "gimple.h"
100483 +#include "rtl.h"
100484 +#include "emit-rtl.h"
100485 +#include "tree-flow.h"
100486 +#include "target.h"
100487 +#include "langhooks.h"
100488 +
100489 +// should come from c-tree.h if only it were installed for gcc 4.5...
100490 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
100491 +
100492 +// unused type flag in all versions 4.5-4.8
100493 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
100494 +
100495 +int plugin_is_GPL_compatible;
100496 +
100497 +static struct plugin_info const_plugin_info = {
100498 + .version = "201305231310",
100499 + .help = "no-constify\tturn off constification\n",
100500 +};
100501 +
100502 +typedef struct {
100503 + bool has_fptr_field;
100504 + bool has_writable_field;
100505 + bool has_do_const_field;
100506 + bool has_no_const_field;
100507 +} constify_info;
100508 +
100509 +static const_tree get_field_type(const_tree field)
100510 +{
100511 + return strip_array_types(TREE_TYPE(field));
100512 +}
100513 +
100514 +static bool is_fptr(const_tree field)
100515 +{
100516 + const_tree ptr = get_field_type(field);
100517 +
100518 + if (TREE_CODE(ptr) != POINTER_TYPE)
100519 + return false;
100520 +
100521 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
100522 +}
100523 +
100524 +/*
100525 + * determine whether the given structure type meets the requirements for automatic constification,
100526 + * including the constification attributes on nested structure types
100527 + */
100528 +static void constifiable(const_tree node, constify_info *cinfo)
100529 +{
100530 + const_tree field;
100531 +
100532 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100533 +
100534 + // e.g., pointer to structure fields while still constructing the structure type
100535 + if (TYPE_FIELDS(node) == NULL_TREE)
100536 + return;
100537 +
100538 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
100539 + const_tree type = get_field_type(field);
100540 + enum tree_code code = TREE_CODE(type);
100541 +
100542 + if (node == type)
100543 + continue;
100544 +
100545 + if (is_fptr(field))
100546 + cinfo->has_fptr_field = true;
100547 + else if (!TREE_READONLY(field))
100548 + cinfo->has_writable_field = true;
100549 +
100550 + if (code == RECORD_TYPE || code == UNION_TYPE) {
100551 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100552 + cinfo->has_do_const_field = true;
100553 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
100554 + cinfo->has_no_const_field = true;
100555 + else
100556 + constifiable(type, cinfo);
100557 + }
100558 + }
100559 +}
100560 +
100561 +static bool constified(const_tree node)
100562 +{
100563 + constify_info cinfo = {
100564 + .has_fptr_field = false,
100565 + .has_writable_field = false,
100566 + .has_do_const_field = false,
100567 + .has_no_const_field = false
100568 + };
100569 +
100570 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100571 +
100572 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
100573 + gcc_assert(!TYPE_READONLY(node));
100574 + return false;
100575 + }
100576 +
100577 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
100578 + gcc_assert(TYPE_READONLY(node));
100579 + return true;
100580 + }
100581 +
100582 + constifiable(node, &cinfo);
100583 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
100584 + return false;
100585 +
100586 + return TYPE_READONLY(node);
100587 +}
100588 +
100589 +static void deconstify_tree(tree node);
100590 +
100591 +static void deconstify_type(tree type)
100592 +{
100593 + tree field;
100594 +
100595 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
100596 +
100597 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
100598 + const_tree fieldtype = get_field_type(field);
100599 +
100600 + // special case handling of simple ptr-to-same-array-type members
100601 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
100602 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
100603 +
100604 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
100605 + continue;
100606 + if (TREE_TYPE(TREE_TYPE(field)) == type)
100607 + continue;
100608 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
100609 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
100610 + TREE_TYPE(TREE_TYPE(field)) = type;
100611 + }
100612 + continue;
100613 + }
100614 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
100615 + continue;
100616 + if (!constified(fieldtype))
100617 + continue;
100618 +
100619 + deconstify_tree(field);
100620 + TREE_READONLY(field) = 0;
100621 + }
100622 + TYPE_READONLY(type) = 0;
100623 + C_TYPE_FIELDS_READONLY(type) = 0;
100624 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100625 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
100626 +}
100627 +
100628 +static void deconstify_tree(tree node)
100629 +{
100630 + tree old_type, new_type, field;
100631 +
100632 + old_type = TREE_TYPE(node);
100633 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
100634 + node = TREE_TYPE(node) = copy_node(old_type);
100635 + old_type = TREE_TYPE(old_type);
100636 + }
100637 +
100638 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
100639 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
100640 +
100641 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
100642 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
100643 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
100644 + DECL_FIELD_CONTEXT(field) = new_type;
100645 +
100646 + deconstify_type(new_type);
100647 +
100648 + TREE_TYPE(node) = new_type;
100649 +}
100650 +
100651 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100652 +{
100653 + tree type;
100654 + constify_info cinfo = {
100655 + .has_fptr_field = false,
100656 + .has_writable_field = false,
100657 + .has_do_const_field = false,
100658 + .has_no_const_field = false
100659 + };
100660 +
100661 + *no_add_attrs = true;
100662 + if (TREE_CODE(*node) == FUNCTION_DECL) {
100663 + error("%qE attribute does not apply to functions", name);
100664 + return NULL_TREE;
100665 + }
100666 +
100667 + if (TREE_CODE(*node) == PARM_DECL) {
100668 + error("%qE attribute does not apply to function parameters", name);
100669 + return NULL_TREE;
100670 + }
100671 +
100672 + if (TREE_CODE(*node) == VAR_DECL) {
100673 + error("%qE attribute does not apply to variables", name);
100674 + return NULL_TREE;
100675 + }
100676 +
100677 + if (TYPE_P(*node)) {
100678 + *no_add_attrs = false;
100679 + type = *node;
100680 + } else {
100681 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100682 + type = TREE_TYPE(*node);
100683 + }
100684 +
100685 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100686 + error("%qE attribute applies to struct and union types only", name);
100687 + return NULL_TREE;
100688 + }
100689 +
100690 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100691 + error("%qE attribute is already applied to the type", name);
100692 + return NULL_TREE;
100693 + }
100694 +
100695 + if (TYPE_P(*node)) {
100696 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100697 + error("%qE attribute is incompatible with 'do_const'", name);
100698 + return NULL_TREE;
100699 + }
100700 +
100701 + constifiable(type, &cinfo);
100702 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100703 + deconstify_tree(*node);
100704 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100705 + return NULL_TREE;
100706 + }
100707 +
100708 + error("%qE attribute used on type that is not constified", name);
100709 + return NULL_TREE;
100710 +}
100711 +
100712 +static void constify_type(tree type)
100713 +{
100714 + TYPE_READONLY(type) = 1;
100715 + C_TYPE_FIELDS_READONLY(type) = 1;
100716 + TYPE_CONSTIFY_VISITED(type) = 1;
100717 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100718 +}
100719 +
100720 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100721 +{
100722 + *no_add_attrs = true;
100723 + if (!TYPE_P(*node)) {
100724 + error("%qE attribute applies to types only", name);
100725 + return NULL_TREE;
100726 + }
100727 +
100728 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
100729 + error("%qE attribute applies to struct and union types only", name);
100730 + return NULL_TREE;
100731 + }
100732 +
100733 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
100734 + error("%qE attribute is already applied to the type", name);
100735 + return NULL_TREE;
100736 + }
100737 +
100738 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
100739 + error("%qE attribute is incompatible with 'no_const'", name);
100740 + return NULL_TREE;
100741 + }
100742 +
100743 + *no_add_attrs = false;
100744 + return NULL_TREE;
100745 +}
100746 +
100747 +static struct attribute_spec no_const_attr = {
100748 + .name = "no_const",
100749 + .min_length = 0,
100750 + .max_length = 0,
100751 + .decl_required = false,
100752 + .type_required = false,
100753 + .function_type_required = false,
100754 + .handler = handle_no_const_attribute,
100755 +#if BUILDING_GCC_VERSION >= 4007
100756 + .affects_type_identity = true
100757 +#endif
100758 +};
100759 +
100760 +static struct attribute_spec do_const_attr = {
100761 + .name = "do_const",
100762 + .min_length = 0,
100763 + .max_length = 0,
100764 + .decl_required = false,
100765 + .type_required = false,
100766 + .function_type_required = false,
100767 + .handler = handle_do_const_attribute,
100768 +#if BUILDING_GCC_VERSION >= 4007
100769 + .affects_type_identity = true
100770 +#endif
100771 +};
100772 +
100773 +static void register_attributes(void *event_data, void *data)
100774 +{
100775 + register_attribute(&no_const_attr);
100776 + register_attribute(&do_const_attr);
100777 +}
100778 +
100779 +static void finish_type(void *event_data, void *data)
100780 +{
100781 + tree type = (tree)event_data;
100782 + constify_info cinfo = {
100783 + .has_fptr_field = false,
100784 + .has_writable_field = false,
100785 + .has_do_const_field = false,
100786 + .has_no_const_field = false
100787 + };
100788 +
100789 + if (type == NULL_TREE || type == error_mark_node)
100790 + return;
100791 +
100792 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
100793 + return;
100794 +
100795 + constifiable(type, &cinfo);
100796 +
100797 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
100798 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100799 + return;
100800 + if (cinfo.has_writable_field)
100801 + return;
100802 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
100803 + return;
100804 + }
100805 +
100806 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
100807 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
100808 + deconstify_type(type);
100809 + TYPE_CONSTIFY_VISITED(type) = 1;
100810 + } else
100811 + error("'no_const' attribute used on type that is not constified");
100812 + return;
100813 + }
100814 +
100815 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100816 + constify_type(type);
100817 + return;
100818 + }
100819 +
100820 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
100821 + constify_type(type);
100822 + return;
100823 + }
100824 +
100825 + deconstify_type(type);
100826 + TYPE_CONSTIFY_VISITED(type) = 1;
100827 +}
100828 +
100829 +static void check_global_variables(void)
100830 +{
100831 + struct varpool_node *node;
100832 +
100833 +#if BUILDING_GCC_VERSION <= 4007
100834 + for (node = varpool_nodes; node; node = node->next) {
100835 + tree var = node->decl;
100836 +#else
100837 + FOR_EACH_VARIABLE(node) {
100838 + tree var = node->symbol.decl;
100839 +#endif
100840 + tree type = TREE_TYPE(var);
100841 +
100842 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100843 + continue;
100844 +
100845 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100846 + continue;
100847 +
100848 + if (!TYPE_CONSTIFY_VISITED(type))
100849 + continue;
100850 +
100851 + if (DECL_EXTERNAL(var))
100852 + continue;
100853 +
100854 + if (DECL_INITIAL(var))
100855 + continue;
100856 +
100857 + // this works around a gcc bug/feature where uninitialized globals
100858 + // are moved into the .bss section regardless of any constification
100859 + DECL_INITIAL(var) = build_constructor(type, NULL);
100860 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
100861 + }
100862 +}
100863 +
100864 +static unsigned int check_local_variables(void)
100865 +{
100866 + unsigned int ret = 0;
100867 + tree var;
100868 +
100869 +#if BUILDING_GCC_VERSION == 4005
100870 + tree vars;
100871 +#else
100872 + unsigned int i;
100873 +#endif
100874 +
100875 +#if BUILDING_GCC_VERSION == 4005
100876 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
100877 + var = TREE_VALUE(vars);
100878 +#else
100879 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
100880 +#endif
100881 + tree type = TREE_TYPE(var);
100882 +
100883 + gcc_assert(DECL_P(var));
100884 + if (is_global_var(var))
100885 + continue;
100886 +
100887 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100888 + continue;
100889 +
100890 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100891 + continue;
100892 +
100893 + if (!TYPE_CONSTIFY_VISITED(type))
100894 + continue;
100895 +
100896 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
100897 + ret = 1;
100898 + }
100899 + return ret;
100900 +}
100901 +
100902 +static unsigned int check_variables(void)
100903 +{
100904 + check_global_variables();
100905 + return check_local_variables();
100906 +}
100907 +
100908 + unsigned int ret = 0;
100909 +static struct gimple_opt_pass pass_local_variable = {
100910 + {
100911 + .type = GIMPLE_PASS,
100912 + .name = "check_variables",
100913 +#if BUILDING_GCC_VERSION >= 4008
100914 + .optinfo_flags = OPTGROUP_NONE,
100915 +#endif
100916 + .gate = NULL,
100917 + .execute = check_variables,
100918 + .sub = NULL,
100919 + .next = NULL,
100920 + .static_pass_number = 0,
100921 + .tv_id = TV_NONE,
100922 + .properties_required = 0,
100923 + .properties_provided = 0,
100924 + .properties_destroyed = 0,
100925 + .todo_flags_start = 0,
100926 + .todo_flags_finish = 0
100927 + }
100928 +};
100929 +
100930 +static struct {
100931 + const char *name;
100932 + const char *asm_op;
100933 +} sections[] = {
100934 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
100935 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
100936 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
100937 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
100938 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
100939 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
100940 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
100941 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
100942 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
100943 +};
100944 +
100945 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
100946 +
100947 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
100948 +{
100949 + size_t i;
100950 +
100951 + for (i = 0; i < ARRAY_SIZE(sections); i++)
100952 + if (!strcmp(sections[i].name, name))
100953 + return 0;
100954 + return old_section_type_flags(decl, name, reloc);
100955 +}
100956 +
100957 +static void constify_start_unit(void *gcc_data, void *user_data)
100958 +{
100959 +// size_t i;
100960 +
100961 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
100962 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
100963 +// sections[i].section = get_section(sections[i].name, 0, NULL);
100964 +
100965 + old_section_type_flags = targetm.section_type_flags;
100966 + targetm.section_type_flags = constify_section_type_flags;
100967 +}
100968 +
100969 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100970 +{
100971 + const char * const plugin_name = plugin_info->base_name;
100972 + const int argc = plugin_info->argc;
100973 + const struct plugin_argument * const argv = plugin_info->argv;
100974 + int i;
100975 + bool constify = true;
100976 +
100977 + struct register_pass_info local_variable_pass_info = {
100978 + .pass = &pass_local_variable.pass,
100979 + .reference_pass_name = "ssa",
100980 + .ref_pass_instance_number = 1,
100981 + .pos_op = PASS_POS_INSERT_BEFORE
100982 + };
100983 +
100984 + if (!plugin_default_version_check(version, &gcc_version)) {
100985 + error(G_("incompatible gcc/plugin versions"));
100986 + return 1;
100987 + }
100988 +
100989 + for (i = 0; i < argc; ++i) {
100990 + if (!(strcmp(argv[i].key, "no-constify"))) {
100991 + constify = false;
100992 + continue;
100993 + }
100994 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100995 + }
100996 +
100997 + if (strcmp(lang_hooks.name, "GNU C")) {
100998 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
100999 + constify = false;
101000 + }
101001 +
101002 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
101003 + if (constify) {
101004 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
101005 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
101006 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
101007 + }
101008 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101009 +
101010 + return 0;
101011 +}
101012 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
101013 new file mode 100644
101014 index 0000000..e518932
101015 --- /dev/null
101016 +++ b/tools/gcc/generate_size_overflow_hash.sh
101017 @@ -0,0 +1,94 @@
101018 +#!/bin/bash
101019 +
101020 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
101021 +
101022 +header1="size_overflow_hash.h"
101023 +database="size_overflow_hash.data"
101024 +n=65536
101025 +
101026 +usage() {
101027 +cat <<EOF
101028 +usage: $0 options
101029 +OPTIONS:
101030 + -h|--help help
101031 + -o header file
101032 + -d database file
101033 + -n hash array size
101034 +EOF
101035 + return 0
101036 +}
101037 +
101038 +while true
101039 +do
101040 + case "$1" in
101041 + -h|--help) usage && exit 0;;
101042 + -n) n=$2; shift 2;;
101043 + -o) header1="$2"; shift 2;;
101044 + -d) database="$2"; shift 2;;
101045 + --) shift 1; break ;;
101046 + *) break ;;
101047 + esac
101048 +done
101049 +
101050 +create_defines() {
101051 + for i in `seq 0 31`
101052 + do
101053 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
101054 + done
101055 + echo >> "$header1"
101056 +}
101057 +
101058 +create_structs() {
101059 + rm -f "$header1"
101060 +
101061 + create_defines
101062 +
101063 + cat "$database" | while read data
101064 + do
101065 + data_array=($data)
101066 + struct_hash_name="${data_array[0]}"
101067 + funcn="${data_array[1]}"
101068 + params="${data_array[2]}"
101069 + next="${data_array[4]}"
101070 +
101071 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
101072 +
101073 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
101074 + echo -en "\t.param\t= " >> "$header1"
101075 + line=
101076 + for param_num in ${params//-/ };
101077 + do
101078 + line="${line}PARAM"$param_num"|"
101079 + done
101080 +
101081 + echo -e "${line%?},\n};\n" >> "$header1"
101082 + done
101083 +}
101084 +
101085 +create_headers() {
101086 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
101087 +}
101088 +
101089 +create_array_elements() {
101090 + index=0
101091 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
101092 + do
101093 + data_array=($data)
101094 + i="${data_array[3]}"
101095 + hash="${data_array[0]}"
101096 + while [[ $index -lt $i ]]
101097 + do
101098 + echo -e "\t["$index"]\t= NULL," >> "$header1"
101099 + index=$(($index + 1))
101100 + done
101101 + index=$(($index + 1))
101102 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
101103 + done
101104 + echo '};' >> $header1
101105 +}
101106 +
101107 +create_structs
101108 +create_headers
101109 +create_array_elements
101110 +
101111 +exit 0
101112 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
101113 new file mode 100644
101114 index 0000000..568b360
101115 --- /dev/null
101116 +++ b/tools/gcc/kallocstat_plugin.c
101117 @@ -0,0 +1,170 @@
101118 +/*
101119 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101120 + * Licensed under the GPL v2
101121 + *
101122 + * Note: the choice of the license means that the compilation process is
101123 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101124 + * but for the kernel it doesn't matter since it doesn't link against
101125 + * any of the gcc libraries
101126 + *
101127 + * gcc plugin to find the distribution of k*alloc sizes
101128 + *
101129 + * TODO:
101130 + *
101131 + * BUGS:
101132 + * - none known
101133 + */
101134 +#include "gcc-plugin.h"
101135 +#include "config.h"
101136 +#include "system.h"
101137 +#include "coretypes.h"
101138 +#include "tree.h"
101139 +#include "tree-pass.h"
101140 +#include "flags.h"
101141 +#include "intl.h"
101142 +#include "toplev.h"
101143 +#include "plugin.h"
101144 +//#include "expr.h" where are you...
101145 +#include "diagnostic.h"
101146 +#include "plugin-version.h"
101147 +#include "tm.h"
101148 +#include "function.h"
101149 +#include "basic-block.h"
101150 +#include "gimple.h"
101151 +#include "rtl.h"
101152 +#include "emit-rtl.h"
101153 +
101154 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101155 +
101156 +int plugin_is_GPL_compatible;
101157 +
101158 +static const char * const kalloc_functions[] = {
101159 + "__kmalloc",
101160 + "kmalloc",
101161 + "kmalloc_large",
101162 + "kmalloc_node",
101163 + "kmalloc_order",
101164 + "kmalloc_order_trace",
101165 + "kmalloc_slab",
101166 + "kzalloc",
101167 + "kzalloc_node",
101168 +};
101169 +
101170 +static struct plugin_info kallocstat_plugin_info = {
101171 + .version = "201302112000",
101172 +};
101173 +
101174 +static unsigned int execute_kallocstat(void);
101175 +
101176 +static struct gimple_opt_pass kallocstat_pass = {
101177 + .pass = {
101178 + .type = GIMPLE_PASS,
101179 + .name = "kallocstat",
101180 +#if BUILDING_GCC_VERSION >= 4008
101181 + .optinfo_flags = OPTGROUP_NONE,
101182 +#endif
101183 + .gate = NULL,
101184 + .execute = execute_kallocstat,
101185 + .sub = NULL,
101186 + .next = NULL,
101187 + .static_pass_number = 0,
101188 + .tv_id = TV_NONE,
101189 + .properties_required = 0,
101190 + .properties_provided = 0,
101191 + .properties_destroyed = 0,
101192 + .todo_flags_start = 0,
101193 + .todo_flags_finish = 0
101194 + }
101195 +};
101196 +
101197 +static bool is_kalloc(const char *fnname)
101198 +{
101199 + size_t i;
101200 +
101201 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
101202 + if (!strcmp(fnname, kalloc_functions[i]))
101203 + return true;
101204 + return false;
101205 +}
101206 +
101207 +static unsigned int execute_kallocstat(void)
101208 +{
101209 + basic_block bb;
101210 +
101211 + // 1. loop through BBs and GIMPLE statements
101212 + FOR_EACH_BB(bb) {
101213 + gimple_stmt_iterator gsi;
101214 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101215 + // gimple match:
101216 + tree fndecl, size;
101217 + gimple call_stmt;
101218 + const char *fnname;
101219 +
101220 + // is it a call
101221 + call_stmt = gsi_stmt(gsi);
101222 + if (!is_gimple_call(call_stmt))
101223 + continue;
101224 + fndecl = gimple_call_fndecl(call_stmt);
101225 + if (fndecl == NULL_TREE)
101226 + continue;
101227 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
101228 + continue;
101229 +
101230 + // is it a call to k*alloc
101231 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
101232 + if (!is_kalloc(fnname))
101233 + continue;
101234 +
101235 + // is the size arg the result of a simple const assignment
101236 + size = gimple_call_arg(call_stmt, 0);
101237 + while (true) {
101238 + gimple def_stmt;
101239 + expanded_location xloc;
101240 + size_t size_val;
101241 +
101242 + if (TREE_CODE(size) != SSA_NAME)
101243 + break;
101244 + def_stmt = SSA_NAME_DEF_STMT(size);
101245 + if (!def_stmt || !is_gimple_assign(def_stmt))
101246 + break;
101247 + if (gimple_num_ops(def_stmt) != 2)
101248 + break;
101249 + size = gimple_assign_rhs1(def_stmt);
101250 + if (!TREE_CONSTANT(size))
101251 + continue;
101252 + xloc = expand_location(gimple_location(def_stmt));
101253 + if (!xloc.file)
101254 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101255 + size_val = TREE_INT_CST_LOW(size);
101256 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
101257 + break;
101258 + }
101259 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101260 +//debug_tree(gimple_call_fn(call_stmt));
101261 +//print_node(stderr, "pax", fndecl, 4);
101262 + }
101263 + }
101264 +
101265 + return 0;
101266 +}
101267 +
101268 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101269 +{
101270 + const char * const plugin_name = plugin_info->base_name;
101271 + struct register_pass_info kallocstat_pass_info = {
101272 + .pass = &kallocstat_pass.pass,
101273 + .reference_pass_name = "ssa",
101274 + .ref_pass_instance_number = 1,
101275 + .pos_op = PASS_POS_INSERT_AFTER
101276 + };
101277 +
101278 + if (!plugin_default_version_check(version, &gcc_version)) {
101279 + error(G_("incompatible gcc/plugin versions"));
101280 + return 1;
101281 + }
101282 +
101283 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
101284 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
101285 +
101286 + return 0;
101287 +}
101288 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
101289 new file mode 100644
101290 index 0000000..698da67
101291 --- /dev/null
101292 +++ b/tools/gcc/kernexec_plugin.c
101293 @@ -0,0 +1,471 @@
101294 +/*
101295 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101296 + * Licensed under the GPL v2
101297 + *
101298 + * Note: the choice of the license means that the compilation process is
101299 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101300 + * but for the kernel it doesn't matter since it doesn't link against
101301 + * any of the gcc libraries
101302 + *
101303 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
101304 + *
101305 + * TODO:
101306 + *
101307 + * BUGS:
101308 + * - none known
101309 + */
101310 +#include "gcc-plugin.h"
101311 +#include "config.h"
101312 +#include "system.h"
101313 +#include "coretypes.h"
101314 +#include "tree.h"
101315 +#include "tree-pass.h"
101316 +#include "flags.h"
101317 +#include "intl.h"
101318 +#include "toplev.h"
101319 +#include "plugin.h"
101320 +//#include "expr.h" where are you...
101321 +#include "diagnostic.h"
101322 +#include "plugin-version.h"
101323 +#include "tm.h"
101324 +#include "function.h"
101325 +#include "basic-block.h"
101326 +#include "gimple.h"
101327 +#include "rtl.h"
101328 +#include "emit-rtl.h"
101329 +#include "tree-flow.h"
101330 +
101331 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101332 +extern rtx emit_move_insn(rtx x, rtx y);
101333 +
101334 +#if BUILDING_GCC_VERSION <= 4006
101335 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
101336 +#endif
101337 +
101338 +#if BUILDING_GCC_VERSION >= 4008
101339 +#define TODO_dump_func 0
101340 +#endif
101341 +
101342 +int plugin_is_GPL_compatible;
101343 +
101344 +static struct plugin_info kernexec_plugin_info = {
101345 + .version = "201308230150",
101346 + .help = "method=[bts|or]\tinstrumentation method\n"
101347 +};
101348 +
101349 +static unsigned int execute_kernexec_reload(void);
101350 +static unsigned int execute_kernexec_fptr(void);
101351 +static unsigned int execute_kernexec_retaddr(void);
101352 +static bool kernexec_cmodel_check(void);
101353 +
101354 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
101355 +static void (*kernexec_instrument_retaddr)(rtx);
101356 +
101357 +static struct gimple_opt_pass kernexec_reload_pass = {
101358 + .pass = {
101359 + .type = GIMPLE_PASS,
101360 + .name = "kernexec_reload",
101361 +#if BUILDING_GCC_VERSION >= 4008
101362 + .optinfo_flags = OPTGROUP_NONE,
101363 +#endif
101364 + .gate = kernexec_cmodel_check,
101365 + .execute = execute_kernexec_reload,
101366 + .sub = NULL,
101367 + .next = NULL,
101368 + .static_pass_number = 0,
101369 + .tv_id = TV_NONE,
101370 + .properties_required = 0,
101371 + .properties_provided = 0,
101372 + .properties_destroyed = 0,
101373 + .todo_flags_start = 0,
101374 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101375 + }
101376 +};
101377 +
101378 +static struct gimple_opt_pass kernexec_fptr_pass = {
101379 + .pass = {
101380 + .type = GIMPLE_PASS,
101381 + .name = "kernexec_fptr",
101382 +#if BUILDING_GCC_VERSION >= 4008
101383 + .optinfo_flags = OPTGROUP_NONE,
101384 +#endif
101385 + .gate = kernexec_cmodel_check,
101386 + .execute = execute_kernexec_fptr,
101387 + .sub = NULL,
101388 + .next = NULL,
101389 + .static_pass_number = 0,
101390 + .tv_id = TV_NONE,
101391 + .properties_required = 0,
101392 + .properties_provided = 0,
101393 + .properties_destroyed = 0,
101394 + .todo_flags_start = 0,
101395 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101396 + }
101397 +};
101398 +
101399 +static struct rtl_opt_pass kernexec_retaddr_pass = {
101400 + .pass = {
101401 + .type = RTL_PASS,
101402 + .name = "kernexec_retaddr",
101403 +#if BUILDING_GCC_VERSION >= 4008
101404 + .optinfo_flags = OPTGROUP_NONE,
101405 +#endif
101406 + .gate = kernexec_cmodel_check,
101407 + .execute = execute_kernexec_retaddr,
101408 + .sub = NULL,
101409 + .next = NULL,
101410 + .static_pass_number = 0,
101411 + .tv_id = TV_NONE,
101412 + .properties_required = 0,
101413 + .properties_provided = 0,
101414 + .properties_destroyed = 0,
101415 + .todo_flags_start = 0,
101416 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
101417 + }
101418 +};
101419 +
101420 +static bool kernexec_cmodel_check(void)
101421 +{
101422 + tree section;
101423 +
101424 + if (ix86_cmodel != CM_KERNEL)
101425 + return false;
101426 +
101427 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
101428 + if (!section || !TREE_VALUE(section))
101429 + return true;
101430 +
101431 + section = TREE_VALUE(TREE_VALUE(section));
101432 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
101433 + return true;
101434 +
101435 + return false;
101436 +}
101437 +
101438 +/*
101439 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
101440 + */
101441 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
101442 +{
101443 + gimple asm_movabs_stmt;
101444 +
101445 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
101446 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
101447 + gimple_asm_set_volatile(asm_movabs_stmt, true);
101448 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
101449 + update_stmt(asm_movabs_stmt);
101450 +}
101451 +
101452 +/*
101453 + * find all asm() stmts that clobber r10 and add a reload of r10
101454 + */
101455 +static unsigned int execute_kernexec_reload(void)
101456 +{
101457 + basic_block bb;
101458 +
101459 + // 1. loop through BBs and GIMPLE statements
101460 + FOR_EACH_BB(bb) {
101461 + gimple_stmt_iterator gsi;
101462 +
101463 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101464 + // gimple match: __asm__ ("" : : : "r10");
101465 + gimple asm_stmt;
101466 + size_t nclobbers;
101467 +
101468 + // is it an asm ...
101469 + asm_stmt = gsi_stmt(gsi);
101470 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
101471 + continue;
101472 +
101473 + // ... clobbering r10
101474 + nclobbers = gimple_asm_nclobbers(asm_stmt);
101475 + while (nclobbers--) {
101476 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
101477 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
101478 + continue;
101479 + kernexec_reload_fptr_mask(&gsi);
101480 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
101481 + break;
101482 + }
101483 + }
101484 + }
101485 +
101486 + return 0;
101487 +}
101488 +
101489 +/*
101490 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
101491 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
101492 + */
101493 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
101494 +{
101495 + gimple assign_intptr, assign_new_fptr, call_stmt;
101496 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
101497 +
101498 + call_stmt = gsi_stmt(*gsi);
101499 + old_fptr = gimple_call_fn(call_stmt);
101500 +
101501 + // create temporary unsigned long variable used for bitops and cast fptr to it
101502 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
101503 +#if BUILDING_GCC_VERSION <= 4007
101504 + add_referenced_var(intptr);
101505 +#endif
101506 + intptr = make_ssa_name(intptr, NULL);
101507 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
101508 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101509 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101510 + update_stmt(assign_intptr);
101511 +
101512 + // apply logical or to temporary unsigned long and bitmask
101513 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
101514 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
101515 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
101516 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
101517 + assign_intptr = gimple_build_assign(intptr, orptr);
101518 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101519 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101520 + update_stmt(assign_intptr);
101521 +
101522 + // cast temporary unsigned long back to a temporary fptr variable
101523 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
101524 +#if BUILDING_GCC_VERSION <= 4007
101525 + add_referenced_var(new_fptr);
101526 +#endif
101527 + new_fptr = make_ssa_name(new_fptr, NULL);
101528 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
101529 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
101530 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
101531 + update_stmt(assign_new_fptr);
101532 +
101533 + // replace call stmt fn with the new fptr
101534 + gimple_call_set_fn(call_stmt, new_fptr);
101535 + update_stmt(call_stmt);
101536 +}
101537 +
101538 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
101539 +{
101540 + gimple asm_or_stmt, call_stmt;
101541 + tree old_fptr, new_fptr, input, output;
101542 +#if BUILDING_GCC_VERSION <= 4007
101543 + VEC(tree, gc) *inputs = NULL;
101544 + VEC(tree, gc) *outputs = NULL;
101545 +#else
101546 + vec<tree, va_gc> *inputs = NULL;
101547 + vec<tree, va_gc> *outputs = NULL;
101548 +#endif
101549 +
101550 + call_stmt = gsi_stmt(*gsi);
101551 + old_fptr = gimple_call_fn(call_stmt);
101552 +
101553 + // create temporary fptr variable
101554 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
101555 +#if BUILDING_GCC_VERSION <= 4007
101556 + add_referenced_var(new_fptr);
101557 +#endif
101558 + new_fptr = make_ssa_name(new_fptr, NULL);
101559 +
101560 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
101561 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
101562 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
101563 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
101564 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
101565 +#if BUILDING_GCC_VERSION <= 4007
101566 + VEC_safe_push(tree, gc, inputs, input);
101567 + VEC_safe_push(tree, gc, outputs, output);
101568 +#else
101569 + vec_safe_push(inputs, input);
101570 + vec_safe_push(outputs, output);
101571 +#endif
101572 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
101573 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
101574 + gimple_asm_set_volatile(asm_or_stmt, true);
101575 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
101576 + update_stmt(asm_or_stmt);
101577 +
101578 + // replace call stmt fn with the new fptr
101579 + gimple_call_set_fn(call_stmt, new_fptr);
101580 + update_stmt(call_stmt);
101581 +}
101582 +
101583 +/*
101584 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
101585 + */
101586 +static unsigned int execute_kernexec_fptr(void)
101587 +{
101588 + basic_block bb;
101589 +
101590 + // 1. loop through BBs and GIMPLE statements
101591 + FOR_EACH_BB(bb) {
101592 + gimple_stmt_iterator gsi;
101593 +
101594 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101595 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
101596 + tree fn;
101597 + gimple call_stmt;
101598 +
101599 + // is it a call ...
101600 + call_stmt = gsi_stmt(gsi);
101601 + if (!is_gimple_call(call_stmt))
101602 + continue;
101603 + fn = gimple_call_fn(call_stmt);
101604 + if (TREE_CODE(fn) == ADDR_EXPR)
101605 + continue;
101606 + if (TREE_CODE(fn) != SSA_NAME)
101607 + gcc_unreachable();
101608 +
101609 + // ... through a function pointer
101610 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
101611 + fn = SSA_NAME_VAR(fn);
101612 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
101613 + debug_tree(fn);
101614 + gcc_unreachable();
101615 + }
101616 + }
101617 + fn = TREE_TYPE(fn);
101618 + if (TREE_CODE(fn) != POINTER_TYPE)
101619 + continue;
101620 + fn = TREE_TYPE(fn);
101621 + if (TREE_CODE(fn) != FUNCTION_TYPE)
101622 + continue;
101623 +
101624 + kernexec_instrument_fptr(&gsi);
101625 +
101626 +//debug_tree(gimple_call_fn(call_stmt));
101627 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101628 + }
101629 + }
101630 +
101631 + return 0;
101632 +}
101633 +
101634 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
101635 +static void kernexec_instrument_retaddr_bts(rtx insn)
101636 +{
101637 + rtx btsq;
101638 + rtvec argvec, constraintvec, labelvec;
101639 + int line;
101640 +
101641 + // create asm volatile("btsq $63,(%%rsp)":::)
101642 + argvec = rtvec_alloc(0);
101643 + constraintvec = rtvec_alloc(0);
101644 + labelvec = rtvec_alloc(0);
101645 + line = expand_location(RTL_LOCATION(insn)).line;
101646 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101647 + MEM_VOLATILE_P(btsq) = 1;
101648 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
101649 + emit_insn_before(btsq, insn);
101650 +}
101651 +
101652 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
101653 +static void kernexec_instrument_retaddr_or(rtx insn)
101654 +{
101655 + rtx orq;
101656 + rtvec argvec, constraintvec, labelvec;
101657 + int line;
101658 +
101659 + // create asm volatile("orq %%r10,(%%rsp)":::)
101660 + argvec = rtvec_alloc(0);
101661 + constraintvec = rtvec_alloc(0);
101662 + labelvec = rtvec_alloc(0);
101663 + line = expand_location(RTL_LOCATION(insn)).line;
101664 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101665 + MEM_VOLATILE_P(orq) = 1;
101666 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
101667 + emit_insn_before(orq, insn);
101668 +}
101669 +
101670 +/*
101671 + * find all asm level function returns and forcibly set the highest bit of the return address
101672 + */
101673 +static unsigned int execute_kernexec_retaddr(void)
101674 +{
101675 + rtx insn;
101676 +
101677 + // 1. find function returns
101678 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101679 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101680 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101681 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101682 + rtx body;
101683 +
101684 + // is it a retn
101685 + if (!JUMP_P(insn))
101686 + continue;
101687 + body = PATTERN(insn);
101688 + if (GET_CODE(body) == PARALLEL)
101689 + body = XVECEXP(body, 0, 0);
101690 + if (!ANY_RETURN_P(body))
101691 + continue;
101692 + kernexec_instrument_retaddr(insn);
101693 + }
101694 +
101695 +// print_simple_rtl(stderr, get_insns());
101696 +// print_rtl(stderr, get_insns());
101697 +
101698 + return 0;
101699 +}
101700 +
101701 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101702 +{
101703 + const char * const plugin_name = plugin_info->base_name;
101704 + const int argc = plugin_info->argc;
101705 + const struct plugin_argument * const argv = plugin_info->argv;
101706 + int i;
101707 + struct register_pass_info kernexec_reload_pass_info = {
101708 + .pass = &kernexec_reload_pass.pass,
101709 + .reference_pass_name = "ssa",
101710 + .ref_pass_instance_number = 1,
101711 + .pos_op = PASS_POS_INSERT_AFTER
101712 + };
101713 + struct register_pass_info kernexec_fptr_pass_info = {
101714 + .pass = &kernexec_fptr_pass.pass,
101715 + .reference_pass_name = "ssa",
101716 + .ref_pass_instance_number = 1,
101717 + .pos_op = PASS_POS_INSERT_AFTER
101718 + };
101719 + struct register_pass_info kernexec_retaddr_pass_info = {
101720 + .pass = &kernexec_retaddr_pass.pass,
101721 + .reference_pass_name = "pro_and_epilogue",
101722 + .ref_pass_instance_number = 1,
101723 + .pos_op = PASS_POS_INSERT_AFTER
101724 + };
101725 +
101726 + if (!plugin_default_version_check(version, &gcc_version)) {
101727 + error(G_("incompatible gcc/plugin versions"));
101728 + return 1;
101729 + }
101730 +
101731 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
101732 +
101733 + if (TARGET_64BIT == 0)
101734 + return 0;
101735 +
101736 + for (i = 0; i < argc; ++i) {
101737 + if (!strcmp(argv[i].key, "method")) {
101738 + if (!argv[i].value) {
101739 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101740 + continue;
101741 + }
101742 + if (!strcmp(argv[i].value, "bts")) {
101743 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
101744 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
101745 + } else if (!strcmp(argv[i].value, "or")) {
101746 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
101747 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
101748 + fix_register("r10", 1, 1);
101749 + } else
101750 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
101751 + continue;
101752 + }
101753 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101754 + }
101755 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
101756 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
101757 +
101758 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
101759 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
101760 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
101761 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
101762 +
101763 + return 0;
101764 +}
101765 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
101766 new file mode 100644
101767 index 0000000..679b9ef
101768 --- /dev/null
101769 +++ b/tools/gcc/latent_entropy_plugin.c
101770 @@ -0,0 +1,335 @@
101771 +/*
101772 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
101773 + * Licensed under the GPL v2
101774 + *
101775 + * Note: the choice of the license means that the compilation process is
101776 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101777 + * but for the kernel it doesn't matter since it doesn't link against
101778 + * any of the gcc libraries
101779 + *
101780 + * gcc plugin to help generate a little bit of entropy from program state,
101781 + * used during boot in the kernel
101782 + *
101783 + * TODO:
101784 + * - add ipa pass to identify not explicitly marked candidate functions
101785 + * - mix in more program state (function arguments/return values, loop variables, etc)
101786 + * - more instrumentation control via attribute parameters
101787 + *
101788 + * BUGS:
101789 + * - LTO needs -flto-partition=none for now
101790 + */
101791 +#include "gcc-plugin.h"
101792 +#include "config.h"
101793 +#include "system.h"
101794 +#include "coretypes.h"
101795 +#include "tree.h"
101796 +#include "tree-pass.h"
101797 +#include "flags.h"
101798 +#include "intl.h"
101799 +#include "toplev.h"
101800 +#include "plugin.h"
101801 +//#include "expr.h" where are you...
101802 +#include "diagnostic.h"
101803 +#include "plugin-version.h"
101804 +#include "tm.h"
101805 +#include "function.h"
101806 +#include "basic-block.h"
101807 +#include "gimple.h"
101808 +#include "rtl.h"
101809 +#include "emit-rtl.h"
101810 +#include "tree-flow.h"
101811 +#include "langhooks.h"
101812 +
101813 +#if BUILDING_GCC_VERSION >= 4008
101814 +#define TODO_dump_func 0
101815 +#endif
101816 +
101817 +int plugin_is_GPL_compatible;
101818 +
101819 +static tree latent_entropy_decl;
101820 +
101821 +static struct plugin_info latent_entropy_plugin_info = {
101822 + .version = "201308230230",
101823 + .help = NULL
101824 +};
101825 +
101826 +static unsigned int execute_latent_entropy(void);
101827 +static bool gate_latent_entropy(void);
101828 +
101829 +static struct gimple_opt_pass latent_entropy_pass = {
101830 + .pass = {
101831 + .type = GIMPLE_PASS,
101832 + .name = "latent_entropy",
101833 +#if BUILDING_GCC_VERSION >= 4008
101834 + .optinfo_flags = OPTGROUP_NONE,
101835 +#endif
101836 + .gate = gate_latent_entropy,
101837 + .execute = execute_latent_entropy,
101838 + .sub = NULL,
101839 + .next = NULL,
101840 + .static_pass_number = 0,
101841 + .tv_id = TV_NONE,
101842 + .properties_required = PROP_gimple_leh | PROP_cfg,
101843 + .properties_provided = 0,
101844 + .properties_destroyed = 0,
101845 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
101846 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
101847 + }
101848 +};
101849 +
101850 +static unsigned HOST_WIDE_INT seed;
101851 +static unsigned HOST_WIDE_INT get_random_const(void)
101852 +{
101853 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
101854 + return seed;
101855 +}
101856 +
101857 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101858 +{
101859 + switch (TREE_CODE(*node)) {
101860 + default:
101861 + *no_add_attrs = true;
101862 + error("%qE attribute only applies to functions and variables", name);
101863 + break;
101864 +
101865 + case VAR_DECL:
101866 + if (DECL_INITIAL(*node)) {
101867 + *no_add_attrs = true;
101868 + error("variable %qD with %qE attribute must not be initialized", *node, name);
101869 + break;
101870 + }
101871 + DECL_INITIAL(*node) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
101872 + break;
101873 +
101874 + case FUNCTION_DECL:
101875 + break;
101876 + }
101877 +
101878 + return NULL_TREE;
101879 +}
101880 +
101881 +static struct attribute_spec latent_entropy_attr = {
101882 + .name = "latent_entropy",
101883 + .min_length = 0,
101884 + .max_length = 0,
101885 + .decl_required = true,
101886 + .type_required = false,
101887 + .function_type_required = false,
101888 + .handler = handle_latent_entropy_attribute,
101889 +#if BUILDING_GCC_VERSION >= 4007
101890 + .affects_type_identity = false
101891 +#endif
101892 +};
101893 +
101894 +static void register_attributes(void *event_data, void *data)
101895 +{
101896 + register_attribute(&latent_entropy_attr);
101897 +}
101898 +
101899 +static bool gate_latent_entropy(void)
101900 +{
101901 + tree latent_entropy_attr;
101902 +
101903 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
101904 + return latent_entropy_attr != NULL_TREE;
101905 +}
101906 +
101907 +static enum tree_code get_op(tree *rhs)
101908 +{
101909 + static enum tree_code op;
101910 + unsigned HOST_WIDE_INT random_const;
101911 +
101912 + random_const = get_random_const();
101913 +
101914 + switch (op) {
101915 + case BIT_XOR_EXPR:
101916 + op = PLUS_EXPR;
101917 + break;
101918 +
101919 + case PLUS_EXPR:
101920 + if (rhs) {
101921 + op = LROTATE_EXPR;
101922 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
101923 + break;
101924 + }
101925 +
101926 + case LROTATE_EXPR:
101927 + default:
101928 + op = BIT_XOR_EXPR;
101929 + break;
101930 + }
101931 + if (rhs)
101932 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
101933 + return op;
101934 +}
101935 +
101936 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
101937 +{
101938 + gimple_stmt_iterator gsi;
101939 + gimple assign;
101940 + tree addxorrol, rhs;
101941 + enum tree_code op;
101942 +
101943 + op = get_op(&rhs);
101944 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
101945 + assign = gimple_build_assign(local_entropy, addxorrol);
101946 + gsi = gsi_after_labels(bb);
101947 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101948 + update_stmt(assign);
101949 +//debug_bb(bb);
101950 +}
101951 +
101952 +static void perturb_latent_entropy(basic_block bb, tree rhs)
101953 +{
101954 + gimple_stmt_iterator gsi;
101955 + gimple assign;
101956 + tree addxorrol, temp;
101957 +
101958 + // 1. create temporary copy of latent_entropy
101959 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
101960 +#if BUILDING_GCC_VERSION <= 4007
101961 + add_referenced_var(temp);
101962 +#endif
101963 +
101964 + // 2. read...
101965 + temp = make_ssa_name(temp, NULL);
101966 + assign = gimple_build_assign(temp, latent_entropy_decl);
101967 + SSA_NAME_DEF_STMT(temp) = assign;
101968 +#if BUILDING_GCC_VERSION <= 4007
101969 + add_referenced_var(latent_entropy_decl);
101970 +#endif
101971 + gsi = gsi_after_labels(bb);
101972 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101973 + update_stmt(assign);
101974 +
101975 + // 3. ...modify...
101976 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
101977 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
101978 + assign = gimple_build_assign(temp, addxorrol);
101979 + SSA_NAME_DEF_STMT(temp) = assign;
101980 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101981 + update_stmt(assign);
101982 +
101983 + // 4. ...write latent_entropy
101984 + assign = gimple_build_assign(latent_entropy_decl, temp);
101985 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101986 + update_stmt(assign);
101987 +}
101988 +
101989 +static unsigned int execute_latent_entropy(void)
101990 +{
101991 + basic_block bb;
101992 + gimple assign;
101993 + gimple_stmt_iterator gsi;
101994 + tree local_entropy;
101995 +
101996 + if (!latent_entropy_decl) {
101997 + struct varpool_node *node;
101998 +
101999 +#if BUILDING_GCC_VERSION <= 4007
102000 + for (node = varpool_nodes; node; node = node->next) {
102001 + tree var = node->decl;
102002 +#else
102003 + FOR_EACH_VARIABLE(node) {
102004 + tree var = node->symbol.decl;
102005 +#endif
102006 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
102007 + continue;
102008 + latent_entropy_decl = var;
102009 +// debug_tree(var);
102010 + break;
102011 + }
102012 + if (!latent_entropy_decl) {
102013 +// debug_tree(current_function_decl);
102014 + return 0;
102015 + }
102016 + }
102017 +
102018 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
102019 +
102020 + // 1. create local entropy variable
102021 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
102022 +#if BUILDING_GCC_VERSION <= 4007
102023 + add_referenced_var(local_entropy);
102024 + mark_sym_for_renaming(local_entropy);
102025 +#endif
102026 +
102027 + // 2. initialize local entropy variable
102028 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102029 + if (dom_info_available_p(CDI_DOMINATORS))
102030 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102031 + gsi = gsi_start_bb(bb);
102032 +
102033 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
102034 +// gimple_set_location(assign, loc);
102035 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102036 + update_stmt(assign);
102037 +//debug_bb(bb);
102038 + bb = bb->next_bb;
102039 +
102040 + // 3. instrument each BB with an operation on the local entropy variable
102041 + while (bb != EXIT_BLOCK_PTR) {
102042 + perturb_local_entropy(bb, local_entropy);
102043 +//debug_bb(bb);
102044 + bb = bb->next_bb;
102045 + };
102046 +
102047 + // 4. mix local entropy into the global entropy variable
102048 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
102049 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
102050 + return 0;
102051 +}
102052 +
102053 +static void start_unit_callback(void *gcc_data, void *user_data)
102054 +{
102055 + tree latent_entropy_type;
102056 +
102057 +#if BUILDING_GCC_VERSION >= 4007
102058 + seed = get_random_seed(false);
102059 +#else
102060 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
102061 + seed *= seed;
102062 +#endif
102063 +
102064 + if (in_lto_p)
102065 + return;
102066 +
102067 + // extern volatile u64 latent_entropy
102068 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
102069 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
102070 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
102071 +
102072 + TREE_STATIC(latent_entropy_decl) = 1;
102073 + TREE_PUBLIC(latent_entropy_decl) = 1;
102074 + TREE_USED(latent_entropy_decl) = 1;
102075 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
102076 + DECL_EXTERNAL(latent_entropy_decl) = 1;
102077 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
102078 + lang_hooks.decls.pushdecl(latent_entropy_decl);
102079 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
102080 +// varpool_finalize_decl(latent_entropy_decl);
102081 +// varpool_mark_needed_node(latent_entropy_decl);
102082 +}
102083 +
102084 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102085 +{
102086 + const char * const plugin_name = plugin_info->base_name;
102087 + struct register_pass_info latent_entropy_pass_info = {
102088 + .pass = &latent_entropy_pass.pass,
102089 + .reference_pass_name = "optimized",
102090 + .ref_pass_instance_number = 1,
102091 + .pos_op = PASS_POS_INSERT_BEFORE
102092 + };
102093 +
102094 + if (!plugin_default_version_check(version, &gcc_version)) {
102095 + error(G_("incompatible gcc/plugin versions"));
102096 + return 1;
102097 + }
102098 +
102099 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
102100 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102101 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
102102 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102103 +
102104 + return 0;
102105 +}
102106 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
102107 new file mode 100644
102108 index 0000000..b04803b
102109 --- /dev/null
102110 +++ b/tools/gcc/size_overflow_hash.data
102111 @@ -0,0 +1,6350 @@
102112 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
102113 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
102114 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
102115 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
102116 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
102117 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
102118 +padzero_55 padzero 1 55 &sel_read_policyvers_55
102119 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
102120 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
102121 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
102122 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
102123 +load_msg_95 load_msg 2 95 NULL
102124 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
102125 +init_q_132 init_q 4 132 NULL
102126 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
102127 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
102128 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
102129 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
102130 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
102131 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
102132 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
102133 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
102134 +br_port_info_size_268 br_port_info_size 0 268 NULL
102135 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
102136 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
102137 +SYSC_connect_304 SYSC_connect 3 304 NULL
102138 +syslog_print_307 syslog_print 2 307 NULL
102139 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
102140 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
102141 +next_node_allowed_318 next_node_allowed 1 318 NULL
102142 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
102143 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
102144 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
102145 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
102146 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
102147 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
102148 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
102149 +pidlist_resize_496 pidlist_resize 2 496 NULL
102150 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
102151 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
102152 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
102153 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
102154 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
102155 +dle_count_543 dle_count 0 543 NULL
102156 +devres_alloc_551 devres_alloc 2 551 NULL
102157 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
102158 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
102159 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
102160 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
102161 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
102162 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
102163 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
102164 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
102165 +isp1760_register_628 isp1760_register 1-2 628 NULL
102166 +clone_split_bio_633 clone_split_bio 6 633 NULL
102167 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
102168 +remap_to_cache_640 remap_to_cache 3 640 NULL
102169 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
102170 +unlink_queued_645 unlink_queued 3-4 645 NULL
102171 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
102172 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
102173 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
102174 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
102175 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
102176 +disk_max_parts_719 disk_max_parts 0 719 NULL
102177 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
102178 +dvb_video_write_754 dvb_video_write 3 754 NULL
102179 +if_writecmd_815 if_writecmd 2 815 NULL
102180 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
102181 +read_fifo_826 read_fifo 3 826 NULL
102182 +um_idi_read_850 um_idi_read 3 850 NULL
102183 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
102184 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
102185 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
102186 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
102187 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
102188 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
102189 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
102190 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
102191 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
102192 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
102193 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
102194 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
102195 +_do_truncate_1019 _do_truncate 2 1019 NULL
102196 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
102197 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
102198 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
102199 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
102200 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
102201 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
102202 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
102203 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
102204 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
102205 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
102206 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
102207 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
102208 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
102209 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
102210 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
102211 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
102212 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
102213 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
102214 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
102215 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
102216 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
102217 +nested_get_page_1252 nested_get_page 2 1252 NULL
102218 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
102219 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
102220 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
102221 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
102222 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
102223 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
102224 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
102225 +ffs_1322 ffs 0 1322 NULL
102226 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
102227 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
102228 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
102229 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
102230 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
102231 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
102232 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
102233 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
102234 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
102235 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
102236 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
102237 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
102238 +zone_page_state_1393 zone_page_state 0 1393 NULL
102239 +file_read_actor_1401 file_read_actor 4 1401 NULL
102240 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
102241 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
102242 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
102243 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
102244 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
102245 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
102246 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
102247 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
102248 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
102249 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
102250 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
102251 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
102252 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
102253 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
102254 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
102255 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
102256 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
102257 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
102258 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
102259 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
102260 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
102261 +rmap_add_1677 rmap_add 3 1677 NULL
102262 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
102263 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
102264 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
102265 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
102266 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
102267 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
102268 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
102269 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
102270 +cosa_write_1774 cosa_write 3 1774 NULL
102271 +update_macheader_1775 update_macheader 7 1775 NULL
102272 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
102273 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
102274 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
102275 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
102276 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
102277 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
102278 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
102279 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
102280 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
102281 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
102282 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
102283 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
102284 +read_swap_header_1957 read_swap_header 0 1957 NULL
102285 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
102286 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
102287 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
102288 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
102289 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
102290 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
102291 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
102292 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
102293 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
102294 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
102295 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
102296 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
102297 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
102298 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
102299 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
102300 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
102301 +audit_expand_2098 audit_expand 2 2098 NULL
102302 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
102303 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
102304 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
102305 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
102306 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
102307 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
102308 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
102309 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
102310 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
102311 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
102312 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
102313 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
102314 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
102315 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
102316 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
102317 +vhci_write_2224 vhci_write 3 2224 NULL
102318 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
102319 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
102320 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
102321 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
102322 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
102323 +do_update_counters_2259 do_update_counters 4 2259 NULL
102324 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
102325 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
102326 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
102327 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
102328 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
102329 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
102330 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
102331 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
102332 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
102333 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
102334 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
102335 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
102336 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
102337 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
102338 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
102339 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
102340 +raid1_size_2419 raid1_size 0-2 2419 NULL
102341 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
102342 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
102343 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
102344 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
102345 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
102346 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
102347 +update_pmkid_2481 update_pmkid 4 2481 NULL
102348 +wiphy_new_2482 wiphy_new 2 2482 NULL
102349 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
102350 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
102351 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
102352 +dm_write_2513 dm_write 3 2513 NULL
102353 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
102354 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
102355 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
102356 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
102357 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
102358 +slot_bytes_2609 slot_bytes 0 2609 NULL
102359 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
102360 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
102361 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
102362 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
102363 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
102364 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
102365 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
102366 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
102367 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
102368 +__next_cpu_2782 __next_cpu 1 2782 NULL
102369 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
102370 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
102371 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
102372 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
102373 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
102374 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
102375 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
102376 +mq_map_2871 mq_map 2 2871 NULL
102377 +nla_padlen_2883 nla_padlen 1 2883 NULL
102378 +cmm_write_2896 cmm_write 3 2896 NULL
102379 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
102380 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
102381 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
102382 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
102383 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
102384 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
102385 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
102386 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
102387 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
102388 +depth_write_3021 depth_write 3 3021 NULL
102389 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
102390 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
102391 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
102392 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
102393 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
102394 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
102395 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
102396 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
102397 +free_coherent_3082 free_coherent 4-2 3082 NULL
102398 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
102399 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
102400 +rb_alloc_3102 rb_alloc 1 3102 NULL
102401 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
102402 +print_time_3132 print_time 0 3132 NULL
102403 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
102404 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
102405 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
102406 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
102407 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
102408 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
102409 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
102410 +alloc_context_3194 alloc_context 1 3194 NULL
102411 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
102412 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
102413 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
102414 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
102415 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
102416 +key_key_read_3241 key_key_read 3 3241 NULL
102417 +number_3243 number 0 3243 NULL
102418 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
102419 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
102420 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
102421 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
102422 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
102423 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
102424 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
102425 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
102426 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
102427 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
102428 +scnprintf_3360 scnprintf 0-2 3360 NULL
102429 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
102430 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
102431 +send_stream_3397 send_stream 4 3397 NULL
102432 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
102433 +msix_map_region_3411 msix_map_region 3 3411 NULL
102434 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
102435 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
102436 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
102437 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
102438 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
102439 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
102440 +map_single_3449 map_single 0-2 3449 NULL
102441 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
102442 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
102443 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
102444 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
102445 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
102446 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
102447 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
102448 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
102449 +SyS_readv_3539 SyS_readv 3 3539 NULL
102450 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
102451 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
102452 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
102453 +evtchn_read_3569 evtchn_read 3 3569 NULL
102454 +vc_resize_3585 vc_resize 2-3 3585 NULL
102455 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
102456 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
102457 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
102458 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
102459 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
102460 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
102461 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
102462 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
102463 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
102464 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
102465 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
102466 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
102467 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
102468 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
102469 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
102470 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
102471 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
102472 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
102473 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
102474 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
102475 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
102476 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
102477 +get_fd_set_3866 get_fd_set 1 3866 NULL
102478 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
102479 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
102480 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
102481 +nvram_write_3894 nvram_write 3 3894 NULL
102482 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
102483 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
102484 +vcs_write_3910 vcs_write 3 3910 NULL
102485 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
102486 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
102487 +do_add_counters_3992 do_add_counters 3 3992 NULL
102488 +userspace_status_4004 userspace_status 4 4004 NULL
102489 +mei_write_4005 mei_write 3 4005 NULL nohasharray
102490 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
102491 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
102492 +mm_populate_4016 mm_populate 1 4016 NULL
102493 +blk_end_request_4024 blk_end_request 3 4024 NULL
102494 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
102495 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
102496 +read_file_queues_4078 read_file_queues 3 4078 NULL
102497 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
102498 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
102499 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
102500 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
102501 +tm6000_read_4151 tm6000_read 3 4151 NULL
102502 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
102503 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
102504 +get_alua_req_4166 get_alua_req 3 4166 NULL
102505 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
102506 +read_file_bool_4180 read_file_bool 3 4180 NULL
102507 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
102508 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
102509 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
102510 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
102511 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
102512 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
102513 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
102514 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
102515 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
102516 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
102517 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
102518 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
102519 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
102520 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
102521 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
102522 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
102523 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
102524 +memparse_4444 memparse 0 4444 NULL
102525 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
102526 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
102527 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
102528 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
102529 +set_link_security_4502 set_link_security 4 4502 NULL
102530 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
102531 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
102532 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
102533 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
102534 +tty_register_device_4544 tty_register_device 2 4544 NULL
102535 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
102536 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
102537 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
102538 +bch_alloc_4593 bch_alloc 1 4593 NULL
102539 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
102540 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
102541 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
102542 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
102543 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
102544 +kone_receive_4690 kone_receive 4 4690 NULL
102545 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
102546 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
102547 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
102548 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
102549 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
102550 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
102551 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
102552 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
102553 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
102554 +create_subvol_4791 create_subvol 4 4791 NULL
102555 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
102556 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
102557 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
102558 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
102559 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
102560 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
102561 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
102562 +sys_ipc_4889 sys_ipc 3 4889 NULL
102563 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
102564 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
102565 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
102566 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
102567 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
102568 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
102569 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
102570 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
102571 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
102572 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
102573 +do_mincore_5018 do_mincore 0-1 5018 NULL
102574 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
102575 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
102576 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
102577 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
102578 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
102579 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
102580 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
102581 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
102582 +sound_write_5102 sound_write 3 5102 NULL
102583 +clear_dirty_5105 clear_dirty 3 5105 NULL
102584 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
102585 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
102586 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
102587 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
102588 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
102589 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
102590 +skb_network_header_5203 skb_network_header 0 5203 NULL
102591 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
102592 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
102593 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
102594 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
102595 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
102596 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
102597 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
102598 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
102599 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
102600 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
102601 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
102602 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
102603 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
102604 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
102605 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
102606 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
102607 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
102608 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
102609 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
102610 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
102611 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
102612 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
102613 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
102614 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
102615 +tty_write_5494 tty_write 3 5494 NULL
102616 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
102617 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
102618 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
102619 +spidev_message_5518 spidev_message 3 5518 NULL
102620 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
102621 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
102622 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
102623 +le_readq_5557 le_readq 0 5557 NULL
102624 +inw_5558 inw 0 5558 NULL
102625 +fir16_create_5574 fir16_create 3 5574 NULL
102626 +bioset_create_5580 bioset_create 1 5580 NULL
102627 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
102628 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
102629 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
102630 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
102631 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
102632 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
102633 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
102634 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
102635 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
102636 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
102637 +get_arg_5694 get_arg 3 5694 NULL
102638 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
102639 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
102640 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
102641 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
102642 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
102643 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
102644 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
102645 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
102646 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
102647 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
102648 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
102649 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
102650 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
102651 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
102652 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
102653 +setup_req_5848 setup_req 3 5848 NULL
102654 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
102655 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
102656 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
102657 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
102658 +port_show_regs_5904 port_show_regs 3 5904 NULL
102659 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
102660 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
102661 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
102662 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
102663 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
102664 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
102665 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
102666 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
102667 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
102668 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
102669 +native_pte_val_5978 native_pte_val 0 5978 NULL
102670 +SyS_semop_5980 SyS_semop 3 5980 NULL
102671 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
102672 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
102673 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
102674 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
102675 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
102676 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
102677 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
102678 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
102679 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
102680 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
102681 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
102682 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
102683 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
102684 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
102685 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
102686 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
102687 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
102688 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
102689 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
102690 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
102691 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
102692 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
102693 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
102694 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
102695 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
102696 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
102697 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
102698 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
102699 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
102700 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
102701 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
102702 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
102703 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
102704 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
102705 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
102706 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
102707 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
102708 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
102709 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
102710 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
102711 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
102712 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
102713 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
102714 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
102715 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
102716 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
102717 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
102718 +mei_read_6507 mei_read 3 6507 NULL
102719 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
102720 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
102721 +wdm_read_6549 wdm_read 3 6549 NULL
102722 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
102723 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
102724 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
102725 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
102726 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
102727 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
102728 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
102729 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
102730 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
102731 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
102732 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
102733 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
102734 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
102735 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
102736 +mpeg_read_6708 mpeg_read 3 6708 NULL
102737 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
102738 +video_proc_write_6724 video_proc_write 3 6724 NULL
102739 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
102740 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
102741 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
102742 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
102743 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
102744 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
102745 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
102746 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
102747 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
102748 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
102749 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
102750 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
102751 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
102752 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
102753 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
102754 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
102755 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
102756 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
102757 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
102758 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
102759 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
102760 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
102761 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
102762 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
102763 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
102764 +request_key_async_6990 request_key_async 4 6990 NULL
102765 +tpl_write_6998 tpl_write 3 6998 NULL
102766 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
102767 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
102768 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
102769 +wimax_msg_7030 wimax_msg 4 7030 NULL
102770 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
102771 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
102772 +event_enable_read_7074 event_enable_read 3 7074 NULL
102773 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
102774 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
102775 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
102776 +check_header_7108 check_header 0 7108 NULL
102777 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
102778 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
102779 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
102780 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
102781 +get_param_h_7247 get_param_h 0 7247 NULL
102782 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
102783 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
102784 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
102785 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
102786 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
102787 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
102788 +mgmt_control_7349 mgmt_control 3 7349 NULL
102789 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
102790 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
102791 +hweight_long_7388 hweight_long 0-1 7388 NULL
102792 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
102793 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
102794 +readb_7401 readb 0 7401 NULL
102795 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
102796 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
102797 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
102798 +numa_emulation_7466 numa_emulation 2 7466 NULL
102799 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
102800 +garp_request_join_7471 garp_request_join 4 7471 NULL
102801 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
102802 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
102803 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
102804 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
102805 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
102806 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
102807 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
102808 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
102809 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
102810 +groups_alloc_7614 groups_alloc 1 7614 NULL
102811 +sg_virt_7616 sg_virt 0 7616 NULL
102812 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
102813 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
102814 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
102815 +dev_write_7708 dev_write 3 7708 NULL
102816 +unmap_region_7709 unmap_region 1 7709 NULL
102817 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
102818 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
102819 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
102820 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
102821 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
102822 +ioread32be_7773 ioread32be 0 7773 NULL
102823 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
102824 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
102825 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
102826 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
102827 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
102828 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
102829 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
102830 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
102831 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
102832 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
102833 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
102834 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
102835 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
102836 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
102837 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
102838 +sys_mbind_7990 sys_mbind 5 7990 NULL
102839 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
102840 +vcs_read_8017 vcs_read 3 8017 NULL
102841 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
102842 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
102843 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
102844 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
102845 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
102846 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
102847 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
102848 +venus_lookup_8121 venus_lookup 4 8121 NULL
102849 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
102850 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
102851 +ore_truncate_8181 ore_truncate 3 8181 NULL
102852 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
102853 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
102854 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
102855 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
102856 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
102857 +play_iframe_8219 play_iframe 3 8219 NULL
102858 +create_log_8225 create_log 2 8225 NULL nohasharray
102859 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
102860 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
102861 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
102862 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
102863 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
102864 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
102865 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
102866 +init_cdev_8274 init_cdev 1 8274 NULL
102867 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
102868 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
102869 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
102870 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
102871 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
102872 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
102873 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
102874 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
102875 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
102876 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
102877 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
102878 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
102879 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
102880 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
102881 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
102882 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
102883 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
102884 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
102885 +dev_config_8506 dev_config 3 8506 NULL
102886 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
102887 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
102888 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
102889 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
102890 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
102891 +user_on_off_8552 user_on_off 2 8552 NULL
102892 +profile_remove_8556 profile_remove 3 8556 NULL
102893 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
102894 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
102895 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
102896 +tower_write_8580 tower_write 3 8580 NULL
102897 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
102898 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
102899 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
102900 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
102901 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
102902 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
102903 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
102904 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
102905 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
102906 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
102907 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
102908 +arcfb_write_8702 arcfb_write 3 8702 NULL
102909 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
102910 +init_header_8703 init_header 0 8703 &i_size_read_8703
102911 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
102912 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
102913 +f_dupfd_8730 f_dupfd 1 8730 NULL
102914 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
102915 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
102916 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
102917 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
102918 +sys_prctl_8766 sys_prctl 4 8766 NULL
102919 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
102920 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
102921 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
102922 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
102923 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
102924 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
102925 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
102926 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
102927 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
102928 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
102929 +clear_bitset_8840 clear_bitset 2 8840 NULL
102930 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
102931 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
102932 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
102933 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
102934 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
102935 +layout_commit_8926 layout_commit 3 8926 NULL
102936 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
102937 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
102938 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
102939 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
102940 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
102941 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
102942 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
102943 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
102944 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
102945 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
102946 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
102947 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
102948 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
102949 +nla_put_9042 nla_put 3 9042 NULL
102950 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
102951 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
102952 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
102953 +string_9080 string 0 9080 NULL
102954 +create_queues_9088 create_queues 2-3 9088 NULL
102955 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
102956 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
102957 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
102958 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
102959 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
102960 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
102961 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
102962 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
102963 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
102964 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
102965 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
102966 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
102967 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
102968 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
102969 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
102970 +get_pfn_9207 get_pfn 1 9207 NULL
102971 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
102972 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
102973 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
102974 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
102975 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
102976 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
102977 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
102978 +flakey_status_9274 flakey_status 5 9274 NULL
102979 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
102980 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
102981 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
102982 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
102983 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
102984 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
102985 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
102986 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
102987 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
102988 +read_9397 read 3 9397 NULL
102989 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
102990 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
102991 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
102992 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
102993 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
102994 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
102995 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
102996 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
102997 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
102998 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
102999 +lp_write_9511 lp_write 3 9511 NULL
103000 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
103001 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
103002 +read_file_dma_9530 read_file_dma 3 9530 NULL
103003 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
103004 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
103005 +fw_node_create_9559 fw_node_create 2 9559 NULL
103006 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
103007 +kobj_map_9566 kobj_map 2-3 9566 NULL
103008 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
103009 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
103010 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
103011 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
103012 +do_sync_9604 do_sync 1 9604 NULL
103013 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
103014 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
103015 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
103016 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
103017 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
103018 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
103019 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
103020 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
103021 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
103022 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
103023 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
103024 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
103025 +is_hole_9694 is_hole 2 9694 NULL nohasharray
103026 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
103027 +fnb_9703 fnb 2-3 9703 NULL
103028 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
103029 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
103030 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
103031 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
103032 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
103033 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
103034 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
103035 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
103036 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
103037 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
103038 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
103039 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
103040 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
103041 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
103042 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
103043 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
103044 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
103045 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
103046 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
103047 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
103048 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
103049 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
103050 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
103051 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
103052 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
103053 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
103054 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
103055 +read_file_misc_9948 read_file_misc 3 9948 NULL
103056 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
103057 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
103058 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
103059 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
103060 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
103061 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
103062 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
103063 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
103064 +handle_request_10024 handle_request 9 10024 NULL
103065 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
103066 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
103067 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
103068 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
103069 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
103070 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
103071 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
103072 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
103073 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
103074 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
103075 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
103076 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
103077 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
103078 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
103079 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
103080 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
103081 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
103082 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
103083 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
103084 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
103085 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
103086 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
103087 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
103088 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
103089 +read_emulate_10310 read_emulate 2-4 10310 NULL
103090 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
103091 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
103092 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
103093 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
103094 +get_dump_page_10338 get_dump_page 1 10338 NULL
103095 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
103096 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
103097 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
103098 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
103099 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
103100 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
103101 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
103102 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
103103 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
103104 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
103105 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
103106 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
103107 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
103108 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
103109 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
103110 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
103111 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
103112 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
103113 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
103114 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
103115 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
103116 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
103117 +otp_read_10594 otp_read 2-4-5 10594 NULL
103118 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
103119 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
103120 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
103121 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
103122 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
103123 +parport_write_10669 parport_write 0 10669 NULL
103124 +inl_10708 inl 0 10708 NULL nohasharray
103125 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
103126 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
103127 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
103128 +spi_sync_10731 spi_sync 0 10731 NULL
103129 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
103130 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
103131 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
103132 +sys_syslog_10746 sys_syslog 3 10746 NULL
103133 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
103134 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
103135 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
103136 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
103137 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
103138 +sys_bind_10799 sys_bind 3 10799 NULL
103139 +compat_put_int_10828 compat_put_int 1 10828 NULL
103140 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
103141 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
103142 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
103143 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
103144 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
103145 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
103146 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
103147 +get_scq_10897 get_scq 2 10897 NULL
103148 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
103149 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
103150 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
103151 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
103152 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
103153 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
103154 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
103155 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
103156 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
103157 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
103158 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
103159 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
103160 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
103161 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
103162 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
103163 +count_argc_11083 count_argc 0 11083 NULL
103164 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
103165 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
103166 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
103167 +page_offset_11120 page_offset 0 11120 NULL
103168 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
103169 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
103170 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
103171 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
103172 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
103173 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
103174 +__swab16p_11220 __swab16p 0 11220 NULL
103175 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
103176 +mmap_region_11247 mmap_region 0-2 11247 NULL
103177 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
103178 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
103179 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
103180 +cru_detect_11272 cru_detect 1 11272 NULL
103181 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
103182 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
103183 +construct_key_11329 construct_key 3 11329 NULL nohasharray
103184 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
103185 +next_segment_11330 next_segment 0-2-1 11330 NULL
103186 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
103187 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
103188 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
103189 +sel_write_create_11353 sel_write_create 3 11353 NULL
103190 +handle_unit_11355 handle_unit 0-1 11355 NULL
103191 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
103192 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
103193 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
103194 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
103195 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
103196 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
103197 +str_to_user_11411 str_to_user 2 11411 NULL
103198 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
103199 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
103200 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
103201 +trace_options_read_11419 trace_options_read 3 11419 NULL
103202 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
103203 +prepare_image_11424 prepare_image 0 11424 NULL
103204 +vring_size_11426 vring_size 0-1-2 11426 NULL
103205 +bttv_read_11432 bttv_read 3 11432 NULL
103206 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
103207 +swp_offset_11475 swp_offset 0 11475 NULL
103208 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
103209 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
103210 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
103211 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
103212 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
103213 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
103214 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
103215 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
103216 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
103217 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
103218 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
103219 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
103220 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
103221 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
103222 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
103223 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
103224 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
103225 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
103226 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
103227 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
103228 +split_11691 split 2 11691 NULL
103229 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
103230 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
103231 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
103232 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
103233 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
103234 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
103235 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
103236 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
103237 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
103238 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
103239 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
103240 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
103241 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
103242 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
103243 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
103244 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
103245 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
103246 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
103247 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
103248 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
103249 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
103250 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
103251 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
103252 +atmel_read16_11981 atmel_read16 0 11981 NULL
103253 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
103254 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
103255 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
103256 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
103257 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
103258 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
103259 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
103260 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
103261 +set_powered_12129 set_powered 4 12129 NULL
103262 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
103263 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
103264 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
103265 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
103266 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
103267 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
103268 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
103269 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
103270 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
103271 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
103272 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
103273 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
103274 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
103275 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
103276 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
103277 +scaled_div_12201 scaled_div 1-2 12201 NULL
103278 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
103279 +receive_copy_12216 receive_copy 3 12216 NULL
103280 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
103281 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
103282 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
103283 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
103284 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
103285 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
103286 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
103287 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
103288 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
103289 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
103290 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
103291 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
103292 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
103293 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
103294 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
103295 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
103296 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
103297 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
103298 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
103299 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
103300 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
103301 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
103302 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
103303 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
103304 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
103305 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
103306 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
103307 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
103308 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
103309 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
103310 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
103311 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
103312 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
103313 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
103314 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
103315 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
103316 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
103317 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
103318 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
103319 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
103320 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
103321 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
103322 +wb_create_12651 wb_create 1 12651 NULL
103323 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
103324 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
103325 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
103326 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
103327 +ivtv_write_12721 ivtv_write 3 12721 NULL
103328 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
103329 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
103330 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
103331 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
103332 +listxattr_12769 listxattr 3 12769 NULL
103333 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
103334 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
103335 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
103336 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
103337 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
103338 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
103339 +readq_12825 readq 0 12825 NULL
103340 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
103341 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
103342 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
103343 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
103344 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
103345 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
103346 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
103347 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
103348 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
103349 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
103350 +bm_status_write_12964 bm_status_write 3 12964 NULL
103351 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
103352 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
103353 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
103354 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
103355 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
103356 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
103357 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
103358 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
103359 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
103360 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
103361 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
103362 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
103363 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
103364 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
103365 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
103366 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
103367 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
103368 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
103369 +blk_update_request_13146 blk_update_request 3 13146 NULL
103370 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
103371 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
103372 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
103373 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
103374 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
103375 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
103376 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
103377 +comedi_read_13199 comedi_read 3 13199 NULL
103378 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
103379 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
103380 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
103381 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
103382 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
103383 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
103384 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
103385 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
103386 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
103387 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
103388 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
103389 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
103390 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
103391 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
103392 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
103393 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
103394 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
103395 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
103396 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
103397 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
103398 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
103399 +cache_ctr_13364 cache_ctr 2 13364 NULL
103400 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
103401 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
103402 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
103403 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
103404 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
103405 +sky2_receive_13407 sky2_receive 2 13407 NULL
103406 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
103407 +keyring_read_13438 keyring_read 3 13438 NULL
103408 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
103409 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
103410 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
103411 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
103412 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
103413 +core_status_13515 core_status 4 13515 NULL
103414 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
103415 +bm_init_13529 bm_init 2 13529 NULL
103416 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
103417 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
103418 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
103419 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
103420 +sys_madvise_13569 sys_madvise 1 13569 NULL
103421 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
103422 +cache_write_13589 cache_write 3 13589 NULL
103423 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
103424 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
103425 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
103426 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
103427 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
103428 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
103429 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
103430 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
103431 +packet_snd_13634 packet_snd 3 13634 NULL
103432 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
103433 +cache_downcall_13666 cache_downcall 3 13666 NULL
103434 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
103435 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
103436 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
103437 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
103438 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
103439 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
103440 +random_read_13815 random_read 3 13815 NULL
103441 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
103442 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
103443 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
103444 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
103445 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
103446 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
103447 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
103448 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
103449 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
103450 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
103451 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
103452 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
103453 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
103454 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
103455 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
103456 +com90xx_found_13974 com90xx_found 3 13974 NULL
103457 +qcam_read_13977 qcam_read 3 13977 NULL
103458 +dsp_read_13980 dsp_read 2 13980 NULL
103459 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
103460 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
103461 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
103462 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
103463 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
103464 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
103465 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
103466 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
103467 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
103468 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
103469 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
103470 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
103471 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
103472 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
103473 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
103474 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
103475 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
103476 +em_canid_change_14150 em_canid_change 3 14150 NULL
103477 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
103478 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
103479 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
103480 +alloc_async_14208 alloc_async 1 14208 NULL
103481 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
103482 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
103483 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
103484 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
103485 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
103486 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
103487 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
103488 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
103489 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
103490 +rr_status_14293 rr_status 5 14293 NULL
103491 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
103492 +oo_objects_14319 oo_objects 0 14319 NULL
103493 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
103494 +scsi2int_14358 scsi2int 0 14358 NULL
103495 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
103496 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
103497 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
103498 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
103499 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
103500 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
103501 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
103502 +block_size_14443 block_size 0 14443 NULL
103503 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
103504 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
103505 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
103506 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
103507 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
103508 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
103509 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
103510 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
103511 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
103512 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
103513 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
103514 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
103515 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
103516 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
103517 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
103518 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
103519 +dbJoin_14644 dbJoin 0 14644 NULL
103520 +profile_replace_14652 profile_replace 3 14652 NULL
103521 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
103522 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
103523 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
103524 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
103525 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
103526 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
103527 +get_bio_block_14714 get_bio_block 0 14714 NULL
103528 +vfd_write_14717 vfd_write 3 14717 NULL
103529 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
103530 +raid1_resize_14740 raid1_resize 2 14740 NULL
103531 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
103532 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
103533 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
103534 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
103535 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
103536 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
103537 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
103538 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
103539 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
103540 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
103541 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
103542 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
103543 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
103544 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
103545 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
103546 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
103547 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
103548 +unifi_read_14899 unifi_read 3 14899 NULL
103549 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
103550 +krealloc_14908 krealloc 2 14908 NULL
103551 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
103552 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
103553 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
103554 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
103555 +queue_cnt_14951 queue_cnt 0 14951 NULL
103556 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
103557 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
103558 +setkey_14987 setkey 3 14987 NULL nohasharray
103559 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
103560 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
103561 +vmap_15025 vmap 2 15025 NULL
103562 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
103563 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
103564 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
103565 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
103566 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
103567 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
103568 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
103569 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
103570 +start_port_15124 start_port 0 15124 NULL
103571 +memchr_15126 memchr 0 15126 NULL
103572 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
103573 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
103574 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
103575 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
103576 +reserve_resources_15194 reserve_resources 3 15194 NULL
103577 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
103578 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
103579 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
103580 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
103581 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
103582 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
103583 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
103584 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
103585 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
103586 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
103587 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
103588 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
103589 +ioread16_15342 ioread16 0 15342 NULL
103590 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
103591 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
103592 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
103593 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
103594 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
103595 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
103596 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
103597 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
103598 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
103599 +get_modalias_15406 get_modalias 2 15406 NULL
103600 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
103601 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
103602 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
103603 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
103604 +memweight_15450 memweight 2 15450 NULL
103605 +vmalloc_15464 vmalloc 1 15464 NULL
103606 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
103607 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
103608 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
103609 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
103610 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
103611 +persistent_status_15574 persistent_status 4 15574 NULL
103612 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
103613 +vme_user_write_15587 vme_user_write 3 15587 NULL
103614 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
103615 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
103616 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
103617 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
103618 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
103619 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
103620 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
103621 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
103622 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
103623 +fs_path_add_15648 fs_path_add 3 15648 NULL
103624 +xsd_read_15653 xsd_read 3 15653 NULL
103625 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
103626 +unix_bind_15668 unix_bind 3 15668 NULL
103627 +dm_read_15674 dm_read 3 15674 NULL
103628 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
103629 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
103630 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
103631 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
103632 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
103633 +do_test_15766 do_test 1 15766 NULL
103634 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
103635 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
103636 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
103637 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
103638 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
103639 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
103640 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
103641 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
103642 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
103643 +table_size_15851 table_size 0-1-2 15851 NULL
103644 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
103645 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
103646 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
103647 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
103648 +native_read_msr_15905 native_read_msr 0 15905 NULL
103649 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
103650 +power_read_15939 power_read 3 15939 NULL
103651 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
103652 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
103653 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
103654 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
103655 +frame_alloc_15981 frame_alloc 4 15981 NULL
103656 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
103657 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
103658 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
103659 +got_frame_16028 got_frame 2 16028 NULL
103660 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
103661 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
103662 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
103663 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
103664 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
103665 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
103666 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
103667 +fsm_init_16134 fsm_init 2 16134 NULL
103668 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
103669 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
103670 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
103671 +mapping_level_16188 mapping_level 2 16188 NULL
103672 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
103673 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
103674 +create_table_16213 create_table 2 16213 NULL
103675 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
103676 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
103677 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
103678 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
103679 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
103680 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
103681 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
103682 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
103683 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
103684 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
103685 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
103686 +account_16283 account 0-2-4 16283 NULL nohasharray
103687 +mirror_status_16283 mirror_status 5 16283 &account_16283
103688 +retry_instruction_16285 retry_instruction 2 16285 NULL
103689 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
103690 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
103691 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
103692 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
103693 +wb_map_16301 wb_map 2 16301 NULL
103694 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
103695 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
103696 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
103697 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
103698 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
103699 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
103700 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
103701 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
103702 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
103703 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
103704 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
103705 +raid10_resize_16537 raid10_resize 2 16537 NULL
103706 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
103707 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
103708 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
103709 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
103710 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
103711 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
103712 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
103713 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
103714 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
103715 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
103716 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
103717 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
103718 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
103719 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
103720 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
103721 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
103722 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
103723 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
103724 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
103725 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
103726 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
103727 +st_write_16874 st_write 3 16874 NULL
103728 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
103729 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
103730 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
103731 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
103732 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
103733 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
103734 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
103735 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
103736 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
103737 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
103738 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
103739 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
103740 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
103741 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
103742 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
103743 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
103744 +mac_address_string_17091 mac_address_string 0 17091 NULL
103745 +entry_length_17093 entry_length 0 17093 NULL
103746 +sys_preadv_17100 sys_preadv 3 17100 NULL
103747 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
103748 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
103749 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
103750 +sep_read_17161 sep_read 3 17161 NULL
103751 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
103752 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
103753 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
103754 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
103755 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
103756 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
103757 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
103758 +to_oblock_17254 to_oblock 0-1 17254 NULL
103759 +unpack_value_17259 unpack_value 1 17259 NULL
103760 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
103761 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
103762 +alloc_ep_17269 alloc_ep 1 17269 NULL
103763 +pg_read_17276 pg_read 3 17276 NULL
103764 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
103765 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
103766 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
103767 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
103768 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
103769 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
103770 +skb_pad_17302 skb_pad 2 17302 NULL
103771 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
103772 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
103773 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
103774 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
103775 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
103776 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
103777 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
103778 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
103779 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
103780 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
103781 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
103782 +compat_cmd_17465 compat_cmd 2 17465 NULL
103783 +probe_bios_17467 probe_bios 1 17467 NULL
103784 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
103785 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
103786 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
103787 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
103788 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
103789 +copy_from_user_17559 copy_from_user 3 17559 NULL
103790 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
103791 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
103792 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
103793 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
103794 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
103795 +osst_execute_17607 osst_execute 7-6 17607 NULL
103796 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
103797 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
103798 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
103799 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
103800 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
103801 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
103802 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
103803 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
103804 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
103805 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
103806 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
103807 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
103808 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
103809 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
103810 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
103811 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
103812 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
103813 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
103814 +perf_clock_17787 perf_clock 0 17787 NULL
103815 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
103816 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
103817 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
103818 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
103819 +count_leafs_17842 count_leafs 0 17842 NULL
103820 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
103821 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
103822 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
103823 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
103824 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
103825 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
103826 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
103827 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
103828 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
103829 +recover_head_17904 recover_head 3 17904 NULL
103830 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
103831 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
103832 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
103833 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
103834 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
103835 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
103836 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
103837 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
103838 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
103839 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
103840 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
103841 +fill_read_18019 fill_read 0 18019 NULL
103842 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
103843 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
103844 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
103845 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
103846 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
103847 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
103848 +packet_came_18072 packet_came 3 18072 NULL
103849 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
103850 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
103851 +get_vm_area_18080 get_vm_area 1 18080 NULL
103852 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
103853 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
103854 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
103855 +svc_getnl_18120 svc_getnl 0 18120 NULL
103856 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
103857 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
103858 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
103859 +_has_tag_18169 _has_tag 2 18169 NULL
103860 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
103861 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
103862 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
103863 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
103864 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
103865 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
103866 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
103867 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
103868 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
103869 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
103870 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
103871 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
103872 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
103873 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
103874 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
103875 +um_idi_write_18293 um_idi_write 3 18293 NULL
103876 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
103877 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
103878 +vga_r_18310 vga_r 0 18310 NULL
103879 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
103880 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
103881 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
103882 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
103883 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
103884 +ep_io_18367 ep_io 0 18367 NULL
103885 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
103886 +ci_role_write_18388 ci_role_write 3 18388 NULL
103887 +__video_register_device_18399 __video_register_device 3 18399 NULL
103888 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
103889 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
103890 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
103891 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
103892 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
103893 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
103894 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
103895 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
103896 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
103897 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
103898 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
103899 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
103900 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
103901 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
103902 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
103903 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
103904 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
103905 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
103906 +debug_output_18575 debug_output 3 18575 NULL
103907 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
103908 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
103909 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
103910 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
103911 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
103912 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
103913 +from_buffer_18625 from_buffer 3 18625 NULL
103914 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
103915 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
103916 +unmap_page_18665 unmap_page 2-3 18665 NULL
103917 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
103918 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
103919 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
103920 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
103921 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
103922 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
103923 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
103924 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
103925 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
103926 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
103927 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
103928 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
103929 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
103930 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
103931 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
103932 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
103933 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
103934 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
103935 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
103936 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
103937 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
103938 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
103939 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
103940 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
103941 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
103942 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
103943 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
103944 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
103945 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
103946 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
103947 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
103948 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
103949 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
103950 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
103951 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
103952 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
103953 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
103954 +huge_page_size_19008 huge_page_size 0 19008 NULL
103955 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
103956 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
103957 +revalidate_19043 revalidate 2 19043 NULL
103958 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
103959 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
103960 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
103961 +msix_map_region_19072 msix_map_region 2 19072 NULL
103962 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
103963 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
103964 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
103965 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
103966 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
103967 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
103968 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
103969 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
103970 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
103971 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
103972 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
103973 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
103974 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
103975 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
103976 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
103977 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
103978 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
103979 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
103980 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
103981 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
103982 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
103983 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
103984 +qc_capture_19298 qc_capture 3 19298 NULL
103985 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
103986 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
103987 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
103988 +debug_read_19322 debug_read 3 19322 NULL
103989 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
103990 +closure_sub_19359 closure_sub 2 19359 NULL
103991 +read_zero_19366 read_zero 3 19366 NULL
103992 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
103993 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
103994 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
103995 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
103996 +__phys_addr_19434 __phys_addr 0 19434 NULL
103997 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
103998 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
103999 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
104000 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
104001 +sky2_read16_19475 sky2_read16 0 19475 NULL
104002 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
104003 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
104004 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
104005 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
104006 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
104007 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
104008 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
104009 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
104010 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
104011 +nfsd_read_19568 nfsd_read 5 19568 NULL
104012 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
104013 +bm_status_read_19583 bm_status_read 3 19583 NULL
104014 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
104015 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
104016 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
104017 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
104018 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
104019 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
104020 +bio_detain_19690 bio_detain 2 19690 NULL
104021 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
104022 +read_reg_19723 read_reg 0 19723 NULL
104023 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
104024 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
104025 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
104026 +p9_client_read_19750 p9_client_read 5 19750 NULL
104027 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
104028 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
104029 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
104030 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
104031 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
104032 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
104033 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
104034 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
104035 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
104036 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
104037 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
104038 +__nla_put_19857 __nla_put 3 19857 NULL
104039 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
104040 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
104041 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
104042 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
104043 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
104044 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
104045 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
104046 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
104047 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
104048 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
104049 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
104050 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
104051 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
104052 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
104053 +team_options_register_20091 team_options_register 3 20091 NULL
104054 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
104055 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
104056 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
104057 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
104058 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
104059 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
104060 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
104061 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
104062 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
104063 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
104064 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
104065 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
104066 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
104067 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
104068 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
104069 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
104070 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
104071 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
104072 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
104073 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
104074 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
104075 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
104076 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
104077 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
104078 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
104079 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
104080 +read_buf_20469 read_buf 2 20469 NULL
104081 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
104082 +fast_user_write_20494 fast_user_write 5 20494 NULL
104083 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
104084 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
104085 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
104086 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
104087 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
104088 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
104089 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
104090 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
104091 +venus_create_20555 venus_create 4 20555 NULL
104092 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
104093 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
104094 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
104095 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
104096 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
104097 +lirc_write_20604 lirc_write 3 20604 NULL
104098 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
104099 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
104100 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
104101 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
104102 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
104103 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
104104 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
104105 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
104106 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
104107 +cpumask_size_20683 cpumask_size 0 20683 NULL
104108 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
104109 +gru_vtop_20689 gru_vtop 2 20689 NULL
104110 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
104111 +__maestro_read_20700 __maestro_read 0 20700 NULL
104112 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
104113 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
104114 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
104115 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
104116 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
104117 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
104118 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
104119 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
104120 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
104121 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
104122 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
104123 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
104124 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
104125 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
104126 +sys_sendto_20809 sys_sendto 6 20809 NULL
104127 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
104128 +strndup_user_20819 strndup_user 2 20819 NULL
104129 +calc_layout_20829 calc_layout 3 20829 NULL
104130 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
104131 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
104132 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
104133 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
104134 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
104135 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
104136 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
104137 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
104138 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
104139 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
104140 +htable_bits_20933 htable_bits 0 20933 NULL
104141 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
104142 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
104143 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
104144 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
104145 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
104146 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
104147 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
104148 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
104149 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
104150 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
104151 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
104152 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
104153 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
104154 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
104155 +multipath_status_21094 multipath_status 5 21094 NULL
104156 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
104157 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
104158 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
104159 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
104160 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
104161 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
104162 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
104163 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
104164 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
104165 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
104166 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
104167 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
104168 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
104169 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
104170 +input_ff_create_21240 input_ff_create 2 21240 NULL
104171 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
104172 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
104173 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
104174 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
104175 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
104176 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
104177 +add_res_range_21310 add_res_range 4 21310 NULL
104178 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
104179 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
104180 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
104181 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
104182 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
104183 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
104184 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
104185 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
104186 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
104187 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
104188 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
104189 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
104190 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
104191 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
104192 +concat_writev_21451 concat_writev 3 21451 NULL
104193 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
104194 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
104195 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
104196 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
104197 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
104198 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
104199 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
104200 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
104201 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
104202 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
104203 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
104204 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
104205 +validate_nnode_21638 validate_nnode 0 21638 NULL
104206 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
104207 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
104208 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
104209 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
104210 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
104211 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
104212 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
104213 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
104214 +vm_brk_21739 vm_brk 1 21739 NULL
104215 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
104216 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
104217 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
104218 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
104219 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
104220 +min_odd_21802 min_odd 0 21802 NULL
104221 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
104222 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
104223 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
104224 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
104225 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
104226 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
104227 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
104228 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
104229 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
104230 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
104231 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
104232 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
104233 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
104234 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
104235 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
104236 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
104237 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
104238 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
104239 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
104240 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
104241 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
104242 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
104243 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
104244 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
104245 +write_opcode_22082 write_opcode 2 22082 NULL
104246 +mem_rw_22085 mem_rw 3 22085 NULL
104247 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
104248 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
104249 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
104250 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
104251 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
104252 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
104253 +compat_insn_22142 compat_insn 2 22142 NULL
104254 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
104255 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
104256 +fls_22210 fls 0 22210 NULL
104257 +mem_write_22232 mem_write 3 22232 NULL
104258 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
104259 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
104260 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
104261 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
104262 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
104263 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
104264 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
104265 +extend_brk_22301 extend_brk 0 22301 NULL
104266 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
104267 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
104268 +get_segment_base_22324 get_segment_base 0 22324 NULL
104269 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
104270 +atomic_read_22342 atomic_read 0 22342 NULL
104271 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
104272 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
104273 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
104274 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
104275 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
104276 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
104277 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
104278 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
104279 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
104280 +zoran_write_22404 zoran_write 3 22404 NULL
104281 +queue_reply_22416 queue_reply 3 22416 NULL
104282 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
104283 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
104284 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
104285 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
104286 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
104287 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
104288 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
104289 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
104290 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
104291 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
104292 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
104293 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
104294 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
104295 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
104296 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
104297 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
104298 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
104299 +snapshot_read_22601 snapshot_read 3 22601 NULL
104300 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
104301 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
104302 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
104303 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
104304 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
104305 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
104306 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
104307 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
104308 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
104309 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
104310 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
104311 +map_22700 map 2 22700 NULL
104312 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
104313 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
104314 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
104315 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
104316 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
104317 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
104318 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
104319 +print_frame_22769 print_frame 0 22769 NULL
104320 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
104321 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
104322 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
104323 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
104324 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
104325 +create_attr_set_22861 create_attr_set 1 22861 NULL
104326 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
104327 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
104328 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
104329 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
104330 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
104331 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
104332 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
104333 +vme_get_size_22964 vme_get_size 0 22964 NULL
104334 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
104335 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
104336 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
104337 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
104338 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
104339 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
104340 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
104341 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
104342 +st_status_23032 st_status 5 23032 NULL
104343 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
104344 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
104345 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
104346 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
104347 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
104348 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
104349 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
104350 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
104351 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
104352 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
104353 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
104354 +fls_long_23096 fls_long 0 23096 NULL
104355 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
104356 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
104357 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
104358 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
104359 +__clear_user_23118 __clear_user 0 23118 NULL
104360 +dm_write_async_23120 dm_write_async 3 23120 NULL
104361 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
104362 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
104363 +read_file_ani_23161 read_file_ani 3 23161 NULL
104364 +ioremap_23172 ioremap 1-2 23172 NULL
104365 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
104366 +usblp_write_23178 usblp_write 3 23178 NULL
104367 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
104368 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
104369 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
104370 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
104371 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
104372 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
104373 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
104374 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
104375 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
104376 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
104377 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
104378 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
104379 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
104380 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
104381 +doc_probe_23285 doc_probe 1 23285 NULL
104382 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
104383 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
104384 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
104385 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
104386 +page_readlink_23346 page_readlink 3 23346 NULL
104387 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
104388 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
104389 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
104390 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
104391 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
104392 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
104393 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
104394 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
104395 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
104396 +event_filter_read_23494 event_filter_read 3 23494 NULL
104397 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
104398 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
104399 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
104400 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
104401 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
104402 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
104403 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
104404 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
104405 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
104406 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
104407 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
104408 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
104409 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
104410 +sInW_23663 sInW 0 23663 NULL
104411 +SyS_connect_23669 SyS_connect 3 23669 NULL
104412 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
104413 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
104414 +cx18_read_23699 cx18_read 3 23699 NULL
104415 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
104416 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
104417 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
104418 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
104419 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
104420 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
104421 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
104422 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
104423 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
104424 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
104425 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
104426 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
104427 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
104428 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
104429 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
104430 +p54_init_common_23850 p54_init_common 1 23850 NULL
104431 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
104432 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
104433 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
104434 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
104435 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
104436 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
104437 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
104438 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
104439 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
104440 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
104441 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
104442 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
104443 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
104444 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
104445 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
104446 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
104447 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
104448 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
104449 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
104450 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
104451 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
104452 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
104453 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
104454 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
104455 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
104456 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
104457 +mpu401_read_24126 mpu401_read 3 24126 NULL
104458 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
104459 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
104460 +set_discard_24162 set_discard 2 24162 NULL
104461 +adu_read_24177 adu_read 3 24177 NULL
104462 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
104463 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
104464 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
104465 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
104466 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
104467 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
104468 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
104469 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
104470 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
104471 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
104472 +thin_status_24278 thin_status 5 24278 NULL
104473 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
104474 +msg_size_24288 msg_size 0 24288 NULL
104475 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
104476 +map_page_24298 map_page 3-4 24298 NULL
104477 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
104478 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
104479 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
104480 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
104481 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
104482 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
104483 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
104484 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
104485 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
104486 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
104487 +igetword_24373 igetword 0 24373 NULL
104488 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
104489 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
104490 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
104491 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
104492 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
104493 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
104494 +smk_user_access_24440 smk_user_access 3 24440 NULL
104495 +page_address_24444 page_address 0 24444 NULL
104496 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
104497 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
104498 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
104499 +pd_video_read_24510 pd_video_read 3 24510 NULL
104500 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
104501 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
104502 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
104503 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
104504 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
104505 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
104506 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
104507 +count_preds_24600 count_preds 0 24600 NULL
104508 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
104509 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
104510 +context_alloc_24645 context_alloc 3 24645 NULL
104511 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
104512 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
104513 +read_fs_24717 read_fs 0 24717 NULL
104514 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
104515 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
104516 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
104517 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
104518 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
104519 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
104520 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
104521 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
104522 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
104523 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
104524 +cache_read_24790 cache_read 3 24790 NULL
104525 +unpack_str_24798 unpack_str 0 24798 NULL
104526 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
104527 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
104528 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
104529 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
104530 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
104531 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
104532 +setup_buffering_24872 setup_buffering 3 24872 NULL
104533 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
104534 +queues_read_24877 queues_read 3 24877 NULL nohasharray
104535 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
104536 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
104537 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
104538 +next_token_24929 next_token 0 24929 NULL
104539 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
104540 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
104541 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
104542 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
104543 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
104544 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
104545 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
104546 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
104547 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
104548 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
104549 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
104550 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
104551 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
104552 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
104553 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
104554 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
104555 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
104556 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
104557 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
104558 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
104559 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
104560 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
104561 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
104562 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
104563 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
104564 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
104565 +stripe_status_25259 stripe_status 5 25259 NULL
104566 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
104567 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
104568 +vfs_writev_25278 vfs_writev 3 25278 NULL
104569 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
104570 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
104571 +help_25316 help 5 25316 NULL nohasharray
104572 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
104573 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
104574 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
104575 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
104576 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
104577 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
104578 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
104579 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
104580 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
104581 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
104582 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
104583 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
104584 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
104585 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
104586 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
104587 +sb_permission_25523 sb_permission 0 25523 NULL
104588 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
104589 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
104590 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
104591 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
104592 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
104593 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
104594 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
104595 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
104596 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
104597 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
104598 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
104599 +__direct_map_25647 __direct_map 5-6 25647 NULL
104600 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
104601 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
104602 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
104603 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
104604 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
104605 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
104606 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
104607 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
104608 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
104609 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
104610 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
104611 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
104612 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
104613 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
104614 +sg_read_25799 sg_read 3 25799 NULL
104615 +system_enable_read_25815 system_enable_read 3 25815 NULL
104616 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
104617 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
104618 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
104619 +parport_read_25855 parport_read 0 25855 NULL
104620 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
104621 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
104622 +key_attr_size_25865 key_attr_size 0 25865 NULL
104623 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
104624 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
104625 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
104626 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
104627 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
104628 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
104629 +rcname_read_25919 rcname_read 3 25919 NULL
104630 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
104631 +key_flags_read_25931 key_flags_read 3 25931 NULL
104632 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
104633 +flush_25957 flush 2 25957 NULL
104634 +video_register_device_25971 video_register_device 3 25971 NULL
104635 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
104636 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
104637 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
104638 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
104639 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
104640 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
104641 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
104642 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
104643 +tun_do_read_26047 tun_do_read 5 26047 NULL
104644 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
104645 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
104646 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
104647 +skb_cow_26138 skb_cow 2 26138 NULL
104648 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
104649 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
104650 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
104651 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
104652 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
104653 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
104654 +disk_devt_26180 disk_devt 0 26180 NULL
104655 +get_registers_26187 get_registers 3 26187 NULL
104656 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
104657 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
104658 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
104659 +mce_write_26201 mce_write 3 26201 NULL
104660 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
104661 +bio_split_26235 bio_split 2 26235 NULL
104662 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
104663 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
104664 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
104665 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
104666 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
104667 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
104668 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
104669 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
104670 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
104671 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
104672 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
104673 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
104674 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
104675 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
104676 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
104677 +read_vmcore_26501 read_vmcore 3 26501 NULL
104678 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
104679 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
104680 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
104681 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
104682 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
104683 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
104684 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
104685 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
104686 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
104687 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
104688 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
104689 +pack_value_26625 pack_value 1 26625 NULL
104690 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
104691 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
104692 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
104693 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
104694 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
104695 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
104696 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
104697 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
104698 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
104699 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
104700 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
104701 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
104702 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
104703 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
104704 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
104705 +smk_write_load_26829 smk_write_load 3 26829 NULL
104706 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
104707 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
104708 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
104709 +scnprint_id_26842 scnprint_id 3 26842 NULL
104710 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
104711 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
104712 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
104713 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
104714 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
104715 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
104716 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
104717 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
104718 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
104719 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
104720 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
104721 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
104722 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
104723 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
104724 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
104725 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
104726 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
104727 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
104728 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
104729 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
104730 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
104731 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
104732 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
104733 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
104734 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
104735 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
104736 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
104737 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
104738 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
104739 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
104740 +pms_capture_27142 pms_capture 4 27142 NULL
104741 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
104742 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
104743 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
104744 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
104745 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
104746 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
104747 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
104748 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
104749 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
104750 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
104751 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
104752 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
104753 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
104754 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
104755 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
104756 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
104757 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
104758 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
104759 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
104760 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
104761 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
104762 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
104763 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
104764 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
104765 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
104766 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
104767 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
104768 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
104769 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
104770 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
104771 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
104772 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
104773 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
104774 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
104775 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
104776 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
104777 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
104778 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
104779 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
104780 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
104781 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
104782 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
104783 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
104784 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
104785 +qword_get_27670 qword_get 0 27670 NULL
104786 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
104787 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
104788 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
104789 +evm_write_key_27715 evm_write_key 3 27715 NULL
104790 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
104791 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
104792 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
104793 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
104794 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
104795 +kcalloc_27770 kcalloc 1-2 27770 NULL
104796 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
104797 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
104798 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
104799 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
104800 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
104801 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
104802 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
104803 +read_profile_27859 read_profile 3 27859 NULL
104804 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
104805 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
104806 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
104807 +gluebi_write_27905 gluebi_write 3 27905 NULL
104808 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
104809 +bm_find_next_27929 bm_find_next 2 27929 NULL
104810 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
104811 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
104812 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
104813 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
104814 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
104815 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
104816 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
104817 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
104818 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
104819 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
104820 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
104821 +pool_status_28055 pool_status 5 28055 NULL
104822 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
104823 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
104824 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
104825 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
104826 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
104827 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
104828 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
104829 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
104830 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
104831 +video_read_28148 video_read 3 28148 NULL
104832 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
104833 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
104834 +vread_28173 vread 0 28173 NULL
104835 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
104836 +d_path_28198 d_path 0 28198 NULL
104837 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
104838 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
104839 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
104840 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
104841 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
104842 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
104843 +usemap_size_28281 usemap_size 0 28281 NULL
104844 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
104845 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
104846 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
104847 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
104848 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
104849 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
104850 +snapshot_write_28351 snapshot_write 3 28351 NULL
104851 +sys_writev_28384 sys_writev 3 28384 NULL
104852 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
104853 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
104854 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
104855 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
104856 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
104857 +__split_large_page_28429 __split_large_page 2 28429 NULL
104858 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
104859 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
104860 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
104861 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
104862 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
104863 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
104864 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
104865 +max_response_pages_28492 max_response_pages 0 28492 NULL
104866 +clear_discard_28494 clear_discard 2 28494 NULL
104867 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
104868 +__next_node_28521 __next_node 1 28521 NULL
104869 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
104870 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
104871 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
104872 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
104873 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
104874 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
104875 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
104876 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
104877 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
104878 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
104879 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
104880 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
104881 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
104882 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
104883 +_set_range_28627 _set_range 3 28627 NULL
104884 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
104885 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
104886 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
104887 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
104888 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
104889 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
104890 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
104891 +spi_execute_28736 spi_execute 5 28736 NULL
104892 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
104893 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
104894 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
104895 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
104896 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
104897 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
104898 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
104899 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
104900 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
104901 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
104902 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
104903 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
104904 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
104905 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
104906 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
104907 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
104908 +to_cblock_28899 to_cblock 0-1 28899 NULL
104909 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
104910 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
104911 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
104912 +push_rx_28939 push_rx 3 28939 NULL
104913 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
104914 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
104915 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
104916 +bin_uuid_28999 bin_uuid 3 28999 NULL
104917 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
104918 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
104919 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
104920 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
104921 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
104922 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
104923 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
104924 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
104925 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
104926 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
104927 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
104928 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
104929 +snprintf_29125 snprintf 0 29125 NULL
104930 +iov_shorten_29130 iov_shorten 0 29130 NULL
104931 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
104932 +reshape_ring_29147 reshape_ring 2 29147 NULL
104933 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
104934 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
104935 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
104936 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
104937 +__mm_populate_29204 __mm_populate 1 29204 NULL
104938 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
104939 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
104940 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
104941 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
104942 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
104943 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
104944 +recover_peb_29238 recover_peb 6-7 29238 NULL
104945 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
104946 +block_div_29268 block_div 0-1-2 29268 NULL
104947 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
104948 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
104949 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
104950 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
104951 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
104952 +tun_put_user_29337 tun_put_user 5 29337 NULL
104953 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
104954 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
104955 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
104956 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
104957 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
104958 +mempool_create_29437 mempool_create 1 29437 NULL
104959 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
104960 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
104961 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
104962 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
104963 +do_register_entry_29478 do_register_entry 4 29478 NULL
104964 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
104965 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
104966 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
104967 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
104968 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
104969 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
104970 +set_brk_29551 set_brk 1 29551 NULL nohasharray
104971 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
104972 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
104973 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
104974 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
104975 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
104976 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
104977 +slots_per_page_29601 slots_per_page 0 29601 NULL
104978 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
104979 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
104980 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
104981 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
104982 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
104983 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
104984 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
104985 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
104986 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
104987 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
104988 +probes_write_29711 probes_write 3 29711 NULL
104989 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
104990 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
104991 +std_nic_write_29752 std_nic_write 3 29752 NULL
104992 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
104993 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
104994 +dbAlloc_29794 dbAlloc 0 29794 NULL
104995 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
104996 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
104997 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
104998 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
104999 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
105000 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
105001 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
105002 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
105003 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
105004 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
105005 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
105006 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
105007 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
105008 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
105009 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
105010 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
105011 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
105012 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
105013 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
105014 +drp_wmove_30043 drp_wmove 4 30043 NULL
105015 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
105016 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
105017 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
105018 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
105019 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
105020 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
105021 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
105022 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
105023 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
105024 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
105025 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
105026 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
105027 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
105028 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
105029 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
105030 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
105031 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
105032 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
105033 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
105034 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
105035 +compat_readv_30273 compat_readv 3 30273 NULL
105036 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
105037 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
105038 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
105039 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
105040 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
105041 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
105042 +resource_from_user_30341 resource_from_user 3 30341 NULL
105043 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
105044 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
105045 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
105046 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
105047 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
105048 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
105049 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
105050 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
105051 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
105052 +mq_create_30425 mq_create 1 30425 NULL
105053 +enable_write_30456 enable_write 3 30456 NULL
105054 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
105055 +urandom_read_30462 urandom_read 3 30462 NULL
105056 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
105057 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
105058 +write_head_30481 write_head 4 30481 NULL
105059 +adu_write_30487 adu_write 3 30487 NULL
105060 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
105061 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
105062 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
105063 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
105064 +set_le_30581 set_le 4 30581 NULL
105065 +from_cblock_30582 from_cblock 0-1 30582 NULL
105066 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
105067 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
105068 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
105069 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
105070 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
105071 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
105072 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
105073 +agp_remap_30665 agp_remap 2 30665 NULL
105074 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
105075 +il_free_pages_30692 il_free_pages 2 30692 NULL
105076 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
105077 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
105078 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
105079 +snapshot_status_30744 snapshot_status 5 30744 NULL
105080 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
105081 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
105082 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
105083 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
105084 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
105085 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
105086 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
105087 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
105088 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
105089 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
105090 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
105091 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
105092 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
105093 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
105094 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
105095 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
105096 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
105097 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
105098 +sys_mincore_31079 sys_mincore 1 31079 NULL
105099 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
105100 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
105101 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
105102 +depth_read_31112 depth_read 3 31112 NULL
105103 +ssb_read16_31139 ssb_read16 0 31139 NULL
105104 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
105105 +size_inside_page_31141 size_inside_page 0 31141 NULL
105106 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
105107 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
105108 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
105109 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
105110 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
105111 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
105112 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
105113 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
105114 +__read_reg_31216 __read_reg 0 31216 NULL
105115 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
105116 +cyy_readb_31240 cyy_readb 0 31240 NULL
105117 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
105118 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
105119 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
105120 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
105121 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
105122 +command_file_write_31318 command_file_write 3 31318 NULL
105123 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
105124 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
105125 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
105126 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
105127 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
105128 +inb_31388 inb 0 31388 NULL
105129 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
105130 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
105131 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
105132 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
105133 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
105134 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
105135 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
105136 +do_fcntl_31468 do_fcntl 3 31468 NULL
105137 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
105138 +alg_setkey_31485 alg_setkey 3 31485 NULL
105139 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
105140 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
105141 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
105142 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
105143 +hidraw_write_31536 hidraw_write 3 31536 NULL
105144 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
105145 +usbvision_read_31555 usbvision_read 3 31555 NULL
105146 +normalize_31566 normalize 0-1-2 31566 NULL
105147 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
105148 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
105149 +osst_write_31581 osst_write 3 31581 NULL
105150 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
105151 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
105152 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
105153 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
105154 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
105155 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
105156 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
105157 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
105158 +__lgread_31668 __lgread 4 31668 NULL
105159 +symbol_string_31670 symbol_string 0 31670 NULL
105160 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
105161 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
105162 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
105163 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
105164 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
105165 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
105166 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
105167 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
105168 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
105169 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
105170 +muldiv64_31743 muldiv64 2-3 31743 NULL
105171 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
105172 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
105173 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
105174 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
105175 +get_count_order_31800 get_count_order 0 31800 NULL
105176 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
105177 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
105178 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
105179 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
105180 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
105181 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
105182 +xattr_permission_31907 xattr_permission 0 31907 NULL
105183 +new_dir_31919 new_dir 3 31919 NULL
105184 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
105185 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
105186 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
105187 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
105188 +vb2_write_31948 vb2_write 3 31948 NULL
105189 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
105190 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
105191 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
105192 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
105193 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
105194 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
105195 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
105196 +calc_hmac_32010 calc_hmac 3 32010 NULL
105197 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
105198 +aead_len_32021 aead_len 0 32021 NULL
105199 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
105200 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
105201 +stk_read_32038 stk_read 3 32038 NULL
105202 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
105203 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
105204 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
105205 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
105206 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
105207 +bio_alloc_32095 bio_alloc 2 32095 NULL
105208 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
105209 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
105210 +disk_status_32120 disk_status 4 32120 NULL
105211 +venus_link_32165 venus_link 5 32165 NULL
105212 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
105213 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
105214 +load_header_32183 load_header 0 32183 NULL
105215 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
105216 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
105217 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
105218 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
105219 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
105220 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
105221 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
105222 +hex_string_32310 hex_string 0 32310 NULL
105223 +SyS_select_32319 SyS_select 1 32319 NULL
105224 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
105225 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
105226 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
105227 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
105228 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
105229 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
105230 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
105231 +local_clock_32385 local_clock 0 32385 NULL
105232 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
105233 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
105234 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
105235 +log_text_32428 log_text 0 32428 NULL
105236 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
105237 +hid_input_report_32458 hid_input_report 4 32458 NULL
105238 +cache_status_32462 cache_status 5 32462 NULL
105239 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
105240 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
105241 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
105242 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
105243 +disconnect_32521 disconnect 4 32521 NULL
105244 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
105245 +ilo_read_32531 ilo_read 3 32531 NULL
105246 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
105247 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
105248 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
105249 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
105250 +__first_node_32558 __first_node 0 32558 NULL
105251 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
105252 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
105253 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
105254 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
105255 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
105256 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
105257 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
105258 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
105259 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
105260 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
105261 +kvmalloc_32646 kvmalloc 1 32646 NULL
105262 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
105263 +generic_readlink_32654 generic_readlink 3 32654 NULL
105264 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
105265 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
105266 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
105267 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
105268 +get_arg_page_32746 get_arg_page 2 32746 NULL
105269 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
105270 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
105271 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
105272 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
105273 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
105274 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
105275 +vga_rseq_32848 vga_rseq 0 32848 NULL
105276 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
105277 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
105278 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
105279 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
105280 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
105281 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
105282 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
105283 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
105284 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
105285 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
105286 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
105287 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
105288 +compat_filldir_32999 compat_filldir 3 32999 NULL
105289 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
105290 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
105291 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
105292 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
105293 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
105294 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
105295 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
105296 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
105297 +alloc_tio_33077 alloc_tio 3 33077 NULL
105298 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
105299 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
105300 +write_node_33121 write_node 4 33121 NULL
105301 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
105302 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
105303 +__len_within_target_33132 __len_within_target 0 33132 NULL
105304 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
105305 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
105306 +pp_read_33210 pp_read 3 33210 NULL
105307 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
105308 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
105309 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
105310 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
105311 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
105312 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
105313 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
105314 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
105315 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
105316 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
105317 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
105318 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
105319 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
105320 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
105321 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
105322 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
105323 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
105324 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
105325 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
105326 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
105327 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
105328 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
105329 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
105330 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
105331 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
105332 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
105333 +create_entry_33479 create_entry 2 33479 NULL
105334 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
105335 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
105336 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
105337 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
105338 +res_counter_read_33499 res_counter_read 4 33499 NULL
105339 +fb_read_33506 fb_read 3 33506 NULL
105340 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
105341 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
105342 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
105343 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
105344 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
105345 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
105346 +dup_array_33551 dup_array 3 33551 NULL
105347 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
105348 +count_subheaders_33591 count_subheaders 0 33591 NULL
105349 +scsi_execute_33596 scsi_execute 5 33596 NULL
105350 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
105351 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
105352 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
105353 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
105354 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
105355 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
105356 +inw_p_33668 inw_p 0 33668 NULL
105357 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
105358 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
105359 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
105360 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
105361 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
105362 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
105363 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
105364 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
105365 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
105366 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
105367 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
105368 +Read_hfc_33755 Read_hfc 0 33755 NULL
105369 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
105370 +hashtab_create_33769 hashtab_create 3 33769 NULL
105371 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
105372 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
105373 +find_next_offset_33804 find_next_offset 3 33804 NULL
105374 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
105375 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
105376 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
105377 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
105378 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
105379 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
105380 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
105381 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
105382 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
105383 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
105384 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
105385 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
105386 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
105387 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
105388 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
105389 +ppp_write_34034 ppp_write 3 34034 NULL
105390 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
105391 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
105392 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
105393 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
105394 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
105395 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
105396 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
105397 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
105398 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
105399 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
105400 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
105401 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
105402 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
105403 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
105404 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
105405 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
105406 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
105407 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
105408 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
105409 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
105410 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
105411 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
105412 +__insert_34349 __insert 2-3 34349 NULL
105413 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
105414 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
105415 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
105416 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
105417 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
105418 +ea_read_34378 ea_read 0 34378 NULL
105419 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
105420 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
105421 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
105422 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
105423 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
105424 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
105425 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
105426 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
105427 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
105428 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
105429 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
105430 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
105431 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
105432 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
105433 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
105434 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
105435 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
105436 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
105437 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
105438 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
105439 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
105440 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
105441 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
105442 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
105443 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
105444 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
105445 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
105446 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
105447 +port_print_34704 port_print 3 34704 NULL
105448 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
105449 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
105450 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
105451 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
105452 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
105453 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
105454 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
105455 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
105456 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
105457 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
105458 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
105459 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
105460 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
105461 +msg_print_text_34889 msg_print_text 0 34889 NULL
105462 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
105463 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
105464 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
105465 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
105466 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
105467 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
105468 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
105469 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
105470 +Realloc_34961 Realloc 2 34961 NULL
105471 +mq_lookup_34990 mq_lookup 2 34990 NULL
105472 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
105473 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
105474 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
105475 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
105476 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
105477 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
105478 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
105479 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
105480 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
105481 +store_ifalias_35088 store_ifalias 4 35088 NULL
105482 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
105483 +capi_write_35104 capi_write 3 35104 NULL nohasharray
105484 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
105485 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
105486 +pointer_35138 pointer 0 35138 NULL
105487 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
105488 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
105489 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
105490 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
105491 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
105492 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
105493 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
105494 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
105495 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
105496 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
105497 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
105498 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
105499 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
105500 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
105501 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
105502 +set_fd_set_35249 set_fd_set 1 35249 NULL
105503 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
105504 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
105505 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
105506 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
105507 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
105508 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
105509 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
105510 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
105511 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
105512 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
105513 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
105514 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
105515 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
105516 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
105517 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
105518 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
105519 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
105520 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
105521 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
105522 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
105523 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
105524 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
105525 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
105526 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
105527 +async_setkey_35521 async_setkey 3 35521 NULL
105528 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
105529 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
105530 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
105531 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
105532 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
105533 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
105534 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
105535 +ReadZReg_35604 ReadZReg 0 35604 NULL
105536 +kernel_readv_35617 kernel_readv 3 35617 NULL
105537 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
105538 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
105539 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
105540 +store_debug_level_35652 store_debug_level 3 35652 NULL
105541 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
105542 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
105543 +dm_table_create_35687 dm_table_create 3 35687 NULL
105544 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
105545 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
105546 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
105547 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
105548 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
105549 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
105550 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
105551 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
105552 +fls64_35862 fls64 0 35862 NULL
105553 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
105554 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
105555 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
105556 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
105557 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
105558 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
105559 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
105560 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
105561 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
105562 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
105563 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
105564 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
105565 +acl_alloc_35979 acl_alloc 1 35979 NULL
105566 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
105567 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
105568 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
105569 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
105570 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
105571 +account_shadowed_36048 account_shadowed 2 36048 NULL
105572 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
105573 +write_emulate_36065 write_emulate 2-4 36065 NULL
105574 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
105575 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
105576 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
105577 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
105578 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
105579 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
105580 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
105581 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
105582 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
105583 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
105584 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
105585 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
105586 +twl_set_36154 twl_set 2 36154 NULL
105587 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
105588 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
105589 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
105590 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
105591 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
105592 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
105593 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
105594 +is_dirty_36223 is_dirty 2 36223 NULL
105595 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
105596 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
105597 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
105598 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
105599 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
105600 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
105601 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
105602 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
105603 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
105604 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
105605 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
105606 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
105607 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
105608 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
105609 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
105610 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
105611 +lc_create_36332 lc_create 4 36332 NULL
105612 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
105613 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
105614 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
105615 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
105616 +to_sector_36361 to_sector 0-1 36361 NULL
105617 +tunables_read_36385 tunables_read 3 36385 NULL
105618 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
105619 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
105620 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
105621 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
105622 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
105623 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
105624 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
105625 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
105626 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
105627 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
105628 +get_param_l_36518 get_param_l 0 36518 NULL
105629 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
105630 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
105631 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
105632 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
105633 +get_entry_len_36549 get_entry_len 0 36549 NULL
105634 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
105635 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
105636 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
105637 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
105638 +__erst_read_36579 __erst_read 0 36579 NULL
105639 +put_cmsg_36589 put_cmsg 4 36589 NULL
105640 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
105641 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
105642 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
105643 +format_decode_36638 format_decode 0 36638 NULL
105644 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
105645 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
105646 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
105647 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
105648 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
105649 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
105650 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
105651 +sched_clock_36717 sched_clock 0 36717 NULL
105652 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
105653 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
105654 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
105655 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
105656 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
105657 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
105658 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
105659 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
105660 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
105661 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
105662 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
105663 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
105664 +cm_write_36858 cm_write 3 36858 NULL
105665 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
105666 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
105667 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
105668 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
105669 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
105670 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
105671 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
105672 +build_key_36931 build_key 1 36931 NULL
105673 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
105674 +write_leb_36957 write_leb 5 36957 NULL
105675 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
105676 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
105677 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
105678 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
105679 +setxattr_37006 setxattr 4 37006 NULL
105680 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
105681 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
105682 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
105683 +parse_command_37079 parse_command 2 37079 NULL
105684 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
105685 +tun_get_user_37094 tun_get_user 5 37094 NULL
105686 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
105687 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
105688 +msg_word_37164 msg_word 0 37164 NULL
105689 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
105690 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
105691 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
105692 +__do_replace_37227 __do_replace 5 37227 NULL
105693 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
105694 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
105695 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
105696 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
105697 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
105698 +c101_run_37279 c101_run 2 37279 NULL
105699 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
105700 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
105701 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
105702 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
105703 +send_msg_37323 send_msg 4 37323 NULL
105704 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
105705 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
105706 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
105707 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
105708 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
105709 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
105710 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
105711 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
105712 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
105713 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
105714 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
105715 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
105716 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
105717 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
105718 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
105719 +__remove_37457 __remove 2 37457 NULL
105720 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
105721 +get_est_timing_37484 get_est_timing 0 37484 NULL
105722 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
105723 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
105724 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
105725 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
105726 +hdr_size_37536 hdr_size 0 37536 NULL
105727 +a2p_37544 a2p 0-1 37544 NULL
105728 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
105729 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
105730 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
105731 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
105732 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
105733 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
105734 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
105735 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
105736 +check_pt_base_37635 check_pt_base 3 37635 NULL
105737 +alloc_fd_37637 alloc_fd 1 37637 NULL
105738 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
105739 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
105740 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
105741 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
105742 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
105743 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
105744 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
105745 +nametbl_header_37698 nametbl_header 2 37698 NULL
105746 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
105747 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
105748 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
105749 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
105750 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
105751 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
105752 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
105753 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
105754 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
105755 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
105756 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
105757 +deny_write_access_37813 deny_write_access 0 37813 NULL
105758 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
105759 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
105760 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
105761 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
105762 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
105763 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
105764 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
105765 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
105766 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
105767 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
105768 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
105769 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
105770 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
105771 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
105772 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
105773 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
105774 +vfs_readv_38011 vfs_readv 3 38011 NULL
105775 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
105776 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
105777 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
105778 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
105779 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
105780 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
105781 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
105782 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
105783 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
105784 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
105785 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
105786 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
105787 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
105788 +ep0_read_38095 ep0_read 3 38095 NULL
105789 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
105790 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
105791 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
105792 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
105793 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
105794 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
105795 +cdev_add_38176 cdev_add 2-3 38176 NULL
105796 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
105797 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
105798 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
105799 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
105800 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
105801 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
105802 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
105803 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
105804 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
105805 +from_dblock_38256 from_dblock 0-1 38256 NULL
105806 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
105807 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
105808 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
105809 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
105810 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
105811 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
105812 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
105813 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
105814 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
105815 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
105816 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
105817 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
105818 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
105819 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
105820 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
105821 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
105822 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
105823 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
105824 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
105825 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
105826 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
105827 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
105828 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
105829 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
105830 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
105831 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
105832 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
105833 +dev_names_read_38509 dev_names_read 3 38509 NULL
105834 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
105835 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
105836 +set_queue_count_38519 set_queue_count 0 38519 NULL
105837 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
105838 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
105839 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
105840 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
105841 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
105842 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
105843 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
105844 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
105845 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
105846 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
105847 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
105848 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
105849 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
105850 +cma_create_area_38642 cma_create_area 2 38642 NULL
105851 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
105852 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
105853 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
105854 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
105855 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
105856 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
105857 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
105858 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
105859 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
105860 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
105861 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
105862 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
105863 +udf_readpages_38761 udf_readpages 4 38761 NULL
105864 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
105865 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
105866 +err_decode_38804 err_decode 2 38804 NULL
105867 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
105868 +sys_select_38827 sys_select 1 38827 NULL
105869 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
105870 +direct_entry_38836 direct_entry 3 38836 NULL
105871 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
105872 +interfaces_38859 interfaces 2 38859 NULL
105873 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
105874 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
105875 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
105876 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
105877 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
105878 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
105879 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
105880 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
105881 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
105882 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
105883 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
105884 +udf_new_block_38999 udf_new_block 4 38999 NULL
105885 +get_nodes_39012 get_nodes 3 39012 NULL
105886 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
105887 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
105888 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
105889 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
105890 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
105891 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
105892 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
105893 +ea_foreach_39133 ea_foreach 0 39133 NULL
105894 +generic_permission_39150 generic_permission 0 39150 NULL
105895 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
105896 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
105897 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
105898 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
105899 +init_list_set_39188 init_list_set 2-3 39188 NULL
105900 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
105901 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
105902 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
105903 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
105904 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
105905 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
105906 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
105907 +drm_order_39244 drm_order 0 39244 NULL
105908 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
105909 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
105910 +__skb_cow_39254 __skb_cow 2 39254 NULL
105911 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
105912 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
105913 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
105914 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
105915 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
105916 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
105917 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
105918 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
105919 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
105920 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
105921 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
105922 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
105923 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
105924 +__send_to_port_39386 __send_to_port 3 39386 NULL
105925 +user_power_read_39414 user_power_read 3 39414 NULL
105926 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
105927 +sys_semop_39457 sys_semop 3 39457 NULL
105928 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
105929 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
105930 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
105931 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
105932 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
105933 +int_proc_write_39542 int_proc_write 3 39542 NULL
105934 +pp_write_39554 pp_write 3 39554 NULL
105935 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
105936 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
105937 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
105938 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
105939 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
105940 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
105941 +ext_depth_39607 ext_depth 0 39607 NULL
105942 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
105943 +sdio_readb_39618 sdio_readb 0 39618 NULL
105944 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
105945 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
105946 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
105947 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
105948 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
105949 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
105950 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
105951 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
105952 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
105953 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
105954 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
105955 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
105956 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
105957 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
105958 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
105959 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
105960 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
105961 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
105962 +pkt_add_39897 pkt_add 3 39897 NULL
105963 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
105964 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
105965 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
105966 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
105967 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
105968 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
105969 +__spi_async_39932 __spi_async 0 39932 NULL
105970 +__get_order_39935 __get_order 0 39935 NULL
105971 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
105972 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
105973 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
105974 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
105975 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
105976 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
105977 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
105978 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
105979 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
105980 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
105981 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
105982 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
105983 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
105984 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
105985 +add_tty_40055 add_tty 1 40055 NULL nohasharray
105986 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
105987 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
105988 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
105989 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
105990 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
105991 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
105992 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
105993 +pt_write_40159 pt_write 3 40159 NULL
105994 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
105995 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
105996 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
105997 +allocate_probes_40204 allocate_probes 1 40204 NULL
105998 +compat_put_long_40214 compat_put_long 1 40214 NULL
105999 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
106000 +osst_read_40237 osst_read 3 40237 NULL
106001 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
106002 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
106003 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
106004 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
106005 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
106006 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
106007 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
106008 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
106009 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
106010 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
106011 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
106012 +mmio_read_40348 mmio_read 4 40348 NULL
106013 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
106014 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
106015 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
106016 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
106017 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
106018 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
106019 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
106020 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
106021 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
106022 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
106023 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
106024 +tty_write_room_40495 tty_write_room 0 40495 NULL
106025 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
106026 +sg_phys_40507 sg_phys 0 40507 NULL
106027 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
106028 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
106029 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
106030 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
106031 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
106032 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
106033 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
106034 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
106035 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
106036 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
106037 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
106038 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
106039 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
106040 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
106041 +fops_read_40672 fops_read 3 40672 NULL
106042 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
106043 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
106044 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
106045 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
106046 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
106047 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
106048 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
106049 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
106050 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
106051 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
106052 +card_send_command_40757 card_send_command 3 40757 NULL
106053 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
106054 +pg_write_40766 pg_write 3 40766 NULL
106055 +show_list_40775 show_list 3 40775 NULL
106056 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
106057 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
106058 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
106059 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
106060 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
106061 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
106062 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
106063 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
106064 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
106065 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
106066 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
106067 +read_file_queue_40895 read_file_queue 3 40895 NULL
106068 +waiters_read_40902 waiters_read 3 40902 NULL
106069 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
106070 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
106071 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
106072 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
106073 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
106074 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
106075 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
106076 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
106077 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
106078 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
106079 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
106080 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
106081 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
106082 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
106083 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
106084 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
106085 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
106086 +dma_attach_41094 dma_attach 5-6 41094 NULL
106087 +provide_user_output_41105 provide_user_output 3 41105 NULL
106088 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
106089 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
106090 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
106091 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
106092 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
106093 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
106094 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
106095 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
106096 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
106097 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
106098 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
106099 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
106100 +erst_read_41260 erst_read 0 41260 NULL
106101 +__fprog_create_41263 __fprog_create 2 41263 NULL
106102 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
106103 +alloc_context_41283 alloc_context 1 41283 NULL
106104 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
106105 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
106106 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
106107 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
106108 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
106109 +kmp_init_41373 kmp_init 2 41373 NULL
106110 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
106111 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
106112 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
106113 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
106114 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
106115 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
106116 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
106117 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
106118 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
106119 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
106120 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
106121 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
106122 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
106123 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
106124 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
106125 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
106126 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
106127 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
106128 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
106129 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
106130 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
106131 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
106132 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
106133 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
106134 +vga_io_r_41609 vga_io_r 0 41609 NULL
106135 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
106136 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
106137 +a2mp_send_41615 a2mp_send 4 41615 NULL
106138 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
106139 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
106140 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
106141 +get_std_timing_41654 get_std_timing 0 41654 NULL
106142 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
106143 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
106144 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
106145 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
106146 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
106147 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
106148 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
106149 +fillonedir_41746 fillonedir 3 41746 NULL
106150 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
106151 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
106152 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
106153 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
106154 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
106155 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
106156 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
106157 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
106158 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
106159 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
106160 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
106161 +get_packet_41914 get_packet 3 41914 NULL
106162 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
106163 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
106164 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
106165 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
106166 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
106167 +read_gssp_41947 read_gssp 3 41947 NULL
106168 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
106169 +portnames_read_41958 portnames_read 3 41958 NULL
106170 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
106171 +dst_mtu_41969 dst_mtu 0 41969 NULL
106172 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
106173 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
106174 +lguest_map_42008 lguest_map 1-2 42008 NULL
106175 +pool_allocate_42012 pool_allocate 3 42012 NULL
106176 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
106177 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
106178 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
106179 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
106180 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
106181 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
106182 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
106183 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
106184 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
106185 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
106186 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
106187 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
106188 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
106189 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
106190 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
106191 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
106192 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
106193 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
106194 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
106195 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
106196 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
106197 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
106198 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
106199 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
106200 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
106201 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
106202 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
106203 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
106204 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
106205 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
106206 +free_cblock_42318 free_cblock 2 42318 NULL
106207 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
106208 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
106209 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
106210 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
106211 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
106212 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
106213 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
106214 +krng_get_random_42420 krng_get_random 3 42420 NULL
106215 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
106216 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
106217 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
106218 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
106219 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
106220 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
106221 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
106222 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
106223 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
106224 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
106225 +bypass_write_42498 bypass_write 3 42498 NULL
106226 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
106227 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
106228 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
106229 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
106230 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
106231 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
106232 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
106233 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
106234 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
106235 +map_state_42602 map_state 1 42602 NULL nohasharray
106236 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
106237 +nd_get_link_42603 nd_get_link 0 42603 NULL
106238 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
106239 +resp_write_42628 resp_write 2 42628 NULL
106240 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
106241 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
106242 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
106243 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
106244 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
106245 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
106246 +vb2_read_42703 vb2_read 3 42703 NULL
106247 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
106248 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
106249 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
106250 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
106251 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
106252 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
106253 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
106254 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
106255 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
106256 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
106257 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
106258 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
106259 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
106260 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
106261 +set_arg_42824 set_arg 3 42824 NULL
106262 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
106263 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
106264 +prandom_u32_42853 prandom_u32 0 42853 NULL
106265 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
106266 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
106267 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
106268 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
106269 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
106270 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
106271 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
106272 +hd_end_request_42904 hd_end_request 2 42904 NULL
106273 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
106274 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
106275 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
106276 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
106277 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
106278 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
106279 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
106280 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
106281 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
106282 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
106283 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
106284 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
106285 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
106286 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
106287 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
106288 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
106289 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
106290 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
106291 +uuid_string_43154 uuid_string 0 43154 NULL
106292 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
106293 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
106294 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
106295 +process_measurement_43190 process_measurement 0 43190 NULL
106296 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
106297 +uio_write_43202 uio_write 3 43202 NULL
106298 +iso_callback_43208 iso_callback 3 43208 NULL
106299 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
106300 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
106301 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
106302 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
106303 +fixup_leb_43256 fixup_leb 3 43256 NULL
106304 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
106305 +evtchn_write_43278 evtchn_write 3 43278 NULL
106306 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
106307 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
106308 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
106309 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
106310 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
106311 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
106312 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
106313 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
106314 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
106315 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
106316 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
106317 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
106318 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
106319 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
106320 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
106321 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
106322 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
106323 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
106324 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
106325 +do_readlink_43518 do_readlink 2 43518 NULL
106326 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
106327 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
106328 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
106329 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
106330 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
106331 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
106332 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
106333 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
106334 +proc_read_43614 proc_read 3 43614 NULL
106335 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
106336 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
106337 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
106338 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
106339 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
106340 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
106341 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
106342 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
106343 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
106344 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
106345 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
106346 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
106347 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
106348 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
106349 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
106350 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
106351 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
106352 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
106353 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
106354 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
106355 +read_flush_43851 read_flush 3 43851 NULL
106356 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
106357 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
106358 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
106359 +SendString_43928 SendString 3 43928 NULL
106360 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
106361 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
106362 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
106363 +nla_reserve_43984 nla_reserve 3 43984 NULL
106364 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
106365 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
106366 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
106367 +emit_flags_44006 emit_flags 4-3 44006 NULL
106368 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
106369 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
106370 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
106371 +load_discard_44083 load_discard 3 44083 NULL
106372 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
106373 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
106374 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
106375 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
106376 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
106377 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
106378 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
106379 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
106380 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
106381 +__set_free_44211 __set_free 2 44211 NULL
106382 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
106383 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
106384 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
106385 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
106386 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
106387 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
106388 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
106389 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
106390 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
106391 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
106392 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
106393 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
106394 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
106395 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
106396 +__is_discarded_44359 __is_discarded 2 44359 NULL
106397 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
106398 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
106399 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
106400 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
106401 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
106402 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
106403 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
106404 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
106405 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
106406 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
106407 +bio_advance_44496 bio_advance 2 44496 NULL
106408 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
106409 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
106410 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
106411 +spidev_write_44510 spidev_write 3 44510 NULL
106412 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
106413 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
106414 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
106415 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
106416 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
106417 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
106418 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
106419 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
106420 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
106421 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
106422 +mpi_resize_44674 mpi_resize 2 44674 NULL
106423 +ts_read_44687 ts_read 3 44687 NULL
106424 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
106425 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
106426 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
106427 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
106428 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
106429 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
106430 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
106431 +set_brk_44749 set_brk 1 44749 NULL
106432 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
106433 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
106434 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
106435 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
106436 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
106437 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
106438 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
106439 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
106440 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
106441 +sisusb_write_44834 sisusb_write 3 44834 NULL
106442 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
106443 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
106444 +cubic_root_44848 cubic_root 1 44848 NULL
106445 +copydesc_user_44855 copydesc_user 3 44855 NULL
106446 +skb_availroom_44883 skb_availroom 0 44883 NULL
106447 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
106448 +do_tty_write_44896 do_tty_write 5 44896 NULL
106449 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
106450 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
106451 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
106452 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
106453 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
106454 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
106455 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
106456 +sel_write_user_45060 sel_write_user 3 45060 NULL
106457 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
106458 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
106459 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
106460 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
106461 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
106462 +usbdev_read_45114 usbdev_read 3 45114 NULL
106463 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
106464 +send_to_tty_45141 send_to_tty 3 45141 NULL
106465 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
106466 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
106467 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
106468 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
106469 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
106470 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
106471 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
106472 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
106473 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
106474 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
106475 +add_child_45201 add_child 4 45201 NULL
106476 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
106477 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
106478 +__dirty_45228 __dirty 2 45228 NULL
106479 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
106480 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
106481 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
106482 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
106483 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
106484 +pte_val_45313 pte_val 0 45313 NULL
106485 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
106486 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
106487 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
106488 +keymap_store_45406 keymap_store 4 45406 NULL
106489 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
106490 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
106491 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
106492 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
106493 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
106494 +__node_remap_45458 __node_remap 4 45458 NULL
106495 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
106496 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
106497 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
106498 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
106499 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
106500 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
106501 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
106502 +copy_macs_45534 copy_macs 4 45534 NULL
106503 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
106504 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
106505 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
106506 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
106507 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
106508 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
106509 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
106510 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
106511 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
106512 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
106513 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
106514 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
106515 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
106516 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
106517 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
106518 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
106519 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
106520 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
106521 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
106522 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
106523 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
106524 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
106525 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
106526 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
106527 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
106528 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
106529 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
106530 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
106531 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
106532 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
106533 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
106534 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
106535 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
106536 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
106537 +isdn_write_45863 isdn_write 3 45863 NULL
106538 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
106539 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
106540 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
106541 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
106542 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
106543 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
106544 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
106545 +alloc_mr_45935 alloc_mr 1 45935 NULL
106546 +split_large_page_45941 split_large_page 2 45941 NULL
106547 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
106548 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
106549 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
106550 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
106551 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
106552 +get_free_entries_46030 get_free_entries 1 46030 NULL
106553 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
106554 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
106555 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
106556 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
106557 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
106558 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
106559 +slhc_toss_46066 slhc_toss 0 46066 NULL
106560 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
106561 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
106562 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
106563 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
106564 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
106565 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
106566 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
106567 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
106568 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
106569 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
106570 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
106571 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
106572 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
106573 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
106574 +add_conn_list_46197 add_conn_list 3 46197 NULL
106575 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
106576 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
106577 +dsp_write_46218 dsp_write 2 46218 NULL
106578 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
106579 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
106580 +ReadReg_46277 ReadReg 0 46277 NULL
106581 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
106582 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
106583 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
106584 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
106585 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
106586 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
106587 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
106588 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
106589 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
106590 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
106591 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
106592 +filldir64_46469 filldir64 3 46469 NULL
106593 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
106594 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
106595 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
106596 +kmsg_read_46514 kmsg_read 3 46514 NULL
106597 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
106598 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
106599 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
106600 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
106601 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
106602 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
106603 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
106604 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
106605 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
106606 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
106607 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
106608 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
106609 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
106610 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
106611 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
106612 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
106613 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
106614 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
106615 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
106616 +prepare_copy_46725 prepare_copy 2 46725 NULL
106617 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
106618 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
106619 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
106620 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
106621 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
106622 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
106623 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
106624 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
106625 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
106626 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
106627 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
106628 +spi_async_46857 spi_async 0 46857 NULL
106629 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
106630 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
106631 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
106632 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
106633 +rvmalloc_46873 rvmalloc 1 46873 NULL
106634 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
106635 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
106636 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
106637 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
106638 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
106639 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
106640 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
106641 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
106642 +fb_write_46924 fb_write 3 46924 NULL
106643 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
106644 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
106645 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
106646 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
106647 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
106648 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
106649 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
106650 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
106651 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
106652 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
106653 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
106654 +__map_single_47020 __map_single 3-4-7 47020 NULL
106655 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
106656 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
106657 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
106658 +fs_path_len_47060 fs_path_len 0 47060 NULL
106659 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
106660 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
106661 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
106662 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
106663 +mousedev_read_47123 mousedev_read 3 47123 NULL
106664 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
106665 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
106666 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
106667 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
106668 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
106669 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
106670 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
106671 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
106672 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
106673 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
106674 +l2headersize_47238 l2headersize 0 47238 NULL
106675 +options_write_47243 options_write 3 47243 NULL
106676 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
106677 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
106678 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
106679 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
106680 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
106681 +vsnprintf_47291 vsnprintf 0 47291 NULL
106682 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
106683 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
106684 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
106685 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
106686 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
106687 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
106688 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
106689 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
106690 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
106691 +nametbl_list_47391 nametbl_list 2 47391 NULL
106692 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
106693 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
106694 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
106695 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
106696 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
106697 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
106698 +vzalloc_47421 vzalloc 1 47421 NULL
106699 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
106700 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
106701 +__load_mapping_47460 __load_mapping 2 47460 NULL
106702 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
106703 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
106704 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
106705 +core_sys_select_47494 core_sys_select 1 47494 NULL
106706 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
106707 +unlink_simple_47506 unlink_simple 3 47506 NULL
106708 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
106709 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
106710 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
106711 +oz_events_read_47535 oz_events_read 3 47535 NULL
106712 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
106713 +read_ldt_47570 read_ldt 2 47570 NULL
106714 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
106715 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
106716 +pci_iomap_47575 pci_iomap 3 47575 NULL
106717 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
106718 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
106719 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
106720 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
106721 +uea_request_47613 uea_request 4 47613 NULL
106722 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
106723 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
106724 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
106725 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
106726 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
106727 +save_microcode_47717 save_microcode 3 47717 NULL
106728 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
106729 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
106730 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
106731 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
106732 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
106733 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
106734 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
106735 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
106736 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
106737 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
106738 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
106739 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
106740 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
106741 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
106742 +vhci_read_47878 vhci_read 3 47878 NULL
106743 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
106744 +load_mapping_47904 load_mapping 3 47904 NULL
106745 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
106746 +comedi_write_47926 comedi_write 3 47926 NULL
106747 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
106748 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
106749 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
106750 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
106751 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
106752 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
106753 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
106754 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
106755 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
106756 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
106757 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
106758 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
106759 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
106760 +disc_write_48070 disc_write 3 48070 NULL
106761 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
106762 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
106763 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
106764 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
106765 +set_discoverable_48141 set_discoverable 4 48141 NULL
106766 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
106767 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
106768 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
106769 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
106770 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
106771 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
106772 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
106773 +init_ipath_48187 init_ipath 1 48187 NULL
106774 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
106775 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
106776 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
106777 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
106778 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
106779 +read_file_recv_48232 read_file_recv 3 48232 NULL
106780 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
106781 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
106782 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
106783 +send_set_info_48288 send_set_info 7 48288 NULL
106784 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
106785 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
106786 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
106787 +hash_setkey_48310 hash_setkey 3 48310 NULL
106788 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
106789 +skb_add_data_48363 skb_add_data 3 48363 NULL
106790 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
106791 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
106792 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
106793 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
106794 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
106795 +print_filtered_48442 print_filtered 2-0 48442 NULL
106796 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
106797 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
106798 +send_control_msg_48498 send_control_msg 6 48498 NULL
106799 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
106800 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
106801 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
106802 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
106803 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
106804 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
106805 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
106806 +named_distribute_48544 named_distribute 4 48544 NULL
106807 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
106808 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
106809 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
106810 +mtd_read_48655 mtd_read 0 48655 NULL
106811 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
106812 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
106813 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
106814 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
106815 +altera_drscan_48698 altera_drscan 2 48698 NULL
106816 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
106817 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
106818 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
106819 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
106820 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
106821 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
106822 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
106823 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
106824 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
106825 +azx_get_position_48841 azx_get_position 0 48841 NULL
106826 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
106827 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
106828 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
106829 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
106830 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
106831 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
106832 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
106833 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
106834 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
106835 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
106836 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
106837 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
106838 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
106839 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
106840 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
106841 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
106842 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
106843 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
106844 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
106845 +transient_status_49027 transient_status 4 49027 NULL
106846 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
106847 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
106848 +ubi_read_49061 ubi_read 0 49061 NULL
106849 +scsi_register_49094 scsi_register 2 49094 NULL
106850 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
106851 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
106852 +check_exists_49119 check_exists 2 49119 NULL nohasharray
106853 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
106854 +pt_read_49136 pt_read 3 49136 NULL
106855 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
106856 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
106857 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
106858 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
106859 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
106860 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
106861 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
106862 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
106863 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
106864 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
106865 +resp_write_same_49217 resp_write_same 2 49217 NULL
106866 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
106867 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
106868 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
106869 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
106870 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
106871 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
106872 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
106873 +uio_read_49300 uio_read 3 49300 NULL
106874 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
106875 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
106876 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
106877 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
106878 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
106879 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
106880 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
106881 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
106882 +px_raw_event_49371 px_raw_event 4 49371 NULL
106883 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
106884 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
106885 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
106886 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
106887 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
106888 +md_domain_init_49432 md_domain_init 2 49432 NULL
106889 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
106890 +get_lru_size_49441 get_lru_size 0 49441 NULL
106891 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
106892 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
106893 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
106894 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
106895 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
106896 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
106897 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
106898 +smk_write_access_49561 smk_write_access 3 49561 NULL
106899 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
106900 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
106901 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
106902 +tap_write_49595 tap_write 3 49595 NULL
106903 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
106904 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
106905 +heap_init_49617 heap_init 2 49617 NULL
106906 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
106907 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
106908 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
106909 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
106910 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
106911 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
106912 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
106913 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
106914 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
106915 +check_frame_49741 check_frame 0 49741 NULL
106916 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
106917 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
106918 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
106919 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
106920 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
106921 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
106922 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
106923 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
106924 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
106925 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
106926 +add_uuid_49831 add_uuid 4 49831 NULL
106927 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
106928 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
106929 +twl4030_write_49846 twl4030_write 2 49846 NULL
106930 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
106931 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
106932 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
106933 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
106934 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
106935 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
106936 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
106937 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
106938 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
106939 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
106940 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
106941 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
106942 +__module_alloc_50004 __module_alloc 1 50004 NULL
106943 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
106944 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
106945 +isdn_read_50021 isdn_read 3 50021 NULL
106946 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
106947 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
106948 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
106949 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
106950 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
106951 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
106952 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
106953 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
106954 +read_file_slot_50111 read_file_slot 3 50111 NULL
106955 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
106956 +copy_items_50140 copy_items 6 50140 NULL
106957 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
106958 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
106959 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
106960 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
106961 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
106962 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
106963 +odev_update_50169 odev_update 2 50169 NULL
106964 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
106965 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
106966 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
106967 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
106968 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
106969 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
106970 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
106971 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
106972 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
106973 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
106974 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
106975 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
106976 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
106977 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
106978 +do_launder_page_50329 do_launder_page 0 50329 NULL
106979 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
106980 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
106981 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
106982 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
106983 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
106984 +tpm_read_50344 tpm_read 3 50344 NULL
106985 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
106986 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
106987 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
106988 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
106989 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
106990 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
106991 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
106992 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
106993 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
106994 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
106995 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
106996 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
106997 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
106998 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
106999 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
107000 +force_mapping_50464 force_mapping 2 50464 NULL
107001 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
107002 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
107003 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
107004 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
107005 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
107006 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
107007 +fat_readpages_50582 fat_readpages 4 50582 NULL
107008 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
107009 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
107010 +sge_rx_50594 sge_rx 3 50594 NULL
107011 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
107012 +__ffs_50625 __ffs 0 50625 NULL
107013 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
107014 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
107015 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
107016 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
107017 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
107018 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
107019 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
107020 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
107021 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
107022 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
107023 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
107024 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
107025 +skb_padto_50759 skb_padto 2 50759 NULL
107026 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
107027 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
107028 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
107029 +tpm_write_50798 tpm_write 3 50798 NULL
107030 +write_flush_50803 write_flush 3 50803 NULL
107031 +dvb_play_50814 dvb_play 3 50814 NULL
107032 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
107033 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
107034 +SetArea_50835 SetArea 4 50835 NULL nohasharray
107035 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
107036 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
107037 +self_check_write_50856 self_check_write 5 50856 NULL
107038 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
107039 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
107040 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
107041 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
107042 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
107043 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
107044 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
107045 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
107046 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
107047 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
107048 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
107049 +timeout_write_50991 timeout_write 3 50991 NULL
107050 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
107051 +proc_write_51003 proc_write 3 51003 NULL
107052 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
107053 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
107054 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
107055 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
107056 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
107057 +dump_midi_51040 dump_midi 3 51040 NULL
107058 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
107059 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
107060 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
107061 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
107062 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
107063 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
107064 +ti_recv_51110 ti_recv 3 51110 NULL
107065 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
107066 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
107067 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
107068 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
107069 +set_dirty_51144 set_dirty 3 51144 NULL
107070 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
107071 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
107072 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
107073 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
107074 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
107075 +tipc_send_51238 tipc_send 4 51238 NULL
107076 +drm_property_create_51239 drm_property_create 4 51239 NULL
107077 +st_read_51251 st_read 3 51251 NULL
107078 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
107079 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
107080 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
107081 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
107082 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
107083 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
107084 +get_cell_51316 get_cell 2 51316 NULL
107085 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
107086 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
107087 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
107088 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
107089 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
107090 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
107091 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
107092 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
107093 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
107094 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
107095 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
107096 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
107097 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
107098 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
107099 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
107100 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
107101 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
107102 +vaddr_51480 vaddr 0 51480 NULL
107103 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
107104 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
107105 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
107106 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
107107 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
107108 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
107109 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
107110 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
107111 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
107112 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
107113 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
107114 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
107115 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
107116 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
107117 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
107118 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
107119 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
107120 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
107121 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
107122 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
107123 +sel_write_access_51704 sel_write_access 3 51704 NULL
107124 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
107125 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
107126 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
107127 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
107128 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
107129 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
107130 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
107131 +if_write_51756 if_write 3 51756 NULL
107132 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
107133 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
107134 +to_ratio_51809 to_ratio 2-1 51809 NULL
107135 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
107136 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
107137 +ioread32_51847 ioread32 0 51847 NULL nohasharray
107138 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
107139 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
107140 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
107141 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
107142 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
107143 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
107144 +user_read_51881 user_read 3 51881 NULL
107145 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
107146 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
107147 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
107148 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
107149 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
107150 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
107151 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
107152 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
107153 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
107154 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
107155 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
107156 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
107157 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
107158 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
107159 +rdmalt_52022 rdmalt 0 52022 NULL
107160 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
107161 +override_release_52032 override_release 2 52032 NULL
107162 +end_port_52042 end_port 0 52042 NULL
107163 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
107164 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
107165 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
107166 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
107167 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
107168 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
107169 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
107170 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
107171 +retry_count_read_52129 retry_count_read 3 52129 NULL
107172 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
107173 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
107174 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
107175 +htable_size_52148 htable_size 0-1 52148 NULL
107176 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
107177 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
107178 +alix_present_52165 alix_present 1 52165 NULL
107179 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
107180 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
107181 +print_prefix_52176 print_prefix 0 52176 NULL
107182 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
107183 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
107184 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
107185 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
107186 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
107187 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
107188 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
107189 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
107190 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
107191 +atomic64_read_52300 atomic64_read 0 52300 NULL
107192 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
107193 +read_file_reset_52310 read_file_reset 3 52310 NULL
107194 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
107195 +hwflags_read_52318 hwflags_read 3 52318 NULL
107196 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
107197 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
107198 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
107199 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
107200 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
107201 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
107202 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
107203 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
107204 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
107205 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
107206 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
107207 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
107208 +delay_status_52431 delay_status 5 52431 NULL
107209 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
107210 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
107211 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
107212 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
107213 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
107214 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
107215 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
107216 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
107217 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
107218 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
107219 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
107220 +from_oblock_52546 from_oblock 0-1 52546 NULL
107221 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
107222 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
107223 +emit_code_52583 emit_code 0-3 52583 NULL
107224 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
107225 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
107226 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
107227 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
107228 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
107229 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
107230 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
107231 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
107232 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
107233 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
107234 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
107235 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
107236 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
107237 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
107238 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
107239 +twlreg_write_52880 twlreg_write 3 52880 NULL
107240 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
107241 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
107242 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
107243 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
107244 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
107245 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
107246 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
107247 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
107248 +send_packet_52960 send_packet 4 52960 NULL
107249 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
107250 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
107251 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
107252 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
107253 +num_node_state_52989 num_node_state 0 52989 NULL
107254 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
107255 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
107256 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
107257 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
107258 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
107259 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
107260 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
107261 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
107262 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
107263 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
107264 +verity_status_53120 verity_status 5 53120 NULL
107265 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
107266 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
107267 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
107268 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
107269 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
107270 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
107271 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
107272 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
107273 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
107274 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
107275 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
107276 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
107277 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
107278 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
107279 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
107280 +vm_mmap_53339 vm_mmap 0 53339 NULL
107281 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
107282 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
107283 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
107284 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
107285 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
107286 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
107287 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
107288 +n2_run_53459 n2_run 3 53459 NULL
107289 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
107290 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
107291 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
107292 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
107293 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
107294 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
107295 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
107296 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
107297 +check_acl_53512 check_acl 0 53512 NULL
107298 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
107299 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
107300 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
107301 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
107302 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
107303 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
107304 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
107305 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
107306 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
107307 +_preload_range_53676 _preload_range 2-3 53676 NULL
107308 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
107309 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
107310 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
107311 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
107312 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
107313 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
107314 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
107315 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
107316 +wdm_write_53735 wdm_write 3 53735 NULL
107317 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
107318 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
107319 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
107320 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
107321 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
107322 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
107323 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
107324 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
107325 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
107326 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
107327 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
107328 +pms_read_53873 pms_read 3 53873 NULL
107329 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
107330 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
107331 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
107332 +proc_file_read_53905 proc_file_read 3 53905 NULL
107333 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
107334 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
107335 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
107336 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
107337 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
107338 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
107339 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
107340 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
107341 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
107342 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
107343 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
107344 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
107345 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
107346 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
107347 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
107348 +_malloc_54077 _malloc 1 54077 NULL
107349 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
107350 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
107351 +create_xattr_54106 create_xattr 5 54106 NULL
107352 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
107353 +strn_len_54122 strn_len 0 54122 NULL
107354 +isku_receive_54130 isku_receive 4 54130 NULL
107355 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
107356 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
107357 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
107358 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
107359 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
107360 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
107361 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
107362 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
107363 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
107364 +reada_add_block_54247 reada_add_block 2 54247 NULL
107365 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
107366 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
107367 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
107368 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
107369 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
107370 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
107371 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
107372 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
107373 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
107374 +sprintf_54306 sprintf 0 54306 NULL
107375 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
107376 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
107377 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
107378 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
107379 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
107380 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
107381 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
107382 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
107383 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
107384 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
107385 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
107386 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
107387 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
107388 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
107389 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
107390 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
107391 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
107392 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
107393 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
107394 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
107395 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
107396 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
107397 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
107398 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
107399 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
107400 +viacam_read_54526 viacam_read 3 54526 NULL
107401 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
107402 +setsockopt_54539 setsockopt 5 54539 NULL
107403 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
107404 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
107405 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
107406 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
107407 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
107408 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
107409 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
107410 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
107411 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
107412 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
107413 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
107414 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
107415 +evm_read_key_54674 evm_read_key 3 54674 NULL
107416 +resource_string_54699 resource_string 0 54699 NULL
107417 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
107418 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
107419 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
107420 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
107421 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
107422 +kzalloc_54740 kzalloc 1 54740 NULL
107423 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
107424 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
107425 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
107426 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
107427 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
107428 +domain_init_54797 domain_init 2 54797 NULL
107429 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
107430 +get_dev_size_54807 get_dev_size 0 54807 NULL
107431 +nfsd_write_54809 nfsd_write 6 54809 NULL
107432 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
107433 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
107434 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
107435 +write_rio_54837 write_rio 3 54837 NULL
107436 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
107437 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
107438 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
107439 +printer_read_54851 printer_read 3 54851 NULL
107440 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
107441 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
107442 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
107443 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
107444 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
107445 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
107446 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
107447 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
107448 +add_port_54941 add_port 2 54941 NULL
107449 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
107450 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
107451 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
107452 +c4_add_card_54968 c4_add_card 3 54968 NULL
107453 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
107454 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
107455 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
107456 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
107457 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
107458 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
107459 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
107460 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
107461 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
107462 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
107463 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
107464 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
107465 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
107466 +corrupt_data_55120 corrupt_data 0 55120 NULL
107467 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
107468 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
107469 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
107470 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
107471 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
107472 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
107473 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
107474 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
107475 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
107476 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
107477 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
107478 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
107479 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
107480 +dump_command_55220 dump_command 1 55220 NULL
107481 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
107482 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
107483 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
107484 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
107485 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
107486 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
107487 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
107488 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
107489 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
107490 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
107491 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
107492 +do_shmat_55336 do_shmat 5 55336 NULL
107493 +vme_user_read_55338 vme_user_read 3 55338 NULL
107494 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
107495 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
107496 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
107497 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
107498 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
107499 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
107500 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
107501 +alloc_skb_55439 alloc_skb 1 55439 NULL
107502 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
107503 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
107504 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
107505 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
107506 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
107507 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
107508 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
107509 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
107510 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
107511 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
107512 +ea_get_55522 ea_get 0 55522 NULL
107513 +buffer_size_55534 buffer_size 0 55534 NULL
107514 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
107515 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
107516 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
107517 +add_partition_55588 add_partition 2 55588 NULL
107518 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
107519 +free_pages_55603 free_pages 1 55603 NULL
107520 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
107521 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
107522 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
107523 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
107524 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
107525 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
107526 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
107527 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
107528 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
107529 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
107530 +read_oldmem_55658 read_oldmem 3 55658 NULL
107531 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
107532 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
107533 +get_info_55681 get_info 3 55681 NULL
107534 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
107535 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
107536 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
107537 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
107538 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
107539 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
107540 +set_local_name_55757 set_local_name 4 55757 NULL
107541 +strlen_55778 strlen 0 55778 NULL
107542 +set_spte_55783 set_spte 5-4 55783 NULL
107543 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
107544 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
107545 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
107546 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
107547 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
107548 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
107549 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
107550 +hsc_write_55875 hsc_write 3 55875 NULL
107551 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
107552 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
107553 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
107554 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
107555 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
107556 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
107557 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
107558 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
107559 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
107560 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
107561 +__set_discard_56081 __set_discard 2 56081 NULL
107562 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
107563 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
107564 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
107565 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
107566 +map_addr_56144 map_addr 7 56144 NULL
107567 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
107568 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
107569 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
107570 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
107571 +skb_headroom_56200 skb_headroom 0 56200 NULL
107572 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
107573 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
107574 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
107575 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
107576 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
107577 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
107578 +fd_copyin_56247 fd_copyin 3 56247 NULL
107579 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
107580 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
107581 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
107582 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
107583 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
107584 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
107585 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
107586 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
107587 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
107588 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
107589 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
107590 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
107591 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
107592 +dev_read_56369 dev_read 3 56369 NULL
107593 +write_gssp_56404 write_gssp 3 56404 NULL
107594 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
107595 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
107596 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
107597 +store_msg_56417 store_msg 3 56417 NULL
107598 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
107599 +fl_create_56435 fl_create 5 56435 NULL
107600 +gnttab_map_56439 gnttab_map 2 56439 NULL
107601 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
107602 +set_connectable_56458 set_connectable 4 56458 NULL
107603 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
107604 +putused_user_56467 putused_user 3 56467 NULL
107605 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
107606 +global_rt_period_56476 global_rt_period 0 56476 NULL
107607 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
107608 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
107609 +init_map_ip_56508 init_map_ip 5 56508 NULL
107610 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
107611 +ip_options_get_56538 ip_options_get 4 56538 NULL
107612 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
107613 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
107614 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
107615 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
107616 +event_filter_write_56609 event_filter_write 3 56609 NULL
107617 +gather_array_56641 gather_array 3 56641 NULL
107618 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
107619 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
107620 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
107621 +build_map_info_56696 build_map_info 2 56696 NULL
107622 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
107623 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
107624 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
107625 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
107626 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
107627 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
107628 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
107629 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
107630 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
107631 +hash_lookup_56792 hash_lookup 2 56792 NULL
107632 +do_syslog_56807 do_syslog 3 56807 NULL
107633 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
107634 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
107635 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
107636 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
107637 +wb_lookup_56858 wb_lookup 2 56858 NULL
107638 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
107639 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
107640 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
107641 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
107642 +strcspn_56913 strcspn 0 56913 NULL
107643 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
107644 +check_header_56930 check_header 2 56930 NULL
107645 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
107646 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
107647 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
107648 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
107649 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
107650 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
107651 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
107652 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
107653 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
107654 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
107655 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
107656 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
107657 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
107658 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
107659 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
107660 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
107661 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
107662 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
107663 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
107664 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
107665 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
107666 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
107667 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
107668 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
107669 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
107670 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
107671 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
107672 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
107673 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
107674 +flush_space_57241 flush_space 3 57241 NULL
107675 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
107676 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
107677 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
107678 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
107679 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
107680 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
107681 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
107682 +fw_file_size_57307 fw_file_size 0 57307 NULL
107683 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
107684 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
107685 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
107686 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
107687 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
107688 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
107689 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
107690 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
107691 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
107692 +read_file_blob_57406 read_file_blob 3 57406 NULL
107693 +enclosure_register_57412 enclosure_register 3 57412 NULL
107694 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
107695 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
107696 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
107697 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
107698 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
107699 +ReadReg_57453 ReadReg 0 57453 NULL
107700 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
107701 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
107702 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
107703 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
107704 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
107705 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
107706 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
107707 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
107708 +skb_headlen_57501 skb_headlen 0 57501 NULL
107709 +copy_in_user_57502 copy_in_user 3 57502 NULL
107710 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
107711 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
107712 +init_tag_map_57515 init_tag_map 3 57515 NULL
107713 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
107714 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
107715 +inode_permission_57531 inode_permission 0 57531 NULL
107716 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
107717 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
107718 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
107719 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
107720 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
107721 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
107722 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
107723 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
107724 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
107725 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
107726 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
107727 +mem_read_57631 mem_read 3 57631 NULL
107728 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
107729 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
107730 +r3964_write_57662 r3964_write 4 57662 NULL
107731 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
107732 +__lgwrite_57669 __lgwrite 4 57669 NULL
107733 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
107734 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
107735 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
107736 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
107737 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
107738 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
107739 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
107740 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
107741 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
107742 +ld2_57794 ld2 0 57794 NULL
107743 +ivtv_read_57796 ivtv_read 3 57796 NULL
107744 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
107745 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
107746 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
107747 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
107748 +copy_to_user_57835 copy_to_user 3 57835 NULL
107749 +flash_read_57843 flash_read 3 57843 NULL
107750 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
107751 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
107752 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
107753 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
107754 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
107755 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
107756 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
107757 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
107758 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
107759 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
107760 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
107761 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
107762 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
107763 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
107764 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
107765 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
107766 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
107767 +mce_async_out_58056 mce_async_out 3 58056 NULL
107768 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
107769 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
107770 +cm4040_write_58079 cm4040_write 3 58079 NULL
107771 +udi_log_event_58105 udi_log_event 3 58105 NULL
107772 +savemem_58129 savemem 3 58129 NULL
107773 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
107774 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
107775 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
107776 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
107777 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
107778 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
107779 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
107780 +read_file_debug_58256 read_file_debug 3 58256 NULL
107781 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
107782 +profile_load_58267 profile_load 3 58267 NULL
107783 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
107784 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
107785 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
107786 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
107787 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
107788 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
107789 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
107790 +next_pidmap_58347 next_pidmap 2 58347 NULL
107791 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
107792 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
107793 +save_hint_58359 save_hint 2 58359 NULL
107794 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
107795 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
107796 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
107797 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
107798 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
107799 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
107800 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
107801 +capabilities_read_58457 capabilities_read 3 58457 NULL
107802 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
107803 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
107804 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
107805 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
107806 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
107807 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
107808 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
107809 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
107810 +__clear_discard_58546 __clear_discard 2 58546 NULL
107811 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
107812 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
107813 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
107814 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
107815 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
107816 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
107817 +xip_file_read_58592 xip_file_read 3 58592 NULL
107818 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
107819 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
107820 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
107821 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
107822 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
107823 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
107824 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
107825 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
107826 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
107827 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
107828 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
107829 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
107830 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
107831 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
107832 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
107833 +acpi_map_58725 acpi_map 1-2 58725 NULL
107834 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
107835 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
107836 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
107837 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
107838 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
107839 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
107840 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
107841 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
107842 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
107843 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
107844 +ep_read_58813 ep_read 3 58813 NULL
107845 +command_write_58841 command_write 3 58841 NULL
107846 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
107847 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
107848 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
107849 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
107850 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
107851 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
107852 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
107853 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
107854 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
107855 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
107856 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
107857 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
107858 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
107859 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
107860 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
107861 +ep_write_59008 ep_write 3 59008 NULL
107862 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
107863 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
107864 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
107865 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
107866 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
107867 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
107868 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
107869 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
107870 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
107871 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
107872 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
107873 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
107874 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
107875 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
107876 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
107877 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
107878 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
107879 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
107880 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
107881 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
107882 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
107883 +dt3155_read_59226 dt3155_read 3 59226 NULL
107884 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
107885 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
107886 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
107887 +nla_len_59258 nla_len 0 59258 NULL
107888 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
107889 +fd_copyout_59323 fd_copyout 3 59323 NULL
107890 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
107891 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
107892 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
107893 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
107894 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
107895 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
107896 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
107897 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
107898 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
107899 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
107900 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
107901 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
107902 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
107903 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
107904 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
107905 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
107906 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
107907 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
107908 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
107909 +tunables_write_59563 tunables_write 3 59563 NULL
107910 +memdup_user_59590 memdup_user 2 59590 NULL
107911 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
107912 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
107913 +mtrr_write_59622 mtrr_write 3 59622 NULL
107914 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
107915 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
107916 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
107917 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
107918 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
107919 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
107920 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
107921 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
107922 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
107923 +sriov_enable_59689 sriov_enable 2 59689 NULL
107924 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
107925 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
107926 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
107927 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
107928 +strnlen_59746 strnlen 0 59746 NULL
107929 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
107930 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
107931 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
107932 +venus_remove_59781 venus_remove 4 59781 NULL
107933 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
107934 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
107935 +ipw_write_59807 ipw_write 3 59807 NULL
107936 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
107937 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
107938 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
107939 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
107940 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
107941 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
107942 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
107943 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
107944 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
107945 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
107946 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
107947 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
107948 +lookup_node_59953 lookup_node 2 59953 NULL
107949 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
107950 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
107951 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
107952 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
107953 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
107954 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
107955 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
107956 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
107957 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
107958 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
107959 +register_device_60015 register_device 2-3 60015 NULL
107960 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
107961 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
107962 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
107963 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
107964 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
107965 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
107966 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
107967 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
107968 +compat_writev_60063 compat_writev 3 60063 NULL
107969 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
107970 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
107971 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
107972 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
107973 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
107974 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
107975 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
107976 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
107977 +init_state_60165 init_state 2 60165 NULL
107978 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
107979 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
107980 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
107981 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
107982 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
107983 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
107984 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
107985 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
107986 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
107987 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
107988 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
107989 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
107990 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
107991 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
107992 +printer_write_60276 printer_write 3 60276 NULL
107993 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
107994 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
107995 +getDataLength_60301 getDataLength 0 60301 NULL
107996 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
107997 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
107998 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
107999 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
108000 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
108001 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
108002 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
108003 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
108004 +driver_names_read_60399 driver_names_read 3 60399 NULL
108005 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
108006 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
108007 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
108008 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
108009 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
108010 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
108011 +rx_data_60442 rx_data 4 60442 NULL nohasharray
108012 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
108013 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
108014 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
108015 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
108016 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
108017 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
108018 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
108019 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
108020 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
108021 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
108022 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
108023 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
108024 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
108025 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
108026 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
108027 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
108028 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
108029 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
108030 +init_data_container_60709 init_data_container 1 60709 NULL
108031 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
108032 +raid_status_60755 raid_status 5 60755 NULL
108033 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
108034 +opticon_write_60775 opticon_write 4 60775 NULL
108035 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
108036 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
108037 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
108038 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
108039 +generic_writepages_60871 generic_writepages 0 60871 NULL
108040 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
108041 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
108042 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
108043 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
108044 +sys_mlock_60932 sys_mlock 1 60932 NULL
108045 +pti_char_write_60960 pti_char_write 3 60960 NULL
108046 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
108047 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
108048 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
108049 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
108050 +symtab_init_61050 symtab_init 2 61050 NULL
108051 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
108052 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
108053 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
108054 +get_derived_key_61100 get_derived_key 4 61100 NULL
108055 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
108056 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
108057 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
108058 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
108059 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
108060 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
108061 +__vmalloc_61168 __vmalloc 1 61168 NULL
108062 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
108063 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
108064 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
108065 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
108066 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
108067 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
108068 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
108069 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
108070 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
108071 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
108072 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
108073 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
108074 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
108075 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
108076 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
108077 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
108078 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
108079 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
108080 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
108081 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
108082 +change_xattr_61390 change_xattr 5 61390 NULL
108083 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
108084 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
108085 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
108086 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
108087 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
108088 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
108089 +erst_errno_61526 erst_errno 0 61526 NULL
108090 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
108091 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
108092 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
108093 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
108094 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
108095 +seq_open_private_61589 seq_open_private 3 61589 NULL
108096 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
108097 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
108098 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
108099 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
108100 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
108101 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
108102 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
108103 +resize_stripes_61650 resize_stripes 2 61650 NULL
108104 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
108105 +insert_one_name_61668 insert_one_name 7 61668 NULL
108106 +lock_loop_61681 lock_loop 1 61681 NULL
108107 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
108108 +filter_read_61692 filter_read 3 61692 NULL
108109 +iov_length_61716 iov_length 0 61716 NULL
108110 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
108111 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
108112 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
108113 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
108114 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
108115 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
108116 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
108117 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
108118 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
108119 +get_fw_name_61874 get_fw_name 3 61874 NULL
108120 +free_init_pages_61875 free_init_pages 2 61875 NULL
108121 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
108122 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
108123 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
108124 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
108125 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
108126 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
108127 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
108128 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
108129 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
108130 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
108131 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
108132 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
108133 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
108134 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
108135 +cow_file_range_61979 cow_file_range 3 61979 NULL
108136 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
108137 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
108138 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
108139 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
108140 +SYSC_select_62024 SYSC_select 1 62024 NULL
108141 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
108142 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
108143 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
108144 +do_pselect_62061 do_pselect 1 62061 NULL
108145 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
108146 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
108147 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
108148 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
108149 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
108150 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
108151 +ql_status_62135 ql_status 5 62135 NULL
108152 +video_usercopy_62151 video_usercopy 2 62151 NULL
108153 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
108154 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
108155 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
108156 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
108157 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
108158 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
108159 +allocate_partition_62245 allocate_partition 4 62245 NULL
108160 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
108161 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
108162 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
108163 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
108164 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
108165 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
108166 +subseq_list_62332 subseq_list 3-0 62332 NULL
108167 +flash_write_62354 flash_write 3 62354 NULL
108168 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
108169 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
108170 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
108171 +altera_irscan_62396 altera_irscan 2 62396 NULL
108172 +set_ssp_62411 set_ssp 4 62411 NULL
108173 +unmap_single_62423 unmap_single 2 62423 NULL
108174 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
108175 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
108176 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
108177 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
108178 +remove_mapping_62491 remove_mapping 2 62491 NULL
108179 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
108180 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
108181 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
108182 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
108183 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
108184 +debugfs_read_62535 debugfs_read 3 62535 NULL
108185 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
108186 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
108187 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
108188 +get_subdir_62581 get_subdir 3 62581 NULL
108189 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
108190 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
108191 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
108192 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
108193 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
108194 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
108195 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
108196 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
108197 +write_62671 write 3 62671 NULL
108198 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
108199 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
108200 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
108201 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
108202 +rdm_62719 rdm 0 62719 NULL
108203 +key_replays_read_62746 key_replays_read 3 62746 NULL
108204 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
108205 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
108206 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
108207 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
108208 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
108209 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
108210 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
108211 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
108212 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
108213 +set_swbp_62853 set_swbp 3 62853 NULL
108214 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
108215 +aoechr_write_62883 aoechr_write 3 62883 NULL
108216 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
108217 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
108218 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
108219 +getdqbuf_62908 getdqbuf 1 62908 NULL
108220 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
108221 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
108222 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
108223 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
108224 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
108225 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
108226 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
108227 +unlink1_63059 unlink1 3 63059 NULL
108228 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
108229 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
108230 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
108231 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
108232 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
108233 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
108234 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
108235 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
108236 +vme_master_read_63221 vme_master_read 0 63221 NULL
108237 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
108238 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
108239 +ptp_read_63251 ptp_read 4 63251 NULL
108240 +raid5_resize_63306 raid5_resize 2 63306 NULL
108241 +proc_info_read_63344 proc_info_read 3 63344 NULL
108242 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
108243 +idmouse_read_63374 idmouse_read 3 63374 NULL
108244 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
108245 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
108246 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
108247 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
108248 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
108249 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
108250 +kone_send_63435 kone_send 4 63435 NULL
108251 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
108252 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
108253 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
108254 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
108255 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
108256 +read_kcore_63488 read_kcore 3 63488 NULL
108257 +save_hint_63497 save_hint 2 63497 NULL
108258 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
108259 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
108260 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
108261 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
108262 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
108263 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
108264 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
108265 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
108266 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
108267 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
108268 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
108269 +module_alloc_63630 module_alloc 1 63630 NULL
108270 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
108271 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
108272 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
108273 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
108274 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
108275 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
108276 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
108277 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
108278 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
108279 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
108280 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
108281 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
108282 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
108283 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
108284 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
108285 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
108286 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
108287 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
108288 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
108289 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
108290 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
108291 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
108292 +prepare_copy_63826 prepare_copy 2 63826 NULL
108293 +sel_write_load_63830 sel_write_load 3 63830 NULL
108294 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
108295 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
108296 +divas_write_63901 divas_write 3 63901 NULL
108297 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
108298 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
108299 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
108300 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
108301 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
108302 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
108303 +__team_options_register_63941 __team_options_register 3 63941 NULL
108304 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
108305 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
108306 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
108307 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
108308 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
108309 +kmemdup_64015 kmemdup 2 64015 NULL
108310 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
108311 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
108312 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
108313 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
108314 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
108315 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
108316 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
108317 +get_u8_64076 get_u8 0 64076 NULL
108318 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
108319 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
108320 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
108321 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
108322 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
108323 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
108324 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
108325 +init_bch_64130 init_bch 1-2 64130 NULL
108326 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
108327 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
108328 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
108329 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
108330 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
108331 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
108332 +read_pulse_64227 read_pulse 0-3 64227 NULL
108333 +header_len_64232 header_len 0 64232 NULL
108334 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
108335 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
108336 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
108337 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
108338 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
108339 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
108340 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
108341 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
108342 +ffz_64324 ffz 0 64324 NULL
108343 +map_region_64328 map_region 1 64328 NULL
108344 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
108345 +ts_write_64336 ts_write 3 64336 NULL
108346 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
108347 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
108348 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
108349 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
108350 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
108351 +ilo_write_64378 ilo_write 3 64378 NULL
108352 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
108353 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
108354 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
108355 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
108356 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
108357 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
108358 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
108359 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
108360 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
108361 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
108362 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
108363 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
108364 +cap_capable_64462 cap_capable 0 64462 NULL
108365 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
108366 +single_open_size_64483 single_open_size 4 64483 NULL
108367 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
108368 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
108369 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
108370 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
108371 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
108372 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
108373 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
108374 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
108375 +SyS_bind_64544 SyS_bind 3 64544 NULL
108376 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
108377 +__spi_sync_64561 __spi_sync 0 64561 NULL
108378 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
108379 +fanotify_write_64623 fanotify_write 3 64623 NULL
108380 +to_dblock_64655 to_dblock 0-1 64655 NULL
108381 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
108382 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
108383 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
108384 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
108385 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
108386 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
108387 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
108388 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
108389 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
108390 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
108391 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
108392 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
108393 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
108394 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
108395 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
108396 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
108397 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
108398 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
108399 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
108400 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
108401 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
108402 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
108403 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
108404 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
108405 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
108406 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
108407 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
108408 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
108409 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
108410 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
108411 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
108412 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
108413 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
108414 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
108415 +pskb_pull_65005 pskb_pull 2 65005 NULL
108416 +unifi_write_65012 unifi_write 3 65012 NULL
108417 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
108418 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
108419 +insert_dent_65034 insert_dent 7 65034 NULL
108420 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
108421 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
108422 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
108423 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
108424 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
108425 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
108426 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
108427 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
108428 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
108429 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
108430 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
108431 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
108432 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
108433 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
108434 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
108435 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
108436 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
108437 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
108438 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
108439 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
108440 +get_var_len_65304 get_var_len 0 65304 NULL
108441 +unpack_array_65318 unpack_array 0 65318 NULL
108442 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
108443 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
108444 +init_list_set_65351 init_list_set 2-3 65351 NULL
108445 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
108446 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
108447 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
108448 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
108449 +strchr_65372 strchr 0 65372 NULL nohasharray
108450 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
108451 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
108452 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
108453 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
108454 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
108455 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
108456 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
108457 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
108458 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
108459 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
108460 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
108461 +alloc_dr_65495 alloc_dr 2 65495 NULL
108462 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
108463 new file mode 100644
108464 index 0000000..03d0c84
108465 --- /dev/null
108466 +++ b/tools/gcc/size_overflow_plugin.c
108467 @@ -0,0 +1,2113 @@
108468 +/*
108469 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
108470 + * Licensed under the GPL v2, or (at your option) v3
108471 + *
108472 + * Homepage:
108473 + * http://www.grsecurity.net/~ephox/overflow_plugin/
108474 + *
108475 + * Documentation:
108476 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
108477 + *
108478 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
108479 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
108480 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
108481 + *
108482 + * Usage:
108483 + * $ 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
108484 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
108485 + */
108486 +
108487 +#include "gcc-plugin.h"
108488 +#include "config.h"
108489 +#include "system.h"
108490 +#include "coretypes.h"
108491 +#include "tree.h"
108492 +#include "tree-pass.h"
108493 +#include "intl.h"
108494 +#include "plugin-version.h"
108495 +#include "tm.h"
108496 +#include "toplev.h"
108497 +#include "function.h"
108498 +#include "tree-flow.h"
108499 +#include "plugin.h"
108500 +#include "gimple.h"
108501 +#include "diagnostic.h"
108502 +#include "cfgloop.h"
108503 +
108504 +#if BUILDING_GCC_VERSION >= 4008
108505 +#define TODO_dump_func 0
108506 +#endif
108507 +
108508 +struct size_overflow_hash {
108509 + const struct size_overflow_hash * const next;
108510 + const char * const name;
108511 + const unsigned int param;
108512 +};
108513 +
108514 +#include "size_overflow_hash.h"
108515 +
108516 +enum mark {
108517 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
108518 +};
108519 +
108520 +enum err_code_conditions {
108521 + CAST_ONLY, FROM_CONST
108522 +};
108523 +
108524 +static unsigned int call_count = 0;
108525 +
108526 +#define __unused __attribute__((__unused__))
108527 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
108528 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
108529 +#define BEFORE_STMT true
108530 +#define AFTER_STMT false
108531 +#define CREATE_NEW_VAR NULL_TREE
108532 +#define CODES_LIMIT 32
108533 +#define MAX_PARAM 31
108534 +#define MY_STMT GF_PLF_1
108535 +#define NO_CAST_CHECK GF_PLF_2
108536 +#define FROM_ARG true
108537 +#define FROM_RET false
108538 +
108539 +#if BUILDING_GCC_VERSION == 4005
108540 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
108541 +#endif
108542 +
108543 +int plugin_is_GPL_compatible;
108544 +void debug_gimple_stmt(gimple gs);
108545 +
108546 +static tree expand(struct pointer_set_t *visited, tree lhs);
108547 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
108548 +static tree report_size_overflow_decl;
108549 +static const_tree const_char_ptr_type_node;
108550 +static unsigned int handle_function(void);
108551 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
108552 +static tree get_size_overflow_type(gimple stmt, const_tree node);
108553 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
108554 +static void print_missing_msg(tree func, unsigned int argnum);
108555 +
108556 +static struct plugin_info size_overflow_plugin_info = {
108557 + .version = "20130822beta",
108558 + .help = "no-size-overflow\tturn off size overflow checking\n",
108559 +};
108560 +
108561 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108562 +{
108563 + unsigned int arg_count;
108564 + enum tree_code code = TREE_CODE(*node);
108565 +
108566 + switch (code) {
108567 + case FUNCTION_DECL:
108568 + arg_count = type_num_arguments(TREE_TYPE(*node));
108569 + break;
108570 + case FUNCTION_TYPE:
108571 + case METHOD_TYPE:
108572 + arg_count = type_num_arguments(*node);
108573 + break;
108574 + default:
108575 + *no_add_attrs = true;
108576 + error("%s: %qE attribute only applies to functions", __func__, name);
108577 + return NULL_TREE;
108578 + }
108579 +
108580 + for (; args; args = TREE_CHAIN(args)) {
108581 + tree position = TREE_VALUE(args);
108582 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108583 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108584 + *no_add_attrs = true;
108585 + }
108586 + }
108587 + return NULL_TREE;
108588 +}
108589 +
108590 +static const char* get_asm_name(tree node)
108591 +{
108592 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
108593 +}
108594 +
108595 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108596 +{
108597 + unsigned int arg_count, arg_num;
108598 + enum tree_code code = TREE_CODE(*node);
108599 +
108600 + switch (code) {
108601 + case FUNCTION_DECL:
108602 + arg_count = type_num_arguments(TREE_TYPE(*node));
108603 + break;
108604 + case FUNCTION_TYPE:
108605 + case METHOD_TYPE:
108606 + arg_count = type_num_arguments(*node);
108607 + break;
108608 + case FIELD_DECL:
108609 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
108610 + if (arg_num != 0) {
108611 + *no_add_attrs = true;
108612 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
108613 + }
108614 + return NULL_TREE;
108615 + default:
108616 + *no_add_attrs = true;
108617 + error("%qE attribute only applies to functions", name);
108618 + return NULL_TREE;
108619 + }
108620 +
108621 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
108622 + return NULL_TREE;
108623 +
108624 + for (; args; args = TREE_CHAIN(args)) {
108625 + tree position = TREE_VALUE(args);
108626 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108627 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108628 + *no_add_attrs = true;
108629 + }
108630 + }
108631 + return NULL_TREE;
108632 +}
108633 +
108634 +static struct attribute_spec size_overflow_attr = {
108635 + .name = "size_overflow",
108636 + .min_length = 1,
108637 + .max_length = -1,
108638 + .decl_required = true,
108639 + .type_required = false,
108640 + .function_type_required = false,
108641 + .handler = handle_size_overflow_attribute,
108642 +#if BUILDING_GCC_VERSION >= 4007
108643 + .affects_type_identity = false
108644 +#endif
108645 +};
108646 +
108647 +static struct attribute_spec intentional_overflow_attr = {
108648 + .name = "intentional_overflow",
108649 + .min_length = 1,
108650 + .max_length = -1,
108651 + .decl_required = true,
108652 + .type_required = false,
108653 + .function_type_required = false,
108654 + .handler = handle_intentional_overflow_attribute,
108655 +#if BUILDING_GCC_VERSION >= 4007
108656 + .affects_type_identity = false
108657 +#endif
108658 +};
108659 +
108660 +static void register_attributes(void __unused *event_data, void __unused *data)
108661 +{
108662 + register_attribute(&size_overflow_attr);
108663 + register_attribute(&intentional_overflow_attr);
108664 +}
108665 +
108666 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
108667 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
108668 +{
108669 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
108670 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
108671 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
108672 +
108673 + unsigned int m = 0x57559429;
108674 + unsigned int n = 0x5052acdb;
108675 + const unsigned int *key4 = (const unsigned int *)key;
108676 + unsigned int h = len;
108677 + unsigned int k = len + seed + n;
108678 + unsigned long long p;
108679 +
108680 + while (len >= 8) {
108681 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
108682 + len -= 8;
108683 + }
108684 + if (len >= 4) {
108685 + cwmixb(key4[0]) key4 += 1;
108686 + len -= 4;
108687 + }
108688 + if (len)
108689 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
108690 + cwmixb(h ^ (k + n));
108691 + return k ^ h;
108692 +
108693 +#undef cwfold
108694 +#undef cwmixa
108695 +#undef cwmixb
108696 +}
108697 +
108698 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
108699 +{
108700 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
108701 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
108702 + return fn ^ codes;
108703 +}
108704 +
108705 +static inline tree get_original_function_decl(tree fndecl)
108706 +{
108707 + if (DECL_ABSTRACT_ORIGIN(fndecl))
108708 + return DECL_ABSTRACT_ORIGIN(fndecl);
108709 + return fndecl;
108710 +}
108711 +
108712 +static inline gimple get_def_stmt(const_tree node)
108713 +{
108714 + gcc_assert(node != NULL_TREE);
108715 + if (TREE_CODE(node) != SSA_NAME)
108716 + return NULL;
108717 + return SSA_NAME_DEF_STMT(node);
108718 +}
108719 +
108720 +static unsigned char get_tree_code(const_tree type)
108721 +{
108722 + switch (TREE_CODE(type)) {
108723 + case ARRAY_TYPE:
108724 + return 0;
108725 + case BOOLEAN_TYPE:
108726 + return 1;
108727 + case ENUMERAL_TYPE:
108728 + return 2;
108729 + case FUNCTION_TYPE:
108730 + return 3;
108731 + case INTEGER_TYPE:
108732 + return 4;
108733 + case POINTER_TYPE:
108734 + return 5;
108735 + case RECORD_TYPE:
108736 + return 6;
108737 + case UNION_TYPE:
108738 + return 7;
108739 + case VOID_TYPE:
108740 + return 8;
108741 + case REAL_TYPE:
108742 + return 9;
108743 + case VECTOR_TYPE:
108744 + return 10;
108745 + case REFERENCE_TYPE:
108746 + return 11;
108747 + case OFFSET_TYPE:
108748 + return 12;
108749 + case COMPLEX_TYPE:
108750 + return 13;
108751 + default:
108752 + debug_tree((tree)type);
108753 + gcc_unreachable();
108754 + }
108755 +}
108756 +
108757 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
108758 +{
108759 + gcc_assert(type != NULL_TREE);
108760 +
108761 + while (type && len < CODES_LIMIT) {
108762 + tree_codes[len] = get_tree_code(type);
108763 + len++;
108764 + type = TREE_TYPE(type);
108765 + }
108766 + return len;
108767 +}
108768 +
108769 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
108770 +{
108771 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
108772 + enum tree_code code = TREE_CODE(type);
108773 + size_t len = 0;
108774 +
108775 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
108776 +
108777 + arg = TYPE_ARG_TYPES(type);
108778 + // skip builtins __builtin_constant_p
108779 + if (!arg && DECL_BUILT_IN(fndecl))
108780 + return 0;
108781 +
108782 + if (TREE_CODE_CLASS(code) == tcc_type)
108783 + result = type;
108784 + else
108785 + result = DECL_RESULT(fndecl);
108786 +
108787 + gcc_assert(result != NULL_TREE);
108788 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
108789 +
108790 + if (arg == NULL_TREE) {
108791 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
108792 + arg_field = DECL_ARGUMENT_FLD(fndecl);
108793 + if (arg_field == NULL_TREE)
108794 + return 0;
108795 + arg = TREE_TYPE(arg_field);
108796 + len = add_type_codes(arg, tree_codes, len);
108797 + gcc_assert(len != 0);
108798 + return len;
108799 + }
108800 +
108801 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
108802 + while (arg && len < CODES_LIMIT) {
108803 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
108804 + arg = TREE_CHAIN(arg);
108805 + }
108806 +
108807 + gcc_assert(len != 0);
108808 + return len;
108809 +}
108810 +
108811 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
108812 +{
108813 + unsigned int hash;
108814 + const struct size_overflow_hash *entry;
108815 + unsigned char tree_codes[CODES_LIMIT];
108816 + size_t len;
108817 + const char *func_name;
108818 +
108819 + fndecl = get_original_function_decl(fndecl);
108820 + len = get_function_decl(fndecl, tree_codes);
108821 + if (len == 0)
108822 + return NULL;
108823 +
108824 + func_name = get_asm_name(fndecl);
108825 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
108826 +
108827 + entry = size_overflow_hash[hash];
108828 + while (entry) {
108829 + if (!strcmp(entry->name, func_name))
108830 + return entry;
108831 + entry = entry->next;
108832 + }
108833 +
108834 + return NULL;
108835 +}
108836 +
108837 +static bool is_bool(const_tree node)
108838 +{
108839 + const_tree type;
108840 +
108841 + if (node == NULL_TREE)
108842 + return false;
108843 +
108844 + type = TREE_TYPE(node);
108845 + if (!INTEGRAL_TYPE_P(type))
108846 + return false;
108847 + if (TREE_CODE(type) == BOOLEAN_TYPE)
108848 + return true;
108849 + if (TYPE_PRECISION(type) == 1)
108850 + return true;
108851 + return false;
108852 +}
108853 +
108854 +static bool skip_types(const_tree var)
108855 +{
108856 + tree type;
108857 +
108858 + if (is_gimple_constant(var))
108859 + return true;
108860 +
108861 + switch (TREE_CODE(var)) {
108862 + case ADDR_EXPR:
108863 +#if BUILDING_GCC_VERSION >= 4006
108864 + case MEM_REF:
108865 +#endif
108866 + case ARRAY_REF:
108867 + case BIT_FIELD_REF:
108868 + case INDIRECT_REF:
108869 + case TARGET_MEM_REF:
108870 + return true;
108871 + case PARM_DECL:
108872 + case VAR_DECL:
108873 + case COMPONENT_REF:
108874 + return false;
108875 + default:
108876 + break;
108877 + }
108878 +
108879 + gcc_assert(TREE_CODE(var) == SSA_NAME);
108880 +
108881 + type = TREE_TYPE(var);
108882 + switch (TREE_CODE(type)) {
108883 + case INTEGER_TYPE:
108884 + case ENUMERAL_TYPE:
108885 + return false;
108886 + case BOOLEAN_TYPE:
108887 + return is_bool(var);
108888 + default:
108889 + break;
108890 + }
108891 +
108892 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
108893 +
108894 + type = TREE_TYPE(type);
108895 + gcc_assert(type != NULL_TREE);
108896 + switch (TREE_CODE(type)) {
108897 + case RECORD_TYPE:
108898 + case POINTER_TYPE:
108899 + case ARRAY_TYPE:
108900 + return true;
108901 + case VOID_TYPE:
108902 + case INTEGER_TYPE:
108903 + case UNION_TYPE:
108904 + return false;
108905 + default:
108906 + break;
108907 + }
108908 +
108909 + debug_tree((tree)var);
108910 + gcc_unreachable();
108911 +}
108912 +
108913 +static unsigned int find_arg_number(const_tree arg, tree func)
108914 +{
108915 + tree var;
108916 + unsigned int argnum = 1;
108917 +
108918 + if (TREE_CODE(arg) == SSA_NAME)
108919 + arg = SSA_NAME_VAR(arg);
108920 +
108921 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
108922 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
108923 + continue;
108924 + if (!skip_types(var))
108925 + return argnum;
108926 + }
108927 +
108928 + return 0;
108929 +}
108930 +
108931 +static tree create_new_var(tree type)
108932 +{
108933 + tree new_var = create_tmp_var(type, "cicus");
108934 +
108935 +#if BUILDING_GCC_VERSION <= 4007
108936 + add_referenced_var(new_var);
108937 +#endif
108938 + return new_var;
108939 +}
108940 +
108941 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
108942 +{
108943 + gimple assign;
108944 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108945 + tree type = TREE_TYPE(rhs1);
108946 + tree lhs = create_new_var(type);
108947 +
108948 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
108949 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
108950 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108951 +
108952 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
108953 + update_stmt(assign);
108954 + gimple_set_plf(assign, MY_STMT, true);
108955 + return assign;
108956 +}
108957 +
108958 +static tree cast_a_tree(tree type, tree var)
108959 +{
108960 + gcc_assert(type != NULL_TREE);
108961 + gcc_assert(var != NULL_TREE);
108962 + gcc_assert(fold_convertible_p(type, var));
108963 +
108964 + return fold_convert(type, var);
108965 +}
108966 +
108967 +static tree get_lhs(const_gimple stmt)
108968 +{
108969 + switch (gimple_code(stmt)) {
108970 + case GIMPLE_ASSIGN:
108971 + return gimple_get_lhs(stmt);
108972 + case GIMPLE_PHI:
108973 + return gimple_phi_result(stmt);
108974 + case GIMPLE_CALL:
108975 + return gimple_call_lhs(stmt);
108976 + default:
108977 + return NULL_TREE;
108978 + }
108979 +}
108980 +
108981 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
108982 +{
108983 + const_gimple def_stmt = get_def_stmt(rhs);
108984 +
108985 + if (force)
108986 + return false;
108987 +
108988 + if (is_gimple_constant(rhs))
108989 + return false;
108990 +
108991 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
108992 + return false;
108993 +
108994 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
108995 + return false;
108996 +
108997 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
108998 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
108999 + return false;
109000 +
109001 + return true;
109002 +}
109003 +
109004 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
109005 +{
109006 + gimple assign, def_stmt;
109007 +
109008 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
109009 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
109010 + gcc_unreachable();
109011 +
109012 + def_stmt = get_def_stmt(rhs);
109013 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
109014 + return def_stmt;
109015 +
109016 + if (lhs == CREATE_NEW_VAR)
109017 + lhs = create_new_var(dst_type);
109018 +
109019 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
109020 +
109021 + if (!gsi_end_p(*gsi)) {
109022 + location_t loc = gimple_location(gsi_stmt(*gsi));
109023 + gimple_set_location(assign, loc);
109024 + }
109025 +
109026 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
109027 +
109028 + if (before)
109029 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
109030 + else
109031 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
109032 + update_stmt(assign);
109033 + gimple_set_plf(assign, MY_STMT, true);
109034 +
109035 + return assign;
109036 +}
109037 +
109038 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
109039 +{
109040 + gimple_stmt_iterator gsi;
109041 + tree lhs;
109042 + const_gimple new_stmt;
109043 +
109044 + if (rhs == NULL_TREE)
109045 + return NULL_TREE;
109046 +
109047 + gsi = gsi_for_stmt(stmt);
109048 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
109049 +
109050 + lhs = get_lhs(new_stmt);
109051 + gcc_assert(lhs != NULL_TREE);
109052 + return lhs;
109053 +}
109054 +
109055 +static tree cast_to_TI_type(gimple stmt, tree node)
109056 +{
109057 + gimple_stmt_iterator gsi;
109058 + gimple cast_stmt;
109059 + tree type = TREE_TYPE(node);
109060 +
109061 + if (types_compatible_p(type, intTI_type_node))
109062 + return node;
109063 +
109064 + gsi = gsi_for_stmt(stmt);
109065 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109066 + return gimple_get_lhs(cast_stmt);
109067 +}
109068 +
109069 +static void check_function_hash(const_gimple stmt)
109070 +{
109071 + tree func;
109072 + const struct size_overflow_hash *hash;
109073 +
109074 + if (gimple_code(stmt) != GIMPLE_CALL)
109075 + return;
109076 +
109077 + func = gimple_call_fndecl(stmt);
109078 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
109079 + if (func == NULL_TREE)
109080 + return;
109081 +
109082 + hash = get_function_hash(func);
109083 + if (!hash)
109084 + print_missing_msg(func, 0);
109085 +}
109086 +
109087 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
109088 +{
109089 + tree lhs, new_lhs;
109090 + gimple_stmt_iterator gsi;
109091 +
109092 + if (rhs1 == NULL_TREE) {
109093 + debug_gimple_stmt(oldstmt);
109094 + error("%s: rhs1 is NULL_TREE", __func__);
109095 + gcc_unreachable();
109096 + }
109097 +
109098 + switch (gimple_code(oldstmt)) {
109099 + case GIMPLE_ASM:
109100 + lhs = rhs1;
109101 + break;
109102 + case GIMPLE_CALL:
109103 + lhs = gimple_call_lhs(oldstmt);
109104 + break;
109105 + case GIMPLE_ASSIGN:
109106 + lhs = gimple_get_lhs(oldstmt);
109107 + break;
109108 + default:
109109 + debug_gimple_stmt(oldstmt);
109110 + gcc_unreachable();
109111 + }
109112 +
109113 + gsi = gsi_for_stmt(oldstmt);
109114 + pointer_set_insert(visited, oldstmt);
109115 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
109116 + basic_block next_bb, cur_bb;
109117 + const_edge e;
109118 +
109119 + gcc_assert(before == false);
109120 + gcc_assert(stmt_can_throw_internal(oldstmt));
109121 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
109122 + gcc_assert(!gsi_end_p(gsi));
109123 +
109124 + cur_bb = gimple_bb(oldstmt);
109125 + next_bb = cur_bb->next_bb;
109126 + e = find_edge(cur_bb, next_bb);
109127 + gcc_assert(e != NULL);
109128 + gcc_assert(e->flags & EDGE_FALLTHRU);
109129 +
109130 + gsi = gsi_after_labels(next_bb);
109131 + gcc_assert(!gsi_end_p(gsi));
109132 +
109133 + before = true;
109134 + oldstmt = gsi_stmt(gsi);
109135 + }
109136 +
109137 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
109138 + return new_lhs;
109139 +}
109140 +
109141 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
109142 +{
109143 + gimple stmt;
109144 + gimple_stmt_iterator gsi;
109145 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
109146 +
109147 + if (gimple_plf(oldstmt, MY_STMT))
109148 + return lhs;
109149 +
109150 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
109151 + rhs1 = gimple_assign_rhs1(oldstmt);
109152 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
109153 + }
109154 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
109155 + rhs2 = gimple_assign_rhs2(oldstmt);
109156 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
109157 + }
109158 +
109159 + stmt = gimple_copy(oldstmt);
109160 + gimple_set_location(stmt, gimple_location(oldstmt));
109161 + gimple_set_plf(stmt, MY_STMT, true);
109162 +
109163 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
109164 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
109165 +
109166 + size_overflow_type = get_size_overflow_type(oldstmt, node);
109167 +
109168 + new_var = create_new_var(size_overflow_type);
109169 + new_var = make_ssa_name(new_var, stmt);
109170 + gimple_set_lhs(stmt, new_var);
109171 +
109172 + if (rhs1 != NULL_TREE)
109173 + gimple_assign_set_rhs1(stmt, rhs1);
109174 +
109175 + if (rhs2 != NULL_TREE)
109176 + gimple_assign_set_rhs2(stmt, rhs2);
109177 +#if BUILDING_GCC_VERSION >= 4007
109178 + if (rhs3 != NULL_TREE)
109179 + gimple_assign_set_rhs3(stmt, rhs3);
109180 +#endif
109181 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
109182 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
109183 +
109184 + gsi = gsi_for_stmt(oldstmt);
109185 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
109186 + update_stmt(stmt);
109187 + pointer_set_insert(visited, oldstmt);
109188 + return gimple_get_lhs(stmt);
109189 +}
109190 +
109191 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
109192 +{
109193 + basic_block first_bb;
109194 + gimple assign;
109195 + gimple_stmt_iterator gsi;
109196 +
109197 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
109198 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
109199 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
109200 +
109201 + gsi = gsi_start_bb(first_bb);
109202 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
109203 + return gimple_get_lhs(assign);
109204 +}
109205 +
109206 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
109207 +{
109208 + gimple_stmt_iterator gsi;
109209 + const_gimple assign;
109210 + gimple def_stmt = get_def_stmt(new_arg);
109211 +
109212 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
109213 + gsi = gsi_after_labels(gimple_bb(def_stmt));
109214 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
109215 + } else {
109216 + gsi = gsi_for_stmt(def_stmt);
109217 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
109218 + }
109219 +
109220 + return gimple_get_lhs(assign);
109221 +}
109222 +
109223 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
109224 +{
109225 + basic_block bb;
109226 + gimple_stmt_iterator gsi;
109227 + const_gimple assign, def_stmt;
109228 +
109229 + def_stmt = get_def_stmt(arg);
109230 + bb = gimple_bb(def_stmt);
109231 + gcc_assert(bb->index != 0);
109232 + gsi = gsi_after_labels(bb);
109233 +
109234 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
109235 + return gimple_get_lhs(assign);
109236 +}
109237 +
109238 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
109239 +{
109240 + tree size_overflow_type;
109241 + const_gimple def_stmt = get_def_stmt(arg);
109242 +
109243 + if (phi_ssa_name != NULL_TREE)
109244 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
109245 +
109246 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
109247 +
109248 + if (new_arg != NULL_TREE) {
109249 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
109250 + return use_phi_ssa_name(phi_ssa_name, new_arg);
109251 + }
109252 +
109253 + switch(gimple_code(def_stmt)) {
109254 + case GIMPLE_PHI:
109255 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
109256 + case GIMPLE_NOP:
109257 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
109258 + default:
109259 + debug_gimple_stmt((gimple)def_stmt);
109260 + gcc_unreachable();
109261 + }
109262 +}
109263 +
109264 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
109265 +{
109266 + basic_block bb;
109267 + gimple phi;
109268 + gimple_seq seq;
109269 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
109270 +
109271 + bb = gsi_bb(gsi);
109272 +
109273 + phi = create_phi_node(result, bb);
109274 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
109275 + seq = phi_nodes(bb);
109276 + gsi = gsi_last(seq);
109277 + gsi_remove(&gsi, false);
109278 +
109279 + gsi = gsi_for_stmt(oldstmt);
109280 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
109281 + gimple_set_bb(phi, bb);
109282 + gimple_set_plf(phi, MY_STMT, true);
109283 + return phi;
109284 +}
109285 +
109286 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
109287 +{
109288 + gimple new_phi = NULL;
109289 + gimple oldstmt = get_def_stmt(orig_result);
109290 + tree phi_ssa_name = NULL_TREE;
109291 + unsigned int i;
109292 +
109293 + pointer_set_insert(visited, oldstmt);
109294 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
109295 + tree arg, new_arg;
109296 +
109297 + arg = gimple_phi_arg_def(oldstmt, i);
109298 +
109299 + new_arg = expand(visited, arg);
109300 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
109301 + if (i == 0) {
109302 + phi_ssa_name = new_arg;
109303 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
109304 + }
109305 +
109306 + gcc_assert(new_phi != NULL);
109307 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
109308 + }
109309 +
109310 + gcc_assert(new_phi != NULL);
109311 + update_stmt(new_phi);
109312 + return gimple_phi_result(new_phi);
109313 +}
109314 +
109315 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
109316 +{
109317 + const_gimple assign;
109318 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109319 + tree origtype = TREE_TYPE(orig_rhs);
109320 +
109321 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
109322 +
109323 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109324 + return gimple_get_lhs(assign);
109325 +}
109326 +
109327 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
109328 +{
109329 + const_tree rhs1, lhs, rhs1_type, lhs_type;
109330 + enum machine_mode lhs_mode, rhs_mode;
109331 + gimple def_stmt = get_def_stmt(no_const_rhs);
109332 +
109333 + if (!gimple_assign_cast_p(def_stmt))
109334 + return false;
109335 +
109336 + rhs1 = gimple_assign_rhs1(def_stmt);
109337 + lhs = gimple_get_lhs(def_stmt);
109338 + rhs1_type = TREE_TYPE(rhs1);
109339 + lhs_type = TREE_TYPE(lhs);
109340 + rhs_mode = TYPE_MODE(rhs1_type);
109341 + lhs_mode = TYPE_MODE(lhs_type);
109342 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
109343 + return false;
109344 +
109345 + return true;
109346 +}
109347 +
109348 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
109349 +{
109350 + tree rhs1 = gimple_assign_rhs1(stmt);
109351 + tree lhs = gimple_get_lhs(stmt);
109352 + const_tree rhs1_type = TREE_TYPE(rhs1);
109353 + const_tree lhs_type = TREE_TYPE(lhs);
109354 +
109355 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
109356 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109357 +
109358 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
109359 +}
109360 +
109361 +static bool no_uses(tree node)
109362 +{
109363 + imm_use_iterator imm_iter;
109364 + use_operand_p use_p;
109365 +
109366 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
109367 + const_gimple use_stmt = USE_STMT(use_p);
109368 + if (use_stmt == NULL)
109369 + return true;
109370 + if (is_gimple_debug(use_stmt))
109371 + continue;
109372 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
109373 + continue;
109374 + return false;
109375 + }
109376 + return true;
109377 +}
109378 +
109379 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
109380 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
109381 +{
109382 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
109383 + gimple def_stmt = get_def_stmt(lhs);
109384 +
109385 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
109386 + return false;
109387 +
109388 + rhs1 = gimple_assign_rhs1(def_stmt);
109389 + rhs_type = TREE_TYPE(rhs1);
109390 + lhs_type = TREE_TYPE(lhs);
109391 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
109392 + return false;
109393 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
109394 + return false;
109395 +
109396 + def_stmt = get_def_stmt(rhs1);
109397 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
109398 + return false;
109399 +
109400 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
109401 + return false;
109402 +
109403 + rhs1 = gimple_assign_rhs1(def_stmt);
109404 + rhs2 = gimple_assign_rhs2(def_stmt);
109405 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
109406 + return false;
109407 +
109408 + if (is_gimple_constant(rhs2))
109409 + not_const_rhs = rhs1;
109410 + else
109411 + not_const_rhs = rhs2;
109412 +
109413 + return no_uses(not_const_rhs);
109414 +}
109415 +
109416 +static bool skip_lhs_cast_check(const_gimple stmt)
109417 +{
109418 + const_tree rhs = gimple_assign_rhs1(stmt);
109419 + const_gimple def_stmt = get_def_stmt(rhs);
109420 +
109421 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
109422 + if (gimple_code(def_stmt) == GIMPLE_ASM)
109423 + return true;
109424 +
109425 + if (is_const_plus_unsigned_signed_truncation(rhs))
109426 + return true;
109427 +
109428 + return false;
109429 +}
109430 +
109431 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
109432 +{
109433 + bool cast_lhs, cast_rhs;
109434 + tree lhs = gimple_get_lhs(stmt);
109435 + tree rhs = gimple_assign_rhs1(stmt);
109436 + const_tree lhs_type = TREE_TYPE(lhs);
109437 + const_tree rhs_type = TREE_TYPE(rhs);
109438 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
109439 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
109440 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
109441 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
109442 +
109443 + static bool check_lhs[3][4] = {
109444 + // ss su us uu
109445 + { false, true, true, false }, // lhs > rhs
109446 + { false, false, false, false }, // lhs = rhs
109447 + { true, true, true, true }, // lhs < rhs
109448 + };
109449 +
109450 + static bool check_rhs[3][4] = {
109451 + // ss su us uu
109452 + { true, false, true, true }, // lhs > rhs
109453 + { true, false, true, true }, // lhs = rhs
109454 + { true, false, true, true }, // lhs < rhs
109455 + };
109456 +
109457 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
109458 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
109459 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109460 +
109461 + if (lhs_size > rhs_size) {
109462 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109463 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109464 + } else if (lhs_size == rhs_size) {
109465 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109466 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109467 + } else {
109468 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109469 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109470 + }
109471 +
109472 + if (!cast_lhs && !cast_rhs)
109473 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109474 +
109475 + if (cast_lhs && !skip_lhs_cast_check(stmt))
109476 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
109477 +
109478 + if (cast_rhs)
109479 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
109480 +
109481 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109482 +}
109483 +
109484 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
109485 +{
109486 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
109487 +
109488 + if (gimple_plf(stmt, MY_STMT))
109489 + return lhs;
109490 +
109491 + rhs1 = gimple_assign_rhs1(stmt);
109492 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
109493 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109494 +
109495 + new_rhs1 = expand(visited, rhs1);
109496 +
109497 + if (new_rhs1 == NULL_TREE)
109498 + return create_cast_assign(visited, stmt);
109499 +
109500 + if (gimple_plf(stmt, NO_CAST_CHECK))
109501 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109502 +
109503 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
109504 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
109505 +
109506 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
109507 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
109508 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109509 + }
109510 +
109511 + if (!gimple_assign_cast_p(stmt))
109512 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109513 +
109514 + return create_cast_overflow_check(visited, new_rhs1, stmt);
109515 +}
109516 +
109517 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
109518 +{
109519 + tree rhs1, lhs = gimple_get_lhs(stmt);
109520 + gimple def_stmt = get_def_stmt(lhs);
109521 +
109522 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
109523 + rhs1 = gimple_assign_rhs1(def_stmt);
109524 +
109525 + if (is_gimple_constant(rhs1))
109526 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109527 +
109528 + switch (TREE_CODE(rhs1)) {
109529 + case SSA_NAME:
109530 + return handle_unary_rhs(visited, def_stmt);
109531 + case ARRAY_REF:
109532 + case BIT_FIELD_REF:
109533 + case ADDR_EXPR:
109534 + case COMPONENT_REF:
109535 + case INDIRECT_REF:
109536 +#if BUILDING_GCC_VERSION >= 4006
109537 + case MEM_REF:
109538 +#endif
109539 + case TARGET_MEM_REF:
109540 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109541 + case PARM_DECL:
109542 + case VAR_DECL:
109543 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109544 +
109545 + default:
109546 + debug_gimple_stmt(def_stmt);
109547 + debug_tree(rhs1);
109548 + gcc_unreachable();
109549 + }
109550 +}
109551 +
109552 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
109553 +{
109554 + gimple cond_stmt;
109555 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
109556 +
109557 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
109558 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
109559 + update_stmt(cond_stmt);
109560 +}
109561 +
109562 +static tree create_string_param(tree string)
109563 +{
109564 + tree i_type, a_type;
109565 + const int length = TREE_STRING_LENGTH(string);
109566 +
109567 + gcc_assert(length > 0);
109568 +
109569 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
109570 + a_type = build_array_type(char_type_node, i_type);
109571 +
109572 + TREE_TYPE(string) = a_type;
109573 + TREE_CONSTANT(string) = 1;
109574 + TREE_READONLY(string) = 1;
109575 +
109576 + return build1(ADDR_EXPR, ptr_type_node, string);
109577 +}
109578 +
109579 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
109580 +{
109581 + gimple func_stmt;
109582 + const_gimple def_stmt;
109583 + const_tree loc_line;
109584 + tree loc_file, ssa_name, current_func;
109585 + expanded_location xloc;
109586 + char *ssa_name_buf;
109587 + int len;
109588 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
109589 +
109590 + def_stmt = get_def_stmt(arg);
109591 + xloc = expand_location(gimple_location(def_stmt));
109592 +
109593 + if (!gimple_has_location(def_stmt)) {
109594 + xloc = expand_location(gimple_location(stmt));
109595 + if (!gimple_has_location(stmt))
109596 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
109597 + }
109598 +
109599 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
109600 +
109601 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
109602 + loc_file = create_string_param(loc_file);
109603 +
109604 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
109605 + current_func = create_string_param(current_func);
109606 +
109607 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
109608 + call_count++;
109609 + 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);
109610 + gcc_assert(len > 0);
109611 + ssa_name = build_string(len + 1, ssa_name_buf);
109612 + free(ssa_name_buf);
109613 + ssa_name = create_string_param(ssa_name);
109614 +
109615 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
109616 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
109617 +
109618 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
109619 +}
109620 +
109621 +static void __unused print_the_code_insertions(const_gimple stmt)
109622 +{
109623 + location_t loc = gimple_location(stmt);
109624 +
109625 + inform(loc, "Integer size_overflow check applied here.");
109626 +}
109627 +
109628 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
109629 +{
109630 + basic_block cond_bb, join_bb, bb_true;
109631 + edge e;
109632 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109633 +
109634 + cond_bb = gimple_bb(stmt);
109635 + if (before)
109636 + gsi_prev(&gsi);
109637 + if (gsi_end_p(gsi))
109638 + e = split_block_after_labels(cond_bb);
109639 + else
109640 + e = split_block(cond_bb, gsi_stmt(gsi));
109641 + cond_bb = e->src;
109642 + join_bb = e->dest;
109643 + e->flags = EDGE_FALSE_VALUE;
109644 + e->probability = REG_BR_PROB_BASE;
109645 +
109646 + bb_true = create_empty_bb(cond_bb);
109647 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
109648 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
109649 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
109650 +
109651 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
109652 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
109653 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
109654 +
109655 + if (current_loops != NULL) {
109656 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
109657 + add_bb_to_loop(bb_true, cond_bb->loop_father);
109658 + }
109659 +
109660 + insert_cond(cond_bb, arg, cond_code, type_value);
109661 + insert_cond_result(bb_true, stmt, arg, min);
109662 +
109663 +// print_the_code_insertions(stmt);
109664 +}
109665 +
109666 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
109667 +{
109668 + const_tree rhs_type = TREE_TYPE(rhs);
109669 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
109670 +
109671 + gcc_assert(rhs_type != NULL_TREE);
109672 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
109673 + return;
109674 +
109675 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
109676 +
109677 + if (is_const_plus_unsigned_signed_truncation(rhs))
109678 + return;
109679 +
109680 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
109681 + // typemax (-1) < typemin (0)
109682 + if (TREE_OVERFLOW(type_max))
109683 + return;
109684 +
109685 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
109686 +
109687 + cast_rhs_type = TREE_TYPE(cast_rhs);
109688 + type_max_type = TREE_TYPE(type_max);
109689 + type_min_type = TREE_TYPE(type_min);
109690 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
109691 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
109692 +
109693 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
109694 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
109695 +}
109696 +
109697 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
109698 +{
109699 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
109700 + return false;
109701 + if (!is_gimple_constant(rhs))
109702 + return false;
109703 + return true;
109704 +}
109705 +
109706 +static tree get_def_stmt_rhs(const_tree var)
109707 +{
109708 + tree rhs1, def_stmt_rhs1;
109709 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
109710 +
109711 + def_stmt = get_def_stmt(var);
109712 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
109713 +
109714 + rhs1 = gimple_assign_rhs1(def_stmt);
109715 + rhs1_def_stmt = get_def_stmt(rhs1);
109716 + if (!gimple_assign_cast_p(rhs1_def_stmt))
109717 + return rhs1;
109718 +
109719 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109720 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
109721 +
109722 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
109723 + case GIMPLE_CALL:
109724 + case GIMPLE_NOP:
109725 + case GIMPLE_ASM:
109726 + case GIMPLE_PHI:
109727 + return def_stmt_rhs1;
109728 + case GIMPLE_ASSIGN:
109729 + return rhs1;
109730 + default:
109731 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
109732 + gcc_unreachable();
109733 + }
109734 +}
109735 +
109736 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
109737 +{
109738 + tree new_rhs, orig_rhs;
109739 + void (*gimple_assign_set_rhs)(gimple, tree);
109740 + tree rhs1 = gimple_assign_rhs1(stmt);
109741 + tree rhs2 = gimple_assign_rhs2(stmt);
109742 + tree lhs = gimple_get_lhs(stmt);
109743 +
109744 + if (!check_overflow)
109745 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109746 +
109747 + if (change_rhs == NULL_TREE)
109748 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109749 +
109750 + if (new_rhs2 == NULL_TREE) {
109751 + orig_rhs = rhs1;
109752 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
109753 + } else {
109754 + orig_rhs = rhs2;
109755 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
109756 + }
109757 +
109758 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
109759 +
109760 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
109761 + gimple_assign_set_rhs(stmt, new_rhs);
109762 + update_stmt(stmt);
109763 +
109764 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109765 +}
109766 +
109767 +static bool is_subtraction_special(const_gimple stmt)
109768 +{
109769 + gimple rhs1_def_stmt, rhs2_def_stmt;
109770 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
109771 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
109772 + const_tree rhs1 = gimple_assign_rhs1(stmt);
109773 + const_tree rhs2 = gimple_assign_rhs2(stmt);
109774 +
109775 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
109776 + return false;
109777 +
109778 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
109779 +
109780 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
109781 + return false;
109782 +
109783 + rhs1_def_stmt = get_def_stmt(rhs1);
109784 + rhs2_def_stmt = get_def_stmt(rhs2);
109785 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
109786 + return false;
109787 +
109788 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109789 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
109790 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
109791 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
109792 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
109793 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
109794 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
109795 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
109796 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
109797 + return false;
109798 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
109799 + return false;
109800 +
109801 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
109802 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
109803 + return true;
109804 +}
109805 +
109806 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
109807 +{
109808 + tree new_rhs1, new_rhs2;
109809 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
109810 + gimple assign, stmt = get_def_stmt(lhs);
109811 + tree rhs1 = gimple_assign_rhs1(stmt);
109812 + tree rhs2 = gimple_assign_rhs2(stmt);
109813 +
109814 + if (!is_subtraction_special(stmt))
109815 + return NULL_TREE;
109816 +
109817 + new_rhs1 = expand(visited, rhs1);
109818 + new_rhs2 = expand(visited, rhs2);
109819 +
109820 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
109821 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
109822 +
109823 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
109824 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
109825 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
109826 + }
109827 +
109828 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
109829 + new_lhs = gimple_get_lhs(assign);
109830 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
109831 +
109832 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109833 +}
109834 +
109835 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
109836 +{
109837 + const_gimple def_stmt;
109838 +
109839 + if (TREE_CODE(rhs) != SSA_NAME)
109840 + return false;
109841 +
109842 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
109843 + return false;
109844 +
109845 + def_stmt = get_def_stmt(rhs);
109846 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
109847 + return false;
109848 +
109849 + return true;
109850 +}
109851 +
109852 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
109853 +{
109854 + tree rhs1, rhs2, new_lhs;
109855 + gimple def_stmt = get_def_stmt(lhs);
109856 + tree new_rhs1 = NULL_TREE;
109857 + tree new_rhs2 = NULL_TREE;
109858 +
109859 + rhs1 = gimple_assign_rhs1(def_stmt);
109860 + rhs2 = gimple_assign_rhs2(def_stmt);
109861 +
109862 + /* no DImode/TImode division in the 32/64 bit kernel */
109863 + switch (gimple_assign_rhs_code(def_stmt)) {
109864 + case RDIV_EXPR:
109865 + case TRUNC_DIV_EXPR:
109866 + case CEIL_DIV_EXPR:
109867 + case FLOOR_DIV_EXPR:
109868 + case ROUND_DIV_EXPR:
109869 + case TRUNC_MOD_EXPR:
109870 + case CEIL_MOD_EXPR:
109871 + case FLOOR_MOD_EXPR:
109872 + case ROUND_MOD_EXPR:
109873 + case EXACT_DIV_EXPR:
109874 + case POINTER_PLUS_EXPR:
109875 + case BIT_AND_EXPR:
109876 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109877 + default:
109878 + break;
109879 + }
109880 +
109881 + new_lhs = handle_integer_truncation(visited, lhs);
109882 + if (new_lhs != NULL_TREE)
109883 + return new_lhs;
109884 +
109885 + if (TREE_CODE(rhs1) == SSA_NAME)
109886 + new_rhs1 = expand(visited, rhs1);
109887 + if (TREE_CODE(rhs2) == SSA_NAME)
109888 + new_rhs2 = expand(visited, rhs2);
109889 +
109890 + if (is_a_neg_overflow(def_stmt, rhs2))
109891 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
109892 + if (is_a_neg_overflow(def_stmt, rhs1))
109893 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
109894 +
109895 +
109896 + if (is_a_constant_overflow(def_stmt, rhs2))
109897 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
109898 + if (is_a_constant_overflow(def_stmt, rhs1))
109899 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
109900 +
109901 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109902 +}
109903 +
109904 +#if BUILDING_GCC_VERSION >= 4007
109905 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
109906 +{
109907 + if (is_gimple_constant(rhs))
109908 + return cast_a_tree(size_overflow_type, rhs);
109909 + if (TREE_CODE(rhs) != SSA_NAME)
109910 + return NULL_TREE;
109911 + return expand(visited, rhs);
109912 +}
109913 +
109914 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
109915 +{
109916 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
109917 + gimple def_stmt = get_def_stmt(lhs);
109918 +
109919 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
109920 +
109921 + rhs1 = gimple_assign_rhs1(def_stmt);
109922 + rhs2 = gimple_assign_rhs2(def_stmt);
109923 + rhs3 = gimple_assign_rhs3(def_stmt);
109924 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
109925 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
109926 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
109927 +
109928 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
109929 +}
109930 +#endif
109931 +
109932 +static tree get_size_overflow_type(gimple stmt, const_tree node)
109933 +{
109934 + const_tree type;
109935 + tree new_type;
109936 +
109937 + gcc_assert(node != NULL_TREE);
109938 +
109939 + type = TREE_TYPE(node);
109940 +
109941 + if (gimple_plf(stmt, MY_STMT))
109942 + return TREE_TYPE(node);
109943 +
109944 + switch (TYPE_MODE(type)) {
109945 + case QImode:
109946 + new_type = intHI_type_node;
109947 + break;
109948 + case HImode:
109949 + new_type = intSI_type_node;
109950 + break;
109951 + case SImode:
109952 + new_type = intDI_type_node;
109953 + break;
109954 + case DImode:
109955 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
109956 + new_type = intDI_type_node;
109957 + else
109958 + new_type = intTI_type_node;
109959 + break;
109960 + default:
109961 + debug_tree((tree)node);
109962 + error("%s: unsupported gcc configuration.", __func__);
109963 + gcc_unreachable();
109964 + }
109965 +
109966 + if (TYPE_QUALS(type) != 0)
109967 + return build_qualified_type(new_type, TYPE_QUALS(type));
109968 + return new_type;
109969 +}
109970 +
109971 +static tree expand_visited(gimple def_stmt)
109972 +{
109973 + const_gimple next_stmt;
109974 + gimple_stmt_iterator gsi;
109975 + enum gimple_code code = gimple_code(def_stmt);
109976 +
109977 + if (code == GIMPLE_ASM)
109978 + return NULL_TREE;
109979 +
109980 + gsi = gsi_for_stmt(def_stmt);
109981 + gsi_next(&gsi);
109982 +
109983 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
109984 + return NULL_TREE;
109985 + gcc_assert(!gsi_end_p(gsi));
109986 + next_stmt = gsi_stmt(gsi);
109987 +
109988 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
109989 + return NULL_TREE;
109990 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
109991 +
109992 + return get_lhs(next_stmt);
109993 +}
109994 +
109995 +static tree expand(struct pointer_set_t *visited, tree lhs)
109996 +{
109997 + gimple def_stmt;
109998 +
109999 + if (skip_types(lhs))
110000 + return NULL_TREE;
110001 +
110002 + def_stmt = get_def_stmt(lhs);
110003 +
110004 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
110005 + return NULL_TREE;
110006 +
110007 + if (gimple_plf(def_stmt, MY_STMT))
110008 + return lhs;
110009 +
110010 + if (pointer_set_contains(visited, def_stmt))
110011 + return expand_visited(def_stmt);
110012 +
110013 + switch (gimple_code(def_stmt)) {
110014 + case GIMPLE_PHI:
110015 + return handle_phi(visited, lhs);
110016 + case GIMPLE_CALL:
110017 + case GIMPLE_ASM:
110018 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
110019 + case GIMPLE_ASSIGN:
110020 + switch (gimple_num_ops(def_stmt)) {
110021 + case 2:
110022 + return handle_unary_ops(visited, def_stmt);
110023 + case 3:
110024 + return handle_binary_ops(visited, lhs);
110025 +#if BUILDING_GCC_VERSION >= 4007
110026 + case 4:
110027 + return handle_ternary_ops(visited, lhs);
110028 +#endif
110029 + }
110030 + default:
110031 + debug_gimple_stmt(def_stmt);
110032 + error("%s: unknown gimple code", __func__);
110033 + gcc_unreachable();
110034 + }
110035 +}
110036 +
110037 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
110038 +{
110039 + const_gimple assign;
110040 + tree orig_type = TREE_TYPE(orig_node);
110041 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110042 +
110043 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110044 + return gimple_get_lhs(assign);
110045 +}
110046 +
110047 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
110048 +{
110049 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
110050 + update_stmt(stmt);
110051 +}
110052 +
110053 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
110054 +{
110055 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
110056 + update_stmt(stmt);
110057 +}
110058 +
110059 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
110060 +{
110061 + tree arg;
110062 + const_tree origarg;
110063 +
110064 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
110065 + return true;
110066 +
110067 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
110068 + while (origarg && *argnum) {
110069 + (*argnum)--;
110070 + origarg = TREE_CHAIN(origarg);
110071 + }
110072 +
110073 + gcc_assert(*argnum == 0);
110074 +
110075 + gcc_assert(origarg != NULL_TREE);
110076 + *argnum = 0;
110077 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
110078 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
110079 + return true;
110080 + return false;
110081 +}
110082 +
110083 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
110084 +{
110085 + gimple phi = get_def_stmt(result);
110086 + unsigned int i, n = gimple_phi_num_args(phi);
110087 +
110088 + if (!phi)
110089 + return MARK_NO;
110090 +
110091 + pointer_set_insert(visited, phi);
110092 + for (i = 0; i < n; i++) {
110093 + enum mark marked;
110094 + const_tree arg = gimple_phi_arg_def(phi, i);
110095 + marked = pre_expand(visited, search_err_code, arg);
110096 + if (marked != MARK_NO)
110097 + return marked;
110098 + }
110099 + return MARK_NO;
110100 +}
110101 +
110102 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
110103 +{
110104 + gimple def_stmt = get_def_stmt(lhs);
110105 + const_tree rhs;
110106 +
110107 + if (!def_stmt)
110108 + return MARK_NO;
110109 +
110110 + rhs = gimple_assign_rhs1(def_stmt);
110111 +
110112 + def_stmt = get_def_stmt(rhs);
110113 + if (is_gimple_constant(rhs))
110114 + search_err_code[FROM_CONST] = true;
110115 +
110116 + return pre_expand(visited, search_err_code, rhs);
110117 +}
110118 +
110119 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
110120 +{
110121 + gimple def_stmt = get_def_stmt(lhs);
110122 + const_tree rhs1, rhs2;
110123 + enum mark marked;
110124 +
110125 + if (!def_stmt)
110126 + return MARK_NO;
110127 +
110128 + search_err_code[CAST_ONLY] = false;
110129 +
110130 + rhs1 = gimple_assign_rhs1(def_stmt);
110131 + rhs2 = gimple_assign_rhs2(def_stmt);
110132 + marked = pre_expand(visited, search_err_code, rhs1);
110133 + if (marked != MARK_NO)
110134 + return marked;
110135 + return pre_expand(visited, search_err_code, rhs2);
110136 +}
110137 +
110138 +static const_tree search_field_decl(const_tree comp_ref)
110139 +{
110140 + const_tree field = NULL_TREE;
110141 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
110142 +
110143 + for (i = 0; i < len; i++) {
110144 + field = TREE_OPERAND(comp_ref, i);
110145 + if (TREE_CODE(field) == FIELD_DECL)
110146 + break;
110147 + }
110148 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
110149 + return field;
110150 +}
110151 +
110152 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
110153 +{
110154 + const_tree attr, p;
110155 +
110156 + // 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);
110157 + if (fndecl == NULL_TREE)
110158 + return MARK_NO;
110159 +
110160 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
110161 + if (!attr || !TREE_VALUE(attr))
110162 + return MARK_NO;
110163 +
110164 + p = TREE_VALUE(attr);
110165 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
110166 + return MARK_TURN_OFF;
110167 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
110168 + return MARK_NOT_INTENTIONAL;
110169 + if (argnum == 0) {
110170 + gcc_assert(current_function_decl == fndecl);
110171 + return MARK_NO;
110172 + }
110173 +
110174 + do {
110175 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
110176 + return MARK_YES;
110177 + p = TREE_CHAIN(p);
110178 + } while (p);
110179 +
110180 + return MARK_NO;
110181 +}
110182 +
110183 +static void print_missing_msg(tree func, unsigned int argnum)
110184 +{
110185 + unsigned int new_hash;
110186 + size_t len;
110187 + unsigned char tree_codes[CODES_LIMIT];
110188 + location_t loc;
110189 + const char *curfunc;
110190 +
110191 + func = get_original_function_decl(func);
110192 + loc = DECL_SOURCE_LOCATION(func);
110193 + curfunc = get_asm_name(func);
110194 +
110195 + len = get_function_decl(func, tree_codes);
110196 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
110197 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
110198 +}
110199 +
110200 +static unsigned int search_missing_attribute(const_tree arg)
110201 +{
110202 + unsigned int argnum;
110203 + const struct size_overflow_hash *hash;
110204 + const_tree type = TREE_TYPE(arg);
110205 + tree func = get_original_function_decl(current_function_decl);
110206 +
110207 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
110208 +
110209 + if (TREE_CODE(type) == POINTER_TYPE)
110210 + return 0;
110211 +
110212 + argnum = find_arg_number(arg, func);
110213 + if (argnum == 0)
110214 + return 0;
110215 +
110216 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
110217 + return argnum;
110218 +
110219 + hash = get_function_hash(func);
110220 + if (!hash || !(hash->param & (1U << argnum))) {
110221 + print_missing_msg(func, argnum);
110222 + return 0;
110223 + }
110224 + return argnum;
110225 +}
110226 +
110227 +static enum mark is_already_marked(const_tree lhs)
110228 +{
110229 + unsigned int argnum;
110230 + const_tree fndecl;
110231 +
110232 + argnum = search_missing_attribute(lhs);
110233 + fndecl = get_original_function_decl(current_function_decl);
110234 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
110235 + return MARK_YES;
110236 + return MARK_NO;
110237 +}
110238 +
110239 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
110240 +{
110241 + const_gimple def_stmt;
110242 +
110243 + if (skip_types(lhs))
110244 + return MARK_NO;
110245 +
110246 + if (TREE_CODE(lhs) == PARM_DECL)
110247 + return is_already_marked(lhs);
110248 +
110249 + if (TREE_CODE(lhs) == COMPONENT_REF) {
110250 + const_tree field, attr;
110251 +
110252 + field = search_field_decl(lhs);
110253 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
110254 + if (!attr || !TREE_VALUE(attr))
110255 + return MARK_NO;
110256 + return MARK_YES;
110257 + }
110258 +
110259 + def_stmt = get_def_stmt(lhs);
110260 +
110261 + if (!def_stmt)
110262 + return MARK_NO;
110263 +
110264 + if (pointer_set_contains(visited, def_stmt))
110265 + return MARK_NO;
110266 +
110267 + switch (gimple_code(def_stmt)) {
110268 + case GIMPLE_NOP:
110269 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
110270 + return is_already_marked(lhs);
110271 + return MARK_NO;
110272 + case GIMPLE_PHI:
110273 + return walk_phi(visited, search_err_code, lhs);
110274 + case GIMPLE_CALL:
110275 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
110276 + return MARK_TURN_OFF;
110277 + check_function_hash(def_stmt);
110278 + return MARK_NO;
110279 + case GIMPLE_ASM:
110280 + search_err_code[CAST_ONLY] = false;
110281 + return MARK_NO;
110282 + case GIMPLE_ASSIGN:
110283 + switch (gimple_num_ops(def_stmt)) {
110284 + case 2:
110285 + return walk_unary_ops(visited, search_err_code, lhs);
110286 + case 3:
110287 + return walk_binary_ops(visited, search_err_code, lhs);
110288 + }
110289 + default:
110290 + debug_gimple_stmt((gimple)def_stmt);
110291 + error("%s: unknown gimple code", __func__);
110292 + gcc_unreachable();
110293 + }
110294 +}
110295 +
110296 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
110297 +static bool skip_asm(const_tree arg)
110298 +{
110299 + gimple def_stmt = get_def_stmt(arg);
110300 +
110301 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
110302 + return false;
110303 +
110304 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
110305 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
110306 +}
110307 +
110308 +/*
110309 +0</MARK_YES: no dup, search attributes (so, int)
110310 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
110311 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
110312 +*/
110313 +
110314 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
110315 +{
110316 + struct pointer_set_t *visited;
110317 + enum mark is_marked, is_found;
110318 + location_t loc;
110319 + bool search_err_code[2] = {true, false};
110320 +
110321 + is_marked = mark_status(current_function_decl, 0);
110322 + if (is_marked == MARK_TURN_OFF)
110323 + return true;
110324 +
110325 + is_marked = mark_status(fndecl, argnum + 1);
110326 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
110327 + return true;
110328 +
110329 + visited = pointer_set_create();
110330 + is_found = pre_expand(visited, search_err_code, arg);
110331 + pointer_set_destroy(visited);
110332 +
110333 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
110334 + return true;
110335 +
110336 + if (where == FROM_ARG && skip_asm(arg))
110337 + return true;
110338 +
110339 + if (is_found == MARK_TURN_OFF)
110340 + return true;
110341 +
110342 + if ((is_found == MARK_YES && is_marked == MARK_YES))
110343 + return true;
110344 +
110345 + if (is_found == MARK_YES) {
110346 + loc = DECL_SOURCE_LOCATION(fndecl);
110347 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
110348 + return true;
110349 + }
110350 + return false;
110351 +}
110352 +
110353 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
110354 +{
110355 + struct pointer_set_t *visited;
110356 + tree arg, new_arg;
110357 + bool match;
110358 +
110359 + if (argnum == 0)
110360 + return;
110361 +
110362 + argnum--;
110363 +
110364 + match = get_function_arg(&argnum, fndecl);
110365 + if (!match)
110366 + return;
110367 + gcc_assert(gimple_call_num_args(stmt) > argnum);
110368 + arg = gimple_call_arg(stmt, argnum);
110369 + if (arg == NULL_TREE)
110370 + return;
110371 +
110372 + if (skip_types(arg))
110373 + return;
110374 +
110375 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
110376 + return;
110377 +
110378 + visited = pointer_set_create();
110379 + new_arg = expand(visited, arg);
110380 + pointer_set_destroy(visited);
110381 +
110382 + if (new_arg == NULL_TREE)
110383 + return;
110384 +
110385 + change_function_arg(stmt, arg, argnum, new_arg);
110386 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
110387 +}
110388 +
110389 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
110390 +{
110391 + tree p = TREE_VALUE(attr);
110392 + do {
110393 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
110394 + p = TREE_CHAIN(p);
110395 + } while (p);
110396 +}
110397 +
110398 +static void handle_function_by_hash(gimple stmt, tree fndecl)
110399 +{
110400 + unsigned int num;
110401 + const struct size_overflow_hash *hash;
110402 +
110403 + hash = get_function_hash(fndecl);
110404 + if (!hash)
110405 + return;
110406 +
110407 + for (num = 0; num <= MAX_PARAM; num++)
110408 + if (hash->param & (1U << num))
110409 + handle_function_arg(stmt, fndecl, num);
110410 +}
110411 +
110412 +static bool check_return_value(void)
110413 +{
110414 + const struct size_overflow_hash *hash;
110415 +
110416 + hash = get_function_hash(current_function_decl);
110417 + if (!hash || !(hash->param & 1U << 0))
110418 + return false;
110419 +
110420 + return true;
110421 +}
110422 +
110423 +static void handle_return_value(gimple ret_stmt)
110424 +{
110425 + struct pointer_set_t *visited;
110426 + tree ret, new_ret;
110427 +
110428 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
110429 + return;
110430 +
110431 + ret = gimple_return_retval(ret_stmt);
110432 +
110433 + if (skip_types(ret))
110434 + return;
110435 +
110436 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
110437 + return;
110438 +
110439 + visited = pointer_set_create();
110440 + new_ret = expand(visited, ret);
110441 + pointer_set_destroy(visited);
110442 +
110443 + change_function_return(ret_stmt, ret, new_ret);
110444 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
110445 +}
110446 +
110447 +static void set_plf_false(void)
110448 +{
110449 + basic_block bb;
110450 +
110451 + FOR_ALL_BB(bb) {
110452 + gimple_stmt_iterator si;
110453 +
110454 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
110455 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110456 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
110457 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110458 + }
110459 +}
110460 +
110461 +static unsigned int handle_function(void)
110462 +{
110463 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
110464 + bool check_ret;
110465 +
110466 + set_plf_false();
110467 +
110468 + check_ret = check_return_value();
110469 +
110470 + do {
110471 + gimple_stmt_iterator gsi;
110472 + next = bb->next_bb;
110473 +
110474 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110475 + tree fndecl, attr;
110476 + gimple stmt = gsi_stmt(gsi);
110477 +
110478 + if (check_ret)
110479 + handle_return_value(stmt);
110480 +
110481 + if (!(is_gimple_call(stmt)))
110482 + continue;
110483 + fndecl = gimple_call_fndecl(stmt);
110484 + if (fndecl == NULL_TREE)
110485 + continue;
110486 + if (gimple_call_num_args(stmt) == 0)
110487 + continue;
110488 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
110489 + if (!attr || !TREE_VALUE(attr))
110490 + handle_function_by_hash(stmt, fndecl);
110491 + else
110492 + handle_function_by_attribute(stmt, attr, fndecl);
110493 + gsi = gsi_for_stmt(stmt);
110494 + next = gimple_bb(stmt)->next_bb;
110495 + }
110496 + bb = next;
110497 + } while (bb);
110498 + return 0;
110499 +}
110500 +
110501 +static struct gimple_opt_pass size_overflow_pass = {
110502 + .pass = {
110503 + .type = GIMPLE_PASS,
110504 + .name = "size_overflow",
110505 +#if BUILDING_GCC_VERSION >= 4008
110506 + .optinfo_flags = OPTGROUP_NONE,
110507 +#endif
110508 + .gate = NULL,
110509 + .execute = handle_function,
110510 + .sub = NULL,
110511 + .next = NULL,
110512 + .static_pass_number = 0,
110513 + .tv_id = TV_NONE,
110514 + .properties_required = PROP_cfg,
110515 + .properties_provided = 0,
110516 + .properties_destroyed = 0,
110517 + .todo_flags_start = 0,
110518 + .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
110519 + }
110520 +};
110521 +
110522 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
110523 +{
110524 + tree fntype;
110525 +
110526 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
110527 +
110528 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
110529 + fntype = build_function_type_list(void_type_node,
110530 + const_char_ptr_type_node,
110531 + unsigned_type_node,
110532 + const_char_ptr_type_node,
110533 + const_char_ptr_type_node,
110534 + NULL_TREE);
110535 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
110536 +
110537 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
110538 + TREE_PUBLIC(report_size_overflow_decl) = 1;
110539 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
110540 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
110541 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
110542 +}
110543 +
110544 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110545 +{
110546 + int i;
110547 + const char * const plugin_name = plugin_info->base_name;
110548 + const int argc = plugin_info->argc;
110549 + const struct plugin_argument * const argv = plugin_info->argv;
110550 + bool enable = true;
110551 +
110552 + struct register_pass_info size_overflow_pass_info = {
110553 + .pass = &size_overflow_pass.pass,
110554 + .reference_pass_name = "ssa",
110555 + .ref_pass_instance_number = 1,
110556 + .pos_op = PASS_POS_INSERT_AFTER
110557 + };
110558 +
110559 + if (!plugin_default_version_check(version, &gcc_version)) {
110560 + error(G_("incompatible gcc/plugin versions"));
110561 + return 1;
110562 + }
110563 +
110564 + for (i = 0; i < argc; ++i) {
110565 + if (!strcmp(argv[i].key, "no-size-overflow")) {
110566 + enable = false;
110567 + continue;
110568 + }
110569 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110570 + }
110571 +
110572 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
110573 + if (enable) {
110574 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
110575 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
110576 + }
110577 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110578 +
110579 + return 0;
110580 +}
110581 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
110582 new file mode 100644
110583 index 0000000..ac2901e
110584 --- /dev/null
110585 +++ b/tools/gcc/stackleak_plugin.c
110586 @@ -0,0 +1,327 @@
110587 +/*
110588 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
110589 + * Licensed under the GPL v2
110590 + *
110591 + * Note: the choice of the license means that the compilation process is
110592 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110593 + * but for the kernel it doesn't matter since it doesn't link against
110594 + * any of the gcc libraries
110595 + *
110596 + * gcc plugin to help implement various PaX features
110597 + *
110598 + * - track lowest stack pointer
110599 + *
110600 + * TODO:
110601 + * - initialize all local variables
110602 + *
110603 + * BUGS:
110604 + * - none known
110605 + */
110606 +#include "gcc-plugin.h"
110607 +#include "config.h"
110608 +#include "system.h"
110609 +#include "coretypes.h"
110610 +#include "tree.h"
110611 +#include "tree-pass.h"
110612 +#include "flags.h"
110613 +#include "intl.h"
110614 +#include "toplev.h"
110615 +#include "plugin.h"
110616 +//#include "expr.h" where are you...
110617 +#include "diagnostic.h"
110618 +#include "plugin-version.h"
110619 +#include "tm.h"
110620 +#include "function.h"
110621 +#include "basic-block.h"
110622 +#include "gimple.h"
110623 +#include "rtl.h"
110624 +#include "emit-rtl.h"
110625 +
110626 +#if BUILDING_GCC_VERSION >= 4008
110627 +#define TODO_dump_func 0
110628 +#endif
110629 +
110630 +extern void print_gimple_stmt(FILE *, gimple, int, int);
110631 +
110632 +int plugin_is_GPL_compatible;
110633 +
110634 +static int track_frame_size = -1;
110635 +static const char track_function[] = "pax_track_stack";
110636 +static const char check_function[] = "pax_check_alloca";
110637 +static bool init_locals;
110638 +
110639 +static struct plugin_info stackleak_plugin_info = {
110640 + .version = "201302112000",
110641 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
110642 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
110643 +};
110644 +
110645 +static bool gate_stackleak_track_stack(void);
110646 +static unsigned int execute_stackleak_tree_instrument(void);
110647 +static unsigned int execute_stackleak_final(void);
110648 +
110649 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
110650 + .pass = {
110651 + .type = GIMPLE_PASS,
110652 + .name = "stackleak_tree_instrument",
110653 +#if BUILDING_GCC_VERSION >= 4008
110654 + .optinfo_flags = OPTGROUP_NONE,
110655 +#endif
110656 + .gate = gate_stackleak_track_stack,
110657 + .execute = execute_stackleak_tree_instrument,
110658 + .sub = NULL,
110659 + .next = NULL,
110660 + .static_pass_number = 0,
110661 + .tv_id = TV_NONE,
110662 + .properties_required = PROP_gimple_leh | PROP_cfg,
110663 + .properties_provided = 0,
110664 + .properties_destroyed = 0,
110665 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
110666 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
110667 + }
110668 +};
110669 +
110670 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
110671 + .pass = {
110672 + .type = RTL_PASS,
110673 + .name = "stackleak_final",
110674 +#if BUILDING_GCC_VERSION >= 4008
110675 + .optinfo_flags = OPTGROUP_NONE,
110676 +#endif
110677 + .gate = gate_stackleak_track_stack,
110678 + .execute = execute_stackleak_final,
110679 + .sub = NULL,
110680 + .next = NULL,
110681 + .static_pass_number = 0,
110682 + .tv_id = TV_NONE,
110683 + .properties_required = 0,
110684 + .properties_provided = 0,
110685 + .properties_destroyed = 0,
110686 + .todo_flags_start = 0,
110687 + .todo_flags_finish = TODO_dump_func
110688 + }
110689 +};
110690 +
110691 +static bool gate_stackleak_track_stack(void)
110692 +{
110693 + return track_frame_size >= 0;
110694 +}
110695 +
110696 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
110697 +{
110698 + gimple check_alloca;
110699 + tree fntype, fndecl, alloca_size;
110700 +
110701 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
110702 + fndecl = build_fn_decl(check_function, fntype);
110703 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110704 +
110705 + // insert call to void pax_check_alloca(unsigned long size)
110706 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
110707 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
110708 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
110709 +}
110710 +
110711 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
110712 +{
110713 + gimple track_stack;
110714 + tree fntype, fndecl;
110715 +
110716 + fntype = build_function_type_list(void_type_node, NULL_TREE);
110717 + fndecl = build_fn_decl(track_function, fntype);
110718 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110719 +
110720 + // insert call to void pax_track_stack(void)
110721 + track_stack = gimple_build_call(fndecl, 0);
110722 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
110723 +}
110724 +
110725 +#if BUILDING_GCC_VERSION == 4005
110726 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
110727 +{
110728 + tree fndecl;
110729 +
110730 + if (!is_gimple_call(stmt))
110731 + return false;
110732 + fndecl = gimple_call_fndecl(stmt);
110733 + if (!fndecl)
110734 + return false;
110735 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
110736 + return false;
110737 +// print_node(stderr, "pax", fndecl, 4);
110738 + return DECL_FUNCTION_CODE(fndecl) == code;
110739 +}
110740 +#endif
110741 +
110742 +static bool is_alloca(gimple stmt)
110743 +{
110744 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
110745 + return true;
110746 +
110747 +#if BUILDING_GCC_VERSION >= 4007
110748 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
110749 + return true;
110750 +#endif
110751 +
110752 + return false;
110753 +}
110754 +
110755 +static unsigned int execute_stackleak_tree_instrument(void)
110756 +{
110757 + basic_block bb, entry_bb;
110758 + bool prologue_instrumented = false, is_leaf = true;
110759 +
110760 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
110761 +
110762 + // 1. loop through BBs and GIMPLE statements
110763 + FOR_EACH_BB(bb) {
110764 + gimple_stmt_iterator gsi;
110765 +
110766 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110767 + gimple stmt;
110768 +
110769 + stmt = gsi_stmt(gsi);
110770 +
110771 + if (is_gimple_call(stmt))
110772 + is_leaf = false;
110773 +
110774 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
110775 + if (!is_alloca(stmt))
110776 + continue;
110777 +
110778 + // 2. insert stack overflow check before each __builtin_alloca call
110779 + stackleak_check_alloca(&gsi);
110780 +
110781 + // 3. insert track call after each __builtin_alloca call
110782 + stackleak_add_instrumentation(&gsi);
110783 + if (bb == entry_bb)
110784 + prologue_instrumented = true;
110785 + }
110786 + }
110787 +
110788 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
110789 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
110790 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
110791 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
110792 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
110793 + return 0;
110794 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
110795 + return 0;
110796 +
110797 + // 4. insert track call at the beginning
110798 + if (!prologue_instrumented) {
110799 + gimple_stmt_iterator gsi;
110800 +
110801 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110802 + if (dom_info_available_p(CDI_DOMINATORS))
110803 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110804 + gsi = gsi_start_bb(bb);
110805 + stackleak_add_instrumentation(&gsi);
110806 + }
110807 +
110808 + return 0;
110809 +}
110810 +
110811 +static unsigned int execute_stackleak_final(void)
110812 +{
110813 + rtx insn, next;
110814 +
110815 + if (cfun->calls_alloca)
110816 + return 0;
110817 +
110818 + // keep calls only if function frame is big enough
110819 + if (get_frame_size() >= track_frame_size)
110820 + return 0;
110821 +
110822 + // 1. find pax_track_stack calls
110823 + for (insn = get_insns(); insn; insn = next) {
110824 + // 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))
110825 + rtx body;
110826 +
110827 + next = NEXT_INSN(insn);
110828 + if (!CALL_P(insn))
110829 + continue;
110830 + body = PATTERN(insn);
110831 + if (GET_CODE(body) != CALL)
110832 + continue;
110833 + body = XEXP(body, 0);
110834 + if (GET_CODE(body) != MEM)
110835 + continue;
110836 + body = XEXP(body, 0);
110837 + if (GET_CODE(body) != SYMBOL_REF)
110838 + continue;
110839 + if (strcmp(XSTR(body, 0), track_function))
110840 + continue;
110841 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110842 + // 2. delete call
110843 + delete_insn_and_edges(insn);
110844 +#if BUILDING_GCC_VERSION >= 4007
110845 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
110846 + insn = next;
110847 + next = NEXT_INSN(insn);
110848 + delete_insn_and_edges(insn);
110849 + }
110850 +#endif
110851 + }
110852 +
110853 +// print_simple_rtl(stderr, get_insns());
110854 +// print_rtl(stderr, get_insns());
110855 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110856 +
110857 + return 0;
110858 +}
110859 +
110860 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110861 +{
110862 + const char * const plugin_name = plugin_info->base_name;
110863 + const int argc = plugin_info->argc;
110864 + const struct plugin_argument * const argv = plugin_info->argv;
110865 + int i;
110866 + struct register_pass_info stackleak_tree_instrument_pass_info = {
110867 + .pass = &stackleak_tree_instrument_pass.pass,
110868 +// .reference_pass_name = "tree_profile",
110869 + .reference_pass_name = "optimized",
110870 + .ref_pass_instance_number = 1,
110871 + .pos_op = PASS_POS_INSERT_BEFORE
110872 + };
110873 + struct register_pass_info stackleak_final_pass_info = {
110874 + .pass = &stackleak_final_rtl_opt_pass.pass,
110875 + .reference_pass_name = "final",
110876 + .ref_pass_instance_number = 1,
110877 + .pos_op = PASS_POS_INSERT_BEFORE
110878 + };
110879 +
110880 + if (!plugin_default_version_check(version, &gcc_version)) {
110881 + error(G_("incompatible gcc/plugin versions"));
110882 + return 1;
110883 + }
110884 +
110885 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
110886 +
110887 + for (i = 0; i < argc; ++i) {
110888 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
110889 + if (!argv[i].value) {
110890 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110891 + continue;
110892 + }
110893 + track_frame_size = atoi(argv[i].value);
110894 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
110895 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110896 + continue;
110897 + }
110898 + if (!strcmp(argv[i].key, "initialize-locals")) {
110899 + if (argv[i].value) {
110900 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110901 + continue;
110902 + }
110903 + init_locals = true;
110904 + continue;
110905 + }
110906 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110907 + }
110908 +
110909 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
110910 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
110911 +
110912 + return 0;
110913 +}
110914 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
110915 new file mode 100644
110916 index 0000000..4fae911
110917 --- /dev/null
110918 +++ b/tools/gcc/structleak_plugin.c
110919 @@ -0,0 +1,277 @@
110920 +/*
110921 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
110922 + * Licensed under the GPL v2
110923 + *
110924 + * Note: the choice of the license means that the compilation process is
110925 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110926 + * but for the kernel it doesn't matter since it doesn't link against
110927 + * any of the gcc libraries
110928 + *
110929 + * gcc plugin to forcibly initialize certain local variables that could
110930 + * otherwise leak kernel stack to userland if they aren't properly initialized
110931 + * by later code
110932 + *
110933 + * Homepage: http://pax.grsecurity.net/
110934 + *
110935 + * Usage:
110936 + * $ # for 4.5/4.6/C based 4.7
110937 + * $ 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
110938 + * $ # for C++ based 4.7/4.8+
110939 + * $ 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
110940 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
110941 + *
110942 + * TODO: eliminate redundant initializers
110943 + * increase type coverage
110944 + */
110945 +
110946 +#include "gcc-plugin.h"
110947 +#include "config.h"
110948 +#include "system.h"
110949 +#include "coretypes.h"
110950 +#include "tree.h"
110951 +#include "tree-pass.h"
110952 +#include "intl.h"
110953 +#include "plugin-version.h"
110954 +#include "tm.h"
110955 +#include "toplev.h"
110956 +#include "function.h"
110957 +#include "tree-flow.h"
110958 +#include "plugin.h"
110959 +#include "gimple.h"
110960 +#include "diagnostic.h"
110961 +#include "cfgloop.h"
110962 +#include "langhooks.h"
110963 +
110964 +#if BUILDING_GCC_VERSION >= 4008
110965 +#define TODO_dump_func 0
110966 +#endif
110967 +
110968 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110969 +
110970 +// unused type flag in all versions 4.5-4.8
110971 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
110972 +
110973 +int plugin_is_GPL_compatible;
110974 +void debug_gimple_stmt(gimple gs);
110975 +
110976 +static struct plugin_info structleak_plugin_info = {
110977 + .version = "201304082245",
110978 + .help = "disable\tdo not activate plugin\n",
110979 +};
110980 +
110981 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
110982 +{
110983 + *no_add_attrs = true;
110984 +
110985 + // check for types? for now accept everything linux has to offer
110986 + if (TREE_CODE(*node) != FIELD_DECL)
110987 + return NULL_TREE;
110988 +
110989 + *no_add_attrs = false;
110990 + return NULL_TREE;
110991 +}
110992 +
110993 +static struct attribute_spec user_attr = {
110994 + .name = "user",
110995 + .min_length = 0,
110996 + .max_length = 0,
110997 + .decl_required = false,
110998 + .type_required = false,
110999 + .function_type_required = false,
111000 + .handler = handle_user_attribute,
111001 +#if BUILDING_GCC_VERSION >= 4007
111002 + .affects_type_identity = true
111003 +#endif
111004 +};
111005 +
111006 +static void register_attributes(void *event_data, void *data)
111007 +{
111008 + register_attribute(&user_attr);
111009 +// register_attribute(&force_attr);
111010 +}
111011 +
111012 +static tree get_field_type(tree field)
111013 +{
111014 + return strip_array_types(TREE_TYPE(field));
111015 +}
111016 +
111017 +static bool is_userspace_type(tree type)
111018 +{
111019 + tree field;
111020 +
111021 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
111022 + tree fieldtype = get_field_type(field);
111023 + enum tree_code code = TREE_CODE(fieldtype);
111024 +
111025 + if (code == RECORD_TYPE || code == UNION_TYPE)
111026 + if (is_userspace_type(fieldtype))
111027 + return true;
111028 +
111029 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
111030 + return true;
111031 + }
111032 + return false;
111033 +}
111034 +
111035 +static void finish_type(void *event_data, void *data)
111036 +{
111037 + tree type = (tree)event_data;
111038 +
111039 + if (TYPE_USERSPACE(type))
111040 + return;
111041 +
111042 + if (is_userspace_type(type))
111043 + TYPE_USERSPACE(type) = 1;
111044 +}
111045 +
111046 +static void initialize(tree var)
111047 +{
111048 + basic_block bb;
111049 + gimple_stmt_iterator gsi;
111050 + tree initializer;
111051 + gimple init_stmt;
111052 +
111053 + // this is the original entry bb before the forced split
111054 + // TODO: check further BBs in case more splits occured before us
111055 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
111056 +
111057 + // first check if the variable is already initialized, warn otherwise
111058 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
111059 + gimple stmt = gsi_stmt(gsi);
111060 + tree rhs1;
111061 +
111062 + // we're looking for an assignment of a single rhs...
111063 + if (!gimple_assign_single_p(stmt))
111064 + continue;
111065 + rhs1 = gimple_assign_rhs1(stmt);
111066 +#if BUILDING_GCC_VERSION >= 4007
111067 + // ... of a non-clobbering expression...
111068 + if (TREE_CLOBBER_P(rhs1))
111069 + continue;
111070 +#endif
111071 + // ... to our variable...
111072 + if (gimple_get_lhs(stmt) != var)
111073 + continue;
111074 + // if it's an initializer then we're good
111075 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
111076 + return;
111077 + }
111078 +
111079 + // these aren't the 0days you're looking for
111080 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
111081 +
111082 + // build the initializer expression
111083 + initializer = build_constructor(TREE_TYPE(var), NULL);
111084 +
111085 + // build the initializer stmt
111086 + init_stmt = gimple_build_assign(var, initializer);
111087 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
111088 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
111089 + update_stmt(init_stmt);
111090 +}
111091 +
111092 +static unsigned int handle_function(void)
111093 +{
111094 + basic_block bb;
111095 + unsigned int ret = 0;
111096 + tree var;
111097 +
111098 +#if BUILDING_GCC_VERSION == 4005
111099 + tree vars;
111100 +#else
111101 + unsigned int i;
111102 +#endif
111103 +
111104 + // split the first bb where we can put the forced initializers
111105 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
111106 + if (dom_info_available_p(CDI_DOMINATORS))
111107 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
111108 +
111109 + // enumarate all local variables and forcibly initialize our targets
111110 +#if BUILDING_GCC_VERSION == 4005
111111 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
111112 + var = TREE_VALUE(vars);
111113 +#else
111114 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
111115 +#endif
111116 + tree type = TREE_TYPE(var);
111117 +
111118 + gcc_assert(DECL_P(var));
111119 + if (!auto_var_in_fn_p(var, current_function_decl))
111120 + continue;
111121 +
111122 + // only care about structure types
111123 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
111124 + continue;
111125 +
111126 + // if the type is of interest, examine the variable
111127 + if (TYPE_USERSPACE(type))
111128 + initialize(var);
111129 + }
111130 +
111131 + return ret;
111132 +}
111133 +
111134 +static struct gimple_opt_pass structleak_pass = {
111135 + .pass = {
111136 + .type = GIMPLE_PASS,
111137 + .name = "structleak",
111138 +#if BUILDING_GCC_VERSION >= 4008
111139 + .optinfo_flags = OPTGROUP_NONE,
111140 +#endif
111141 + .gate = NULL,
111142 + .execute = handle_function,
111143 + .sub = NULL,
111144 + .next = NULL,
111145 + .static_pass_number = 0,
111146 + .tv_id = TV_NONE,
111147 + .properties_required = PROP_cfg,
111148 + .properties_provided = 0,
111149 + .properties_destroyed = 0,
111150 + .todo_flags_start = 0,
111151 + .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
111152 + }
111153 +};
111154 +
111155 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
111156 +{
111157 + int i;
111158 + const char * const plugin_name = plugin_info->base_name;
111159 + const int argc = plugin_info->argc;
111160 + const struct plugin_argument * const argv = plugin_info->argv;
111161 + bool enable = true;
111162 +
111163 + struct register_pass_info structleak_pass_info = {
111164 + .pass = &structleak_pass.pass,
111165 + .reference_pass_name = "ssa",
111166 + .ref_pass_instance_number = 1,
111167 + .pos_op = PASS_POS_INSERT_AFTER
111168 + };
111169 +
111170 + if (!plugin_default_version_check(version, &gcc_version)) {
111171 + error(G_("incompatible gcc/plugin versions"));
111172 + return 1;
111173 + }
111174 +
111175 + if (strcmp(lang_hooks.name, "GNU C")) {
111176 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
111177 + enable = false;
111178 + }
111179 +
111180 + for (i = 0; i < argc; ++i) {
111181 + if (!strcmp(argv[i].key, "disable")) {
111182 + enable = false;
111183 + continue;
111184 + }
111185 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
111186 + }
111187 +
111188 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
111189 + if (enable) {
111190 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
111191 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
111192 + }
111193 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
111194 +
111195 + return 0;
111196 +}
111197 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
111198 index 280dd82..077b427 100644
111199 --- a/tools/lib/lk/Makefile
111200 +++ b/tools/lib/lk/Makefile
111201 @@ -28,7 +28,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
111202
111203 LIBFILE = liblk.a
111204
111205 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
111206 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
111207 EXTLIBS = -lelf -lpthread -lrt -lm
111208 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
111209 ALL_LDFLAGS = $(LDFLAGS)
111210 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
111211 index 6789d78..4afd019e 100644
111212 --- a/tools/perf/util/include/asm/alternative-asm.h
111213 +++ b/tools/perf/util/include/asm/alternative-asm.h
111214 @@ -5,4 +5,7 @@
111215
111216 #define altinstruction_entry #
111217
111218 + .macro pax_force_retaddr rip=0, reload=0
111219 + .endm
111220 +
111221 #endif
111222 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
111223 index 96b919d..c49bb74 100644
111224 --- a/tools/perf/util/include/linux/compiler.h
111225 +++ b/tools/perf/util/include/linux/compiler.h
111226 @@ -18,4 +18,12 @@
111227 #define __force
111228 #endif
111229
111230 +#ifndef __size_overflow
111231 +# define __size_overflow(...)
111232 +#endif
111233 +
111234 +#ifndef __intentional_overflow
111235 +# define __intentional_overflow(...)
111236 +#endif
111237 +
111238 #endif
111239 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
111240 index 1580dd4..5627b5b 100644
111241 --- a/virt/kvm/kvm_main.c
111242 +++ b/virt/kvm/kvm_main.c
111243 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
111244
111245 static cpumask_var_t cpus_hardware_enabled;
111246 static int kvm_usage_count = 0;
111247 -static atomic_t hardware_enable_failed;
111248 +static atomic_unchecked_t hardware_enable_failed;
111249
111250 struct kmem_cache *kvm_vcpu_cache;
111251 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
111252
111253 -static __read_mostly struct preempt_ops kvm_preempt_ops;
111254 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
111255 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
111256 +static struct preempt_ops kvm_preempt_ops = {
111257 + .sched_in = kvm_sched_in,
111258 + .sched_out = kvm_sched_out,
111259 +};
111260
111261 struct dentry *kvm_debugfs_dir;
111262
111263 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
111264 /* We can read the guest memory with __xxx_user() later on. */
111265 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
111266 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
111267 - !access_ok(VERIFY_WRITE,
111268 + !__access_ok(VERIFY_WRITE,
111269 (void __user *)(unsigned long)mem->userspace_addr,
111270 mem->memory_size)))
111271 goto out;
111272 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
111273 return 0;
111274 }
111275
111276 -static struct file_operations kvm_vcpu_fops = {
111277 +static file_operations_no_const kvm_vcpu_fops __read_only = {
111278 .release = kvm_vcpu_release,
111279 .unlocked_ioctl = kvm_vcpu_ioctl,
111280 #ifdef CONFIG_COMPAT
111281 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
111282 return 0;
111283 }
111284
111285 -static struct file_operations kvm_vm_fops = {
111286 +static file_operations_no_const kvm_vm_fops __read_only = {
111287 .release = kvm_vm_release,
111288 .unlocked_ioctl = kvm_vm_ioctl,
111289 #ifdef CONFIG_COMPAT
111290 @@ -2662,7 +2667,7 @@ out:
111291 return r;
111292 }
111293
111294 -static struct file_operations kvm_chardev_ops = {
111295 +static file_operations_no_const kvm_chardev_ops __read_only = {
111296 .unlocked_ioctl = kvm_dev_ioctl,
111297 .compat_ioctl = kvm_dev_ioctl,
111298 .llseek = noop_llseek,
111299 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
111300
111301 if (r) {
111302 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
111303 - atomic_inc(&hardware_enable_failed);
111304 + atomic_inc_unchecked(&hardware_enable_failed);
111305 printk(KERN_INFO "kvm: enabling virtualization on "
111306 "CPU%d failed\n", cpu);
111307 }
111308 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
111309
111310 kvm_usage_count++;
111311 if (kvm_usage_count == 1) {
111312 - atomic_set(&hardware_enable_failed, 0);
111313 + atomic_set_unchecked(&hardware_enable_failed, 0);
111314 on_each_cpu(hardware_enable_nolock, NULL, 1);
111315
111316 - if (atomic_read(&hardware_enable_failed)) {
111317 + if (atomic_read_unchecked(&hardware_enable_failed)) {
111318 hardware_disable_all_nolock();
111319 r = -EBUSY;
111320 }
111321 @@ -3100,7 +3105,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
111322 kvm_arch_vcpu_put(vcpu);
111323 }
111324
111325 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111326 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111327 struct module *module)
111328 {
111329 int r;
111330 @@ -3147,7 +3152,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111331 if (!vcpu_align)
111332 vcpu_align = __alignof__(struct kvm_vcpu);
111333 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
111334 - 0, NULL);
111335 + SLAB_USERCOPY, NULL);
111336 if (!kvm_vcpu_cache) {
111337 r = -ENOMEM;
111338 goto out_free_3;
111339 @@ -3157,9 +3162,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111340 if (r)
111341 goto out_free;
111342
111343 + pax_open_kernel();
111344 kvm_chardev_ops.owner = module;
111345 kvm_vm_fops.owner = module;
111346 kvm_vcpu_fops.owner = module;
111347 + pax_close_kernel();
111348
111349 r = misc_register(&kvm_dev);
111350 if (r) {
111351 @@ -3169,9 +3176,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111352
111353 register_syscore_ops(&kvm_syscore_ops);
111354
111355 - kvm_preempt_ops.sched_in = kvm_sched_in;
111356 - kvm_preempt_ops.sched_out = kvm_sched_out;
111357 -
111358 r = kvm_init_debug();
111359 if (r) {
111360 printk(KERN_ERR "kvm: create debugfs files failed\n");